Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
consolidate resource nodes with just one language resource
Browse files Browse the repository at this point in the history
  • Loading branch information
zodiacon committed May 10, 2022
1 parent 872828b commit d335f8e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TotalPE/IconGroupView.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CIconGroupView :

BEGIN_MSG_MAP(CIconGroupView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
//MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
CHAIN_MSG_MAP(CScrollImpl<CIconGroupView>)
CHAIN_MSG_MAP(CView)
Expand Down
1 change: 1 addition & 0 deletions TotalPE/Interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum class TreeItemType : size_t {
ResourceName,
ResourceLnaguage,
CLR = 1 << 22,
Language = 1LL << 62,
Resource = 1LL << 63,
};
DEFINE_ENUM_FLAG_OPERATORS(TreeItemType);
Expand Down
9 changes: 8 additions & 1 deletion TotalPE/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,25 @@ void CMainFrame::ParseResources(HTREEITEM hRoot, pe_resource_directory_entry con
name = std::format(L"#{}", node.get_id());
type = !name.empty() ? TreeItemWithIndex(TreeItemType::ResourceTypeName, node.get_id()) : TreeItemWithIndex(TreeItemType::Resource, node.get_id());
icon = ResourceTypeIconIndex(node.get_id());

}
else if (depth == 1) {
type = TreeItemType::ResourceName;
int dummy;
m_Tree.GetItemImage(hRoot, icon, dummy);
if (node.get_resource_directory().get_entry_list().size() == 1) {
// add the only resource, no need for another level
auto& child = node.get_resource_directory().get_entry_list()[0];
name += L" (" + PEStrings::LanguageToString(child.get_id()) + L")";
type = static_cast<TreeItemType>((DWORD_PTR)&child) | TreeItemType::Resource | TreeItemType::Language;
}
}
else if (depth == 2) {
ATLASSERT(node.is_includes_data());
type = static_cast<TreeItemType>((DWORD_PTR)&node) | TreeItemType::Resource;
}
hRoot = InsertTreeItem(m_Tree, name.c_str(), icon, type, hRoot, TVI_SORT);
if (depth == 1 && (type & TreeItemType::Language) == TreeItemType::Language)
return;

if (!node.is_includes_data()) {
for (auto& child : node.get_resource_directory().get_entry_list())
Expand Down
5 changes: 3 additions & 2 deletions TotalPE/ViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ HWND ViewManager::CreateOrGetView(TreeItemType type, HWND hParent, pe_image_full
}
if (!hView) {
if ((type & TreeItemType::Resource) == TreeItemType::Resource) {
auto node = (pe_resource_directory_entry*)(DWORD_PTR(type) & ((1LL << 62) - 1));
auto combined = (type & TreeItemType::Language) == TreeItemType::Language;
auto node = (pe_resource_directory_entry*)(vtype & ((1LL << 61) - 1));
auto& data = node->get_data_entry().get_data();
auto typeName = m_pFrame->GetTreeItemText(2);
auto typeName = m_pFrame->GetTreeItemText(combined ? 1 : 2);
if (typeName == L"Manifest" || typeName == L"HTML") {
CStringA xml((PCSTR)data.data(), (int)data.size());
auto view = new CTextView(m_pFrame, pe);
Expand Down

0 comments on commit d335f8e

Please sign in to comment.