diff --git a/release.bat b/release.bat index 9cdc2733..bb78c0d7 100644 --- a/release.bat +++ b/release.bat @@ -23,12 +23,14 @@ mkdir %RELEASEDIR%\bin_base\bin\x64 copy bin\x32\BeaEngine.dll %RELEASEDIR%\bin_base\bin\x32\BeaEngine.dll copy bin\x32\dbghelp.dll %RELEASEDIR%\bin_base\bin\x32\dbghelp.dll +copy bin\x32\DeviceNameResolver.dll %RELEASEDIR%\bin_base\bin\x32\DeviceNameResolver.dll copy bin\x32\Scylla.dll %RELEASEDIR%\bin_base\bin\x32\Scylla.dll copy bin\x32\sqlite.dll %RELEASEDIR%\bin_base\bin\x32\sqlite.dll copy bin\x32\TitanEngine.dll %RELEASEDIR%\bin_base\bin\x32\TitanEngine.dll copy bin\x32\XEDParse.dll %RELEASEDIR%\bin_base\bin\x32\XEDParse.dll copy bin\x64\BeaEngine.dll %RELEASEDIR%\bin_base\bin\x64\BeaEngine.dll copy bin\x64\dbghelp.dll %RELEASEDIR%\bin_base\bin\x64\dbghelp.dll +copy bin\x64\DeviceNameResolver.dll %RELEASEDIR%\bin_base\bin\x64\DeviceNameResolver.dll copy bin\x64\Scylla.dll %RELEASEDIR%\bin_base\bin\x64\Scylla.dll copy bin\x64\sqlite.dll %RELEASEDIR%\bin_base\bin\x64\sqlite.dll copy bin\x64\TitanEngine.dll %RELEASEDIR%\bin_base\bin\x64\TitanEngine.dll diff --git a/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver.h b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver.h new file mode 100644 index 00000000..dd6dd6af --- /dev/null +++ b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver.h @@ -0,0 +1,16 @@ +#ifndef _DEVICENAMERESOLVER_H +#define _DEVICENAMERESOLVER_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +__declspec(dllexport) bool DevicePathToPathW(const wchar_t* szDevicePath, wchar_t* szPath, size_t nSize); +__declspec(dllexport) bool DevicePathToPathA(const char* szDevicePath, char* szPath, size_t nSize); + +#ifdef __cplusplus +} +#endif + +#endif // _DEVICENAMERESOLVER_H diff --git a/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x64.a b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x64.a new file mode 100644 index 00000000..d9c5f8c1 Binary files /dev/null and b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x64.a differ diff --git a/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x64.lib b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x64.lib new file mode 100644 index 00000000..7f797fe9 Binary files /dev/null and b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x64.lib differ diff --git a/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x86.a b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x86.a new file mode 100644 index 00000000..7217306f Binary files /dev/null and b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x86.a differ diff --git a/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x86.lib b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x86.lib new file mode 100644 index 00000000..f96cbf23 Binary files /dev/null and b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver_x86.lib differ diff --git a/x64_dbg_dbg/_global.cpp b/x64_dbg_dbg/_global.cpp index 72456590..bc8a7858 100644 --- a/x64_dbg_dbg/_global.cpp +++ b/x64_dbg_dbg/_global.cpp @@ -1,4 +1,5 @@ #include "_global.h" +#include "DeviceNameResolver\DeviceNameResolver.h" #include HINSTANCE hInst; @@ -116,30 +117,6 @@ bool DirExists(const char* dir) return (attrib==FILE_ATTRIBUTE_DIRECTORY); } -bool DevicePathToPath(const char* devicepath, char* path, size_t path_size) -{ - if(!devicepath or !path) - return false; - char curDrive[3]=" :"; - char curDevice[MAX_PATH]=""; - for(char drive='C'; drive<='Z'; drive++) - { - *curDrive=drive; - if(!QueryDosDeviceA(curDrive, curDevice, MAX_PATH)) - continue; - strcat(curDevice, "\\"); //fixed thanks to ahmadmansoor! - size_t curDevice_len=strlen(curDevice); - if(!_strnicmp(devicepath, curDevice, curDevice_len)) //we match the device - { - if(strlen(devicepath)-curDevice_len>=path_size) - return false; - sprintf(path, "%s\\%s", curDrive, devicepath+curDevice_len); - return true; - } - } - return false; -} - bool GetFileNameFromHandle(HANDLE hFile, char* szFileName) { if(!GetFileSize(hFile, 0)) @@ -156,7 +133,7 @@ bool GetFileNameFromHandle(HANDLE hFile, char* szFileName) char szMappedName[MAX_PATH]=""; if(GetMappedFileNameA(GetCurrentProcess(), pFileMap, szMappedName, MAX_PATH)) { - if(!DevicePathToPath(szMappedName, szFileName, MAX_PATH)) + if(!DevicePathToPathA(szMappedName, szFileName, MAX_PATH)) return false; UnmapViewOfFile(pFileMap); CloseHandle(hFileMap); diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index 71edd458..24912c3c 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -106,7 +106,6 @@ void formathex(char* string); void formatdec(char* string); bool FileExists(const char* file); bool DirExists(const char* dir); -bool DevicePathToPath(const char* devicepath, char* path, size_t path_size); bool GetFileNameFromHandle(HANDLE hFile, char* szFileName); bool settingboolget(const char* section, const char* name); diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 9ed8c41a..fec8c1d3 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -16,6 +16,7 @@ #include "disasm_fast.h" #include "BeaEngine\BeaEngine.h" +#include "DeviceNameResolver\DeviceNameResolver.h" static PROCESS_INFORMATION g_pi= {0,0,0,0}; static char szFileName[MAX_PATH]=""; @@ -473,7 +474,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) if(!GetMappedFileNameA(fdProcessInfo->hProcess, base, DebugFileName, deflen)) strcpy(DebugFileName, "??? (GetMappedFileName failed)"); else - DevicePathToPath(DebugFileName, DebugFileName, deflen); + DevicePathToPathA(DebugFileName, DebugFileName, deflen); dprintf("Process Started: "fhex" %s\n", base, DebugFileName); //init program database @@ -655,7 +656,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) if(!GetMappedFileNameA(fdProcessInfo->hProcess, base, DLLDebugFileName, deflen)) strcpy(DLLDebugFileName, "??? (GetMappedFileName failed)"); else - DevicePathToPath(DLLDebugFileName, DLLDebugFileName, deflen); + DevicePathToPathA(DLLDebugFileName, DLLDebugFileName, deflen); dprintf("DLL Loaded: "fhex" %s\n", base, DLLDebugFileName); SymLoadModuleEx(fdProcessInfo->hProcess, LoadDll->hFile, DLLDebugFileName, 0, (DWORD64)base, 0, 0, 0); diff --git a/x64_dbg_dbg/x64_dbg_dbg.cbp b/x64_dbg_dbg/x64_dbg_dbg.cbp index 37b443b5..cbcdd966 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.cbp +++ b/x64_dbg_dbg/x64_dbg_dbg.cbp @@ -28,6 +28,7 @@ + @@ -51,6 +52,7 @@ + diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index ee0962a8..6e8dfb52 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -56,6 +56,7 @@ + @@ -129,7 +130,7 @@ Windows true true - XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;sqlite\sqlite32.lib;BeaEngine\BeaEngine.lib;psapi.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;shlwapi.lib;%(AdditionalDependencies) + DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;sqlite\sqlite32.lib;BeaEngine\BeaEngine.lib;psapi.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;shlwapi.lib;%(AdditionalDependencies) @@ -144,7 +145,7 @@ Windows true true - XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;sqlite\sqlite64.lib;BeaEngine\BeaEngine_64.lib;psapi.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;shlwapi.lib;%(AdditionalDependencies) + DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;sqlite\sqlite64.lib;BeaEngine\BeaEngine_64.lib;psapi.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;shlwapi.lib;%(AdditionalDependencies) diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 679e354a..1ddb6844 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -31,6 +31,9 @@ {6b85ff77-8866-4618-9d46-006d8c349f8f} + + {f4eb1487-15d6-4836-9d20-339d0f18c31f} + @@ -239,5 +242,8 @@ Header Files\sqlite + + Header Files\DeviceNameResolver + \ No newline at end of file