1
0
Fork 0

Merge branch 'master' into doxygen

Conflicts:
	x64_dbg_bridge/bridgemain.cpp
	x64_dbg_dbg/debugger.cpp
	x64_dbg_dbg/threading.cpp
	x64_dbg_dbg/x64_dbg.cpp
	x64_dbg_launcher/x64_dbg_launcher.cpp
This commit is contained in:
lovrolu 2014-10-09 15:59:34 +02:00
commit 72562ab2d1
76 changed files with 5994 additions and 722 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ doc/
#global filetypes to ignore
*.depend
*.layout
*.patch
*.cscope_file_list
*.bmarks
*.chw

View File

@ -7,7 +7,7 @@
#include "_global.h"
#include "bridgemain.h"
#include <stdio.h>
#include <new>
#include "simpleini.h"
/**
* \brief Global variable that stores a handle to the Bridge's DLL.
@ -17,7 +17,7 @@ static HINSTANCE hInst;
/**
* \brief Path to the Bridge's INI file. It set when BridgeInit is called.
*/
static char szIniFile[1024] = "";
static wchar_t szIniFile[MAX_PATH] = L"";
#ifdef _WIN64
#define dbg_lib "x64_dbg.dll"
@ -65,15 +65,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;
@ -165,8 +165,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;
}
@ -211,9 +216,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;
}
/**

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

@ -525,66 +525,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);
@ -593,19 +593,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);
@ -619,31 +619,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);
@ -676,11 +676,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);
@ -744,25 +744,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);
@ -772,7 +772,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);
@ -781,8 +781,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);
@ -790,20 +790,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);
@ -812,17 +812,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();
@ -833,53 +833,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);
@ -889,30 +889,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);
@ -920,40 +920,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

@ -68,14 +68,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);
@ -84,10 +84,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;
}
@ -200,7 +200,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);
}
/**

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

@ -215,7 +215,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;
}
@ -230,7 +230,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;
}
@ -823,19 +823,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)
@ -851,13 +845,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))
@ -877,13 +865,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

@ -295,7 +295,7 @@ 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));
}
@ -311,7 +311,7 @@ bool FileExists(const char* file)
bool DirExists(const char* dir)
{
DWORD attrib = GetFileAttributes(dir);
DWORD attrib = GetFileAttributesW(ConvertUtf8ToUtf16(dir).c_str());
return (attrib == FILE_ATTRIBUTE_DIRECTORY);
}
@ -328,7 +328,11 @@ bool DirExists(const char* dir)
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;
}
/**
@ -365,7 +369,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

@ -68,15 +68,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
}
/**
@ -91,15 +105,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)!");
@ -150,6 +172,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--;
@ -179,7 +202,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);
@ -236,7 +260,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

@ -6,6 +6,7 @@
#include "argument.h"
#include "console.h"
#include "UString/UString.h"
/*
formatarg:
@ -41,11 +42,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++)
@ -57,18 +60,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] == '\\')
@ -76,17 +82,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++)
@ -136,6 +145,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++)
{
@ -144,6 +154,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)
@ -151,6 +162,7 @@ void argformat(char* cmd)
arguments[i] = '\\';
arguments[i + 1] = '\\';
}
if(strlen(arguments))
sprintf(cmd, "%s %s", command, arguments);
else
@ -195,6 +207,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] != '\\')
@ -242,6 +255,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] == '\\')
@ -249,17 +263,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

@ -146,6 +146,7 @@ PROCESS_INFORMATION* fdProcessInfo = &g_pi;
*/
HANDLE hActiveThread;
bool bUndecorateSymbolNames = true;
/**
@fn static DWORD WINAPI memMapThread(void* ptr)
@ -1026,8 +1027,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);
@ -1072,12 +1076,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
{
@ -1265,8 +1269,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;
@ -1627,13 +1634,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;
@ -2084,7 +2091,7 @@ bool IsProcessElevated()
}
/**
@fn 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)
@fn 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)
@brief Readwritejitkeys.
@ -2099,7 +2106,7 @@ bool IsProcessElevated()
@return true if it succeeds, false if it fails.
*/
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;
@ -2161,7 +2168,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
{
@ -2169,7 +2176,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)
@ -2362,7 +2369,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;
@ -2376,9 +2383,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;
@ -2400,11 +2407,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))
{
@ -2412,7 +2419,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;
@ -2436,14 +2443,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;
}
@ -2461,7 +2470,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;
@ -2482,9 +2493,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;
@ -2529,9 +2540,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));
@ -2712,7 +2723,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;
@ -2798,8 +2809,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

