Skip to content

Commit

Permalink
### 2024-4-7 - 1.7
Browse files Browse the repository at this point in the history
1、修复添加到系统右键菜单打开文件的bug(感谢xiaokaixuan)
2、增加右键菜单Icon,增加删除右键菜单(感谢xiaokaixuan)
3、程序增加管理员权限
  • Loading branch information
JelinYao committed Apr 7, 2024
1 parent d2fc45b commit 4471dae
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 52 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Dependency Walker在Win10上面太卡了,受不了了,自己开发一个替
Dependency Walker is too stuck on Windows 10 , so I developed a replacement myself.

## 更新记录
### 2024-4-7 - 1.7
1、修复添加到系统右键菜单打开文件的bug(感谢xiaokaixuan)
2、增加右键菜单Icon,增加删除右键菜单(感谢xiaokaixuan)
3、程序增加管理员权限

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

Expand Down
82 changes: 36 additions & 46 deletions dependency/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ void CMainDlg::AddUseFunctions(const std::list<IMAGE_EXPORT_FUNCTION>& function_
void CMainDlg::OnMenuFileOpen()
{
OPENFILENAME ofn = { 0 };
TCHAR szFile[MAX_PATH] = { 0 };
wchar_t szFile[MAX_PATH] = { 0 };
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = m_hWnd;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile) / sizeof(szFile[0]);
ofn.lpstrFilter = _T("可执行文件(*.exe)\0*.exe\0dll文件(*.dll)\0*.dll\0所有文件(*.*)\0*.*\0\0");
ofn.lpstrFilter = L"可执行文件(*.exe)\0*.exe\0dll文件(*.dll)\0*.dll\0所有文件(*.*)\0*.*\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
Expand Down Expand Up @@ -220,67 +220,57 @@ void CMainDlg::OnMenuAbout()
void CMainDlg::OnAddRightMenuContext()
{
HKEY hKey = 0;
CString str0 = _T("");
CString str0;
// comfile/cplfile/drvfile/srcfile/sysfile
TCHAR* arr[] = { _T("exefile") ,
_T("dllfile"),
_T("ocxfile"),
_T("comfile"),
_T("sysfile"),
nullptr,
TCHAR* arr[] = {
L"exefile",
L"dllfile",
L"ocxfile",
L"comfile",
L"sysfile",
};
int pos = 0;
TCHAR szMod[MAX_PATH] = { 0 };
::GetModuleFileName(nullptr, szMod, MAX_PATH);
CString strValue = szMod, strExe(szMod);
strValue += _T(" \"%1\"");
strValue += L" \"%1\"";

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

while (true) {
if (!arr[pos]) break;
for (auto pszfile : arr) {
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]);
}
#ifdef _WIN64
str.Format(L"HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies(x64)", pszfile);
#else
str.Format(L"HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies", pszfile);
#endif
CRegUtils::SplitKey(str, hKey, str0);
CRegUtils::CreateKey(hKey, str0);
CString strCmd(str0 + _T("\\command"));
CString strCmd(str0 + L"\\command");
CRegUtils::CreateKey(hKey, strCmd);
CRegUtils::SetString(hKey, strCmd, _T(""), strValue);
CRegUtils::SetString(hKey, str0, _T("Icon"), strExe);
++pos;
CRegUtils::SetString(hKey, strCmd, L"", strValue);
CRegUtils::SetString(hKey, str0, L"Icon", strExe);
}
}

void CMainDlg::OnDelRightMenuContext()
{
HKEY hKey = 0;
CString str0 = _T("");
CString str0;
// comfile/cplfile/drvfile/srcfile/sysfile
TCHAR* arr[] = { _T("exefile") ,
_T("dllfile"),
_T("ocxfile"),
_T("comfile"),
_T("sysfile"),
nullptr,
TCHAR* arr[] = {
L"exefile" ,
L"dllfile",
L"ocxfile",
L"comfile",
L"sysfile",
};
BOOL bWow64 = FALSE;
::IsWow64Process(::GetCurrentProcess(), &bWow64);
for (TCHAR* pszfile : arr)
{
if (!pszfile) break;

// 需要管理员权限才能删除
for (auto pszfile : arr) {
CString str;
if (bWow64) {
str.Format(_T("HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies"), pszfile);
}
else {
str.Format(_T("HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies(x64)"), pszfile);
}
#ifdef _WIN64
str.Format(L"HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies(x64)", pszfile);
#else
str.Format(L"HKEY_CLASSES_ROOT\\%s\\shell\\View Dependencies", pszfile);
#endif
CRegUtils::SplitKey(str, hKey, str0);
CRegUtils::DelKey(hKey, str0);
}
Expand Down Expand Up @@ -322,7 +312,7 @@ void CMainDlg::OnMenuListItemCopy()
list_view_ctrl_export_->GetItemText(pos, 2, item.GetBufferSetLength(128), 128);
if (!item.IsEmpty()) {
item_text += item;
item_text += _T("\n");
item_text += L"\n";
}
pos = (int)::SendMessage(list_view_export_, LVM_GETNEXTITEM, (WPARAM)pos, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
}
Expand Down Expand Up @@ -555,7 +545,7 @@ 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(""));
::SetWindowText(hwnd_dep_path_, L"");
// 没有搜索到
return;
}
Expand Down
8 changes: 4 additions & 4 deletions dependency/dependency.rc
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,6,0,0
PRODUCTVERSION 1,6,0,0
FILEVERSION 1,7,0,0
PRODUCTVERSION 1,7,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -212,12 +212,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "dependency Module"
VALUE "FileVersion", "1.6.0.0"
VALUE "FileVersion", "1.7.0.0"
VALUE "InternalName", "dependency"
VALUE "LegalCopyright", "Copyright 2021"
VALUE "OriginalFilename", "dependency.exe"
VALUE "ProductName", "dependency Module"
VALUE "ProductVersion", "1.6.0.0"
VALUE "ProductVersion", "1.7.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down
8 changes: 6 additions & 2 deletions dependency/dependency.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>delayimp.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
<ResourceCompile>
<Culture>0x0409</Culture>
Expand Down Expand Up @@ -118,13 +119,14 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINDOWS;STRICT;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;..\wtl\include;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>delayimp.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
<ResourceCompile>
<Culture>0x0409</Culture>
Expand Down Expand Up @@ -158,6 +160,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>delayimp.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
<ResourceCompile>
<Culture>0x0409</Culture>
Expand Down Expand Up @@ -186,12 +189,13 @@
</ExceptionHandling>
<DebugInformationFormat>
</DebugInformationFormat>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;..\wtl\include;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>delayimp.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
<ResourceCompile>
<Culture>0x0409</Culture>
Expand Down

0 comments on commit 4471dae

Please sign in to comment.