Skip to content

Commit

Permalink
### 2023-11-25 - 1.6
Browse files Browse the repository at this point in the history
1、增加添加到系统右键菜单(由xuxian02092213实现,感谢支持)
  • Loading branch information
JelinYao committed Nov 25, 2023
1 parent 2bd8ab8 commit e68cd67
Show file tree
Hide file tree
Showing 16 changed files with 342 additions and 174 deletions.
7 changes: 7 additions & 0 deletions Debug/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<config>
<language selected="0">
<item text="中文-简体">Chinese</item>
<item text="English">English</item>
</language>
</config>
19 changes: 19 additions & 0 deletions Debug/language/Chinese.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<resources>
<string id="File">文件</string>
<string id="View">视图</string>
<string id="Language">语言</string>
<string id="Help">帮助</string>
<string id="OpenFile">打开文件(&O)</string>
<string id="CloseFile">关闭文件(&C)</string>
<string id="Exit">退出(&E)</string>
<string id="ExpendAll">展开所有(&E)</string>
<string id="CollapseAll">收拢所有(&C)</string>
<string id="About">关于我们(&A)</string>
<string id="OpenInvalidFile">请打开有效的PE文件</string>
<string id="TipTitle">提示</string>
<string id="ErrorTitle">错误</string>
<string id="MsgDragMuiltipleFiles">不支持拖入多个文件</string>
<string id="MsgCallFailed">调用失败,错误码:</string>
<string id="AddToSystemMenu">添加到系统右键菜单</string>
</resources>
19 changes: 19 additions & 0 deletions Debug/language/English.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<resources>
<string id="File">File</string>
<string id="View">View</string>
<string id="Language">Language</string>
<string id="Help">Help</string>
<string id="OpenFile">Open file(&O)</string>
<string id="CloseFile">Close file(&C)</string>
<string id="Exit">Exit(&E)</string>
<string id="ExpendAll">Expend all(&E)</string>
<string id="CollapseAll">Collapse all(&C)</string>
<string id="About">About(&A)</string>
<string id="OpenInvalidFile">Invalid windows pe file</string>
<string id="TipTitle">info</string>
<string id="ErrorTitle">error</string>
<string id="MsgDragMuiltipleFiles">Drag multiple files is not supported</string>
<string id="MsgCallFailed">execute failed,error code: </string>
<string id="AddToSystemMenu">add to system menu</string>
</resources>
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,38 @@ Dependency Walker在Win10上面太卡了,受不了了,自己开发一个替
Dependency Walker is too stuck on Windows 10 , so I developed a replacement myself.

## 更新记录
### 2023-11-25 - 1.6
1、增加添加到系统右键菜单(由xuxian02092213实现,感谢支持)

### 2023年1月31日 - 1.5
1、解决加载64位PE文件导入表显示不全的bug

### 2022年1月11日 - 1.4
1、支持多语言切换

### 2021年11月15日 - 1.3.0.5
1、解决64位pe文件加载出错的问题
2、编译64位Dependency

### 2021年6月27日 - 1.2.0.4
1、修复部分dll加载闪退的问题
2、支持拖动调整控件位置

### 2021年5月10日 - 1.1.0.3
1、导出函数表添加右键菜单,支持复制函数名和查询函数
2、修复bug

### 2021年5月8日 - 1.0.0.2
1、修复展开\收拢所有节点卡死的问题
2、增加打开文件校验,只允许打开PE文件
3、支持拖动文件

### 2021年5月10日 - 1.1.0.3
1、导出函数表添加右键菜单,支持复制函数名和查询函数
2、修复bug

### 2021年6月27日 - 1.2.0.4
1、修复部分dll加载闪退的问题
2、支持拖动调整控件位置

### 2021年11月15日 - 1.3.0.5
1、解决64位pe文件加载出错的问题
2、编译64位Dependency

### 2022年1月11日 - 1.4
1、支持多语言切换

### 2023年1月31日 - 1.5
1、解决加载64位PE文件导入表显示不全的bug



## 程序截图

