1
0
Fork 0

DBG: re-added DeviceNameResolver

krnldbg
Mr. eXoDia 2014-04-17 22:43:55 +02:00
parent 1e1b921afd
commit 8b07e44826
12 changed files with 34 additions and 30 deletions

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,5 @@
#include "_global.h"
#include "DeviceNameResolver\DeviceNameResolver.h"
#include <new>
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);

View File

@ -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);

View File

@ -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);

View File

@ -28,6 +28,7 @@
<Add library=".\sqlite\libsqlite32.a" />
<Add library=".\BeaEngine\libBeaEngine.a" />
<Add library=".\XEDParse\XEDParse_x86.a" />
<Add library=".\DeviceNameResolver\DeviceNameResolver_x86.a" />
</Linker>
</Target>
<Target title="x64">
@ -51,6 +52,7 @@
<Add library=".\sqlite\libsqlite64.a" />
<Add library=".\BeaEngine\libBeaEngine_64.a" />
<Add library=".\XEDParse\XEDParse_x64.a" />
<Add library=".\DeviceNameResolver\DeviceNameResolver_x64.a" />
</Linker>
</Target>
</Build>

View File

@ -56,6 +56,7 @@
<ClInclude Include="dbghelp\dbghelp.h" />
<ClInclude Include="dbg\dbg.h" />
<ClInclude Include="debugger.h" />
<ClInclude Include="DeviceNameResolver\DeviceNameResolver.h" />
<ClInclude Include="disasm_fast.h" />
<ClInclude Include="disasm_helper.h" />
<ClInclude Include="instruction.h" />
@ -129,7 +130,7 @@
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>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)</AdditionalDependencies>
<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)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -144,7 +145,7 @@
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>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)</AdditionalDependencies>
<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)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -31,6 +31,9 @@
<Filter Include="Header Files\XEDParse">
<UniqueIdentifier>{6b85ff77-8866-4618-9d46-006d8c349f8f}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\DeviceNameResolver">
<UniqueIdentifier>{f4eb1487-15d6-4836-9d20-339d0f18c31f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="_exports.cpp">
@ -239,5 +242,8 @@
<ClInclude Include="sqlite\sqlite3.h">
<Filter>Header Files\sqlite</Filter>
</ClInclude>
<ClInclude Include="DeviceNameResolver\DeviceNameResolver.h">
<Filter>Header Files\DeviceNameResolver</Filter>
</ClInclude>
</ItemGroup>
</Project>