@ -46,7 +46,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!");
@ -88,6 +88,7 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
while(currentfolder[len] != '\\' and len != 0)
len--;
currentfolder[len] = 0;
if(DirExists(arg3))
strcpy(currentfolder, arg3);
//initialize
@ -1147,7 +1148,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!");
@ -1246,11 +1247,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;
}
@ -1885,12 +1888,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

@ -299,7 +299,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;
}

13
x64_dbg_dbg/log.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "log.h"
#include "_global.h"
log::log(void)
{
}
log::~log(void)
{
GuiAddLogMessage(message.str().c_str());
}

23
x64_dbg_dbg/log.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <sstream>
// a Qt's QDebug like message logging
// usage: "log() << "hi" << "there";
class log
{
public:
log();
~log();
public:
template<class T>
inline log & operator<<(const T & x)
{
// accumulate messages
message << x;
return *this;
}
private:
std::ostringstream message;
};

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

@ -15,6 +15,7 @@
*/
MemoryMap memoryPages;
bool bListAllPages = false;
/**
@fn void memupdatemap(HANDLE hProcess)
@ -32,11 +33,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

@ -239,14 +239,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?)");
@ -256,7 +256,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++)
@ -268,7 +268,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

@ -51,20 +51,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;
@ -73,8 +73,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);
@ -222,8 +222,8 @@ void pluginload(const char* pluginDir)
}
curPluginHandle++;
}
while(FindNextFileA(hSearch, &foundData));
SetCurrentDirectoryA(currentDir);
while(FindNextFileW(hSearch, &foundData));
SetCurrentDirectoryW(currentDir);
}
/**

View File

@ -137,7 +137,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

@ -184,10 +184,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))
@ -195,7 +195,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;
@ -259,7 +259,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

@ -14,7 +14,7 @@
@return true if waitarray[ 16], false if not.
*/
static volatile bool waitarray[16];
static volatile bool waitarray[WAITID_LAST];
/**
@fn void waitclear()

View File

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

View File

@ -1096,59 +1096,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;
}
@ -1164,20 +1166,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

@ -47,50 +47,6 @@ static HANDLE hCommandLoopThread = 0;
static char alloctrace[MAX_PATH] = "";
/**
@fn static void commandlinefree(int argc, char** argv)
@brief Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-
Simple-Win32-CommandLine-Parser.htm.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
*/
static void commandlinefree(int argc, char** argv)
{
for(int i = 0; i < argc; i++)
efree(argv[i]);
efree(argv);
}
/**
@fn static char** commandlineparse(int* argc)
@brief Commandlineparses the given argc.
@param [in,out] argc If non-null, the argc.
@return null if it fails, else a char**.
*/
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;
}
/**
@fn static CMDRESULT cbStrLen(int argc, char* argv[])
@ -396,23 +352,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!";
@ -422,30 +380,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;
}
@ -470,7 +428,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

@ -22,6 +22,7 @@
<ClCompile Include="disasm_fast.cpp" />
<ClCompile Include="disasm_helper.cpp" />
<ClCompile Include="instruction.cpp" />
<ClCompile Include="log.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="math.cpp" />
<ClCompile Include="memory.cpp" />
@ -35,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" />
@ -66,6 +70,7 @@
<ClInclude Include="instruction.h" />
<ClInclude Include="jansson\jansson.h" />
<ClInclude Include="jansson\jansson_config.h" />
<ClInclude Include="log.h" />
<ClInclude Include="lz4\lz4.h" />
<ClInclude Include="lz4\lz4file.h" />
<ClInclude Include="lz4\lz4hc.h" />
@ -83,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,99 +34,132 @@
<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\Debugger Core</Filter>
</ClCompile>
<ClCompile Include="debugger.cpp">
<Filter>Source Files\Debugger Core</Filter>
</ClCompile>
<ClCompile Include="log.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -275,5 +308,17 @@
<ClInclude Include="dynamicmem.h">
<Filter>Header Files</Filter>
</ClInclude>
<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

@ -192,6 +192,7 @@ void ReferenceView::toggleBreakpoint()
}
DbgCmdExec(wCmd.toUtf8().constData());
this->mSearchList->selectNext();
}
void ReferenceView::toggleBookmark()

View File

@ -18,7 +18,7 @@ QString SearchListViewTable::paintContent(QPainter* painter, int_t rowBase, int
const char* addrText = text.toUtf8().constData();
ULONGLONG val = 0;
uint_t wVA;
if(sscanf(addrText, "%llX", &val) != 1)
if(sscanf_s(addrText, "%llX", &val) != 1)
isaddr = false;
else
wVA = val;

View File

@ -16,9 +16,9 @@ const QKeySequence ShortcutEdit::getKeysequence() const
void ShortcutEdit::setErrorState(bool error)
{
if(error)
setStyleSheet("color: #FF0000");
setStyleSheet("color: #DD0000");
else
setStyleSheet("color: #000000");
setStyleSheet("color: #222222");
}
void ShortcutEdit::keyPressEvent(QKeyEvent* event)

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;
}
@ -293,7 +293,7 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
value.size = arg->ArgSize / 8;
//nice little hack
LONGLONG val;
sscanf(arg->ArgMnemonic, "%llX", &val);
sscanf_s(arg->ArgMnemonic, "%llX", &val);
value.value = val;
/*
switch(value.size)
@ -531,7 +531,7 @@ void BeaTokenizer::TokenizeInstruction(BeaInstructionToken* instr, const DISASM*
{
unsigned int segment = 0;
unsigned int address = 0;
sscanf(disasm->Argument1.ArgMnemonic, "%X : %X", &segment, &address);
sscanf_s(disasm->Argument1.ArgMnemonic, "%X : %X", &segment, &address);
AddToken(instr, TokenSpace, QString(" "), 0);
BeaTokenValue val;
val.size = 2;

View File

@ -10,7 +10,9 @@ AppearanceDialog::AppearanceDialog(QWidget* parent) : QDialog(parent), ui(new Ui
ui->setupUi(this);
//set window flags
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
//Colors
colorMap = &Config()->Colors;

View File

@ -673,7 +673,7 @@
<string>HexEdit:</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget1">
<property name="geometry">
<rect>
<x>10</x>
@ -718,7 +718,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget2">
<property name="geometry">
<rect>
<x>130</x>
@ -846,7 +846,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget3">
<property name="geometry">
<rect>
<x>130</x>
@ -974,7 +974,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget4">
<property name="geometry">
<rect>
<x>130</x>
@ -1102,7 +1102,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget5">
<property name="geometry">
<rect>
<x>130</x>
@ -1230,7 +1230,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget6">
<property name="geometry">
<rect>
<x>130</x>
@ -1358,7 +1358,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget7">
<property name="geometry">
<rect>
<x>130</x>
@ -1486,13 +1486,13 @@
</item>
</layout>
</widget>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget1</zorder>
<zorder>layoutWidget2</zorder>
<zorder>layoutWidget3</zorder>
<zorder>layoutWidget4</zorder>
<zorder>layoutWidget5</zorder>
<zorder>layoutWidget6</zorder>
<zorder>layoutWidget7</zorder>
<zorder>labelFontAbstractTables</zorder>
<zorder>labelFontDisassembly</zorder>
<zorder>labelFontHexDump</zorder>

View File

@ -5,7 +5,9 @@
AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AttachDialog)
{
ui->setupUi(this);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
//setup actions

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

@ -4,7 +4,9 @@
CalculatorDialog::CalculatorDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CalculatorDialog)
{
ui->setupUi(this);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
connect(this, SIGNAL(validAddress(bool)), ui->btnGoto, SLOT(setEnabled(bool)));
emit validAddress(false);
@ -69,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
@ -80,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

@ -5,7 +5,9 @@ CloseDialog::CloseDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CloseDia
{
ui->setupUi(this);
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags((Qt::Tool | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint) & ~Qt::WindowCloseButtonHint);
#endif
setFixedSize(this->size()); //fixed size
//setWindowFlags(((windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowCloseButtonHint));
}

View File

@ -8,7 +8,9 @@ ExceptionRangeDialog::ExceptionRangeDialog(QWidget* parent) :
ui->setupUi(this);
//set window flags
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
ui->editStart->setCursorPosition(0);
ui->editEnd->setCursorPosition(0);

View File

@ -6,7 +6,9 @@ GotoDialog::GotoDialog(QWidget* parent) : QDialog(parent), ui(new Ui::GotoDialog
//setup UI first
ui->setupUi(this);
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
//initialize stuff
if(!DbgIsDebugging()) //not debugging

View File

@ -6,8 +6,9 @@
HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexEditDialog)
{
ui->setupUi(this);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
setModal(true); //modal window

View File

@ -5,7 +5,9 @@ LineEditDialog::LineEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Li
{
ui->setupUi(this);
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
setModal(true); //modal window
ui->checkBox->hide();

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++)
{
@ -831,7 +834,7 @@ void MainWindow::menuEntrySlot()
if(action && action->objectName().startsWith("ENTRY|"))
{
int hEntry = -1;
if(sscanf(action->objectName().mid(6).toUtf8().constData(), "%d", &hEntry) == 1)
if(sscanf_s(action->objectName().mid(6).toUtf8().constData(), "%d", &hEntry) == 1)
DbgMenuEntryClicked(hEntry);
}
}

View File

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

View File

@ -87,10 +87,11 @@
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionAbout"/>
<addaction name="actionDonate"/>
<addaction name="actionCheckUpdates"/>
<addaction name="actionCalculator"/>
<addaction name="actionCheckUpdates"/>
<addaction name="actionDonate"/>
<addaction name="separator"/>
<addaction name="actionAbout"/>
</widget>
<widget class="QMenu" name="menuPlugins">
<property name="title">

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

@ -5,8 +5,10 @@ PageMemoryRights::PageMemoryRights(QWidget* parent) : QDialog(parent), ui(new Ui
{
ui->setupUi(this);
//set window flags
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setModal(true);
addr = 0;
size = 0;
}

View File

@ -61,7 +61,7 @@
<bool>false</bool>
</attribute>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="paddingLayoutWidget">
<property name="geometry">
<rect>
<x>330</x>
@ -70,9 +70,9 @@
<height>242</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayoutGroup">
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="rightsGroup">
<property name="title">
<string>Rights</string>
</property>
@ -157,7 +157,7 @@
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="buttonsLayout">
<item>
<widget class="QPushButton" name="btnSelectall">
<property name="text">

View File

@ -11,8 +11,9 @@ PatchDialog::PatchDialog(QWidget* parent) :
ui(new Ui::PatchDialog)
{
ui->setupUi(this);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
setModal(false); //non-modal window
@ -480,7 +481,11 @@ void PatchDialog::on_btnPatchFile_clicked()
void PatchDialog::on_btnImport_clicked()
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
QString filename = QFileDialog::getOpenFileName(this, tr("Open patch"), QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation), tr("Patch files (*.1337)"));
#else
QString filename = QFileDialog::getOpenFileName(this, tr("Open patch"), QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0], tr("Patch files (*.1337)"));
#endif
if(!filename.length())
return;
filename = QDir::toNativeSeparators(filename); //convert to native path format (with backlashes)
@ -525,7 +530,7 @@ void PatchDialog::on_btnImport_clicked()
if(!modbase)
continue;
curLine = curLine.replace(" ", "");
if(sscanf(curLine.toUtf8().constData(), "%llX:%X->%X", &rva, &oldbyte, &newbyte) != 3)
if(sscanf_s(curLine.toUtf8().constData(), "%llX:%X->%X", &rva, &oldbyte, &newbyte) != 3)
{
QMessageBox msg(QMessageBox::Critical, "Error!", QString("Patch file format is incorrect..."));
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
@ -616,7 +621,11 @@ void PatchDialog::on_btnExport_clicked()
if(!mPatches->size())
return;
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
QString filename = QFileDialog::getSaveFileName(this, tr("Save patch"), QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation), tr("Patch files (*.1337)"));
#else
QString filename = QFileDialog::getSaveFileName(this, tr("Save patch"), QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0], tr("Patch files (*.1337)"));
#endif
if(!filename.length())
return;
filename = QDir::toNativeSeparators(filename); //convert to native path format (with backlashes)

View File

@ -6,8 +6,9 @@ PatchDialogGroupSelector::PatchDialogGroupSelector(QWidget* parent) :
ui(new Ui::PatchDialogGroupSelector)
{
ui->setupUi(this);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
setModal(false); //non-modal window

View File

@ -27,6 +27,9 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
wCM_CopyToClipboard = new QAction(tr("Copy Value to Clipboard"), this);
wCM_CopyToClipboard->setShortcutContext(Qt::WidgetShortcut);
this->addAction(wCM_CopyToClipboard);
wCM_CopySymbolToClipboard = new QAction(tr("Copy Symbol Value to Clipboard"), this);
wCM_CopySymbolToClipboard->setShortcutContext(Qt::WidgetShortcut);
this->addAction(wCM_CopySymbolToClipboard);
wCM_FollowInDisassembly = new QAction(tr("Follow in Disassembler"), this);
wCM_FollowInDump = new QAction(tr("Follow in Dump"), this);
wCM_FollowInStack = new QAction("Follow in Stack", this);
@ -229,6 +232,7 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
connect(wCM_Modify, SIGNAL(triggered()), this, SLOT(onModifyAction()));
connect(wCM_ToggleValue, SIGNAL(triggered()), this, SLOT(onToggleValueAction()));
connect(wCM_CopyToClipboard, SIGNAL(triggered()), this, SLOT(onCopyToClipboardAction()));
connect(wCM_CopySymbolToClipboard, SIGNAL(triggered()), this, SLOT(onCopySymbolToClipboardAction()));
connect(wCM_FollowInDisassembly, SIGNAL(triggered()), this, SLOT(onFollowInDisassembly()));
connect(wCM_FollowInDump, SIGNAL(triggered()), this, SLOT(onFollowInDump()));
connect(wCM_FollowInStack, SIGNAL(triggered()), this, SLOT(onFollowInStack()));
@ -245,6 +249,7 @@ void RegistersView::refreshShortcutsSlot()
wCM_SetToOne->setShortcut(ConfigShortcut("ActionSetOneRegister"));
wCM_ToggleValue->setShortcut(ConfigShortcut("ActionToggleRegisterValue"));
wCM_CopyToClipboard->setShortcut(ConfigShortcut("ActionCopy"));
wCM_CopySymbolToClipboard->setShortcut(ConfigShortcut("ActionCopySymbol"));
}
RegistersView::~RegistersView()
@ -368,6 +373,39 @@ QSize RegistersView::sizeHint() const
return QSize(32 * mCharWidth , this->viewport()->height());
}
QString RegistersView::getRegisterLabel(REGISTER_NAME register_selected)
{
char label_text[MAX_LABEL_SIZE] = "";
char module_text[MAX_MODULE_SIZE] = "";
char string_text[MAX_STRING_SIZE] = "";
QString valueText = QString("%1").arg(registerValue(&wRegDumpStruct, register_selected), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
duint register_value = registerValue(&wRegDumpStruct, register_selected);
QString newText = QString("");
bool hasString = DbgGetStringAt(register_value, string_text);
bool hasLabel = DbgGetLabelAt(register_value, SEG_DEFAULT, label_text);
bool hasModule = DbgGetModuleAt(register_value, module_text);
if(hasString)
{
newText = string_text;
}
else if(hasLabel && hasModule)
{
newText = "<" + QString(module_text) + "." + QString(label_text) + ">";
}
else if(hasModule)
{
newText = QString(module_text) + "." + valueText;
}
else if(hasLabel)
{
newText = "<" + QString(label_text) + ">";
}
return newText;
}
void RegistersView::drawRegister(QPainter* p, REGISTER_NAME reg, uint_t value)
{
// is the register-id known?
@ -415,35 +453,18 @@ void RegistersView::drawRegister(QPainter* p, REGISTER_NAME reg, uint_t value)
p->drawText(x, y, width, mRowHeight, Qt::AlignVCenter, valueText);
//p->drawText(x + (mRegisterPlaces[reg].labelwidth)*mCharWidth ,mRowHeight*(mRegisterPlaces[reg].line+1),QString("%1").arg(value, mRegisterPlaces[reg].valuesize, 16, QChar('0')).toUpper());
// do we have a label ?
char label_text[MAX_LABEL_SIZE] = "";
char module_text[MAX_MODULE_SIZE] = "";
char string_text[MAX_STRING_SIZE] = "";
bool hasString = DbgGetStringAt(value, string_text);
bool hasLabel = DbgGetLabelAt(value, SEG_DEFAULT, label_text);
bool hasModule = DbgGetModuleAt(value, module_text);
QString newText = getRegisterLabel(reg);
bool isCharacter = false;
x += valueText.length() * mCharWidth;
x += 5 * mCharWidth; //5 spaces
QString newText = "";
if(hasString)
{
newText = string_text;
}
else if(hasLabel && hasModule)
{
newText = "<" + QString(module_text) + "." + QString(label_text) + ">";
}
else if(hasModule)
{
newText = QString(module_text) + "." + valueText;
}
else if(hasLabel)
{
newText = "<" + QString(label_text) + ">";
}
bool has_label;
if(newText != "")
has_label = true;
else
{
has_label = false;
// can we interpret the character as ASCII ??
if(mGPR.contains(reg))
{
@ -468,7 +489,7 @@ void RegistersView::drawRegister(QPainter* p, REGISTER_NAME reg, uint_t value)
}
}
// are there additional informations?
if(hasString || hasLabel || hasModule || isCharacter)
if(has_label || isCharacter)
{
width = newText.length() * mCharWidth;
p->setPen(ConfigColor("RegistersExtraInfoColor"));
@ -546,6 +567,14 @@ void RegistersView::onCopyToClipboardAction()
clipboard->setText(QString("%1").arg((uint_t)registerValue(&wRegDumpStruct, mSelected), sizeof(int_t) * 2, 16, QChar('0')).toUpper());
}
void RegistersView::onCopySymbolToClipboardAction()
{
QClipboard* clipboard = QApplication::clipboard();
QString symbol = getRegisterLabel(mSelected);
if(symbol != "")
clipboard->setText(symbol);
}
void RegistersView::onFollowInDisassembly()
{
if(mGPR.contains(mSelected))
@ -611,6 +640,9 @@ void RegistersView::displayCustomContextMenuSlot(QPoint pos)
}
}
wMenu.addAction(wCM_CopyToClipboard);
QString symbol = getRegisterLabel(mSelected);
if(symbol != "")
wMenu.addAction(wCM_CopySymbolToClipboard);
wMenu.exec(this->mapToGlobal(pos));
}
else

View File

@ -76,7 +76,6 @@ protected:
virtual void mouseDoubleClickEvent(QMouseEvent* event);
virtual void paintEvent(QPaintEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
//virtual void wheelEvent(QWheelEvent* event);
// use-in-class-only methods
void drawRegister(QPainter* p, REGISTER_NAME reg, uint_t value);
@ -95,9 +94,11 @@ protected slots:
void onModifyAction();
void onToggleValueAction();
void onCopyToClipboardAction();
void onCopySymbolToClipboardAction();
void onFollowInDisassembly();
void onFollowInDump();
void onFollowInStack();
QString getRegisterLabel(REGISTER_NAME);
private:
int mVScrollOffset;
@ -130,6 +131,7 @@ private:
QAction* wCM_Modify;
QAction* wCM_ToggleValue;
QAction* wCM_CopyToClipboard;
QAction* wCM_CopySymbolToClipboard;
QAction* wCM_FollowInDisassembly;
QAction* wCM_FollowInDump;
QAction* wCM_FollowInStack;

View File

@ -11,9 +11,11 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
{
ui->setupUi(this);
//set window flags
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
setModal(true);
LoadSettings(); //load settings from file
connect(Bridge::getBridge(), SIGNAL(setLastException(uint)), this, SLOT(setLastException(uint)));
lastException = 0;
@ -142,7 +144,7 @@ void SettingsDialog::LoadSettings()
{
unsigned long start;
unsigned long end;
if(sscanf(ranges.at(i).toUtf8().constData(), "%08X-%08X", &start, &end) == 2 && start <= end)
if(sscanf_s(ranges.at(i).toUtf8().constData(), "%08X-%08X", &start, &end) == 2 && start <= end)
{
RangeStruct newRange;
newRange.start = start;

View File

@ -241,7 +241,7 @@
<string>Default Breakpoint Type:</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutSettingsWidget">
<property name="geometry">
<rect>
<x>20</x>
@ -270,7 +270,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutBreakpoingWidget">
<property name="geometry">
<rect>
<x>20</x>
@ -369,7 +369,7 @@
<string>Ignored Exceptions:</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutExceptionsWidget">
<property name="geometry">
<rect>
<x>170</x>
@ -477,7 +477,7 @@
<string>Set x64_dbg as Just In Time Debugger</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutSettingsPadWidget">
<property name="geometry">
<rect>
<x>10</x>

View File

@ -5,9 +5,11 @@ ShortcutsDialog::ShortcutsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::
{
ui->setupUi(this);
//set window flags
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setFixedSize(this->size()); //fixed size
setModal(true);
// x64 has no model-view-controler pattern
QStringList tblHeader;
@ -22,7 +24,12 @@ ShortcutsDialog::ShortcutsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::
ui->tblShortcuts->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tblShortcuts->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tblShortcuts->setShowGrid(false);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
ui->tblShortcuts->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
#else
ui->tblShortcuts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
#endif
ui->tblShortcuts->verticalHeader()->setDefaultSectionSize(15);
const unsigned int numShortcuts = Config()->Shortcuts.count();

View File

@ -4,12 +4,12 @@
WordEditDialog::WordEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::WordEditDialog)
{
ui->setupUi(this);
setModal(true);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
#endif
setModal(true);
mValidateThread = new WordEditDialogValidateThread(this);
mWord = 0;
}
@ -100,7 +100,7 @@ void WordEditDialog::on_expressionLineEdit_textChanged(const QString & arg1)
void WordEditDialog::on_signedLineEdit_textEdited(const QString & arg1)
{
LONGLONG value;
if(sscanf(arg1.toUtf8().constData(), "%lld", &value) == 1)
if(sscanf_s(arg1.toUtf8().constData(), "%lld", &value) == 1)
{
ui->signedLineEdit->setStyleSheet("");
ui->buttons->button(QDialogButtonBox::Ok)->setEnabled(true);
@ -116,7 +116,7 @@ void WordEditDialog::on_signedLineEdit_textEdited(const QString & arg1)
void WordEditDialog::on_unsignedLineEdit_textEdited(const QString & arg1)
{
LONGLONG value;
if(sscanf(arg1.toUtf8().constData(), "%llu", &value) == 1)
if(sscanf_s(arg1.toUtf8().constData(), "%llu", &value) == 1)
{
ui->unsignedLineEdit->setStyleSheet("");
ui->buttons->button(QDialogButtonBox::Ok)->setEnabled(true);

View File

@ -250,6 +250,7 @@ Configuration::Configuration() : QObject()
defaultShortcuts.insert("ActionSetOneRegister", Shortcut(tr("Actions -> Set Register to One"), "1"));
defaultShortcuts.insert("ActionToggleRegisterValue", Shortcut(tr("Actions -> Toggle Register Value"), "Space"));
defaultShortcuts.insert("ActionCopy", Shortcut(tr("Actions -> Copy"), "Ctrl+C"));
defaultShortcuts.insert("ActionCopySymbol", Shortcut(tr("Actions -> Copy Symbol"), "Ctrl+S"));
defaultShortcuts.insert("ActionLoadScript", Shortcut(tr("Actions -> Load Script"), "Ctrl+O"));
defaultShortcuts.insert("ActionUnloadScript", Shortcut(tr("Actions -> Unload Script"), "Ctrl+U"));
defaultShortcuts.insert("ActionRunScript", Shortcut(tr("Actions -> Run Script"), "Space"));

View File

@ -1,23 +1,21 @@
#include "main.h"
#include <QAbstractEventDispatcher>
#include <QMessageBox>
#include "Bridge.h"
#include "Configuration.h"
#include "MainWindow.h"
#include <QTextCodec>
MyApplication::MyApplication(int & argc, char** argv) : QApplication(argc, argv)
{
}
bool MyApplication::winEventFilter(MSG* message, long* result)
{
return DbgWinEvent(message, result);
}
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
bool MyApplication::globalEventFilter(void* message)
{
return DbgWinEventGlobal((MSG*)message);
}
#endif
bool MyApplication::winEventFilter(MSG* message, long* result)
{
return DbgWinEvent(message, result);
}
bool MyApplication::notify(QObject* receiver, QEvent* event)
{
@ -48,7 +46,13 @@ static Configuration* mConfiguration;
int main(int argc, char* argv[])
{
MyApplication application(argc, argv);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
QAbstractEventDispatcher::instance(application.thread())->setEventFilter(MyApplication::globalEventFilter);
#else
x64GlobalFilter* filter = new x64GlobalFilter();
QAbstractEventDispatcher::instance(application.thread())->installNativeEventFilter(filter);
#endif
// load config file + set config font
mConfiguration = new Configuration;
@ -60,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();
@ -84,5 +93,8 @@ int main(int argc, char* argv[])
//execute the application
int result = application.exec();
mConfiguration->save(); //save config on exit
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
QAbstractEventDispatcher::instance(application.thread())->removeNativeEventFilter(filter);
#endif
return result;
}

View File

@ -2,6 +2,14 @@
#define MAIN_H
#include <QApplication>
#include <QAbstractEventDispatcher>
#include <QMessageBox>
#include "Bridge.h"
#include "Configuration.h"
#include "MainWindow.h"
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include <QAbstractNativeEventFilter>
#endif
class MyApplication : public QApplication
{
@ -9,10 +17,22 @@ public:
MyApplication(int & argc, char** argv);
bool notify(QObject* receiver, QEvent* event);
bool winEventFilter(MSG* message, long* result);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
static bool globalEventFilter(void* message);
#endif
};
int main(int argc, char* argv[]);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
class x64GlobalFilter : public QAbstractNativeEventFilter
{
public:
virtual bool nativeEventFilter(const QByteArray &, void* message, long*) Q_DECL_OVERRIDE
{
return DbgWinEventGlobal((MSG*)message);
}
};
#endif // QT_VERSION
#endif // MAIN_H

View File

@ -55,7 +55,7 @@ enum arch
};
/**
@fn static bool FileExists(const char* file)
@fn static bool FileExists(const wchar_t* file)
@brief Queries if a given file exists.
@ -64,14 +64,14 @@ enum arch
@return true if it succeeds, false if it fails.
*/
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));
}
/**
@fn static arch GetFileArchitecture(const char* szFileName)
@fn static arch GetFileArchitecture(const wchar_t* szFileName)
@brief Gets file architecture.
@ -80,10 +80,10 @@ static bool FileExists(const char* file)
@return The file architecture.
*/
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];
@ -114,51 +114,7 @@ static arch GetFileArchitecture(const char* szFileName)
}
/**
@fn static void commandlinefree(int argc, char** argv)
@brief Original code by Aurel from http://www.codeguru.com/cpp/w-p/win32/article.php/c1427/A-
Simple-Win32-CommandLine-Parser.htm.
@param argc The argc.
@param [in,out] argv If non-null, the argv.
*/
static void commandlinefree(int argc, char** argv)
{
for(int i = 0; i < argc; i++)
free(argv[i]);
free(argv);
}
/**
@fn static char** commandlineparse(int* argc)
@brief Commandlineparses the given argc.
@param [in,out] argc If non-null, the argc.
@return null if it fails, else a char**.
*/
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;
}
/**
@fn static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, char* filename, int filename_size, const char* init_dir)
@fn static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* defext, wchar_t* filename, int filename_size, const wchar_t* init_dir)
@brief Queries if a given browse file open.
@ -172,20 +128,20 @@ static char** commandlineparse(int* argc)
@return true if it succeeds, false if it fails.
*/
static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, char* filename, int filename_size, const char* init_dir)
static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* defext, wchar_t* filename, int filename_size, const wchar_t* 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);
}
/**
@ -193,19 +149,19 @@ static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, c
@brief A macro that defines shellext executable key.
*/
#define SHELLEXT_EXE_KEY "exefile\\shell\\Debug with x64_dbg\\Command"
#define SHELLEXT_EXE_KEY L"exefile\\shell\\Debug with x64_dbg\\Command"
/**
@def SHELLEXT_DLL_KEY
@brief A macro that defines shellext DLL key.
*/
#define SHELLEXT_DLL_KEY "dllfile\\shell\\Debug with x64_dbg\\Command"
#define SHELLEXT_DLL_KEY L"dllfile\\shell\\Debug with x64_dbg\\Command"
/**
@fn void RegisterShellExtension(const char* key, const char* command)
@fn static void RegisterShellExtension(const wchar_t* key, const wchar_t* command)
@brief Registers the shell extension.
@ -213,19 +169,35 @@ static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, c
@param command The 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);
}
/**
@fn int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
@ -243,123 +215,124 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
{
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;
}