Expand Down
1 change: 1 addition & 0 deletions Release/language/Chinese.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<string id="ErrorTitle">错误</string>
<string id="MsgDragMuiltipleFiles">不支持拖入多个文件</string>
<string id="MsgCallFailed">调用失败,错误码:</string>
<string id="AddToSystemMenu">添加到系统右键菜单</string>
</resources>
1 change: 1 addition & 0 deletions Release/language/English.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<string id="ErrorTitle">error</string>
<string id="MsgDragMuiltipleFiles">Drag multiple files is not supported</string>
<string id="MsgCallFailed">execute failed,error code: </string>
<string id="AddToSystemMenu">add to system menu</string>
</resources>
1 change: 1 addition & 0 deletions dependency/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace language {
static CONSTEXPR char* kExpendAll = "ExpendAll";
static CONSTEXPR char* kCollapseAll = "CollapseAll";
static CONSTEXPR char* kAbout = "About";
static CONSTEXPR char* kAddToSystemMenu = "AddToSystemMenu";
static CONSTEXPR char* kOpenInvalidFile = "OpenInvalidFile";
static CONSTEXPR char* kTipTitle = "TipTitle";
static CONSTEXPR char* kErrorTitle = "ErrorTitle";
Expand Down
87 changes: 80 additions & 7 deletions dependency/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ResourceMgr.h"
#include "Language.h"
#include "MenuDefine.h"
#include "RegUtils.h"

#ifdef _WIN64
constexpr wchar_t kDefaultWindowText[] = L"dependency64";
Expand Down Expand Up @@ -49,6 +50,10 @@ LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam
HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
SetIcon(hIconSmall, FALSE);

hAccel = AtlLoadAccelerators(IDR_MAINFRAME);

::SetWindowText(m_hWnd, kDefaultWindowText);

// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
Expand All @@ -59,6 +64,7 @@ LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam
left_spliter_cursor = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE));
right_spliter_cursor = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS));
tree_view_ = ::GetDlgItem(m_hWnd, IDC_TREE1);
hwnd_dep_path_ = ::GetDlgItem(m_hWnd, IDC_STATIC_PATH);
list_view_export_ = ::GetDlgItem(m_hWnd, IDC_LIST1);
list_view_use_ = ::GetDlgItem(m_hWnd, IDC_LIST2);
list_view_ctrl_export_ = std::make_unique<CListViewCtrl>(list_view_export_);
Expand All @@ -68,11 +74,16 @@ LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam
::DragAcceptFiles(m_hWnd, TRUE);
RECT rc;
::GetClientRect(m_hWnd, &rc);
left_spliter_xpos_ = int((rc.right - rc.left) * 0.3);
right_spliter_ypos = int((rc.bottom - rc.top) * 0.24);
left_spliter_xpos_ = int((rc.right - rc.left)*0.3);
right_spliter_ypos = int((rc.bottom - rc.top)*0.24);
// init resource
ResourceMgr::Instance()->Init(this);
SetWindowTitle(L"");

if (__argc > 1) {
std::wstring file = __wargv[1];
OpenFile(file);
}

return TRUE;
}

Expand Down Expand Up @@ -206,6 +217,45 @@ void CMainDlg::OnMenuAbout()
dlg.DoModal();
}

void CMainDlg::OnAddRightMenuContext()
{
HKEY hKey = 0;
CString str0 = _T("");
// comfile/cplfile/drvfile/srcfile/sysfile
TCHAR* arr[] = { _T("exefile") ,
_T("dllfile"),
_T("ocxfile"),
_T("comfile"),
_T("sysfile"),
nullptr,
};
int pos = 0;
TCHAR szMod[MAX_PATH] = { 0 };
::GetModuleFileName(nullptr, szMod, MAX_PATH);
CString strValue = szMod;
strValue += _T(" %1");

BOOL bWow64 = FALSE;
BOOL bRet = ::IsWow64Process(::GetCurrentProcess(), &bWow64);

while (true) {
if (!arr[pos]) break;
CString str;
if (bWow64) {
str.Format(_T("HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies\\"), arr[pos]);
}
else {
str.Format(_T("HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies(x64)\\"), arr[pos]);
}
CRegUtils::SplitKey(str, hKey, str0);
CRegUtils::CreateKey(hKey, str0);
str0 += _T("\\command");
CRegUtils::CreateKey(hKey, str0);
CRegUtils::SetString(hKey, str0, _T(""), strValue);
++pos;
}
}

