1
0
Fork 0

Merged mrexodia/x64_dbg into master

This commit is contained in:
David Reguera Garcia (Dreg) 2014-09-30 14:51:26 +02:00
commit f47d265c33
49 changed files with 5765 additions and 599 deletions

View File

@ -1,10 +1,10 @@
#include "_global.h"
#include "bridgemain.h"
#include <stdio.h>
#include <new>
#include "simpleini.h"
static HINSTANCE hInst;
static char szIniFile[1024] = "";
static wchar_t szIniFile[MAX_PATH] = L"";
#ifdef _WIN64
#define dbg_lib "x64_dbg.dll"
@ -32,15 +32,15 @@ static char szIniFile[1024] = "";
BRIDGE_IMPEXP const char* BridgeInit()
{
///Settings load
if(!GetModuleFileNameA(0, szIniFile, 1024))
if(!GetModuleFileNameW(0, szIniFile, MAX_PATH))
return "Error getting module path!";
int len = (int)strlen(szIniFile);
while(szIniFile[len] != '.' && szIniFile[len] != '\\' && len)
int len = (int)wcslen(szIniFile);
while(szIniFile[len] != L'.' && szIniFile[len] != L'\\' && len)
len--;
if(szIniFile[len] == '\\')
strcat(szIniFile, ".ini");
if(szIniFile[len] == L'\\')
wcscat_s(szIniFile, L".ini");
else
strcpy(&szIniFile[len], ".ini");
wcscpy_s(&szIniFile[len], sizeof(szIniFile) - len, L".ini");
HINSTANCE hInst;
const char* szLib;
@ -105,8 +105,13 @@ BRIDGE_IMPEXP bool BridgeSettingGet(const char* section, const char* key, char*
{
if(!section || !key || !value)
return false;
if(!GetPrivateProfileStringA(section, key, "", value, MAX_SETTING_SIZE, szIniFile))
CSimpleIniA inifile(true, false, false);
if(inifile.LoadFile(szIniFile) < 0)
return false;
const char* szValue = inifile.GetValue(section, key);
if(!szValue)
return false;
strcpy_s(value, MAX_SETTING_SIZE, szValue);
return true;
}
@ -131,9 +136,13 @@ BRIDGE_IMPEXP bool BridgeSettingSet(const char* section, const char* key, const
{
if(!section)
return false;
if(!WritePrivateProfileStringA(section, key, value, szIniFile))
return false;
return true;
CSimpleIniA inifile(true, false, false);
inifile.LoadFile(szIniFile);
if(!key || !value) //delete value/key when 0
inifile.Delete(section, key, true);
else
inifile.SetValue(section, key, value);
return inifile.SaveFile(szIniFile, false) >= 0;
}
BRIDGE_IMPEXP bool BridgeSettingSetUint(const char* section, const char* key, duint value)

3704
x64_dbg_bridge/simpleini.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="bridgemain.h" />
<ClInclude Include="simpleini.h" />
<ClInclude Include="_global.h" />
</ItemGroup>
<PropertyGroup Label="Globals">

View File

@ -29,5 +29,8 @@
<ClInclude Include="bridgemain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="simpleini.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -594,66 +594,66 @@ extern "C"
// Global.Function.Declaration:
// TitanEngine.Dumper.functions:
__declspec(dllexport) bool TITCALL DumpProcess(HANDLE hProcess, LPVOID ImageBase, char* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpProcessW(HANDLE hProcess, LPVOID ImageBase, wchar_t* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpProcessEx(DWORD ProcessId, LPVOID ImageBase, char* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpProcessExW(DWORD ProcessId, LPVOID ImageBase, wchar_t* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpMemory(HANDLE hProcess, LPVOID MemoryStart, ULONG_PTR MemorySize, char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpMemoryW(HANDLE hProcess, LPVOID MemoryStart, ULONG_PTR MemorySize, wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpMemoryEx(DWORD ProcessId, LPVOID MemoryStart, ULONG_PTR MemorySize, char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpMemoryExW(DWORD ProcessId, LPVOID MemoryStart, ULONG_PTR MemorySize, wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpRegions(HANDLE hProcess, char* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpRegionsW(HANDLE hProcess, wchar_t* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpRegionsEx(DWORD ProcessId, char* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpRegionsExW(DWORD ProcessId, wchar_t* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpModule(HANDLE hProcess, LPVOID ModuleBase, char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpModuleW(HANDLE hProcess, LPVOID ModuleBase, wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpModuleEx(DWORD ProcessId, LPVOID ModuleBase, char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpModuleExW(DWORD ProcessId, LPVOID ModuleBase, wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL PastePEHeader(HANDLE hProcess, LPVOID ImageBase, char* szDebuggedFileName);
__declspec(dllexport) bool TITCALL PastePEHeaderW(HANDLE hProcess, LPVOID ImageBase, wchar_t* szDebuggedFileName);
__declspec(dllexport) bool TITCALL ExtractSection(char* szFileName, char* szDumpFileName, DWORD SectionNumber);
__declspec(dllexport) bool TITCALL ExtractSectionW(wchar_t* szFileName, wchar_t* szDumpFileName, DWORD SectionNumber);
__declspec(dllexport) bool TITCALL ResortFileSections(char* szFileName);
__declspec(dllexport) bool TITCALL ResortFileSectionsW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL FindOverlay(char* szFileName, LPDWORD OverlayStart, LPDWORD OverlaySize);
__declspec(dllexport) bool TITCALL FindOverlayW(wchar_t* szFileName, LPDWORD OverlayStart, LPDWORD OverlaySize);
__declspec(dllexport) bool TITCALL ExtractOverlay(char* szFileName, char* szExtactedFileName);
__declspec(dllexport) bool TITCALL ExtractOverlayW(wchar_t* szFileName, wchar_t* szExtactedFileName);
__declspec(dllexport) bool TITCALL AddOverlay(char* szFileName, char* szOverlayFileName);
__declspec(dllexport) bool TITCALL AddOverlayW(wchar_t* szFileName, wchar_t* szOverlayFileName);
__declspec(dllexport) bool TITCALL CopyOverlay(char* szInFileName, char* szOutFileName);
__declspec(dllexport) bool TITCALL CopyOverlayW(wchar_t* szInFileName, wchar_t* szOutFileName);
__declspec(dllexport) bool TITCALL RemoveOverlay(char* szFileName);
__declspec(dllexport) bool TITCALL RemoveOverlayW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL MakeAllSectionsRWE(char* szFileName);
__declspec(dllexport) bool TITCALL MakeAllSectionsRWEW(wchar_t* szFileName);
__declspec(dllexport) long TITCALL AddNewSectionEx(char* szFileName, char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize);
__declspec(dllexport) long TITCALL AddNewSectionExW(wchar_t* szFileName, char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize);
__declspec(dllexport) long TITCALL AddNewSection(char* szFileName, char* szSectionName, DWORD SectionSize);
__declspec(dllexport) long TITCALL AddNewSectionW(wchar_t* szFileName, char* szSectionName, DWORD SectionSize);
__declspec(dllexport) bool TITCALL ResizeLastSection(char* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData);
__declspec(dllexport) bool TITCALL ResizeLastSectionW(wchar_t* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData);
__declspec(dllexport) void TITCALL SetSharedOverlay(char* szFileName);
__declspec(dllexport) void TITCALL SetSharedOverlayW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL DumpProcess(HANDLE hProcess, LPVOID ImageBase, const char* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpProcessW(HANDLE hProcess, LPVOID ImageBase, const wchar_t* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpProcessEx(DWORD ProcessId, LPVOID ImageBase, const char* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpProcessExW(DWORD ProcessId, LPVOID ImageBase, const wchar_t* szDumpFileName, ULONG_PTR EntryPoint);
__declspec(dllexport) bool TITCALL DumpMemory(HANDLE hProcess, LPVOID MemoryStart, ULONG_PTR MemorySize, const char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpMemoryW(HANDLE hProcess, LPVOID MemoryStart, ULONG_PTR MemorySize, const wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpMemoryEx(DWORD ProcessId, LPVOID MemoryStart, ULONG_PTR MemorySize, const char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpMemoryExW(DWORD ProcessId, LPVOID MemoryStart, ULONG_PTR MemorySize, const wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpRegions(HANDLE hProcess, const char* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpRegionsW(HANDLE hProcess, const wchar_t* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpRegionsEx(DWORD ProcessId, const char* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpRegionsExW(DWORD ProcessId, const wchar_t* szDumpFolder, bool DumpAboveImageBaseOnly);
__declspec(dllexport) bool TITCALL DumpModule(HANDLE hProcess, LPVOID ModuleBase, const char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpModuleW(HANDLE hProcess, LPVOID ModuleBase, const wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpModuleEx(DWORD ProcessId, LPVOID ModuleBase, const char* szDumpFileName);
__declspec(dllexport) bool TITCALL DumpModuleExW(DWORD ProcessId, LPVOID ModuleBase, const wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL PastePEHeader(HANDLE hProcess, LPVOID ImageBase, const char* szDebuggedFileName);
__declspec(dllexport) bool TITCALL PastePEHeaderW(HANDLE hProcess, LPVOID ImageBase, const wchar_t* szDebuggedFileName);
__declspec(dllexport) bool TITCALL ExtractSection(const char* szFileName, const char* szDumpFileName, DWORD SectionNumber);
__declspec(dllexport) bool TITCALL ExtractSectionW(const wchar_t* szFileName, const wchar_t* szDumpFileName, DWORD SectionNumber);
__declspec(dllexport) bool TITCALL ResortFileSections(const char* szFileName);
__declspec(dllexport) bool TITCALL ResortFileSectionsW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL FindOverlay(const char* szFileName, LPDWORD OverlayStart, LPDWORD OverlaySize);
__declspec(dllexport) bool TITCALL FindOverlayW(const wchar_t* szFileName, LPDWORD OverlayStart, LPDWORD OverlaySize);
__declspec(dllexport) bool TITCALL ExtractOverlay(const char* szFileName, const char* szExtactedFileName);
__declspec(dllexport) bool TITCALL ExtractOverlayW(const wchar_t* szFileName, const wchar_t* szExtactedFileName);
__declspec(dllexport) bool TITCALL AddOverlay(const char* szFileName, const char* szOverlayFileName);
__declspec(dllexport) bool TITCALL AddOverlayW(const wchar_t* szFileName, const wchar_t* szOverlayFileName);
__declspec(dllexport) bool TITCALL CopyOverlay(const char* szInFileName, const char* szOutFileName);
__declspec(dllexport) bool TITCALL CopyOverlayW(const wchar_t* szInFileName, const wchar_t* szOutFileName);
__declspec(dllexport) bool TITCALL RemoveOverlay(const char* szFileName);
__declspec(dllexport) bool TITCALL RemoveOverlayW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL MakeAllSectionsRWE(const char* szFileName);
__declspec(dllexport) bool TITCALL MakeAllSectionsRWEW(const wchar_t* szFileName);
__declspec(dllexport) long TITCALL AddNewSectionEx(const char* szFileName, const char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize);
__declspec(dllexport) long TITCALL AddNewSectionExW(const wchar_t* szFileName, const char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize);
__declspec(dllexport) long TITCALL AddNewSection(const char* szFileName, const char* szSectionName, DWORD SectionSize);
__declspec(dllexport) long TITCALL AddNewSectionW(const wchar_t* szFileName, const char* szSectionName, DWORD SectionSize);
__declspec(dllexport) bool TITCALL ResizeLastSection(const char* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData);
__declspec(dllexport) bool TITCALL ResizeLastSectionW(const wchar_t* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData);
__declspec(dllexport) void TITCALL SetSharedOverlay(const char* szFileName);
__declspec(dllexport) void TITCALL SetSharedOverlayW(const wchar_t* szFileName);
__declspec(dllexport) char* TITCALL GetSharedOverlay();
__declspec(dllexport) wchar_t* TITCALL GetSharedOverlayW();
__declspec(dllexport) bool TITCALL DeleteLastSection(char* szFileName);
__declspec(dllexport) bool TITCALL DeleteLastSectionW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL DeleteLastSectionEx(char* szFileName, DWORD NumberOfSections);
__declspec(dllexport) bool TITCALL DeleteLastSectionExW(wchar_t* szFileName, DWORD NumberOfSections);
__declspec(dllexport) bool TITCALL DeleteLastSection(const char* szFileName);
__declspec(dllexport) bool TITCALL DeleteLastSectionW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL DeleteLastSectionEx(const char* szFileName, DWORD NumberOfSections);
__declspec(dllexport) bool TITCALL DeleteLastSectionExW(const wchar_t* szFileName, DWORD NumberOfSections);
__declspec(dllexport) ULONG_PTR TITCALL GetPE32DataFromMappedFile(ULONG_PTR FileMapVA, DWORD WhichSection, DWORD WhichData);
__declspec(dllexport) ULONG_PTR TITCALL GetPE32Data(char* szFileName, DWORD WhichSection, DWORD WhichData);
__declspec(dllexport) ULONG_PTR TITCALL GetPE32DataW(wchar_t* szFileName, DWORD WhichSection, DWORD WhichData);
__declspec(dllexport) ULONG_PTR TITCALL GetPE32Data(const char* szFileName, DWORD WhichSection, DWORD WhichData);
__declspec(dllexport) ULONG_PTR TITCALL GetPE32DataW(const wchar_t* szFileName, DWORD WhichSection, DWORD WhichData);
__declspec(dllexport) bool TITCALL GetPE32DataFromMappedFileEx(ULONG_PTR FileMapVA, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL GetPE32DataEx(char* szFileName, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL GetPE32DataExW(wchar_t* szFileName, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL GetPE32DataEx(const char* szFileName, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL GetPE32DataExW(const wchar_t* szFileName, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL SetPE32DataForMappedFile(ULONG_PTR FileMapVA, DWORD WhichSection, DWORD WhichData, ULONG_PTR NewDataValue);
__declspec(dllexport) bool TITCALL SetPE32Data(char* szFileName, DWORD WhichSection, DWORD WhichData, ULONG_PTR NewDataValue);
__declspec(dllexport) bool TITCALL SetPE32DataW(wchar_t* szFileName, DWORD WhichSection, DWORD WhichData, ULONG_PTR NewDataValue);
__declspec(dllexport) bool TITCALL SetPE32Data(const char* szFileName, DWORD WhichSection, DWORD WhichData, ULONG_PTR NewDataValue);
__declspec(dllexport) bool TITCALL SetPE32DataW(const wchar_t* szFileName, DWORD WhichSection, DWORD WhichData, ULONG_PTR NewDataValue);
__declspec(dllexport) bool TITCALL SetPE32DataForMappedFileEx(ULONG_PTR FileMapVA, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL SetPE32DataEx(char* szFileName, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL SetPE32DataExW(wchar_t* szFileName, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL SetPE32DataEx(const char* szFileName, LPVOID DataStorage);
__declspec(dllexport) bool TITCALL SetPE32DataExW(const wchar_t* szFileName, LPVOID DataStorage);
__declspec(dllexport) long TITCALL GetPE32SectionNumberFromVA(ULONG_PTR FileMapVA, ULONG_PTR AddressToConvert);
__declspec(dllexport) ULONG_PTR TITCALL ConvertVAtoFileOffset(ULONG_PTR FileMapVA, ULONG_PTR AddressToConvert, bool ReturnType);
__declspec(dllexport) ULONG_PTR TITCALL ConvertVAtoFileOffsetEx(ULONG_PTR FileMapVA, DWORD FileSize, ULONG_PTR ImageBase, ULONG_PTR AddressToConvert, bool AddressIsRVA, bool ReturnType);
@ -662,19 +662,19 @@ __declspec(dllexport) ULONG_PTR TITCALL ConvertFileOffsetToVAEx(ULONG_PTR FileMa
__declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead);
__declspec(dllexport) bool TITCALL MemoryWriteSafe(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten);
// TitanEngine.Realigner.functions:
__declspec(dllexport) bool TITCALL FixHeaderCheckSum(char* szFileName);
__declspec(dllexport) bool TITCALL FixHeaderCheckSumW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL FixHeaderCheckSum(const char* szFileName);
__declspec(dllexport) bool TITCALL FixHeaderCheckSumW(const wchar_t* szFileName);
__declspec(dllexport) long TITCALL RealignPE(ULONG_PTR FileMapVA, DWORD FileSize, DWORD RealingMode);
__declspec(dllexport) long TITCALL RealignPEEx(char* szFileName, DWORD RealingFileSize, DWORD ForcedFileAlignment);
__declspec(dllexport) long TITCALL RealignPEExW(wchar_t* szFileName, DWORD RealingFileSize, DWORD ForcedFileAlignment);
__declspec(dllexport) bool TITCALL WipeSection(char* szFileName, int WipeSectionNumber, bool RemovePhysically);
__declspec(dllexport) bool TITCALL WipeSectionW(wchar_t* szFileName, int WipeSectionNumber, bool RemovePhysically);
__declspec(dllexport) bool TITCALL IsPE32FileValidEx(char* szFileName, DWORD CheckDepth, LPVOID FileStatusInfo);
__declspec(dllexport) bool TITCALL IsPE32FileValidExW(wchar_t* szFileName, DWORD CheckDepth, LPVOID FileStatusInfo);
__declspec(dllexport) bool TITCALL FixBrokenPE32FileEx(char* szFileName, LPVOID FileStatusInfo, LPVOID FileFixInfo);
__declspec(dllexport) bool TITCALL FixBrokenPE32FileExW(wchar_t* szFileName, LPVOID FileStatusInfo, LPVOID FileFixInfo);
__declspec(dllexport) bool TITCALL IsFileDLL(char* szFileName, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL IsFileDLLW(wchar_t* szFileName, ULONG_PTR FileMapVA);
__declspec(dllexport) long TITCALL RealignPEEx(const char* szFileName, DWORD RealingFileSize, DWORD ForcedFileAlignment);
__declspec(dllexport) long TITCALL RealignPEExW(const wchar_t* szFileName, DWORD RealingFileSize, DWORD ForcedFileAlignment);
__declspec(dllexport) bool TITCALL WipeSection(const char* szFileName, int WipeSectionNumber, bool RemovePhysically);
__declspec(dllexport) bool TITCALL WipeSectionW(const wchar_t* szFileName, int WipeSectionNumber, bool RemovePhysically);
__declspec(dllexport) bool TITCALL IsPE32FileValidEx(const char* szFileName, DWORD CheckDepth, LPVOID FileStatusInfo);
__declspec(dllexport) bool TITCALL IsPE32FileValidExW(const wchar_t* szFileName, DWORD CheckDepth, LPVOID FileStatusInfo);
__declspec(dllexport) bool TITCALL FixBrokenPE32FileEx(const char* szFileName, LPVOID FileStatusInfo, LPVOID FileFixInfo);
__declspec(dllexport) bool TITCALL FixBrokenPE32FileExW(const wchar_t* szFileName, LPVOID FileStatusInfo, LPVOID FileFixInfo);
__declspec(dllexport) bool TITCALL IsFileDLL(const char* szFileName, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL IsFileDLLW(const wchar_t* szFileName, ULONG_PTR FileMapVA);
// TitanEngine.Hider.functions:
__declspec(dllexport) void* TITCALL GetPEBLocation(HANDLE hProcess);
__declspec(dllexport) void* TITCALL GetPEBLocation64(HANDLE hProcess);
@ -688,31 +688,31 @@ __declspec(dllexport) void TITCALL RelocaterInit(DWORD MemorySize, ULONG_PTR Old
__declspec(dllexport) void TITCALL RelocaterAddNewRelocation(HANDLE hProcess, ULONG_PTR RelocateAddress, DWORD RelocateState);
__declspec(dllexport) long TITCALL RelocaterEstimatedSize();
__declspec(dllexport) bool TITCALL RelocaterExportRelocation(ULONG_PTR StorePlace, DWORD StorePlaceRVA, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL RelocaterExportRelocationEx(char* szFileName, char* szSectionName);
__declspec(dllexport) bool TITCALL RelocaterExportRelocationExW(wchar_t* szFileName, char* szSectionName);
__declspec(dllexport) bool TITCALL RelocaterExportRelocationEx(const char* szFileName, const char* szSectionName);
__declspec(dllexport) bool TITCALL RelocaterExportRelocationExW(const wchar_t* szFileName, const char* szSectionName);
__declspec(dllexport) bool TITCALL RelocaterGrabRelocationTable(HANDLE hProcess, ULONG_PTR MemoryStart, DWORD MemorySize);
__declspec(dllexport) bool TITCALL RelocaterGrabRelocationTableEx(HANDLE hProcess, ULONG_PTR MemoryStart, ULONG_PTR MemorySize, DWORD NtSizeOfImage);
__declspec(dllexport) bool TITCALL RelocaterMakeSnapshot(HANDLE hProcess, char* szSaveFileName, LPVOID MemoryStart, ULONG_PTR MemorySize);
__declspec(dllexport) bool TITCALL RelocaterMakeSnapshotW(HANDLE hProcess, wchar_t* szSaveFileName, LPVOID MemoryStart, ULONG_PTR MemorySize);
__declspec(dllexport) bool TITCALL RelocaterCompareTwoSnapshots(HANDLE hProcess, ULONG_PTR LoadedImageBase, ULONG_PTR NtSizeOfImage, char* szDumpFile1, char* szDumpFile2, ULONG_PTR MemStart);
__declspec(dllexport) bool TITCALL RelocaterCompareTwoSnapshotsW(HANDLE hProcess, ULONG_PTR LoadedImageBase, ULONG_PTR NtSizeOfImage, wchar_t* szDumpFile1, wchar_t* szDumpFile2, ULONG_PTR MemStart);
__declspec(dllexport) bool TITCALL RelocaterChangeFileBase(char* szFileName, ULONG_PTR NewImageBase);
__declspec(dllexport) bool TITCALL RelocaterChangeFileBaseW(wchar_t* szFileName, ULONG_PTR NewImageBase);
__declspec(dllexport) bool TITCALL RelocaterMakeSnapshot(HANDLE hProcess, const char* szSaveFileName, LPVOID MemoryStart, ULONG_PTR MemorySize);
__declspec(dllexport) bool TITCALL RelocaterMakeSnapshotW(HANDLE hProcess, const wchar_t* szSaveFileName, LPVOID MemoryStart, ULONG_PTR MemorySize);
__declspec(dllexport) bool TITCALL RelocaterCompareTwoSnapshots(HANDLE hProcess, ULONG_PTR LoadedImageBase, ULONG_PTR NtSizeOfImage, const char* szDumpFile1, const char* szDumpFile2, ULONG_PTR MemStart);
__declspec(dllexport) bool TITCALL RelocaterCompareTwoSnapshotsW(HANDLE hProcess, ULONG_PTR LoadedImageBase, ULONG_PTR NtSizeOfImage, const wchar_t* szDumpFile1, const wchar_t* szDumpFile2, ULONG_PTR MemStart);
__declspec(dllexport) bool TITCALL RelocaterChangeFileBase(const char* szFileName, ULONG_PTR NewImageBase);
__declspec(dllexport) bool TITCALL RelocaterChangeFileBaseW(const wchar_t* szFileName, ULONG_PTR NewImageBase);
__declspec(dllexport) bool TITCALL RelocaterRelocateMemoryBlock(ULONG_PTR FileMapVA, ULONG_PTR MemoryLocation, void* RelocateMemory, DWORD RelocateMemorySize, ULONG_PTR CurrentLoadedBase, ULONG_PTR RelocateBase);
__declspec(dllexport) bool TITCALL RelocaterWipeRelocationTable(char* szFileName);
__declspec(dllexport) bool TITCALL RelocaterWipeRelocationTableW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL RelocaterWipeRelocationTable(const char* szFileName);
__declspec(dllexport) bool TITCALL RelocaterWipeRelocationTableW(const wchar_t* szFileName);
// TitanEngine.Resourcer.functions:
__declspec(dllexport) ULONG_PTR TITCALL ResourcerLoadFileForResourceUse(char* szFileName);
__declspec(dllexport) ULONG_PTR TITCALL ResourcerLoadFileForResourceUseW(wchar_t* szFileName);
__declspec(dllexport) ULONG_PTR TITCALL ResourcerLoadFileForResourceUse(const char* szFileName);
__declspec(dllexport) ULONG_PTR TITCALL ResourcerLoadFileForResourceUseW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL ResourcerFreeLoadedFile(LPVOID LoadedFileBase);
__declspec(dllexport) bool TITCALL ResourcerExtractResourceFromFileEx(ULONG_PTR FileMapVA, char* szResourceType, char* szResourceName, char* szExtractedFileName);
__declspec(dllexport) bool TITCALL ResourcerExtractResourceFromFile(char* szFileName, char* szResourceType, char* szResourceName, char* szExtractedFileName);
__declspec(dllexport) bool TITCALL ResourcerExtractResourceFromFileW(wchar_t* szFileName, char* szResourceType, char* szResourceName, char* szExtractedFileName);
__declspec(dllexport) bool TITCALL ResourcerFindResource(char* szFileName, char* szResourceType, DWORD ResourceType, char* szResourceName, DWORD ResourceName, DWORD ResourceLanguage, PULONG_PTR pResourceData, LPDWORD pResourceSize);
__declspec(dllexport) bool TITCALL ResourcerFindResourceW(wchar_t* szFileName, wchar_t* szResourceType, DWORD ResourceType, wchar_t* szResourceName, DWORD ResourceName, DWORD ResourceLanguage, PULONG_PTR pResourceData, LPDWORD pResourceSize);
__declspec(dllexport) bool TITCALL ResourcerFindResourceEx(ULONG_PTR FileMapVA, DWORD FileSize, wchar_t* szResourceType, DWORD ResourceType, wchar_t* szResourceName, DWORD ResourceName, DWORD ResourceLanguage, PULONG_PTR pResourceData, LPDWORD pResourceSize);
__declspec(dllexport) void TITCALL ResourcerEnumerateResource(char* szFileName, void* CallBack);
__declspec(dllexport) void TITCALL ResourcerEnumerateResourceW(wchar_t* szFileName, void* CallBack);
__declspec(dllexport) bool TITCALL ResourcerExtractResourceFromFileEx(ULONG_PTR FileMapVA, const char* szResourceType, const char* szResourceName, const char* szExtractedFileName);
__declspec(dllexport) bool TITCALL ResourcerExtractResourceFromFile(const char* szFileName, const char* szResourceType, const char* szResourceName, const char* szExtractedFileName);
__declspec(dllexport) bool TITCALL ResourcerExtractResourceFromFileW(const wchar_t* szFileName, char* szResourceType, const char* szResourceName, const char* szExtractedFileName);
__declspec(dllexport) bool TITCALL ResourcerFindResource(const char* szFileName, const char* szResourceType, DWORD ResourceType, const char* szResourceName, DWORD ResourceName, DWORD ResourceLanguage, PULONG_PTR pResourceData, LPDWORD pResourceSize);
__declspec(dllexport) bool TITCALL ResourcerFindResourceW(const wchar_t* szFileName, const wchar_t* szResourceType, DWORD ResourceType, const wchar_t* szResourceName, DWORD ResourceName, DWORD ResourceLanguage, PULONG_PTR pResourceData, LPDWORD pResourceSize);
__declspec(dllexport) bool TITCALL ResourcerFindResourceEx(ULONG_PTR FileMapVA, DWORD FileSize, const wchar_t* szResourceType, DWORD ResourceType, const wchar_t* szResourceName, DWORD ResourceName, DWORD ResourceLanguage, PULONG_PTR pResourceData, LPDWORD pResourceSize);
__declspec(dllexport) void TITCALL ResourcerEnumerateResource(const char* szFileName, void* CallBack);
__declspec(dllexport) void TITCALL ResourcerEnumerateResourceW(const wchar_t* szFileName, void* CallBack);
__declspec(dllexport) void TITCALL ResourcerEnumerateResourceEx(ULONG_PTR FileMapVA, DWORD FileSize, void* CallBack);
// TitanEngine.Threader.functions:
__declspec(dllexport) bool TITCALL ThreaderImportRunningThreadData(DWORD ProcessId);
@ -745,11 +745,11 @@ __declspec(dllexport) long TITCALL StaticLengthDisassemble(LPVOID DisassmAddress
__declspec(dllexport) long TITCALL LengthDisassembleEx(HANDLE hProcess, LPVOID DisassmAddress);
__declspec(dllexport) long TITCALL LengthDisassemble(LPVOID DisassmAddress);
__declspec(dllexport) void* TITCALL InitDebug(char* szFileName, char* szCommandLine, char* szCurrentFolder);
__declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szCommandLine, wchar_t* szCurrentFolder);
__declspec(dllexport) void* TITCALL InitDebugEx(char* szFileName, char* szCommandLine, char* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) void* TITCALL InitDebugExW(wchar_t* szFileName, wchar_t* szCommandLine, wchar_t* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) void* TITCALL InitDLLDebug(char* szFileName, bool ReserveModuleBase, char* szCommandLine, char* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool ReserveModuleBase, wchar_t* szCommandLine, wchar_t* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) void* TITCALL InitDebugW(const wchar_t* szFileName, const wchar_t* szCommandLine, const wchar_t* szCurrentFolder);
__declspec(dllexport) void* TITCALL InitDebugEx(const char* szFileName, const char* szCommandLine, const char* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) void* TITCALL InitDebugExW(const wchar_t* szFileName, const wchar_t* szCommandLine, const wchar_t* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) void* TITCALL InitDLLDebug(const char* szFileName, bool ReserveModuleBase, const char* szCommandLine, const char* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) void* TITCALL InitDLLDebugW(const wchar_t* szFileName, bool ReserveModuleBase, const wchar_t* szCommandLine, const wchar_t* szCurrentFolder, LPVOID EntryCallBack);
__declspec(dllexport) bool TITCALL StopDebug();
__declspec(dllexport) void TITCALL SetBPXOptions(long DefaultBreakPointType);
__declspec(dllexport) bool TITCALL IsBPXEnabled(ULONG_PTR bpxAddress);
@ -814,25 +814,25 @@ __declspec(dllexport) bool TITCALL AttachDebugger(DWORD ProcessId, bool KillOnEx
__declspec(dllexport) bool TITCALL DetachDebugger(DWORD ProcessId);
__declspec(dllexport) bool TITCALL DetachDebuggerEx(DWORD ProcessId);
__declspec(dllexport) void TITCALL DebugLoopEx(DWORD TimeOut);
__declspec(dllexport) void TITCALL AutoDebugEx(char* szFileName, bool ReserveModuleBase, char* szCommandLine, char* szCurrentFolder, DWORD TimeOut, LPVOID EntryCallBack);
__declspec(dllexport) void TITCALL AutoDebugExW(wchar_t* szFileName, bool ReserveModuleBase, wchar_t* szCommandLine, wchar_t* szCurrentFolder, DWORD TimeOut, LPVOID EntryCallBack);
__declspec(dllexport) void TITCALL AutoDebugEx(const char* szFileName, bool ReserveModuleBase, const char* szCommandLine, const char* szCurrentFolder, DWORD TimeOut, LPVOID EntryCallBack);
__declspec(dllexport) void TITCALL AutoDebugExW(const wchar_t* szFileName, bool ReserveModuleBase, const wchar_t* szCommandLine, const wchar_t* szCurrentFolder, DWORD TimeOut, LPVOID EntryCallBack);
__declspec(dllexport) bool TITCALL IsFileBeingDebugged();
__declspec(dllexport) void TITCALL SetErrorModel(bool DisplayErrorMessages);
// TitanEngine.FindOEP.functions:
__declspec(dllexport) void TITCALL FindOEPInit();
__declspec(dllexport) bool TITCALL FindOEPGenerically(char* szFileName, LPVOID TraceInitCallBack, LPVOID CallBack);
__declspec(dllexport) bool TITCALL FindOEPGenericallyW(wchar_t* szFileName, LPVOID TraceInitCallBack, LPVOID CallBack);
__declspec(dllexport) bool TITCALL FindOEPGenerically(const char* szFileName, LPVOID TraceInitCallBack, LPVOID CallBack);
__declspec(dllexport) bool TITCALL FindOEPGenericallyW(const wchar_t* szFileName, LPVOID TraceInitCallBack, LPVOID CallBack);
// TitanEngine.Importer.functions:
__declspec(dllexport) void TITCALL ImporterAddNewDll(char* szDLLName, ULONG_PTR FirstThunk);
__declspec(dllexport) void TITCALL ImporterAddNewAPI(char* szAPIName, ULONG_PTR ThunkValue);
__declspec(dllexport) void TITCALL ImporterAddNewDll(const char* szDLLName, ULONG_PTR FirstThunk);
__declspec(dllexport) void TITCALL ImporterAddNewAPI(const char* szAPIName, ULONG_PTR ThunkValue);
__declspec(dllexport) void TITCALL ImporterAddNewOrdinalAPI(ULONG_PTR OrdinalNumber, ULONG_PTR ThunkValue);
__declspec(dllexport) long TITCALL ImporterGetAddedDllCount();
__declspec(dllexport) long TITCALL ImporterGetAddedAPICount();
__declspec(dllexport) bool TITCALL ImporterExportIAT(ULONG_PTR StorePlace, ULONG_PTR FileMapVA, HANDLE hFileMap);
__declspec(dllexport) long TITCALL ImporterEstimatedSize();
__declspec(dllexport) bool TITCALL ImporterExportIATEx(char* szDumpFileName, char* szExportFileName, char* szSectionName);
__declspec(dllexport) bool TITCALL ImporterExportIATExW(wchar_t* szDumpFileName, wchar_t* szExportFileName, wchar_t* szSectionName = L".RL!TEv2");
__declspec(dllexport) ULONG_PTR TITCALL ImporterFindAPIWriteLocation(char* szAPIName);
__declspec(dllexport) bool TITCALL ImporterExportIATEx(const char* szDumpFileName, const char* szExportFileName, const char* szSectionName);
__declspec(dllexport) bool TITCALL ImporterExportIATExW(const wchar_t* szDumpFileName, const wchar_t* szExportFileName, const wchar_t* szSectionName = L".RL!TEv2");
__declspec(dllexport) ULONG_PTR TITCALL ImporterFindAPIWriteLocation(const char* szAPIName);
__declspec(dllexport) ULONG_PTR TITCALL ImporterFindOrdinalAPIWriteLocation(ULONG_PTR OrdinalNumber);
__declspec(dllexport) ULONG_PTR TITCALL ImporterFindAPIByWriteLocation(ULONG_PTR APIWriteLocation);
__declspec(dllexport) ULONG_PTR TITCALL ImporterFindDLLByWriteLocation(ULONG_PTR APIWriteLocation);
@ -842,7 +842,7 @@ __declspec(dllexport) void* TITCALL ImporterGetAPIName(ULONG_PTR APIAddress);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetAPIOrdinalNumber(ULONG_PTR APIAddress);
__declspec(dllexport) void* TITCALL ImporterGetAPINameEx(ULONG_PTR APIAddress, ULONG_PTR DLLBasesList);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteAPIAddress(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteAPIAddressEx(char* szDLLName, char* szAPIName);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteAPIAddressEx(const char* szDLLName, const char* szAPIName);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetLocalAPIAddress(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) void* TITCALL ImporterGetDLLNameFromDebugee(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) void* TITCALL ImporterGetDLLNameFromDebugeeW(HANDLE hProcess, ULONG_PTR APIAddress);
@ -851,8 +851,8 @@ __declspec(dllexport) ULONG_PTR TITCALL ImporterGetAPIOrdinalNumberFromDebugee(H
__declspec(dllexport) long TITCALL ImporterGetDLLIndexEx(ULONG_PTR APIAddress, ULONG_PTR DLLBasesList);
__declspec(dllexport) long TITCALL ImporterGetDLLIndex(HANDLE hProcess, ULONG_PTR APIAddress, ULONG_PTR DLLBasesList);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteDLLBase(HANDLE hProcess, HMODULE LocalModuleBase);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteDLLBaseEx(HANDLE hProcess, char* szModuleName);
__declspec(dllexport) void* TITCALL ImporterGetRemoteDLLBaseExW(HANDLE hProcess, wchar_t* szModuleName);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteDLLBaseEx(HANDLE hProcess, const char* szModuleName);
__declspec(dllexport) void* TITCALL ImporterGetRemoteDLLBaseExW(HANDLE hProcess, const wchar_t* szModuleName);
__declspec(dllexport) bool TITCALL ImporterIsForwardedAPI(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) void* TITCALL ImporterGetForwardedAPIName(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) void* TITCALL ImporterGetForwardedDLLName(HANDLE hProcess, ULONG_PTR APIAddress);
@ -860,20 +860,20 @@ __declspec(dllexport) long TITCALL ImporterGetForwardedDLLIndex(HANDLE hProcess,
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetForwardedAPIOrdinalNumber(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetNearestAPIAddress(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) void* TITCALL ImporterGetNearestAPIName(HANDLE hProcess, ULONG_PTR APIAddress);
__declspec(dllexport) bool TITCALL ImporterCopyOriginalIAT(char* szOriginalFile, char* szDumpFile);
__declspec(dllexport) bool TITCALL ImporterCopyOriginalIATW(wchar_t* szOriginalFile, wchar_t* szDumpFile);
__declspec(dllexport) bool TITCALL ImporterLoadImportTable(char* szFileName);
__declspec(dllexport) bool TITCALL ImporterLoadImportTableW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL ImporterMoveOriginalIAT(char* szOriginalFile, char* szDumpFile, char* szSectionName);
__declspec(dllexport) bool TITCALL ImporterMoveOriginalIATW(wchar_t* szOriginalFile, wchar_t* szDumpFile, char* szSectionName);
__declspec(dllexport) void TITCALL ImporterAutoSearchIAT(DWORD ProcessId, char* szFileName, ULONG_PTR SearchStart, LPVOID pIATStart, LPVOID pIATSize);
__declspec(dllexport) void TITCALL ImporterAutoSearchIATW(DWORD ProcessIds, wchar_t* szFileName, ULONG_PTR SearchStart, LPVOID pIATStart, LPVOID pIATSize);
__declspec(dllexport) bool TITCALL ImporterCopyOriginalIAT(const char* szOriginalFile, const char* szDumpFile);
__declspec(dllexport) bool TITCALL ImporterCopyOriginalIATW(const wchar_t* szOriginalFile, const wchar_t* szDumpFile);
__declspec(dllexport) bool TITCALL ImporterLoadImportTable(const char* szFileName);
__declspec(dllexport) bool TITCALL ImporterLoadImportTableW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL ImporterMoveOriginalIAT(const char* szOriginalFile, const char* szDumpFile, const char* szSectionName);
__declspec(dllexport) bool TITCALL ImporterMoveOriginalIATW(const wchar_t* szOriginalFile, const wchar_t* szDumpFile, const char* szSectionName);
__declspec(dllexport) void TITCALL ImporterAutoSearchIAT(DWORD ProcessId, const char* szFileName, ULONG_PTR SearchStart, LPVOID pIATStart, LPVOID pIATSize);
__declspec(dllexport) void TITCALL ImporterAutoSearchIATW(DWORD ProcessIds, const wchar_t* szFileName, ULONG_PTR SearchStart, LPVOID pIATStart, LPVOID pIATSize);
__declspec(dllexport) void TITCALL ImporterAutoSearchIATEx(DWORD ProcessId, ULONG_PTR ImageBase, ULONG_PTR SearchStart, LPVOID pIATStart, LPVOID pIATSize);
__declspec(dllexport) void TITCALL ImporterEnumAddedData(LPVOID EnumCallBack);
__declspec(dllexport) long TITCALL ImporterAutoFixIATEx(DWORD ProcessId, char* szDumpedFile, char* szSectionName, bool DumpRunningProcess, bool RealignFile, ULONG_PTR EntryPointAddress, ULONG_PTR ImageBase, ULONG_PTR SearchStart, bool TryAutoFix, bool FixEliminations, LPVOID UnknownPointerFixCallback);
__declspec(dllexport) long TITCALL ImporterAutoFixIATExW(DWORD ProcessId, wchar_t* szDumpedFile, wchar_t* szSectionName, bool DumpRunningProcess, bool RealignFile, ULONG_PTR EntryPointAddress, ULONG_PTR ImageBase, ULONG_PTR SearchStart, bool TryAutoFix, bool FixEliminations, LPVOID UnknownPointerFixCallback);
__declspec(dllexport) long TITCALL ImporterAutoFixIAT(DWORD ProcessId, char* szDumpedFile, ULONG_PTR SearchStart);
__declspec(dllexport) long TITCALL ImporterAutoFixIATW(DWORD ProcessId, wchar_t* szDumpedFile, ULONG_PTR SearchStart);
__declspec(dllexport) long TITCALL ImporterAutoFixIATEx(DWORD ProcessId, const char* szDumpedFile, const char* szSectionName, bool DumpRunningProcess, bool RealignFile, ULONG_PTR EntryPointAddress, ULONG_PTR ImageBase, ULONG_PTR SearchStart, bool TryAutoFix, bool FixEliminations, LPVOID UnknownPointerFixCallback);
__declspec(dllexport) long TITCALL ImporterAutoFixIATExW(DWORD ProcessId, const wchar_t* szDumpedFile, const wchar_t* szSectionName, bool DumpRunningProcess, bool RealignFile, ULONG_PTR EntryPointAddress, ULONG_PTR ImageBase, ULONG_PTR SearchStart, bool TryAutoFix, bool FixEliminations, LPVOID UnknownPointerFixCallback);
__declspec(dllexport) long TITCALL ImporterAutoFixIAT(DWORD ProcessId, const char* szDumpedFile, ULONG_PTR SearchStart);
__declspec(dllexport) long TITCALL ImporterAutoFixIATW(DWORD ProcessId, const wchar_t* szDumpedFile, ULONG_PTR SearchStart);
__declspec(dllexport) bool TITCALL ImporterDeleteAPI(DWORD_PTR apiAddr);
// Global.Engine.Hook.functions:
__declspec(dllexport) bool TITCALL HooksSafeTransitionEx(LPVOID HookAddressArray, int NumberOfHooks, bool TransitionStart);
@ -882,17 +882,17 @@ __declspec(dllexport) bool TITCALL HooksIsAddressRedirected(LPVOID HookAddress);
__declspec(dllexport) void* TITCALL HooksGetTrampolineAddress(LPVOID HookAddress);
__declspec(dllexport) void* TITCALL HooksGetHookEntryDetails(LPVOID HookAddress);
__declspec(dllexport) bool TITCALL HooksInsertNewRedirection(LPVOID HookAddress, LPVOID RedirectTo, int HookType);
__declspec(dllexport) bool TITCALL HooksInsertNewIATRedirectionEx(ULONG_PTR FileMapVA, ULONG_PTR LoadedModuleBase, char* szHookFunction, LPVOID RedirectTo);
__declspec(dllexport) bool TITCALL HooksInsertNewIATRedirection(char* szModuleName, char* szHookFunction, LPVOID RedirectTo);
__declspec(dllexport) bool TITCALL HooksInsertNewIATRedirectionEx(ULONG_PTR FileMapVA, ULONG_PTR LoadedModuleBase, const char* szHookFunction, LPVOID RedirectTo);
__declspec(dllexport) bool TITCALL HooksInsertNewIATRedirection(const char* szModuleName, const char* szHookFunction, LPVOID RedirectTo);
__declspec(dllexport) bool TITCALL HooksRemoveRedirection(LPVOID HookAddress, bool RemoveAll);
__declspec(dllexport) bool TITCALL HooksRemoveRedirectionsForModule(HMODULE ModuleBase);
__declspec(dllexport) bool TITCALL HooksRemoveIATRedirection(char* szModuleName, char* szHookFunction, bool RemoveAll);
__declspec(dllexport) bool TITCALL HooksRemoveIATRedirection(const char* szModuleName, const char* szHookFunction, bool RemoveAll);
__declspec(dllexport) bool TITCALL HooksDisableRedirection(LPVOID HookAddress, bool DisableAll);
__declspec(dllexport) bool TITCALL HooksDisableRedirectionsForModule(HMODULE ModuleBase);
__declspec(dllexport) bool TITCALL HooksDisableIATRedirection(char* szModuleName, char* szHookFunction, bool DisableAll);
__declspec(dllexport) bool TITCALL HooksDisableIATRedirection(const char* szModuleName, const char* szHookFunction, bool DisableAll);
__declspec(dllexport) bool TITCALL HooksEnableRedirection(LPVOID HookAddress, bool EnableAll);
__declspec(dllexport) bool TITCALL HooksEnableRedirectionsForModule(HMODULE ModuleBase);
__declspec(dllexport) bool TITCALL HooksEnableIATRedirection(char* szModuleName, char* szHookFunction, bool EnableAll);
__declspec(dllexport) bool TITCALL HooksEnableIATRedirection(const char* szModuleName, const char* szHookFunction, bool EnableAll);
__declspec(dllexport) void TITCALL HooksScanModuleMemory(HMODULE ModuleBase, LPVOID CallBack);
__declspec(dllexport) void TITCALL HooksScanEntireProcessMemory(LPVOID CallBack);
__declspec(dllexport) void TITCALL HooksScanEntireProcessMemoryEx();
@ -903,53 +903,53 @@ __declspec(dllexport) ULONG_PTR TITCALL HashTracerLevel1(HANDLE hProcess, ULONG_
__declspec(dllexport) long TITCALL TracerDetectRedirection(HANDLE hProcess, ULONG_PTR AddressToTrace);
__declspec(dllexport) ULONG_PTR TITCALL TracerFixKnownRedirection(HANDLE hProcess, ULONG_PTR AddressToTrace, DWORD RedirectionId);
__declspec(dllexport) ULONG_PTR TITCALL TracerFixRedirectionViaModule(HMODULE hModuleHandle, HANDLE hProcess, ULONG_PTR AddressToTrace, DWORD IdParameter);
__declspec(dllexport) long TITCALL TracerFixRedirectionViaImpRecPlugin(HANDLE hProcess, char* szPluginName, ULONG_PTR AddressToTrace);
__declspec(dllexport) long TITCALL TracerFixRedirectionViaImpRecPlugin(HANDLE hProcess, const char* szPluginName, ULONG_PTR AddressToTrace);
// TitanEngine.Exporter.functions:
__declspec(dllexport) void TITCALL ExporterCleanup();
__declspec(dllexport) void TITCALL ExporterSetImageBase(ULONG_PTR ImageBase);
__declspec(dllexport) void TITCALL ExporterInit(DWORD MemorySize, ULONG_PTR ImageBase, DWORD ExportOrdinalBase, char* szExportModuleName);
__declspec(dllexport) bool TITCALL ExporterAddNewExport(char* szExportName, DWORD ExportRelativeAddress);
__declspec(dllexport) void TITCALL ExporterInit(DWORD MemorySize, ULONG_PTR ImageBase, DWORD ExportOrdinalBase, const char* szExportModuleName);
__declspec(dllexport) bool TITCALL ExporterAddNewExport(const char* szExportName, DWORD ExportRelativeAddress);
__declspec(dllexport) bool TITCALL ExporterAddNewOrdinalExport(DWORD OrdinalNumber, DWORD ExportRelativeAddress);
__declspec(dllexport) long TITCALL ExporterGetAddedExportCount();
__declspec(dllexport) long TITCALL ExporterEstimatedSize();
__declspec(dllexport) bool TITCALL ExporterBuildExportTable(ULONG_PTR StorePlace, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL ExporterBuildExportTableEx(char* szExportFileName, char* szSectionName);
__declspec(dllexport) bool TITCALL ExporterBuildExportTableExW(wchar_t* szExportFileName, char* szSectionName);
__declspec(dllexport) bool TITCALL ExporterLoadExportTable(char* szFileName);
__declspec(dllexport) bool TITCALL ExporterLoadExportTableW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL ExporterBuildExportTableEx(const char* szExportFileName, const char* szSectionName);
__declspec(dllexport) bool TITCALL ExporterBuildExportTableExW(const wchar_t* szExportFileName, const char* szSectionName);
__declspec(dllexport) bool TITCALL ExporterLoadExportTable(const char* szFileName);
__declspec(dllexport) bool TITCALL ExporterLoadExportTableW(const wchar_t* szFileName);
// TitanEngine.Librarian.functions:
__declspec(dllexport) bool TITCALL LibrarianSetBreakPoint(char* szLibraryName, DWORD bpxType, bool SingleShoot, LPVOID bpxCallBack);
__declspec(dllexport) bool TITCALL LibrarianRemoveBreakPoint(char* szLibraryName, DWORD bpxType);
__declspec(dllexport) void* TITCALL LibrarianGetLibraryInfo(char* szLibraryName);
__declspec(dllexport) void* TITCALL LibrarianGetLibraryInfoW(wchar_t* szLibraryName);
__declspec(dllexport) bool TITCALL LibrarianSetBreakPoint(const char* szLibraryName, DWORD bpxType, bool SingleShoot, LPVOID bpxCallBack);
__declspec(dllexport) bool TITCALL LibrarianRemoveBreakPoint(const char* szLibraryName, DWORD bpxType);
__declspec(dllexport) void* TITCALL LibrarianGetLibraryInfo(const char* szLibraryName);
__declspec(dllexport) void* TITCALL LibrarianGetLibraryInfoW(const wchar_t* szLibraryName);
__declspec(dllexport) void* TITCALL LibrarianGetLibraryInfoEx(void* BaseOfDll);
__declspec(dllexport) void* TITCALL LibrarianGetLibraryInfoExW(void* BaseOfDll);
__declspec(dllexport) void TITCALL LibrarianEnumLibraryInfo(void* EnumCallBack);
__declspec(dllexport) void TITCALL LibrarianEnumLibraryInfoW(void* EnumCallBack);
// TitanEngine.Process.functions:
__declspec(dllexport) long TITCALL GetActiveProcessId(char* szImageName);
__declspec(dllexport) long TITCALL GetActiveProcessIdW(wchar_t* szImageName);
__declspec(dllexport) void TITCALL EnumProcessesWithLibrary(char* szLibraryName, void* EnumFunction);
__declspec(dllexport) long TITCALL GetActiveProcessId(const char* szImageName);
__declspec(dllexport) long TITCALL GetActiveProcessIdW(const wchar_t* szImageName);
__declspec(dllexport) void TITCALL EnumProcessesWithLibrary(const char* szLibraryName, void* EnumFunction);
__declspec(dllexport) HANDLE TITCALL TitanOpenProcess(DWORD dwDesiredAccess, bool bInheritHandle, DWORD dwProcessId);
// TitanEngine.TLSFixer.functions:
__declspec(dllexport) bool TITCALL TLSBreakOnCallBack(LPVOID ArrayOfCallBacks, DWORD NumberOfCallBacks, LPVOID bpxCallBack);
__declspec(dllexport) bool TITCALL TLSGrabCallBackData(char* szFileName, LPVOID ArrayOfCallBacks, LPDWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSGrabCallBackDataW(wchar_t* szFileName, LPVOID ArrayOfCallBacks, LPDWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSBreakOnCallBackEx(char* szFileName, LPVOID bpxCallBack);
__declspec(dllexport) bool TITCALL TLSBreakOnCallBackExW(wchar_t* szFileName, LPVOID bpxCallBack);
__declspec(dllexport) bool TITCALL TLSRemoveCallback(char* szFileName);
__declspec(dllexport) bool TITCALL TLSRemoveCallbackW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL TLSRemoveTable(char* szFileName);
__declspec(dllexport) bool TITCALL TLSRemoveTableW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL TLSBackupData(char* szFileName);
__declspec(dllexport) bool TITCALL TLSBackupDataW(wchar_t* szFileName);
__declspec(dllexport) bool TITCALL TLSGrabCallBackData(const char* szFileName, LPVOID ArrayOfCallBacks, LPDWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSGrabCallBackDataW(const wchar_t* szFileName, LPVOID ArrayOfCallBacks, LPDWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSBreakOnCallBackEx(const char* szFileName, LPVOID bpxCallBack);
__declspec(dllexport) bool TITCALL TLSBreakOnCallBackExW(const wchar_t* szFileName, LPVOID bpxCallBack);
__declspec(dllexport) bool TITCALL TLSRemoveCallback(const char* szFileName);
__declspec(dllexport) bool TITCALL TLSRemoveCallbackW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL TLSRemoveTable(const char* szFileName);
__declspec(dllexport) bool TITCALL TLSRemoveTableW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL TLSBackupData(const char* szFileName);
__declspec(dllexport) bool TITCALL TLSBackupDataW(const wchar_t* szFileName);
__declspec(dllexport) bool TITCALL TLSRestoreData();
__declspec(dllexport) bool TITCALL TLSBuildNewTable(ULONG_PTR FileMapVA, ULONG_PTR StorePlace, ULONG_PTR StorePlaceRVA, LPVOID ArrayOfCallBacks, DWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSBuildNewTableEx(char* szFileName, char* szSectionName, LPVOID ArrayOfCallBacks, DWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSBuildNewTableExW(wchar_t* szFileName, char* szSectionName, LPVOID ArrayOfCallBacks, DWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSBuildNewTableEx(const char* szFileName, const char* szSectionName, LPVOID ArrayOfCallBacks, DWORD NumberOfCallBacks);
__declspec(dllexport) bool TITCALL TLSBuildNewTableExW(const wchar_t* szFileName, const char* szSectionName, LPVOID ArrayOfCallBacks, DWORD NumberOfCallBacks);
// TitanEngine.TranslateName.functions:
__declspec(dllexport) void* TITCALL TranslateNativeName(char* szNativeName);
__declspec(dllexport) void* TITCALL TranslateNativeNameW(wchar_t* szNativeName);
__declspec(dllexport) void* TITCALL TranslateNativeName(const char* szNativeName);
__declspec(dllexport) void* TITCALL TranslateNativeNameW(const wchar_t* szNativeName);
// TitanEngine.Handler.functions:
__declspec(dllexport) long TITCALL HandlerGetActiveHandleCount(DWORD ProcessId);
__declspec(dllexport) bool TITCALL HandlerIsHandleOpen(DWORD ProcessId, HANDLE hHandle);
@ -959,30 +959,30 @@ __declspec(dllexport) long TITCALL HandlerEnumerateOpenHandles(DWORD ProcessId,
__declspec(dllexport) ULONG_PTR TITCALL HandlerGetHandleDetails(HANDLE hProcess, DWORD ProcessId, HANDLE hHandle, DWORD InformationReturn);
__declspec(dllexport) bool TITCALL HandlerCloseRemoteHandle(HANDLE hProcess, HANDLE hHandle);
__declspec(dllexport) long TITCALL HandlerEnumerateLockHandles(char* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated, LPVOID HandleDataBuffer, DWORD MaxHandleCount);
__declspec(dllexport) long TITCALL HandlerEnumerateLockHandlesW(wchar_t* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated, LPVOID HandleDataBuffer, DWORD MaxHandleCount);
__declspec(dllexport) bool TITCALL HandlerCloseAllLockHandles(char* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
__declspec(dllexport) bool TITCALL HandlerCloseAllLockHandlesW(wchar_t* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
__declspec(dllexport) bool TITCALL HandlerIsFileLocked(char* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
__declspec(dllexport) bool TITCALL HandlerIsFileLockedW(wchar_t* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
__declspec(dllexport) long TITCALL HandlerEnumerateLockHandlesW(const wchar_t* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated, LPVOID HandleDataBuffer, DWORD MaxHandleCount);
__declspec(dllexport) bool TITCALL HandlerCloseAllLockHandles(const char* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
__declspec(dllexport) bool TITCALL HandlerCloseAllLockHandlesW(const wchar_t* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
__declspec(dllexport) bool TITCALL HandlerIsFileLocked(const char* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
__declspec(dllexport) bool TITCALL HandlerIsFileLockedW(const wchar_t* szFileOrFolderName, bool NameIsFolder, bool NameIsTranslated);
// TitanEngine.Handler[Mutex].functions:
__declspec(dllexport) long TITCALL HandlerEnumerateOpenMutexes(HANDLE hProcess, DWORD ProcessId, LPVOID HandleBuffer, DWORD MaxHandleCount);
__declspec(dllexport) ULONG_PTR TITCALL HandlerGetOpenMutexHandle(HANDLE hProcess, DWORD ProcessId, char* szMutexString);
__declspec(dllexport) ULONG_PTR TITCALL HandlerGetOpenMutexHandleW(HANDLE hProcess, DWORD ProcessId, wchar_t* szMutexString);
__declspec(dllexport) long TITCALL HandlerGetProcessIdWhichCreatedMutex(char* szMutexString);
__declspec(dllexport) long TITCALL HandlerGetProcessIdWhichCreatedMutexW(wchar_t* szMutexString);
__declspec(dllexport) ULONG_PTR TITCALL HandlerGetOpenMutexHandle(HANDLE hProcess, DWORD ProcessId, const char* szMutexString);
__declspec(dllexport) ULONG_PTR TITCALL HandlerGetOpenMutexHandleW(HANDLE hProcess, DWORD ProcessId, const wchar_t* szMutexString);
__declspec(dllexport) long TITCALL HandlerGetProcessIdWhichCreatedMutex(const char* szMutexString);
__declspec(dllexport) long TITCALL HandlerGetProcessIdWhichCreatedMutexW(const wchar_t* szMutexString);
// TitanEngine.Injector.functions:
__declspec(dllexport) bool TITCALL RemoteLoadLibrary(HANDLE hProcess, char* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteLoadLibraryW(HANDLE hProcess, wchar_t* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteFreeLibrary(HANDLE hProcess, HMODULE hModule, char* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteFreeLibraryW(HANDLE hProcess, HMODULE hModule, wchar_t* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteLoadLibrary(HANDLE hProcess, const char* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteLoadLibraryW(HANDLE hProcess, const wchar_t* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteFreeLibrary(HANDLE hProcess, HMODULE hModule, const char* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteFreeLibraryW(HANDLE hProcess, HMODULE hModule, const wchar_t* szLibraryFile, bool WaitForThreadExit);
__declspec(dllexport) bool TITCALL RemoteExitProcess(HANDLE hProcess, DWORD ExitCode);
// TitanEngine.StaticUnpacker.functions:
__declspec(dllexport) bool TITCALL StaticFileLoad(char* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileLoadW(wchar_t* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileUnload(char* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileOpen(char* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh);
__declspec(dllexport) bool TITCALL StaticFileOpenW(wchar_t* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh);
__declspec(dllexport) bool TITCALL StaticFileLoad(const char* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileLoadW(const wchar_t* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileUnload(const char* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileUnloadW(const wchar_t* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA);
__declspec(dllexport) bool TITCALL StaticFileOpen(const char* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh);
__declspec(dllexport) bool TITCALL StaticFileOpenW(const wchar_t* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh);
__declspec(dllexport) bool TITCALL StaticFileGetContent(HANDLE FileHandle, DWORD FilePositionLow, LPDWORD FilePositionHigh, void* Buffer, DWORD Size);
__declspec(dllexport) void TITCALL StaticFileClose(HANDLE FileHandle);
__declspec(dllexport) void TITCALL StaticMemoryDecrypt(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionType, DWORD DecryptionKeySize, ULONG_PTR DecryptionKey);
@ -990,40 +990,40 @@ __declspec(dllexport) void TITCALL StaticMemoryDecryptEx(LPVOID MemoryStart, DWO
__declspec(dllexport) void TITCALL StaticMemoryDecryptSpecial(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionKeySize, DWORD SpecDecryptionType, void* DecryptionCallBack);
__declspec(dllexport) void TITCALL StaticSectionDecrypt(ULONG_PTR FileMapVA, DWORD SectionNumber, bool SimulateLoad, DWORD DecryptionType, DWORD DecryptionKeySize, ULONG_PTR DecryptionKey);
__declspec(dllexport) bool TITCALL StaticMemoryDecompress(void* Source, DWORD SourceSize, void* Destination, DWORD DestinationSize, int Algorithm);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopy(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, char* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyW(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, char* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyExW(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, char* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64W(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopy(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, const char* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyW(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, const wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, const char* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyExW(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, const wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, const char* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64W(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, const wchar_t* szDumpFileName);
__declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD SizeOfMemory, void* HashDigest, bool OutputString, int Algorithm);
__declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* HashDigest, bool OutputString, int Algorithm);
__declspec(dllexport) bool TITCALL StaticHashFile(char* szFileName, char* HashDigest, bool OutputString, int Algorithm);
__declspec(dllexport) bool TITCALL StaticHashFileW(const wchar_t* szFileName, char* HashDigest, bool OutputString, int Algorithm);
__declspec(dllexport) bool TITCALL StaticHashFile(const char* szFileName, char* HashDigest, bool OutputString, int Algorithm);
// TitanEngine.Engine.functions:
__declspec(dllexport) void TITCALL EngineUnpackerInitialize(char* szFileName, char* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack);
__declspec(dllexport) void TITCALL EngineUnpackerInitializeW(wchar_t* szFileName, wchar_t* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack);
__declspec(dllexport) void TITCALL EngineUnpackerInitialize(const char* szFileName, const char* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack);
__declspec(dllexport) void TITCALL EngineUnpackerInitializeW(const wchar_t* szFileName, const wchar_t* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack);
__declspec(dllexport) bool TITCALL EngineUnpackerSetBreakCondition(void* SearchStart, DWORD SearchSize, void* SearchPattern, DWORD PatternSize, DWORD PatternDelta, ULONG_PTR BreakType, bool SingleBreak, DWORD Parameter1, DWORD Parameter2);
__declspec(dllexport) void TITCALL EngineUnpackerSetEntryPointAddress(ULONG_PTR UnpackedEntryPointAddress);
__declspec(dllexport) void TITCALL EngineUnpackerFinalizeUnpacking();
// TitanEngine.Engine.functions:
__declspec(dllexport) void TITCALL SetEngineVariable(DWORD VariableId, bool VariableSet);
__declspec(dllexport) bool TITCALL EngineCreateMissingDependencies(char* szFileName, char* szOutputFolder, bool LogCreatedFiles);
__declspec(dllexport) bool TITCALL EngineCreateMissingDependenciesW(wchar_t* szFileName, wchar_t* szOutputFolder, bool LogCreatedFiles);
__declspec(dllexport) bool TITCALL EngineCreateMissingDependencies(const char* szFileName, const char* szOutputFolder, bool LogCreatedFiles);
__declspec(dllexport) bool TITCALL EngineCreateMissingDependenciesW(const wchar_t* szFileName, const wchar_t* szOutputFolder, bool LogCreatedFiles);
__declspec(dllexport) bool TITCALL EngineFakeMissingDependencies(HANDLE hProcess);
__declspec(dllexport) bool TITCALL EngineDeleteCreatedDependencies();
__declspec(dllexport) bool TITCALL EngineCreateUnpackerWindow(char* WindowUnpackerTitle, char* WindowUnpackerLongTitle, char* WindowUnpackerName, char* WindowUnpackerAuthor, void* StartUnpackingCallBack);
__declspec(dllexport) void TITCALL EngineAddUnpackerWindowLogMessage(char* szLogMessage);
__declspec(dllexport) bool TITCALL EngineCreateUnpackerWindow(const char* WindowUnpackerTitle, const char* WindowUnpackerLongTitle, const char* WindowUnpackerName, const char* WindowUnpackerAuthor, void* StartUnpackingCallBack);
__declspec(dllexport) void TITCALL EngineAddUnpackerWindowLogMessage(const char* szLogMessage);
__declspec(dllexport) bool TITCALL EngineCheckStructAlignment(DWORD StructureType, ULONG_PTR StructureSize);
// Global.Engine.Extension.Functions:
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginLoaded(char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginEnabled(char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginLoaded(const char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginEnabled(const char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerDisableAllPlugins();
__declspec(dllexport) bool TITCALL ExtensionManagerDisablePlugin(char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerDisablePlugin(const char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerEnableAllPlugins();
__declspec(dllexport) bool TITCALL ExtensionManagerEnablePlugin(char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerEnablePlugin(const char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadAllPlugins();
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadPlugin(char* szPluginName);
__declspec(dllexport) void* TITCALL ExtensionManagerGetPluginInfo(char* szPluginName);
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadPlugin(const char* szPluginName);
__declspec(dllexport) void* TITCALL ExtensionManagerGetPluginInfo(const char* szPluginName);
#ifdef __cplusplus
}

View File

@ -0,0 +1,50 @@
/**
* UTF8 string library.
*
* Allows to use native UTF8 sequences as a string class. Has many overloaded
* operators that provides such features as concatenation, types converting and
* much more.
*
* Distributed under GPL v3
*
* Author:
* Grigory Gorelov (gorelov@grigory.info)
* See more information on grigory.info
*/
#include "Exception.h"
UTF8::Exception::Exception(const std::string & error, const int & StatusCode)
{
this->error = error;
this->StatusCode = StatusCode;
}
UTF8::Exception::Exception(std::string error)
{
this->error = error;
this->StatusCode = UnspecifiedException;
}
UTF8::Exception::Exception(const UTF8::Exception & e)
{
error = e.error;
StatusCode = e.StatusCode;
}
std::string UTF8::Exception::GetErrorString() const
{
return error;
}
int UTF8::Exception::GetErrorCode() const
{
return StatusCode;
}
UTF8::Exception & UTF8::Exception::operator =(const UTF8::Exception & e)
{
error = e.error;
error = e.StatusCode;
return *this;
}

View File

@ -0,0 +1,64 @@
/**
* UTF8 string library.
*
* Allows to use native UTF8 sequences as a string class. Has many overloaded
* operators that provides such features as concatenation, types converting and
* much more.
*
* Distributed under GPL v3
*
* Author:
* Grigory Gorelov (gorelov@grigory.info)
* See more information on grigory.info
*/
#ifndef _UTF8_Exception_H
#define _UTF8_Exception_H
#include <string>
namespace UTF8
{
/**
* Exception class. When something bad happens it is thowed by UTF8::String.
*/
class Exception
{
public:
enum
{
UnspecifiedException = 1,
StringToIntConversionError = 2,
StringToDoubleConversionError = 3,
FileNotFound = 4,
StringIsNotACharacter = 5
};
/**
* Just a constructor
*/
Exception(std::string error);
/// Just a constructor
Exception(const std::string & error, const int & StatusCode);
/// Copying constructor
Exception(const Exception & e);
/// Returns error string
std::string GetErrorString() const;
/// Returns error code
int GetErrorCode() const;
/// Assing operator
Exception & operator =(const Exception &);
private:
std::string error;
int StatusCode;
};
}
#endif /* _EXCEPTION_H */

View File

@ -0,0 +1,882 @@
/**
* UTF8 string library.
*
* Allows to use native UTF8 sequences as a string class. Has many overloaded
* operators that provides such features as concatenation, types converting and
* much more.
*
* Distributed under GPL v3
*
* Author:
* Grigory Gorelov (gorelov@grigory.info)
* See more information on grigory.info
*/
#include "String.h"
#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <ostream>
#include <stdint.h>
#include <errno.h>
#include "Exception.h"
bool UTF8::String::HasThisString(const UTF8::String & Str) const
{
return GetSubstringPosition(Str) != -1;
}
bool UTF8::String::CharacterIsOneOfThese(const UTF8::String & Characters) const
{
if(Length() == 1)
{
for(unsigned int i = 0; i < Characters.Length(); i++)
{
if(Characters[i] == *this)
{
return true;
}
}
return false;
}
else
{
throw Exception("[CharacterIsOneOfThese] String is more then one character length: \"" + ToString() + "\"", UTF8::Exception::StringIsNotACharacter);
}
}
UTF8::String UTF8::String::FromFile(const UTF8::String & Path)
{
UTF8::String s;
std::ifstream File;
File.open(Path.ToConstCharPtr());
if(File.is_open())
{
File.seekg(0, std::ios::end);
size_t Length = (size_t)File.tellg();
File.seekg(0, std::ios::beg);
char* buf = new char[Length + 1];
memset(buf, 0, Length + 1);
File.read(buf, Length);
s.AppendString(buf);
delete buf;
}
else
{
throw Exception("Cannot open file \"" + Path.ToString() + "\"", UTF8::Exception::FileNotFound);
}
File.close();
return s;
}
long UTF8::String::Search(const UTF8::String & SubString, unsigned int StartPosition, int Direction) const
{
unsigned int SubstringLength = SubString.Length();
unsigned int n = StartPosition;
if(n > Length() - SubstringLength)
{
if(Direction == SearchDirectionFromLeftToRight)
{
return -1;
}
else
{
n = Length() - SubstringLength;
}
}
if(n < 0)
{
if(Direction == SearchDirectionFromRightToLeft)
{
return -1;
}
else
{
n = 0;
}
}
while(((Direction == SearchDirectionFromLeftToRight) && (n < Length() - SubstringLength + 1)) || ((Direction == SearchDirectionFromRightToLeft) && (n >= 0)))
{
if(this->Substring(n, SubstringLength) == SubString)
{
return n;
}
n += Direction == SearchDirectionFromLeftToRight ? 1 : -1;
}
return -1;
}
std::ostream & operator<<(std::ostream & os, const UTF8::String & s)
{
os << s.ToString();
return os;
}
bool operator==(const char* str, const UTF8::String & StringObj)
{
return StringObj == str;
}
bool operator==(const std::string & str, const UTF8::String & StringObj)
{
return StringObj == str;
}
bool operator!=(const char* str, const UTF8::String & StringObj)
{
return StringObj != str;
}
bool operator!=(const std::string & str, const UTF8::String & StringObj)
{
return StringObj != str;
}
UTF8::String UTF8::String::Quote() const
{
return "\"" + (*this) + "\"";
}
UTF8::String UTF8::String::Trim() const
{
UTF8::String result = *this;
unsigned int i = 0;
while((result[i] == " ") || (result[i] == "\n") || (result[i] == "\r") || (result[i] == "\t"))
{
i++;
}
if(i == result.Length())
{
return UTF8::String();
}
long j = result.Length();
while((result[j - 1] == " ") || (result[j - 1] == "\n") || (result[j - 1] == "\r") || (result[j - 1] == "\t"))
{
j--;
}
result = result.Substring(i, j - i);
return result;
}
UTF8::String UTF8::String::Replace(const UTF8::String & Search, const UTF8::String & Replace) const
{
UTF8::String result = *this;
// Long to cover unsigned int and -1
long pos = 0;
while((pos = result.Search(Search, pos)) != -1)
{
result = result.SubstringReplace(pos, Search.Length(), Replace);
// Next time we search after replacement
pos += Replace.Length();
}
return result;
}
UTF8::String UTF8::String::SubstringReplace(unsigned int Start, unsigned int Count, const UTF8::String & Replace) const
{
if(Start < Length())
{
return (Start ? Substring(0, Start) : UTF8::String()) + Replace + Substring(Start + Count);
}
else
{
return *this;
}
}
UTF8::String UTF8::String::Implode(const std::vector <UTF8::String> & Strings, const UTF8::String & Separator)
{
if(Strings.size())
{
UTF8::String Result;
for(unsigned int i = 0; i < Strings.size(); i++)
{
if(Result.Length())
{
Result += Separator;
}
Result += Strings[i];
}
return Result;
}
else
{
return UTF8::String();
}
}
std::vector <UTF8::String> UTF8::String::Explode(const String & Separator) const
{
std::vector <UTF8::String> v;
unsigned int prev = 0;
unsigned int i = 0;
while(i < Length() - Separator.Length() + 1)
{
if(Substring(i, Separator.Length()) == Separator)
{
if(i - prev > 0)
{
v.push_back(Substring(prev, i - prev));
}
i += Separator.Length();
prev = i;
}
else
{
i++;
}
}
if(prev < Length())
{
v.push_back(Substring(prev, Length() - prev));
}
return v;
}
UTF8::String operator+(const char* CharPtr, const UTF8::String & StringObj)
{
UTF8::String s(CharPtr);
s += StringObj;
return s;
}
UTF8::String operator+(const std::string & str, const UTF8::String & StringObj)
{
UTF8::String s(str);
s += StringObj;
return s;
}
UTF8::String UTF8::String::operator+(const UTF8::String & s) const
{
UTF8::String res(*this);
res.AppendString(s.Data);
return res;
}
UTF8::String & UTF8::String::operator+=(const UTF8::String & s)
{
AppendString(s.Data);
return *this;
}
void UTF8::String::AppendString(const char* str)
{
// The functions that can fill buffer directly:
//
// SetString AppendString
//
// Make sure all preparations are done there
if(str && strlen(str))
{
if(DataArrayLength)
{
CheckIfStringIsCorrect(str);
unsigned int StrLength = (unsigned int)strlen(str);
Data = (char*) realloc(Data, DataArrayLength + StrLength + 1);
if(Data != NULL)
{
memcpy(Data + DataArrayLength, str, StrLength);
DataArrayLength += StrLength;
Data[DataArrayLength] = 0;
CalculateStringLength();
}
else
{
throw Exception("[AppendString] Cannot realloc any more memory");
}
}
else
{
SetString(str);
}
}
}
void UTF8::String::SetString(const char* str)
{
// The functions that can fill buffer directly:
//
// SetString AppendString
//
// Make sure all preparations are done there
if(str && strlen(str))
{
CheckIfStringIsCorrect(str);
Empty();
DataArrayLength = (unsigned int)strlen(str);
Data = new char[DataArrayLength + 1];
Data[DataArrayLength] = 0;
memcpy(Data, str, DataArrayLength);
CalculateStringLength();
}
else
{
Empty();
}
}
void UTF8::String::ConvertFromInt64(int64_t n)
{
Empty();
if(n)
{
bool minus;
if(n < 0)
{
n = -n;
minus = true;
}
else
{
minus = false;
}
char tmp[32] = "0";
const char* num = "0123456789";
memset(tmp, 0, 32);
unsigned int i = 30;
while(n)
{
tmp[i] = num[n % 10];
n /= 10;
i--;
if((i < 0) || ((i < 1) && minus))
{
throw Exception("[ConvertFromInt] Cycle terminated, buffer overflow.");
}
}
if(minus)
{
tmp[i] = '-';
i--;
}
SetString(tmp + i + 1);
}
else
{
SetString("0");
}
CalculateStringLength();
}
void UTF8::String::InitString()
{
Data = NULL;
DataArrayLength = 0;
StringLength = 0;
}
UTF8::String::String()
{
InitString();
}
UTF8::String::String(const std::string & s)
{
InitString();
CheckIfStringIsCorrect(s.c_str());
AppendString(s.c_str());
CalculateStringLength();
}
int UTF8::String::GetSymbolIndexInDataArray(unsigned int Position) const
{
if(Position >= StringLength)
{
throw Exception(UTF8::String("[GetSymbolIndexInDataArray] trying to get position beyond the end of string."));
}
unsigned int n = 0;
for(unsigned int i = 0; i < Position; i++)
{
n += GetSequenceLength(Data + n);
}
return n;
}
long UTF8::String::GetSubstringPosition(const UTF8::String & SubString, unsigned int Start) const
{
if(SubString.Length() > StringLength)
{
return -1;
}
unsigned int ScansCount = StringLength - SubString.StringLength + 1 - Start;
for(unsigned int i = 0; i < ScansCount; i++)
{
if(this->Substring(i + Start, SubString.StringLength) == SubString)
{
return i + Start;
}
}
return -1;
}
UTF8::String UTF8::String::Substring(unsigned int Start, unsigned int Count) const
{
if(Start >= StringLength)
{
return UTF8::String();
}
if((Start + Count > StringLength) || (Count == 0))
{
Count = StringLength - Start;
}
unsigned int StartIndex = GetSymbolIndexInDataArray(Start);
unsigned int CopyAmount = 0;
for(unsigned int i = 0; i < Count; i++)
{
CopyAmount += GetSequenceLength(Data + StartIndex + CopyAmount);
}
char* tmp = new char[CopyAmount + 1];
memcpy(tmp, Data + StartIndex, CopyAmount);
tmp[CopyAmount] = 0;
UTF8::String r(tmp);
delete tmp;
return r;
}
UTF8::String::String(const char* str)
{
InitString();
SetString(str);
}
UTF8::String::String(const uint32_t* str)
{
InitString();
ConvertFromUTF32(str);
}
void UTF8::String::ConvertFromUTF32(const uint32_t* s)
{
if(s)
{
unsigned int WideStringLength = 0;
do
{
WideStringLength++;
if(WideStringLength == 4294967295UL)
{
throw Exception("[ConvertFromUTF32] Cannot find termination symbol in incoming string.");
}
}
while(s[WideStringLength]);
char* tmp = new char[WideStringLength * 4 + 1];
memset(tmp, 0, WideStringLength * 4 + 1);
unsigned int pos = 0;
for(unsigned int i = 0; i < WideStringLength; i++)
{
uint32_t wc = s[i];
if(wc < 0x80)
{
tmp[pos++] = wc;
}
else if(wc < 0x800)
{
tmp[pos++] = (wc >> 6) | 0xC0 /* 0b11000000 */;
tmp[pos++] = (wc & 0x3F /* 0b00111111 */) | 0x80 /* 0b10000000 */;
}
else if(wc < 0x10000)
{
tmp[pos++] = (wc >> 12) | 0xE0 /* 0b11100000 */;
tmp[pos++] = ((wc >> 6) & 0x3F /* 0b00111111 */) | 0x80 /* 0b10000000 */;
tmp[pos++] = (wc & 0x3F /* 0b00111111 */) | 0x80 /* 0b10000000 */;
}
else
{
tmp[pos++] = (wc >> 18) | 0xF0 /* 0b11110000 */;
tmp[pos++] = ((wc >> 12) & 0x3F /* 0b00111111 */) | 0x80 /* 0b10000000 */;
tmp[pos++] = ((wc >> 6) & 0x3F /* 0b00111111 */) | 0x80 /* 0b10000000 */;
tmp[pos++] = (wc & 0x3F /* 0b00111111 */) | 0x80 /* 0b10000000 */;
}
}
SetString(tmp);
delete tmp;
}
}
void UTF8::String::CalculateStringLength()
{
// We are not writing anything to memory so limits are not needed
if(Data)
{
unsigned int n = 0, count = 0;
do
{
// We do not need to check line end here, it is checked when string is changed
n += GetSequenceLength(Data + n);
count++;
}
while(Data[n]);
StringLength = count;
}
else
{
StringLength = 0;
}
}
void UTF8::String::CheckIfStringIsCorrect(const char* str) const
{
if(str)
{
// We are not writing anything to memory so limits are not needed
unsigned int n = 0, i;
unsigned int SequenceLength;
while(str[n])
{
SequenceLength = GetSequenceLength(str + n);
for(i = 1; i < SequenceLength; i++)
{
if((((unsigned char) str[n + i]) >> 6) != 0x2 /* 0b00000010 */)
{
std::string s(str);
throw Exception("[CheckIfStringIsCorrect] Incorrect byte in UTF8 sequence: \"" + s + "\"");
}
}
n += SequenceLength;
if(n >= 0xFFFFFFFF - 4)
{
std::string s(str);
throw Exception("[CheckIfStringIsCorrect] termination char was not found in string: \"" + s + "\"");
}
}
}
}
bool UTF8::String::operator>(const UTF8::String & s) const
{
if(*this == s)
{
return false;
}
if(*this < s)
{
return false;
}
return true;
}
bool UTF8::String::operator<(const UTF8::String & s) const
{
unsigned int MinLength = StringLength < s.StringLength ? StringLength : s.StringLength;
//std::cout << "MinLength=" << MinLength;
unsigned int MyPos = 0, RemotePos = 0;
unsigned int MySequenceLength, RemoteSequenceLength;
for(unsigned int i = 0; i < MinLength; i++)
{
MySequenceLength = GetSequenceLength(Data + MyPos);
RemoteSequenceLength = GetSequenceLength(s.Data + RemotePos);
if(MySequenceLength < RemoteSequenceLength)
{
return true;
}
if(MySequenceLength > RemoteSequenceLength)
{
return false;
}
for(unsigned int j = 0; j < MySequenceLength; j++)
{
if(Data[MyPos + j] < s.Data[RemotePos + j])
{
return true;
}
if(Data[MyPos + j] > s.Data[RemotePos + j])
{
return false;
}
}
MyPos += MySequenceLength;
RemotePos += RemoteSequenceLength;
}
// If this string is substring of s (from left side) then it is lower
return StringLength < s.StringLength;
}
UTF8::String UTF8::String::operator[](unsigned int const n) const
{
if(n >= StringLength)
{
return UTF8::String();
}
if(n < 0)
{
return UTF8::String();
}
unsigned int pos = 0;
for(unsigned int i = 0; i < n; i++)
{
pos += GetSequenceLength(Data + pos);
}
char t[5];
memset(t, 0, 5);
memcpy(t, Data + pos, GetSequenceLength(Data + pos));
return UTF8::String(t);
}
unsigned int UTF8::String::GetSequenceLength(const char* StartByte) const
{
if(StartByte && strlen(StartByte))
{
unsigned char Byte = StartByte[0];
if(Byte < 128)
{
return 1;
}
// Here we need back order due to mask operation
if((Byte >> 5) == 0x6 /* 0b00000110 */)
{
return 2;
}
if((Byte >> 4) == 0xE /* 0b00001110 */)
{
return 3;
}
if((Byte >> 3) == 0x1E /* 0b00011110 */)
{
return 4;
}
throw Exception(std::string("[GetSequenceLength] Invalid UTF8 start byte. My own string is: [") + Data + "] Argument is: [" + StartByte + "]");
}
else
{
throw Exception(std::string("[GetSequenceLength] Invalid UTF8 start byte (it is empty). My own string is: [") + Data + "] Argument is: [" + StartByte + "]");
}
}
UTF8::String & UTF8::String::operator=(const String & Original)
{
// Check if objects are not same
if((unsigned int long) &Original != (unsigned int long) this)
{
Empty();
SetString(Original.Data);
}
return *this;
}
UTF8::String & UTF8::String::operator=(const char* str)
{
Empty();
SetString(str);
return *this;
}
UTF8::String & UTF8::String::operator=(const uint32_t* str)
{
Empty();
ConvertFromUTF32(str);
return *this;
}
UTF8::String::operator std::string() const
{
return this->ToString();
}
void UTF8::String::Empty()
{
if(DataArrayLength)
{
delete Data;
InitString();
}
}
std::string UTF8::String::ToString() const
{
if(DataArrayLength)
{
return std::string(Data);
}
else
{
return std::string();
}
}
UTF8::String UTF8::String::operator+(const char* s) const
{
UTF8::String res(*this);
res.AppendString(s);
return res;
}
bool UTF8::String::operator==(const UTF8::String & s) const
{
if(DataArrayLength != s.DataArrayLength)
{
return false;
}
else
{
for(unsigned int i = 0; i < DataArrayLength; i++)
{
if(Data[i] != s.Data[i])
{
return false;
}
}
return true;
}
}
bool UTF8::String::operator!=(const UTF8::String & s) const
{
return !(*this == s);
}
bool UTF8::String::operator==(const char* str) const
{
if(str && strlen(str))
{
if(DataArrayLength != strlen(str))
{
return false;
}
else
{
for(unsigned int i = 0; i < DataArrayLength; i++)
{
if(Data[i] != str[i])
{
return false;
}
}
return true;
}
}
else
{
return StringLength == 0;
}
}
bool UTF8::String::operator!=(const char* str) const
{
return !(*this == str);
}
const char* UTF8::String::ToConstCharPtr() const
{
return Data;
}
const char* UTF8::String::c_str() const
{
return Data;
}
unsigned int UTF8::String::Length() const
{
return StringLength;
}
unsigned int UTF8::String::DataLength() const
{
return DataArrayLength;
}
UTF8::String::~String()
{
Empty();
}
UTF8::String::String(const String & orig)
{
InitString();
SetString(orig.Data);
}

View File

@ -0,0 +1,309 @@
/**
* UTF8 string library.
*
* Allows to use native UTF8 sequences as a string class. Has many overloaded
* operators that provides such features as concatenation, types converting and
* much more.
*
* Distributed under GPL v3
*
* Author:
* Grigory Gorelov (gorelov@grigory.info)
* See more information on grigory.info
*/
#ifndef _UTF8_String_H
#define _UTF8_String_H
#include "Exception.h"
#include <string.h>
#include <stdint.h>
#include <fstream>
#include <vector>
namespace UTF8
{
/**
* The only string class containing everything to work with UTF8 strings
*/
class String
{
public:
static const int SearchDirectionFromLeftToRight = 1;
static const int SearchDirectionFromRightToLeft = 2;
/**
* Search substring in string
* @param StartPosition Position to start search
* @param Direction Search forward or backward, uses SearchDirectionFromLeftToRight and SearchDirectionFromRightToLeft
* @return Returns position of substring if found. Otherwise returns -1
*/
long Search(const UTF8::String & SubString, unsigned int StartPosition = 0, int Direction = SearchDirectionFromLeftToRight) const;
/// Simple constructor only initiates buffers
String();
/**
* Create string object from UTF8 char * string
*/
String(const char* str);
/**
* Create string object from UTF-32 string
*/
String(const uint32_t*);
/**
* Create string object from UTF8 std::string
*/
String(const std::string &);
/**
* Copying constructor. Feel free to such things UTF8::String s2=s1;
*/
String(const String & orig);
/**
* Deconstructor.
*/
~String();
/**
* Converts UTF8::String to std::string
*/
std::string ToString() const;
/**
* Reads content from a file and returns as UTF8::String
*/
static String FromFile(const UTF8::String & Path);
/**
* Converts UTF8::String to const char *
*/
const char* ToConstCharPtr() const;
/**
* Converts UTF8::String to const char *
*/
const char* c_str() const;
/**
* Separates string using given separator and returns vector
*/
std::vector <String> Explode(const String & Separator) const;
/**
* Creating String from array of String adding separator between them.
*/
static String Implode(const std::vector <String> & Strings, const String & Separator);
/**
* Sum operator. Provides String1+String2 exression.
*/
String operator+(const String &) const;
/**
* Sum operator. Provides String1+"Str" exression.
*/
String operator+(const char*) const;
/**
* Unary sum operator. Provides String1+=String2 expression.
*/
String & operator+=(const String &);
/**
* Assign operator. Provides String1=String2 expression.
*/
String & operator=(const String &);
/**
* Assign operator. Provides String1="New value" expression.
*/
String & operator=(const char*);
/**
* Assign operator. Provides String1=(uint32_t*) UTF32_StringPointer expression.
* Automatically converts UNICODE to UTF-8 ans stores in itself
*/
String & operator=(const uint32_t*);
/**
* Provides std::string test=String expression.
*/
operator std::string() const;
/**
* Returns substring of current string.
* @param Start Start position of substring
* @param Count Number of sybmols after start position. If number==0 string from Start till end is returned.
*/
String Substring(unsigned int Start, unsigned int Count = 0) const;
/**
* Replaces one text peace by another and returns result
* @param Search Search string
* @param Replace Replace string
* @return Returns result of replacement
*/
String Replace(const String & Search, const String & Replace) const;
/**
* Returns trimmed string. Removes whitespaces from left and right
*/
String Trim() const;
/**
* Returns string with nice quotes like this « ».
*/
String Quote() const;
/**
* Replaces region of string by text peace and returns result.
* @param Search Search string
* @param Replace Replace string
* @return Returns result of replacement
*/
String SubstringReplace(unsigned int Start, unsigned int Count, const String & Replace) const;
/**
* Returns position of substring in current string.
* @param Start Position to start search. Default is 0.
* @return If substring not found returns -1.
*/
long GetSubstringPosition(const UTF8::String & SubString, unsigned int Start = 0) const;
/**
* Get one char operator. Provides UTF8::String c=String1[1];
*/
String operator[](unsigned int const) const;
/**
* Test operator. Provides String1==String2 expression.
*/
bool operator==(const UTF8::String &) const;
/**
* Test operator. Provides String1!=String2 expression.
*/
bool operator!=(const UTF8::String &) const;
/**
* Test operator. Provides String1=="Test" expression.
*/
bool operator==(const char*) const;
/**
* Test operator. Provides String1!="Test" expression.
*/
bool operator!=(const char*) const;
/** Test operator. Provides String1<String2 expression.
* Operator compares left characters of two strings.
* If String1[0] value is less then the String2[0] returns true.
* If they are equal then goes to second character and so on.
* Can be used to sort strings alphabetical.
*/
bool operator<(const UTF8::String &) const;
/** Test operator. Provides String1>String2 expression.
* Operator compares left characters of two strings.
* If String1[0] value is greater then the String2[0] returns true.
* If they are equal then goes to second character and so on.
* Can be used to sort strings alphabetical.
*/
bool operator>(const UTF8::String &) const;
/**
* Returns current string length. Also see DataLength to get buffer
* size
*/
unsigned int Length() const;
/**
* Returns current char data array length, containig UTF8 string.
* As one character in UTF8 can be stored by more then one byte use
* this function to know how much memory allocated for the string.
*/
unsigned int DataLength() const;
/**
* Clears current string as if it is just created
*/
void Empty();
/**
* If string is a one character check if it is one of given
*/
bool CharacterIsOneOfThese(const UTF8::String & Characters) const;
/**
* Checks if this string contains given another string
*/
bool HasThisString(const UTF8::String & Str) const;
/**
* Special function to convert from very big integers
* Normally it is ok to assing UTF8::String to number. Or construct from it.
* This function exists only for very very big integers conversion.
*/
void ConvertFromInt64(int64_t n);
private:
char* Data;
unsigned int DataArrayLength;
unsigned int StringLength;
unsigned int GetSequenceLength(const char* StartByte) const;
void CheckIfStringIsCorrect(const char* str) const;
void CalculateStringLength();
void InitString();
void AppendString(const char* str);
void SetString(const char* str);
int GetSymbolIndexInDataArray(unsigned int Position) const;
void ConvertFromUTF32(const uint32_t*);
};
}
/**
* Not in class overloaded operator +. Provides "Sample"+String1 expression.
*/
UTF8::String operator+(const char*, const UTF8::String &);
/**
* Not in class overloaded operator +. Provides std::string("123")+String1 expression.
*/
UTF8::String operator+(const std::string &, const UTF8::String &);
/**
* Not in class overloaded operator ==. Provides "Test"==String1 expression.
*/
bool operator==(const char*, const UTF8::String &);
/**
* Not in class overloaded operator ==. Provides std::string==String1 expression.
*/
bool operator==(const std::string &, const UTF8::String &);
/**
* Not in class overloaded operator !=. Provides "Test"!=String1 expression.
*/
bool operator!=(const char*, const UTF8::String &);
/**
* Not in class overloaded operator !=. Provides std::string!=String1 expression.
*/
bool operator!=(const std::string &, const UTF8::String &);
/**
* Overloading for cout. Provides std::cout << (UTF8::String) operation;
*/
std::ostream & operator<<(std::ostream & os, const UTF8::String & s);
#endif /* _UTF8STRING_H */

View File

@ -0,0 +1,29 @@
#include "UString.h"
#include <windows.h>
//Functions taken from: http://www.nubaria.com/en/blog/?p=289
UString ConvertUtf16ToUtf8(const std::wstring & wstr)
{
std::string convertedString;
int requiredSize = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0);
if(requiredSize > 0)
{
std::vector<char> buffer(requiredSize);
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], requiredSize, 0, 0);
convertedString.assign(buffer.begin(), buffer.end() - 1);
}
return convertedString;
}
std::wstring ConvertUtf8ToUtf16(const UString & str)
{
std::wstring convertedString;
int requiredSize = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0);
if(requiredSize > 0)
{
std::vector<wchar_t> buffer(requiredSize);
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &buffer[0], requiredSize);
convertedString.assign(buffer.begin(), buffer.end() - 1);
}
return convertedString;
}

View File

@ -0,0 +1,12 @@
#ifndef _USTRING_H
#define _USTRING_H
#include "String.h"
#include <string>
typedef UTF8::String UString;
UString ConvertUtf16ToUtf8(const std::wstring & wstr);
std::wstring ConvertUtf8ToUtf16(const UString & str);
#endif // _USTRING_H

View File

@ -26,14 +26,14 @@ static bool _sectionfromaddr(duint addr, char* section)
HMODULE hMod = (HMODULE)modbasefromaddr(addr);
if(!hMod)
return false;
char curModPath[MAX_PATH] = "";
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, hMod, curModPath, MAX_PATH))
wchar_t curModPath[MAX_PATH] = L"";
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, hMod, curModPath, MAX_PATH))
return false;
HANDLE FileHandle;
DWORD LoadedSize;
HANDLE FileMap;
ULONG_PTR FileMapVA;
if(StaticFileLoad(curModPath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
if(StaticFileLoadW(curModPath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
{
uint rva = addr - (uint)hMod;
int sectionNumber = GetPE32SectionNumberFromVA(FileMapVA, GetPE32DataFromMappedFile(FileMapVA, 0, UE_IMAGEBASE) + rva);
@ -42,10 +42,10 @@ static bool _sectionfromaddr(duint addr, char* section)
const char* name = (const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
if(section)
strcpy(section, name);
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
StaticFileUnloadW(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
return true;
}
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
StaticFileUnloadW(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
}
return false;
}
@ -94,7 +94,14 @@ static bool _patchrestore(duint addr)
static int _modpathfromaddr(duint addr, char* path, int size)
{
return GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), path, size);
Memory<wchar_t*> wszModPath(size * sizeof(wchar_t), "_modpathfromaddr:wszModPath");
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)addr, wszModPath, size))
{
*path = '\0';
return 0;
}
strcpy_s(path, size, ConvertUtf16ToUtf8(wszModPath).c_str());
return (int)strlen(path);
}
static int _modpathfromname(const char* modname, char* path, int size)

View File

@ -60,7 +60,7 @@ typedef bool (*GETPROCESSLIST)(DBGPROCESSINFO** entries, int* count);
typedef bool (*GETPAGERIGHTS)(duint addr, char* rights);
typedef bool (*SETPAGERIGHTS)(duint addr, const char* rights);
typedef bool (*PAGERIGHTSTOSTRING)(DWORD protect, char* rights);
typedef bool (*ISPROCESSELEVATED)(void);
typedef bool (*ISPROCESSELEVATED)();
typedef bool (*GETCMDLINE)(char* cmdline, size_t* cbsize);
typedef bool (*SETCMDLINE)(const char* cmdline);

View File

@ -107,7 +107,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
pSymbol->MaxNameLen = MAX_LABEL_SIZE;
if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement)
{
if(settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
if(bUndecorateSymbolNames or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
strcpy_s(addrinfo->label, pSymbol->Name);
retval = true;
}
@ -122,7 +122,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
{
if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement)
{
if(settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
if(bUndecorateSymbolNames or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE))
sprintf_s(addrinfo->label, "JMP.&%s", pSymbol->Name);
retval = true;
}
@ -589,19 +589,13 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
case DBG_SETTINGS_UPDATED:
{
valuesetsignedcalc(!settingboolget("Engine", "CalculationType")); //0:signed, 1:unsigned
SetEngineVariable(UE_ENGINE_SET_DEBUG_PRIVILEGE, settingboolget("Engine", "EnableDebugPrivilege"));
bOnlyCipAutoComments = settingboolget("Disassembler", "OnlyCipAutoComments");
bListAllPages = settingboolget("Engine", "ListAllPages");
bUndecorateSymbolNames = settingboolget("Engine", "UndecorateSymbolNames");
uint setting;
if(BridgeSettingGetUint("Engine", "CalculationType", &setting))
{
switch(setting)
{
case 0: //calc_signed
valuesetsignedcalc(true);
break;
case 1: //calc_unsigned
valuesetsignedcalc(false);
break;
}
}
if(BridgeSettingGetUint("Engine", "BreakpointType", &setting))
{
switch(setting)
@ -617,13 +611,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
break;
}
}
if(BridgeSettingGetUint("Engine", "EnableDebugPrivilege", &setting))
{
if(setting)
SetEngineVariable(UE_ENGINE_SET_DEBUG_PRIVILEGE, true);
else
SetEngineVariable(UE_ENGINE_SET_DEBUG_PRIVILEGE, false);
}
char exceptionRange[MAX_SETTING_SIZE] = "";
dbgclearignoredexceptions();
if(BridgeSettingGet("Exceptions", "IgnoreRange", exceptionRange))
@ -643,13 +631,6 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
entry = strtok(0, ",");
}
}
if(BridgeSettingGetUint("Disassembler", "OnlyCipAutoComments", &setting))
{
if(setting)
bOnlyCipAutoComments = true;
else
bOnlyCipAutoComments = false;
}
}
break;

View File

@ -141,19 +141,23 @@ void formatdec(char* string)
bool FileExists(const char* file)
{
DWORD attrib = GetFileAttributes(file);
DWORD attrib = GetFileAttributesW(ConvertUtf8ToUtf16(file).c_str());
return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY));
}
bool DirExists(const char* dir)
{
DWORD attrib = GetFileAttributes(dir);
DWORD attrib = GetFileAttributesW(ConvertUtf8ToUtf16(dir).c_str());
return (attrib == FILE_ATTRIBUTE_DIRECTORY);
}
bool GetFileNameFromHandle(HANDLE hFile, char* szFileName)
{
return PathFromFileHandleA(hFile, szFileName, MAX_PATH);
wchar_t wszFileName[MAX_PATH] = L"";
if(!PathFromFileHandleW(hFile, wszFileName, sizeof(wszFileName)))
return false;
strcpy_s(szFileName, MAX_PATH, ConvertUtf16ToUtf8(wszFileName).c_str());
return true;
}
bool settingboolget(const char* section, const char* name)
@ -169,7 +173,7 @@ bool settingboolget(const char* section, const char* name)
arch GetFileArchitecture(const char* szFileName)
{
arch retval = notfound;
HANDLE hFile = CreateFileA(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
HANDLE hFile = CreateFileW(ConvertUtf8ToUtf16(szFileName).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile != INVALID_HANDLE_VALUE)
{
unsigned char data[0x1000];

View File

@ -21,6 +21,7 @@
#include "jansson\jansson.h"
#include "DeviceNameResolver\DeviceNameResolver.h"
#include "handle.h"
#include "UString\UString.h"
#ifdef __GNUC__
#include "dbghelp\dbghelp.h"

View File

@ -28,15 +28,29 @@ void dbsave()
functioncachesave(root);
loopcachesave(root);
bpcachesave(root);
std::wstring wdbpath = ConvertUtf8ToUtf16(dbpath);
if(json_object_size(root))
{
json_dump_file(root, dbpath, JSON_INDENT(4));
LZ4_compress_file(dbpath, dbpath);
FILE* jsonFile = 0;
if(_wfopen_s(&jsonFile, wdbpath.c_str(), L"wb"))
{
dputs("failed to open database file for editing!");
json_decref(root); //free root
return;
}
if(json_dumpf(root, jsonFile, JSON_INDENT(4)) == -1)
{
dputs("couldn't write JSON to database file...");
json_decref(root); //free root
return;
}
fclose(jsonFile);
LZ4_compress_fileW(wdbpath.c_str(), wdbpath.c_str());
}
else //remove database when nothing is in there
DeleteFileA(dbpath);
json_decref(root); //free root
DeleteFileW(wdbpath.c_str());
dprintf("%ums\n", GetTickCount() - ticks);
json_decref(root); //free root
}
void dbload()
@ -45,15 +59,23 @@ void dbload()
return;
dprintf("loading database...");
DWORD ticks = GetTickCount();
LZ4_STATUS status = LZ4_decompress_file(dbpath, dbpath);
std::wstring wdbpath = ConvertUtf8ToUtf16(dbpath);
LZ4_STATUS status = LZ4_decompress_fileW(wdbpath.c_str(), wdbpath.c_str());
if(status != LZ4_SUCCESS && status != LZ4_INVALID_ARCHIVE)
{
dputs("\ninvalid database file!");
return;
}
JSON root = json_load_file(dbpath, 0, 0);
FILE* jsonFile = 0;
if(_wfopen_s(&jsonFile, wdbpath.c_str(), L"rb"))
{
dputs("\nfailed to open database file!");
return;
}
JSON root = json_loadf(jsonFile, 0, 0);
fclose(jsonFile);
if(status != LZ4_INVALID_ARCHIVE)
LZ4_compress_file(dbpath, dbpath);
LZ4_compress_fileW(wdbpath.c_str(), wdbpath.c_str());
if(!root)
{
dputs("\ninvalid database file (JSON)!");
@ -87,6 +109,7 @@ bool modload(uint base, uint size, const char* fullpath)
if(!base or !size or !fullpath)
return false;
char name[deflen] = "";
int len = (int)strlen(fullpath);
while(fullpath[len] != '\\' and len)
len--;
@ -116,7 +139,8 @@ bool modload(uint base, uint size, const char* fullpath)
DWORD LoadedSize;
HANDLE FileMap;
ULONG_PTR FileMapVA;
if(StaticFileLoad((char*)fullpath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
std::wstring wszFullPath = ConvertUtf8ToUtf16(fullpath);
if(StaticFileLoadW(wszFullPath.c_str(), UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
{
info.entry = GetPE32DataFromMappedFile(FileMapVA, 0, UE_OEP) + info.base; //get entry point
int SectionCount = (int)GetPE32DataFromMappedFile(FileMapVA, 0, UE_SECTIONNUMBER);
@ -173,7 +197,7 @@ bool modload(uint base, uint size, const char* fullpath)
info.sections.push_back(curSection);
}
}
StaticFileUnload((char*)fullpath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
StaticFileUnloadW(wszFullPath.c_str(), false, FileHandle, LoadedSize, FileMap, FileMapVA);
}
//add module to list

View File

@ -1,5 +1,6 @@
#include "argument.h"
#include "console.h"
#include "UString/UString.h"
/*
formatarg:
@ -26,11 +27,13 @@ void argformat(char* cmd)
{
if(strlen(cmd) >= deflen)
return;
char command_[deflen] = "";
char* command = command_;
strcpy(command, cmd);
while(*command == ' ')
command++;
int len = (int)strlen(command);
int start = 0;
for(int i = 0; i < len; i++)
@ -42,18 +45,21 @@ void argformat(char* cmd)
}
if(!start)
start = len;
char arguments_[deflen] = "";
char* arguments = arguments_;
strcpy_s(arguments, deflen, command + start);
char temp[deflen] = "";
len = (int)strlen(arguments);
for(int i = 0, j = 0; i < len; i++)
{
if(arguments[i] == '"' and arguments[i + 1] == '"')
if(arguments[i] == '"' and arguments[i + 1] == '"') //TODO: fix this
i += 2;
j += sprintf(temp + j, "%c", arguments[i]);
}
strcpy_s(arguments, deflen, temp);
len = (int)strlen(arguments);
for(int i = 0; i < len; i++)
if(arguments[i] == '\\' and arguments[i + 1] == '\\')
@ -61,17 +67,20 @@ void argformat(char* cmd)
arguments[i] = 1;
arguments[i + 1] = 1;
}
while((*arguments == ',' or * arguments == ' ') and * (arguments - 1) != '\\')
arguments++;
len = (int)strlen(arguments);
while((arguments[len - 1] == ' ' or arguments[len - 1] == ',') and arguments[len - 2] != '\\')
len--;
arguments[len] = 0;
len = (int)strlen(arguments);
int quote_count = 0;
for(int i = 0; i < len; i++)
if(arguments[i] == '"')
quote_count++;
if(!(quote_count % 2))
{
for(int i = 0; i < len; i++)
@ -121,6 +130,7 @@ void argformat(char* cmd)
j += sprintf(temp + j, "%c", arguments[i]);
}
strcpy(arguments, temp);
len = (int)strlen(arguments);
for(int i = 0, j = 0; i < len; i++)
{
@ -129,6 +139,7 @@ void argformat(char* cmd)
j += sprintf(temp + j, "%c", arguments[i]);
}
strcpy(arguments, temp);
len = (int)strlen(arguments);
for(int i = 0; i < len; i++)
if(arguments[i] == 1 and arguments[i + 1] == 1)
@ -136,6 +147,7 @@ void argformat(char* cmd)
arguments[i] = '\\';
arguments[i + 1] = '\\';
}
if(strlen(arguments))
sprintf(cmd, "%s %s", command, arguments);
else
@ -169,6 +181,7 @@ int arggetcount(const char* cmd)
temp[i] = 1;
temp[i + 1] = 1;
}
for(int i = start; i < len; i++)
{
if(temp[i] == ',' and temp[i - 1] != '\\')
@ -202,6 +215,7 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional)
char temp_[deflen] = "";
char* temp = temp_ + 1;
strcpy(temp, cmd + start);
int len = (int)strlen(temp);
for(int i = 0; i < len; i++)
if(temp[i] == '\\' and temp[i + 1] == '\\')
@ -209,17 +223,20 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional)
temp[i] = 1;
temp[i + 1] = 1;
}
for(int i = 0; i < len; i++)
{
if(temp[i] == ',' and temp[i - 1] != '\\')
temp[i] = 0;
}
for(int i = 0; i < len; i++)
if(temp[i] == 1 and temp[i + 1] == 1)
{
temp[i] = '\\';
temp[i + 1] = '\\';
}
char new_temp[deflen] = "";
int new_len = len;
for(int i = 0, j = 0; i < len; i++) //handle escape characters

View File

@ -34,6 +34,7 @@ char szSymbolCachePath[MAX_PATH] = "";
char sqlitedb[deflen] = "";
PROCESS_INFORMATION* fdProcessInfo = &g_pi;
HANDLE hActiveThread;
bool bUndecorateSymbolNames = true;
static DWORD WINAPI memMapThread(void* ptr)
{
@ -650,8 +651,11 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
char DebugFileName[deflen] = "";
if(!GetFileNameFromHandle(CreateProcessInfo->hFile, DebugFileName))
{
if(!DevicePathFromFileHandleA(CreateProcessInfo->hFile, DebugFileName, deflen))
wchar_t wszFileName[MAX_PATH] = L"";
if(!DevicePathFromFileHandleW(CreateProcessInfo->hFile, wszFileName, sizeof(wszFileName)))
strcpy(DebugFileName, "??? (GetFileNameFromHandle failed!)");
else
strcpy_s(DebugFileName, MAX_PATH, ConvertUtf16ToUtf8(wszFileName).c_str());
}
dprintf("Process Started: "fhex" %s\n", base, DebugFileName);
@ -696,12 +700,12 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
if(settingboolget("Events", "TlsCallbacks"))
{
DWORD NumberOfCallBacks = 0;
TLSGrabCallBackData(DebugFileName, 0, &NumberOfCallBacks);
TLSGrabCallBackDataW(ConvertUtf8ToUtf16(DebugFileName).c_str(), 0, &NumberOfCallBacks);
if(NumberOfCallBacks)
{
dprintf("TLS Callbacks: %d\n", NumberOfCallBacks);
Memory<uint*> TLSCallBacks(NumberOfCallBacks * sizeof(uint), "cbCreateProcess:TLSCallBacks");
if(!TLSGrabCallBackData(DebugFileName, TLSCallBacks, &NumberOfCallBacks))
if(!TLSGrabCallBackDataW(ConvertUtf8ToUtf16(DebugFileName).c_str(), TLSCallBacks, &NumberOfCallBacks))
dputs("failed to get TLS callback addresses!");
else
{
@ -849,8 +853,11 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
char DLLDebugFileName[deflen] = "";
if(!GetFileNameFromHandle(LoadDll->hFile, DLLDebugFileName))
{
if(!DevicePathFromFileHandleA(LoadDll->hFile, DLLDebugFileName, deflen))
wchar_t wszFileName[MAX_PATH] = L"";
if(!DevicePathFromFileHandleW(LoadDll->hFile, wszFileName, sizeof(wszFileName)))
strcpy(DLLDebugFileName, "??? (GetFileNameFromHandle failed!)");
else
strcpy_s(DLLDebugFileName, MAX_PATH, ConvertUtf16ToUtf8(wszFileName).c_str());
}
SymLoadModuleEx(fdProcessInfo->hProcess, LoadDll->hFile, DLLDebugFileName, 0, (DWORD64)base, 0, 0, 0);
IMAGEHLP_MODULE64 modInfo;
@ -1169,13 +1176,13 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
bSkipExceptions = false;
bBreakOnNextDll = false;
INIT_STRUCT* init = (INIT_STRUCT*)lpParameter;
bFileIsDll = IsFileDLL(init->exe, 0);
pDebuggedEntry = GetPE32Data(init->exe, 0, UE_OEP);
bFileIsDll = IsFileDLLW(ConvertUtf8ToUtf16(init->exe).c_str(), 0);
pDebuggedEntry = GetPE32DataW(ConvertUtf8ToUtf16(init->exe).c_str(), 0, UE_OEP);
strcpy_s(szFileName, init->exe);
if(bFileIsDll)
fdProcessInfo = (PROCESS_INFORMATION*)InitDLLDebug(init->exe, false, init->commandline, init->currentfolder, 0);
fdProcessInfo = (PROCESS_INFORMATION*)InitDLLDebugW(ConvertUtf8ToUtf16(init->exe).c_str(), false, ConvertUtf8ToUtf16(init->commandline).c_str(), ConvertUtf8ToUtf16(init->currentfolder).c_str(), 0);
else
fdProcessInfo = (PROCESS_INFORMATION*)InitDebug(init->exe, init->commandline, init->currentfolder);
fdProcessInfo = (PROCESS_INFORMATION*)InitDebugW(ConvertUtf8ToUtf16(init->exe).c_str(), ConvertUtf8ToUtf16(init->commandline).c_str(), ConvertUtf8ToUtf16(init->currentfolder).c_str());
if(!fdProcessInfo)
{
fdProcessInfo = &g_pi;
@ -1495,7 +1502,7 @@ bool IsProcessElevated()
return !!IsAdminMember;
}
static bool readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char* key, arch arch_in, arch* arch_out, readwritejitkey_error_t* error, bool write)
static bool readwritejitkey(wchar_t* jit_key_value, DWORD* jit_key_vale_size, char* key, arch arch_in, arch* arch_out, readwritejitkey_error_t* error, bool write)
{
DWORD key_flags;
DWORD lRv;
@ -1557,7 +1564,7 @@ static bool readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char*
if(lRv != ERROR_SUCCESS)
return false;
lRv = RegSetValueExA(hKey, key, 0, REG_SZ, (BYTE*) jit_key_value, (DWORD)(* jit_key_vale_size) + 1);
lRv = RegSetValueExW(hKey, ConvertUtf8ToUtf16(key).c_str(), 0, REG_SZ, (BYTE*)jit_key_value, (DWORD)(*jit_key_vale_size) + 1);
}
else
{
@ -1565,7 +1572,7 @@ static bool readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char*
if(lRv != ERROR_SUCCESS)
return false;
lRv = RegQueryValueExA(hKey, key, 0, NULL, (LPBYTE)jit_key_value, jit_key_vale_size);
lRv = RegQueryValueExW(hKey, ConvertUtf8ToUtf16(key).c_str(), 0, NULL, (LPBYTE)jit_key_value, jit_key_vale_size);
if(lRv != ERROR_SUCCESS)
{
if(error != NULL)
@ -1691,7 +1698,7 @@ bool dbggetpagerights(uint addr, char* rights)
bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
{
char jit_entry[4];
wchar_t jit_entry[4] = L"";
DWORD jit_entry_size = sizeof(jit_entry) - 1;
readwritejitkey_error_t rw_error;
@ -1705,9 +1712,9 @@ bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_
}
return false;
}
if(_strcmpi(jit_entry, "1") == 0)
if(_wcsicmp(jit_entry, L"1") == 0)
*auto_on = true;
else if(_strcmpi(jit_entry, "0") == 0)
else if(_wcsicmp(jit_entry, L"0") == 0)
*auto_on = false;
else
return false;
@ -1716,11 +1723,11 @@ bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_
bool dbgsetjitauto(bool auto_on, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
{
DWORD auto_string_size = sizeof("1");
DWORD auto_string_size = sizeof(L"1");
readwritejitkey_error_t rw_error;
if(!auto_on)
{
char jit_entry[4];
wchar_t jit_entry[4] = L"";
DWORD jit_entry_size = sizeof(jit_entry) - 1;
if(!readwritejitkey(jit_entry, &jit_entry_size, "Auto", arch_in, arch_out, &rw_error, false))
{
@ -1728,7 +1735,7 @@ bool dbgsetjitauto(bool auto_on, arch arch_in, arch* arch_out, readwritejitkey_e
return true;
}
}
if(!readwritejitkey(auto_on ? "1" : "0", &auto_string_size, "Auto", arch_in, arch_out, &rw_error, true))
if(!readwritejitkey(auto_on ? L"1" : L"0", &auto_string_size, "Auto", arch_in, arch_out, &rw_error, true))
{
if(rw_error_out != NULL)
*rw_error_out = rw_error;
@ -1739,14 +1746,16 @@ bool dbgsetjitauto(bool auto_on, arch arch_in, arch* arch_out, readwritejitkey_e
bool dbggetjit(char jit_entry[JIT_ENTRY_MAX_SIZE], arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
{
DWORD jit_entry_size = JIT_ENTRY_MAX_SIZE;
wchar_t wszJitEntry[JIT_ENTRY_MAX_SIZE] = L"";
DWORD jit_entry_size = JIT_ENTRY_MAX_SIZE * sizeof(wchar_t);
readwritejitkey_error_t rw_error;
if(!readwritejitkey(jit_entry, &jit_entry_size, "Debugger", arch_in, arch_out, &rw_error, false))
if(!readwritejitkey(wszJitEntry, &jit_entry_size, "Debugger", arch_in, arch_out, &rw_error, false))
{
if(rw_error_out != NULL)
*rw_error_out = rw_error;
return false;
}
strcpy_s(jit_entry, JIT_ENTRY_MAX_SIZE, ConvertUtf16ToUtf8(wszJitEntry).c_str());
return true;
}
@ -1754,7 +1763,9 @@ bool dbggetdefjit(char* jit_entry)
{
char path[JIT_ENTRY_DEF_SIZE];
path[0] = '"';
GetModuleFileNameA(GetModuleHandleA(NULL), &path[1], MAX_PATH);
wchar_t wszPath[MAX_PATH] = L"";
GetModuleFileNameW(GetModuleHandleW(NULL), wszPath, MAX_PATH);
strcpy(&path[1], ConvertUtf16ToUtf8(wszPath).c_str());
strcat(path, ATTACH_CMD_LINE);
strcpy(jit_entry, path);
return true;
@ -1762,9 +1773,9 @@ bool dbggetdefjit(char* jit_entry)
bool dbgsetjit(char* jit_cmd, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
{
DWORD jit_cmd_size = (DWORD)strlen(jit_cmd);
DWORD jit_cmd_size = (DWORD)strlen(jit_cmd) * sizeof(wchar_t);
readwritejitkey_error_t rw_error;
if(!readwritejitkey(jit_cmd, & jit_cmd_size, "Debugger", arch_in, arch_out, & rw_error, true))
if(!readwritejitkey((wchar_t*)ConvertUtf8ToUtf16(jit_cmd).c_str(), & jit_cmd_size, "Debugger", arch_in, arch_out, & rw_error, true))
{
if(rw_error_out != NULL)
*rw_error_out = rw_error;
@ -1799,9 +1810,9 @@ bool dbglistprocesses(std::vector<PROCESSENTRY32>* list)
continue;
if((mewow64 and !wow64) or (!mewow64 and wow64))
continue;
char szExePath[MAX_PATH] = "";
if(GetModuleFileNameExA(hProcess, 0, szExePath, sizeof(szExePath)))
strcpy_s(pe32.szExeFile, szExePath);
wchar_t szExePath[MAX_PATH] = L"";
if(GetModuleFileNameExW(hProcess, 0, szExePath, MAX_PATH))
strcpy_s(pe32.szExeFile, ConvertUtf16ToUtf8(szExePath).c_str());
list->push_back(pe32);
}
while(Process32Next(hProcessSnap, &pe32));
@ -1937,7 +1948,7 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error)
Memory<wchar_t*> command_linewstr(new_command_line.Length);
// Covert to Unicode.
if(!MultiByteToWideChar(CP_ACP, 0, cmd_line, (int)cmd_line_size + 1, command_linewstr, (int)cmd_line_size + 1))
if(!MultiByteToWideChar(CP_UTF8, 0, cmd_line, (int)cmd_line_size + 1, command_linewstr, (int)cmd_line_size + 1))
{
cmd_line_error->type = CMDL_ERR_CONVERTUNICODE;
return false;
@ -2012,8 +2023,8 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error)
*cmd_line = (char*)emalloc(cmd_line_size, "dbggetcmdline:cmd_line");
//Convert TO ASCII
if(!WideCharToMultiByte(CP_ACP, 0, wstr_cmd, (int)wstr_cmd_size, * cmd_line, (int)cmd_line_size, NULL, NULL))
//Convert TO UTF-8
if(!WideCharToMultiByte(CP_UTF8, 0, wstr_cmd, (int)wstr_cmd_size, * cmd_line, (int)cmd_line_size, NULL, NULL))
{
efree(*cmd_line);
cmd_line_error->type = CMDL_ERR_CONVERTUNICODE;

View File

@ -13,7 +13,6 @@
#define JIT_ENTRY_MAX_SIZE 512
#define JIT_REG_KEY TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug")
typedef enum
{
ERROR_RW = 0,
@ -129,5 +128,6 @@ extern PROCESS_INFORMATION* fdProcessInfo;
extern HANDLE hActiveThread;
extern char szFileName[MAX_PATH];
extern char szSymbolCachePath[MAX_PATH];
extern bool bUndecorateSymbolNames;
#endif // _DEBUGGER_H

View File

@ -25,7 +25,7 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
dputs("file does not exist!");
return STATUS_ERROR;
}
HANDLE hFile = CreateFileA(arg1, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
HANDLE hFile = CreateFileW(ConvertUtf8ToUtf16(arg1).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile == INVALID_HANDLE_VALUE)
{
dputs("could not open file!");
@ -67,6 +67,7 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
while(currentfolder[len] != '\\' and len != 0)
len--;
currentfolder[len] = 0;
if(DirExists(arg3))
strcpy(currentfolder, arg3);
//initialize
@ -808,7 +809,7 @@ static DWORD WINAPI scyllaThread(void* lpParam)
{
typedef INT (WINAPI * SCYLLASTARTGUI)(DWORD pid, HINSTANCE mod);
SCYLLASTARTGUI ScyllaStartGui = 0;
HINSTANCE hScylla = LoadLibraryA("Scylla.dll");
HINSTANCE hScylla = LoadLibraryW(L"Scylla.dll");
if(!hScylla)
{
dputs("error loading Scylla.dll!");
@ -885,11 +886,13 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
#endif // _WIN64
return STATUS_ERROR;
}
if(!GetModuleFileNameExA(hProcess, 0, szFileName, sizeof(szFileName)))
wchar_t wszFileName[MAX_PATH] = L"";
if(!GetModuleFileNameExW(hProcess, 0, wszFileName, MAX_PATH))
{
dprintf("could not get module filename %X!\n", pid);
return STATUS_ERROR;
}
strcpy_s(szFileName, ConvertUtf16ToUtf8(wszFileName).c_str());
CloseHandle(CreateThread(0, 0, threadAttachLoop, (void*)pid, 0, 0));
return STATUS_CONTINUE;
}
@ -1348,12 +1351,14 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
dprintf("invalid module \"%s\"!\n", argv[1]);
return STATUS_ERROR;
}
char szModulePath[MAX_PATH] = "";
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szModulePath, MAX_PATH))
wchar_t wszModulePath[MAX_PATH] = L"";
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, wszModulePath, MAX_PATH))
{
dputs("GetModuleFileNameExA failed!");
return STATUS_ERROR;
}
char szModulePath[MAX_PATH] = "";
strcpy_s(szModulePath, ConvertUtf16ToUtf8(wszModulePath).c_str());
char szOldSearchPath[MAX_PATH] = "";
if(!SymGetSearchPath(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current search path
{

View File

@ -223,7 +223,7 @@ CMDRESULT cbInstrChd(int argc, char* argv[])
dputs("directory doesn't exist");
return STATUS_ERROR;
}
SetCurrentDirectoryA(argv[1]);
SetCurrentDirectoryW(ConvertUtf8ToUtf16(argv[1]).c_str());
dputs("current directory changed!");
return STATUS_CONTINUE;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -17,7 +17,9 @@ extern "C"
#endif
__declspec(dllimport) LZ4_STATUS LZ4_compress_file(const char* input_filename, const char* output_filename);
__declspec(dllimport) LZ4_STATUS LZ4_compress_fileW(const wchar_t* input_filename, const wchar_t* output_filename);
__declspec(dllimport) LZ4_STATUS LZ4_decompress_file(const char* input_filename, const char* output_filename);
__declspec(dllimport) LZ4_STATUS LZ4_decompress_fileW(const wchar_t* input_filename, const wchar_t* output_filename);
#if defined (__cplusplus)
}

View File

@ -5,6 +5,7 @@
#include "threading.h"
MemoryMap memoryPages;
bool bListAllPages = false;
void memupdatemap(HANDLE hProcess)
{
@ -14,11 +15,6 @@ void memupdatemap(HANDLE hProcess)
uint MyAddress = 0, newAddress = 0;
uint curAllocationBase = 0;
uint setting = 0;
bool bListAllPages = false;
if(BridgeSettingGetUint("Engine", "ListAllPages", &setting) && setting)
bListAllPages = true;
std::vector<MEMPAGE> pageVector;
do
{

View File

@ -7,6 +7,7 @@
typedef std::map<Range, MEMPAGE, RangeCompare> MemoryMap;
extern MemoryMap memoryPages;
extern bool bListAllPages;
struct PATTERNNIBBLE
{

View File

@ -153,14 +153,14 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
sprintf(error, "failed to get base of module %s", modname);
return -1;
}
char szOriginalName[MAX_PATH] = "";
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szOriginalName, MAX_PATH))
wchar_t szOriginalName[MAX_PATH] = L"";
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szOriginalName, MAX_PATH))
{
if(error)
sprintf(error, "failed to get module path of module %s", modname);
return -1;
}
if(!CopyFileA(szOriginalName, szFileName, false))
if(!CopyFileW(szOriginalName, ConvertUtf8ToUtf16(szFileName).c_str(), false))
{
if(error)
strcpy(error, "failed to make a copy of the original file (patch target is in use?)");
@ -170,7 +170,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
DWORD LoadedSize;
HANDLE FileMap;
ULONG_PTR FileMapVA;
if(StaticFileLoad((char*)szFileName, UE_ACCESS_ALL, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
if(StaticFileLoadW(ConvertUtf8ToUtf16(szFileName).c_str(), UE_ACCESS_ALL, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
{
int patched = 0;
for(int i = 0; i < count; i++)
@ -182,7 +182,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
*ptr = patchlist[i].newbyte;
patched++;
}
if(!StaticFileUnload((char*)szFileName, true, FileHandle, LoadedSize, FileMap, FileMapVA))
if(!StaticFileUnloadW(ConvertUtf8ToUtf16(szFileName).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA))
{
if(error)
strcpy(error, "StaticFileUnload failed");

View File

@ -14,20 +14,20 @@ static std::vector<PLUG_MENU> pluginMenuList;
void pluginload(const char* pluginDir)
{
//load new plugins
char currentDir[deflen] = "";
GetCurrentDirectoryA(deflen, currentDir);
SetCurrentDirectoryA(pluginDir);
wchar_t currentDir[deflen] = L"";
GetCurrentDirectoryW(deflen, currentDir);
SetCurrentDirectoryW(ConvertUtf8ToUtf16(pluginDir).c_str());
char searchName[deflen] = "";
#ifdef _WIN64
sprintf(searchName, "%s\\*.dp64", pluginDir);
#else
sprintf(searchName, "%s\\*.dp32", pluginDir);
#endif // _WIN64
WIN32_FIND_DATA foundData;
HANDLE hSearch = FindFirstFileA(searchName, &foundData);
WIN32_FIND_DATAW foundData;
HANDLE hSearch = FindFirstFileW(ConvertUtf8ToUtf16(searchName).c_str(), &foundData);
if(hSearch == INVALID_HANDLE_VALUE)
{
SetCurrentDirectoryA(currentDir);
SetCurrentDirectoryW(currentDir);
return;
}
PLUG_DATA pluginData;
@ -36,8 +36,8 @@ void pluginload(const char* pluginDir)
//set plugin data
pluginData.initStruct.pluginHandle = curPluginHandle;
char szPluginPath[MAX_PATH] = "";
sprintf(szPluginPath, "%s\\%s", pluginDir, foundData.cFileName);
pluginData.hPlugin = LoadLibraryA(szPluginPath); //load the plugin library
sprintf_s(szPluginPath, "%s\\%s", pluginDir, ConvertUtf16ToUtf8(foundData.cFileName).c_str());
pluginData.hPlugin = LoadLibraryW(ConvertUtf8ToUtf16(szPluginPath).c_str()); //load the plugin library
if(!pluginData.hPlugin)
{
dprintf("[PLUGIN] Failed to load plugin: %s\n", foundData.cFileName);
@ -185,8 +185,8 @@ void pluginload(const char* pluginDir)
}
curPluginHandle++;
}
while(FindNextFileA(hSearch, &foundData));
SetCurrentDirectoryA(currentDir);
while(FindNextFileW(hSearch, &foundData));
SetCurrentDirectoryW(currentDir);
}
static void plugincmdunregisterall(int pluginHandle)

View File

@ -62,7 +62,7 @@ static int scriptinternalstep(int fromIp) //internal step routine
static bool scriptcreatelinemap(const char* filename)
{
HANDLE hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
HANDLE hFile = CreateFileW(ConvertUtf8ToUtf16(filename).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile == INVALID_HANDLE_VALUE)
{
GuiScriptError(0, "CreateFile failed...");

View File

@ -101,10 +101,10 @@ void symdownloadallsymbols(const char* szSymbolStore)
{
dprintf("downloading symbols for %s...\n", modList.at(i).name);
uint modbase = modList.at(i).base;
char szModulePath[MAX_PATH] = "";
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szModulePath, MAX_PATH))
wchar_t szModulePath[MAX_PATH] = L"";
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModulePath, MAX_PATH))
{
dprintf("GetModuleFileNameExA("fhex") failed!\n", modbase);
dprintf("GetModuleFileNameExW("fhex") failed!\n", modbase);
continue;
}
if(!SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase))
@ -112,7 +112,7 @@ void symdownloadallsymbols(const char* szSymbolStore)
dprintf("SymUnloadModule64("fhex") failed!\n", modbase);
continue;
}
if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, szModulePath, 0, (DWORD64)modbase, 0, 0, 0))
if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, ConvertUtf16ToUtf8(szModulePath).c_str(), 0, (DWORD64)modbase, 0, 0, 0))
{
dprintf("SymLoadModuleEx("fhex") failed!\n", modbase);
continue;
@ -155,7 +155,7 @@ const char* symgetsymbolicname(uint addr)
pSymbol->MaxNameLen = MAX_LABEL_SIZE;
if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement)
{
if(!settingboolget("Engine", "UndecorateSymbolNames") or !UnDecorateSymbolName(pSymbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE))
if(!bUndecorateSymbolNames or !UnDecorateSymbolName(pSymbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE))
strcpy_s(label, pSymbol->Name);
retval = true;
}

View File

@ -1,6 +1,6 @@
#include "threading.h"
static volatile bool waitarray[16];
static volatile bool waitarray[WAITID_LAST];
void waitclear()
{

View File

@ -8,7 +8,7 @@ enum WAIT_ID
{
WAITID_RUN,
WAITID_STOP,
WAITID_USERDB
WAITID_LAST
};
//functions

View File

@ -991,59 +991,61 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
if(!strlen(apiname))
return false;
uint modbase = modbasefromname(modname);
char szModName[MAX_PATH];
if(!GetModuleFileNameEx(fdProcessInfo->hProcess, (HMODULE)modbase, szModName, MAX_PATH))
wchar_t szModName[MAX_PATH] = L"";
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModName, MAX_PATH))
{
if(!silent)
dprintf("could not get filename of module "fhex"\n", modbase);
}
else
{
char szBaseName[256] = "";
int len = (int)strlen(szModName);
while(szModName[len] != '\\')
len--;
strcpy_s(szBaseName, szModName + len + 1);
HMODULE mod = LoadLibraryExA(szModName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
if(!mod)
wchar_t* szBaseName = wcschr(szModName, L'\\');
if(szBaseName)
{
if(!silent)
dprintf("unable to load library %s\n", szBaseName);
}
else
{
uint addr = (uint)GetProcAddress(mod, apiname);
if(!addr) //not found
szBaseName++;
HMODULE mod = LoadLibraryExW(szModName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
if(!mod)
{
if(!_stricmp(apiname, "base") or !_stricmp(apiname, "imagebase") or !_stricmp(apiname, "header"))
addr = modbase;
else
if(!silent)
dprintf("unable to load library %s\n", szBaseName);
}
else
{
uint addr = (uint)GetProcAddress(mod, apiname);
if(!addr) //not found
{
uint ordinal;
if(valfromstring(apiname, &ordinal))
if(!_stricmp(apiname, "base") or !_stricmp(apiname, "imagebase") or !_stricmp(apiname, "header"))
addr = modbase;
else
{
addr = (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
if(!addr and !ordinal)
addr = modbase;
uint ordinal;
if(valfromstring(apiname, &ordinal))
{
addr = (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
if(!addr and !ordinal)
addr = modbase;
}
}
}
}
FreeLibrary(mod);
if(addr) //found!
{
if(value_size)
*value_size = sizeof(uint);
if(hexonly)
*hexonly = true;
uint rva;
if(addr == modbase)
rva = 0;
else
rva = addr - (uint)mod;
*value = modbase + rva;
return true;
FreeLibrary(mod);
if(addr) //found!
{
if(value_size)
*value_size = sizeof(uint);
if(hexonly)
*hexonly = true;
uint rva;
if(addr == modbase)
rva = 0;
else
rva = addr - (uint)mod;
*value = modbase + rva;
return true;
}
}
}
else if(!silent)
dputs("unknown error");
}
return false;
}
@ -1059,20 +1061,20 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
{
for(unsigned int i = 0; i < cbNeeded / sizeof(HMODULE); i++)
{
char szModuleName[MAX_PATH] = "";
if(GetModuleFileNameExA(fdProcessInfo->hProcess, hMods[i], szModuleName, sizeof(szModuleName)))
wchar_t szModuleName[MAX_PATH] = L"";
if(GetModuleFileNameExW(fdProcessInfo->hProcess, hMods[i], szModuleName, MAX_PATH))
{
char* szBaseName = strchr(szModuleName, '\\');
wchar_t* szBaseName = wcschr(szModuleName, L'\\');
if(szBaseName)
{
szBaseName++;
HMODULE hModule = LoadLibraryExA(szModuleName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
HMODULE hModule = LoadLibraryExW(szModuleName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
if(hModule)
{
ULONG_PTR funcAddress = (ULONG_PTR)GetProcAddress(hModule, name);
if(funcAddress)
{
if(!_stricmp(szBaseName, "kernelbase.dll"))
if(!_wcsicmp(szBaseName, L"kernelbase.dll"))
kernelbase = found;
uint rva = funcAddress - (uint)hModule;
addrfound[found] = (uint)hMods[i] + rva;

View File

@ -22,31 +22,6 @@ static COMMAND* command_list = 0;
static HANDLE hCommandLoopThread = 0;
static char alloctrace[MAX_PATH] = "";
//Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-Simple-Win32-CommandLine-Parser.htm
static void commandlinefree(int argc, char** argv)
{
for(int i = 0; i < argc; i++)
efree(argv[i]);
efree(argv);
}
static char** commandlineparse(int* argc)
{
if(!argc)
return NULL;
LPWSTR wcCommandLine = GetCommandLineW();
LPWSTR* argw = CommandLineToArgvW(wcCommandLine, argc);
char** argv = (char**)emalloc(sizeof(void*) * (*argc + 1));
for(int i = 0; i < *argc; i++)
{
int bufSize = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, argw[i], -1, NULL, 0, NULL, NULL);
argv[i] = (char*)emalloc(bufSize + 1);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, argw[i], bufSize, argv[i], bufSize * sizeof(char), NULL, NULL);
}
LocalFree(argw);
return argv;
}
static CMDRESULT cbStrLen(int argc, char* argv[])
{
if(argc < 2)
@ -256,23 +231,25 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
dbginit();
dbgfunctionsinit();
json_set_alloc_funcs(emalloc_json, efree_json);
wchar_t wszDir[deflen] = L"";
if(!GetModuleFileNameW(hInst, wszDir, deflen))
return "GetModuleFileNameW failed!";
char dir[deflen] = "";
if(!GetModuleFileNameA(hInst, dir, deflen))
return "GetModuleFileNameA failed!";
strcpy_s(dir, ConvertUtf16ToUtf8(wszDir).c_str());
int len = (int)strlen(dir);
while(dir[len] != '\\')
len--;
dir[len] = 0;
strcpy(alloctrace, dir);
PathAppendA(alloctrace, "\\alloctrace.txt");
DeleteFileA(alloctrace);
DeleteFileW(ConvertUtf8ToUtf16(alloctrace).c_str());
setalloctrace(alloctrace);
strcpy(dbbasepath, dir); //debug directory
PathAppendA(dbbasepath, "db");
CreateDirectoryA(dbbasepath, 0); //create database directory
CreateDirectoryW(ConvertUtf8ToUtf16(dbbasepath).c_str(), 0); //create database directory
strcpy(szSymbolCachePath, dir);
PathAppendA(szSymbolCachePath, "symbols");
SetCurrentDirectoryA(dir);
SetCurrentDirectoryW(ConvertUtf8ToUtf16(dir).c_str());;
gMsgStack = msgallocstack();
if(!gMsgStack)
return "Could not allocate message stack!";
@ -282,30 +259,30 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
char plugindir[deflen] = "";
strcpy(plugindir, dir);
PathAppendA(plugindir, "plugins");
CreateDirectoryA(plugindir, 0);
CreateDirectoryW(ConvertUtf8ToUtf16(plugindir).c_str(), 0);
pluginload(plugindir);
//handle command line
int argc = 0;
char** argv = commandlineparse(&argc);
wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if(argc == 2) //we have an argument
{
std::string str = "init \"";
str += argv[1];
UString str = "init \"";
str += ConvertUtf16ToUtf8(argv[1]);
str += "\"";
DbgCmdExec(str.c_str());
}
else if(argc == 5) //4 arguments (JIT)
{
if(_strcmpi(argv[1], "-a") == 0 && !_stricmp(argv[3], "-e"))
if(_wcsicmp(argv[1], L"-a") == 0 && !_wcsicmp(argv[3], L"-e"))
{
std::string str = "attach .";
str += argv[2];
UString str = "attach .";
str += ConvertUtf16ToUtf8(argv[2]);
str += ", .";
str += argv[4];
str += ConvertUtf16ToUtf8(argv[4]);
DbgCmdExec(str.c_str());
}
}
commandlinefree(argc, argv);
LocalFree(argv);
return 0;
}
@ -324,7 +301,7 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
if(memleaks())
{
char msg[256] = "";
sprintf(msg, "%d memory leak(s) found!\n\nPlease send 'alloctrace.txt' to the authors of x64_dbg.", memleaks());
sprintf(msg, "%d memory leak(s) found!\n\nPlease send contact the authors of x64_dbg.", memleaks());
MessageBoxA(0, msg, "error", MB_ICONERROR | MB_SYSTEMMODAL);
}
else

View File

@ -36,6 +36,9 @@
<ClCompile Include="symbolinfo.cpp" />
<ClCompile Include="thread.cpp" />
<ClCompile Include="threading.cpp" />
<ClCompile Include="UString\Exception.cpp" />
<ClCompile Include="UString\String.cpp" />
<ClCompile Include="UString\UString.cpp" />
<ClCompile Include="value.cpp" />
<ClCompile Include="variable.cpp" />
<ClCompile Include="x64_dbg.cpp" />
@ -85,6 +88,9 @@
<ClInclude Include="threading.h" />
<ClInclude Include="TitanEngine\TitanEngine.h" />
<ClInclude Include="undocumented.h" />
<ClInclude Include="UString\Exception.h" />
<ClInclude Include="UString\String.h" />
<ClInclude Include="UString\UString.h" />
<ClInclude Include="value.h" />
<ClInclude Include="variable.h" />
<ClInclude Include="x64_dbg.h" />

View File

@ -34,100 +34,130 @@
<Filter Include="Header Files\lz4">
<UniqueIdentifier>{6a8d58f0-1417-4bff-aecd-0f9f5e0641f9}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\UString">
<UniqueIdentifier>{adf51b13-6f3b-4b04-9ba9-21fb7a38150d}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\UString">
<UniqueIdentifier>{ee24febc-948e-4226-ba0e-68a9b449fb23}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Interfaces/Exports">
<UniqueIdentifier>{44fd9eb7-2017-49b8-8d9a-dec680632343}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Core">
<UniqueIdentifier>{148408a8-bfe7-4d36-a04a-64d645a3e713}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Information">
<UniqueIdentifier>{687e60a0-5c44-481b-9149-9bd4cc41aaf8}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Utilities">
<UniqueIdentifier>{abc27485-7d81-4847-8ffe-62b0838f4ba4}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Debugger Core">
<UniqueIdentifier>{52e2c3ae-0223-4216-b896-41d9f171f731}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="_exports.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="_global.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="addrinfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="argument.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="breakpoint.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="console.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="debugger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="instruction.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="math.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="memory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="msgqueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="simplescript.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="threading.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="value.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="variable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="x64_dbg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="plugin_loader.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="UString\Exception.cpp">
<Filter>Source Files\UString</Filter>
</ClCompile>
<ClCompile Include="_plugins.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="UString\String.cpp">
<Filter>Source Files\UString</Filter>
</ClCompile>
<ClCompile Include="assemble.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="disasm_helper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="symbolinfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stackinfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="thread.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="disasm_fast.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="reference.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="murmurhash.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="UString\UString.cpp">
<Filter>Source Files\UString</Filter>
</ClCompile>
<ClCompile Include="_dbgfunctions.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\Interfaces/Exports</Filter>
</ClCompile>
<ClCompile Include="_exports.cpp">
<Filter>Source Files\Interfaces/Exports</Filter>
</ClCompile>
<ClCompile Include="_plugins.cpp">
<Filter>Source Files\Interfaces/Exports</Filter>
</ClCompile>
<ClCompile Include="_global.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="argument.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="command.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="console.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="math.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="murmurhash.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="msgqueue.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="threading.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="value.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="variable.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="addrinfo.cpp">
<Filter>Source Files\Information</Filter>
</ClCompile>
<ClCompile Include="breakpoint.cpp">
<Filter>Source Files\Information</Filter>
</ClCompile>
<ClCompile Include="assemble.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="disasm_fast.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="disasm_helper.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="memory.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="plugin_loader.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="patches.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="reference.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="simplescript.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="stackinfo.cpp">
<Filter>Source Files\Information</Filter>
</ClCompile>
<ClCompile Include="symbolinfo.cpp">
<Filter>Source Files\Information</Filter>
</ClCompile>
<ClCompile Include="thread.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="instruction.cpp">
<Filter>Source Files\Debugger Core</Filter>
</ClCompile>
<ClCompile Include="debugger_commands.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\Debugger Core</Filter>
</ClCompile>
<ClCompile Include="debugger.cpp">
<Filter>Source Files\Debugger Core</Filter>
</ClCompile>
<ClCompile Include="log.cpp">
<Filter>Source Files</Filter>
@ -281,5 +311,14 @@
<ClInclude Include="log.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UString\Exception.h">
<Filter>Header Files\UString</Filter>
</ClInclude>
<ClInclude Include="UString\String.h">
<Filter>Header Files\UString</Filter>
</ClInclude>
<ClInclude Include="UString\UString.h">
<Filter>Header Files\UString</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -444,7 +444,7 @@ QString HexDump::byteToString(byte_t byte, ByteViewMode_e mode)
case AsciiByte:
{
QChar wChar((char)byte);
QChar wChar = QChar::fromLatin1((char)byte);
if(wChar.isPrint() == true)
wStr = QString(wChar);
@ -489,7 +489,7 @@ QString HexDump::wordToString(uint16 word, WordViewMode_e mode)
case UnicodeWord:
{
QChar wChar((char)word & 0xFF);
QChar wChar = QChar::fromLatin1((char)word & 0xFF);
if(wChar.isPrint() == true && (word >> 8) == 0)
wStr = QString(wChar);
else

View File

@ -21,12 +21,12 @@ void BeaTokenizer::AddToken(BeaInstructionToken* instr, const BeaTokenType type,
token.text = text.trimmed(); //remove whitespaces from the start and end
else
token.text = text;
if(ConfigBool("Disassembler", "Uppercase"))
token.text = token.text.toUpper();
if(value)
token.value = *value;
else
{
if(ConfigBool("Disassembler", "Uppercase"))
token.text = token.text.toUpper();
token.value.size = 0;
token.value.value = 0;
}

View File

@ -205,11 +205,12 @@ void BreakpointsView::refreshShortcutsSlot()
void BreakpointsView::hardwareBPContextMenuSlot(const QPoint & pos)
{
if(mHardBPTable->getRowCount() != 0)
StdTable* table = mHardBPTable;
if(table->getRowCount() != 0)
{
int wI = 0;
QMenu* wMenu = new QMenu(this);
uint_t wVA = mHardBPTable->getCellContent(mHardBPTable->getInitialSelection(), 0).toULongLong(0, 16);
uint_t wVA = table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16);
BPMAP wBPList;
// Remove
@ -249,21 +250,21 @@ void BreakpointsView::hardwareBPContextMenuSlot(const QPoint & pos)
//Copy
QMenu wCopyMenu("&Copy", this);
mHardBPTable->setupCopyMenu(&wCopyMenu);
table->setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
{
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
}
wMenu->exec(mHardBPTable->mapToGlobal(pos));
wMenu->exec(table->mapToGlobal(pos));
}
}
void BreakpointsView::removeHardBPActionSlot()
{
//qDebug() << "mHardBPTable->getInitialSelection()" << mHardBPTable->getInitialSelection();
uint_t wVA = mHardBPTable->getCellContent(mHardBPTable->getInitialSelection(), 0).toULongLong(0, 16);
StdTable* table = mHardBPTable;
uint_t wVA = table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16);
Breakpoints::removeBP(bp_hardware, wVA);
}
@ -274,12 +275,17 @@ void BreakpointsView::removeAllHardBPActionSlot()
void BreakpointsView::enableDisableHardBPActionSlot()
{
Breakpoints::toggleBPByDisabling(bp_hardware, mHardBPTable->getCellContent(mHardBPTable->getInitialSelection(), 0).toULongLong(0, 16));
StdTable* table = mHardBPTable;
Breakpoints::toggleBPByDisabling(bp_hardware, table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16));
int_t sel = table->getInitialSelection();
if(sel + 1 < table->getRowCount())
table->setSingleSelection(sel + 1);
}
void BreakpointsView::doubleClickHardwareSlot()
{
QString addrText = mHardBPTable->getCellContent(mHardBPTable->getInitialSelection(), 0);
StdTable* table = mHardBPTable;
QString addrText = table->getCellContent(table->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
@ -309,11 +315,12 @@ void BreakpointsView::setupSoftBPRightClickContextMenu()
void BreakpointsView::softwareBPContextMenuSlot(const QPoint & pos)
{
if(mSoftBPTable->getRowCount() != 0)
StdTable* table = mSoftBPTable;
if(table->getRowCount() != 0)
{
int wI = 0;
QMenu* wMenu = new QMenu(this);
uint_t wVA = mSoftBPTable->getCellContent(mSoftBPTable->getInitialSelection(), 0).toULongLong(0, 16);
uint_t wVA = table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16);
BPMAP wBPList;
// Remove
@ -353,20 +360,21 @@ void BreakpointsView::softwareBPContextMenuSlot(const QPoint & pos)
//Copy
QMenu wCopyMenu("&Copy", this);
mSoftBPTable->setupCopyMenu(&wCopyMenu);
table->setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
{
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
}
wMenu->exec(mSoftBPTable->mapToGlobal(pos));
wMenu->exec(table->mapToGlobal(pos));
}
}
void BreakpointsView::removeSoftBPActionSlot()
{
uint_t wVA = mSoftBPTable->getCellContent(mSoftBPTable->getInitialSelection(), 0).toULongLong(0, 16);
StdTable* table = mSoftBPTable;
uint_t wVA = table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16);
Breakpoints::removeBP(bp_normal, wVA);
}
@ -377,12 +385,17 @@ void BreakpointsView::removeAllSoftBPActionSlot()
void BreakpointsView::enableDisableSoftBPActionSlot()
{
Breakpoints::toggleBPByDisabling(bp_normal, mSoftBPTable->getCellContent(mSoftBPTable->getInitialSelection(), 0).toULongLong(0, 16));
StdTable* table = mSoftBPTable;
Breakpoints::toggleBPByDisabling(bp_normal, table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16));
int_t sel = table->getInitialSelection();
if(sel + 1 < table->getRowCount())
table->setSingleSelection(sel + 1);
}
void BreakpointsView::doubleClickSoftwareSlot()
{
QString addrText = mSoftBPTable->getCellContent(mSoftBPTable->getInitialSelection(), 0);
StdTable* table = mSoftBPTable;
QString addrText = table->getCellContent(table->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
@ -412,11 +425,12 @@ void BreakpointsView::setupMemBPRightClickContextMenu()
void BreakpointsView::memoryBPContextMenuSlot(const QPoint & pos)
{
if(mMemBPTable->getRowCount() != 0)
StdTable* table = mMemBPTable;
if(table->getRowCount() != 0)
{
int wI = 0;
QMenu* wMenu = new QMenu(this);
uint_t wVA = mMemBPTable->getCellContent(mMemBPTable->getInitialSelection(), 0).toULongLong(0, 16);
uint_t wVA = table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16);
BPMAP wBPList;
// Remove
@ -456,20 +470,21 @@ void BreakpointsView::memoryBPContextMenuSlot(const QPoint & pos)
//Copy
QMenu wCopyMenu("&Copy", this);
mMemBPTable->setupCopyMenu(&wCopyMenu);
table->setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
{
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
}
wMenu->exec(mMemBPTable->mapToGlobal(pos));
wMenu->exec(table->mapToGlobal(pos));
}
}
void BreakpointsView::removeMemBPActionSlot()
{
uint_t wVA = mMemBPTable->getCellContent(mMemBPTable->getInitialSelection(), 0).toULongLong(0, 16);
StdTable* table = mMemBPTable;
uint_t wVA = table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16);
Breakpoints::removeBP(bp_memory, wVA);
}
@ -480,12 +495,17 @@ void BreakpointsView::removeAllMemBPActionSlot()
void BreakpointsView::enableDisableMemBPActionSlot()
{
Breakpoints::toggleBPByDisabling(bp_memory, mMemBPTable->getCellContent(mMemBPTable->getInitialSelection(), 0).toULongLong(0, 16));
StdTable* table = mMemBPTable;
Breakpoints::toggleBPByDisabling(bp_memory, table->getCellContent(table->getInitialSelection(), 0).toULongLong(0, 16));
int_t sel = table->getInitialSelection();
if(sel + 1 < table->getRowCount())
table->setSingleSelection(sel + 1);
}
void BreakpointsView::doubleClickMemorySlot()
{
QString addrText = mMemBPTable->getCellContent(mMemBPTable->getInitialSelection(), 0);
StdTable* table = mMemBPTable;
QString addrText = table->getCellContent(table->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}

View File

@ -74,13 +74,13 @@ QString CPUInfoBox::getSymbolicName(int_t addr)
finalText = addrText;
if(addr == (addr & 0xFF))
{
QChar c = QChar((char)addr);
QChar c = QChar::fromLatin1((char)addr);
if(c.isPrint())
finalText += QString(" '%1'").arg((char)addr);
}
else if(addr == (addr & 0xFFF)) //UNICODE?
{
QChar c = QChar((wchar_t)addr);
QChar c = QChar::fromLatin1((wchar_t)addr);
if(c.isPrint())
finalText += " L'" + QString(c) + "'";
}
@ -113,9 +113,14 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA)
start = 1;
}
bool bUpper = ConfigBool("Disassembler", "Uppercase");
for(int i = 0, j = start; i < instr.argcount && j < 2; i++)
{
DISASM_ARG arg = instr.arg[i];
QString argMnemonic = QString(arg.mnemonic);
if(bUpper)
argMnemonic = argMnemonic.toUpper();
if(arg.type == arg_memory)
{
QString sizeName = "";
@ -136,8 +141,11 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA)
break;
}
if(bUpper)
sizeName = sizeName.toUpper();
if(!DbgMemIsValidReadPtr(arg.value))
setInfoLine(j, sizeName + "[" + QString(arg.mnemonic) + "]=???");
setInfoLine(j, sizeName + "[" + argMnemonic + "]=???");
else
{
QString addrText;
@ -145,7 +153,7 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA)
addrText = getSymbolicName(arg.memvalue);
else
addrText = QString("%1").arg(arg.memvalue, memsize * 2, 16, QChar('0')).toUpper();
setInfoLine(j, sizeName + "[" + QString(arg.mnemonic) + "]=" + addrText);
setInfoLine(j, sizeName + "[" + argMnemonic + "]=" + addrText);
}
j++;
}

View File

@ -71,7 +71,7 @@ void CalculatorDialog::validateExpression()
ui->txtOct->setText(inFormat(ans, N_OCT));
if((ans == (ans & 0xFF)))
{
QChar c = QChar((char)ans);
QChar c = QChar::fromLatin1((char)ans);
if(c.isPrint())
ui->txtAscii->setText("'" + QString(c) + "'");
else
@ -82,7 +82,7 @@ void CalculatorDialog::validateExpression()
ui->txtAscii->setCursorPosition(1);
if((ans == (ans & 0xFFF))) //UNICODE?
{
QChar c = QChar((wchar_t)ans);
QChar c = QChar::fromLatin1((wchar_t)ans);
if(c.isPrint())
ui->txtUnicode->setText("L'" + QString(c) + "'");
else

View File

@ -311,12 +311,15 @@ void MainWindow::loadMRUList(int maxItems)
if(QString(currentFile).size() && QFile(currentFile).exists())
mMRUList.push_back(currentFile);
}
mMRUList.removeDuplicates();
updateMRUMenu();
}
//save recent files to settings
void MainWindow::saveMRUList()
{
BridgeSettingSet("Recent Files", 0, 0); //clear
mMRUList.removeDuplicates();
int mruSize = mMRUList.size();
for(int i = 0; i < mruSize; i++)
{

View File

@ -115,7 +115,7 @@ private:
const char* mWindowMainTitle;
QList<QString> mMRUList;
QStringList mMRUList;
int mMaxMRU;
unsigned int lastException;

View File

@ -373,6 +373,7 @@ void MemoryMapView::switchView()
BridgeSettingSetUint("Engine", "ListAllPages", 0);
else
BridgeSettingSetUint("Engine", "ListAllPages", 1);
DbgSettingsUpdated();
DbgFunctions()->MemUpdateMap();
setSingleSelection(0);
setTableOffset(0);

View File

@ -1,4 +1,5 @@
#include "main.h"
#include <QTextCodec>
MyApplication::MyApplication(int & argc, char** argv) : QApplication(argc, argv)
{
@ -63,6 +64,11 @@ int main(int argc, char* argv[])
qRegisterMetaType<byte_t>("byte_t");
qRegisterMetaType<DBGSTATE>("DBGSTATE");
// Set QString codec to UTF-8
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
// Init communication with debugger
Bridge::initBridge();

View File

@ -11,16 +11,16 @@ enum arch
x64
};
static bool FileExists(const char* file)
static bool FileExists(const wchar_t* file)
{
DWORD attrib = GetFileAttributes(file);
DWORD attrib = GetFileAttributesW(file);
return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY));
}
static arch GetFileArchitecture(const char* szFileName)
static arch GetFileArchitecture(const wchar_t* szFileName)
{
arch retval = notfound;
HANDLE hFile = CreateFileA(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
HANDLE hFile = CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile != INVALID_HANDLE_VALUE)
{
unsigned char data[0x1000];
@ -50,184 +50,176 @@ static arch GetFileArchitecture(const char* szFileName)
return retval;
}
//Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-Simple-Win32-CommandLine-Parser.htm
static void commandlinefree(int argc, char** argv)
static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* defext, wchar_t* filename, int filename_size, const wchar_t* init_dir)
{
for(int i = 0; i < argc; i++)
free(argv[i]);
free(argv);
}
static char** commandlineparse(int* argc)
{
if(!argc)
return NULL;
LPWSTR wcCommandLine = GetCommandLineW();
LPWSTR* argw = CommandLineToArgvW(wcCommandLine, argc);
char** argv = (char**)malloc(sizeof(void*) * (*argc + 1));
for(int i = 0; i < *argc; i++)
{
int bufSize = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, argw[i], -1, NULL, 0, NULL, NULL);
argv[i] = (char*)malloc(bufSize + 1);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, argw[i], bufSize, argv[i], bufSize * sizeof(char), NULL, NULL);
}
LocalFree(argw);
return argv;
}
static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, char* filename, int filename_size, const char* init_dir)
{
OPENFILENAME ofstruct;
OPENFILENAMEW ofstruct;
memset(&ofstruct, 0, sizeof(ofstruct));
ofstruct.lStructSize = sizeof(ofstruct);
ofstruct.hwndOwner = owner;
ofstruct.hInstance = GetModuleHandleA(0);
ofstruct.hInstance = GetModuleHandleW(0);
ofstruct.lpstrFilter = filter;
ofstruct.lpstrFile = filename;
ofstruct.nMaxFile = filename_size - 1;
ofstruct.lpstrInitialDir = init_dir;
ofstruct.lpstrDefExt = defext;
ofstruct.Flags = OFN_EXTENSIONDIFFERENT | OFN_HIDEREADONLY | OFN_NONETWORKBUTTON;
return !!GetOpenFileNameA(&ofstruct);
return !!GetOpenFileNameW(&ofstruct);
}
#define SHELLEXT_EXE_KEY "exefile\\shell\\Debug with x64_dbg\\Command"
#define SHELLEXT_DLL_KEY "dllfile\\shell\\Debug with x64_dbg\\Command"
#define SHELLEXT_EXE_KEY L"exefile\\shell\\Debug with x64_dbg\\Command"
#define SHELLEXT_DLL_KEY L"dllfile\\shell\\Debug with x64_dbg\\Command"
void RegisterShellExtension(const char* key, const char* command)
static void RegisterShellExtension(const wchar_t* key, const wchar_t* command)
{
HKEY hKey;
if(RegCreateKeyA(HKEY_CLASSES_ROOT, key, &hKey) != ERROR_SUCCESS)
if(RegCreateKeyW(HKEY_CLASSES_ROOT, key, &hKey) != ERROR_SUCCESS)
{
MessageBoxA(0, "RegCreateKeyA failed!", "Running as Admin?", MB_ICONERROR);
MessageBoxW(0, L"RegCreateKeyA failed!", L"Running as Admin?", MB_ICONERROR);
return;
}
if(RegSetValueExA(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, strlen(command) + 1) != ERROR_SUCCESS)
MessageBoxA(0, "RegSetValueExA failed!", "Running as Admin?", MB_ICONERROR);
if(RegSetValueExW(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS)
MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR);
RegCloseKey(hKey);
}
static void CreateUnicodeFile(const wchar_t* file)
{
//Taken from: http://www.codeproject.com/Articles/9071/Using-Unicode-in-INI-files
if(FileExists(file))
return;
// UTF16-LE BOM(FFFE)
WORD wBOM = 0xFEFF;
HANDLE hFile = CreateFileW(file, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
return;
DWORD written = 0;
WriteFile(hFile, &wBOM, sizeof(WORD), &written, NULL);
CloseHandle(hFile);
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
CoInitialize(NULL); //fixed some crash
//Get INI file path
char szModulePath[MAX_PATH] = "";
if(!GetModuleFileNameA(0, szModulePath, MAX_PATH))
wchar_t szModulePath[MAX_PATH] = L"";
if(!GetModuleFileNameW(0, szModulePath, MAX_PATH))
{
MessageBoxA(0, "Error getting module path!", "Error", MB_ICONERROR | MB_SYSTEMMODAL);
MessageBoxW(0, L"Error getting module path!", L"Error", MB_ICONERROR | MB_SYSTEMMODAL);
return 0;
}
char szIniPath[MAX_PATH] = "";
strcpy(szIniPath, szModulePath);
char szCurrentDir[MAX_PATH] = "";
strcpy(szCurrentDir, szModulePath);
int len = (int)strlen(szCurrentDir);
while(szCurrentDir[len] != '\\' && len)
wchar_t szIniPath[MAX_PATH] = L"";
wcscpy_s(szIniPath, szModulePath);
wchar_t szCurrentDir[MAX_PATH] = L"";
wcscpy_s(szCurrentDir, szModulePath);
int len = (int)wcslen(szCurrentDir);
while(szCurrentDir[len] != L'\\' && len)
len--;
if(len)
szCurrentDir[len] = '\0';
len = (int)strlen(szIniPath);
while(szIniPath[len] != '.' && szIniPath[len] != '\\' && len)
szCurrentDir[len] = L'\0';
len = (int)wcslen(szIniPath);
while(szIniPath[len] != L'.' && szIniPath[len] != L'\\' && len)
len--;
if(szIniPath[len] == '\\')
strcat(szIniPath, ".ini");
if(szIniPath[len] == L'\\')
wcscat_s(szIniPath, L".ini");
else
strcpy(&szIniPath[len], ".ini");
wcscpy(&szIniPath[len], L".ini");
CreateUnicodeFile(szIniPath);
//Load settings
bool bDoneSomething = false;
char sz32Path[MAX_PATH] = "";
if(!GetPrivateProfileStringA("Launcher", "x32_dbg", "", sz32Path, MAX_PATH, szIniPath))
wchar_t sz32Path[MAX_PATH] = L"";
if(!GetPrivateProfileStringW(L"Launcher", L"x32_dbg", L"", sz32Path, MAX_PATH, szIniPath))
{
strcpy(sz32Path, szCurrentDir);
PathAppendA(sz32Path, "x32\\x32_dbg.exe");
wcscpy_s(sz32Path, szCurrentDir);
PathAppendW(sz32Path, L"x32\\x32_dbg.exe");
if(FileExists(sz32Path))
{
WritePrivateProfileStringA("Launcher", "x32_dbg", sz32Path, szIniPath);
WritePrivateProfileStringW(L"Launcher", L"x32_dbg", sz32Path, szIniPath);
bDoneSomething = true;
}
}
char sz32Dir[MAX_PATH] = "";
strcpy(sz32Dir, sz32Path);
len = (int)strlen(sz32Dir);
while(sz32Dir[len] != '\\' && len)
wchar_t sz32Dir[MAX_PATH] = L"";
wcscpy_s(sz32Dir, sz32Path);
len = (int)wcslen(sz32Dir);
while(sz32Dir[len] != L'\\' && len)
len--;
if(len)
sz32Dir[len] = '\0';
char sz64Path[MAX_PATH] = "";
if(!GetPrivateProfileStringA("Launcher", "x64_dbg", "", sz64Path, MAX_PATH, szIniPath))
sz32Dir[len] = L'\0';
wchar_t sz64Path[MAX_PATH] = L"";
if(!GetPrivateProfileStringW(L"Launcher", L"x64_dbg", L"", sz64Path, MAX_PATH, szIniPath))
{
strcpy(sz64Path, szCurrentDir);
PathAppendA(sz64Path, "x64\\x64_dbg.exe");
wcscpy_s(sz64Path, szCurrentDir);
PathAppendW(sz64Path, L"x64\\x64_dbg.exe");
if(FileExists(sz64Path))
{
WritePrivateProfileStringA("Launcher", "x64_dbg", sz64Path, szIniPath);
WritePrivateProfileStringW(L"Launcher", L"x64_dbg", sz64Path, szIniPath);
bDoneSomething = true;
}
}
char sz64Dir[MAX_PATH] = "";
strcpy(sz64Dir, sz64Path);
len = (int)strlen(sz64Dir);
while(sz64Dir[len] != '\\' && len)
wchar_t sz64Dir[MAX_PATH] = L"";
wcscpy_s(sz64Dir, sz64Path);
len = (int)wcslen(sz64Dir);
while(sz64Dir[len] != L'\\' && len)
len--;
if(len)
sz64Dir[len] = '\0';
sz64Dir[len] = L'\0';
//Handle command line
int argc = 0;
char** argv = commandlineparse(&argc);
wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if(argc <= 1) //no arguments -> set configuration
{
if(!FileExists(sz32Path) && BrowseFileOpen(0, "x32_dbg.exe\0x32_dbg.exe\0\0", 0, sz32Path, MAX_PATH, szCurrentDir))
if(!FileExists(sz32Path) && BrowseFileOpen(0, L"x32_dbg.exe\0x32_dbg.exe\0\0", 0, sz32Path, MAX_PATH, szCurrentDir))
{
WritePrivateProfileStringA("Launcher", "x32_dbg", sz32Path, szIniPath);
WritePrivateProfileStringW(L"Launcher", L"x32_dbg", sz32Path, szIniPath);
bDoneSomething = true;
}
if(!FileExists(sz64Path) && BrowseFileOpen(0, "x64_dbg.exe\0x64_dbg.exe\0\0", 0, sz64Path, MAX_PATH, szCurrentDir))
if(!FileExists(sz64Path) && BrowseFileOpen(0, L"x64_dbg.exe\0x64_dbg.exe\0\0", 0, sz64Path, MAX_PATH, szCurrentDir))
{
WritePrivateProfileStringA("Launcher", "x64_dbg", sz64Path, szIniPath);
WritePrivateProfileStringW(L"Launcher", L"x64_dbg", sz64Path, szIniPath);
bDoneSomething = true;
}
if(MessageBoxA(0, "Do you want to register a shell extension?", "Question", MB_YESNO | MB_ICONQUESTION) == IDYES)
if(MessageBoxW(0, L"Do you want to register a shell extension?", L"Question", MB_YESNO | MB_ICONQUESTION) == IDYES)
{
char szLauncherCommand[MAX_PATH] = "";
sprintf_s(szLauncherCommand, "\"%s\" \"%%1\"", szModulePath);
wchar_t szLauncherCommand[MAX_PATH] = L"";
swprintf_s(szLauncherCommand, sizeof(szLauncherCommand), L"\"%s\" \"%%1\"", szModulePath);
RegisterShellExtension(SHELLEXT_EXE_KEY, szLauncherCommand);
RegisterShellExtension(SHELLEXT_DLL_KEY, szLauncherCommand);
}
if(bDoneSomething)
MessageBoxA(0, "New configuration written!", "Done!", MB_ICONINFORMATION);
MessageBoxW(0, L"New configuration written!", L"Done!", MB_ICONINFORMATION);
}
if(argc == 2) //one argument -> execute debugger
{
std::string cmdLine = "\"";
std::wstring cmdLine = L"\"";
cmdLine += argv[1];
cmdLine += "\"";
cmdLine += L"\"";
switch(GetFileArchitecture(argv[1]))
{
case x32:
if(sz32Path[0])
ShellExecuteA(0, "open", sz32Path, cmdLine.c_str(), sz32Dir, SW_SHOWNORMAL);
ShellExecuteW(0, L"open", sz32Path, cmdLine.c_str(), sz32Dir, SW_SHOWNORMAL);
else
MessageBoxA(0, "Path to x32_dbg not specified in launcher configuration...", "Error!", MB_ICONERROR);
MessageBoxW(0, L"Path to x32_dbg not specified in launcher configuration...", L"Error!", MB_ICONERROR);
break;
case x64:
if(sz64Path[0])
ShellExecuteA(0, "open", sz64Path, cmdLine.c_str(), sz64Dir, SW_SHOWNORMAL);
ShellExecuteW(0, L"open", sz64Path, cmdLine.c_str(), sz64Dir, SW_SHOWNORMAL);
else
MessageBoxA(0, "Path to x64_dbg not specified in launcher configuration...", "Error!", MB_ICONERROR);
MessageBoxW(0, L"Path to x64_dbg not specified in launcher configuration...", L"Error!", MB_ICONERROR);
break;
case invalid:
MessageBoxA(0, argv[1], "Invalid PE File!", MB_ICONERROR);
MessageBoxW(0, argv[1], L"Invalid PE File!", MB_ICONERROR);
break;
case notfound:
MessageBoxA(0, argv[1], "File not found or in use!", MB_ICONERROR);
MessageBoxW(0, argv[1], L"File not found or in use!", MB_ICONERROR);
break;
}
}
commandlinefree(argc, argv);
LocalFree(argv);
return 0;
}