void ExpendAllItem(HWND tree_view, HTREEITEM item, UINT code) {
if (item == NULL) {
return;
Expand Down Expand Up @@ -235,9 +285,17 @@ void CMainDlg::OnMenuCollapseAll()

void CMainDlg::OnMenuListItemCopy()
{
int select_index = (int)::SendMessage(list_view_export_, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
CString item_text;
list_view_ctrl_export_->GetItemText(select_index, 2, item_text.GetBufferSetLength(128), 128);
int pos = (int)::SendMessage(list_view_export_, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
while (pos >= 0) {
CString item;
list_view_ctrl_export_->GetItemText(pos, 2, item.GetBufferSetLength(128), 128);
if (!item.IsEmpty()) {
item_text += item;
item_text += _T("\n");
}
pos = (int)::SendMessage(list_view_export_, LVM_GETNEXTITEM, (WPARAM)pos, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
}
if (!item_text.IsEmpty()) {
CopyToClipbord(item_text.GetBuffer());
}
Expand Down Expand Up @@ -291,6 +349,10 @@ void CMainDlg::OnSwitchLanguage()
HMENU subMenu = ::GetSubMenu(menu, i);
char** key = (char**)(kSubMenus[i].array);
for (int j = 0; j < kSubMenus[i].count; ++j) {
if (!key[j]) {
// 遇到分隔符菜单项,直接跳过
continue;
}
auto text = ResourceMgr::Instance()->GetText(key[j]);
if (text) {
UINT id = ::GetMenuItemID(subMenu, j);
Expand Down Expand Up @@ -334,11 +396,16 @@ LRESULT CMainDlg::OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bH
if (wParam != SIZE_MINIMIZED) {
auto width = GET_X_LPARAM(lParam);
auto height = GET_Y_LPARAM(lParam);
height -= 20;

::MoveWindow(tree_view_, 0, 0, left_spliter_xpos_ - 1, height, TRUE);
::MoveWindow(list_view_use_, left_spliter_xpos_ + 1, 0, width - left_spliter_xpos_ - 1, right_spliter_ypos - 1, TRUE);
::MoveWindow(list_view_export_, left_spliter_xpos_ + 1, right_spliter_ypos + 1,
width - left_spliter_xpos_ - 1, height - right_spliter_ypos - 1, TRUE);

RECT rcWnd;
::GetClientRect(hwnd_dep_path_, &rcWnd);
::MoveWindow(hwnd_dep_path_, 0, height - rcWnd.bottom + rcWnd.top + 20, width, rcWnd.bottom - rcWnd.top, TRUE);
}
return 0;
}
Expand All @@ -356,10 +423,15 @@ LRESULT CMainDlg::OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOO
case ID_FILE_CLOSE: OnMenuFileClose(); break;
case ID_FILE_EXIT: OnMenuExit(); break;
case ID_HELP_ABOUT: OnMenuAbout(); break;
case ID_ADD_DEFAULT_MENU: OnAddRightMenuContext(); break;
case ID_VIEW_EXPEND: OnMenuExpendAll(); break;
case ID_VIEW_COLLAPSE: OnMenuCollapseAll(); break;
case ID_LISTITEM_COPY: OnMenuListItemCopy(); break;
case ID_LISTITEM_FIND: OnMenuListItemFind(); break;
case ID_LISTITEM_COPY_ALL: {
list_view_ctrl_export_->SelectAllItems();
OnMenuListItemCopy();
}break;
default:
break;
}
Expand Down Expand Up @@ -406,7 +478,6 @@ BOOL CMainDlg::OpenFile(const std::wstring& pe_path)
is_x64_archite_ = pe.IsX64Archite();
std::list<IMAGE_IMPORT_DLL> dll_list;
bool success = is_x64_archite_ ? pe.GetImportDllsX64(dll_list) : pe.GetImportDlls(dll_list);

tree_root_item_ = AddTreeItem(TVI_ROOT, TVI_FIRST, file_name.c_str());
TREEITEM_DATA item_data;
item_data.item_text = std::move(file_name);
Expand Down Expand Up @@ -453,14 +524,15 @@ void CMainDlg::ExpendTreeItem(HTREEITEM item)
find_itor->second.read_flag = TRUE;
std::wstring pe_path;
if (!SearchDllPath(is_x64_archite_, current_pe_dir_, find_itor->second.item_text, pe_path)) {
::SetWindowText(hwnd_dep_path_, _T(""));
// 没有搜索到
return;
}
::SetWindowText(hwnd_dep_path_, pe_path.c_str());
PEHelper pe(pe_path);
std::list<IMAGE_IMPORT_DLL> dll_list;
TREEITEM_DATA item_data;
bool success = is_x64_archite_ ? pe.GetImportDllsX64(dll_list) : pe.GetImportDlls(dll_list);

if (success) {
HTREEITEM prev_item = TVI_FIRST;
for (auto itor = dll_list.begin(); itor != dll_list.end(); ++itor) {
Expand Down Expand Up @@ -543,6 +615,7 @@ LRESULT CMainDlg::OnNMRclickList1(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandl

BOOL CMainDlg::PreTranslateMessage(MSG* pMsg)
{
::TranslateAccelerator(m_hWnd, hAccel, pMsg);
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F5) {
if (!current_pe_path_.empty()) {
auto pe_path = current_pe_path_;
Expand Down
Loading

0 comments on commit e68cd67

Please sign in to comment.