From ab0279e168065cfa4afe6b87da34e81f68fe904c Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Tue, 30 Dec 2014 03:51:04 +0100 Subject: [PATCH 001/106] GUI: close buttons on tabs --- x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp | 11 +++++++++-- x64_dbg_gui/Project/Src/Gui/ReferenceManager.h | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp index 20b0499a..2ea62a8e 100644 --- a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp @@ -1,11 +1,13 @@ #include "ReferenceManager.h" #include "Bridge.h" -ReferenceManager::ReferenceManager(QWidget* parent) : MHTabWidget(parent, false, true) +ReferenceManager::ReferenceManager(QWidget* parent) : QTabWidget(parent) { - this->setMovable(true); + setMovable(true); + setTabsClosable(true); mCurrentReferenceView = 0; connect(Bridge::getBridge(), SIGNAL(referenceInitialize(QString)), this, SLOT(newReferenceView(QString))); + connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); } ReferenceView* ReferenceManager::currentReferenceView() @@ -23,3 +25,8 @@ void ReferenceManager::newReferenceView(QString name) setCurrentIndex(0); Bridge::getBridge()->BridgeSetResult(1); } + +void ReferenceManager::closeTab(int index) +{ + removeTab(index); +} diff --git a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h index 8f131ed9..5a54b6ce 100644 --- a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h +++ b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h @@ -1,18 +1,19 @@ #ifndef REFERENCEMANAGER_H #define REFERENCEMANAGER_H -#include "TabWidget.h" +#include #include "ReferenceView.h" -class ReferenceManager : public MHTabWidget +class ReferenceManager : public QTabWidget { Q_OBJECT public: explicit ReferenceManager(QWidget* parent = 0); ReferenceView* currentReferenceView(); -public slots: +private slots: void newReferenceView(QString name); + void closeTab(int index); signals: void showCpu(); From ab3cf76115837db8ddfe30a670df17769e92b6be Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Tue, 30 Dec 2014 03:57:58 +0100 Subject: [PATCH 002/106] DBG+GUI: updated register context structures (for plugin mingw compatibility) --- x64_dbg_bridge/bridgemain.h | 20 +++++++++--- x64_dbg_dbg/TitanEngine/TitanEngine.h | 22 ++++++------- x64_dbg_dbg/x64_dbg.cpp | 2 ++ x64_dbg_gui/Project/Src/Gui/RegistersView.cpp | 32 +++++++++---------- 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index 09f961f4..b7d50aa5 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -423,6 +423,18 @@ typedef struct } X87CONTROLWORDFIELDS; +typedef struct DECLSPEC_ALIGN(16) _XMMREGISTER +{ + ULONGLONG Low; + LONGLONG High; +} XMMREGISTER; + +typedef struct +{ + XMMREGISTER Low; //XMM/SSE part + XMMREGISTER High; //AVX part +} YMMREGISTER; + typedef struct { BYTE data[10]; @@ -480,11 +492,11 @@ typedef struct X87FPU x87fpu; DWORD MxCsr; #ifdef _WIN64 - M128A XmmRegisters[16]; - BYTE YmmRegisters[32 * 16]; + XMMREGISTER XmmRegisters[16]; + YMMREGISTER YmmRegisters[16]; #else // x86 - M128A XmmRegisters[8]; - BYTE YmmRegisters[32 * 8]; + XMMREGISTER XmmRegisters[8]; + YMMREGISTER YmmRegisters[8]; #endif } REGISTERCONTEXT; diff --git a/x64_dbg_dbg/TitanEngine/TitanEngine.h b/x64_dbg_dbg/TitanEngine/TitanEngine.h index 0576db7c..55d01c2b 100644 --- a/x64_dbg_dbg/TitanEngine/TitanEngine.h +++ b/x64_dbg_dbg/TitanEngine/TitanEngine.h @@ -10,14 +10,6 @@ #include #include -#ifdef __GNUC__ -typedef struct DECLSPEC_ALIGN(16) _M128A -{ - ULONGLONG Low; - LONGLONG High; -} M128A, *PM128A; -#endif //__GNUC__ - #pragma pack(push, 1) // Global.Constant.Structure.Declaration: @@ -594,10 +586,16 @@ typedef struct DWORD OriginalCOMTableSize; } FILE_FIX_INFO, *PFILE_FIX_INFO; +typedef struct DECLSPEC_ALIGN(16) _XmmRegister_t +{ + ULONGLONG Low; + LONGLONG High; +} XmmRegister_t; + typedef struct { - M128A Low; //XMM/SSE part - M128A High; //AVX part + XmmRegister_t Low; //XMM/SSE part + XmmRegister_t High; //AVX part } YmmRegister_t; typedef struct @@ -657,10 +655,10 @@ typedef struct x87FPU_t x87fpu; DWORD MxCsr; #ifdef _WIN64 - M128A XmmRegisters[16]; + XmmRegister_t XmmRegisters[16]; YmmRegister_t YmmRegisters[16]; #else // x86 - M128A XmmRegisters[8]; + XmmRegister_t XmmRegisters[8]; YmmRegister_t YmmRegisters[8]; #endif } TITAN_ENGINE_CONTEXT_t; diff --git a/x64_dbg_dbg/x64_dbg.cpp b/x64_dbg_dbg/x64_dbg.cpp index 18037434..8963663b 100644 --- a/x64_dbg_dbg/x64_dbg.cpp +++ b/x64_dbg_dbg/x64_dbg.cpp @@ -234,6 +234,8 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit() { if(!EngineCheckStructAlignment(UE_STRUCT_TITAN_ENGINE_CONTEXT, sizeof(TITAN_ENGINE_CONTEXT_t))) return "Invalid TITAN_ENGINE_CONTEXT_t alignment!"; + if(sizeof(TITAN_ENGINE_CONTEXT_t) != sizeof(REGISTERCONTEXT)) + return "Invalid REGISTERCONTEXT alignment!"; dbginit(); dbgfunctionsinit(); json_set_alloc_funcs(emalloc_json, efree_json); diff --git a/x64_dbg_gui/Project/Src/Gui/RegistersView.cpp b/x64_dbg_gui/Project/Src/Gui/RegistersView.cpp index d00d39f5..1d95ab00 100644 --- a/x64_dbg_gui/Project/Src/Gui/RegistersView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/RegistersView.cpp @@ -2375,22 +2375,22 @@ char* RegistersView::registerValue(const REGDUMP* regd, const REGISTER_NAME reg) if(reg == XMM14) return (char*) & (regd->regcontext.XmmRegisters[14]); if(reg == XMM15) return (char*) & (regd->regcontext.XmmRegisters[15]); - if(reg == YMM0) return (char*) & (regd->regcontext.YmmRegisters[32 * 0]); - if(reg == YMM1) return (char*) & (regd->regcontext.YmmRegisters[32 * 1]); - if(reg == YMM2) return (char*) & (regd->regcontext.YmmRegisters[32 * 2]); - if(reg == YMM3) return (char*) & (regd->regcontext.YmmRegisters[32 * 3]); - if(reg == YMM4) return (char*) & (regd->regcontext.YmmRegisters[32 * 4]); - if(reg == YMM5) return (char*) & (regd->regcontext.YmmRegisters[32 * 5]); - if(reg == YMM6) return (char*) & (regd->regcontext.YmmRegisters[32 * 6]); - if(reg == YMM7) return (char*) & (regd->regcontext.YmmRegisters[32 * 7]); - if(reg == YMM8) return (char*) & (regd->regcontext.YmmRegisters[32 * 8]); - if(reg == YMM9) return (char*) & (regd->regcontext.YmmRegisters[32 * 9]); - if(reg == YMM10) return (char*) & (regd->regcontext.YmmRegisters[32 * 10]); - if(reg == YMM11) return (char*) & (regd->regcontext.YmmRegisters[32 * 11]); - if(reg == YMM12) return (char*) & (regd->regcontext.YmmRegisters[32 * 12]); - if(reg == YMM13) return (char*) & (regd->regcontext.YmmRegisters[32 * 13]); - if(reg == YMM14) return (char*) & (regd->regcontext.YmmRegisters[32 * 14]); - if(reg == YMM15) return (char*) & (regd->regcontext.YmmRegisters[32 * 15]); + if(reg == YMM0) return (char*) & (regd->regcontext.YmmRegisters[0]); + if(reg == YMM1) return (char*) & (regd->regcontext.YmmRegisters[1]); + if(reg == YMM2) return (char*) & (regd->regcontext.YmmRegisters[2]); + if(reg == YMM3) return (char*) & (regd->regcontext.YmmRegisters[3]); + if(reg == YMM4) return (char*) & (regd->regcontext.YmmRegisters[4]); + if(reg == YMM5) return (char*) & (regd->regcontext.YmmRegisters[5]); + if(reg == YMM6) return (char*) & (regd->regcontext.YmmRegisters[6]); + if(reg == YMM7) return (char*) & (regd->regcontext.YmmRegisters[7]); + if(reg == YMM8) return (char*) & (regd->regcontext.YmmRegisters[8]); + if(reg == YMM9) return (char*) & (regd->regcontext.YmmRegisters[9]); + if(reg == YMM10) return (char*) & (regd->regcontext.YmmRegisters[10]); + if(reg == YMM11) return (char*) & (regd->regcontext.YmmRegisters[11]); + if(reg == YMM12) return (char*) & (regd->regcontext.YmmRegisters[12]); + if(reg == YMM13) return (char*) & (regd->regcontext.YmmRegisters[13]); + if(reg == YMM14) return (char*) & (regd->regcontext.YmmRegisters[14]); + if(reg == YMM15) return (char*) & (regd->regcontext.YmmRegisters[15]); return (char*) & null_value; } From 2eaac560e67dda49a1786a1d8200a07fa1c7ac9c Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 1 Jan 2015 20:43:49 +0100 Subject: [PATCH 003/106] DBG: updated version --- x64_dbg_bridge/bridgemain.h | 2 +- x64_dbg_exe/resource.rc | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index b7d50aa5..eaff79f3 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -37,7 +37,7 @@ extern "C" //Bridge defines #define MAX_SETTING_SIZE 65536 -#define DBG_VERSION 23 +#define DBG_VERSION 24 //Bridge functions BRIDGE_IMPEXP const char* BridgeInit(); diff --git a/x64_dbg_exe/resource.rc b/x64_dbg_exe/resource.rc index f95d4139..15456905 100644 --- a/x64_dbg_exe/resource.rc +++ b/x64_dbg_exe/resource.rc @@ -67,8 +67,8 @@ IDI_ICON1 ICON "..\\bug.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,0,2,3 - PRODUCTVERSION 0,0,2,3 + FILEVERSION 0,0,2,4 + PRODUCTVERSION 0,0,2,4 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -84,10 +84,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "x64_dbg" - VALUE "FileVersion", "0.0.2.3" + VALUE "FileVersion", "0.0.2.4" VALUE "LegalCopyright", "x64dbg.com" VALUE "ProductName", "x64_dbg" - VALUE "ProductVersion", "V2.2ALPHA" + VALUE "ProductVersion", "0.0.2.4" END END BLOCK "VarFileInfo" From 2e347ad716f7346fb002935f0394923a2a6309e5 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 1 Jan 2015 20:44:19 +0100 Subject: [PATCH 004/106] GUI: resolved issue #233 (crack in hexdump when scrolling up sometimes) --- x64_dbg_gui/Project/Src/BasicView/HexDump.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 4 ++++ x64_dbg_gui/Project/Src/Gui/CPUStack.cpp | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp b/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp index 31f9cf63..f577ccea 100644 --- a/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp @@ -238,7 +238,7 @@ QString HexDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i { // Reset byte offset when base address is reached if(rowBase == 0 && mByteOffset != 0) - printDumpAt(mMemPage->getBase(), false); + printDumpAt(mMemPage->getBase(), false, false); // Compute RVA int wBytePerRowCount = getBytePerRowCount(); diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index 3ca26842..8acaa507 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -361,6 +361,10 @@ void CPUDump::refreshShortcutsSlot() QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h) { + // Reset byte offset when base address is reached + if(rowBase == 0 && mByteOffset != 0) + printDumpAt(mMemPage->getBase(), false, false); + QString wStr = ""; if(!col) //address { diff --git a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp index 059646cf..c49475a2 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp @@ -169,6 +169,10 @@ void CPUStack::refreshShortcutsSlot() QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h) { + // Reset byte offset when base address is reached + if(rowBase == 0 && mByteOffset != 0) + printDumpAt(mMemPage->getBase(), false, false); + // Compute RVA int wBytePerRowCount = getBytePerRowCount(); int_t wRva = (rowBase + rowOffset) * wBytePerRowCount - mByteOffset; From cca12ca83f73dfb6e8c0016b1d4017b2d082094d Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 2 Jan 2015 16:38:00 +0100 Subject: [PATCH 005/106] GUI: resolved issue #236 (reference view does not follow in disassembler correctly) --- x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp index 428fec2a..a0d546ec 100644 --- a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp @@ -7,6 +7,7 @@ ReferenceView::ReferenceView() { // Setup SearchListView settings mSearchStartCol = 1; + mFollowDumpDefault = false; // Create search progress bar mSearchProgress = new QProgressBar(); From fbd28ee8426c4a509b45d404660a424ddb9e2f9f Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 2 Jan 2015 17:08:17 +0100 Subject: [PATCH 006/106] BRIDGE: resolved issue #237 (x64dbg sometimes loses settings) --- x64_dbg_bridge/bridgemain.cpp | 46 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.cpp b/x64_dbg_bridge/bridgemain.cpp index 595a1f0f..bfa8cd88 100644 --- a/x64_dbg_bridge/bridgemain.cpp +++ b/x64_dbg_bridge/bridgemain.cpp @@ -5,6 +5,7 @@ static HINSTANCE hInst; static wchar_t szIniFile[MAX_PATH] = L""; +static CRITICAL_SECTION csIni; #ifdef _WIN64 #define dbg_lib "x64_dbg.dll" @@ -105,14 +106,20 @@ BRIDGE_IMPEXP bool BridgeSettingGet(const char* section, const char* key, char* { if(!section || !key || !value) return false; + EnterCriticalSection(&csIni); 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; + bool success = false; + if(inifile.LoadFile(szIniFile) >= 0) + { + const char* szValue = inifile.GetValue(section, key); + if(szValue) + { + strcpy_s(value, MAX_SETTING_SIZE, szValue); + success = true; + } + } + LeaveCriticalSection(&csIni); + return success; } BRIDGE_IMPEXP bool BridgeSettingGetUint(const char* section, const char* key, duint* value) @@ -134,15 +141,20 @@ BRIDGE_IMPEXP bool BridgeSettingGetUint(const char* section, const char* key, du BRIDGE_IMPEXP bool BridgeSettingSet(const char* section, const char* key, const char* value) { - if(!section) - return false; - 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; + bool success = false; + if(section) + { + EnterCriticalSection(&csIni); + 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); + success = inifile.SaveFile(szIniFile, false) >= 0; + LeaveCriticalSection(&csIni); + } + return success; } BRIDGE_IMPEXP bool BridgeSettingSetUint(const char* section, const char* key, duint value) @@ -1000,7 +1012,7 @@ BRIDGE_IMPEXP void GuiUpdateCallStack() //Main BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + InitializeCriticalSection(&csIni); hInst = hinstDLL; return TRUE; } - From 218bb05c18b6da8b6e2e32061bf56e03c3d10056 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 2 Jan 2015 17:12:19 +0100 Subject: [PATCH 007/106] BRIDGE: fixed a bug with the critical section (initialized multiple times) --- x64_dbg_bridge/bridgemain.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.cpp b/x64_dbg_bridge/bridgemain.cpp index bfa8cd88..4e266ed9 100644 --- a/x64_dbg_bridge/bridgemain.cpp +++ b/x64_dbg_bridge/bridgemain.cpp @@ -32,7 +32,10 @@ static CRITICAL_SECTION csIni; //Bridge BRIDGE_IMPEXP const char* BridgeInit() { - ///Settings load + //Initialize critial section + InitializeCriticalSection(&csIni); + + //Settings load if(!GetModuleFileNameW(0, szIniFile, MAX_PATH)) return "Error getting module path!"; int len = (int)wcslen(szIniFile); @@ -82,6 +85,7 @@ BRIDGE_IMPEXP const char* BridgeStart() if(!_dbg_dbginit || !_gui_guiinit) return "\"_dbg_dbginit\" || \"_gui_guiinit\" was not loaded yet, call BridgeInit!"; _gui_guiinit(0, 0); //remove arguments + DeleteCriticalSection(&csIni); return 0; } @@ -1012,7 +1016,6 @@ BRIDGE_IMPEXP void GuiUpdateCallStack() //Main BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - InitializeCriticalSection(&csIni); hInst = hinstDLL; return TRUE; } From bbe499ebdf0a79d9195d89b400ce9a9fbdbe573f Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 2 Jan 2015 17:22:09 +0100 Subject: [PATCH 008/106] DBG: added a 'secret' option to disable database compression --- x64_dbg_dbg/addrinfo.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index 62ce22a3..a6bd913d 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -45,7 +45,8 @@ void dbsave() return; } fclose(jsonFile); - LZ4_compress_fileW(wdbpath.c_str(), wdbpath.c_str()); + if(!settingboolget("Engine", "DisableCompression")) + LZ4_compress_fileW(wdbpath.c_str(), wdbpath.c_str()); } else //remove database when nothing is in there DeleteFileW(wdbpath.c_str()); @@ -60,8 +61,9 @@ void dbload() dprintf("loading database..."); DWORD ticks = GetTickCount(); WString wdbpath = StringUtils::Utf8ToUtf16(dbpath); + bool compress = !settingboolget("Engine", "DisableCompression"); LZ4_STATUS status = LZ4_decompress_fileW(wdbpath.c_str(), wdbpath.c_str()); - if(status != LZ4_SUCCESS && status != LZ4_INVALID_ARCHIVE) + if(status != LZ4_SUCCESS && status != LZ4_INVALID_ARCHIVE && compress) { dputs("\ninvalid database file!"); return; @@ -74,7 +76,7 @@ void dbload() } JSON root = json_loadf(jsonFile, 0, 0); fclose(jsonFile); - if(status != LZ4_INVALID_ARCHIVE) + if(status != LZ4_INVALID_ARCHIVE && compress) LZ4_compress_fileW(wdbpath.c_str(), wdbpath.c_str()); if(!root) { From 45393bda756d95e0ca9f5c2d1d1762e23e54e2bc Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 2 Jan 2015 12:35:06 -0500 Subject: [PATCH 009/106] GUI: Normalize table headers --- x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp | 12 ++++++------ x64_dbg_gui/Project/Src/Gui/ThreadView.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp index 8d053128..92ca43f2 100644 --- a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp @@ -9,12 +9,12 @@ MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent) int charwidth = getCharWidth(); - addColumnAt(8 + charwidth * 2 * sizeof(uint_t), "ADDR", false, "Address"); //addr - addColumnAt(8 + charwidth * 2 * sizeof(uint_t), "SIZE", false, "Size"); //size - addColumnAt(8 + charwidth * 32, "INFO", false, "Page Information"); //page information - addColumnAt(8 + charwidth * 3, "TYP", false, "Allocation Type"); //allocation type - addColumnAt(8 + charwidth * 5, "CPROT", false, "Current Protection"); //current protection - addColumnAt(8 + charwidth * 5, "APROT", false, "Allocation Protection"); //allocation protection + addColumnAt(8 + charwidth * 2 * sizeof(uint_t), "Address", false, "Address"); //addr + addColumnAt(8 + charwidth * 2 * sizeof(uint_t), "Size", false, "Size"); //size + addColumnAt(8 + charwidth * 32, "Info", false, "Page Information"); //page information + addColumnAt(8 + charwidth * 5, "Type", false, "Allocation Type"); //allocation type + addColumnAt(8 + charwidth * 11, "Protection", false, "Current Protection"); //current protection + addColumnAt(8 + charwidth * 8, "Initial", false, "Allocation Protection"); //allocation protection addColumnAt(100, "", false); connect(Bridge::getBridge(), SIGNAL(updateMemory()), this, SLOT(refreshMap())); diff --git a/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp b/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp index b1232ac6..4266b420 100644 --- a/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp @@ -198,8 +198,8 @@ ThreadView::ThreadView(StdTable* parent) : StdTable(parent) #endif //_WIN64 addColumnAt(8 + charwidth * 14, "Suspend Count", false); addColumnAt(8 + charwidth * 12, "Priority", false); - addColumnAt(8 + charwidth * 16, "WaitReason", false); - addColumnAt(8 + charwidth * 10, "LastError", false); + addColumnAt(8 + charwidth * 12, "Wait Reason", false); + addColumnAt(8 + charwidth * 11, "Last Error", false); addColumnAt(0, "Name", false); //setCopyMenuOnly(true); From ff2b7422c7d300df27623797187c3079253c869a Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 2 Jan 2015 13:01:45 -0500 Subject: [PATCH 010/106] DBG: Capitalize status messages --- x64_dbg_dbg/debugger.cpp | 71 +++++---- x64_dbg_dbg/debugger_commands.cpp | 253 +++++++++++++++--------------- 2 files changed, 163 insertions(+), 161 deletions(-) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 6e668cd5..1febebdf 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -273,7 +273,7 @@ void cbUserBreakpoint() PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; if(!bpget(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled) - dputs("breakpoint reached not in list!"); + dputs("Breakpoint reached not in list!"); else { const char* bptype = "INT3"; @@ -324,7 +324,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress) PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; if(!bpget((uint)ExceptionAddress, BPHARDWARE, 0, &bp)) - dputs("hardware breakpoint reached not in list!"); + dputs("Hardware breakpoint reached not in list!"); else { const char* bpsize = ""; @@ -363,16 +363,16 @@ void cbHardwareBreakpoint(void* ExceptionAddress) if(symbolicname) { if(*bp.name) - dprintf("hardware breakpoint (%s%s) \"%s\" at %s ("fhex")!\n", bpsize, bptype, bp.name, symbolicname, bp.addr); + dprintf("Hardware breakpoint (%s%s) \"%s\" at %s ("fhex")!\n", bpsize, bptype, bp.name, symbolicname, bp.addr); else - dprintf("hardware breakpoint (%s%s) at %s ("fhex")!\n", bpsize, bptype, symbolicname, bp.addr); + dprintf("Hardware breakpoint (%s%s) at %s ("fhex")!\n", bpsize, bptype, symbolicname, bp.addr); } else { if(*bp.name) - dprintf("hardware breakpoint (%s%s) \"%s\" at "fhex"!\n", bpsize, bptype, bp.name, bp.addr); + dprintf("Hardware breakpoint (%s%s) \"%s\" at "fhex"!\n", bpsize, bptype, bp.name, bp.addr); else - dprintf("hardware breakpoint (%s%s) at "fhex"!\n", bpsize, bptype, bp.addr); + dprintf("Hardware breakpoint (%s%s) at "fhex"!\n", bpsize, bptype, bp.addr); } bptobridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; @@ -401,7 +401,7 @@ void cbMemoryBreakpoint(void* ExceptionAddress) PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; if(!bpget(base, BPMEMORY, 0, &bp)) - dputs("memory breakpoint reached not in list!"); + dputs("Memory breakpoint reached not in list!"); else { const char* bptype = ""; @@ -424,16 +424,16 @@ void cbMemoryBreakpoint(void* ExceptionAddress) if(symbolicname) { if(*bp.name) - dprintf("memory breakpoint%s \"%s\" at %s ("fhex", "fhex")!\n", bptype, bp.name, symbolicname, bp.addr, ExceptionAddress); + dprintf("Memory breakpoint%s \"%s\" at %s ("fhex", "fhex")!\n", bptype, bp.name, symbolicname, bp.addr, ExceptionAddress); else - dprintf("memory breakpoint%s at %s ("fhex", "fhex")!\n", bptype, symbolicname, bp.addr, ExceptionAddress); + dprintf("Memory breakpoint%s at %s ("fhex", "fhex")!\n", bptype, symbolicname, bp.addr, ExceptionAddress); } else { if(*bp.name) - dprintf("memory breakpoint%s \"%s\" at "fhex" ("fhex")!\n", bptype, bp.name, bp.addr, ExceptionAddress); + dprintf("Memory breakpoint%s \"%s\" at "fhex" ("fhex")!\n", bptype, bp.name, bp.addr, ExceptionAddress); else - dprintf("memory breakpoint%s at "fhex" ("fhex")!\n", bptype, bp.addr, ExceptionAddress); + dprintf("Memory breakpoint%s at "fhex" ("fhex")!\n", bptype, bp.addr, ExceptionAddress); } bptobridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; @@ -537,7 +537,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp) case BPNORMAL: { if(!SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint)) - dprintf("could not set breakpoint "fhex"!\n", bp->addr); + dprintf("Could not set breakpoint "fhex"!\n", bp->addr); } break; @@ -546,7 +546,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp) uint size = 0; memfindbaseaddr(bp->addr, &size); if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) - dprintf("could not set memory breakpoint "fhex"!\n", bp->addr); + dprintf("Could not set memory breakpoint "fhex"!\n", bp->addr); } break; @@ -555,14 +555,14 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp) DWORD drx = 0; if(!GetUnusedHardwareBreakPointRegister(&drx)) { - dputs("you can only set 4 hardware breakpoints"); + dputs("You can only set 4 hardware breakpoints"); return false; } int titantype = bp->titantype; TITANSETDRX(titantype, drx); bpsettitantype(bp->addr, BPHARDWARE, titantype); if(!SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) - dprintf("could not set hardware breakpoint "fhex"!\n", bp->addr); + dprintf("Could not set hardware breakpoint "fhex"!\n", bp->addr); } break; @@ -708,7 +708,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) dprintf("TLS Callbacks: %d\n", NumberOfCallBacks); Memory TLSCallBacks(NumberOfCallBacks * sizeof(uint), "cbCreateProcess:TLSCallBacks"); if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), TLSCallBacks, &NumberOfCallBacks)) - dputs("failed to get TLS callback addresses!"); + dputs("Failed to get TLS callback addresses!"); else { for(unsigned int i = 0; i < NumberOfCallBacks; i++) @@ -821,9 +821,9 @@ static void cbSystemBreakpoint(void* ExceptionData) hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); //log message if(bIsAttached) - dputs("attach breakpoint reached!"); + dputs("Attach breakpoint reached!"); else - dputs("system breakpoint reached!"); + dputs("System breakpoint reached!"); bSkipExceptions = false; //we are not skipping first-chance exceptions uint cip = GetContextDataEx(hActiveThread, UE_CIP); GuiDumpAt(memfindbaseaddr(cip, 0, true)); //dump somewhere @@ -1015,7 +1015,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) if(!DetachDebuggerEx(fdProcessInfo->dwProcessId)) dputs("DetachDebuggerEx failed..."); else - dputs("detached!"); + dputs("Detached!"); isDetachedByUser = false; return; } @@ -1061,9 +1061,9 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) if(ExceptionData->dwFirstChance) //first chance exception { if(exceptionName) - dprintf("first chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName); + dprintf("First chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName); else - dprintf("first chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode); + dprintf("First chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode); SetNextDbgContinueStatus(DBG_EXCEPTION_NOT_HANDLED); if(bSkipExceptions || dbgisignoredexception(ExceptionCode)) return; @@ -1071,9 +1071,9 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) else //lock the exception { if(exceptionName) - dprintf("last chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName); + dprintf("Last chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName); else - dprintf("last chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode); + dprintf("Last chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode); SetNextDbgContinueStatus(DBG_CONTINUE); } @@ -1115,7 +1115,7 @@ DWORD WINAPI threadDebugLoop(void* lpParameter) if(!fdProcessInfo) { fdProcessInfo = &g_pi; - dputs("error starting process (invalid pe?)!"); + dputs("Error starting process (invalid pe?)!"); unlock(WAITID_STOP); return 0; } @@ -1192,7 +1192,8 @@ bool cbDeleteAllBreakpoints(const BREAKPOINT* bp) { if(bpdel(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr))) return true; - dprintf("delete breakpoint failed: "fhex"\n", bp->addr); + + dprintf("Delete breakpoint failed: "fhex"\n", bp->addr); return false; } @@ -1200,9 +1201,10 @@ bool cbEnableAllBreakpoints(const BREAKPOINT* bp) { if(bp->type != BPNORMAL or bp->enabled) return true; + if(!bpenable(bp->addr, BPNORMAL, true) or !SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint)) { - dprintf("could not enable breakpoint "fhex"\n", bp->addr); + dprintf("Could not enable breakpoint "fhex"\n", bp->addr); return false; } return true; @@ -1212,9 +1214,10 @@ bool cbDisableAllBreakpoints(const BREAKPOINT* bp) { if(bp->type != BPNORMAL or !bp->enabled) return true; + if(!bpenable(bp->addr, BPNORMAL, false) or !DeleteBPX(bp->addr)) { - dprintf("could not disable breakpoint "fhex"\n", bp->addr); + dprintf("Could not disable breakpoint "fhex"\n", bp->addr); return false; } return true; @@ -1227,7 +1230,7 @@ bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp) DWORD drx = 0; if(!GetUnusedHardwareBreakPointRegister(&drx)) { - dprintf("did not enable hardware breakpoint "fhex" (all slots full)\n", bp->addr); + dprintf("Did not enable hardware breakpoint "fhex" (all slots full)\n", bp->addr); return true; } int titantype = bp->titantype; @@ -1247,7 +1250,7 @@ bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp) return true; if(!bpenable(bp->addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { - dprintf("could not disable hardware breakpoint "fhex"\n", bp->addr); + dprintf("Could not disable hardware breakpoint "fhex"\n", bp->addr); return false; } return true; @@ -1261,7 +1264,7 @@ bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp) memfindbaseaddr(bp->addr, &size); if(!bpenable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) { - dprintf("could not enable memory breakpoint "fhex"\n", bp->addr); + dprintf("Could not enable memory breakpoint "fhex"\n", bp->addr); return false; } return true; @@ -1273,7 +1276,7 @@ bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp) return true; if(!bpenable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { - dprintf("could not disable memory breakpoint "fhex"\n", bp->addr); + dprintf("Could not disable memory breakpoint "fhex"\n", bp->addr); return false; } return true; @@ -1309,7 +1312,7 @@ bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp) memfindbaseaddr(bp->addr, &size); if(!bpdel(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size)) { - dprintf("delete memory breakpoint failed: "fhex"\n", bp->addr); + dprintf("Delete memory breakpoint failed: "fhex"\n", bp->addr); return STATUS_ERROR; } return true; @@ -1321,7 +1324,7 @@ bool cbDeleteAllHardwareBreakpoints(const BREAKPOINT* bp) return true; if(!bpdel(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { - dprintf("delete hardware breakpoint failed: "fhex"\n", bp->addr); + dprintf("Delete hardware breakpoint failed: "fhex"\n", bp->addr); return STATUS_ERROR; } return true; @@ -1412,7 +1415,7 @@ void cbDetach() if(!DetachDebuggerEx(fdProcessInfo->dwProcessId)) dputs("DetachDebuggerEx failed..."); else - dputs("detached!"); + dputs("Detached!"); return; } diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 00fc1f8a..5310259d 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -29,18 +29,18 @@ CMDRESULT cbDebugInit(int argc, char* argv[]) char szResolvedPath[MAX_PATH] = ""; if(ResolveShortcut(GuiGetWindowHandle(), StringUtils::Utf8ToUtf16(arg1).c_str(), szResolvedPath, _countof(szResolvedPath))) { - dprintf("resolved shortcut \"%s\"->\"%s\"\n", arg1, szResolvedPath); + dprintf("Resolved shortcut \"%s\"->\"%s\"\n", arg1, szResolvedPath); strcpy_s(arg1, szResolvedPath); } if(!FileExists(arg1)) { - dputs("file does not exist!"); + dputs("File does not exist!"); return STATUS_ERROR; } HANDLE hFile = CreateFileW(StringUtils::Utf8ToUtf16(arg1).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if(hFile == INVALID_HANDLE_VALUE) { - dputs("could not open file!"); + dputs("Could not open file!"); return STATUS_ERROR; } GetFileNameFromHandle(hFile, arg1); //get full path of the file @@ -50,14 +50,14 @@ CMDRESULT cbDebugInit(int argc, char* argv[]) switch(GetFileArchitecture(arg1)) { case invalid: - dputs("invalid PE file!"); + dputs("Invalid PE file!"); return STATUS_ERROR; #ifdef _WIN64 case x32: - dputs("use x32_dbg to debug this file!"); + dputs("Use x32_dbg to debug this file!"); #else //x86 case x64: - dputs("use x64_dbg to debug this file!"); + dputs("Use x64_dbg to debug this file!"); #endif //_WIN64 return STATUS_ERROR; default: @@ -109,7 +109,7 @@ CMDRESULT cbDebugRun(int argc, char* argv[]) { if(!waitislocked(WAITID_RUN)) { - dputs("program is already running"); + dputs("Program is already running"); return STATUS_ERROR; } GuiSetDebugState(running); @@ -155,12 +155,12 @@ CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[]) } else { - dputs("invalid type specified!"); + dputs("Invalid type specified!"); return STATUS_ERROR; } SetBPXOptions(type); BridgeSettingSetUint("Engine", "BreakpointType", setting_type); - dprintf("default breakpoint type set to: %s\n", a); + dprintf("Default breakpoint type set to: %s\n", a); return STATUS_CONTINUE; } @@ -182,7 +182,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] uint addr = 0; if(!valfromstring(argaddr, &addr)) { - dprintf("invalid addr: \"%s\"\n", argaddr); + dprintf("Invalid addr: \"%s\"\n", argaddr); return STATUS_ERROR; } int type = 0; @@ -206,30 +206,30 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] bpname = argname; if(bpget(addr, BPNORMAL, bpname, 0)) { - dputs("breakpoint already set!"); + dputs("Breakpoint already set!"); return STATUS_CONTINUE; } if(IsBPXEnabled(addr)) { - dprintf("error setting breakpoint at "fhex"! (IsBPXEnabled)\n", addr); + dprintf("Error setting breakpoint at "fhex"! (IsBPXEnabled)\n", addr); return STATUS_ERROR; } else if(!memread(fdProcessInfo->hProcess, (void*)addr, &oldbytes, sizeof(short), 0)) { - dprintf("error setting breakpoint at "fhex"! (memread)\n", addr); + dprintf("Error setting breakpoint at "fhex"! (memread)\n", addr); return STATUS_ERROR; } else if(!bpnew(addr, true, singleshoot, oldbytes, BPNORMAL, type, bpname)) { - dprintf("error setting breakpoint at "fhex"! (bpnew)\n", addr); + dprintf("Error setting breakpoint at "fhex"! (bpnew)\n", addr); return STATUS_ERROR; } else if(!SetBPX(addr, type, (void*)cbUserBreakpoint)) { - dprintf("error setting breakpoint at "fhex"! (SetBPX)\n", addr); + dprintf("Error setting breakpoint at "fhex"! (SetBPX)\n", addr); return STATUS_ERROR; } - dprintf("breakpoint at "fhex" set!\n", addr); + dprintf("Breakpoint at "fhex" set!\n", addr); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -241,12 +241,12 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]) { if(!bpgetcount(BPNORMAL)) { - dputs("no breakpoints to delete!"); + dputs("No breakpoints to delete!"); return STATUS_CONTINUE; } if(!bpenumall(cbDeleteAllBreakpoints)) //at least one deletion failed return STATUS_ERROR; - dputs("all breakpoints deleted!"); + dputs("All breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -255,12 +255,12 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]) { if(!bpdel(found.addr, BPNORMAL)) { - dprintf("delete breakpoint failed (bpdel): "fhex"\n", found.addr); + dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr); return STATUS_ERROR; } else if(found.enabled && !DeleteBPX(found.addr)) { - dprintf("delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr); + dprintf("Delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr); GuiUpdateAllViews(); return STATUS_ERROR; } @@ -269,21 +269,21 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint { - dprintf("no such breakpoint \"%s\"\n", arg1); + dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(!bpdel(found.addr, BPNORMAL)) { - dprintf("delete breakpoint failed (bpdel): "fhex"\n", found.addr); + dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr); return STATUS_ERROR; } else if(found.enabled && !DeleteBPX(found.addr)) { - dprintf("delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr); + dprintf("Delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr); GuiUpdateAllViews(); return STATUS_ERROR; } - dputs("breakpoint deleted!"); + dputs("Breakpoint deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -295,12 +295,12 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) { if(!bpgetcount(BPNORMAL)) { - dputs("no breakpoints to enable!"); + dputs("No breakpoints to enable!"); return STATUS_CONTINUE; } if(!bpenumall(cbEnableAllBreakpoints)) //at least one enable failed return STATUS_ERROR; - dputs("all breakpoints enabled!"); + dputs("All breakpoints enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -309,7 +309,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) { if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) { - dprintf("could not enable breakpoint "fhex"\n", found.addr); + dprintf("Could not enable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } GuiUpdateAllViews(); @@ -318,21 +318,21 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint { - dprintf("no such breakpoint \"%s\"\n", arg1); + dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(found.enabled) { - dputs("breakpoint already enabled!"); + dputs("Breakpoint already enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) { - dprintf("could not enable breakpoint "fhex"\n", found.addr); + dprintf("Could not enable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("breakpoint enabled!"); + dputs("Breakpoint enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -344,12 +344,12 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) { if(!bpgetcount(BPNORMAL)) { - dputs("no breakpoints to disable!"); + dputs("No breakpoints to disable!"); return STATUS_CONTINUE; } if(!bpenumall(cbDisableAllBreakpoints)) //at least one deletion failed return STATUS_ERROR; - dputs("all breakpoints disabled!"); + dputs("All breakpoints disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -358,7 +358,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) { if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) { - dprintf("could not disable breakpoint "fhex"\n", found.addr); + dprintf("Could not disable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } GuiUpdateAllViews(); @@ -367,20 +367,20 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint { - dprintf("no such breakpoint \"%s\"\n", arg1); + dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(!found.enabled) { - dputs("breakpoint already disabled!"); + dputs("Breakpoint already disabled!"); return STATUS_CONTINUE; } if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) { - dprintf("could not disable breakpoint "fhex"\n", found.addr); + dprintf("Could not disable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("breakpoint disabled!"); + dputs("Breakpoint disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -440,9 +440,9 @@ CMDRESULT cbDebugeSingleStep(int argc, char* argv[]) CMDRESULT cbDebugHide(int argc, char* argv[]) { if(HideDebugger(fdProcessInfo->hProcess, UE_HIDE_PEBONLY)) - dputs("debugger hidden"); + dputs("Debugger hidden"); else - dputs("something went wrong"); + dputs("Something went wrong"); return STATUS_CONTINUE; } @@ -495,7 +495,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]) type = UE_MEMORY_EXECUTE; //EXECUTE break; default: - dputs("invalid type (argument ignored)"); + dputs("Invalid type (argument ignored)"); break; } } @@ -506,15 +506,15 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]) singleshoot = true; if(bpget(base, BPMEMORY, 0, 0)) { - dputs("hardware breakpoint already set!"); + dputs("Hardware breakpoint already set!"); return STATUS_CONTINUE; } if(!bpnew(base, true, singleshoot, 0, BPMEMORY, type, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint)) { - dputs("error setting memory breakpoint!"); + dputs("Error setting memory breakpoint!"); return STATUS_ERROR; } - dprintf("memory breakpoint at "fhex" set!\n", addr); + dprintf("Memory breakpoint at "fhex" set!\n", addr); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -531,7 +531,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) } if(!bpenumall(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed return STATUS_ERROR; - dputs("all memory breakpoints deleted!"); + dputs("All memory breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -542,7 +542,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) memfindbaseaddr(found.addr, &size); if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { - dprintf("delete memory breakpoint failed: "fhex"\n", found.addr); + dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; } return STATUS_CONTINUE; @@ -550,17 +550,17 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid breakpoint { - dprintf("no such memory breakpoint \"%s\"\n", arg1); + dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } uint size; memfindbaseaddr(found.addr, &size); if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { - dprintf("delete memory breakpoint failed: "fhex"\n", found.addr); + dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("memory breakpoint deleted!"); + dputs("Memory breakpoint deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -625,19 +625,19 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]) break; #endif // _WIN64 default: - dputs("invalid size, using 1"); + dputs("Invalid size, using 1"); break; } if((addr % size) != 0) { - dprintf("address not aligned to %d\n", size); + dprintf("Address not aligned to %d\n", size); return STATUS_ERROR; } } DWORD drx = 0; if(!GetUnusedHardwareBreakPointRegister(&drx)) { - dputs("you can only set 4 hardware breakpoints"); + dputs("You can only set 4 hardware breakpoints"); return STATUS_ERROR; } int titantype = 0; @@ -647,15 +647,15 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]) //TODO: hwbp in multiple threads TEST if(bpget(addr, BPHARDWARE, 0, 0)) { - dputs("hardware breakpoint already set!"); + dputs("Hardware breakpoint already set!"); return STATUS_CONTINUE; } if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0) or !SetHardwareBreakPoint(addr, drx, type, (DWORD)size, (void*)cbHardwareBreakpoint)) { - dputs("error setting hardware breakpoint!"); + dputs("Error setting hardware breakpoint!"); return STATUS_ERROR; } - dprintf("hardware breakpoint at "fhex" set!\n", addr); + dprintf("Hardware breakpoint at "fhex" set!\n", addr); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -667,12 +667,12 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) { if(!bpgetcount(BPHARDWARE)) { - dputs("no hardware breakpoints to delete!"); + dputs("No hardware breakpoints to delete!"); return STATUS_CONTINUE; } if(!bpenumall(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed return STATUS_ERROR; - dputs("all hardware breakpoints deleted!"); + dputs("All hardware breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -681,7 +681,7 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) { if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { - dprintf("delete hardware breakpoint failed: "fhex"\n", found.addr); + dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; } return STATUS_CONTINUE; @@ -689,15 +689,15 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid breakpoint { - dprintf("no such hardware breakpoint \"%s\"\n", arg1); + dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { - dprintf("delete hardware breakpoint failed: "fhex"\n", found.addr); + dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("hardware breakpoint deleted!"); + dputs("Hardware breakpoint deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -736,7 +736,7 @@ CMDRESULT cbDebugFree(int argc, char* argv[]) } else if(!lastalloc) { - dputs("lastalloc is zero, provide a page address"); + dputs("$lastalloc is zero, provide a page address"); return STATUS_ERROR; } if(addr == lastalloc) @@ -759,7 +759,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[]) uint size; if(argc < 3) { - dputs("not enough arguments"); + dputs("Not enough arguments"); return STATUS_ERROR; } if(!valfromstring(argv[1], &addr, false) or !valfromstring(argv[2], &value, false)) @@ -783,9 +783,9 @@ CMDRESULT cbDebugMemset(int argc, char* argv[]) } BYTE fi = value & 0xFF; if(!Fill((void*)addr, size & 0xFFFFFFFF, &fi)) - dputs("memset failed"); + dputs("Memset failed"); else - dprintf("memory "fhex" (size: %.8X) set to %.2X\n", addr, size & 0xFFFFFFFF, value & 0xFF); + dprintf("Memory "fhex" (size: %.8X) set to %.2X\n", addr, size & 0xFFFFFFFF, value & 0xFF); return STATUS_CONTINUE; } @@ -809,7 +809,7 @@ CMDRESULT cbDebugPause(int argc, char* argv[]) { if(waitislocked(WAITID_RUN)) { - dputs("program is not running"); + dputs("Program is not running"); return STATUS_ERROR; } dbgsetispausedbyuser(true); @@ -824,7 +824,7 @@ static DWORD WINAPI scyllaThread(void* lpParam) HINSTANCE hScylla = LoadLibraryW(L"Scylla.dll"); if(!hScylla) { - dputs("error loading Scylla.dll!"); + dputs("Error loading Scylla.dll!"); bScyllaLoaded = false; FreeLibrary(hScylla); return 0; @@ -832,7 +832,7 @@ static DWORD WINAPI scyllaThread(void* lpParam) ScyllaStartGui = (SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui"); if(!ScyllaStartGui) { - dputs("could not find export 'ScyllaStartGui' inside Scylla.dll"); + dputs("Could not find export 'ScyllaStartGui' inside Scylla.dll"); bScyllaLoaded = false; FreeLibrary(hScylla); return 0; @@ -862,7 +862,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[]) { if(argc < 2) { - dputs("not enough arguments!"); + dputs("Not enough arguments!"); return STATUS_ERROR; } uint pid = 0; @@ -880,7 +880,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[]) Handle hProcess = TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid); if(!hProcess) { - dprintf("could not open process %X!\n", pid); + dprintf("Could not open process %X!\n", pid); return STATUS_ERROR; } BOOL wow64 = false, mewow64 = false; @@ -901,7 +901,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[]) wchar_t wszFileName[MAX_PATH] = L""; if(!GetModuleFileNameExW(hProcess, 0, wszFileName, MAX_PATH)) { - dprintf("could not get module filename %X!\n", pid); + dprintf("Could not get module filename %X!\n", pid); return STATUS_ERROR; } strcpy_s(szFileName, StringUtils::Utf16ToUtf8(wszFileName).c_str()); @@ -928,7 +928,7 @@ CMDRESULT cbDebugDump(int argc, char* argv[]) duint addr = 0; if(!valfromstring(argv[1], &addr)) { - dprintf("invalid address \"%s\"!\n", argv[1]); + dprintf("Invalid address \"%s\"!\n", argv[1]); return STATUS_ERROR; } GuiDumpAt(addr); @@ -942,7 +942,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[]) addr = GetContextDataEx(hActiveThread, UE_CSP); else if(!valfromstring(argv[1], &addr)) { - dprintf("invalid address \"%s\"!\n", argv[1]); + dprintf("Invalid address \"%s\"!\n", argv[1]); return STATUS_ERROR; } duint csp = GetContextDataEx(hActiveThread, UE_CSP); @@ -951,7 +951,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[]) if(base && addr >= base && addr < (base + size)) GuiStackDumpAt(addr, csp); else - dputs("invalid stack address!"); + dputs("Invalid stack address!"); return STATUS_CONTINUE; } @@ -960,12 +960,12 @@ CMDRESULT cbDebugContinue(int argc, char* argv[]) if(argc < 2) { SetNextDbgContinueStatus(DBG_CONTINUE); - dputs("exception will be swallowed"); + dputs("Exception will be swallowed"); } else { SetNextDbgContinueStatus(DBG_EXCEPTION_NOT_HANDLED); - dputs("exception will be thrown in the program"); + dputs("Exception will be thrown in the program"); } return STATUS_CONTINUE; } @@ -994,7 +994,7 @@ CMDRESULT cbDebugBpDll(int argc, char* argv[]) if(argc > 3) singleshoot = false; LibrarianSetBreakPoint(argv[1], type, singleshoot, (void*)cbLibrarianBreakpoint); - dprintf("dll breakpoint set on \"%s\"!\n", argv[1]); + dprintf("Dll breakpoint set on \"%s\"!\n", argv[1]); return STATUS_CONTINUE; } @@ -1002,15 +1002,15 @@ CMDRESULT cbDebugBcDll(int argc, char* argv[]) { if(argc < 2) { - dputs("not enough arguments"); + dputs("Not enough arguments"); return STATUS_ERROR; } if(!LibrarianRemoveBreakPoint(argv[1], UE_ON_LIB_ALL)) { - dputs("failed to remove dll breakpoint..."); + dputs("Failed to remove DLL breakpoint..."); return STATUS_ERROR; } - dputs("dll breakpoint removed!"); + dputs("DLL breakpoint removed!"); return STATUS_CONTINUE; } @@ -1022,13 +1022,13 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[]) return STATUS_ERROR; if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { - dprintf("invalid thread %X\n", threadid); + dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //switch thread hActiveThread = threadgethandle((DWORD)threadid); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); - dputs("thread switched!"); + dputs("Thread switched!"); return STATUS_CONTINUE; } @@ -1040,16 +1040,16 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[]) return STATUS_ERROR; if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { - dprintf("invalid thread %X\n", threadid); + dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //suspend thread if(SuspendThread(threadgethandle((DWORD)threadid)) == -1) { - dputs("error suspending thread"); + dputs("Error suspending thread"); return STATUS_ERROR; } - dputs("thread suspended"); + dputs("Thread suspended"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1062,16 +1062,16 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[]) return STATUS_ERROR; if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { - dprintf("invalid thread %X\n", threadid); + dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //resume thread if(ResumeThread(threadgethandle((DWORD)threadid)) == -1) { - dputs("error resuming thread"); + dputs("Error resuming thread"); return STATUS_ERROR; } - dputs("thread resumed!"); + dputs("Thread resumed!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1088,17 +1088,17 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[]) return STATUS_ERROR; if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { - dprintf("invalid thread %X\n", threadid); + dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //terminate thread if(TerminateThread(threadgethandle((DWORD)threadid), (DWORD)exitcode) != 0) { GuiUpdateAllViews(); - dputs("thread terminated"); + dputs("Thread terminated"); return STATUS_CONTINUE; } - dputs("error terminating thread!"); + dputs("Error terminating thread!"); return STATUS_ERROR; } @@ -1124,7 +1124,7 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[]) { if(argc < 3) { - dputs("not enough arguments!"); + dputs("Not enough arguments!"); return STATUS_ERROR; } uint threadid; @@ -1149,7 +1149,7 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[]) priority = THREAD_PRIORITY_LOWEST; else { - dputs("unknown priority value, read the help!"); + dputs("Unknown priority value, read the help!"); return STATUS_ERROR; } } @@ -1166,22 +1166,22 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[]) case THREAD_PRIORITY_LOWEST: break; default: - dputs("unknown priority value, read the help!"); + dputs("Unknown priority value, read the help!"); return STATUS_ERROR; } } if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { - dprintf("invalid thread %X\n", threadid); + dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //set thread priority if(SetThreadPriority(threadgethandle((DWORD)threadid), (int)priority) == 0) { - dputs("error setting thread priority"); + dputs("Error setting thread priority"); return STATUS_ERROR; } - dputs("thread priority changed!"); + dputs("Thread priority changed!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1192,19 +1192,19 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) DWORD drx = 0; if(!GetUnusedHardwareBreakPointRegister(&drx)) { - dputs("you can only set 4 hardware breakpoints"); + dputs("You can only set 4 hardware breakpoints"); return STATUS_ERROR; } if(!argget(*argv, arg1, 0, true)) //enable all hardware breakpoints { if(!bpgetcount(BPHARDWARE)) { - dputs("no hardware breakpoints to enable!"); + dputs("No hardware breakpoints to enable!"); return STATUS_CONTINUE; } if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed return STATUS_ERROR; - dputs("all hardware breakpoints enabled!"); + dputs("All hardware breakpoints enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1212,12 +1212,12 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint { - dprintf("no such hardware breakpoint \"%s\"\n", arg1); + dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(found.enabled) { - dputs("hardware breakpoint already enabled!"); + dputs("Hardware breakpoint already enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1225,10 +1225,10 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) bpsettitantype(found.addr, BPHARDWARE, found.titantype); if(!bpenable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint)) { - dprintf("could not enable hardware breakpoint "fhex"\n", found.addr); + dprintf("Could not enable hardware breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("hardware breakpoint enabled!"); + dputs("Hardware breakpoint enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1240,12 +1240,12 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) { if(!bpgetcount(BPHARDWARE)) { - dputs("no hardware breakpoints to disable!"); + dputs("No hardware breakpoints to disable!"); return STATUS_CONTINUE; } if(!bpenumall(cbDisableAllHardwareBreakpoints)) //at least one deletion failed return STATUS_ERROR; - dputs("all hardware breakpoints disabled!"); + dputs("All hardware breakpoints disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1253,20 +1253,20 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint { - dprintf("no such hardware breakpoint \"%s\"\n", arg1); + dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(!found.enabled) { - dputs("hardware breakpoint already disabled!"); + dputs("Hardware breakpoint already disabled!"); return STATUS_CONTINUE; } if(!bpenable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { - dprintf("could not disable hardware breakpoint "fhex"\n", found.addr); + dprintf("Could not disable hardware breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("hardware breakpoint disabled!"); + dputs("Hardware breakpoint disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1277,19 +1277,19 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) DWORD drx = 0; if(!GetUnusedHardwareBreakPointRegister(0)) { - dputs("you can only set 4 hardware breakpoints"); + dputs("You can only set 4 hardware breakpoints"); return STATUS_ERROR; } if(!argget(*argv, arg1, 0, true)) //enable all memory breakpoints { if(!bpgetcount(BPMEMORY)) { - dputs("no hardware breakpoints to enable!"); + dputs("No hardware breakpoints to enable!"); return STATUS_CONTINUE; } if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed return STATUS_ERROR; - dputs("all memory breakpoints enabled!"); + dputs("All memory breakpoints enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1297,12 +1297,12 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint { - dprintf("no such memory breakpoint \"%s\"\n", arg1); + dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(found.enabled) { - dputs("hardware memory already enabled!"); + dputs("Hardware memory already enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1310,10 +1310,10 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) memfindbaseaddr(found.addr, &size); if(!bpenable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint)) { - dprintf("could not enable memory breakpoint "fhex"\n", found.addr); + dprintf("Could not enable memory breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("memory breakpoint enabled!"); + dputs("Memory breakpoint enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1325,12 +1325,12 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) { if(!bpgetcount(BPMEMORY)) { - dputs("no memory breakpoints to disable!"); + dputs("No memory breakpoints to disable!"); return STATUS_CONTINUE; } if(!bpenumall(cbDisableAllMemoryBreakpoints)) //at least one deletion failed return STATUS_ERROR; - dputs("all memory breakpoints disabled!"); + dputs("All memory breakpoints disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1338,22 +1338,22 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) uint addr = 0; if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint { - dprintf("no such memory breakpoint \"%s\"\n", arg1); + dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } if(!found.enabled) { - dputs("memory breakpoint already disabled!"); + dputs("Memory breakpoint already disabled!"); return STATUS_CONTINUE; } uint size = 0; memfindbaseaddr(found.addr, &size); if(!bpenable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size)) { - dprintf("could not disable memory breakpoint "fhex"\n", found.addr); + dprintf("Could not disable memory breakpoint "fhex"\n", found.addr); return STATUS_ERROR; } - dputs("memory breakpoint disabled!"); + dputs("Memory breakpoint disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1371,14 +1371,14 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) { symdownloadallsymbols(szSymbolStore); //download symbols for all modules GuiSymbolRefreshCurrent(); - dputs("done! See symbol log for more information"); + dputs("Done! See symbol log for more information"); return STATUS_CONTINUE; } //get some module information uint modbase = modbasefromname(argv[1]); if(!modbase) { - dprintf("invalid module \"%s\"!\n", argv[1]); + dprintf("Invalid module \"%s\"!\n", argv[1]); return STATUS_ERROR; } wchar_t wszModulePath[MAX_PATH] = L""; @@ -1422,7 +1422,7 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) return STATUS_ERROR; } GuiSymbolRefreshCurrent(); - dputs("done! See symbol log for more information"); + dputs("Done! See symbol log for more information"); return STATUS_CONTINUE; } @@ -1549,7 +1549,6 @@ CMDRESULT cbDebugSetJITAuto(int argc, char* argv[]) return STATUS_CONTINUE; } - CMDRESULT cbDebugSetJIT(int argc, char* argv[]) { arch actual_arch = invalid; From af790b5cc92d066e6931e0e42a917d368c243304 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sat, 3 Jan 2015 20:44:27 +0100 Subject: [PATCH 011/106] DBG: allow assembling "jmp short 401000" (short is simply ignored now) --- x64_dbg_dbg/assemble.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x64_dbg_dbg/assemble.cpp b/x64_dbg_dbg/assemble.cpp index bebd141c..3250447d 100644 --- a/x64_dbg_dbg/assemble.cpp +++ b/x64_dbg_dbg/assemble.cpp @@ -30,7 +30,11 @@ bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction #endif parse.cbUnknown = cbUnknown; parse.cip = addr; - strcpy(parse.instr, instruction); + String instr = instruction; + size_t pos = instr.find(" short "); + if(pos != String::npos) + instr.erase(pos, 6); + strcpy(parse.instr, instr.c_str()); if(XEDParseAssemble(&parse) == XEDPARSE_ERROR) { if(error) From 3a15a26a6e31b4f2e460507adb61762a4195fdad Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sat, 3 Jan 2015 20:44:54 +0100 Subject: [PATCH 012/106] DBG: hardware breakpoints working again --- x64_dbg_dbg/debugger_commands.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 5310259d..a9f7a6e0 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -606,25 +606,30 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]) } } char arg3[deflen] = ""; //size - uint size = UE_HARDWARE_SIZE_1; + DWORD titsize; if(argget(*argv, arg3, 2, true)) { + uint size; if(!valfromstring(arg3, &size)) return STATUS_ERROR; switch(size) { + case 1: + titsize = UE_HARDWARE_SIZE_1; + break; case 2: - size = UE_HARDWARE_SIZE_2; + titsize = UE_HARDWARE_SIZE_2; break; case 4: - size = UE_HARDWARE_SIZE_4; + titsize = UE_HARDWARE_SIZE_4; break; #ifdef _WIN64 case 8: - size = UE_HARDWARE_SIZE_8; + titsize = UE_HARDWARE_SIZE_8; break; #endif // _WIN64 default: + titsize = UE_HARDWARE_SIZE_1; dputs("Invalid size, using 1"); break; } @@ -643,16 +648,21 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]) int titantype = 0; TITANSETDRX(titantype, drx); TITANSETTYPE(titantype, type); - TITANSETSIZE(titantype, size); + TITANSETSIZE(titantype, titsize); //TODO: hwbp in multiple threads TEST if(bpget(addr, BPHARDWARE, 0, 0)) { dputs("Hardware breakpoint already set!"); return STATUS_CONTINUE; } - if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0) or !SetHardwareBreakPoint(addr, drx, type, (DWORD)size, (void*)cbHardwareBreakpoint)) + if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0)) { - dputs("Error setting hardware breakpoint!"); + dputs("error setting hardware breakpoint (bpnew)!"); + return STATUS_ERROR; + } + if(!SetHardwareBreakPoint(addr, drx, type, titsize, (void*)cbHardwareBreakpoint)) + { + dputs("error setting hardware breakpoint (TitanEngine)!"); return STATUS_ERROR; } dprintf("Hardware breakpoint at "fhex" set!\n", addr); From 93977457f92b79d96676c9b78f11a6ff5a2debf0 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 4 Jan 2015 19:51:04 +0100 Subject: [PATCH 013/106] GUI: better menu code --- x64_dbg_gui/Project/Src/Bridge/Bridge.cpp | 5 + x64_dbg_gui/Project/Src/Bridge/Bridge.h | 4 + x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 129 ++++++++++++--------- x64_dbg_gui/Project/Src/Gui/MainWindow.h | 13 +++ 4 files changed, 96 insertions(+), 55 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp index 0a30219c..f85ee53e 100644 --- a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp +++ b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp @@ -238,6 +238,11 @@ void Bridge::emitSetLastException(unsigned int exceptionCode) emit setLastException(exceptionCode); } +void Bridge::emitMenuAddToList(QWidget* parent, QMenu* menu, int hMenu, int hParentMenu) +{ + emit menuAddMenuToList(parent, menu, hMenu, hParentMenu); +} + int Bridge::emitMenuAddMenu(int hMenu, QString title) { mBridgeMutex->lock(); diff --git a/x64_dbg_gui/Project/Src/Bridge/Bridge.h b/x64_dbg_gui/Project/Src/Bridge/Bridge.h index 33b56e2f..13752ee7 100644 --- a/x64_dbg_gui/Project/Src/Bridge/Bridge.h +++ b/x64_dbg_gui/Project/Src/Bridge/Bridge.h @@ -60,10 +60,12 @@ public: void emitUpdateMemory(); void emitAddRecentFile(QString file); void emitSetLastException(unsigned int exceptionCode); + void emitMenuAddToList(QWidget* parent, QMenu* menu, int hMenu, int hParentMenu = -1); int emitMenuAddMenu(int hMenu, QString title); int emitMenuAddMenuEntry(int hMenu, QString title); void emitMenuAddSeparator(int hMenu); void emitMenuClearMenu(int hMenu); + void emitMenuRemoveEntry(int hEntry); bool emitSelectionGet(int hWindow, SELECTIONDATA* selection); bool emitSelectionSet(int hWindow, const SELECTIONDATA* selection); bool emitGetStrWindow(const QString title, QString* text); @@ -119,10 +121,12 @@ signals: void updateMemory(); void addRecentFile(QString file); void setLastException(unsigned int exceptionCode); + void menuAddMenuToList(QWidget* parent, QMenu* menu, int hMenu, int hParentMenu); void menuAddMenu(int hMenu, QString title); void menuAddMenuEntry(int hMenu, QString title); void menuAddSeparator(int hMenu); void menuClearMenu(int hMenu); + void menuRemoveMenuEntry(int hEntry); void selectionDisasmGet(SELECTIONDATA* selection); void selectionDisasmSet(const SELECTIONDATA* selection); void selectionDumpGet(SELECTIONDATA* selection); diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 00d9b4a5..1c7b4770 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -17,6 +17,22 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi { ui->setupUi(this); + //setup bridge signals + connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString))); + connect(Bridge::getBridge(), SIGNAL(addRecentFile(QString)), this, SLOT(addRecentFile(QString))); + connect(Bridge::getBridge(), SIGNAL(setLastException(uint)), this, SLOT(setLastException(uint))); + connect(Bridge::getBridge(), SIGNAL(menuAddMenuToList(QWidget*, QMenu*, int, int)), this, SLOT(addMenuToList(QWidget*, QMenu*, int, int))); + connect(Bridge::getBridge(), SIGNAL(menuAddMenu(int, QString)), this, SLOT(addMenu(int, QString))); + connect(Bridge::getBridge(), SIGNAL(menuAddMenuEntry(int, QString)), this, SLOT(addMenuEntry(int, QString))); + connect(Bridge::getBridge(), SIGNAL(menuAddSeparator(int)), this, SLOT(addSeparator(int))); + connect(Bridge::getBridge(), SIGNAL(menuClearMenu(int)), this, SLOT(clearMenu(int))); + connect(Bridge::getBridge(), SIGNAL(menuRemoveMenuEntry(int)), this, SLOT(removeMenuEntry(int))); + connect(Bridge::getBridge(), SIGNAL(getStrWindow(QString, QString*)), this, SLOT(getStrWindow(QString, QString*))); + + //setup menu api + initMenuApi(); + addMenuToList(this, ui->menuPlugins, GUI_PLUGIN_MENU); + this->showMaximized(); #ifdef _WIN64 @@ -173,18 +189,10 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi connect(ui->actionDetach, SIGNAL(triggered()), this, SLOT(detach())); connect(ui->actionChangeCommandLine, SIGNAL(triggered()), this, SLOT(changeCommandLine())); - connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString))); - connect(Bridge::getBridge(), SIGNAL(addRecentFile(QString)), this, SLOT(addRecentFile(QString))); - connect(Bridge::getBridge(), SIGNAL(setLastException(uint)), this, SLOT(setLastException(uint))); - connect(Bridge::getBridge(), SIGNAL(menuAddMenu(int, QString)), this, SLOT(addMenu(int, QString))); - connect(Bridge::getBridge(), SIGNAL(menuAddMenuEntry(int, QString)), this, SLOT(addMenuEntry(int, QString))); - connect(Bridge::getBridge(), SIGNAL(menuAddSeparator(int)), this, SLOT(addSeparator(int))); - connect(Bridge::getBridge(), SIGNAL(menuClearMenu(int)), this, SLOT(clearMenu(int))); connect(mCpuWidget->mDisas, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget())); connect(mCpuWidget->mDisas, SIGNAL(showPatches()), this, SLOT(patchWindow())); connect(mCpuWidget->mDump, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget())); connect(mCpuWidget->mStack, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget())); - connect(Bridge::getBridge(), SIGNAL(getStrWindow(QString, QString*)), this, SLOT(getStrWindow(QString, QString*))); connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcuts())); //Set default setttings (when not set) @@ -195,9 +203,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi //Create updatechecker mUpdateChecker = new UpdateChecker(this); - //setup menu api - initMenuApi(); - refreshShortcuts(); bClose = false; @@ -706,8 +711,10 @@ void MainWindow::findModularCalls() displayReferencesWidget(); } -void MainWindow::addMenu(int hMenu, QString title) +const MainWindow::MenuInfo* MainWindow::findMenu(int hMenu) { + if(hMenu == -1) + return 0; int nFound = -1; for(int i = 0; i < mMenuList.size(); i++) { @@ -717,77 +724,73 @@ void MainWindow::addMenu(int hMenu, QString title) break; } } - if(nFound == -1 && hMenu != -1) + return nFound == -1 ? 0 : &mMenuList.at(nFound); +} + +void MainWindow::addMenuToList(QWidget* parent, QMenu* menu, int hMenu, int hParentMenu) +{ + if(!findMenu(hMenu)) + mMenuList.push_back(MenuInfo(parent, menu, hMenu, hParentMenu)); +} + +void MainWindow::addMenu(int hMenu, QString title) +{ + const MenuInfo* menu = findMenu(hMenu); + if(!menu && hMenu != -1) { Bridge::getBridge()->BridgeSetResult(-1); return; } - MenuInfo newInfo; - int hMenuNew = hMenuNext; - hMenuNext++; - QMenu* wMenu = new QMenu(title, this); - newInfo.mMenu = wMenu; - newInfo.hMenu = hMenuNew; - newInfo.hParentMenu = hMenu; - mMenuList.push_back(newInfo); + int hMenuNew = hMenuNext++; + QWidget* parent = hMenu == -1 ? this : menu->parent; + QMenu* wMenu = new QMenu(title, parent); + wMenu->menuAction()->setVisible(false); + mMenuList.push_back(MenuInfo(parent, wMenu, hMenuNew, hMenu)); if(hMenu == -1) //top-level ui->menuBar->addMenu(wMenu); else //deeper level - mMenuList.at(nFound).mMenu->addMenu(wMenu); + menu->mMenu->addMenu(wMenu); Bridge::getBridge()->BridgeSetResult(hMenuNew); } void MainWindow::addMenuEntry(int hMenu, QString title) { - int nFound = -1; - for(int i = 0; i < mMenuList.size(); i++) - { - if(hMenu == mMenuList.at(i).hMenu) - { - nFound = i; - break; - } - } - if(nFound == -1 && hMenu != -1) + const MenuInfo* menu = findMenu(hMenu); + if(!menu && hMenu != -1) { Bridge::getBridge()->BridgeSetResult(-1); return; } MenuEntryInfo newInfo; - int hEntryNew = hEntryNext; - hEntryNext++; + int hEntryNew = hEntryNext++; newInfo.hEntry = hEntryNew; newInfo.hParentMenu = hMenu; - QAction* wAction = new QAction(title, this); + QWidget* parent = hMenu == -1 ? this : menu->parent; + QAction* wAction = new QAction(title, parent); wAction->setObjectName(QString().sprintf("ENTRY|%d", hEntryNew)); - this->addAction(wAction); + parent->addAction(wAction); connect(wAction, SIGNAL(triggered()), this, SLOT(menuEntrySlot())); newInfo.mAction = wAction; mEntryList.push_back(newInfo); if(hMenu == -1) //top level ui->menuBar->addAction(wAction); else //deeper level - mMenuList.at(nFound).mMenu->addAction(wAction); + { + menu->mMenu->addAction(wAction); + menu->mMenu->menuAction()->setVisible(true); + } Bridge::getBridge()->BridgeSetResult(hEntryNew); } void MainWindow::addSeparator(int hMenu) { - int nFound = -1; - for(int i = 0; i < mMenuList.size(); i++) - { - if(hMenu == mMenuList.at(i).hMenu) //we found a menu that has the menu as parent - { - nFound = i; - break; - } - } - if(nFound == -1) //not found + const MenuInfo* menu = findMenu(hMenu); + if(!menu) return; MenuEntryInfo newInfo; newInfo.hEntry = -1; newInfo.hParentMenu = hMenu; - newInfo.mAction = mMenuList.at(nFound).mMenu->addSeparator(); + newInfo.mAction = menu->mMenu->addSeparator(); mEntryList.push_back(newInfo); } @@ -795,12 +798,14 @@ void MainWindow::clearMenu(int hMenu) { if(!mMenuList.size() || hMenu == -1) return; + const MenuInfo* menu = findMenu(hMenu); //delete menu entries for(int i = mEntryList.size() - 1; i > -1; i--) { if(hMenu == mEntryList.at(i).hParentMenu) //we found an entry that has the menu as parent { - this->removeAction(mEntryList.at(i).mAction); + QWidget* parent = menu == 0 ? this : menu->parent; + parent->removeAction(mEntryList.at(i).mAction); delete mEntryList.at(i).mAction; //delete the entry object mEntryList.erase(mEntryList.begin() + i); } @@ -815,6 +820,9 @@ void MainWindow::clearMenu(int hMenu) mMenuList.erase(mMenuList.begin() + i); //delete the child entry } } + //hide the empty menu + if(menu) + menu->mMenu->menuAction()->setVisible(false); } void MainWindow::initMenuApi() @@ -824,12 +832,6 @@ void MainWindow::initMenuApi() hEntryNext = 256; mMenuList.clear(); hMenuNext = 256; - MenuInfo newInfo; - //add plugin menu - newInfo.mMenu = ui->menuPlugins; - newInfo.hMenu = GUI_PLUGIN_MENU; - newInfo.hParentMenu = -1; - mMenuList.push_back(newInfo); } void MainWindow::menuEntrySlot() @@ -843,6 +845,23 @@ void MainWindow::menuEntrySlot() } } +void MainWindow::removeMenuEntry(int hEntry) +{ + for(int i = 0; i < mEntryList.size(); i++) + { + if(mEntryList.at(i).hEntry == hEntry) + { + const MenuEntryInfo & entry = mEntryList.at(i); + const MenuInfo* menu = findMenu(entry.hParentMenu); + QWidget* parent = menu == 0 ? this : menu->parent; + parent->removeAction(entry.mAction); + delete entry.mAction; + mEntryList.erase(mEntryList.begin() + i); + break; + } + } +} + void MainWindow::runSelection() { if(!DbgIsDebugging()) diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.h b/x64_dbg_gui/Project/Src/Gui/MainWindow.h index 75e33498..a73b5059 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.h +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.h @@ -71,11 +71,13 @@ public slots: void setLastException(unsigned int exceptionCode); void findStrings(); void findModularCalls(); + void addMenuToList(QWidget* parent, QMenu* menu, int hMenu, int hParentMenu = -1); void addMenu(int hMenu, QString title); void addMenuEntry(int hMenu, QString title); void addSeparator(int hMenu); void clearMenu(int hMenu); void menuEntrySlot(); + void removeMenuEntry(int hEntry); void runSelection(); void getStrWindow(const QString title, QString* text); void patchWindow(); @@ -137,6 +139,16 @@ private: struct MenuInfo { + public: + MenuInfo(QWidget* parent, QMenu* mMenu, int hMenu, int hParentMenu) + { + this->parent = parent; + this->mMenu = mMenu; + this->hMenu = hMenu; + this->hParentMenu = hParentMenu; + } + + QWidget* parent; QMenu* mMenu; int hMenu; int hParentMenu; @@ -148,6 +160,7 @@ private: int hMenuNext; void initMenuApi(); + const MenuInfo* findMenu(int hMenu); protected: void dragEnterEvent(QDragEnterEvent* pEvent); From 6f46bd5569c1af839c1a25d04871ec5e6d94bbf8 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 4 Jan 2015 19:51:29 +0100 Subject: [PATCH 014/106] DBG: added STATUS_INVALID_EXCEPTION_HANDLER to the exception names --- x64_dbg_dbg/debugger.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 1febebdf..42c3407b 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -117,6 +117,7 @@ void dbginit() exceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); exceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); exceptionNames.insert(std::make_pair(MS_VC_EXCEPTION, "MS_VC_EXCEPTION")); + exceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); CloseHandle(CreateThread(0, 0, memMapThread, 0, 0, 0)); } From 7b726e6e292a3e37631f9ba4402f1973a980cecd Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 4 Jan 2015 20:33:11 +0100 Subject: [PATCH 015/106] GUI: BridgeResult class to handle results of signals --- x64_dbg_gui/Project/Src/Bridge/Bridge.cpp | 75 +++++++------------ x64_dbg_gui/Project/Src/Bridge/Bridge.h | 8 +- .../Project/Src/Bridge/BridgeResult.cpp | 20 +++++ x64_dbg_gui/Project/Src/Bridge/BridgeResult.h | 14 ++++ .../Project/Src/Gui/CPUDisassembly.cpp | 6 +- x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 6 +- x64_dbg_gui/Project/Src/Gui/CPUStack.cpp | 6 +- x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 32 +++++--- .../Project/Src/Gui/ReferenceManager.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/ScriptView.cpp | 10 ++- x64_dbg_gui/Project/x64_dbg.pro | 6 +- 11 files changed, 107 insertions(+), 78 deletions(-) create mode 100644 x64_dbg_gui/Project/Src/Bridge/BridgeResult.cpp create mode 100644 x64_dbg_gui/Project/Src/Bridge/BridgeResult.h diff --git a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp index f85ee53e..ee8702eb 100644 --- a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp +++ b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp @@ -33,7 +33,7 @@ void Bridge::CopyToClipboard(const QString & text) clipboard->setText(text); } -void Bridge::BridgeSetResult(int_t result) +void Bridge::setResult(int_t result) { bridgeResult = result; hasBridgeResult = true; @@ -89,12 +89,9 @@ void Bridge::emitDumpAt(int_t va) void Bridge::emitScriptAdd(int count, const char** lines) { - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; emit scriptAdd(count, lines); - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); + result.Wait(); } void Bridge::emitScriptClear() @@ -109,7 +106,9 @@ void Bridge::emitScriptSetIp(int line) void Bridge::emitScriptError(int line, QString message) { + BridgeResult result; emit scriptError(line, message); + result.Wait(); } void Bridge::emitScriptSetTitle(QString title) @@ -124,18 +123,16 @@ void Bridge::emitScriptSetInfoLine(int line, QString info) void Bridge::emitScriptMessage(QString message) { + BridgeResult result; emit scriptMessage(message); + result.Wait(); } int Bridge::emitScriptQuestion(QString message) { - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; emit scriptQuestion(message); - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); - return bridgeResult; + return result.Wait(); } void Bridge::emitScriptEnableHighlighting(bool enable) @@ -200,12 +197,9 @@ void Bridge::emitReferenceSetSearchStartCol(int col) void Bridge::emitReferenceInitialize(QString name) { - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; emit referenceInitialize(name); - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); + result.Wait(); } void Bridge::emitStackDumpAt(uint_t va, uint_t csp) @@ -240,39 +234,37 @@ void Bridge::emitSetLastException(unsigned int exceptionCode) void Bridge::emitMenuAddToList(QWidget* parent, QMenu* menu, int hMenu, int hParentMenu) { + BridgeResult result; emit menuAddMenuToList(parent, menu, hMenu, hParentMenu); + result.Wait(); } int Bridge::emitMenuAddMenu(int hMenu, QString title) { - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; emit menuAddMenu(hMenu, title); - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); - return bridgeResult; + return result.Wait(); } int Bridge::emitMenuAddMenuEntry(int hMenu, QString title) { - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; emit menuAddMenuEntry(hMenu, title); - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); - return bridgeResult; + return result.Wait(); } void Bridge::emitMenuAddSeparator(int hMenu) { + BridgeResult result; emit menuAddSeparator(hMenu); + result.Wait(); } void Bridge::emitMenuClearMenu(int hMenu) { + BridgeResult result; emit menuClearMenu(hMenu); + result.Wait(); } void Bridge::emitAddMsgToStatusBar(QString msg) @@ -284,8 +276,7 @@ bool Bridge::emitSelectionGet(int hWindow, SELECTIONDATA* selection) { if(!DbgIsDebugging()) return false; - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; switch(hWindow) { case GUI_DISASSEMBLY: @@ -298,12 +289,9 @@ bool Bridge::emitSelectionGet(int hWindow, SELECTIONDATA* selection) emit selectionStackGet(selection); break; default: - mBridgeMutex->unlock(); return false; } - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); + result.Wait(); if(selection->start > selection->end) //swap start and end { int_t temp = selection->end; @@ -317,8 +305,7 @@ bool Bridge::emitSelectionSet(int hWindow, const SELECTIONDATA* selection) { if(!DbgIsDebugging()) return false; - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; switch(hWindow) { case GUI_DISASSEMBLY: @@ -331,24 +318,16 @@ bool Bridge::emitSelectionSet(int hWindow, const SELECTIONDATA* selection) emit selectionStackSet(selection); break; default: - mBridgeMutex->unlock(); return false; } - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); - return bridgeResult; + return result.Wait(); } bool Bridge::emitGetStrWindow(const QString title, QString* text) { - mBridgeMutex->lock(); - hasBridgeResult = false; + BridgeResult result; emit getStrWindow(title, text); - while(!hasBridgeResult) //wait for thread completion - Sleep(100); - mBridgeMutex->unlock(); - return bridgeResult; + return result.Wait(); } void Bridge::emitAutoCompleteAddCmd(const QString cmd) diff --git a/x64_dbg_gui/Project/Src/Bridge/Bridge.h b/x64_dbg_gui/Project/Src/Bridge/Bridge.h index 13752ee7..eb6c39dc 100644 --- a/x64_dbg_gui/Project/Src/Bridge/Bridge.h +++ b/x64_dbg_gui/Project/Src/Bridge/Bridge.h @@ -6,10 +6,14 @@ #include "Imports.h" #include "NewTypes.h" #include "ReferenceManager.h" +#include "BridgeResult.h" class Bridge : public QObject { Q_OBJECT + + friend class BridgeResult; + public: explicit Bridge(QObject* parent = 0); ~Bridge(); @@ -21,7 +25,7 @@ public: static void CopyToClipboard(const QString & text); //result function - void BridgeSetResult(int_t result); + void setResult(int_t result = 0); // Exports Binding void emitDisassembleAtSignal(int_t va, int_t eip); @@ -147,7 +151,7 @@ signals: private: QMutex* mBridgeMutex; int_t bridgeResult; - bool hasBridgeResult; + volatile bool hasBridgeResult; public: diff --git a/x64_dbg_gui/Project/Src/Bridge/BridgeResult.cpp b/x64_dbg_gui/Project/Src/Bridge/BridgeResult.cpp new file mode 100644 index 00000000..77ad3655 --- /dev/null +++ b/x64_dbg_gui/Project/Src/Bridge/BridgeResult.cpp @@ -0,0 +1,20 @@ +#include "BridgeResult.h" +#include "Bridge.h" + +BridgeResult::BridgeResult() +{ + Bridge::getBridge()->mBridgeMutex->lock(); + Bridge::getBridge()->hasBridgeResult = false; +} + +BridgeResult::~BridgeResult() +{ + Bridge::getBridge()->mBridgeMutex->unlock(); +} + +int_t BridgeResult::Wait() +{ + while(!Bridge::getBridge()->hasBridgeResult) //wait for thread completion + Sleep(100); + return Bridge::getBridge()->bridgeResult; +} diff --git a/x64_dbg_gui/Project/Src/Bridge/BridgeResult.h b/x64_dbg_gui/Project/Src/Bridge/BridgeResult.h new file mode 100644 index 00000000..9499a759 --- /dev/null +++ b/x64_dbg_gui/Project/Src/Bridge/BridgeResult.h @@ -0,0 +1,14 @@ +#ifndef BRIDGERESULT_H +#define BRIDGERESULT_H + +#include "NewTypes.h" + +class BridgeResult +{ +public: + BridgeResult(); + ~BridgeResult(); + int_t Wait(); +}; + +#endif // BRIDGERESULT_H diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp index 2503a4d2..01fca735 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp @@ -992,7 +992,7 @@ void CPUDisassembly::selectionGet(SELECTIONDATA* selection) { selection->start = rvaToVa(getSelectionStart()); selection->end = rvaToVa(getSelectionEnd()); - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void CPUDisassembly::selectionSet(const SELECTIONDATA* selection) @@ -1003,13 +1003,13 @@ void CPUDisassembly::selectionSet(const SELECTIONDATA* selection) int_t end = selection->end; if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range { - Bridge::getBridge()->BridgeSetResult(0); + Bridge::getBridge()->setResult(0); return; } setSingleSelection(start - selMin); expandSelectionUpTo(end - selMin); reloadData(); - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void CPUDisassembly::enableHighlightingMode() diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index 8acaa507..ebb20b0d 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -1057,7 +1057,7 @@ void CPUDump::selectionGet(SELECTIONDATA* selection) { selection->start = rvaToVa(getSelectionStart()); selection->end = rvaToVa(getSelectionEnd()); - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void CPUDump::selectionSet(const SELECTIONDATA* selection) @@ -1068,13 +1068,13 @@ void CPUDump::selectionSet(const SELECTIONDATA* selection) int_t end = selection->end; if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range { - Bridge::getBridge()->BridgeSetResult(0); + Bridge::getBridge()->setResult(0); return; } setSingleSelection(start - selMin); expandSelectionUpTo(end - selMin); reloadData(); - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void CPUDump::memoryAccessSingleshootSlot() diff --git a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp index c49475a2..2fa0795e 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp @@ -413,7 +413,7 @@ void CPUStack::selectionGet(SELECTIONDATA* selection) { selection->start = rvaToVa(getSelectionStart()); selection->end = rvaToVa(getSelectionEnd()); - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void CPUStack::selectionSet(const SELECTIONDATA* selection) @@ -424,13 +424,13 @@ void CPUStack::selectionSet(const SELECTIONDATA* selection) int_t end = selection->end; if(start < selMin || start >= selMax || end < selMin || end >= selMax) //selection out of range { - Bridge::getBridge()->BridgeSetResult(0); + Bridge::getBridge()->setResult(0); return; } setSingleSelection(start - selMin); expandSelectionUpTo(end - selMin); reloadData(); - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void CPUStack::followDisasmSlot() diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 1c7b4770..382a2e4d 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -731,6 +731,7 @@ void MainWindow::addMenuToList(QWidget* parent, QMenu* menu, int hMenu, int hPar { if(!findMenu(hMenu)) mMenuList.push_back(MenuInfo(parent, menu, hMenu, hParentMenu)); + Bridge::getBridge()->setResult(); } void MainWindow::addMenu(int hMenu, QString title) @@ -738,7 +739,7 @@ void MainWindow::addMenu(int hMenu, QString title) const MenuInfo* menu = findMenu(hMenu); if(!menu && hMenu != -1) { - Bridge::getBridge()->BridgeSetResult(-1); + Bridge::getBridge()->setResult(-1); return; } int hMenuNew = hMenuNext++; @@ -750,7 +751,7 @@ void MainWindow::addMenu(int hMenu, QString title) ui->menuBar->addMenu(wMenu); else //deeper level menu->mMenu->addMenu(wMenu); - Bridge::getBridge()->BridgeSetResult(hMenuNew); + Bridge::getBridge()->setResult(hMenuNew); } void MainWindow::addMenuEntry(int hMenu, QString title) @@ -758,7 +759,7 @@ void MainWindow::addMenuEntry(int hMenu, QString title) const MenuInfo* menu = findMenu(hMenu); if(!menu && hMenu != -1) { - Bridge::getBridge()->BridgeSetResult(-1); + Bridge::getBridge()->setResult(-1); return; } MenuEntryInfo newInfo; @@ -779,25 +780,30 @@ void MainWindow::addMenuEntry(int hMenu, QString title) menu->mMenu->addAction(wAction); menu->mMenu->menuAction()->setVisible(true); } - Bridge::getBridge()->BridgeSetResult(hEntryNew); + Bridge::getBridge()->setResult(hEntryNew); } void MainWindow::addSeparator(int hMenu) { const MenuInfo* menu = findMenu(hMenu); - if(!menu) - return; - MenuEntryInfo newInfo; - newInfo.hEntry = -1; - newInfo.hParentMenu = hMenu; - newInfo.mAction = menu->mMenu->addSeparator(); - mEntryList.push_back(newInfo); + if(menu) + { + MenuEntryInfo newInfo; + newInfo.hEntry = -1; + newInfo.hParentMenu = hMenu; + newInfo.mAction = menu->mMenu->addSeparator(); + mEntryList.push_back(newInfo); + } + Bridge::getBridge()->setResult(); } void MainWindow::clearMenu(int hMenu) { if(!mMenuList.size() || hMenu == -1) + { + Bridge::getBridge()->setResult(); return; + } const MenuInfo* menu = findMenu(hMenu); //delete menu entries for(int i = mEntryList.size() - 1; i > -1; i--) @@ -823,6 +829,7 @@ void MainWindow::clearMenu(int hMenu) //hide the empty menu if(menu) menu->mMenu->menuAction()->setVisible(false); + Bridge::getBridge()->setResult(); } void MainWindow::initMenuApi() @@ -860,6 +867,7 @@ void MainWindow::removeMenuEntry(int hEntry) break; } } + Bridge::getBridge()->setResult(); } void MainWindow::runSelection() @@ -879,7 +887,7 @@ void MainWindow::getStrWindow(const QString title, QString* text) if(mLineEdit.exec() != QDialog::Accepted) bResult = false; *text = mLineEdit.editText; - Bridge::getBridge()->BridgeSetResult(bResult); + Bridge::getBridge()->setResult(bResult); } void MainWindow::patchWindow() diff --git a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp index 2ea62a8e..cf3be367 100644 --- a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp @@ -23,7 +23,7 @@ void ReferenceManager::newReferenceView(QString name) connect(mCurrentReferenceView, SIGNAL(showCpu()), this, SIGNAL(showCpu())); insertTab(0, mCurrentReferenceView, name); setCurrentIndex(0); - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void ReferenceManager::closeTab(int index) diff --git a/x64_dbg_gui/Project/Src/Gui/ScriptView.cpp b/x64_dbg_gui/Project/Src/Gui/ScriptView.cpp index 19cb1423..4ee7adf5 100644 --- a/x64_dbg_gui/Project/Src/Gui/ScriptView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ScriptView.cpp @@ -73,7 +73,7 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset else if(DbgScriptBpGet(line)) //breakpoint { painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyBreakpointBackgroundColor"))); - painter->setPen(QPen(ConfigColor("DisassemblyBreakpointBackgroundColor"))); //black address //ScripViewMainBpTextColor + painter->setPen(QPen(ConfigColor("DisassemblyBreakpointColor"))); //black address //ScripViewMainBpTextColor } else { @@ -434,7 +434,7 @@ void ScriptView::add(int count, const char** lines) setCellContent(i, 1, QString(lines[i])); BridgeFree(lines); reloadData(); //repaint - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); } void ScriptView::clear() @@ -490,6 +490,7 @@ void ScriptView::error(int line, QString message) msg.setParent(this, Qt::Dialog); msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint)); msg.exec(); + Bridge::getBridge()->setResult(); } void ScriptView::setTitle(QString title) @@ -582,6 +583,7 @@ void ScriptView::message(QString message) msg.setParent(this, Qt::Dialog); msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint)); msg.exec(); + Bridge::getBridge()->setResult(); } void ScriptView::newIp() @@ -600,9 +602,9 @@ void ScriptView::question(QString message) msg.setParent(this, Qt::Dialog); msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint)); if(msg.exec() == QMessageBox::Yes) - Bridge::getBridge()->BridgeSetResult(1); + Bridge::getBridge()->setResult(1); else - Bridge::getBridge()->BridgeSetResult(0); + Bridge::getBridge()->setResult(0); } void ScriptView::enableHighlighting(bool enable) diff --git a/x64_dbg_gui/Project/x64_dbg.pro b/x64_dbg_gui/Project/x64_dbg.pro index d4a70978..1af66de0 100644 --- a/x64_dbg_gui/Project/x64_dbg.pro +++ b/x64_dbg_gui/Project/x64_dbg.pro @@ -85,7 +85,8 @@ SOURCES += \ Src/Gui/AttachDialog.cpp \ Src/Gui/PageMemoryRights.cpp \ Src/Gui/SelectFields.cpp \ - Src/Gui/ReferenceManager.cpp + Src/Gui/ReferenceManager.cpp \ + Src/Bridge/BridgeResult.cpp HEADERS += \ @@ -149,7 +150,8 @@ HEADERS += \ Src/Gui/AttachDialog.h \ Src/Gui/PageMemoryRights.h \ Src/Gui/SelectFields.h \ - Src/Gui/ReferenceManager.h + Src/Gui/ReferenceManager.h \ + Src/Bridge/BridgeResult.h INCLUDEPATH += \ From 23f65f6a911d49839deb4da160902e804df1b8f8 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 4 Jan 2015 21:16:59 +0100 Subject: [PATCH 016/106] DBG: separate file for exception code resolving + added a file for error code resolving --- x64_dbg_dbg/debugger.cpp | 71 +- x64_dbg_dbg/error.cpp | 2202 +++++++++++++++++++++++ x64_dbg_dbg/error.h | 7 + x64_dbg_dbg/exception.cpp | 77 + x64_dbg_dbg/exception.h | 7 + x64_dbg_dbg/x64_dbg_dbg.vcxproj | 4 + x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters | 12 + 7 files changed, 2314 insertions(+), 66 deletions(-) create mode 100644 x64_dbg_dbg/error.cpp create mode 100644 x64_dbg_dbg/error.h create mode 100644 x64_dbg_dbg/exception.cpp create mode 100644 x64_dbg_dbg/exception.h diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 42c3407b..a43d0b50 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -10,6 +10,8 @@ #include "symbolinfo.h" #include "variable.h" #include "x64_dbg.h" +#include "exception.h" +#include "error.h" static PROCESS_INFORMATION g_pi = {0, 0, 0, 0}; static char szBaseFileName[MAX_PATH] = ""; @@ -24,7 +26,6 @@ static bool bSkipExceptions = false; static bool bBreakOnNextDll = false; static int ecount = 0; static std::vector ignoredExceptionRange; -static std::map exceptionNames; static SIZE_T cachePrivateUsage = 0; static HANDLE hEvent = 0; static String lastDebugText; @@ -56,68 +57,8 @@ static DWORD WINAPI memMapThread(void* ptr) void dbginit() { - exceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); - exceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); - exceptionNames.insert(std::make_pair(0x4000001D, "STATUS_WX86_CONTINUE")); - exceptionNames.insert(std::make_pair(0x4000001E, "STATUS_WX86_SINGLE_STEP")); - exceptionNames.insert(std::make_pair(0x4000001F, "STATUS_WX86_BREAKPOINT")); - exceptionNames.insert(std::make_pair(0x40000020, "STATUS_WX86_EXCEPTION_CONTINUE")); - exceptionNames.insert(std::make_pair(0x40000021, "STATUS_WX86_EXCEPTION_LASTCHANCE")); - exceptionNames.insert(std::make_pair(0x40000022, "STATUS_WX86_EXCEPTION_CHAIN")); - exceptionNames.insert(std::make_pair(0x40000028, "STATUS_WX86_CREATEWX86TIB")); - exceptionNames.insert(std::make_pair(0x40010003, "DBG_TERMINATE_THREAD")); - exceptionNames.insert(std::make_pair(0x40010004, "DBG_TERMINATE_PROCESS")); - exceptionNames.insert(std::make_pair(0x40010005, "DBG_CONTROL_C")); - exceptionNames.insert(std::make_pair(0x40010006, "DBG_PRINTEXCEPTION_C")); - exceptionNames.insert(std::make_pair(0x40010007, "DBG_RIPEXCEPTION")); - exceptionNames.insert(std::make_pair(0x40010008, "DBG_CONTROL_BREAK")); - exceptionNames.insert(std::make_pair(0x40010009, "DBG_COMMAND_EXCEPTION")); - exceptionNames.insert(std::make_pair(0x80000001, "EXCEPTION_GUARD_PAGE")); - exceptionNames.insert(std::make_pair(0x80000002, "EXCEPTION_DATATYPE_MISALIGNMENT")); - exceptionNames.insert(std::make_pair(0x80000003, "EXCEPTION_BREAKPOINT")); - exceptionNames.insert(std::make_pair(0x80000004, "EXCEPTION_SINGLE_STEP")); - exceptionNames.insert(std::make_pair(0x80000026, "STATUS_LONGJUMP")); - exceptionNames.insert(std::make_pair(0x80000029, "STATUS_UNWIND_CONSOLIDATE")); - exceptionNames.insert(std::make_pair(0x80010001, "DBG_EXCEPTION_NOT_HANDLED")); - exceptionNames.insert(std::make_pair(0xC0000005, "EXCEPTION_ACCESS_VIOLATION")); - exceptionNames.insert(std::make_pair(0xC0000006, "EXCEPTION_IN_PAGE_ERROR")); - exceptionNames.insert(std::make_pair(0xC0000008, "EXCEPTION_INVALID_HANDLE")); - exceptionNames.insert(std::make_pair(0xC000000D, "STATUS_INVALID_PARAMETER")); - exceptionNames.insert(std::make_pair(0xC0000017, "STATUS_NO_MEMORY")); - exceptionNames.insert(std::make_pair(0xC000001D, "EXCEPTION_ILLEGAL_INSTRUCTION")); - exceptionNames.insert(std::make_pair(0xC0000025, "EXCEPTION_NONCONTINUABLE_EXCEPTION")); - exceptionNames.insert(std::make_pair(0xC0000026, "EXCEPTION_INVALID_DISPOSITION")); - exceptionNames.insert(std::make_pair(0xC000008C, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED")); - exceptionNames.insert(std::make_pair(0xC000008D, "EXCEPTION_FLT_DENORMAL_OPERAND")); - exceptionNames.insert(std::make_pair(0xC000008E, "EXCEPTION_FLT_DIVIDE_BY_ZERO")); - exceptionNames.insert(std::make_pair(0xC000008F, "EXCEPTION_FLT_INEXACT_RESULT")); - exceptionNames.insert(std::make_pair(0xC0000090, "EXCEPTION_FLT_INVALID_OPERATION")); - exceptionNames.insert(std::make_pair(0xC0000091, "EXCEPTION_FLT_OVERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000092, "EXCEPTION_FLT_STACK_CHECK")); - exceptionNames.insert(std::make_pair(0xC0000093, "EXCEPTION_FLT_UNDERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000094, "EXCEPTION_INT_DIVIDE_BY_ZERO")); - exceptionNames.insert(std::make_pair(0xC0000095, "EXCEPTION_INT_OVERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000096, "EXCEPTION_PRIV_INSTRUCTION")); - exceptionNames.insert(std::make_pair(0xC00000FD, "EXCEPTION_STACK_OVERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000135, "STATUS_DLL_NOT_FOUND")); - exceptionNames.insert(std::make_pair(0xC0000138, "STATUS_ORDINAL_NOT_FOUND")); - exceptionNames.insert(std::make_pair(0xC0000139, "STATUS_ENTRYPOINT_NOT_FOUND")); - exceptionNames.insert(std::make_pair(0xC000013A, "STATUS_CONTROL_C_EXIT")); - exceptionNames.insert(std::make_pair(0xC0000142, "STATUS_DLL_INIT_FAILED")); - exceptionNames.insert(std::make_pair(0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT")); - exceptionNames.insert(std::make_pair(0xC0000194, "EXCEPTION_POSSIBLE_DEADLOCK")); - exceptionNames.insert(std::make_pair(0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS")); - exceptionNames.insert(std::make_pair(0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS")); - exceptionNames.insert(std::make_pair(0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR")); - exceptionNames.insert(std::make_pair(0xC00002C9, "STATUS_REG_NAT_CONSUMPTION")); - exceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN")); - exceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER")); - exceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE")); - exceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); - exceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); - exceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); - exceptionNames.insert(std::make_pair(MS_VC_EXCEPTION, "MS_VC_EXCEPTION")); - exceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); + exceptioninit(); + errorinit(); CloseHandle(CreateThread(0, 0, memMapThread, 0, 0, 0)); } @@ -1056,9 +997,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) } } } - const char* exceptionName = 0; - if(exceptionNames.count(ExceptionCode)) - exceptionName = exceptionNames[ExceptionCode]; + const char* exceptionName = exceptionnamefromcode(ExceptionCode); if(ExceptionData->dwFirstChance) //first chance exception { if(exceptionName) diff --git a/x64_dbg_dbg/error.cpp b/x64_dbg_dbg/error.cpp new file mode 100644 index 00000000..c950011d --- /dev/null +++ b/x64_dbg_dbg/error.cpp @@ -0,0 +1,2202 @@ +#include "error.h" +#include + +static std::map errorNames; + +void errorinit() +{ + errorNames.insert(std::make_pair(0, "ERROR_SUCCESS")); + errorNames.insert(std::make_pair(1, "ERROR_INVALID_FUNCTION")); + errorNames.insert(std::make_pair(2, "ERROR_FILE_NOT_FOUND")); + errorNames.insert(std::make_pair(3, "ERROR_PATH_NOT_FOUND")); + errorNames.insert(std::make_pair(4, "ERROR_TOO_MANY_OPEN_FILES")); + errorNames.insert(std::make_pair(5, "ERROR_ACCESS_DENIED")); + errorNames.insert(std::make_pair(6, "ERROR_INVALID_HANDLE")); + errorNames.insert(std::make_pair(7, "ERROR_ARENA_TRASHED")); + errorNames.insert(std::make_pair(8, "ERROR_NOT_ENOUGH_MEMORY")); + errorNames.insert(std::make_pair(9, "ERROR_INVALID_BLOCK")); + errorNames.insert(std::make_pair(10, "ERROR_BAD_ENVIRONMENT")); + errorNames.insert(std::make_pair(11, "ERROR_BAD_FORMAT")); + errorNames.insert(std::make_pair(12, "ERROR_INVALID_ACCESS")); + errorNames.insert(std::make_pair(13, "ERROR_INVALID_DATA")); + errorNames.insert(std::make_pair(14, "ERROR_OUTOFMEMORY")); + errorNames.insert(std::make_pair(15, "ERROR_INVALID_DRIVE")); + errorNames.insert(std::make_pair(16, "ERROR_CURRENT_DIRECTORY")); + errorNames.insert(std::make_pair(17, "ERROR_NOT_SAME_DEVICE")); + errorNames.insert(std::make_pair(18, "ERROR_NO_MORE_FILES")); + errorNames.insert(std::make_pair(19, "ERROR_WRITE_PROTECT")); + errorNames.insert(std::make_pair(20, "ERROR_BAD_UNIT")); + errorNames.insert(std::make_pair(21, "ERROR_NOT_READY")); + errorNames.insert(std::make_pair(22, "ERROR_BAD_COMMAND")); + errorNames.insert(std::make_pair(23, "ERROR_CRC")); + errorNames.insert(std::make_pair(24, "ERROR_BAD_LENGTH")); + errorNames.insert(std::make_pair(25, "ERROR_SEEK")); + errorNames.insert(std::make_pair(26, "ERROR_NOT_DOS_DISK")); + errorNames.insert(std::make_pair(27, "ERROR_SECTOR_NOT_FOUND")); + errorNames.insert(std::make_pair(28, "ERROR_OUT_OF_PAPER")); + errorNames.insert(std::make_pair(29, "ERROR_WRITE_FAULT")); + errorNames.insert(std::make_pair(30, "ERROR_READ_FAULT")); + errorNames.insert(std::make_pair(31, "ERROR_GEN_FAILURE")); + errorNames.insert(std::make_pair(32, "ERROR_SHARING_VIOLATION")); + errorNames.insert(std::make_pair(33, "ERROR_LOCK_VIOLATION")); + errorNames.insert(std::make_pair(34, "ERROR_WRONG_DISK")); + errorNames.insert(std::make_pair(36, "ERROR_SHARING_BUFFER_EXCEEDED")); + errorNames.insert(std::make_pair(38, "ERROR_HANDLE_EOF")); + errorNames.insert(std::make_pair(39, "ERROR_HANDLE_DISK_FULL")); + errorNames.insert(std::make_pair(50, "ERROR_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(51, "ERROR_REM_NOT_LIST")); + errorNames.insert(std::make_pair(52, "ERROR_DUP_NAME")); + errorNames.insert(std::make_pair(53, "ERROR_BAD_NETPATH")); + errorNames.insert(std::make_pair(54, "ERROR_NETWORK_BUSY")); + errorNames.insert(std::make_pair(55, "ERROR_DEV_NOT_EXIST")); + errorNames.insert(std::make_pair(56, "ERROR_TOO_MANY_CMDS")); + errorNames.insert(std::make_pair(57, "ERROR_ADAP_HDW_ERR")); + errorNames.insert(std::make_pair(58, "ERROR_BAD_NET_RESP")); + errorNames.insert(std::make_pair(59, "ERROR_UNEXP_NET_ERR")); + errorNames.insert(std::make_pair(60, "ERROR_BAD_REM_ADAP")); + errorNames.insert(std::make_pair(61, "ERROR_PRINTQ_FULL")); + errorNames.insert(std::make_pair(62, "ERROR_NO_SPOOL_SPACE")); + errorNames.insert(std::make_pair(63, "ERROR_PRINT_CANCELLED")); + errorNames.insert(std::make_pair(64, "ERROR_NETNAME_DELETED")); + errorNames.insert(std::make_pair(65, "ERROR_NETWORK_ACCESS_DENIED")); + errorNames.insert(std::make_pair(66, "ERROR_BAD_DEV_TYPE")); + errorNames.insert(std::make_pair(67, "ERROR_BAD_NET_NAME")); + errorNames.insert(std::make_pair(68, "ERROR_TOO_MANY_NAMES")); + errorNames.insert(std::make_pair(69, "ERROR_TOO_MANY_SESS")); + errorNames.insert(std::make_pair(70, "ERROR_SHARING_PAUSED")); + errorNames.insert(std::make_pair(71, "ERROR_REQ_NOT_ACCEP")); + errorNames.insert(std::make_pair(72, "ERROR_REDIR_PAUSED")); + errorNames.insert(std::make_pair(80, "ERROR_FILE_EXISTS")); + errorNames.insert(std::make_pair(82, "ERROR_CANNOT_MAKE")); + errorNames.insert(std::make_pair(83, "ERROR_FAIL_I24")); + errorNames.insert(std::make_pair(84, "ERROR_OUT_OF_STRUCTURES")); + errorNames.insert(std::make_pair(85, "ERROR_ALREADY_ASSIGNED")); + errorNames.insert(std::make_pair(86, "ERROR_INVALID_PASSWORD")); + errorNames.insert(std::make_pair(87, "ERROR_INVALID_PARAMETER")); + errorNames.insert(std::make_pair(88, "ERROR_NET_WRITE_FAULT")); + errorNames.insert(std::make_pair(89, "ERROR_NO_PROC_SLOTS")); + errorNames.insert(std::make_pair(100, "ERROR_TOO_MANY_SEMAPHORES")); + errorNames.insert(std::make_pair(101, "ERROR_EXCL_SEM_ALREADY_OWNED")); + errorNames.insert(std::make_pair(102, "ERROR_SEM_IS_SET")); + errorNames.insert(std::make_pair(103, "ERROR_TOO_MANY_SEM_REQUESTS")); + errorNames.insert(std::make_pair(104, "ERROR_INVALID_AT_INTERRUPT_TIME")); + errorNames.insert(std::make_pair(105, "ERROR_SEM_OWNER_DIED")); + errorNames.insert(std::make_pair(106, "ERROR_SEM_USER_LIMIT")); + errorNames.insert(std::make_pair(107, "ERROR_DISK_CHANGE")); + errorNames.insert(std::make_pair(108, "ERROR_DRIVE_LOCKED")); + errorNames.insert(std::make_pair(109, "ERROR_BROKEN_PIPE")); + errorNames.insert(std::make_pair(110, "ERROR_OPEN_FAILED")); + errorNames.insert(std::make_pair(111, "ERROR_BUFFER_OVERFLOW")); + errorNames.insert(std::make_pair(112, "ERROR_DISK_FULL")); + errorNames.insert(std::make_pair(113, "ERROR_NO_MORE_SEARCH_HANDLES")); + errorNames.insert(std::make_pair(114, "ERROR_INVALID_TARGET_HANDLE")); + errorNames.insert(std::make_pair(117, "ERROR_INVALID_CATEGORY")); + errorNames.insert(std::make_pair(118, "ERROR_INVALID_VERIFY_SWITCH")); + errorNames.insert(std::make_pair(119, "ERROR_BAD_DRIVER_LEVEL")); + errorNames.insert(std::make_pair(120, "ERROR_CALL_NOT_IMPLEMENTED")); + errorNames.insert(std::make_pair(121, "ERROR_SEM_TIMEOUT")); + errorNames.insert(std::make_pair(122, "ERROR_INSUFFICIENT_BUFFER")); + errorNames.insert(std::make_pair(123, "ERROR_INVALID_NAME")); + errorNames.insert(std::make_pair(124, "ERROR_INVALID_LEVEL")); + errorNames.insert(std::make_pair(125, "ERROR_NO_VOLUME_LABEL")); + errorNames.insert(std::make_pair(126, "ERROR_MOD_NOT_FOUND")); + errorNames.insert(std::make_pair(127, "ERROR_PROC_NOT_FOUND")); + errorNames.insert(std::make_pair(128, "ERROR_WAIT_NO_CHILDREN")); + errorNames.insert(std::make_pair(129, "ERROR_CHILD_NOT_COMPLETE")); + errorNames.insert(std::make_pair(130, "ERROR_DIRECT_ACCESS_HANDLE")); + errorNames.insert(std::make_pair(131, "ERROR_NEGATIVE_SEEK")); + errorNames.insert(std::make_pair(132, "ERROR_SEEK_ON_DEVICE")); + errorNames.insert(std::make_pair(133, "ERROR_IS_JOIN_TARGET")); + errorNames.insert(std::make_pair(134, "ERROR_IS_JOINED")); + errorNames.insert(std::make_pair(135, "ERROR_IS_SUBSTED")); + errorNames.insert(std::make_pair(136, "ERROR_NOT_JOINED")); + errorNames.insert(std::make_pair(137, "ERROR_NOT_SUBSTED")); + errorNames.insert(std::make_pair(138, "ERROR_JOIN_TO_JOIN")); + errorNames.insert(std::make_pair(139, "ERROR_SUBST_TO_SUBST")); + errorNames.insert(std::make_pair(140, "ERROR_JOIN_TO_SUBST")); + errorNames.insert(std::make_pair(141, "ERROR_SUBST_TO_JOIN")); + errorNames.insert(std::make_pair(142, "ERROR_BUSY_DRIVE")); + errorNames.insert(std::make_pair(143, "ERROR_SAME_DRIVE")); + errorNames.insert(std::make_pair(144, "ERROR_DIR_NOT_ROOT")); + errorNames.insert(std::make_pair(145, "ERROR_DIR_NOT_EMPTY")); + errorNames.insert(std::make_pair(146, "ERROR_IS_SUBST_PATH")); + errorNames.insert(std::make_pair(147, "ERROR_IS_JOIN_PATH")); + errorNames.insert(std::make_pair(148, "ERROR_PATH_BUSY")); + errorNames.insert(std::make_pair(149, "ERROR_IS_SUBST_TARGET")); + errorNames.insert(std::make_pair(150, "ERROR_SYSTEM_TRACE")); + errorNames.insert(std::make_pair(151, "ERROR_INVALID_EVENT_COUNT")); + errorNames.insert(std::make_pair(152, "ERROR_TOO_MANY_MUXWAITERS")); + errorNames.insert(std::make_pair(153, "ERROR_INVALID_LIST_FORMAT")); + errorNames.insert(std::make_pair(154, "ERROR_LABEL_TOO_LONG")); + errorNames.insert(std::make_pair(155, "ERROR_TOO_MANY_TCBS")); + errorNames.insert(std::make_pair(156, "ERROR_SIGNAL_REFUSED")); + errorNames.insert(std::make_pair(157, "ERROR_DISCARDED")); + errorNames.insert(std::make_pair(158, "ERROR_NOT_LOCKED")); + errorNames.insert(std::make_pair(159, "ERROR_BAD_THREADID_ADDR")); + errorNames.insert(std::make_pair(160, "ERROR_BAD_ARGUMENTS")); + errorNames.insert(std::make_pair(161, "ERROR_BAD_PATHNAME")); + errorNames.insert(std::make_pair(162, "ERROR_SIGNAL_PENDING")); + errorNames.insert(std::make_pair(164, "ERROR_MAX_THRDS_REACHED")); + errorNames.insert(std::make_pair(167, "ERROR_LOCK_FAILED")); + errorNames.insert(std::make_pair(170, "ERROR_BUSY")); + errorNames.insert(std::make_pair(173, "ERROR_CANCEL_VIOLATION")); + errorNames.insert(std::make_pair(174, "ERROR_ATOMIC_LOCKS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(180, "ERROR_INVALID_SEGMENT_NUMBER")); + errorNames.insert(std::make_pair(182, "ERROR_INVALID_ORDINAL")); + errorNames.insert(std::make_pair(183, "ERROR_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(186, "ERROR_INVALID_FLAG_NUMBER")); + errorNames.insert(std::make_pair(187, "ERROR_SEM_NOT_FOUND")); + errorNames.insert(std::make_pair(188, "ERROR_INVALID_STARTING_CODESEG")); + errorNames.insert(std::make_pair(189, "ERROR_INVALID_STACKSEG")); + errorNames.insert(std::make_pair(190, "ERROR_INVALID_MODULETYPE")); + errorNames.insert(std::make_pair(191, "ERROR_INVALID_EXE_SIGNATURE")); + errorNames.insert(std::make_pair(192, "ERROR_EXE_MARKED_INVALID")); + errorNames.insert(std::make_pair(193, "ERROR_BAD_EXE_FORMAT")); + errorNames.insert(std::make_pair(194, "ERROR_ITERATED_DATA_EXCEEDS_64k")); + errorNames.insert(std::make_pair(195, "ERROR_INVALID_MINALLOCSIZE")); + errorNames.insert(std::make_pair(196, "ERROR_DYNLINK_FROM_INVALID_RING")); + errorNames.insert(std::make_pair(197, "ERROR_IOPL_NOT_ENABLED")); + errorNames.insert(std::make_pair(198, "ERROR_INVALID_SEGDPL")); + errorNames.insert(std::make_pair(199, "ERROR_AUTODATASEG_EXCEEDS_64k")); + errorNames.insert(std::make_pair(200, "ERROR_RING2SEG_MUST_BE_MOVABLE")); + errorNames.insert(std::make_pair(201, "ERROR_RELOC_CHAIN_XEEDS_SEGLIM")); + errorNames.insert(std::make_pair(202, "ERROR_INFLOOP_IN_RELOC_CHAIN")); + errorNames.insert(std::make_pair(203, "ERROR_ENVVAR_NOT_FOUND")); + errorNames.insert(std::make_pair(205, "ERROR_NO_SIGNAL_SENT")); + errorNames.insert(std::make_pair(206, "ERROR_FILENAME_EXCED_RANGE")); + errorNames.insert(std::make_pair(207, "ERROR_RING2_STACK_IN_USE")); + errorNames.insert(std::make_pair(208, "ERROR_META_EXPANSION_TOO_LONG")); + errorNames.insert(std::make_pair(209, "ERROR_INVALID_SIGNAL_NUMBER")); + errorNames.insert(std::make_pair(210, "ERROR_THREAD_1_INACTIVE")); + errorNames.insert(std::make_pair(212, "ERROR_LOCKED")); + errorNames.insert(std::make_pair(214, "ERROR_TOO_MANY_MODULES")); + errorNames.insert(std::make_pair(215, "ERROR_NESTING_NOT_ALLOWED")); + errorNames.insert(std::make_pair(216, "ERROR_EXE_MACHINE_TYPE_MISMATCH")); + errorNames.insert(std::make_pair(217, "ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY")); + errorNames.insert(std::make_pair(218, "ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY")); + errorNames.insert(std::make_pair(220, "ERROR_FILE_CHECKED_OUT")); + errorNames.insert(std::make_pair(221, "ERROR_CHECKOUT_REQUIRED")); + errorNames.insert(std::make_pair(222, "ERROR_BAD_FILE_TYPE")); + errorNames.insert(std::make_pair(223, "ERROR_FILE_TOO_LARGE")); + errorNames.insert(std::make_pair(224, "ERROR_FORMS_AUTH_REQUIRED")); + errorNames.insert(std::make_pair(225, "ERROR_VIRUS_INFECTED")); + errorNames.insert(std::make_pair(226, "ERROR_VIRUS_DELETED")); + errorNames.insert(std::make_pair(229, "ERROR_PIPE_LOCAL")); + errorNames.insert(std::make_pair(230, "ERROR_BAD_PIPE")); + errorNames.insert(std::make_pair(231, "ERROR_PIPE_BUSY")); + errorNames.insert(std::make_pair(232, "ERROR_NO_DATA")); + errorNames.insert(std::make_pair(233, "ERROR_PIPE_NOT_CONNECTED")); + errorNames.insert(std::make_pair(234, "ERROR_MORE_DATA")); + errorNames.insert(std::make_pair(240, "ERROR_VC_DISCONNECTED")); + errorNames.insert(std::make_pair(254, "ERROR_INVALID_EA_NAME")); + errorNames.insert(std::make_pair(255, "ERROR_EA_LIST_INCONSISTENT")); + errorNames.insert(std::make_pair(259, "ERROR_NO_MORE_ITEMS")); + errorNames.insert(std::make_pair(266, "ERROR_CANNOT_COPY")); + errorNames.insert(std::make_pair(267, "ERROR_DIRECTORY")); + errorNames.insert(std::make_pair(275, "ERROR_EAS_DIDNT_FIT")); + errorNames.insert(std::make_pair(276, "ERROR_EA_FILE_CORRUPT")); + errorNames.insert(std::make_pair(277, "ERROR_EA_TABLE_FULL")); + errorNames.insert(std::make_pair(278, "ERROR_INVALID_EA_HANDLE")); + errorNames.insert(std::make_pair(282, "ERROR_EAS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(288, "ERROR_NOT_OWNER")); + errorNames.insert(std::make_pair(298, "ERROR_TOO_MANY_POSTS")); + errorNames.insert(std::make_pair(299, "ERROR_PARTIAL_COPY")); + errorNames.insert(std::make_pair(300, "ERROR_OPLOCK_NOT_GRANTED")); + errorNames.insert(std::make_pair(301, "ERROR_INVALID_OPLOCK_PROTOCOL")); + errorNames.insert(std::make_pair(302, "ERROR_DISK_TOO_FRAGMENTED")); + errorNames.insert(std::make_pair(303, "ERROR_DELETE_PENDING")); + errorNames.insert(std::make_pair(304, "ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING")); + errorNames.insert(std::make_pair(305, "ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME")); + errorNames.insert(std::make_pair(306, "ERROR_SECURITY_STREAM_IS_INCONSISTENT")); + errorNames.insert(std::make_pair(307, "ERROR_INVALID_LOCK_RANGE")); + errorNames.insert(std::make_pair(308, "ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT")); + errorNames.insert(std::make_pair(309, "ERROR_NOTIFICATION_GUID_ALREADY_DEFINED")); + errorNames.insert(std::make_pair(317, "ERROR_MR_MID_NOT_FOUND")); + errorNames.insert(std::make_pair(318, "ERROR_SCOPE_NOT_FOUND")); + errorNames.insert(std::make_pair(350, "ERROR_FAIL_NOACTION_REBOOT")); + errorNames.insert(std::make_pair(351, "ERROR_FAIL_SHUTDOWN")); + errorNames.insert(std::make_pair(352, "ERROR_FAIL_RESTART")); + errorNames.insert(std::make_pair(353, "ERROR_MAX_SESSIONS_REACHED")); + errorNames.insert(std::make_pair(400, "ERROR_THREAD_MODE_ALREADY_BACKGROUND")); + errorNames.insert(std::make_pair(401, "ERROR_THREAD_MODE_NOT_BACKGROUND")); + errorNames.insert(std::make_pair(402, "ERROR_PROCESS_MODE_ALREADY_BACKGROUND")); + errorNames.insert(std::make_pair(403, "ERROR_PROCESS_MODE_NOT_BACKGROUND")); + errorNames.insert(std::make_pair(487, "ERROR_INVALID_ADDRESS")); + errorNames.insert(std::make_pair(500, "ERROR_USER_PROFILE_LOAD")); + errorNames.insert(std::make_pair(534, "ERROR_ARITHMETIC_OVERFLOW")); + errorNames.insert(std::make_pair(535, "ERROR_PIPE_CONNECTED")); + errorNames.insert(std::make_pair(536, "ERROR_PIPE_LISTENING")); + errorNames.insert(std::make_pair(537, "ERROR_VERIFIER_STOP")); + errorNames.insert(std::make_pair(538, "ERROR_ABIOS_ERROR")); + errorNames.insert(std::make_pair(539, "ERROR_WX86_WARNING")); + errorNames.insert(std::make_pair(540, "ERROR_WX86_ERROR")); + errorNames.insert(std::make_pair(541, "ERROR_TIMER_NOT_CANCELED")); + errorNames.insert(std::make_pair(542, "ERROR_UNWIND")); + errorNames.insert(std::make_pair(543, "ERROR_BAD_STACK")); + errorNames.insert(std::make_pair(544, "ERROR_INVALID_UNWIND_TARGET")); + errorNames.insert(std::make_pair(545, "ERROR_INVALID_PORT_ATTRIBUTES")); + errorNames.insert(std::make_pair(546, "ERROR_PORT_MESSAGE_TOO_LONG")); + errorNames.insert(std::make_pair(547, "ERROR_INVALID_QUOTA_LOWER")); + errorNames.insert(std::make_pair(548, "ERROR_DEVICE_ALREADY_ATTACHED")); + errorNames.insert(std::make_pair(549, "ERROR_INSTRUCTION_MISALIGNMENT")); + errorNames.insert(std::make_pair(550, "ERROR_PROFILING_NOT_STARTED")); + errorNames.insert(std::make_pair(551, "ERROR_PROFILING_NOT_STOPPED")); + errorNames.insert(std::make_pair(552, "ERROR_COULD_NOT_INTERPRET")); + errorNames.insert(std::make_pair(553, "ERROR_PROFILING_AT_LIMIT")); + errorNames.insert(std::make_pair(554, "ERROR_CANT_WAIT")); + errorNames.insert(std::make_pair(555, "ERROR_CANT_TERMINATE_SELF")); + errorNames.insert(std::make_pair(556, "ERROR_UNEXPECTED_MM_CREATE_ERR")); + errorNames.insert(std::make_pair(557, "ERROR_UNEXPECTED_MM_MAP_ERROR")); + errorNames.insert(std::make_pair(558, "ERROR_UNEXPECTED_MM_EXTEND_ERR")); + errorNames.insert(std::make_pair(559, "ERROR_BAD_FUNCTION_TABLE")); + errorNames.insert(std::make_pair(560, "ERROR_NO_GUID_TRANSLATION")); + errorNames.insert(std::make_pair(561, "ERROR_INVALID_LDT_SIZE")); + errorNames.insert(std::make_pair(563, "ERROR_INVALID_LDT_OFFSET")); + errorNames.insert(std::make_pair(564, "ERROR_INVALID_LDT_DESCRIPTOR")); + errorNames.insert(std::make_pair(565, "ERROR_TOO_MANY_THREADS")); + errorNames.insert(std::make_pair(566, "ERROR_THREAD_NOT_IN_PROCESS")); + errorNames.insert(std::make_pair(567, "ERROR_PAGEFILE_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(568, "ERROR_LOGON_SERVER_CONFLICT")); + errorNames.insert(std::make_pair(569, "ERROR_SYNCHRONIZATION_REQUIRED")); + errorNames.insert(std::make_pair(570, "ERROR_NET_OPEN_FAILED")); + errorNames.insert(std::make_pair(571, "ERROR_IO_PRIVILEGE_FAILED")); + errorNames.insert(std::make_pair(572, "ERROR_CONTROL_C_EXIT")); + errorNames.insert(std::make_pair(573, "ERROR_MISSING_SYSTEMFILE")); + errorNames.insert(std::make_pair(574, "ERROR_UNHANDLED_EXCEPTION")); + errorNames.insert(std::make_pair(575, "ERROR_APP_INIT_FAILURE")); + errorNames.insert(std::make_pair(576, "ERROR_PAGEFILE_CREATE_FAILED")); + errorNames.insert(std::make_pair(577, "ERROR_INVALID_IMAGE_HASH")); + errorNames.insert(std::make_pair(578, "ERROR_NO_PAGEFILE")); + errorNames.insert(std::make_pair(579, "ERROR_ILLEGAL_FLOAT_CONTEXT")); + errorNames.insert(std::make_pair(580, "ERROR_NO_EVENT_PAIR")); + errorNames.insert(std::make_pair(581, "ERROR_DOMAIN_CTRLR_CONFIG_ERROR")); + errorNames.insert(std::make_pair(582, "ERROR_ILLEGAL_CHARACTER")); + errorNames.insert(std::make_pair(583, "ERROR_UNDEFINED_CHARACTER")); + errorNames.insert(std::make_pair(584, "ERROR_FLOPPY_VOLUME")); + errorNames.insert(std::make_pair(585, "ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT")); + errorNames.insert(std::make_pair(586, "ERROR_BACKUP_CONTROLLER")); + errorNames.insert(std::make_pair(587, "ERROR_MUTANT_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(588, "ERROR_FS_DRIVER_REQUIRED")); + errorNames.insert(std::make_pair(589, "ERROR_CANNOT_LOAD_REGISTRY_FILE")); + errorNames.insert(std::make_pair(590, "ERROR_DEBUG_ATTACH_FAILED")); + errorNames.insert(std::make_pair(591, "ERROR_SYSTEM_PROCESS_TERMINATED")); + errorNames.insert(std::make_pair(592, "ERROR_DATA_NOT_ACCEPTED")); + errorNames.insert(std::make_pair(593, "ERROR_VDM_HARD_ERROR")); + errorNames.insert(std::make_pair(594, "ERROR_DRIVER_CANCEL_TIMEOUT")); + errorNames.insert(std::make_pair(595, "ERROR_REPLY_MESSAGE_MISMATCH")); + errorNames.insert(std::make_pair(596, "ERROR_LOST_WRITEBEHIND_DATA")); + errorNames.insert(std::make_pair(597, "ERROR_CLIENT_SERVER_PARAMETERS_INVALID")); + errorNames.insert(std::make_pair(598, "ERROR_NOT_TINY_STREAM")); + errorNames.insert(std::make_pair(599, "ERROR_STACK_OVERFLOW_READ")); + errorNames.insert(std::make_pair(600, "ERROR_CONVERT_TO_LARGE")); + errorNames.insert(std::make_pair(601, "ERROR_FOUND_OUT_OF_SCOPE")); + errorNames.insert(std::make_pair(602, "ERROR_ALLOCATE_BUCKET")); + errorNames.insert(std::make_pair(603, "ERROR_MARSHALL_OVERFLOW")); + errorNames.insert(std::make_pair(604, "ERROR_INVALID_VARIANT")); + errorNames.insert(std::make_pair(605, "ERROR_BAD_COMPRESSION_BUFFER")); + errorNames.insert(std::make_pair(606, "ERROR_AUDIT_FAILED")); + errorNames.insert(std::make_pair(607, "ERROR_TIMER_RESOLUTION_NOT_SET")); + errorNames.insert(std::make_pair(608, "ERROR_INSUFFICIENT_LOGON_INFO")); + errorNames.insert(std::make_pair(609, "ERROR_BAD_DLL_ENTRYPOINT")); + errorNames.insert(std::make_pair(610, "ERROR_BAD_SERVICE_ENTRYPOINT")); + errorNames.insert(std::make_pair(611, "ERROR_IP_ADDRESS_CONFLICT1")); + errorNames.insert(std::make_pair(612, "ERROR_IP_ADDRESS_CONFLICT2")); + errorNames.insert(std::make_pair(613, "ERROR_REGISTRY_QUOTA_LIMIT")); + errorNames.insert(std::make_pair(614, "ERROR_NO_CALLBACK_ACTIVE")); + errorNames.insert(std::make_pair(615, "ERROR_PWD_TOO_SHORT")); + errorNames.insert(std::make_pair(616, "ERROR_PWD_TOO_RECENT")); + errorNames.insert(std::make_pair(617, "ERROR_PWD_HISTORY_CONFLICT")); + errorNames.insert(std::make_pair(618, "ERROR_UNSUPPORTED_COMPRESSION")); + errorNames.insert(std::make_pair(619, "ERROR_INVALID_HW_PROFILE")); + errorNames.insert(std::make_pair(620, "ERROR_INVALID_PLUGPLAY_DEVICE_PATH")); + errorNames.insert(std::make_pair(621, "ERROR_QUOTA_LIST_INCONSISTENT")); + errorNames.insert(std::make_pair(622, "ERROR_EVALUATION_EXPIRATION")); + errorNames.insert(std::make_pair(623, "ERROR_ILLEGAL_DLL_RELOCATION")); + errorNames.insert(std::make_pair(624, "ERROR_DLL_INIT_FAILED_LOGOFF")); + errorNames.insert(std::make_pair(625, "ERROR_VALIDATE_CONTINUE")); + errorNames.insert(std::make_pair(626, "ERROR_NO_MORE_MATCHES")); + errorNames.insert(std::make_pair(627, "ERROR_RANGE_LIST_CONFLICT")); + errorNames.insert(std::make_pair(628, "ERROR_SERVER_SID_MISMATCH")); + errorNames.insert(std::make_pair(629, "ERROR_CANT_ENABLE_DENY_ONLY")); + errorNames.insert(std::make_pair(630, "ERROR_FLOAT_MULTIPLE_FAULTS")); + errorNames.insert(std::make_pair(631, "ERROR_FLOAT_MULTIPLE_TRAPS")); + errorNames.insert(std::make_pair(632, "ERROR_NOINTERFACE")); + errorNames.insert(std::make_pair(633, "ERROR_DRIVER_FAILED_SLEEP")); + errorNames.insert(std::make_pair(634, "ERROR_CORRUPT_SYSTEM_FILE")); + errorNames.insert(std::make_pair(635, "ERROR_COMMITMENT_MINIMUM")); + errorNames.insert(std::make_pair(636, "ERROR_PNP_RESTART_ENUMERATION")); + errorNames.insert(std::make_pair(637, "ERROR_SYSTEM_IMAGE_BAD_SIGNATURE")); + errorNames.insert(std::make_pair(638, "ERROR_PNP_REBOOT_REQUIRED")); + errorNames.insert(std::make_pair(639, "ERROR_INSUFFICIENT_POWER")); + errorNames.insert(std::make_pair(640, "ERROR_MULTIPLE_FAULT_VIOLATION")); + errorNames.insert(std::make_pair(641, "ERROR_SYSTEM_SHUTDOWN")); + errorNames.insert(std::make_pair(642, "ERROR_PORT_NOT_SET")); + errorNames.insert(std::make_pair(643, "ERROR_DS_VERSION_CHECK_FAILURE")); + errorNames.insert(std::make_pair(644, "ERROR_RANGE_NOT_FOUND")); + errorNames.insert(std::make_pair(646, "ERROR_NOT_SAFE_MODE_DRIVER")); + errorNames.insert(std::make_pair(647, "ERROR_FAILED_DRIVER_ENTRY")); + errorNames.insert(std::make_pair(648, "ERROR_DEVICE_ENUMERATION_ERROR")); + errorNames.insert(std::make_pair(649, "ERROR_MOUNT_POINT_NOT_RESOLVED")); + errorNames.insert(std::make_pair(650, "ERROR_INVALID_DEVICE_OBJECT_PARAMETER")); + errorNames.insert(std::make_pair(651, "ERROR_MCA_OCCURED")); + errorNames.insert(std::make_pair(652, "ERROR_DRIVER_DATABASE_ERROR")); + errorNames.insert(std::make_pair(653, "ERROR_SYSTEM_HIVE_TOO_LARGE")); + errorNames.insert(std::make_pair(654, "ERROR_DRIVER_FAILED_PRIOR_UNLOAD")); + errorNames.insert(std::make_pair(655, "ERROR_VOLSNAP_PREPARE_HIBERNATE")); + errorNames.insert(std::make_pair(656, "ERROR_HIBERNATION_FAILURE")); + errorNames.insert(std::make_pair(665, "ERROR_FILE_SYSTEM_LIMITATION")); + errorNames.insert(std::make_pair(668, "ERROR_ASSERTION_FAILURE")); + errorNames.insert(std::make_pair(669, "ERROR_ACPI_ERROR")); + errorNames.insert(std::make_pair(670, "ERROR_WOW_ASSERTION")); + errorNames.insert(std::make_pair(671, "ERROR_PNP_BAD_MPS_TABLE")); + errorNames.insert(std::make_pair(672, "ERROR_PNP_TRANSLATION_FAILED")); + errorNames.insert(std::make_pair(673, "ERROR_PNP_IRQ_TRANSLATION_FAILED")); + errorNames.insert(std::make_pair(674, "ERROR_PNP_INVALID_ID")); + errorNames.insert(std::make_pair(675, "ERROR_WAKE_SYSTEM_DEBUGGER")); + errorNames.insert(std::make_pair(676, "ERROR_HANDLES_CLOSED")); + errorNames.insert(std::make_pair(677, "ERROR_EXTRANEOUS_INFORMATION")); + errorNames.insert(std::make_pair(678, "ERROR_RXACT_COMMIT_NECESSARY")); + errorNames.insert(std::make_pair(679, "ERROR_MEDIA_CHECK")); + errorNames.insert(std::make_pair(680, "ERROR_GUID_SUBSTITUTION_MADE")); + errorNames.insert(std::make_pair(681, "ERROR_STOPPED_ON_SYMLINK")); + errorNames.insert(std::make_pair(682, "ERROR_LONGJUMP")); + errorNames.insert(std::make_pair(683, "ERROR_PLUGPLAY_QUERY_VETOED")); + errorNames.insert(std::make_pair(684, "ERROR_UNWIND_CONSOLIDATE")); + errorNames.insert(std::make_pair(685, "ERROR_REGISTRY_HIVE_RECOVERED")); + errorNames.insert(std::make_pair(686, "ERROR_DLL_MIGHT_BE_INSECURE")); + errorNames.insert(std::make_pair(687, "ERROR_DLL_MIGHT_BE_INCOMPATIBLE")); + errorNames.insert(std::make_pair(688, "ERROR_DBG_EXCEPTION_NOT_HANDLED")); + errorNames.insert(std::make_pair(689, "ERROR_DBG_REPLY_LATER")); + errorNames.insert(std::make_pair(690, "ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE")); + errorNames.insert(std::make_pair(691, "ERROR_DBG_TERMINATE_THREAD")); + errorNames.insert(std::make_pair(692, "ERROR_DBG_TERMINATE_PROCESS")); + errorNames.insert(std::make_pair(693, "ERROR_DBG_CONTROL_C")); + errorNames.insert(std::make_pair(694, "ERROR_DBG_PRINTEXCEPTION_C")); + errorNames.insert(std::make_pair(695, "ERROR_DBG_RIPEXCEPTION")); + errorNames.insert(std::make_pair(696, "ERROR_DBG_CONTROL_BREAK")); + errorNames.insert(std::make_pair(697, "ERROR_DBG_COMMAND_EXCEPTION")); + errorNames.insert(std::make_pair(698, "ERROR_OBJECT_NAME_EXISTS")); + errorNames.insert(std::make_pair(699, "ERROR_THREAD_WAS_SUSPENDED")); + errorNames.insert(std::make_pair(700, "ERROR_IMAGE_NOT_AT_BASE")); + errorNames.insert(std::make_pair(701, "ERROR_RXACT_STATE_CREATED")); + errorNames.insert(std::make_pair(702, "ERROR_SEGMENT_NOTIFICATION")); + errorNames.insert(std::make_pair(703, "ERROR_BAD_CURRENT_DIRECTORY")); + errorNames.insert(std::make_pair(704, "ERROR_FT_READ_RECOVERY_FROM_BACKUP")); + errorNames.insert(std::make_pair(705, "ERROR_FT_WRITE_RECOVERY")); + errorNames.insert(std::make_pair(706, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH")); + errorNames.insert(std::make_pair(707, "ERROR_RECEIVE_PARTIAL")); + errorNames.insert(std::make_pair(708, "ERROR_RECEIVE_EXPEDITED")); + errorNames.insert(std::make_pair(709, "ERROR_RECEIVE_PARTIAL_EXPEDITED")); + errorNames.insert(std::make_pair(710, "ERROR_EVENT_DONE")); + errorNames.insert(std::make_pair(711, "ERROR_EVENT_PENDING")); + errorNames.insert(std::make_pair(712, "ERROR_CHECKING_FILE_SYSTEM")); + errorNames.insert(std::make_pair(713, "ERROR_FATAL_APP_EXIT")); + errorNames.insert(std::make_pair(714, "ERROR_PREDEFINED_HANDLE")); + errorNames.insert(std::make_pair(715, "ERROR_WAS_UNLOCKED")); + errorNames.insert(std::make_pair(716, "ERROR_SERVICE_NOTIFICATION")); + errorNames.insert(std::make_pair(717, "ERROR_WAS_LOCKED")); + errorNames.insert(std::make_pair(718, "ERROR_LOG_HARD_ERROR")); + errorNames.insert(std::make_pair(719, "ERROR_ALREADY_WIN32")); + errorNames.insert(std::make_pair(720, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE")); + errorNames.insert(std::make_pair(721, "ERROR_NO_YIELD_PERFORMED")); + errorNames.insert(std::make_pair(722, "ERROR_TIMER_RESUME_IGNORED")); + errorNames.insert(std::make_pair(723, "ERROR_ARBITRATION_UNHANDLED")); + errorNames.insert(std::make_pair(724, "ERROR_CARDBUS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(725, "ERROR_MP_PROCESSOR_MISMATCH")); + errorNames.insert(std::make_pair(726, "ERROR_HIBERNATED")); + errorNames.insert(std::make_pair(727, "ERROR_RESUME_HIBERNATION")); + errorNames.insert(std::make_pair(728, "ERROR_FIRMWARE_UPDATED")); + errorNames.insert(std::make_pair(729, "ERROR_DRIVERS_LEAKING_LOCKED_PAGES")); + errorNames.insert(std::make_pair(730, "ERROR_WAKE_SYSTEM")); + errorNames.insert(std::make_pair(731, "ERROR_WAIT_1")); + errorNames.insert(std::make_pair(732, "ERROR_WAIT_2")); + errorNames.insert(std::make_pair(733, "ERROR_WAIT_3")); + errorNames.insert(std::make_pair(734, "ERROR_WAIT_63")); + errorNames.insert(std::make_pair(735, "ERROR_ABANDONED_WAIT_0")); + errorNames.insert(std::make_pair(736, "ERROR_ABANDONED_WAIT_63")); + errorNames.insert(std::make_pair(737, "ERROR_USER_APC")); + errorNames.insert(std::make_pair(738, "ERROR_KERNEL_APC")); + errorNames.insert(std::make_pair(739, "ERROR_ALERTED")); + errorNames.insert(std::make_pair(740, "ERROR_ELEVATION_REQUIRED")); + errorNames.insert(std::make_pair(741, "ERROR_REPARSE")); + errorNames.insert(std::make_pair(742, "ERROR_OPLOCK_BREAK_IN_PROGRESS")); + errorNames.insert(std::make_pair(743, "ERROR_VOLUME_MOUNTED")); + errorNames.insert(std::make_pair(744, "ERROR_RXACT_COMMITTED")); + errorNames.insert(std::make_pair(745, "ERROR_NOTIFY_CLEANUP")); + errorNames.insert(std::make_pair(746, "ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED")); + errorNames.insert(std::make_pair(747, "ERROR_PAGE_FAULT_TRANSITION")); + errorNames.insert(std::make_pair(748, "ERROR_PAGE_FAULT_DEMAND_ZERO")); + errorNames.insert(std::make_pair(749, "ERROR_PAGE_FAULT_COPY_ON_WRITE")); + errorNames.insert(std::make_pair(750, "ERROR_PAGE_FAULT_GUARD_PAGE")); + errorNames.insert(std::make_pair(751, "ERROR_PAGE_FAULT_PAGING_FILE")); + errorNames.insert(std::make_pair(752, "ERROR_CACHE_PAGE_LOCKED")); + errorNames.insert(std::make_pair(753, "ERROR_CRASH_DUMP")); + errorNames.insert(std::make_pair(754, "ERROR_BUFFER_ALL_ZEROS")); + errorNames.insert(std::make_pair(755, "ERROR_REPARSE_OBJECT")); + errorNames.insert(std::make_pair(756, "ERROR_RESOURCE_REQUIREMENTS_CHANGED")); + errorNames.insert(std::make_pair(757, "ERROR_TRANSLATION_COMPLETE")); + errorNames.insert(std::make_pair(758, "ERROR_NOTHING_TO_TERMINATE")); + errorNames.insert(std::make_pair(759, "ERROR_PROCESS_NOT_IN_JOB")); + errorNames.insert(std::make_pair(760, "ERROR_PROCESS_IN_JOB")); + errorNames.insert(std::make_pair(761, "ERROR_VOLSNAP_HIBERNATE_READY")); + errorNames.insert(std::make_pair(762, "ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY")); + errorNames.insert(std::make_pair(763, "ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED")); + errorNames.insert(std::make_pair(764, "ERROR_INTERRUPT_STILL_CONNECTED")); + errorNames.insert(std::make_pair(765, "ERROR_WAIT_FOR_OPLOCK")); + errorNames.insert(std::make_pair(766, "ERROR_DBG_EXCEPTION_HANDLED")); + errorNames.insert(std::make_pair(767, "ERROR_DBG_CONTINUE")); + errorNames.insert(std::make_pair(768, "ERROR_CALLBACK_POP_STACK")); + errorNames.insert(std::make_pair(769, "ERROR_COMPRESSION_DISABLED")); + errorNames.insert(std::make_pair(770, "ERROR_CANTFETCHBACKWARDS")); + errorNames.insert(std::make_pair(771, "ERROR_CANTSCROLLBACKWARDS")); + errorNames.insert(std::make_pair(772, "ERROR_ROWSNOTRELEASED")); + errorNames.insert(std::make_pair(773, "ERROR_BAD_ACCESSOR_FLAGS")); + errorNames.insert(std::make_pair(774, "ERROR_ERRORS_ENCOUNTERED")); + errorNames.insert(std::make_pair(775, "ERROR_NOT_CAPABLE")); + errorNames.insert(std::make_pair(776, "ERROR_REQUEST_OUT_OF_SEQUENCE")); + errorNames.insert(std::make_pair(777, "ERROR_VERSION_PARSE_ERROR")); + errorNames.insert(std::make_pair(778, "ERROR_BADSTARTPOSITION")); + errorNames.insert(std::make_pair(779, "ERROR_MEMORY_HARDWARE")); + errorNames.insert(std::make_pair(780, "ERROR_DISK_REPAIR_DISABLED")); + errorNames.insert(std::make_pair(781, "ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE")); + errorNames.insert(std::make_pair(782, "ERROR_SYSTEM_POWERSTATE_TRANSITION")); + errorNames.insert(std::make_pair(783, "ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION")); + errorNames.insert(std::make_pair(784, "ERROR_MCA_EXCEPTION")); + errorNames.insert(std::make_pair(785, "ERROR_ACCESS_AUDIT_BY_POLICY")); + errorNames.insert(std::make_pair(786, "ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY")); + errorNames.insert(std::make_pair(787, "ERROR_ABANDON_HIBERFILE")); + errorNames.insert(std::make_pair(788, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED")); + errorNames.insert(std::make_pair(789, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR")); + errorNames.insert(std::make_pair(790, "ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR")); + errorNames.insert(std::make_pair(791, "ERROR_BAD_MCFG_TABLE")); + errorNames.insert(std::make_pair(800, "ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE")); + errorNames.insert(std::make_pair(801, "ERROR_CANNOT_GRANT_REQUESTED_OPLOCK")); + errorNames.insert(std::make_pair(802, "ERROR_CANNOT_BREAK_OPLOCK")); + errorNames.insert(std::make_pair(803, "ERROR_OPLOCK_HANDLE_CLOSED")); + errorNames.insert(std::make_pair(804, "ERROR_NO_ACE_CONDITION")); + errorNames.insert(std::make_pair(805, "ERROR_INVALID_ACE_CONDITION")); + errorNames.insert(std::make_pair(994, "ERROR_EA_ACCESS_DENIED")); + errorNames.insert(std::make_pair(995, "ERROR_OPERATION_ABORTED")); + errorNames.insert(std::make_pair(996, "ERROR_IO_INCOMPLETE")); + errorNames.insert(std::make_pair(997, "ERROR_IO_PENDING")); + errorNames.insert(std::make_pair(998, "ERROR_NOACCESS")); + errorNames.insert(std::make_pair(999, "ERROR_SWAPERROR")); + errorNames.insert(std::make_pair(1001, "ERROR_STACK_OVERFLOW")); + errorNames.insert(std::make_pair(1002, "ERROR_INVALID_MESSAGE")); + errorNames.insert(std::make_pair(1003, "ERROR_CAN_NOT_COMPLETE")); + errorNames.insert(std::make_pair(1004, "ERROR_INVALID_FLAGS")); + errorNames.insert(std::make_pair(1005, "ERROR_UNRECOGNIZED_VOLUME")); + errorNames.insert(std::make_pair(1006, "ERROR_FILE_INVALID")); + errorNames.insert(std::make_pair(1007, "ERROR_FULLSCREEN_MODE")); + errorNames.insert(std::make_pair(1008, "ERROR_NO_TOKEN")); + errorNames.insert(std::make_pair(1009, "ERROR_BADDB")); + errorNames.insert(std::make_pair(1010, "ERROR_BADKEY")); + errorNames.insert(std::make_pair(1011, "ERROR_CANTOPEN")); + errorNames.insert(std::make_pair(1012, "ERROR_CANTREAD")); + errorNames.insert(std::make_pair(1013, "ERROR_CANTWRITE")); + errorNames.insert(std::make_pair(1014, "ERROR_REGISTRY_RECOVERED")); + errorNames.insert(std::make_pair(1015, "ERROR_REGISTRY_CORRUPT")); + errorNames.insert(std::make_pair(1016, "ERROR_REGISTRY_IO_FAILED")); + errorNames.insert(std::make_pair(1017, "ERROR_NOT_REGISTRY_FILE")); + errorNames.insert(std::make_pair(1018, "ERROR_KEY_DELETED")); + errorNames.insert(std::make_pair(1019, "ERROR_NO_LOG_SPACE")); + errorNames.insert(std::make_pair(1020, "ERROR_KEY_HAS_CHILDREN")); + errorNames.insert(std::make_pair(1021, "ERROR_CHILD_MUST_BE_VOLATILE")); + errorNames.insert(std::make_pair(1022, "ERROR_NOTIFY_ENUM_DIR")); + errorNames.insert(std::make_pair(1051, "ERROR_DEPENDENT_SERVICES_RUNNING")); + errorNames.insert(std::make_pair(1052, "ERROR_INVALID_SERVICE_CONTROL")); + errorNames.insert(std::make_pair(1053, "ERROR_SERVICE_REQUEST_TIMEOUT")); + errorNames.insert(std::make_pair(1054, "ERROR_SERVICE_NO_THREAD")); + errorNames.insert(std::make_pair(1055, "ERROR_SERVICE_DATABASE_LOCKED")); + errorNames.insert(std::make_pair(1056, "ERROR_SERVICE_ALREADY_RUNNING")); + errorNames.insert(std::make_pair(1057, "ERROR_INVALID_SERVICE_ACCOUNT")); + errorNames.insert(std::make_pair(1058, "ERROR_SERVICE_DISABLED")); + errorNames.insert(std::make_pair(1059, "ERROR_CIRCULAR_DEPENDENCY")); + errorNames.insert(std::make_pair(1060, "ERROR_SERVICE_DOES_NOT_EXIST")); + errorNames.insert(std::make_pair(1061, "ERROR_SERVICE_CANNOT_ACCEPT_CTRL")); + errorNames.insert(std::make_pair(1062, "ERROR_SERVICE_NOT_ACTIVE")); + errorNames.insert(std::make_pair(1063, "ERROR_FAILED_SERVICE_CONTROLLER_CONNECT")); + errorNames.insert(std::make_pair(1064, "ERROR_EXCEPTION_IN_SERVICE")); + errorNames.insert(std::make_pair(1065, "ERROR_DATABASE_DOES_NOT_EXIST")); + errorNames.insert(std::make_pair(1066, "ERROR_SERVICE_SPECIFIC_ERROR")); + errorNames.insert(std::make_pair(1067, "ERROR_PROCESS_ABORTED")); + errorNames.insert(std::make_pair(1068, "ERROR_SERVICE_DEPENDENCY_FAIL")); + errorNames.insert(std::make_pair(1069, "ERROR_SERVICE_LOGON_FAILED")); + errorNames.insert(std::make_pair(1070, "ERROR_SERVICE_START_HANG")); + errorNames.insert(std::make_pair(1071, "ERROR_INVALID_SERVICE_LOCK")); + errorNames.insert(std::make_pair(1072, "ERROR_SERVICE_MARKED_FOR_DELETE")); + errorNames.insert(std::make_pair(1073, "ERROR_SERVICE_EXISTS")); + errorNames.insert(std::make_pair(1074, "ERROR_ALREADY_RUNNING_LKG")); + errorNames.insert(std::make_pair(1075, "ERROR_SERVICE_DEPENDENCY_DELETED")); + errorNames.insert(std::make_pair(1076, "ERROR_BOOT_ALREADY_ACCEPTED")); + errorNames.insert(std::make_pair(1077, "ERROR_SERVICE_NEVER_STARTED")); + errorNames.insert(std::make_pair(1078, "ERROR_DUPLICATE_SERVICE_NAME")); + errorNames.insert(std::make_pair(1079, "ERROR_DIFFERENT_SERVICE_ACCOUNT")); + errorNames.insert(std::make_pair(1080, "ERROR_CANNOT_DETECT_DRIVER_FAILURE")); + errorNames.insert(std::make_pair(1081, "ERROR_CANNOT_DETECT_PROCESS_ABORT")); + errorNames.insert(std::make_pair(1082, "ERROR_NO_RECOVERY_PROGRAM")); + errorNames.insert(std::make_pair(1083, "ERROR_SERVICE_NOT_IN_EXE")); + errorNames.insert(std::make_pair(1084, "ERROR_NOT_SAFEBOOT_SERVICE")); + errorNames.insert(std::make_pair(1100, "ERROR_END_OF_MEDIA")); + errorNames.insert(std::make_pair(1101, "ERROR_FILEMARK_DETECTED")); + errorNames.insert(std::make_pair(1102, "ERROR_BEGINNING_OF_MEDIA")); + errorNames.insert(std::make_pair(1103, "ERROR_SETMARK_DETECTED")); + errorNames.insert(std::make_pair(1104, "ERROR_NO_DATA_DETECTED")); + errorNames.insert(std::make_pair(1105, "ERROR_PARTITION_FAILURE")); + errorNames.insert(std::make_pair(1106, "ERROR_INVALID_BLOCK_LENGTH")); + errorNames.insert(std::make_pair(1107, "ERROR_DEVICE_NOT_PARTITIONED")); + errorNames.insert(std::make_pair(1108, "ERROR_UNABLE_TO_LOCK_MEDIA")); + errorNames.insert(std::make_pair(1109, "ERROR_UNABLE_TO_UNLOAD_MEDIA")); + errorNames.insert(std::make_pair(1110, "ERROR_MEDIA_CHANGED")); + errorNames.insert(std::make_pair(1111, "ERROR_BUS_RESET")); + errorNames.insert(std::make_pair(1112, "ERROR_NO_MEDIA_IN_DRIVE")); + errorNames.insert(std::make_pair(1113, "ERROR_NO_UNICODE_TRANSLATION")); + errorNames.insert(std::make_pair(1114, "ERROR_DLL_INIT_FAILED")); + errorNames.insert(std::make_pair(1115, "ERROR_SHUTDOWN_IN_PROGRESS")); + errorNames.insert(std::make_pair(1116, "ERROR_NO_SHUTDOWN_IN_PROGRESS")); + errorNames.insert(std::make_pair(1117, "ERROR_IO_DEVICE")); + errorNames.insert(std::make_pair(1118, "ERROR_SERIAL_NO_DEVICE")); + errorNames.insert(std::make_pair(1119, "ERROR_IRQ_BUSY")); + errorNames.insert(std::make_pair(1120, "ERROR_MORE_WRITES")); + errorNames.insert(std::make_pair(1121, "ERROR_COUNTER_TIMEOUT")); + errorNames.insert(std::make_pair(1122, "ERROR_FLOPPY_ID_MARK_NOT_FOUND")); + errorNames.insert(std::make_pair(1123, "ERROR_FLOPPY_WRONG_CYLINDER")); + errorNames.insert(std::make_pair(1124, "ERROR_FLOPPY_UNKNOWN_ERROR")); + errorNames.insert(std::make_pair(1125, "ERROR_FLOPPY_BAD_REGISTERS")); + errorNames.insert(std::make_pair(1126, "ERROR_DISK_RECALIBRATE_FAILED")); + errorNames.insert(std::make_pair(1127, "ERROR_DISK_OPERATION_FAILED")); + errorNames.insert(std::make_pair(1128, "ERROR_DISK_RESET_FAILED")); + errorNames.insert(std::make_pair(1129, "ERROR_EOM_OVERFLOW")); + errorNames.insert(std::make_pair(1130, "ERROR_NOT_ENOUGH_SERVER_MEMORY")); + errorNames.insert(std::make_pair(1131, "ERROR_POSSIBLE_DEADLOCK")); + errorNames.insert(std::make_pair(1132, "ERROR_MAPPED_ALIGNMENT")); + errorNames.insert(std::make_pair(1140, "ERROR_SET_POWER_STATE_VETOED")); + errorNames.insert(std::make_pair(1141, "ERROR_SET_POWER_STATE_FAILED")); + errorNames.insert(std::make_pair(1142, "ERROR_TOO_MANY_LINKS")); + errorNames.insert(std::make_pair(1150, "ERROR_OLD_WIN_VERSION")); + errorNames.insert(std::make_pair(1151, "ERROR_APP_WRONG_OS")); + errorNames.insert(std::make_pair(1152, "ERROR_SINGLE_INSTANCE_APP")); + errorNames.insert(std::make_pair(1153, "ERROR_RMODE_APP")); + errorNames.insert(std::make_pair(1154, "ERROR_INVALID_DLL")); + errorNames.insert(std::make_pair(1155, "ERROR_NO_ASSOCIATION")); + errorNames.insert(std::make_pair(1156, "ERROR_DDE_FAIL")); + errorNames.insert(std::make_pair(1157, "ERROR_DLL_NOT_FOUND")); + errorNames.insert(std::make_pair(1158, "ERROR_NO_MORE_USER_HANDLES")); + errorNames.insert(std::make_pair(1159, "ERROR_MESSAGE_SYNC_ONLY")); + errorNames.insert(std::make_pair(1160, "ERROR_SOURCE_ELEMENT_EMPTY")); + errorNames.insert(std::make_pair(1161, "ERROR_DESTINATION_ELEMENT_FULL")); + errorNames.insert(std::make_pair(1162, "ERROR_ILLEGAL_ELEMENT_ADDRESS")); + errorNames.insert(std::make_pair(1163, "ERROR_MAGAZINE_NOT_PRESENT")); + errorNames.insert(std::make_pair(1164, "ERROR_DEVICE_REINITIALIZATION_NEEDED")); + errorNames.insert(std::make_pair(1165, "ERROR_DEVICE_REQUIRES_CLEANING")); + errorNames.insert(std::make_pair(1166, "ERROR_DEVICE_DOOR_OPEN")); + errorNames.insert(std::make_pair(1167, "ERROR_DEVICE_NOT_CONNECTED")); + errorNames.insert(std::make_pair(1168, "ERROR_NOT_FOUND")); + errorNames.insert(std::make_pair(1169, "ERROR_NO_MATCH")); + errorNames.insert(std::make_pair(1170, "ERROR_SET_NOT_FOUND")); + errorNames.insert(std::make_pair(1171, "ERROR_POINT_NOT_FOUND")); + errorNames.insert(std::make_pair(1172, "ERROR_NO_TRACKING_SERVICE")); + errorNames.insert(std::make_pair(1173, "ERROR_NO_VOLUME_ID")); + errorNames.insert(std::make_pair(1175, "ERROR_UNABLE_TO_REMOVE_REPLACED")); + errorNames.insert(std::make_pair(1176, "ERROR_UNABLE_TO_MOVE_REPLACEMENT")); + errorNames.insert(std::make_pair(1177, "ERROR_UNABLE_TO_MOVE_REPLACEMENT_2")); + errorNames.insert(std::make_pair(1178, "ERROR_JOURNAL_DELETE_IN_PROGRESS")); + errorNames.insert(std::make_pair(1179, "ERROR_JOURNAL_NOT_ACTIVE")); + errorNames.insert(std::make_pair(1180, "ERROR_POTENTIAL_FILE_FOUND")); + errorNames.insert(std::make_pair(1181, "ERROR_JOURNAL_ENTRY_DELETED")); + errorNames.insert(std::make_pair(1190, "ERROR_SHUTDOWN_IS_SCHEDULED")); + errorNames.insert(std::make_pair(1191, "ERROR_SHUTDOWN_USERS_LOGGED_ON")); + errorNames.insert(std::make_pair(1200, "ERROR_BAD_DEVICE")); + errorNames.insert(std::make_pair(1201, "ERROR_CONNECTION_UNAVAIL")); + errorNames.insert(std::make_pair(1202, "ERROR_DEVICE_ALREADY_REMEMBERED")); + errorNames.insert(std::make_pair(1203, "ERROR_NO_NET_OR_BAD_PATH")); + errorNames.insert(std::make_pair(1204, "ERROR_BAD_PROVIDER")); + errorNames.insert(std::make_pair(1205, "ERROR_CANNOT_OPEN_PROFILE")); + errorNames.insert(std::make_pair(1206, "ERROR_BAD_PROFILE")); + errorNames.insert(std::make_pair(1207, "ERROR_NOT_CONTAINER")); + errorNames.insert(std::make_pair(1208, "ERROR_EXTENDED_ERROR")); + errorNames.insert(std::make_pair(1209, "ERROR_INVALID_GROUPNAME")); + errorNames.insert(std::make_pair(1210, "ERROR_INVALID_COMPUTERNAME")); + errorNames.insert(std::make_pair(1211, "ERROR_INVALID_EVENTNAME")); + errorNames.insert(std::make_pair(1212, "ERROR_INVALID_DOMAINNAME")); + errorNames.insert(std::make_pair(1213, "ERROR_INVALID_SERVICENAME")); + errorNames.insert(std::make_pair(1214, "ERROR_INVALID_NETNAME")); + errorNames.insert(std::make_pair(1215, "ERROR_INVALID_SHARENAME")); + errorNames.insert(std::make_pair(1216, "ERROR_INVALID_PASSWORDNAME")); + errorNames.insert(std::make_pair(1217, "ERROR_INVALID_MESSAGENAME")); + errorNames.insert(std::make_pair(1218, "ERROR_INVALID_MESSAGEDEST")); + errorNames.insert(std::make_pair(1219, "ERROR_SESSION_CREDENTIAL_CONFLICT")); + errorNames.insert(std::make_pair(1220, "ERROR_REMOTE_SESSION_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(1221, "ERROR_DUP_DOMAINNAME")); + errorNames.insert(std::make_pair(1222, "ERROR_NO_NETWORK")); + errorNames.insert(std::make_pair(1223, "ERROR_CANCELLED")); + errorNames.insert(std::make_pair(1224, "ERROR_USER_MAPPED_FILE")); + errorNames.insert(std::make_pair(1225, "ERROR_CONNECTION_REFUSED")); + errorNames.insert(std::make_pair(1226, "ERROR_GRACEFUL_DISCONNECT")); + errorNames.insert(std::make_pair(1227, "ERROR_ADDRESS_ALREADY_ASSOCIATED")); + errorNames.insert(std::make_pair(1228, "ERROR_ADDRESS_NOT_ASSOCIATED")); + errorNames.insert(std::make_pair(1229, "ERROR_CONNECTION_INVALID")); + errorNames.insert(std::make_pair(1230, "ERROR_CONNECTION_ACTIVE")); + errorNames.insert(std::make_pair(1231, "ERROR_NETWORK_UNREACHABLE")); + errorNames.insert(std::make_pair(1232, "ERROR_HOST_UNREACHABLE")); + errorNames.insert(std::make_pair(1233, "ERROR_PROTOCOL_UNREACHABLE")); + errorNames.insert(std::make_pair(1234, "ERROR_PORT_UNREACHABLE")); + errorNames.insert(std::make_pair(1235, "ERROR_REQUEST_ABORTED")); + errorNames.insert(std::make_pair(1236, "ERROR_CONNECTION_ABORTED")); + errorNames.insert(std::make_pair(1237, "ERROR_RETRY")); + errorNames.insert(std::make_pair(1238, "ERROR_CONNECTION_COUNT_LIMIT")); + errorNames.insert(std::make_pair(1239, "ERROR_LOGIN_TIME_RESTRICTION")); + errorNames.insert(std::make_pair(1240, "ERROR_LOGIN_WKSTA_RESTRICTION")); + errorNames.insert(std::make_pair(1241, "ERROR_INCORRECT_ADDRESS")); + errorNames.insert(std::make_pair(1242, "ERROR_ALREADY_REGISTERED")); + errorNames.insert(std::make_pair(1243, "ERROR_SERVICE_NOT_FOUND")); + errorNames.insert(std::make_pair(1244, "ERROR_NOT_AUTHENTICATED")); + errorNames.insert(std::make_pair(1245, "ERROR_NOT_LOGGED_ON")); + errorNames.insert(std::make_pair(1246, "ERROR_CONTINUE")); + errorNames.insert(std::make_pair(1247, "ERROR_ALREADY_INITIALIZED")); + errorNames.insert(std::make_pair(1248, "ERROR_NO_MORE_DEVICES")); + errorNames.insert(std::make_pair(1249, "ERROR_NO_SUCH_SITE")); + errorNames.insert(std::make_pair(1250, "ERROR_DOMAIN_CONTROLLER_EXISTS")); + errorNames.insert(std::make_pair(1251, "ERROR_ONLY_IF_CONNECTED")); + errorNames.insert(std::make_pair(1252, "ERROR_OVERRIDE_NOCHANGES")); + errorNames.insert(std::make_pair(1253, "ERROR_BAD_USER_PROFILE")); + errorNames.insert(std::make_pair(1254, "ERROR_NOT_SUPPORTED_ON_SBS")); + errorNames.insert(std::make_pair(1255, "ERROR_SERVER_SHUTDOWN_IN_PROGRESS")); + errorNames.insert(std::make_pair(1256, "ERROR_HOST_DOWN")); + errorNames.insert(std::make_pair(1257, "ERROR_NON_ACCOUNT_SID")); + errorNames.insert(std::make_pair(1258, "ERROR_NON_DOMAIN_SID")); + errorNames.insert(std::make_pair(1259, "ERROR_APPHELP_BLOCK")); + errorNames.insert(std::make_pair(1260, "ERROR_ACCESS_DISABLED_BY_POLICY")); + errorNames.insert(std::make_pair(1261, "ERROR_REG_NAT_CONSUMPTION")); + errorNames.insert(std::make_pair(1262, "ERROR_CSCSHARE_OFFLINE")); + errorNames.insert(std::make_pair(1263, "ERROR_PKINIT_FAILURE")); + errorNames.insert(std::make_pair(1264, "ERROR_SMARTCARD_SUBSYSTEM_FAILURE")); + errorNames.insert(std::make_pair(1265, "ERROR_DOWNGRADE_DETECTED")); + errorNames.insert(std::make_pair(1271, "ERROR_MACHINE_LOCKED")); + errorNames.insert(std::make_pair(1273, "ERROR_CALLBACK_SUPPLIED_INVALID_DATA")); + errorNames.insert(std::make_pair(1274, "ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED")); + errorNames.insert(std::make_pair(1275, "ERROR_DRIVER_BLOCKED")); + errorNames.insert(std::make_pair(1276, "ERROR_INVALID_IMPORT_OF_NON_DLL")); + errorNames.insert(std::make_pair(1277, "ERROR_ACCESS_DISABLED_WEBBLADE")); + errorNames.insert(std::make_pair(1278, "ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER")); + errorNames.insert(std::make_pair(1279, "ERROR_RECOVERY_FAILURE")); + errorNames.insert(std::make_pair(1280, "ERROR_ALREADY_FIBER")); + errorNames.insert(std::make_pair(1281, "ERROR_ALREADY_THREAD")); + errorNames.insert(std::make_pair(1282, "ERROR_STACK_BUFFER_OVERRUN")); + errorNames.insert(std::make_pair(1283, "ERROR_PARAMETER_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1284, "ERROR_DEBUGGER_INACTIVE")); + errorNames.insert(std::make_pair(1285, "ERROR_DELAY_LOAD_FAILED")); + errorNames.insert(std::make_pair(1286, "ERROR_VDM_DISALLOWED")); + errorNames.insert(std::make_pair(1287, "ERROR_UNIDENTIFIED_ERROR")); + errorNames.insert(std::make_pair(1288, "ERROR_INVALID_CRUNTIME_PARAMETER")); + errorNames.insert(std::make_pair(1289, "ERROR_BEYOND_VDL")); + errorNames.insert(std::make_pair(1290, "ERROR_INCOMPATIBLE_SERVICE_SID_TYPE")); + errorNames.insert(std::make_pair(1291, "ERROR_DRIVER_PROCESS_TERMINATED")); + errorNames.insert(std::make_pair(1292, "ERROR_IMPLEMENTATION_LIMIT")); + errorNames.insert(std::make_pair(1293, "ERROR_PROCESS_IS_PROTECTED")); + errorNames.insert(std::make_pair(1294, "ERROR_SERVICE_NOTIFY_CLIENT_LAGGING")); + errorNames.insert(std::make_pair(1295, "ERROR_DISK_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1296, "ERROR_CONTENT_BLOCKED")); + errorNames.insert(std::make_pair(1297, "ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE")); + errorNames.insert(std::make_pair(1298, "ERROR_APP_HANG")); + errorNames.insert(std::make_pair(1299, "ERROR_INVALID_LABEL")); + errorNames.insert(std::make_pair(1300, "ERROR_NOT_ALL_ASSIGNED")); + errorNames.insert(std::make_pair(1301, "ERROR_SOME_NOT_MAPPED")); + errorNames.insert(std::make_pair(1302, "ERROR_NO_QUOTAS_FOR_ACCOUNT")); + errorNames.insert(std::make_pair(1303, "ERROR_LOCAL_USER_SESSION_KEY")); + errorNames.insert(std::make_pair(1304, "ERROR_NULL_LM_PASSWORD")); + errorNames.insert(std::make_pair(1305, "ERROR_UNKNOWN_REVISION")); + errorNames.insert(std::make_pair(1306, "ERROR_REVISION_MISMATCH")); + errorNames.insert(std::make_pair(1307, "ERROR_INVALID_OWNER")); + errorNames.insert(std::make_pair(1308, "ERROR_INVALID_PRIMARY_GROUP")); + errorNames.insert(std::make_pair(1309, "ERROR_NO_IMPERSONATION_TOKEN")); + errorNames.insert(std::make_pair(1310, "ERROR_CANT_DISABLE_MANDATORY")); + errorNames.insert(std::make_pair(1311, "ERROR_NO_LOGON_SERVERS")); + errorNames.insert(std::make_pair(1312, "ERROR_NO_SUCH_LOGON_SESSION")); + errorNames.insert(std::make_pair(1313, "ERROR_NO_SUCH_PRIVILEGE")); + errorNames.insert(std::make_pair(1314, "ERROR_PRIVILEGE_NOT_HELD")); + errorNames.insert(std::make_pair(1315, "ERROR_INVALID_ACCOUNT_NAME")); + errorNames.insert(std::make_pair(1316, "ERROR_USER_EXISTS")); + errorNames.insert(std::make_pair(1317, "ERROR_NO_SUCH_USER")); + errorNames.insert(std::make_pair(1318, "ERROR_GROUP_EXISTS")); + errorNames.insert(std::make_pair(1319, "ERROR_NO_SUCH_GROUP")); + errorNames.insert(std::make_pair(1320, "ERROR_MEMBER_IN_GROUP")); + errorNames.insert(std::make_pair(1321, "ERROR_MEMBER_NOT_IN_GROUP")); + errorNames.insert(std::make_pair(1322, "ERROR_LAST_ADMIN")); + errorNames.insert(std::make_pair(1323, "ERROR_WRONG_PASSWORD")); + errorNames.insert(std::make_pair(1324, "ERROR_ILL_FORMED_PASSWORD")); + errorNames.insert(std::make_pair(1325, "ERROR_PASSWORD_RESTRICTION")); + errorNames.insert(std::make_pair(1326, "ERROR_LOGON_FAILURE")); + errorNames.insert(std::make_pair(1327, "ERROR_ACCOUNT_RESTRICTION")); + errorNames.insert(std::make_pair(1328, "ERROR_INVALID_LOGON_HOURS")); + errorNames.insert(std::make_pair(1329, "ERROR_INVALID_WORKSTATION")); + errorNames.insert(std::make_pair(1330, "ERROR_PASSWORD_EXPIRED")); + errorNames.insert(std::make_pair(1331, "ERROR_ACCOUNT_DISABLED")); + errorNames.insert(std::make_pair(1332, "ERROR_NONE_MAPPED")); + errorNames.insert(std::make_pair(1333, "ERROR_TOO_MANY_LUIDS_REQUESTED")); + errorNames.insert(std::make_pair(1334, "ERROR_LUIDS_EXHAUSTED")); + errorNames.insert(std::make_pair(1335, "ERROR_INVALID_SUB_AUTHORITY")); + errorNames.insert(std::make_pair(1336, "ERROR_INVALID_ACL")); + errorNames.insert(std::make_pair(1337, "ERROR_INVALID_SID")); + errorNames.insert(std::make_pair(1338, "ERROR_INVALID_SECURITY_DESCR")); + errorNames.insert(std::make_pair(1340, "ERROR_BAD_INHERITANCE_ACL")); + errorNames.insert(std::make_pair(1341, "ERROR_SERVER_DISABLED")); + errorNames.insert(std::make_pair(1342, "ERROR_SERVER_NOT_DISABLED")); + errorNames.insert(std::make_pair(1343, "ERROR_INVALID_ID_AUTHORITY")); + errorNames.insert(std::make_pair(1344, "ERROR_ALLOTTED_SPACE_EXCEEDED")); + errorNames.insert(std::make_pair(1345, "ERROR_INVALID_GROUP_ATTRIBUTES")); + errorNames.insert(std::make_pair(1346, "ERROR_BAD_IMPERSONATION_LEVEL")); + errorNames.insert(std::make_pair(1347, "ERROR_CANT_OPEN_ANONYMOUS")); + errorNames.insert(std::make_pair(1348, "ERROR_BAD_VALIDATION_CLASS")); + errorNames.insert(std::make_pair(1349, "ERROR_BAD_TOKEN_TYPE")); + errorNames.insert(std::make_pair(1350, "ERROR_NO_SECURITY_ON_OBJECT")); + errorNames.insert(std::make_pair(1351, "ERROR_CANT_ACCESS_DOMAIN_INFO")); + errorNames.insert(std::make_pair(1352, "ERROR_INVALID_SERVER_STATE")); + errorNames.insert(std::make_pair(1353, "ERROR_INVALID_DOMAIN_STATE")); + errorNames.insert(std::make_pair(1354, "ERROR_INVALID_DOMAIN_ROLE")); + errorNames.insert(std::make_pair(1355, "ERROR_NO_SUCH_DOMAIN")); + errorNames.insert(std::make_pair(1356, "ERROR_DOMAIN_EXISTS")); + errorNames.insert(std::make_pair(1357, "ERROR_DOMAIN_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(1358, "ERROR_INTERNAL_DB_CORRUPTION")); + errorNames.insert(std::make_pair(1359, "ERROR_INTERNAL_ERROR")); + errorNames.insert(std::make_pair(1360, "ERROR_GENERIC_NOT_MAPPED")); + errorNames.insert(std::make_pair(1361, "ERROR_BAD_DESCRIPTOR_FORMAT")); + errorNames.insert(std::make_pair(1362, "ERROR_NOT_LOGON_PROCESS")); + errorNames.insert(std::make_pair(1363, "ERROR_LOGON_SESSION_EXISTS")); + errorNames.insert(std::make_pair(1364, "ERROR_NO_SUCH_PACKAGE")); + errorNames.insert(std::make_pair(1365, "ERROR_BAD_LOGON_SESSION_STATE")); + errorNames.insert(std::make_pair(1366, "ERROR_LOGON_SESSION_COLLISION")); + errorNames.insert(std::make_pair(1367, "ERROR_INVALID_LOGON_TYPE")); + errorNames.insert(std::make_pair(1368, "ERROR_CANNOT_IMPERSONATE")); + errorNames.insert(std::make_pair(1369, "ERROR_RXACT_INVALID_STATE")); + errorNames.insert(std::make_pair(1370, "ERROR_RXACT_COMMIT_FAILURE")); + errorNames.insert(std::make_pair(1371, "ERROR_SPECIAL_ACCOUNT")); + errorNames.insert(std::make_pair(1372, "ERROR_SPECIAL_GROUP")); + errorNames.insert(std::make_pair(1373, "ERROR_SPECIAL_USER")); + errorNames.insert(std::make_pair(1374, "ERROR_MEMBERS_PRIMARY_GROUP")); + errorNames.insert(std::make_pair(1375, "ERROR_TOKEN_ALREADY_IN_USE")); + errorNames.insert(std::make_pair(1376, "ERROR_NO_SUCH_ALIAS")); + errorNames.insert(std::make_pair(1377, "ERROR_MEMBER_NOT_IN_ALIAS")); + errorNames.insert(std::make_pair(1378, "ERROR_MEMBER_IN_ALIAS")); + errorNames.insert(std::make_pair(1379, "ERROR_ALIAS_EXISTS")); + errorNames.insert(std::make_pair(1380, "ERROR_LOGON_NOT_GRANTED")); + errorNames.insert(std::make_pair(1381, "ERROR_TOO_MANY_SECRETS")); + errorNames.insert(std::make_pair(1382, "ERROR_SECRET_TOO_LONG")); + errorNames.insert(std::make_pair(1383, "ERROR_INTERNAL_DB_ERROR")); + errorNames.insert(std::make_pair(1384, "ERROR_TOO_MANY_CONTEXT_IDS")); + errorNames.insert(std::make_pair(1385, "ERROR_LOGON_TYPE_NOT_GRANTED")); + errorNames.insert(std::make_pair(1386, "ERROR_NT_CROSS_ENCRYPTION_REQUIRED")); + errorNames.insert(std::make_pair(1387, "ERROR_NO_SUCH_MEMBER")); + errorNames.insert(std::make_pair(1388, "ERROR_INVALID_MEMBER")); + errorNames.insert(std::make_pair(1389, "ERROR_TOO_MANY_SIDS")); + errorNames.insert(std::make_pair(1390, "ERROR_LM_CROSS_ENCRYPTION_REQUIRED")); + errorNames.insert(std::make_pair(1391, "ERROR_NO_INHERITANCE")); + errorNames.insert(std::make_pair(1392, "ERROR_FILE_CORRUPT")); + errorNames.insert(std::make_pair(1393, "ERROR_DISK_CORRUPT")); + errorNames.insert(std::make_pair(1394, "ERROR_NO_USER_SESSION_KEY")); + errorNames.insert(std::make_pair(1395, "ERROR_LICENSE_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1396, "ERROR_WRONG_TARGET_NAME")); + errorNames.insert(std::make_pair(1397, "ERROR_MUTUAL_AUTH_FAILED")); + errorNames.insert(std::make_pair(1398, "ERROR_TIME_SKEW")); + errorNames.insert(std::make_pair(1399, "ERROR_CURRENT_DOMAIN_NOT_ALLOWED")); + errorNames.insert(std::make_pair(1400, "ERROR_INVALID_WINDOW_HANDLE")); + errorNames.insert(std::make_pair(1401, "ERROR_INVALID_MENU_HANDLE")); + errorNames.insert(std::make_pair(1402, "ERROR_INVALID_CURSOR_HANDLE")); + errorNames.insert(std::make_pair(1403, "ERROR_INVALID_ACCEL_HANDLE")); + errorNames.insert(std::make_pair(1404, "ERROR_INVALID_HOOK_HANDLE")); + errorNames.insert(std::make_pair(1405, "ERROR_INVALID_DWP_HANDLE")); + errorNames.insert(std::make_pair(1406, "ERROR_TLW_WITH_WSCHILD")); + errorNames.insert(std::make_pair(1407, "ERROR_CANNOT_FIND_WND_CLASS")); + errorNames.insert(std::make_pair(1408, "ERROR_WINDOW_OF_OTHER_THREAD")); + errorNames.insert(std::make_pair(1409, "ERROR_HOTKEY_ALREADY_REGISTERED")); + errorNames.insert(std::make_pair(1410, "ERROR_CLASS_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(1411, "ERROR_CLASS_DOES_NOT_EXIST")); + errorNames.insert(std::make_pair(1412, "ERROR_CLASS_HAS_WINDOWS")); + errorNames.insert(std::make_pair(1413, "ERROR_INVALID_INDEX")); + errorNames.insert(std::make_pair(1414, "ERROR_INVALID_ICON_HANDLE")); + errorNames.insert(std::make_pair(1415, "ERROR_PRIVATE_DIALOG_INDEX")); + errorNames.insert(std::make_pair(1416, "ERROR_LISTBOX_ID_NOT_FOUND")); + errorNames.insert(std::make_pair(1417, "ERROR_NO_WILDCARD_CHARACTERS")); + errorNames.insert(std::make_pair(1418, "ERROR_CLIPBOARD_NOT_OPEN")); + errorNames.insert(std::make_pair(1419, "ERROR_HOTKEY_NOT_REGISTERED")); + errorNames.insert(std::make_pair(1420, "ERROR_WINDOW_NOT_DIALOG")); + errorNames.insert(std::make_pair(1421, "ERROR_CONTROL_ID_NOT_FOUND")); + errorNames.insert(std::make_pair(1422, "ERROR_INVALID_COMBOBOX_MESSAGE")); + errorNames.insert(std::make_pair(1423, "ERROR_WINDOW_NOT_COMBOBOX")); + errorNames.insert(std::make_pair(1424, "ERROR_INVALID_EDIT_HEIGHT")); + errorNames.insert(std::make_pair(1425, "ERROR_DC_NOT_FOUND")); + errorNames.insert(std::make_pair(1426, "ERROR_INVALID_HOOK_FILTER")); + errorNames.insert(std::make_pair(1427, "ERROR_INVALID_FILTER_PROC")); + errorNames.insert(std::make_pair(1428, "ERROR_HOOK_NEEDS_HMOD")); + errorNames.insert(std::make_pair(1429, "ERROR_GLOBAL_ONLY_HOOK")); + errorNames.insert(std::make_pair(1430, "ERROR_JOURNAL_HOOK_SET")); + errorNames.insert(std::make_pair(1431, "ERROR_HOOK_NOT_INSTALLED")); + errorNames.insert(std::make_pair(1432, "ERROR_INVALID_LB_MESSAGE")); + errorNames.insert(std::make_pair(1433, "ERROR_SETCOUNT_ON_BAD_LB")); + errorNames.insert(std::make_pair(1434, "ERROR_LB_WITHOUT_TABSTOPS")); + errorNames.insert(std::make_pair(1435, "ERROR_DESTROY_OBJECT_OF_OTHER_THREAD")); + errorNames.insert(std::make_pair(1436, "ERROR_CHILD_WINDOW_MENU")); + errorNames.insert(std::make_pair(1437, "ERROR_NO_SYSTEM_MENU")); + errorNames.insert(std::make_pair(1438, "ERROR_INVALID_MSGBOX_STYLE")); + errorNames.insert(std::make_pair(1439, "ERROR_INVALID_SPI_VALUE")); + errorNames.insert(std::make_pair(1440, "ERROR_SCREEN_ALREADY_LOCKED")); + errorNames.insert(std::make_pair(1441, "ERROR_HWNDS_HAVE_DIFF_PARENT")); + errorNames.insert(std::make_pair(1442, "ERROR_NOT_CHILD_WINDOW")); + errorNames.insert(std::make_pair(1443, "ERROR_INVALID_GW_COMMAND")); + errorNames.insert(std::make_pair(1444, "ERROR_INVALID_THREAD_ID")); + errorNames.insert(std::make_pair(1445, "ERROR_NON_MDICHILD_WINDOW")); + errorNames.insert(std::make_pair(1446, "ERROR_POPUP_ALREADY_ACTIVE")); + errorNames.insert(std::make_pair(1447, "ERROR_NO_SCROLLBARS")); + errorNames.insert(std::make_pair(1448, "ERROR_INVALID_SCROLLBAR_RANGE")); + errorNames.insert(std::make_pair(1449, "ERROR_INVALID_SHOWWIN_COMMAND")); + errorNames.insert(std::make_pair(1450, "ERROR_NO_SYSTEM_RESOURCES")); + errorNames.insert(std::make_pair(1451, "ERROR_NONPAGED_SYSTEM_RESOURCES")); + errorNames.insert(std::make_pair(1452, "ERROR_PAGED_SYSTEM_RESOURCES")); + errorNames.insert(std::make_pair(1453, "ERROR_WORKING_SET_QUOTA")); + errorNames.insert(std::make_pair(1454, "ERROR_PAGEFILE_QUOTA")); + errorNames.insert(std::make_pair(1455, "ERROR_COMMITMENT_LIMIT")); + errorNames.insert(std::make_pair(1456, "ERROR_MENU_ITEM_NOT_FOUND")); + errorNames.insert(std::make_pair(1457, "ERROR_INVALID_KEYBOARD_HANDLE")); + errorNames.insert(std::make_pair(1458, "ERROR_HOOK_TYPE_NOT_ALLOWED")); + errorNames.insert(std::make_pair(1459, "ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION")); + errorNames.insert(std::make_pair(1460, "ERROR_TIMEOUT")); + errorNames.insert(std::make_pair(1461, "ERROR_INVALID_MONITOR_HANDLE")); + errorNames.insert(std::make_pair(1462, "ERROR_INCORRECT_SIZE")); + errorNames.insert(std::make_pair(1463, "ERROR_SYMLINK_CLASS_DISABLED")); + errorNames.insert(std::make_pair(1464, "ERROR_SYMLINK_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(1465, "ERROR_XML_PARSE_ERROR")); + errorNames.insert(std::make_pair(1466, "ERROR_XMLDSIG_ERROR")); + errorNames.insert(std::make_pair(1467, "ERROR_RESTART_APPLICATION")); + errorNames.insert(std::make_pair(1468, "ERROR_WRONG_COMPARTMENT")); + errorNames.insert(std::make_pair(1469, "ERROR_AUTHIP_FAILURE")); + errorNames.insert(std::make_pair(1470, "ERROR_NO_NVRAM_RESOURCES")); + errorNames.insert(std::make_pair(1500, "ERROR_EVENTLOG_FILE_CORRUPT")); + errorNames.insert(std::make_pair(1501, "ERROR_EVENTLOG_CANT_START")); + errorNames.insert(std::make_pair(1502, "ERROR_LOG_FILE_FULL")); + errorNames.insert(std::make_pair(1503, "ERROR_EVENTLOG_FILE_CHANGED")); + errorNames.insert(std::make_pair(1550, "ERROR_INVALID_TASK_NAME")); + errorNames.insert(std::make_pair(1551, "ERROR_INVALID_TASK_INDEX")); + errorNames.insert(std::make_pair(1552, "ERROR_THREAD_ALREADY_IN_TASK")); + errorNames.insert(std::make_pair(1601, "ERROR_INSTALL_SERVICE_FAILURE")); + errorNames.insert(std::make_pair(1602, "ERROR_INSTALL_USEREXIT")); + errorNames.insert(std::make_pair(1603, "ERROR_INSTALL_FAILURE")); + errorNames.insert(std::make_pair(1604, "ERROR_INSTALL_SUSPEND")); + errorNames.insert(std::make_pair(1605, "ERROR_UNKNOWN_PRODUCT")); + errorNames.insert(std::make_pair(1606, "ERROR_UNKNOWN_FEATURE")); + errorNames.insert(std::make_pair(1607, "ERROR_UNKNOWN_COMPONENT")); + errorNames.insert(std::make_pair(1608, "ERROR_UNKNOWN_PROPERTY")); + errorNames.insert(std::make_pair(1609, "ERROR_INVALID_HANDLE_STATE")); + errorNames.insert(std::make_pair(1610, "ERROR_BAD_CONFIGURATION")); + errorNames.insert(std::make_pair(1611, "ERROR_INDEX_ABSENT")); + errorNames.insert(std::make_pair(1612, "ERROR_INSTALL_SOURCE_ABSENT")); + errorNames.insert(std::make_pair(1613, "ERROR_INSTALL_PACKAGE_VERSION")); + errorNames.insert(std::make_pair(1614, "ERROR_PRODUCT_UNINSTALLED")); + errorNames.insert(std::make_pair(1615, "ERROR_BAD_QUERY_SYNTAX")); + errorNames.insert(std::make_pair(1616, "ERROR_INVALID_FIELD")); + errorNames.insert(std::make_pair(1617, "ERROR_DEVICE_REMOVED")); + errorNames.insert(std::make_pair(1618, "ERROR_INSTALL_ALREADY_RUNNING")); + errorNames.insert(std::make_pair(1619, "ERROR_INSTALL_PACKAGE_OPEN_FAILED")); + errorNames.insert(std::make_pair(1620, "ERROR_INSTALL_PACKAGE_INVALID")); + errorNames.insert(std::make_pair(1621, "ERROR_INSTALL_UI_FAILURE")); + errorNames.insert(std::make_pair(1622, "ERROR_INSTALL_LOG_FAILURE")); + errorNames.insert(std::make_pair(1623, "ERROR_INSTALL_LANGUAGE_UNSUPPORTED")); + errorNames.insert(std::make_pair(1624, "ERROR_INSTALL_TRANSFORM_FAILURE")); + errorNames.insert(std::make_pair(1625, "ERROR_INSTALL_PACKAGE_REJECTED")); + errorNames.insert(std::make_pair(1626, "ERROR_FUNCTION_NOT_CALLED")); + errorNames.insert(std::make_pair(1627, "ERROR_FUNCTION_FAILED")); + errorNames.insert(std::make_pair(1628, "ERROR_INVALID_TABLE")); + errorNames.insert(std::make_pair(1629, "ERROR_DATATYPE_MISMATCH")); + errorNames.insert(std::make_pair(1630, "ERROR_UNSUPPORTED_TYPE")); + errorNames.insert(std::make_pair(1631, "ERROR_CREATE_FAILED")); + errorNames.insert(std::make_pair(1632, "ERROR_INSTALL_TEMP_UNWRITABLE")); + errorNames.insert(std::make_pair(1633, "ERROR_INSTALL_PLATFORM_UNSUPPORTED")); + errorNames.insert(std::make_pair(1634, "ERROR_INSTALL_NOTUSED")); + errorNames.insert(std::make_pair(1635, "ERROR_PATCH_PACKAGE_OPEN_FAILED")); + errorNames.insert(std::make_pair(1636, "ERROR_PATCH_PACKAGE_INVALID")); + errorNames.insert(std::make_pair(1637, "ERROR_PATCH_PACKAGE_UNSUPPORTED")); + errorNames.insert(std::make_pair(1638, "ERROR_PRODUCT_VERSION")); + errorNames.insert(std::make_pair(1639, "ERROR_INVALID_COMMAND_LINE")); + errorNames.insert(std::make_pair(1640, "ERROR_INSTALL_REMOTE_DISALLOWED")); + errorNames.insert(std::make_pair(1641, "ERROR_SUCCESS_REBOOT_INITIATED")); + errorNames.insert(std::make_pair(1642, "ERROR_PATCH_TARGET_NOT_FOUND")); + errorNames.insert(std::make_pair(1643, "ERROR_PATCH_PACKAGE_REJECTED")); + errorNames.insert(std::make_pair(1644, "ERROR_INSTALL_TRANSFORM_REJECTED")); + errorNames.insert(std::make_pair(1645, "ERROR_INSTALL_REMOTE_PROHIBITED")); + errorNames.insert(std::make_pair(1646, "ERROR_PATCH_REMOVAL_UNSUPPORTED")); + errorNames.insert(std::make_pair(1647, "ERROR_UNKNOWN_PATCH")); + errorNames.insert(std::make_pair(1648, "ERROR_PATCH_NO_SEQUENCE")); + errorNames.insert(std::make_pair(1649, "ERROR_PATCH_REMOVAL_DISALLOWED")); + errorNames.insert(std::make_pair(1650, "ERROR_INVALID_PATCH_XML")); + errorNames.insert(std::make_pair(1651, "ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT")); + errorNames.insert(std::make_pair(1652, "ERROR_INSTALL_SERVICE_SAFEBOOT")); + errorNames.insert(std::make_pair(1653, "ERROR_FAIL_FAST_EXCEPTION")); + errorNames.insert(std::make_pair(1784, "ERROR_INVALID_USER_BUFFER")); + errorNames.insert(std::make_pair(1785, "ERROR_UNRECOGNIZED_MEDIA")); + errorNames.insert(std::make_pair(1786, "ERROR_NO_TRUST_LSA_SECRET")); + errorNames.insert(std::make_pair(1787, "ERROR_NO_TRUST_SAM_ACCOUNT")); + errorNames.insert(std::make_pair(1788, "ERROR_TRUSTED_DOMAIN_FAILURE")); + errorNames.insert(std::make_pair(1789, "ERROR_TRUSTED_RELATIONSHIP_FAILURE")); + errorNames.insert(std::make_pair(1790, "ERROR_TRUST_FAILURE")); + errorNames.insert(std::make_pair(1792, "ERROR_NETLOGON_NOT_STARTED")); + errorNames.insert(std::make_pair(1793, "ERROR_ACCOUNT_EXPIRED")); + errorNames.insert(std::make_pair(1794, "ERROR_REDIRECTOR_HAS_OPEN_HANDLES")); + errorNames.insert(std::make_pair(1795, "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(1796, "ERROR_UNKNOWN_PORT")); + errorNames.insert(std::make_pair(1797, "ERROR_UNKNOWN_PRINTER_DRIVER")); + errorNames.insert(std::make_pair(1798, "ERROR_UNKNOWN_PRINTPROCESSOR")); + errorNames.insert(std::make_pair(1799, "ERROR_INVALID_SEPARATOR_FILE")); + errorNames.insert(std::make_pair(1800, "ERROR_INVALID_PRIORITY")); + errorNames.insert(std::make_pair(1801, "ERROR_INVALID_PRINTER_NAME")); + errorNames.insert(std::make_pair(1802, "ERROR_PRINTER_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(1803, "ERROR_INVALID_PRINTER_COMMAND")); + errorNames.insert(std::make_pair(1804, "ERROR_INVALID_DATATYPE")); + errorNames.insert(std::make_pair(1805, "ERROR_INVALID_ENVIRONMENT")); + errorNames.insert(std::make_pair(1807, "ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT")); + errorNames.insert(std::make_pair(1808, "ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT")); + errorNames.insert(std::make_pair(1809, "ERROR_NOLOGON_SERVER_TRUST_ACCOUNT")); + errorNames.insert(std::make_pair(1810, "ERROR_DOMAIN_TRUST_INCONSISTENT")); + errorNames.insert(std::make_pair(1811, "ERROR_SERVER_HAS_OPEN_HANDLES")); + errorNames.insert(std::make_pair(1812, "ERROR_RESOURCE_DATA_NOT_FOUND")); + errorNames.insert(std::make_pair(1813, "ERROR_RESOURCE_TYPE_NOT_FOUND")); + errorNames.insert(std::make_pair(1814, "ERROR_RESOURCE_NAME_NOT_FOUND")); + errorNames.insert(std::make_pair(1815, "ERROR_RESOURCE_LANG_NOT_FOUND")); + errorNames.insert(std::make_pair(1816, "ERROR_NOT_ENOUGH_QUOTA")); + errorNames.insert(std::make_pair(1901, "ERROR_INVALID_TIME")); + errorNames.insert(std::make_pair(1902, "ERROR_INVALID_FORM_NAME")); + errorNames.insert(std::make_pair(1903, "ERROR_INVALID_FORM_SIZE")); + errorNames.insert(std::make_pair(1904, "ERROR_ALREADY_WAITING")); + errorNames.insert(std::make_pair(1905, "ERROR_PRINTER_DELETED")); + errorNames.insert(std::make_pair(1906, "ERROR_INVALID_PRINTER_STATE")); + errorNames.insert(std::make_pair(1907, "ERROR_PASSWORD_MUST_CHANGE")); + errorNames.insert(std::make_pair(1908, "ERROR_DOMAIN_CONTROLLER_NOT_FOUND")); + errorNames.insert(std::make_pair(1909, "ERROR_ACCOUNT_LOCKED_OUT")); + errorNames.insert(std::make_pair(1919, "ERROR_NO_SITENAME")); + errorNames.insert(std::make_pair(1920, "ERROR_CANT_ACCESS_FILE")); + errorNames.insert(std::make_pair(1921, "ERROR_CANT_RESOLVE_FILENAME")); + errorNames.insert(std::make_pair(1930, "ERROR_KM_DRIVER_BLOCKED")); + errorNames.insert(std::make_pair(1931, "ERROR_CONTEXT_EXPIRED")); + errorNames.insert(std::make_pair(1932, "ERROR_PER_USER_TRUST_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1933, "ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1934, "ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1935, "ERROR_AUTHENTICATION_FIREWALL_FAILED")); + errorNames.insert(std::make_pair(1936, "ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED")); + errorNames.insert(std::make_pair(1937, "ERROR_NTLM_BLOCKED")); + errorNames.insert(std::make_pair(2000, "ERROR_INVALID_PIXEL_FORMAT")); + errorNames.insert(std::make_pair(2001, "ERROR_BAD_DRIVER")); + errorNames.insert(std::make_pair(2002, "ERROR_INVALID_WINDOW_STYLE")); + errorNames.insert(std::make_pair(2003, "ERROR_METAFILE_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(2004, "ERROR_TRANSFORM_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(2005, "ERROR_CLIPPING_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(2010, "ERROR_INVALID_CMM")); + errorNames.insert(std::make_pair(2011, "ERROR_INVALID_PROFILE")); + errorNames.insert(std::make_pair(2012, "ERROR_TAG_NOT_FOUND")); + errorNames.insert(std::make_pair(2013, "ERROR_TAG_NOT_PRESENT")); + errorNames.insert(std::make_pair(2014, "ERROR_DUPLICATE_TAG")); + errorNames.insert(std::make_pair(2015, "ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE")); + errorNames.insert(std::make_pair(2016, "ERROR_PROFILE_NOT_FOUND")); + errorNames.insert(std::make_pair(2017, "ERROR_INVALID_COLORSPACE")); + errorNames.insert(std::make_pair(2018, "ERROR_ICM_NOT_ENABLED")); + errorNames.insert(std::make_pair(2019, "ERROR_DELETING_ICM_XFORM")); + errorNames.insert(std::make_pair(2020, "ERROR_INVALID_TRANSFORM")); + errorNames.insert(std::make_pair(2021, "ERROR_COLORSPACE_MISMATCH")); + errorNames.insert(std::make_pair(2022, "ERROR_INVALID_COLORINDEX")); + errorNames.insert(std::make_pair(2023, "ERROR_PROFILE_DOES_NOT_MATCH_DEVICE")); + errorNames.insert(std::make_pair(2108, "ERROR_CONNECTED_OTHER_PASSWORD")); + errorNames.insert(std::make_pair(2109, "ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT")); + errorNames.insert(std::make_pair(2202, "ERROR_BAD_USERNAME")); + errorNames.insert(std::make_pair(2250, "ERROR_NOT_CONNECTED")); + errorNames.insert(std::make_pair(2401, "ERROR_OPEN_FILES")); + errorNames.insert(std::make_pair(2402, "ERROR_ACTIVE_CONNECTIONS")); + errorNames.insert(std::make_pair(2404, "ERROR_DEVICE_IN_USE")); + errorNames.insert(std::make_pair(3000, "ERROR_UNKNOWN_PRINT_MONITOR")); + errorNames.insert(std::make_pair(3001, "ERROR_PRINTER_DRIVER_IN_USE")); + errorNames.insert(std::make_pair(3002, "ERROR_SPOOL_FILE_NOT_FOUND")); + errorNames.insert(std::make_pair(3003, "ERROR_SPL_NO_STARTDOC")); + errorNames.insert(std::make_pair(3004, "ERROR_SPL_NO_ADDJOB")); + errorNames.insert(std::make_pair(3005, "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(3006, "ERROR_PRINT_MONITOR_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(3007, "ERROR_INVALID_PRINT_MONITOR")); + errorNames.insert(std::make_pair(3008, "ERROR_PRINT_MONITOR_IN_USE")); + errorNames.insert(std::make_pair(3009, "ERROR_PRINTER_HAS_JOBS_QUEUED")); + errorNames.insert(std::make_pair(3010, "ERROR_SUCCESS_REBOOT_REQUIRED")); + errorNames.insert(std::make_pair(3011, "ERROR_SUCCESS_RESTART_REQUIRED")); + errorNames.insert(std::make_pair(3012, "ERROR_PRINTER_NOT_FOUND")); + errorNames.insert(std::make_pair(3013, "ERROR_PRINTER_DRIVER_WARNED")); + errorNames.insert(std::make_pair(3014, "ERROR_PRINTER_DRIVER_BLOCKED")); + errorNames.insert(std::make_pair(3015, "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE")); + errorNames.insert(std::make_pair(3016, "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND")); + errorNames.insert(std::make_pair(3017, "ERROR_FAIL_REBOOT_REQUIRED")); + errorNames.insert(std::make_pair(3018, "ERROR_FAIL_REBOOT_INITIATED")); + errorNames.insert(std::make_pair(3019, "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED")); + errorNames.insert(std::make_pair(3020, "ERROR_PRINT_JOB_RESTART_REQUIRED")); + errorNames.insert(std::make_pair(3950, "ERROR_IO_REISSUE_AS_CACHED")); + errorNames.insert(std::make_pair(4000, "ERROR_WINS_INTERNAL")); + errorNames.insert(std::make_pair(4001, "ERROR_CAN_NOT_DEL_LOCAL_WINS")); + errorNames.insert(std::make_pair(4002, "ERROR_STATIC_INIT")); + errorNames.insert(std::make_pair(4003, "ERROR_INC_BACKUP")); + errorNames.insert(std::make_pair(4004, "ERROR_FULL_BACKUP")); + errorNames.insert(std::make_pair(4005, "ERROR_REC_NON_EXISTENT")); + errorNames.insert(std::make_pair(4006, "ERROR_RPL_NOT_ALLOWED")); + errorNames.insert(std::make_pair(4100, "ERROR_DHCP_ADDRESS_CONFLICT")); + errorNames.insert(std::make_pair(4200, "ERROR_WMI_GUID_NOT_FOUND")); + errorNames.insert(std::make_pair(4201, "ERROR_WMI_INSTANCE_NOT_FOUND")); + errorNames.insert(std::make_pair(4202, "ERROR_WMI_ITEMID_NOT_FOUND")); + errorNames.insert(std::make_pair(4203, "ERROR_WMI_TRY_AGAIN")); + errorNames.insert(std::make_pair(4204, "ERROR_WMI_DP_NOT_FOUND")); + errorNames.insert(std::make_pair(4205, "ERROR_WMI_UNRESOLVED_INSTANCE_REF")); + errorNames.insert(std::make_pair(4206, "ERROR_WMI_ALREADY_ENABLED")); + errorNames.insert(std::make_pair(4207, "ERROR_WMI_GUID_DISCONNECTED")); + errorNames.insert(std::make_pair(4208, "ERROR_WMI_SERVER_UNAVAILABLE")); + errorNames.insert(std::make_pair(4209, "ERROR_WMI_DP_FAILED")); + errorNames.insert(std::make_pair(4210, "ERROR_WMI_INVALID_MOF")); + errorNames.insert(std::make_pair(4211, "ERROR_WMI_INVALID_REGINFO")); + errorNames.insert(std::make_pair(4212, "ERROR_WMI_ALREADY_DISABLED")); + errorNames.insert(std::make_pair(4213, "ERROR_WMI_READ_ONLY")); + errorNames.insert(std::make_pair(4214, "ERROR_WMI_SET_FAILURE")); + errorNames.insert(std::make_pair(4300, "ERROR_INVALID_MEDIA")); + errorNames.insert(std::make_pair(4301, "ERROR_INVALID_LIBRARY")); + errorNames.insert(std::make_pair(4302, "ERROR_INVALID_MEDIA_POOL")); + errorNames.insert(std::make_pair(4303, "ERROR_DRIVE_MEDIA_MISMATCH")); + errorNames.insert(std::make_pair(4304, "ERROR_MEDIA_OFFLINE")); + errorNames.insert(std::make_pair(4305, "ERROR_LIBRARY_OFFLINE")); + errorNames.insert(std::make_pair(4306, "ERROR_EMPTY")); + errorNames.insert(std::make_pair(4307, "ERROR_NOT_EMPTY")); + errorNames.insert(std::make_pair(4308, "ERROR_MEDIA_UNAVAILABLE")); + errorNames.insert(std::make_pair(4309, "ERROR_RESOURCE_DISABLED")); + errorNames.insert(std::make_pair(4310, "ERROR_INVALID_CLEANER")); + errorNames.insert(std::make_pair(4311, "ERROR_UNABLE_TO_CLEAN")); + errorNames.insert(std::make_pair(4312, "ERROR_OBJECT_NOT_FOUND")); + errorNames.insert(std::make_pair(4313, "ERROR_DATABASE_FAILURE")); + errorNames.insert(std::make_pair(4314, "ERROR_DATABASE_FULL")); + errorNames.insert(std::make_pair(4315, "ERROR_MEDIA_INCOMPATIBLE")); + errorNames.insert(std::make_pair(4316, "ERROR_RESOURCE_NOT_PRESENT")); + errorNames.insert(std::make_pair(4317, "ERROR_INVALID_OPERATION")); + errorNames.insert(std::make_pair(4318, "ERROR_MEDIA_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(4319, "ERROR_DEVICE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(4320, "ERROR_REQUEST_REFUSED")); + errorNames.insert(std::make_pair(4321, "ERROR_INVALID_DRIVE_OBJECT")); + errorNames.insert(std::make_pair(4322, "ERROR_LIBRARY_FULL")); + errorNames.insert(std::make_pair(4323, "ERROR_MEDIUM_NOT_ACCESSIBLE")); + errorNames.insert(std::make_pair(4324, "ERROR_UNABLE_TO_LOAD_MEDIUM")); + errorNames.insert(std::make_pair(4325, "ERROR_UNABLE_TO_INVENTORY_DRIVE")); + errorNames.insert(std::make_pair(4326, "ERROR_UNABLE_TO_INVENTORY_SLOT")); + errorNames.insert(std::make_pair(4327, "ERROR_UNABLE_TO_INVENTORY_TRANSPORT")); + errorNames.insert(std::make_pair(4328, "ERROR_TRANSPORT_FULL")); + errorNames.insert(std::make_pair(4329, "ERROR_CONTROLLING_IEPORT")); + errorNames.insert(std::make_pair(4330, "ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA")); + errorNames.insert(std::make_pair(4331, "ERROR_CLEANER_SLOT_SET")); + errorNames.insert(std::make_pair(4332, "ERROR_CLEANER_SLOT_NOT_SET")); + errorNames.insert(std::make_pair(4333, "ERROR_CLEANER_CARTRIDGE_SPENT")); + errorNames.insert(std::make_pair(4334, "ERROR_UNEXPECTED_OMID")); + errorNames.insert(std::make_pair(4335, "ERROR_CANT_DELETE_LAST_ITEM")); + errorNames.insert(std::make_pair(4336, "ERROR_MESSAGE_EXCEEDS_MAX_SIZE")); + errorNames.insert(std::make_pair(4337, "ERROR_VOLUME_CONTAINS_SYS_FILES")); + errorNames.insert(std::make_pair(4338, "ERROR_INDIGENOUS_TYPE")); + errorNames.insert(std::make_pair(4339, "ERROR_NO_SUPPORTING_DRIVES")); + errorNames.insert(std::make_pair(4340, "ERROR_CLEANER_CARTRIDGE_INSTALLED")); + errorNames.insert(std::make_pair(4341, "ERROR_IEPORT_FULL")); + errorNames.insert(std::make_pair(4350, "ERROR_FILE_OFFLINE")); + errorNames.insert(std::make_pair(4351, "ERROR_REMOTE_STORAGE_NOT_ACTIVE")); + errorNames.insert(std::make_pair(4352, "ERROR_REMOTE_STORAGE_MEDIA_ERROR")); + errorNames.insert(std::make_pair(4390, "ERROR_NOT_A_REPARSE_POINT")); + errorNames.insert(std::make_pair(4391, "ERROR_REPARSE_ATTRIBUTE_CONFLICT")); + errorNames.insert(std::make_pair(4392, "ERROR_INVALID_REPARSE_DATA")); + errorNames.insert(std::make_pair(4393, "ERROR_REPARSE_TAG_INVALID")); + errorNames.insert(std::make_pair(4394, "ERROR_REPARSE_TAG_MISMATCH")); + errorNames.insert(std::make_pair(4500, "ERROR_VOLUME_NOT_SIS_ENABLED")); + errorNames.insert(std::make_pair(5001, "ERROR_DEPENDENT_RESOURCE_EXISTS")); + errorNames.insert(std::make_pair(5002, "ERROR_DEPENDENCY_NOT_FOUND")); + errorNames.insert(std::make_pair(5003, "ERROR_DEPENDENCY_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(5004, "ERROR_RESOURCE_NOT_ONLINE")); + errorNames.insert(std::make_pair(5005, "ERROR_HOST_NODE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5006, "ERROR_RESOURCE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5007, "ERROR_RESOURCE_NOT_FOUND")); + errorNames.insert(std::make_pair(5008, "ERROR_SHUTDOWN_CLUSTER")); + errorNames.insert(std::make_pair(5009, "ERROR_CANT_EVICT_ACTIVE_NODE")); + errorNames.insert(std::make_pair(5010, "ERROR_OBJECT_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(5011, "ERROR_OBJECT_IN_LIST")); + errorNames.insert(std::make_pair(5012, "ERROR_GROUP_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5013, "ERROR_GROUP_NOT_FOUND")); + errorNames.insert(std::make_pair(5014, "ERROR_GROUP_NOT_ONLINE")); + errorNames.insert(std::make_pair(5015, "ERROR_HOST_NODE_NOT_RESOURCE_OWNER")); + errorNames.insert(std::make_pair(5016, "ERROR_HOST_NODE_NOT_GROUP_OWNER")); + errorNames.insert(std::make_pair(5017, "ERROR_RESMON_CREATE_FAILED")); + errorNames.insert(std::make_pair(5018, "ERROR_RESMON_ONLINE_FAILED")); + errorNames.insert(std::make_pair(5019, "ERROR_RESOURCE_ONLINE")); + errorNames.insert(std::make_pair(5020, "ERROR_QUORUM_RESOURCE")); + errorNames.insert(std::make_pair(5021, "ERROR_NOT_QUORUM_CAPABLE")); + errorNames.insert(std::make_pair(5022, "ERROR_CLUSTER_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(5023, "ERROR_INVALID_STATE")); + errorNames.insert(std::make_pair(5024, "ERROR_RESOURCE_PROPERTIES_STORED")); + errorNames.insert(std::make_pair(5025, "ERROR_NOT_QUORUM_CLASS")); + errorNames.insert(std::make_pair(5026, "ERROR_CORE_RESOURCE")); + errorNames.insert(std::make_pair(5027, "ERROR_QUORUM_RESOURCE_ONLINE_FAILED")); + errorNames.insert(std::make_pair(5028, "ERROR_QUORUMLOG_OPEN_FAILED")); + errorNames.insert(std::make_pair(5029, "ERROR_CLUSTERLOG_CORRUPT")); + errorNames.insert(std::make_pair(5030, "ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE")); + errorNames.insert(std::make_pair(5031, "ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE")); + errorNames.insert(std::make_pair(5032, "ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND")); + errorNames.insert(std::make_pair(5033, "ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE")); + errorNames.insert(std::make_pair(5034, "ERROR_QUORUM_OWNER_ALIVE")); + errorNames.insert(std::make_pair(5035, "ERROR_NETWORK_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5036, "ERROR_NODE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5037, "ERROR_ALL_NODES_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5038, "ERROR_RESOURCE_FAILED")); + errorNames.insert(std::make_pair(5039, "ERROR_CLUSTER_INVALID_NODE")); + errorNames.insert(std::make_pair(5040, "ERROR_CLUSTER_NODE_EXISTS")); + errorNames.insert(std::make_pair(5041, "ERROR_CLUSTER_JOIN_IN_PROGRESS")); + errorNames.insert(std::make_pair(5042, "ERROR_CLUSTER_NODE_NOT_FOUND")); + errorNames.insert(std::make_pair(5043, "ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND")); + errorNames.insert(std::make_pair(5044, "ERROR_CLUSTER_NETWORK_EXISTS")); + errorNames.insert(std::make_pair(5045, "ERROR_CLUSTER_NETWORK_NOT_FOUND")); + errorNames.insert(std::make_pair(5046, "ERROR_CLUSTER_NETINTERFACE_EXISTS")); + errorNames.insert(std::make_pair(5047, "ERROR_CLUSTER_NETINTERFACE_NOT_FOUND")); + errorNames.insert(std::make_pair(5048, "ERROR_CLUSTER_INVALID_REQUEST")); + errorNames.insert(std::make_pair(5049, "ERROR_CLUSTER_INVALID_NETWORK_PROVIDER")); + errorNames.insert(std::make_pair(5050, "ERROR_CLUSTER_NODE_DOWN")); + errorNames.insert(std::make_pair(5051, "ERROR_CLUSTER_NODE_UNREACHABLE")); + errorNames.insert(std::make_pair(5052, "ERROR_CLUSTER_NODE_NOT_MEMBER")); + errorNames.insert(std::make_pair(5053, "ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS")); + errorNames.insert(std::make_pair(5054, "ERROR_CLUSTER_INVALID_NETWORK")); + errorNames.insert(std::make_pair(5056, "ERROR_CLUSTER_NODE_UP")); + errorNames.insert(std::make_pair(5057, "ERROR_CLUSTER_IPADDR_IN_USE")); + errorNames.insert(std::make_pair(5058, "ERROR_CLUSTER_NODE_NOT_PAUSED")); + errorNames.insert(std::make_pair(5059, "ERROR_CLUSTER_NO_SECURITY_CONTEXT")); + errorNames.insert(std::make_pair(5060, "ERROR_CLUSTER_NETWORK_NOT_INTERNAL")); + errorNames.insert(std::make_pair(5061, "ERROR_CLUSTER_NODE_ALREADY_UP")); + errorNames.insert(std::make_pair(5062, "ERROR_CLUSTER_NODE_ALREADY_DOWN")); + errorNames.insert(std::make_pair(5063, "ERROR_CLUSTER_NETWORK_ALREADY_ONLINE")); + errorNames.insert(std::make_pair(5064, "ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE")); + errorNames.insert(std::make_pair(5065, "ERROR_CLUSTER_NODE_ALREADY_MEMBER")); + errorNames.insert(std::make_pair(5066, "ERROR_CLUSTER_LAST_INTERNAL_NETWORK")); + errorNames.insert(std::make_pair(5067, "ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS")); + errorNames.insert(std::make_pair(5068, "ERROR_INVALID_OPERATION_ON_QUORUM")); + errorNames.insert(std::make_pair(5069, "ERROR_DEPENDENCY_NOT_ALLOWED")); + errorNames.insert(std::make_pair(5070, "ERROR_CLUSTER_NODE_PAUSED")); + errorNames.insert(std::make_pair(5071, "ERROR_NODE_CANT_HOST_RESOURCE")); + errorNames.insert(std::make_pair(5072, "ERROR_CLUSTER_NODE_NOT_READY")); + errorNames.insert(std::make_pair(5073, "ERROR_CLUSTER_NODE_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(5074, "ERROR_CLUSTER_JOIN_ABORTED")); + errorNames.insert(std::make_pair(5075, "ERROR_CLUSTER_INCOMPATIBLE_VERSIONS")); + errorNames.insert(std::make_pair(5076, "ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED")); + errorNames.insert(std::make_pair(5077, "ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED")); + errorNames.insert(std::make_pair(5078, "ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND")); + errorNames.insert(std::make_pair(5079, "ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(5080, "ERROR_CLUSTER_RESNAME_NOT_FOUND")); + errorNames.insert(std::make_pair(5081, "ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED")); + errorNames.insert(std::make_pair(5082, "ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST")); + errorNames.insert(std::make_pair(5083, "ERROR_CLUSTER_DATABASE_SEQMISMATCH")); + errorNames.insert(std::make_pair(5084, "ERROR_RESMON_INVALID_STATE")); + errorNames.insert(std::make_pair(5085, "ERROR_CLUSTER_GUM_NOT_LOCKER")); + errorNames.insert(std::make_pair(5086, "ERROR_QUORUM_DISK_NOT_FOUND")); + errorNames.insert(std::make_pair(5087, "ERROR_DATABASE_BACKUP_CORRUPT")); + errorNames.insert(std::make_pair(5088, "ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT")); + errorNames.insert(std::make_pair(5089, "ERROR_RESOURCE_PROPERTY_UNCHANGEABLE")); + errorNames.insert(std::make_pair(5890, "ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE")); + errorNames.insert(std::make_pair(5891, "ERROR_CLUSTER_QUORUMLOG_NOT_FOUND")); + errorNames.insert(std::make_pair(5892, "ERROR_CLUSTER_MEMBERSHIP_HALT")); + errorNames.insert(std::make_pair(5893, "ERROR_CLUSTER_INSTANCE_ID_MISMATCH")); + errorNames.insert(std::make_pair(5894, "ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP")); + errorNames.insert(std::make_pair(5895, "ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH")); + errorNames.insert(std::make_pair(5896, "ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP")); + errorNames.insert(std::make_pair(5897, "ERROR_CLUSTER_PARAMETER_MISMATCH")); + errorNames.insert(std::make_pair(5898, "ERROR_NODE_CANNOT_BE_CLUSTERED")); + errorNames.insert(std::make_pair(5899, "ERROR_CLUSTER_WRONG_OS_VERSION")); + errorNames.insert(std::make_pair(5900, "ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME")); + errorNames.insert(std::make_pair(5901, "ERROR_CLUSCFG_ALREADY_COMMITTED")); + errorNames.insert(std::make_pair(5902, "ERROR_CLUSCFG_ROLLBACK_FAILED")); + errorNames.insert(std::make_pair(5903, "ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT")); + errorNames.insert(std::make_pair(5904, "ERROR_CLUSTER_OLD_VERSION")); + errorNames.insert(std::make_pair(5905, "ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME")); + errorNames.insert(std::make_pair(5906, "ERROR_CLUSTER_NO_NET_ADAPTERS")); + errorNames.insert(std::make_pair(5907, "ERROR_CLUSTER_POISONED")); + errorNames.insert(std::make_pair(5908, "ERROR_CLUSTER_GROUP_MOVING")); + errorNames.insert(std::make_pair(5909, "ERROR_CLUSTER_RESOURCE_TYPE_BUSY")); + errorNames.insert(std::make_pair(5910, "ERROR_RESOURCE_CALL_TIMED_OUT")); + errorNames.insert(std::make_pair(5911, "ERROR_INVALID_CLUSTER_IPV6_ADDRESS")); + errorNames.insert(std::make_pair(5912, "ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION")); + errorNames.insert(std::make_pair(5913, "ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS")); + errorNames.insert(std::make_pair(5914, "ERROR_CLUSTER_PARTIAL_SEND")); + errorNames.insert(std::make_pair(5915, "ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION")); + errorNames.insert(std::make_pair(5916, "ERROR_CLUSTER_INVALID_STRING_TERMINATION")); + errorNames.insert(std::make_pair(5917, "ERROR_CLUSTER_INVALID_STRING_FORMAT")); + errorNames.insert(std::make_pair(5918, "ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS")); + errorNames.insert(std::make_pair(5919, "ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS")); + errorNames.insert(std::make_pair(5920, "ERROR_CLUSTER_NULL_DATA")); + errorNames.insert(std::make_pair(5921, "ERROR_CLUSTER_PARTIAL_READ")); + errorNames.insert(std::make_pair(5922, "ERROR_CLUSTER_PARTIAL_WRITE")); + errorNames.insert(std::make_pair(5923, "ERROR_CLUSTER_CANT_DESERIALIZE_DATA")); + errorNames.insert(std::make_pair(5924, "ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT")); + errorNames.insert(std::make_pair(5925, "ERROR_CLUSTER_NO_QUORUM")); + errorNames.insert(std::make_pair(5926, "ERROR_CLUSTER_INVALID_IPV6_NETWORK")); + errorNames.insert(std::make_pair(5927, "ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK")); + errorNames.insert(std::make_pair(5928, "ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP")); + errorNames.insert(std::make_pair(5929, "ERROR_DEPENDENCY_TREE_TOO_COMPLEX")); + errorNames.insert(std::make_pair(5930, "ERROR_EXCEPTION_IN_RESOURCE_CALL")); + errorNames.insert(std::make_pair(5931, "ERROR_CLUSTER_RHS_FAILED_INITIALIZATION")); + errorNames.insert(std::make_pair(5932, "ERROR_CLUSTER_NOT_INSTALLED")); + errorNames.insert(std::make_pair(5933, "ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE")); + errorNames.insert(std::make_pair(5934, "ERROR_CLUSTER_MAX_NODES_IN_CLUSTER")); + errorNames.insert(std::make_pair(5935, "ERROR_CLUSTER_TOO_MANY_NODES")); + errorNames.insert(std::make_pair(5936, "ERROR_CLUSTER_OBJECT_ALREADY_USED")); + errorNames.insert(std::make_pair(5937, "ERROR_NONCORE_GROUPS_FOUND")); + errorNames.insert(std::make_pair(5938, "ERROR_FILE_SHARE_RESOURCE_CONFLICT")); + errorNames.insert(std::make_pair(5939, "ERROR_CLUSTER_EVICT_INVALID_REQUEST")); + errorNames.insert(std::make_pair(5940, "ERROR_CLUSTER_SINGLETON_RESOURCE")); + errorNames.insert(std::make_pair(5941, "ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE")); + errorNames.insert(std::make_pair(5942, "ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED")); + errorNames.insert(std::make_pair(5943, "ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR")); + errorNames.insert(std::make_pair(5944, "ERROR_CLUSTER_GROUP_BUSY")); + errorNames.insert(std::make_pair(5945, "ERROR_CLUSTER_NOT_SHARED_VOLUME")); + errorNames.insert(std::make_pair(5946, "ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR")); + errorNames.insert(std::make_pair(5947, "ERROR_CLUSTER_SHARED_VOLUMES_IN_USE")); + errorNames.insert(std::make_pair(5948, "ERROR_CLUSTER_USE_SHARED_VOLUMES_API")); + errorNames.insert(std::make_pair(5949, "ERROR_CLUSTER_BACKUP_IN_PROGRESS")); + errorNames.insert(std::make_pair(5950, "ERROR_NON_CSV_PATH")); + errorNames.insert(std::make_pair(5951, "ERROR_CSV_VOLUME_NOT_LOCAL")); + errorNames.insert(std::make_pair(5952, "ERROR_CLUSTER_WATCHDOG_TERMINATING")); + errorNames.insert(std::make_pair(6000, "ERROR_ENCRYPTION_FAILED")); + errorNames.insert(std::make_pair(6001, "ERROR_DECRYPTION_FAILED")); + errorNames.insert(std::make_pair(6002, "ERROR_FILE_ENCRYPTED")); + errorNames.insert(std::make_pair(6003, "ERROR_NO_RECOVERY_POLICY")); + errorNames.insert(std::make_pair(6004, "ERROR_NO_EFS")); + errorNames.insert(std::make_pair(6005, "ERROR_WRONG_EFS")); + errorNames.insert(std::make_pair(6006, "ERROR_NO_USER_KEYS")); + errorNames.insert(std::make_pair(6007, "ERROR_FILE_NOT_ENCRYPTED")); + errorNames.insert(std::make_pair(6008, "ERROR_NOT_EXPORT_FORMAT")); + errorNames.insert(std::make_pair(6009, "ERROR_FILE_READ_ONLY")); + errorNames.insert(std::make_pair(6010, "ERROR_DIR_EFS_DISALLOWED")); + errorNames.insert(std::make_pair(6011, "ERROR_EFS_SERVER_NOT_TRUSTED")); + errorNames.insert(std::make_pair(6012, "ERROR_BAD_RECOVERY_POLICY")); + errorNames.insert(std::make_pair(6013, "ERROR_EFS_ALG_BLOB_TOO_BIG")); + errorNames.insert(std::make_pair(6014, "ERROR_VOLUME_NOT_SUPPORT_EFS")); + errorNames.insert(std::make_pair(6015, "ERROR_EFS_DISABLED")); + errorNames.insert(std::make_pair(6016, "ERROR_EFS_VERSION_NOT_SUPPORT")); + errorNames.insert(std::make_pair(6017, "ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE")); + errorNames.insert(std::make_pair(6018, "ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER")); + errorNames.insert(std::make_pair(6019, "ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE")); + errorNames.insert(std::make_pair(6020, "ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE")); + errorNames.insert(std::make_pair(6021, "ERROR_CS_ENCRYPTION_FILE_NOT_CSE")); + errorNames.insert(std::make_pair(6022, "ERROR_ENCRYPTION_POLICY_DENIES_OPERATION")); + errorNames.insert(std::make_pair(6118, "ERROR_NO_BROWSER_SERVERS_FOUND")); + errorNames.insert(std::make_pair(6600, "ERROR_LOG_SECTOR_INVALID")); + errorNames.insert(std::make_pair(6601, "ERROR_LOG_SECTOR_PARITY_INVALID")); + errorNames.insert(std::make_pair(6602, "ERROR_LOG_SECTOR_REMAPPED")); + errorNames.insert(std::make_pair(6603, "ERROR_LOG_BLOCK_INCOMPLETE")); + errorNames.insert(std::make_pair(6604, "ERROR_LOG_INVALID_RANGE")); + errorNames.insert(std::make_pair(6605, "ERROR_LOG_BLOCKS_EXHAUSTED")); + errorNames.insert(std::make_pair(6606, "ERROR_LOG_READ_CONTEXT_INVALID")); + errorNames.insert(std::make_pair(6607, "ERROR_LOG_RESTART_INVALID")); + errorNames.insert(std::make_pair(6608, "ERROR_LOG_BLOCK_VERSION")); + errorNames.insert(std::make_pair(6609, "ERROR_LOG_BLOCK_INVALID")); + errorNames.insert(std::make_pair(6610, "ERROR_LOG_READ_MODE_INVALID")); + errorNames.insert(std::make_pair(6611, "ERROR_LOG_NO_RESTART")); + errorNames.insert(std::make_pair(6612, "ERROR_LOG_METADATA_CORRUPT")); + errorNames.insert(std::make_pair(6613, "ERROR_LOG_METADATA_INVALID")); + errorNames.insert(std::make_pair(6614, "ERROR_LOG_METADATA_INCONSISTENT")); + errorNames.insert(std::make_pair(6615, "ERROR_LOG_RESERVATION_INVALID")); + errorNames.insert(std::make_pair(6616, "ERROR_LOG_CANT_DELETE")); + errorNames.insert(std::make_pair(6617, "ERROR_LOG_CONTAINER_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(6618, "ERROR_LOG_START_OF_LOG")); + errorNames.insert(std::make_pair(6619, "ERROR_LOG_POLICY_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(6620, "ERROR_LOG_POLICY_NOT_INSTALLED")); + errorNames.insert(std::make_pair(6621, "ERROR_LOG_POLICY_INVALID")); + errorNames.insert(std::make_pair(6622, "ERROR_LOG_POLICY_CONFLICT")); + errorNames.insert(std::make_pair(6623, "ERROR_LOG_PINNED_ARCHIVE_TAIL")); + errorNames.insert(std::make_pair(6624, "ERROR_LOG_RECORD_NONEXISTENT")); + errorNames.insert(std::make_pair(6625, "ERROR_LOG_RECORDS_RESERVED_INVALID")); + errorNames.insert(std::make_pair(6626, "ERROR_LOG_SPACE_RESERVED_INVALID")); + errorNames.insert(std::make_pair(6627, "ERROR_LOG_TAIL_INVALID")); + errorNames.insert(std::make_pair(6628, "ERROR_LOG_FULL")); + errorNames.insert(std::make_pair(6629, "ERROR_COULD_NOT_RESIZE_LOG")); + errorNames.insert(std::make_pair(6630, "ERROR_LOG_MULTIPLEXED")); + errorNames.insert(std::make_pair(6631, "ERROR_LOG_DEDICATED")); + errorNames.insert(std::make_pair(6632, "ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS")); + errorNames.insert(std::make_pair(6633, "ERROR_LOG_ARCHIVE_IN_PROGRESS")); + errorNames.insert(std::make_pair(6634, "ERROR_LOG_EPHEMERAL")); + errorNames.insert(std::make_pair(6635, "ERROR_LOG_NOT_ENOUGH_CONTAINERS")); + errorNames.insert(std::make_pair(6636, "ERROR_LOG_CLIENT_ALREADY_REGISTERED")); + errorNames.insert(std::make_pair(6637, "ERROR_LOG_CLIENT_NOT_REGISTERED")); + errorNames.insert(std::make_pair(6638, "ERROR_LOG_FULL_HANDLER_IN_PROGRESS")); + errorNames.insert(std::make_pair(6639, "ERROR_LOG_CONTAINER_READ_FAILED")); + errorNames.insert(std::make_pair(6640, "ERROR_LOG_CONTAINER_WRITE_FAILED")); + errorNames.insert(std::make_pair(6641, "ERROR_LOG_CONTAINER_OPEN_FAILED")); + errorNames.insert(std::make_pair(6642, "ERROR_LOG_CONTAINER_STATE_INVALID")); + errorNames.insert(std::make_pair(6643, "ERROR_LOG_STATE_INVALID")); + errorNames.insert(std::make_pair(6644, "ERROR_LOG_PINNED")); + errorNames.insert(std::make_pair(6645, "ERROR_LOG_METADATA_FLUSH_FAILED")); + errorNames.insert(std::make_pair(6646, "ERROR_LOG_INCONSISTENT_SECURITY")); + errorNames.insert(std::make_pair(6647, "ERROR_LOG_APPENDED_FLUSH_FAILED")); + errorNames.insert(std::make_pair(6648, "ERROR_LOG_PINNED_RESERVATION")); + errorNames.insert(std::make_pair(6700, "ERROR_INVALID_TRANSACTION")); + errorNames.insert(std::make_pair(6701, "ERROR_TRANSACTION_NOT_ACTIVE")); + errorNames.insert(std::make_pair(6702, "ERROR_TRANSACTION_REQUEST_NOT_VALID")); + errorNames.insert(std::make_pair(6703, "ERROR_TRANSACTION_NOT_REQUESTED")); + errorNames.insert(std::make_pair(6704, "ERROR_TRANSACTION_ALREADY_ABORTED")); + errorNames.insert(std::make_pair(6705, "ERROR_TRANSACTION_ALREADY_COMMITTED")); + errorNames.insert(std::make_pair(6706, "ERROR_TM_INITIALIZATION_FAILED")); + errorNames.insert(std::make_pair(6707, "ERROR_RESOURCEMANAGER_READ_ONLY")); + errorNames.insert(std::make_pair(6708, "ERROR_TRANSACTION_NOT_JOINED")); + errorNames.insert(std::make_pair(6709, "ERROR_TRANSACTION_SUPERIOR_EXISTS")); + errorNames.insert(std::make_pair(6710, "ERROR_CRM_PROTOCOL_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(6711, "ERROR_TRANSACTION_PROPAGATION_FAILED")); + errorNames.insert(std::make_pair(6712, "ERROR_CRM_PROTOCOL_NOT_FOUND")); + errorNames.insert(std::make_pair(6713, "ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER")); + errorNames.insert(std::make_pair(6714, "ERROR_CURRENT_TRANSACTION_NOT_VALID")); + errorNames.insert(std::make_pair(6715, "ERROR_TRANSACTION_NOT_FOUND")); + errorNames.insert(std::make_pair(6716, "ERROR_RESOURCEMANAGER_NOT_FOUND")); + errorNames.insert(std::make_pair(6717, "ERROR_ENLISTMENT_NOT_FOUND")); + errorNames.insert(std::make_pair(6718, "ERROR_TRANSACTIONMANAGER_NOT_FOUND")); + errorNames.insert(std::make_pair(6719, "ERROR_TRANSACTIONMANAGER_NOT_ONLINE")); + errorNames.insert(std::make_pair(6720, "ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION")); + errorNames.insert(std::make_pair(6721, "ERROR_TRANSACTION_NOT_ROOT")); + errorNames.insert(std::make_pair(6722, "ERROR_TRANSACTION_OBJECT_EXPIRED")); + errorNames.insert(std::make_pair(6723, "ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED")); + errorNames.insert(std::make_pair(6724, "ERROR_TRANSACTION_RECORD_TOO_LONG")); + errorNames.insert(std::make_pair(6725, "ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(6726, "ERROR_TRANSACTION_INTEGRITY_VIOLATED")); + errorNames.insert(std::make_pair(6727, "ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH")); + errorNames.insert(std::make_pair(6728, "ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT")); + errorNames.insert(std::make_pair(6729, "ERROR_TRANSACTION_MUST_WRITETHROUGH")); + errorNames.insert(std::make_pair(6730, "ERROR_TRANSACTION_NO_SUPERIOR")); + errorNames.insert(std::make_pair(6731, "ERROR_HEURISTIC_DAMAGE_POSSIBLE")); + errorNames.insert(std::make_pair(6800, "ERROR_TRANSACTIONAL_CONFLICT")); + errorNames.insert(std::make_pair(6801, "ERROR_RM_NOT_ACTIVE")); + errorNames.insert(std::make_pair(6802, "ERROR_RM_METADATA_CORRUPT")); + errorNames.insert(std::make_pair(6803, "ERROR_DIRECTORY_NOT_RM")); + errorNames.insert(std::make_pair(6805, "ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE")); + errorNames.insert(std::make_pair(6806, "ERROR_LOG_RESIZE_INVALID_SIZE")); + errorNames.insert(std::make_pair(6807, "ERROR_OBJECT_NO_LONGER_EXISTS")); + errorNames.insert(std::make_pair(6808, "ERROR_STREAM_MINIVERSION_NOT_FOUND")); + errorNames.insert(std::make_pair(6809, "ERROR_STREAM_MINIVERSION_NOT_VALID")); + errorNames.insert(std::make_pair(6810, "ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION")); + errorNames.insert(std::make_pair(6811, "ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT")); + errorNames.insert(std::make_pair(6812, "ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS")); + errorNames.insert(std::make_pair(6814, "ERROR_REMOTE_FILE_VERSION_MISMATCH")); + errorNames.insert(std::make_pair(6815, "ERROR_HANDLE_NO_LONGER_VALID")); + errorNames.insert(std::make_pair(6816, "ERROR_NO_TXF_METADATA")); + errorNames.insert(std::make_pair(6817, "ERROR_LOG_CORRUPTION_DETECTED")); + errorNames.insert(std::make_pair(6818, "ERROR_CANT_RECOVER_WITH_HANDLE_OPEN")); + errorNames.insert(std::make_pair(6819, "ERROR_RM_DISCONNECTED")); + errorNames.insert(std::make_pair(6820, "ERROR_ENLISTMENT_NOT_SUPERIOR")); + errorNames.insert(std::make_pair(6821, "ERROR_RECOVERY_NOT_NEEDED")); + errorNames.insert(std::make_pair(6822, "ERROR_RM_ALREADY_STARTED")); + errorNames.insert(std::make_pair(6823, "ERROR_FILE_IDENTITY_NOT_PERSISTENT")); + errorNames.insert(std::make_pair(6824, "ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY")); + errorNames.insert(std::make_pair(6825, "ERROR_CANT_CROSS_RM_BOUNDARY")); + errorNames.insert(std::make_pair(6826, "ERROR_TXF_DIR_NOT_EMPTY")); + errorNames.insert(std::make_pair(6827, "ERROR_INDOUBT_TRANSACTIONS_EXIST")); + errorNames.insert(std::make_pair(6828, "ERROR_TM_VOLATILE")); + errorNames.insert(std::make_pair(6829, "ERROR_ROLLBACK_TIMER_EXPIRED")); + errorNames.insert(std::make_pair(6830, "ERROR_TXF_ATTRIBUTE_CORRUPT")); + errorNames.insert(std::make_pair(6831, "ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6832, "ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED")); + errorNames.insert(std::make_pair(6833, "ERROR_LOG_GROWTH_FAILED")); + errorNames.insert(std::make_pair(6834, "ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE")); + errorNames.insert(std::make_pair(6835, "ERROR_TXF_METADATA_ALREADY_PRESENT")); + errorNames.insert(std::make_pair(6836, "ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET")); + errorNames.insert(std::make_pair(6837, "ERROR_TRANSACTION_REQUIRED_PROMOTION")); + errorNames.insert(std::make_pair(6838, "ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6839, "ERROR_TRANSACTIONS_NOT_FROZEN")); + errorNames.insert(std::make_pair(6840, "ERROR_TRANSACTION_FREEZE_IN_PROGRESS")); + errorNames.insert(std::make_pair(6841, "ERROR_NOT_SNAPSHOT_VOLUME")); + errorNames.insert(std::make_pair(6842, "ERROR_NO_SAVEPOINT_WITH_OPEN_FILES")); + errorNames.insert(std::make_pair(6843, "ERROR_DATA_LOST_REPAIR")); + errorNames.insert(std::make_pair(6844, "ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6845, "ERROR_TM_IDENTITY_MISMATCH")); + errorNames.insert(std::make_pair(6846, "ERROR_FLOATED_SECTION")); + errorNames.insert(std::make_pair(6847, "ERROR_CANNOT_ACCEPT_TRANSACTED_WORK")); + errorNames.insert(std::make_pair(6848, "ERROR_CANNOT_ABORT_TRANSACTIONS")); + errorNames.insert(std::make_pair(6849, "ERROR_BAD_CLUSTERS")); + errorNames.insert(std::make_pair(6850, "ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6851, "ERROR_VOLUME_DIRTY")); + errorNames.insert(std::make_pair(6852, "ERROR_NO_LINK_TRACKING_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6853, "ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6854, "ERROR_EXPIRED_HANDLE")); + errorNames.insert(std::make_pair(6855, "ERROR_TRANSACTION_NOT_ENLISTED")); + errorNames.insert(std::make_pair(7001, "ERROR_CTX_WINSTATION_NAME_INVALID")); + errorNames.insert(std::make_pair(7002, "ERROR_CTX_INVALID_PD")); + errorNames.insert(std::make_pair(7003, "ERROR_CTX_PD_NOT_FOUND")); + errorNames.insert(std::make_pair(7004, "ERROR_CTX_WD_NOT_FOUND")); + errorNames.insert(std::make_pair(7005, "ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY")); + errorNames.insert(std::make_pair(7006, "ERROR_CTX_SERVICE_NAME_COLLISION")); + errorNames.insert(std::make_pair(7007, "ERROR_CTX_CLOSE_PENDING")); + errorNames.insert(std::make_pair(7008, "ERROR_CTX_NO_OUTBUF")); + errorNames.insert(std::make_pair(7009, "ERROR_CTX_MODEM_INF_NOT_FOUND")); + errorNames.insert(std::make_pair(7010, "ERROR_CTX_INVALID_MODEMNAME")); + errorNames.insert(std::make_pair(7011, "ERROR_CTX_MODEM_RESPONSE_ERROR")); + errorNames.insert(std::make_pair(7012, "ERROR_CTX_MODEM_RESPONSE_TIMEOUT")); + errorNames.insert(std::make_pair(7013, "ERROR_CTX_MODEM_RESPONSE_NO_CARRIER")); + errorNames.insert(std::make_pair(7014, "ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE")); + errorNames.insert(std::make_pair(7015, "ERROR_CTX_MODEM_RESPONSE_BUSY")); + errorNames.insert(std::make_pair(7016, "ERROR_CTX_MODEM_RESPONSE_VOICE")); + errorNames.insert(std::make_pair(7017, "ERROR_CTX_TD_ERROR")); + errorNames.insert(std::make_pair(7022, "ERROR_CTX_WINSTATION_NOT_FOUND")); + errorNames.insert(std::make_pair(7023, "ERROR_CTX_WINSTATION_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(7024, "ERROR_CTX_WINSTATION_BUSY")); + errorNames.insert(std::make_pair(7025, "ERROR_CTX_BAD_VIDEO_MODE")); + errorNames.insert(std::make_pair(7035, "ERROR_CTX_GRAPHICS_INVALID")); + errorNames.insert(std::make_pair(7037, "ERROR_CTX_LOGON_DISABLED")); + errorNames.insert(std::make_pair(7038, "ERROR_CTX_NOT_CONSOLE")); + errorNames.insert(std::make_pair(7040, "ERROR_CTX_CLIENT_QUERY_TIMEOUT")); + errorNames.insert(std::make_pair(7041, "ERROR_CTX_CONSOLE_DISCONNECT")); + errorNames.insert(std::make_pair(7042, "ERROR_CTX_CONSOLE_CONNECT")); + errorNames.insert(std::make_pair(7044, "ERROR_CTX_SHADOW_DENIED")); + errorNames.insert(std::make_pair(7045, "ERROR_CTX_WINSTATION_ACCESS_DENIED")); + errorNames.insert(std::make_pair(7049, "ERROR_CTX_INVALID_WD")); + errorNames.insert(std::make_pair(7050, "ERROR_CTX_SHADOW_INVALID")); + errorNames.insert(std::make_pair(7051, "ERROR_CTX_SHADOW_DISABLED")); + errorNames.insert(std::make_pair(7052, "ERROR_CTX_CLIENT_LICENSE_IN_USE")); + errorNames.insert(std::make_pair(7053, "ERROR_CTX_CLIENT_LICENSE_NOT_SET")); + errorNames.insert(std::make_pair(7054, "ERROR_CTX_LICENSE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(7055, "ERROR_CTX_LICENSE_CLIENT_INVALID")); + errorNames.insert(std::make_pair(7056, "ERROR_CTX_LICENSE_EXPIRED")); + errorNames.insert(std::make_pair(7057, "ERROR_CTX_SHADOW_NOT_RUNNING")); + errorNames.insert(std::make_pair(7058, "ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE")); + errorNames.insert(std::make_pair(7059, "ERROR_ACTIVATION_COUNT_EXCEEDED")); + errorNames.insert(std::make_pair(7060, "ERROR_CTX_WINSTATIONS_DISABLED")); + errorNames.insert(std::make_pair(7061, "ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED")); + errorNames.insert(std::make_pair(7062, "ERROR_CTX_SESSION_IN_USE")); + errorNames.insert(std::make_pair(7063, "ERROR_CTX_NO_FORCE_LOGOFF")); + errorNames.insert(std::make_pair(7064, "ERROR_CTX_ACCOUNT_RESTRICTION")); + errorNames.insert(std::make_pair(7065, "ERROR_RDP_PROTOCOL_ERROR")); + errorNames.insert(std::make_pair(7066, "ERROR_CTX_CDM_CONNECT")); + errorNames.insert(std::make_pair(7067, "ERROR_CTX_CDM_DISCONNECT")); + errorNames.insert(std::make_pair(7068, "ERROR_CTX_SECURITY_LAYER_ERROR")); + errorNames.insert(std::make_pair(7069, "ERROR_TS_INCOMPATIBLE_SESSIONS")); + errorNames.insert(std::make_pair(7070, "ERROR_TS_VIDEO_SUBSYSTEM_ERROR")); + errorNames.insert(std::make_pair(8200, "ERROR_DS_NOT_INSTALLED")); + errorNames.insert(std::make_pair(8201, "ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY")); + errorNames.insert(std::make_pair(8202, "ERROR_DS_NO_ATTRIBUTE_OR_VALUE")); + errorNames.insert(std::make_pair(8203, "ERROR_DS_INVALID_ATTRIBUTE_SYNTAX")); + errorNames.insert(std::make_pair(8204, "ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED")); + errorNames.insert(std::make_pair(8205, "ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS")); + errorNames.insert(std::make_pair(8206, "ERROR_DS_BUSY")); + errorNames.insert(std::make_pair(8207, "ERROR_DS_UNAVAILABLE")); + errorNames.insert(std::make_pair(8208, "ERROR_DS_NO_RIDS_ALLOCATED")); + errorNames.insert(std::make_pair(8209, "ERROR_DS_NO_MORE_RIDS")); + errorNames.insert(std::make_pair(8210, "ERROR_DS_INCORRECT_ROLE_OWNER")); + errorNames.insert(std::make_pair(8211, "ERROR_DS_RIDMGR_INIT_ERROR")); + errorNames.insert(std::make_pair(8212, "ERROR_DS_OBJ_CLASS_VIOLATION")); + errorNames.insert(std::make_pair(8213, "ERROR_DS_CANT_ON_NON_LEAF")); + errorNames.insert(std::make_pair(8214, "ERROR_DS_CANT_ON_RDN")); + errorNames.insert(std::make_pair(8215, "ERROR_DS_CANT_MOD_OBJ_CLASS")); + errorNames.insert(std::make_pair(8216, "ERROR_DS_CROSS_DOM_MOVE_ERROR")); + errorNames.insert(std::make_pair(8217, "ERROR_DS_GC_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(8218, "ERROR_SHARED_POLICY")); + errorNames.insert(std::make_pair(8219, "ERROR_POLICY_OBJECT_NOT_FOUND")); + errorNames.insert(std::make_pair(8220, "ERROR_POLICY_ONLY_IN_DS")); + errorNames.insert(std::make_pair(8221, "ERROR_PROMOTION_ACTIVE")); + errorNames.insert(std::make_pair(8222, "ERROR_NO_PROMOTION_ACTIVE")); + errorNames.insert(std::make_pair(8224, "ERROR_DS_OPERATIONS_ERROR")); + errorNames.insert(std::make_pair(8225, "ERROR_DS_PROTOCOL_ERROR")); + errorNames.insert(std::make_pair(8226, "ERROR_DS_TIMELIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8227, "ERROR_DS_SIZELIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8228, "ERROR_DS_ADMIN_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8229, "ERROR_DS_COMPARE_FALSE")); + errorNames.insert(std::make_pair(8230, "ERROR_DS_COMPARE_TRUE")); + errorNames.insert(std::make_pair(8231, "ERROR_DS_AUTH_METHOD_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(8232, "ERROR_DS_STRONG_AUTH_REQUIRED")); + errorNames.insert(std::make_pair(8233, "ERROR_DS_INAPPROPRIATE_AUTH")); + errorNames.insert(std::make_pair(8234, "ERROR_DS_AUTH_UNKNOWN")); + errorNames.insert(std::make_pair(8235, "ERROR_DS_REFERRAL")); + errorNames.insert(std::make_pair(8236, "ERROR_DS_UNAVAILABLE_CRIT_EXTENSION")); + errorNames.insert(std::make_pair(8237, "ERROR_DS_CONFIDENTIALITY_REQUIRED")); + errorNames.insert(std::make_pair(8238, "ERROR_DS_INAPPROPRIATE_MATCHING")); + errorNames.insert(std::make_pair(8239, "ERROR_DS_CONSTRAINT_VIOLATION")); + errorNames.insert(std::make_pair(8240, "ERROR_DS_NO_SUCH_OBJECT")); + errorNames.insert(std::make_pair(8241, "ERROR_DS_ALIAS_PROBLEM")); + errorNames.insert(std::make_pair(8242, "ERROR_DS_INVALID_DN_SYNTAX")); + errorNames.insert(std::make_pair(8243, "ERROR_DS_IS_LEAF")); + errorNames.insert(std::make_pair(8244, "ERROR_DS_ALIAS_DEREF_PROBLEM")); + errorNames.insert(std::make_pair(8245, "ERROR_DS_UNWILLING_TO_PERFORM")); + errorNames.insert(std::make_pair(8246, "ERROR_DS_LOOP_DETECT")); + errorNames.insert(std::make_pair(8247, "ERROR_DS_NAMING_VIOLATION")); + errorNames.insert(std::make_pair(8248, "ERROR_DS_OBJECT_RESULTS_TOO_LARGE")); + errorNames.insert(std::make_pair(8249, "ERROR_DS_AFFECTS_MULTIPLE_DSAS")); + errorNames.insert(std::make_pair(8250, "ERROR_DS_SERVER_DOWN")); + errorNames.insert(std::make_pair(8251, "ERROR_DS_LOCAL_ERROR")); + errorNames.insert(std::make_pair(8252, "ERROR_DS_ENCODING_ERROR")); + errorNames.insert(std::make_pair(8253, "ERROR_DS_DECODING_ERROR")); + errorNames.insert(std::make_pair(8254, "ERROR_DS_FILTER_UNKNOWN")); + errorNames.insert(std::make_pair(8255, "ERROR_DS_PARAM_ERROR")); + errorNames.insert(std::make_pair(8256, "ERROR_DS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(8257, "ERROR_DS_NO_RESULTS_RETURNED")); + errorNames.insert(std::make_pair(8258, "ERROR_DS_CONTROL_NOT_FOUND")); + errorNames.insert(std::make_pair(8259, "ERROR_DS_CLIENT_LOOP")); + errorNames.insert(std::make_pair(8260, "ERROR_DS_REFERRAL_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8261, "ERROR_DS_SORT_CONTROL_MISSING")); + errorNames.insert(std::make_pair(8262, "ERROR_DS_OFFSET_RANGE_ERROR")); + errorNames.insert(std::make_pair(8301, "ERROR_DS_ROOT_MUST_BE_NC")); + errorNames.insert(std::make_pair(8302, "ERROR_DS_ADD_REPLICA_INHIBITED")); + errorNames.insert(std::make_pair(8303, "ERROR_DS_ATT_NOT_DEF_IN_SCHEMA")); + errorNames.insert(std::make_pair(8304, "ERROR_DS_MAX_OBJ_SIZE_EXCEEDED")); + errorNames.insert(std::make_pair(8305, "ERROR_DS_OBJ_STRING_NAME_EXISTS")); + errorNames.insert(std::make_pair(8306, "ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA")); + errorNames.insert(std::make_pair(8307, "ERROR_DS_RDN_DOESNT_MATCH_SCHEMA")); + errorNames.insert(std::make_pair(8308, "ERROR_DS_NO_REQUESTED_ATTS_FOUND")); + errorNames.insert(std::make_pair(8309, "ERROR_DS_USER_BUFFER_TO_SMALL")); + errorNames.insert(std::make_pair(8310, "ERROR_DS_ATT_IS_NOT_ON_OBJ")); + errorNames.insert(std::make_pair(8311, "ERROR_DS_ILLEGAL_MOD_OPERATION")); + errorNames.insert(std::make_pair(8312, "ERROR_DS_OBJ_TOO_LARGE")); + errorNames.insert(std::make_pair(8313, "ERROR_DS_BAD_INSTANCE_TYPE")); + errorNames.insert(std::make_pair(8314, "ERROR_DS_MASTERDSA_REQUIRED")); + errorNames.insert(std::make_pair(8315, "ERROR_DS_OBJECT_CLASS_REQUIRED")); + errorNames.insert(std::make_pair(8316, "ERROR_DS_MISSING_REQUIRED_ATT")); + errorNames.insert(std::make_pair(8317, "ERROR_DS_ATT_NOT_DEF_FOR_CLASS")); + errorNames.insert(std::make_pair(8318, "ERROR_DS_ATT_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(8320, "ERROR_DS_CANT_ADD_ATT_VALUES")); + errorNames.insert(std::make_pair(8321, "ERROR_DS_SINGLE_VALUE_CONSTRAINT")); + errorNames.insert(std::make_pair(8322, "ERROR_DS_RANGE_CONSTRAINT")); + errorNames.insert(std::make_pair(8323, "ERROR_DS_ATT_VAL_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(8324, "ERROR_DS_CANT_REM_MISSING_ATT")); + errorNames.insert(std::make_pair(8325, "ERROR_DS_CANT_REM_MISSING_ATT_VAL")); + errorNames.insert(std::make_pair(8326, "ERROR_DS_ROOT_CANT_BE_SUBREF")); + errorNames.insert(std::make_pair(8327, "ERROR_DS_NO_CHAINING")); + errorNames.insert(std::make_pair(8328, "ERROR_DS_NO_CHAINED_EVAL")); + errorNames.insert(std::make_pair(8329, "ERROR_DS_NO_PARENT_OBJECT")); + errorNames.insert(std::make_pair(8330, "ERROR_DS_PARENT_IS_AN_ALIAS")); + errorNames.insert(std::make_pair(8331, "ERROR_DS_CANT_MIX_MASTER_AND_REPS")); + errorNames.insert(std::make_pair(8332, "ERROR_DS_CHILDREN_EXIST")); + errorNames.insert(std::make_pair(8333, "ERROR_DS_OBJ_NOT_FOUND")); + errorNames.insert(std::make_pair(8334, "ERROR_DS_ALIASED_OBJ_MISSING")); + errorNames.insert(std::make_pair(8335, "ERROR_DS_BAD_NAME_SYNTAX")); + errorNames.insert(std::make_pair(8336, "ERROR_DS_ALIAS_POINTS_TO_ALIAS")); + errorNames.insert(std::make_pair(8337, "ERROR_DS_CANT_DEREF_ALIAS")); + errorNames.insert(std::make_pair(8338, "ERROR_DS_OUT_OF_SCOPE")); + errorNames.insert(std::make_pair(8339, "ERROR_DS_OBJECT_BEING_REMOVED")); + errorNames.insert(std::make_pair(8340, "ERROR_DS_CANT_DELETE_DSA_OBJ")); + errorNames.insert(std::make_pair(8341, "ERROR_DS_GENERIC_ERROR")); + errorNames.insert(std::make_pair(8342, "ERROR_DS_DSA_MUST_BE_INT_MASTER")); + errorNames.insert(std::make_pair(8343, "ERROR_DS_CLASS_NOT_DSA")); + errorNames.insert(std::make_pair(8344, "ERROR_DS_INSUFF_ACCESS_RIGHTS")); + errorNames.insert(std::make_pair(8345, "ERROR_DS_ILLEGAL_SUPERIOR")); + errorNames.insert(std::make_pair(8346, "ERROR_DS_ATTRIBUTE_OWNED_BY_SAM")); + errorNames.insert(std::make_pair(8347, "ERROR_DS_NAME_TOO_MANY_PARTS")); + errorNames.insert(std::make_pair(8348, "ERROR_DS_NAME_TOO_LONG")); + errorNames.insert(std::make_pair(8349, "ERROR_DS_NAME_VALUE_TOO_LONG")); + errorNames.insert(std::make_pair(8350, "ERROR_DS_NAME_UNPARSEABLE")); + errorNames.insert(std::make_pair(8351, "ERROR_DS_NAME_TYPE_UNKNOWN")); + errorNames.insert(std::make_pair(8352, "ERROR_DS_NOT_AN_OBJECT")); + errorNames.insert(std::make_pair(8353, "ERROR_DS_SEC_DESC_TOO_SHORT")); + errorNames.insert(std::make_pair(8354, "ERROR_DS_SEC_DESC_INVALID")); + errorNames.insert(std::make_pair(8355, "ERROR_DS_NO_DELETED_NAME")); + errorNames.insert(std::make_pair(8356, "ERROR_DS_SUBREF_MUST_HAVE_PARENT")); + errorNames.insert(std::make_pair(8357, "ERROR_DS_NCNAME_MUST_BE_NC")); + errorNames.insert(std::make_pair(8358, "ERROR_DS_CANT_ADD_SYSTEM_ONLY")); + errorNames.insert(std::make_pair(8359, "ERROR_DS_CLASS_MUST_BE_CONCRETE")); + errorNames.insert(std::make_pair(8360, "ERROR_DS_INVALID_DMD")); + errorNames.insert(std::make_pair(8361, "ERROR_DS_OBJ_GUID_EXISTS")); + errorNames.insert(std::make_pair(8362, "ERROR_DS_NOT_ON_BACKLINK")); + errorNames.insert(std::make_pair(8363, "ERROR_DS_NO_CROSSREF_FOR_NC")); + errorNames.insert(std::make_pair(8364, "ERROR_DS_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(8365, "ERROR_DS_UNKNOWN_OPERATION")); + errorNames.insert(std::make_pair(8366, "ERROR_DS_INVALID_ROLE_OWNER")); + errorNames.insert(std::make_pair(8367, "ERROR_DS_COULDNT_CONTACT_FSMO")); + errorNames.insert(std::make_pair(8368, "ERROR_DS_CROSS_NC_DN_RENAME")); + errorNames.insert(std::make_pair(8369, "ERROR_DS_CANT_MOD_SYSTEM_ONLY")); + errorNames.insert(std::make_pair(8370, "ERROR_DS_REPLICATOR_ONLY")); + errorNames.insert(std::make_pair(8371, "ERROR_DS_OBJ_CLASS_NOT_DEFINED")); + errorNames.insert(std::make_pair(8372, "ERROR_DS_OBJ_CLASS_NOT_SUBCLASS")); + errorNames.insert(std::make_pair(8373, "ERROR_DS_NAME_REFERENCE_INVALID")); + errorNames.insert(std::make_pair(8374, "ERROR_DS_CROSS_REF_EXISTS")); + errorNames.insert(std::make_pair(8375, "ERROR_DS_CANT_DEL_MASTER_CROSSREF")); + errorNames.insert(std::make_pair(8376, "ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD")); + errorNames.insert(std::make_pair(8377, "ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX")); + errorNames.insert(std::make_pair(8378, "ERROR_DS_DUP_RDN")); + errorNames.insert(std::make_pair(8379, "ERROR_DS_DUP_OID")); + errorNames.insert(std::make_pair(8380, "ERROR_DS_DUP_MAPI_ID")); + errorNames.insert(std::make_pair(8381, "ERROR_DS_DUP_SCHEMA_ID_GUID")); + errorNames.insert(std::make_pair(8382, "ERROR_DS_DUP_LDAP_DISPLAY_NAME")); + errorNames.insert(std::make_pair(8383, "ERROR_DS_SEMANTIC_ATT_TEST")); + errorNames.insert(std::make_pair(8384, "ERROR_DS_SYNTAX_MISMATCH")); + errorNames.insert(std::make_pair(8385, "ERROR_DS_EXISTS_IN_MUST_HAVE")); + errorNames.insert(std::make_pair(8386, "ERROR_DS_EXISTS_IN_MAY_HAVE")); + errorNames.insert(std::make_pair(8387, "ERROR_DS_NONEXISTENT_MAY_HAVE")); + errorNames.insert(std::make_pair(8388, "ERROR_DS_NONEXISTENT_MUST_HAVE")); + errorNames.insert(std::make_pair(8389, "ERROR_DS_AUX_CLS_TEST_FAIL")); + errorNames.insert(std::make_pair(8390, "ERROR_DS_NONEXISTENT_POSS_SUP")); + errorNames.insert(std::make_pair(8391, "ERROR_DS_SUB_CLS_TEST_FAIL")); + errorNames.insert(std::make_pair(8392, "ERROR_DS_BAD_RDN_ATT_ID_SYNTAX")); + errorNames.insert(std::make_pair(8393, "ERROR_DS_EXISTS_IN_AUX_CLS")); + errorNames.insert(std::make_pair(8394, "ERROR_DS_EXISTS_IN_SUB_CLS")); + errorNames.insert(std::make_pair(8395, "ERROR_DS_EXISTS_IN_POSS_SUP")); + errorNames.insert(std::make_pair(8396, "ERROR_DS_RECALCSCHEMA_FAILED")); + errorNames.insert(std::make_pair(8397, "ERROR_DS_TREE_DELETE_NOT_FINISHED")); + errorNames.insert(std::make_pair(8398, "ERROR_DS_CANT_DELETE")); + errorNames.insert(std::make_pair(8399, "ERROR_DS_ATT_SCHEMA_REQ_ID")); + errorNames.insert(std::make_pair(8400, "ERROR_DS_BAD_ATT_SCHEMA_SYNTAX")); + errorNames.insert(std::make_pair(8401, "ERROR_DS_CANT_CACHE_ATT")); + errorNames.insert(std::make_pair(8402, "ERROR_DS_CANT_CACHE_CLASS")); + errorNames.insert(std::make_pair(8403, "ERROR_DS_CANT_REMOVE_ATT_CACHE")); + errorNames.insert(std::make_pair(8404, "ERROR_DS_CANT_REMOVE_CLASS_CACHE")); + errorNames.insert(std::make_pair(8405, "ERROR_DS_CANT_RETRIEVE_DN")); + errorNames.insert(std::make_pair(8406, "ERROR_DS_MISSING_SUPREF")); + errorNames.insert(std::make_pair(8407, "ERROR_DS_CANT_RETRIEVE_INSTANCE")); + errorNames.insert(std::make_pair(8408, "ERROR_DS_CODE_INCONSISTENCY")); + errorNames.insert(std::make_pair(8409, "ERROR_DS_DATABASE_ERROR")); + errorNames.insert(std::make_pair(8410, "ERROR_DS_GOVERNSID_MISSING")); + errorNames.insert(std::make_pair(8411, "ERROR_DS_MISSING_EXPECTED_ATT")); + errorNames.insert(std::make_pair(8412, "ERROR_DS_NCNAME_MISSING_CR_REF")); + errorNames.insert(std::make_pair(8413, "ERROR_DS_SECURITY_CHECKING_ERROR")); + errorNames.insert(std::make_pair(8414, "ERROR_DS_SCHEMA_NOT_LOADED")); + errorNames.insert(std::make_pair(8415, "ERROR_DS_SCHEMA_ALLOC_FAILED")); + errorNames.insert(std::make_pair(8416, "ERROR_DS_ATT_SCHEMA_REQ_SYNTAX")); + errorNames.insert(std::make_pair(8417, "ERROR_DS_GCVERIFY_ERROR")); + errorNames.insert(std::make_pair(8418, "ERROR_DS_DRA_SCHEMA_MISMATCH")); + errorNames.insert(std::make_pair(8419, "ERROR_DS_CANT_FIND_DSA_OBJ")); + errorNames.insert(std::make_pair(8420, "ERROR_DS_CANT_FIND_EXPECTED_NC")); + errorNames.insert(std::make_pair(8421, "ERROR_DS_CANT_FIND_NC_IN_CACHE")); + errorNames.insert(std::make_pair(8422, "ERROR_DS_CANT_RETRIEVE_CHILD")); + errorNames.insert(std::make_pair(8423, "ERROR_DS_SECURITY_ILLEGAL_MODIFY")); + errorNames.insert(std::make_pair(8424, "ERROR_DS_CANT_REPLACE_HIDDEN_REC")); + errorNames.insert(std::make_pair(8425, "ERROR_DS_BAD_HIERARCHY_FILE")); + errorNames.insert(std::make_pair(8426, "ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED")); + errorNames.insert(std::make_pair(8427, "ERROR_DS_CONFIG_PARAM_MISSING")); + errorNames.insert(std::make_pair(8428, "ERROR_DS_COUNTING_AB_INDICES_FAILED")); + errorNames.insert(std::make_pair(8429, "ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED")); + errorNames.insert(std::make_pair(8430, "ERROR_DS_INTERNAL_FAILURE")); + errorNames.insert(std::make_pair(8431, "ERROR_DS_UNKNOWN_ERROR")); + errorNames.insert(std::make_pair(8432, "ERROR_DS_ROOT_REQUIRES_CLASS_TOP")); + errorNames.insert(std::make_pair(8433, "ERROR_DS_REFUSING_FSMO_ROLES")); + errorNames.insert(std::make_pair(8434, "ERROR_DS_MISSING_FSMO_SETTINGS")); + errorNames.insert(std::make_pair(8435, "ERROR_DS_UNABLE_TO_SURRENDER_ROLES")); + errorNames.insert(std::make_pair(8436, "ERROR_DS_DRA_GENERIC")); + errorNames.insert(std::make_pair(8437, "ERROR_DS_DRA_INVALID_PARAMETER")); + errorNames.insert(std::make_pair(8438, "ERROR_DS_DRA_BUSY")); + errorNames.insert(std::make_pair(8439, "ERROR_DS_DRA_BAD_DN")); + errorNames.insert(std::make_pair(8440, "ERROR_DS_DRA_BAD_NC")); + errorNames.insert(std::make_pair(8441, "ERROR_DS_DRA_DN_EXISTS")); + errorNames.insert(std::make_pair(8442, "ERROR_DS_DRA_INTERNAL_ERROR")); + errorNames.insert(std::make_pair(8443, "ERROR_DS_DRA_INCONSISTENT_DIT")); + errorNames.insert(std::make_pair(8444, "ERROR_DS_DRA_CONNECTION_FAILED")); + errorNames.insert(std::make_pair(8445, "ERROR_DS_DRA_BAD_INSTANCE_TYPE")); + errorNames.insert(std::make_pair(8446, "ERROR_DS_DRA_OUT_OF_MEM")); + errorNames.insert(std::make_pair(8447, "ERROR_DS_DRA_MAIL_PROBLEM")); + errorNames.insert(std::make_pair(8448, "ERROR_DS_DRA_REF_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(8449, "ERROR_DS_DRA_REF_NOT_FOUND")); + errorNames.insert(std::make_pair(8450, "ERROR_DS_DRA_OBJ_IS_REP_SOURCE")); + errorNames.insert(std::make_pair(8451, "ERROR_DS_DRA_DB_ERROR")); + errorNames.insert(std::make_pair(8452, "ERROR_DS_DRA_NO_REPLICA")); + errorNames.insert(std::make_pair(8453, "ERROR_DS_DRA_ACCESS_DENIED")); + errorNames.insert(std::make_pair(8454, "ERROR_DS_DRA_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(8455, "ERROR_DS_DRA_RPC_CANCELLED")); + errorNames.insert(std::make_pair(8456, "ERROR_DS_DRA_SOURCE_DISABLED")); + errorNames.insert(std::make_pair(8457, "ERROR_DS_DRA_SINK_DISABLED")); + errorNames.insert(std::make_pair(8458, "ERROR_DS_DRA_NAME_COLLISION")); + errorNames.insert(std::make_pair(8459, "ERROR_DS_DRA_SOURCE_REINSTALLED")); + errorNames.insert(std::make_pair(8460, "ERROR_DS_DRA_MISSING_PARENT")); + errorNames.insert(std::make_pair(8461, "ERROR_DS_DRA_PREEMPTED")); + errorNames.insert(std::make_pair(8462, "ERROR_DS_DRA_ABANDON_SYNC")); + errorNames.insert(std::make_pair(8463, "ERROR_DS_DRA_SHUTDOWN")); + errorNames.insert(std::make_pair(8464, "ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET")); + errorNames.insert(std::make_pair(8465, "ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA")); + errorNames.insert(std::make_pair(8466, "ERROR_DS_DRA_EXTN_CONNECTION_FAILED")); + errorNames.insert(std::make_pair(8467, "ERROR_DS_INSTALL_SCHEMA_MISMATCH")); + errorNames.insert(std::make_pair(8468, "ERROR_DS_DUP_LINK_ID")); + errorNames.insert(std::make_pair(8469, "ERROR_DS_NAME_ERROR_RESOLVING")); + errorNames.insert(std::make_pair(8470, "ERROR_DS_NAME_ERROR_NOT_FOUND")); + errorNames.insert(std::make_pair(8471, "ERROR_DS_NAME_ERROR_NOT_UNIQUE")); + errorNames.insert(std::make_pair(8472, "ERROR_DS_NAME_ERROR_NO_MAPPING")); + errorNames.insert(std::make_pair(8473, "ERROR_DS_NAME_ERROR_DOMAIN_ONLY")); + errorNames.insert(std::make_pair(8474, "ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING")); + errorNames.insert(std::make_pair(8475, "ERROR_DS_CONSTRUCTED_ATT_MOD")); + errorNames.insert(std::make_pair(8476, "ERROR_DS_WRONG_OM_OBJ_CLASS")); + errorNames.insert(std::make_pair(8477, "ERROR_DS_DRA_REPL_PENDING")); + errorNames.insert(std::make_pair(8478, "ERROR_DS_DS_REQUIRED")); + errorNames.insert(std::make_pair(8479, "ERROR_DS_INVALID_LDAP_DISPLAY_NAME")); + errorNames.insert(std::make_pair(8480, "ERROR_DS_NON_BASE_SEARCH")); + errorNames.insert(std::make_pair(8481, "ERROR_DS_CANT_RETRIEVE_ATTS")); + errorNames.insert(std::make_pair(8482, "ERROR_DS_BACKLINK_WITHOUT_LINK")); + errorNames.insert(std::make_pair(8483, "ERROR_DS_EPOCH_MISMATCH")); + errorNames.insert(std::make_pair(8484, "ERROR_DS_SRC_NAME_MISMATCH")); + errorNames.insert(std::make_pair(8485, "ERROR_DS_SRC_AND_DST_NC_IDENTICAL")); + errorNames.insert(std::make_pair(8486, "ERROR_DS_DST_NC_MISMATCH")); + errorNames.insert(std::make_pair(8487, "ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC")); + errorNames.insert(std::make_pair(8488, "ERROR_DS_SRC_GUID_MISMATCH")); + errorNames.insert(std::make_pair(8489, "ERROR_DS_CANT_MOVE_DELETED_OBJECT")); + errorNames.insert(std::make_pair(8490, "ERROR_DS_PDC_OPERATION_IN_PROGRESS")); + errorNames.insert(std::make_pair(8491, "ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD")); + errorNames.insert(std::make_pair(8492, "ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION")); + errorNames.insert(std::make_pair(8493, "ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS")); + errorNames.insert(std::make_pair(8494, "ERROR_DS_NC_MUST_HAVE_NC_PARENT")); + errorNames.insert(std::make_pair(8495, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE")); + errorNames.insert(std::make_pair(8496, "ERROR_DS_DST_DOMAIN_NOT_NATIVE")); + errorNames.insert(std::make_pair(8497, "ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER")); + errorNames.insert(std::make_pair(8498, "ERROR_DS_CANT_MOVE_ACCOUNT_GROUP")); + errorNames.insert(std::make_pair(8499, "ERROR_DS_CANT_MOVE_RESOURCE_GROUP")); + errorNames.insert(std::make_pair(8500, "ERROR_DS_INVALID_SEARCH_FLAG")); + errorNames.insert(std::make_pair(8501, "ERROR_DS_NO_TREE_DELETE_ABOVE_NC")); + errorNames.insert(std::make_pair(8502, "ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE")); + errorNames.insert(std::make_pair(8503, "ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE")); + errorNames.insert(std::make_pair(8504, "ERROR_DS_SAM_INIT_FAILURE")); + errorNames.insert(std::make_pair(8505, "ERROR_DS_SENSITIVE_GROUP_VIOLATION")); + errorNames.insert(std::make_pair(8506, "ERROR_DS_CANT_MOD_PRIMARYGROUPID")); + errorNames.insert(std::make_pair(8507, "ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD")); + errorNames.insert(std::make_pair(8508, "ERROR_DS_NONSAFE_SCHEMA_CHANGE")); + errorNames.insert(std::make_pair(8509, "ERROR_DS_SCHEMA_UPDATE_DISALLOWED")); + errorNames.insert(std::make_pair(8510, "ERROR_DS_CANT_CREATE_UNDER_SCHEMA")); + errorNames.insert(std::make_pair(8511, "ERROR_DS_INSTALL_NO_SRC_SCH_VERSION")); + errorNames.insert(std::make_pair(8512, "ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE")); + errorNames.insert(std::make_pair(8513, "ERROR_DS_INVALID_GROUP_TYPE")); + errorNames.insert(std::make_pair(8514, "ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN")); + errorNames.insert(std::make_pair(8515, "ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN")); + errorNames.insert(std::make_pair(8516, "ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER")); + errorNames.insert(std::make_pair(8517, "ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER")); + errorNames.insert(std::make_pair(8518, "ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER")); + errorNames.insert(std::make_pair(8519, "ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER")); + errorNames.insert(std::make_pair(8520, "ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER")); + errorNames.insert(std::make_pair(8521, "ERROR_DS_HAVE_PRIMARY_MEMBERS")); + errorNames.insert(std::make_pair(8522, "ERROR_DS_STRING_SD_CONVERSION_FAILED")); + errorNames.insert(std::make_pair(8523, "ERROR_DS_NAMING_MASTER_GC")); + errorNames.insert(std::make_pair(8524, "ERROR_DS_DNS_LOOKUP_FAILURE")); + errorNames.insert(std::make_pair(8525, "ERROR_DS_COULDNT_UPDATE_SPNS")); + errorNames.insert(std::make_pair(8526, "ERROR_DS_CANT_RETRIEVE_SD")); + errorNames.insert(std::make_pair(8527, "ERROR_DS_KEY_NOT_UNIQUE")); + errorNames.insert(std::make_pair(8528, "ERROR_DS_WRONG_LINKED_ATT_SYNTAX")); + errorNames.insert(std::make_pair(8529, "ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD")); + errorNames.insert(std::make_pair(8530, "ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY")); + errorNames.insert(std::make_pair(8531, "ERROR_DS_CANT_START")); + errorNames.insert(std::make_pair(8532, "ERROR_DS_INIT_FAILURE")); + errorNames.insert(std::make_pair(8533, "ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION")); + errorNames.insert(std::make_pair(8534, "ERROR_DS_SOURCE_DOMAIN_IN_FOREST")); + errorNames.insert(std::make_pair(8535, "ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST")); + errorNames.insert(std::make_pair(8536, "ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED")); + errorNames.insert(std::make_pair(8537, "ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN")); + errorNames.insert(std::make_pair(8538, "ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER")); + errorNames.insert(std::make_pair(8539, "ERROR_DS_SRC_SID_EXISTS_IN_FOREST")); + errorNames.insert(std::make_pair(8540, "ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH")); + errorNames.insert(std::make_pair(8541, "ERROR_SAM_INIT_FAILURE")); + errorNames.insert(std::make_pair(8542, "ERROR_DS_DRA_SCHEMA_INFO_SHIP")); + errorNames.insert(std::make_pair(8543, "ERROR_DS_DRA_SCHEMA_CONFLICT")); + errorNames.insert(std::make_pair(8544, "ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT")); + errorNames.insert(std::make_pair(8545, "ERROR_DS_DRA_OBJ_NC_MISMATCH")); + errorNames.insert(std::make_pair(8546, "ERROR_DS_NC_STILL_HAS_DSAS")); + errorNames.insert(std::make_pair(8547, "ERROR_DS_GC_REQUIRED")); + errorNames.insert(std::make_pair(8548, "ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY")); + errorNames.insert(std::make_pair(8549, "ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS")); + errorNames.insert(std::make_pair(8550, "ERROR_DS_CANT_ADD_TO_GC")); + errorNames.insert(std::make_pair(8551, "ERROR_DS_NO_CHECKPOINT_WITH_PDC")); + errorNames.insert(std::make_pair(8552, "ERROR_DS_SOURCE_AUDITING_NOT_ENABLED")); + errorNames.insert(std::make_pair(8553, "ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC")); + errorNames.insert(std::make_pair(8554, "ERROR_DS_INVALID_NAME_FOR_SPN")); + errorNames.insert(std::make_pair(8555, "ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS")); + errorNames.insert(std::make_pair(8556, "ERROR_DS_UNICODEPWD_NOT_IN_QUOTES")); + errorNames.insert(std::make_pair(8557, "ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(8558, "ERROR_DS_MUST_BE_RUN_ON_DST_DC")); + errorNames.insert(std::make_pair(8559, "ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER")); + errorNames.insert(std::make_pair(8560, "ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ")); + errorNames.insert(std::make_pair(8561, "ERROR_DS_INIT_FAILURE_CONSOLE")); + errorNames.insert(std::make_pair(8562, "ERROR_DS_SAM_INIT_FAILURE_CONSOLE")); + errorNames.insert(std::make_pair(8563, "ERROR_DS_FOREST_VERSION_TOO_HIGH")); + errorNames.insert(std::make_pair(8564, "ERROR_DS_DOMAIN_VERSION_TOO_HIGH")); + errorNames.insert(std::make_pair(8565, "ERROR_DS_FOREST_VERSION_TOO_LOW")); + errorNames.insert(std::make_pair(8566, "ERROR_DS_DOMAIN_VERSION_TOO_LOW")); + errorNames.insert(std::make_pair(8567, "ERROR_DS_INCOMPATIBLE_VERSION")); + errorNames.insert(std::make_pair(8568, "ERROR_DS_LOW_DSA_VERSION")); + errorNames.insert(std::make_pair(8569, "ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN")); + errorNames.insert(std::make_pair(8570, "ERROR_DS_NOT_SUPPORTED_SORT_ORDER")); + errorNames.insert(std::make_pair(8571, "ERROR_DS_NAME_NOT_UNIQUE")); + errorNames.insert(std::make_pair(8572, "ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4")); + errorNames.insert(std::make_pair(8573, "ERROR_DS_OUT_OF_VERSION_STORE")); + errorNames.insert(std::make_pair(8574, "ERROR_DS_INCOMPATIBLE_CONTROLS_USED")); + errorNames.insert(std::make_pair(8575, "ERROR_DS_NO_REF_DOMAIN")); + errorNames.insert(std::make_pair(8576, "ERROR_DS_RESERVED_LINK_ID")); + errorNames.insert(std::make_pair(8577, "ERROR_DS_LINK_ID_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(8578, "ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER")); + errorNames.insert(std::make_pair(8579, "ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE")); + errorNames.insert(std::make_pair(8580, "ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC")); + errorNames.insert(std::make_pair(8581, "ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG")); + errorNames.insert(std::make_pair(8582, "ERROR_DS_MODIFYDN_WRONG_GRANDPARENT")); + errorNames.insert(std::make_pair(8583, "ERROR_DS_NAME_ERROR_TRUST_REFERRAL")); + errorNames.insert(std::make_pair(8584, "ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER")); + errorNames.insert(std::make_pair(8585, "ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD")); + errorNames.insert(std::make_pair(8586, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2")); + errorNames.insert(std::make_pair(8587, "ERROR_DS_THREAD_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8588, "ERROR_DS_NOT_CLOSEST")); + errorNames.insert(std::make_pair(8589, "ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF")); + errorNames.insert(std::make_pair(8590, "ERROR_DS_SINGLE_USER_MODE_FAILED")); + errorNames.insert(std::make_pair(8591, "ERROR_DS_NTDSCRIPT_SYNTAX_ERROR")); + errorNames.insert(std::make_pair(8592, "ERROR_DS_NTDSCRIPT_PROCESS_ERROR")); + errorNames.insert(std::make_pair(8593, "ERROR_DS_DIFFERENT_REPL_EPOCHS")); + errorNames.insert(std::make_pair(8594, "ERROR_DS_DRS_EXTENSIONS_CHANGED")); + errorNames.insert(std::make_pair(8595, "ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR")); + errorNames.insert(std::make_pair(8596, "ERROR_DS_NO_MSDS_INTID")); + errorNames.insert(std::make_pair(8597, "ERROR_DS_DUP_MSDS_INTID")); + errorNames.insert(std::make_pair(8598, "ERROR_DS_EXISTS_IN_RDNATTID")); + errorNames.insert(std::make_pair(8599, "ERROR_DS_AUTHORIZATION_FAILED")); + errorNames.insert(std::make_pair(8600, "ERROR_DS_INVALID_SCRIPT")); + errorNames.insert(std::make_pair(8601, "ERROR_DS_REMOTE_CROSSREF_OP_FAILED")); + errorNames.insert(std::make_pair(8602, "ERROR_DS_CROSS_REF_BUSY")); + errorNames.insert(std::make_pair(8603, "ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN")); + errorNames.insert(std::make_pair(8604, "ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC")); + errorNames.insert(std::make_pair(8605, "ERROR_DS_DUPLICATE_ID_FOUND")); + errorNames.insert(std::make_pair(8606, "ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT")); + errorNames.insert(std::make_pair(8607, "ERROR_DS_GROUP_CONVERSION_ERROR")); + errorNames.insert(std::make_pair(8608, "ERROR_DS_CANT_MOVE_APP_BASIC_GROUP")); + errorNames.insert(std::make_pair(8609, "ERROR_DS_CANT_MOVE_APP_QUERY_GROUP")); + errorNames.insert(std::make_pair(8610, "ERROR_DS_ROLE_NOT_VERIFIED")); + errorNames.insert(std::make_pair(8611, "ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL")); + errorNames.insert(std::make_pair(8612, "ERROR_DS_DOMAIN_RENAME_IN_PROGRESS")); + errorNames.insert(std::make_pair(8613, "ERROR_DS_EXISTING_AD_CHILD_NC")); + errorNames.insert(std::make_pair(8614, "ERROR_DS_REPL_LIFETIME_EXCEEDED")); + errorNames.insert(std::make_pair(8615, "ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER")); + errorNames.insert(std::make_pair(8616, "ERROR_DS_LDAP_SEND_QUEUE_FULL")); + errorNames.insert(std::make_pair(8617, "ERROR_DS_DRA_OUT_SCHEDULE_WINDOW")); + errorNames.insert(std::make_pair(8618, "ERROR_DS_POLICY_NOT_KNOWN")); + errorNames.insert(std::make_pair(8619, "ERROR_NO_SITE_SETTINGS_OBJECT")); + errorNames.insert(std::make_pair(8620, "ERROR_NO_SECRETS")); + errorNames.insert(std::make_pair(8621, "ERROR_NO_WRITABLE_DC_FOUND")); + errorNames.insert(std::make_pair(8622, "ERROR_DS_NO_SERVER_OBJECT")); + errorNames.insert(std::make_pair(8623, "ERROR_DS_NO_NTDSA_OBJECT")); + errorNames.insert(std::make_pair(8624, "ERROR_DS_NON_ASQ_SEARCH")); + errorNames.insert(std::make_pair(8625, "ERROR_DS_AUDIT_FAILURE")); + errorNames.insert(std::make_pair(8626, "ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE")); + errorNames.insert(std::make_pair(8627, "ERROR_DS_INVALID_SEARCH_FLAG_TUPLE")); + errorNames.insert(std::make_pair(8628, "ERROR_DS_HIERARCHY_TABLE_TOO_DEEP")); + errorNames.insert(std::make_pair(8629, "ERROR_DS_DRA_CORRUPT_UTD_VECTOR")); + errorNames.insert(std::make_pair(8630, "ERROR_DS_DRA_SECRETS_DENIED")); + errorNames.insert(std::make_pair(8631, "ERROR_DS_RESERVED_MAPI_ID")); + errorNames.insert(std::make_pair(8632, "ERROR_DS_MAPI_ID_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(8633, "ERROR_DS_DRA_MISSING_KRBTGT_SECRET")); + errorNames.insert(std::make_pair(8634, "ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST")); + errorNames.insert(std::make_pair(8635, "ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST")); + errorNames.insert(std::make_pair(8636, "ERROR_INVALID_USER_PRINCIPAL_NAME")); + errorNames.insert(std::make_pair(8637, "ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS")); + errorNames.insert(std::make_pair(8638, "ERROR_DS_OID_NOT_FOUND")); + errorNames.insert(std::make_pair(8639, "ERROR_DS_DRA_RECYCLED_TARGET")); + errorNames.insert(std::make_pair(13000, "ERROR_IPSEC_QM_POLICY_EXISTS")); + errorNames.insert(std::make_pair(13001, "ERROR_IPSEC_QM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13002, "ERROR_IPSEC_QM_POLICY_IN_USE")); + errorNames.insert(std::make_pair(13003, "ERROR_IPSEC_MM_POLICY_EXISTS")); + errorNames.insert(std::make_pair(13004, "ERROR_IPSEC_MM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13005, "ERROR_IPSEC_MM_POLICY_IN_USE")); + errorNames.insert(std::make_pair(13006, "ERROR_IPSEC_MM_FILTER_EXISTS")); + errorNames.insert(std::make_pair(13007, "ERROR_IPSEC_MM_FILTER_NOT_FOUND")); + errorNames.insert(std::make_pair(13008, "ERROR_IPSEC_TRANSPORT_FILTER_EXISTS")); + errorNames.insert(std::make_pair(13009, "ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND")); + errorNames.insert(std::make_pair(13010, "ERROR_IPSEC_MM_AUTH_EXISTS")); + errorNames.insert(std::make_pair(13011, "ERROR_IPSEC_MM_AUTH_NOT_FOUND")); + errorNames.insert(std::make_pair(13012, "ERROR_IPSEC_MM_AUTH_IN_USE")); + errorNames.insert(std::make_pair(13013, "ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13014, "ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND")); + errorNames.insert(std::make_pair(13015, "ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13016, "ERROR_IPSEC_TUNNEL_FILTER_EXISTS")); + errorNames.insert(std::make_pair(13017, "ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND")); + errorNames.insert(std::make_pair(13018, "ERROR_IPSEC_MM_FILTER_PENDING_DELETION")); + errorNames.insert(std::make_pair(13019, "ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION")); + errorNames.insert(std::make_pair(13020, "ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION")); + errorNames.insert(std::make_pair(13021, "ERROR_IPSEC_MM_POLICY_PENDING_DELETION")); + errorNames.insert(std::make_pair(13022, "ERROR_IPSEC_MM_AUTH_PENDING_DELETION")); + errorNames.insert(std::make_pair(13023, "ERROR_IPSEC_QM_POLICY_PENDING_DELETION")); + errorNames.insert(std::make_pair(13800, "ERROR_IPSEC_IKE_NEG_STATUS_BEGIN")); + errorNames.insert(std::make_pair(13801, "ERROR_IPSEC_IKE_AUTH_FAIL")); + errorNames.insert(std::make_pair(13802, "ERROR_IPSEC_IKE_ATTRIB_FAIL")); + errorNames.insert(std::make_pair(13803, "ERROR_IPSEC_IKE_NEGOTIATION_PENDING")); + errorNames.insert(std::make_pair(13804, "ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR")); + errorNames.insert(std::make_pair(13805, "ERROR_IPSEC_IKE_TIMED_OUT")); + errorNames.insert(std::make_pair(13806, "ERROR_IPSEC_IKE_NO_CERT")); + errorNames.insert(std::make_pair(13807, "ERROR_IPSEC_IKE_SA_DELETED")); + errorNames.insert(std::make_pair(13808, "ERROR_IPSEC_IKE_SA_REAPED")); + errorNames.insert(std::make_pair(13809, "ERROR_IPSEC_IKE_MM_ACQUIRE_DROP")); + errorNames.insert(std::make_pair(13810, "ERROR_IPSEC_IKE_QM_ACQUIRE_DROP")); + errorNames.insert(std::make_pair(13811, "ERROR_IPSEC_IKE_QUEUE_DROP_MM")); + errorNames.insert(std::make_pair(13812, "ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM")); + errorNames.insert(std::make_pair(13813, "ERROR_IPSEC_IKE_DROP_NO_RESPONSE")); + errorNames.insert(std::make_pair(13814, "ERROR_IPSEC_IKE_MM_DELAY_DROP")); + errorNames.insert(std::make_pair(13815, "ERROR_IPSEC_IKE_QM_DELAY_DROP")); + errorNames.insert(std::make_pair(13816, "ERROR_IPSEC_IKE_ERROR")); + errorNames.insert(std::make_pair(13817, "ERROR_IPSEC_IKE_CRL_FAILED")); + errorNames.insert(std::make_pair(13818, "ERROR_IPSEC_IKE_INVALID_KEY_USAGE")); + errorNames.insert(std::make_pair(13819, "ERROR_IPSEC_IKE_INVALID_CERT_TYPE")); + errorNames.insert(std::make_pair(13820, "ERROR_IPSEC_IKE_NO_PRIVATE_KEY")); + errorNames.insert(std::make_pair(13821, "ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY")); + errorNames.insert(std::make_pair(13822, "ERROR_IPSEC_IKE_DH_FAIL")); + errorNames.insert(std::make_pair(13823, "ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED")); + errorNames.insert(std::make_pair(13824, "ERROR_IPSEC_IKE_INVALID_HEADER")); + errorNames.insert(std::make_pair(13825, "ERROR_IPSEC_IKE_NO_POLICY")); + errorNames.insert(std::make_pair(13826, "ERROR_IPSEC_IKE_INVALID_SIGNATURE")); + errorNames.insert(std::make_pair(13827, "ERROR_IPSEC_IKE_KERBEROS_ERROR")); + errorNames.insert(std::make_pair(13828, "ERROR_IPSEC_IKE_NO_PUBLIC_KEY")); + errorNames.insert(std::make_pair(13829, "ERROR_IPSEC_IKE_PROCESS_ERR")); + errorNames.insert(std::make_pair(13830, "ERROR_IPSEC_IKE_PROCESS_ERR_SA")); + errorNames.insert(std::make_pair(13831, "ERROR_IPSEC_IKE_PROCESS_ERR_PROP")); + errorNames.insert(std::make_pair(13832, "ERROR_IPSEC_IKE_PROCESS_ERR_TRANS")); + errorNames.insert(std::make_pair(13833, "ERROR_IPSEC_IKE_PROCESS_ERR_KE")); + errorNames.insert(std::make_pair(13834, "ERROR_IPSEC_IKE_PROCESS_ERR_ID")); + errorNames.insert(std::make_pair(13835, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT")); + errorNames.insert(std::make_pair(13836, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ")); + errorNames.insert(std::make_pair(13837, "ERROR_IPSEC_IKE_PROCESS_ERR_HASH")); + errorNames.insert(std::make_pair(13838, "ERROR_IPSEC_IKE_PROCESS_ERR_SIG")); + errorNames.insert(std::make_pair(13839, "ERROR_IPSEC_IKE_PROCESS_ERR_NONCE")); + errorNames.insert(std::make_pair(13840, "ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY")); + errorNames.insert(std::make_pair(13841, "ERROR_IPSEC_IKE_PROCESS_ERR_DELETE")); + errorNames.insert(std::make_pair(13842, "ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR")); + errorNames.insert(std::make_pair(13843, "ERROR_IPSEC_IKE_INVALID_PAYLOAD")); + errorNames.insert(std::make_pair(13844, "ERROR_IPSEC_IKE_LOAD_SOFT_SA")); + errorNames.insert(std::make_pair(13845, "ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN")); + errorNames.insert(std::make_pair(13846, "ERROR_IPSEC_IKE_INVALID_COOKIE")); + errorNames.insert(std::make_pair(13847, "ERROR_IPSEC_IKE_NO_PEER_CERT")); + errorNames.insert(std::make_pair(13848, "ERROR_IPSEC_IKE_PEER_CRL_FAILED")); + errorNames.insert(std::make_pair(13849, "ERROR_IPSEC_IKE_POLICY_CHANGE")); + errorNames.insert(std::make_pair(13850, "ERROR_IPSEC_IKE_NO_MM_POLICY")); + errorNames.insert(std::make_pair(13851, "ERROR_IPSEC_IKE_NOTCBPRIV")); + errorNames.insert(std::make_pair(13852, "ERROR_IPSEC_IKE_SECLOADFAIL")); + errorNames.insert(std::make_pair(13853, "ERROR_IPSEC_IKE_FAILSSPINIT")); + errorNames.insert(std::make_pair(13854, "ERROR_IPSEC_IKE_FAILQUERYSSP")); + errorNames.insert(std::make_pair(13855, "ERROR_IPSEC_IKE_SRVACQFAIL")); + errorNames.insert(std::make_pair(13856, "ERROR_IPSEC_IKE_SRVQUERYCRED")); + errorNames.insert(std::make_pair(13857, "ERROR_IPSEC_IKE_GETSPIFAIL")); + errorNames.insert(std::make_pair(13858, "ERROR_IPSEC_IKE_INVALID_FILTER")); + errorNames.insert(std::make_pair(13859, "ERROR_IPSEC_IKE_OUT_OF_MEMORY")); + errorNames.insert(std::make_pair(13860, "ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED")); + errorNames.insert(std::make_pair(13861, "ERROR_IPSEC_IKE_INVALID_POLICY")); + errorNames.insert(std::make_pair(13862, "ERROR_IPSEC_IKE_UNKNOWN_DOI")); + errorNames.insert(std::make_pair(13863, "ERROR_IPSEC_IKE_INVALID_SITUATION")); + errorNames.insert(std::make_pair(13864, "ERROR_IPSEC_IKE_DH_FAILURE")); + errorNames.insert(std::make_pair(13865, "ERROR_IPSEC_IKE_INVALID_GROUP")); + errorNames.insert(std::make_pair(13866, "ERROR_IPSEC_IKE_ENCRYPT")); + errorNames.insert(std::make_pair(13867, "ERROR_IPSEC_IKE_DECRYPT")); + errorNames.insert(std::make_pair(13868, "ERROR_IPSEC_IKE_POLICY_MATCH")); + errorNames.insert(std::make_pair(13869, "ERROR_IPSEC_IKE_UNSUPPORTED_ID")); + errorNames.insert(std::make_pair(13870, "ERROR_IPSEC_IKE_INVALID_HASH")); + errorNames.insert(std::make_pair(13871, "ERROR_IPSEC_IKE_INVALID_HASH_ALG")); + errorNames.insert(std::make_pair(13872, "ERROR_IPSEC_IKE_INVALID_HASH_SIZE")); + errorNames.insert(std::make_pair(13873, "ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG")); + errorNames.insert(std::make_pair(13874, "ERROR_IPSEC_IKE_INVALID_AUTH_ALG")); + errorNames.insert(std::make_pair(13875, "ERROR_IPSEC_IKE_INVALID_SIG")); + errorNames.insert(std::make_pair(13876, "ERROR_IPSEC_IKE_LOAD_FAILED")); + errorNames.insert(std::make_pair(13877, "ERROR_IPSEC_IKE_RPC_DELETE")); + errorNames.insert(std::make_pair(13878, "ERROR_IPSEC_IKE_BENIGN_REINIT")); + errorNames.insert(std::make_pair(13879, "ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY")); + errorNames.insert(std::make_pair(13880, "ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION")); + errorNames.insert(std::make_pair(13881, "ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN")); + errorNames.insert(std::make_pair(13882, "ERROR_IPSEC_IKE_MM_LIMIT")); + errorNames.insert(std::make_pair(13883, "ERROR_IPSEC_IKE_NEGOTIATION_DISABLED")); + errorNames.insert(std::make_pair(13884, "ERROR_IPSEC_IKE_QM_LIMIT")); + errorNames.insert(std::make_pair(13885, "ERROR_IPSEC_IKE_MM_EXPIRED")); + errorNames.insert(std::make_pair(13886, "ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID")); + errorNames.insert(std::make_pair(13887, "ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH")); + errorNames.insert(std::make_pair(13888, "ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID")); + errorNames.insert(std::make_pair(13889, "ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD")); + errorNames.insert(std::make_pair(13890, "ERROR_IPSEC_IKE_DOS_COOKIE_SENT")); + errorNames.insert(std::make_pair(13891, "ERROR_IPSEC_IKE_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(13892, "ERROR_IPSEC_IKE_CGA_AUTH_FAILED")); + errorNames.insert(std::make_pair(13893, "ERROR_IPSEC_IKE_PROCESS_ERR_NATOA")); + errorNames.insert(std::make_pair(13894, "ERROR_IPSEC_IKE_INVALID_MM_FOR_QM")); + errorNames.insert(std::make_pair(13895, "ERROR_IPSEC_IKE_QM_EXPIRED")); + errorNames.insert(std::make_pair(13896, "ERROR_IPSEC_IKE_TOO_MANY_FILTERS")); + errorNames.insert(std::make_pair(13897, "ERROR_IPSEC_IKE_NEG_STATUS_END")); + errorNames.insert(std::make_pair(13898, "ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL")); + errorNames.insert(std::make_pair(13899, "ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE")); + errorNames.insert(std::make_pair(13900, "ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING")); + errorNames.insert(std::make_pair(13901, "ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING")); + errorNames.insert(std::make_pair(13902, "ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS")); + errorNames.insert(std::make_pair(13903, "ERROR_IPSEC_IKE_RATELIMIT_DROP")); + errorNames.insert(std::make_pair(13904, "ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE")); + errorNames.insert(std::make_pair(13905, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE")); + errorNames.insert(std::make_pair(13906, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE")); + errorNames.insert(std::make_pair(13907, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY")); + errorNames.insert(std::make_pair(13908, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE")); + errorNames.insert(std::make_pair(13909, "ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END")); + errorNames.insert(std::make_pair(13910, "ERROR_IPSEC_BAD_SPI")); + errorNames.insert(std::make_pair(13911, "ERROR_IPSEC_SA_LIFETIME_EXPIRED")); + errorNames.insert(std::make_pair(13912, "ERROR_IPSEC_WRONG_SA")); + errorNames.insert(std::make_pair(13913, "ERROR_IPSEC_REPLAY_CHECK_FAILED")); + errorNames.insert(std::make_pair(13914, "ERROR_IPSEC_INVALID_PACKET")); + errorNames.insert(std::make_pair(13915, "ERROR_IPSEC_INTEGRITY_CHECK_FAILED")); + errorNames.insert(std::make_pair(13916, "ERROR_IPSEC_CLEAR_TEXT_DROP")); + errorNames.insert(std::make_pair(13917, "ERROR_IPSEC_AUTH_FIREWALL_DROP")); + errorNames.insert(std::make_pair(13918, "ERROR_IPSEC_THROTTLE_DROP")); + errorNames.insert(std::make_pair(13925, "ERROR_IPSEC_DOSP_BLOCK")); + errorNames.insert(std::make_pair(13926, "ERROR_IPSEC_DOSP_RECEIVED_MULTICAST")); + errorNames.insert(std::make_pair(13927, "ERROR_IPSEC_DOSP_INVALID_PACKET")); + errorNames.insert(std::make_pair(13928, "ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED")); + errorNames.insert(std::make_pair(13929, "ERROR_IPSEC_DOSP_MAX_ENTRIES")); + errorNames.insert(std::make_pair(13930, "ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED")); + errorNames.insert(std::make_pair(13931, "ERROR_IPSEC_DOSP_NOT_INSTALLED")); + errorNames.insert(std::make_pair(13932, "ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES")); + errorNames.insert(std::make_pair(14000, "ERROR_SXS_SECTION_NOT_FOUND")); + errorNames.insert(std::make_pair(14001, "ERROR_SXS_CANT_GEN_ACTCTX")); + errorNames.insert(std::make_pair(14002, "ERROR_SXS_INVALID_ACTCTXDATA_FORMAT")); + errorNames.insert(std::make_pair(14003, "ERROR_SXS_ASSEMBLY_NOT_FOUND")); + errorNames.insert(std::make_pair(14004, "ERROR_SXS_MANIFEST_FORMAT_ERROR")); + errorNames.insert(std::make_pair(14005, "ERROR_SXS_MANIFEST_PARSE_ERROR")); + errorNames.insert(std::make_pair(14006, "ERROR_SXS_ACTIVATION_CONTEXT_DISABLED")); + errorNames.insert(std::make_pair(14007, "ERROR_SXS_KEY_NOT_FOUND")); + errorNames.insert(std::make_pair(14008, "ERROR_SXS_VERSION_CONFLICT")); + errorNames.insert(std::make_pair(14009, "ERROR_SXS_WRONG_SECTION_TYPE")); + errorNames.insert(std::make_pair(14010, "ERROR_SXS_THREAD_QUERIES_DISABLED")); + errorNames.insert(std::make_pair(14011, "ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET")); + errorNames.insert(std::make_pair(14012, "ERROR_SXS_UNKNOWN_ENCODING_GROUP")); + errorNames.insert(std::make_pair(14013, "ERROR_SXS_UNKNOWN_ENCODING")); + errorNames.insert(std::make_pair(14014, "ERROR_SXS_INVALID_XML_NAMESPACE_URI")); + errorNames.insert(std::make_pair(14015, "ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED")); + errorNames.insert(std::make_pair(14016, "ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED")); + errorNames.insert(std::make_pair(14017, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE")); + errorNames.insert(std::make_pair(14018, "ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE")); + errorNames.insert(std::make_pair(14019, "ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE")); + errorNames.insert(std::make_pair(14020, "ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT")); + errorNames.insert(std::make_pair(14021, "ERROR_SXS_DUPLICATE_DLL_NAME")); + errorNames.insert(std::make_pair(14022, "ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME")); + errorNames.insert(std::make_pair(14023, "ERROR_SXS_DUPLICATE_CLSID")); + errorNames.insert(std::make_pair(14024, "ERROR_SXS_DUPLICATE_IID")); + errorNames.insert(std::make_pair(14025, "ERROR_SXS_DUPLICATE_TLBID")); + errorNames.insert(std::make_pair(14026, "ERROR_SXS_DUPLICATE_PROGID")); + errorNames.insert(std::make_pair(14027, "ERROR_SXS_DUPLICATE_ASSEMBLY_NAME")); + errorNames.insert(std::make_pair(14028, "ERROR_SXS_FILE_HASH_MISMATCH")); + errorNames.insert(std::make_pair(14029, "ERROR_SXS_POLICY_PARSE_ERROR")); + errorNames.insert(std::make_pair(14030, "ERROR_SXS_XML_E_MISSINGQUOTE")); + errorNames.insert(std::make_pair(14031, "ERROR_SXS_XML_E_COMMENTSYNTAX")); + errorNames.insert(std::make_pair(14032, "ERROR_SXS_XML_E_BADSTARTNAMECHAR")); + errorNames.insert(std::make_pair(14033, "ERROR_SXS_XML_E_BADNAMECHAR")); + errorNames.insert(std::make_pair(14034, "ERROR_SXS_XML_E_BADCHARINSTRING")); + errorNames.insert(std::make_pair(14035, "ERROR_SXS_XML_E_XMLDECLSYNTAX")); + errorNames.insert(std::make_pair(14036, "ERROR_SXS_XML_E_BADCHARDATA")); + errorNames.insert(std::make_pair(14037, "ERROR_SXS_XML_E_MISSINGWHITESPACE")); + errorNames.insert(std::make_pair(14038, "ERROR_SXS_XML_E_EXPECTINGTAGEND")); + errorNames.insert(std::make_pair(14039, "ERROR_SXS_XML_E_MISSINGSEMICOLON")); + errorNames.insert(std::make_pair(14040, "ERROR_SXS_XML_E_UNBALANCEDPAREN")); + errorNames.insert(std::make_pair(14041, "ERROR_SXS_XML_E_INTERNALERROR")); + errorNames.insert(std::make_pair(14042, "ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE")); + errorNames.insert(std::make_pair(14043, "ERROR_SXS_XML_E_INCOMPLETE_ENCODING")); + errorNames.insert(std::make_pair(14044, "ERROR_SXS_XML_E_MISSING_PAREN")); + errorNames.insert(std::make_pair(14045, "ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE")); + errorNames.insert(std::make_pair(14046, "ERROR_SXS_XML_E_MULTIPLE_COLONS")); + errorNames.insert(std::make_pair(14047, "ERROR_SXS_XML_E_INVALID_DECIMAL")); + errorNames.insert(std::make_pair(14048, "ERROR_SXS_XML_E_INVALID_HEXIDECIMAL")); + errorNames.insert(std::make_pair(14049, "ERROR_SXS_XML_E_INVALID_UNICODE")); + errorNames.insert(std::make_pair(14050, "ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK")); + errorNames.insert(std::make_pair(14051, "ERROR_SXS_XML_E_UNEXPECTEDENDTAG")); + errorNames.insert(std::make_pair(14052, "ERROR_SXS_XML_E_UNCLOSEDTAG")); + errorNames.insert(std::make_pair(14053, "ERROR_SXS_XML_E_DUPLICATEATTRIBUTE")); + errorNames.insert(std::make_pair(14054, "ERROR_SXS_XML_E_MULTIPLEROOTS")); + errorNames.insert(std::make_pair(14055, "ERROR_SXS_XML_E_INVALIDATROOTLEVEL")); + errorNames.insert(std::make_pair(14056, "ERROR_SXS_XML_E_BADXMLDECL")); + errorNames.insert(std::make_pair(14057, "ERROR_SXS_XML_E_MISSINGROOT")); + errorNames.insert(std::make_pair(14058, "ERROR_SXS_XML_E_UNEXPECTEDEOF")); + errorNames.insert(std::make_pair(14059, "ERROR_SXS_XML_E_BADPEREFINSUBSET")); + errorNames.insert(std::make_pair(14060, "ERROR_SXS_XML_E_UNCLOSEDSTARTTAG")); + errorNames.insert(std::make_pair(14061, "ERROR_SXS_XML_E_UNCLOSEDENDTAG")); + errorNames.insert(std::make_pair(14062, "ERROR_SXS_XML_E_UNCLOSEDSTRING")); + errorNames.insert(std::make_pair(14063, "ERROR_SXS_XML_E_UNCLOSEDCOMMENT")); + errorNames.insert(std::make_pair(14064, "ERROR_SXS_XML_E_UNCLOSEDDECL")); + errorNames.insert(std::make_pair(14065, "ERROR_SXS_XML_E_UNCLOSEDCDATA")); + errorNames.insert(std::make_pair(14066, "ERROR_SXS_XML_E_RESERVEDNAMESPACE")); + errorNames.insert(std::make_pair(14067, "ERROR_SXS_XML_E_INVALIDENCODING")); + errorNames.insert(std::make_pair(14068, "ERROR_SXS_XML_E_INVALIDSWITCH")); + errorNames.insert(std::make_pair(14069, "ERROR_SXS_XML_E_BADXMLCASE")); + errorNames.insert(std::make_pair(14070, "ERROR_SXS_XML_E_INVALID_STANDALONE")); + errorNames.insert(std::make_pair(14071, "ERROR_SXS_XML_E_UNEXPECTED_STANDALONE")); + errorNames.insert(std::make_pair(14072, "ERROR_SXS_XML_E_INVALID_VERSION")); + errorNames.insert(std::make_pair(14073, "ERROR_SXS_XML_E_MISSINGEQUALS")); + errorNames.insert(std::make_pair(14074, "ERROR_SXS_PROTECTION_RECOVERY_FAILED")); + errorNames.insert(std::make_pair(14075, "ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT")); + errorNames.insert(std::make_pair(14076, "ERROR_SXS_PROTECTION_CATALOG_NOT_VALID")); + errorNames.insert(std::make_pair(14077, "ERROR_SXS_UNTRANSLATABLE_HRESULT")); + errorNames.insert(std::make_pair(14078, "ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING")); + errorNames.insert(std::make_pair(14079, "ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE")); + errorNames.insert(std::make_pair(14080, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME")); + errorNames.insert(std::make_pair(14081, "ERROR_SXS_ASSEMBLY_MISSING")); + errorNames.insert(std::make_pair(14082, "ERROR_SXS_CORRUPT_ACTIVATION_STACK")); + errorNames.insert(std::make_pair(14083, "ERROR_SXS_CORRUPTION")); + errorNames.insert(std::make_pair(14084, "ERROR_SXS_EARLY_DEACTIVATION")); + errorNames.insert(std::make_pair(14085, "ERROR_SXS_INVALID_DEACTIVATION")); + errorNames.insert(std::make_pair(14086, "ERROR_SXS_MULTIPLE_DEACTIVATION")); + errorNames.insert(std::make_pair(14087, "ERROR_SXS_PROCESS_TERMINATION_REQUESTED")); + errorNames.insert(std::make_pair(14088, "ERROR_SXS_RELEASE_ACTIVATION_CONTEXT")); + errorNames.insert(std::make_pair(14089, "ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY")); + errorNames.insert(std::make_pair(14090, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE")); + errorNames.insert(std::make_pair(14091, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME")); + errorNames.insert(std::make_pair(14092, "ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE")); + errorNames.insert(std::make_pair(14093, "ERROR_SXS_IDENTITY_PARSE_ERROR")); + errorNames.insert(std::make_pair(14094, "ERROR_MALFORMED_SUBSTITUTION_STRING")); + errorNames.insert(std::make_pair(14095, "ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN")); + errorNames.insert(std::make_pair(14096, "ERROR_UNMAPPED_SUBSTITUTION_STRING")); + errorNames.insert(std::make_pair(14097, "ERROR_SXS_ASSEMBLY_NOT_LOCKED")); + errorNames.insert(std::make_pair(14098, "ERROR_SXS_COMPONENT_STORE_CORRUPT")); + errorNames.insert(std::make_pair(14099, "ERROR_ADVANCED_INSTALLER_FAILED")); + errorNames.insert(std::make_pair(14100, "ERROR_XML_ENCODING_MISMATCH")); + errorNames.insert(std::make_pair(14101, "ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT")); + errorNames.insert(std::make_pair(14102, "ERROR_SXS_IDENTITIES_DIFFERENT")); + errorNames.insert(std::make_pair(14103, "ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT")); + errorNames.insert(std::make_pair(14104, "ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY")); + errorNames.insert(std::make_pair(14105, "ERROR_SXS_MANIFEST_TOO_BIG")); + errorNames.insert(std::make_pair(14106, "ERROR_SXS_SETTING_NOT_REGISTERED")); + errorNames.insert(std::make_pair(14107, "ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE")); + errorNames.insert(std::make_pair(14108, "ERROR_SMI_PRIMITIVE_INSTALLER_FAILED")); + errorNames.insert(std::make_pair(14109, "ERROR_GENERIC_COMMAND_FAILED")); + errorNames.insert(std::make_pair(14110, "ERROR_SXS_FILE_HASH_MISSING")); + errorNames.insert(std::make_pair(15000, "ERROR_EVT_INVALID_CHANNEL_PATH")); + errorNames.insert(std::make_pair(15001, "ERROR_EVT_INVALID_QUERY")); + errorNames.insert(std::make_pair(15002, "ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND")); + errorNames.insert(std::make_pair(15003, "ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND")); + errorNames.insert(std::make_pair(15004, "ERROR_EVT_INVALID_PUBLISHER_NAME")); + errorNames.insert(std::make_pair(15005, "ERROR_EVT_INVALID_EVENT_DATA")); + errorNames.insert(std::make_pair(15007, "ERROR_EVT_CHANNEL_NOT_FOUND")); + errorNames.insert(std::make_pair(15008, "ERROR_EVT_MALFORMED_XML_TEXT")); + errorNames.insert(std::make_pair(15009, "ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL")); + errorNames.insert(std::make_pair(15010, "ERROR_EVT_CONFIGURATION_ERROR")); + errorNames.insert(std::make_pair(15011, "ERROR_EVT_QUERY_RESULT_STALE")); + errorNames.insert(std::make_pair(15012, "ERROR_EVT_QUERY_RESULT_INVALID_POSITION")); + errorNames.insert(std::make_pair(15013, "ERROR_EVT_NON_VALIDATING_MSXML")); + errorNames.insert(std::make_pair(15014, "ERROR_EVT_FILTER_ALREADYSCOPED")); + errorNames.insert(std::make_pair(15015, "ERROR_EVT_FILTER_NOTELTSET")); + errorNames.insert(std::make_pair(15016, "ERROR_EVT_FILTER_INVARG")); + errorNames.insert(std::make_pair(15017, "ERROR_EVT_FILTER_INVTEST")); + errorNames.insert(std::make_pair(15018, "ERROR_EVT_FILTER_INVTYPE")); + errorNames.insert(std::make_pair(15019, "ERROR_EVT_FILTER_PARSEERR")); + errorNames.insert(std::make_pair(15020, "ERROR_EVT_FILTER_UNSUPPORTEDOP")); + errorNames.insert(std::make_pair(15021, "ERROR_EVT_FILTER_UNEXPECTEDTOKEN")); + errorNames.insert(std::make_pair(15022, "ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL")); + errorNames.insert(std::make_pair(15023, "ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE")); + errorNames.insert(std::make_pair(15024, "ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE")); + errorNames.insert(std::make_pair(15025, "ERROR_EVT_CHANNEL_CANNOT_ACTIVATE")); + errorNames.insert(std::make_pair(15026, "ERROR_EVT_FILTER_TOO_COMPLEX")); + errorNames.insert(std::make_pair(15027, "ERROR_EVT_MESSAGE_NOT_FOUND")); + errorNames.insert(std::make_pair(15028, "ERROR_EVT_MESSAGE_ID_NOT_FOUND")); + errorNames.insert(std::make_pair(15029, "ERROR_EVT_UNRESOLVED_VALUE_INSERT")); + errorNames.insert(std::make_pair(15030, "ERROR_EVT_UNRESOLVED_PARAMETER_INSERT")); + errorNames.insert(std::make_pair(15031, "ERROR_EVT_MAX_INSERTS_REACHED")); + errorNames.insert(std::make_pair(15032, "ERROR_EVT_EVENT_DEFINITION_NOT_FOUND")); + errorNames.insert(std::make_pair(15033, "ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND")); + errorNames.insert(std::make_pair(15034, "ERROR_EVT_VERSION_TOO_OLD")); + errorNames.insert(std::make_pair(15035, "ERROR_EVT_VERSION_TOO_NEW")); + errorNames.insert(std::make_pair(15036, "ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY")); + errorNames.insert(std::make_pair(15037, "ERROR_EVT_PUBLISHER_DISABLED")); + errorNames.insert(std::make_pair(15038, "ERROR_EVT_FILTER_OUT_OF_RANGE")); + errorNames.insert(std::make_pair(15080, "ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE")); + errorNames.insert(std::make_pair(15081, "ERROR_EC_LOG_DISABLED")); + errorNames.insert(std::make_pair(15082, "ERROR_EC_CIRCULAR_FORWARDING")); + errorNames.insert(std::make_pair(15083, "ERROR_EC_CREDSTORE_FULL")); + errorNames.insert(std::make_pair(15084, "ERROR_EC_CRED_NOT_FOUND")); + errorNames.insert(std::make_pair(15085, "ERROR_EC_NO_ACTIVE_CHANNEL")); + errorNames.insert(std::make_pair(15100, "ERROR_MUI_FILE_NOT_FOUND")); + errorNames.insert(std::make_pair(15101, "ERROR_MUI_INVALID_FILE")); + errorNames.insert(std::make_pair(15102, "ERROR_MUI_INVALID_RC_CONFIG")); + errorNames.insert(std::make_pair(15103, "ERROR_MUI_INVALID_LOCALE_NAME")); + errorNames.insert(std::make_pair(15104, "ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME")); + errorNames.insert(std::make_pair(15105, "ERROR_MUI_FILE_NOT_LOADED")); + errorNames.insert(std::make_pair(15106, "ERROR_RESOURCE_ENUM_USER_STOP")); + errorNames.insert(std::make_pair(15107, "ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED")); + errorNames.insert(std::make_pair(15108, "ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME")); + errorNames.insert(std::make_pair(15200, "ERROR_MCA_INVALID_CAPABILITIES_STRING")); + errorNames.insert(std::make_pair(15201, "ERROR_MCA_INVALID_VCP_VERSION")); + errorNames.insert(std::make_pair(15202, "ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION")); + errorNames.insert(std::make_pair(15203, "ERROR_MCA_MCCS_VERSION_MISMATCH")); + errorNames.insert(std::make_pair(15204, "ERROR_MCA_UNSUPPORTED_MCCS_VERSION")); + errorNames.insert(std::make_pair(15205, "ERROR_MCA_INTERNAL_ERROR")); + errorNames.insert(std::make_pair(15206, "ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED")); + errorNames.insert(std::make_pair(15207, "ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE")); + errorNames.insert(std::make_pair(15250, "ERROR_AMBIGUOUS_SYSTEM_DEVICE")); + errorNames.insert(std::make_pair(15299, "ERROR_SYSTEM_DEVICE_NOT_FOUND")); + errorNames.insert(std::make_pair(15300, "ERROR_HASH_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(15301, "ERROR_HASH_NOT_PRESENT")); +} + +const char* errornamefromcode(unsigned int ErrorCode) +{ + if(!errorNames.count(ErrorCode)) + return 0; + return errorNames[ErrorCode]; +} \ No newline at end of file diff --git a/x64_dbg_dbg/error.h b/x64_dbg_dbg/error.h new file mode 100644 index 00000000..7b4eeac1 --- /dev/null +++ b/x64_dbg_dbg/error.h @@ -0,0 +1,7 @@ +#ifndef _ERROR_H +#define _ERROR_H + +void errorinit(); +const char* errornamefromcode(unsigned int ErrorCode); + +#endif //_ERROR_H \ No newline at end of file diff --git a/x64_dbg_dbg/exception.cpp b/x64_dbg_dbg/exception.cpp new file mode 100644 index 00000000..8e000e6b --- /dev/null +++ b/x64_dbg_dbg/exception.cpp @@ -0,0 +1,77 @@ +#include "exception.h" +#include + +static std::map exceptionNames; + +void exceptioninit() +{ + exceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); + exceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); + exceptionNames.insert(std::make_pair(0x4000001D, "STATUS_WX86_CONTINUE")); + exceptionNames.insert(std::make_pair(0x4000001E, "STATUS_WX86_SINGLE_STEP")); + exceptionNames.insert(std::make_pair(0x4000001F, "STATUS_WX86_BREAKPOINT")); + exceptionNames.insert(std::make_pair(0x40000020, "STATUS_WX86_EXCEPTION_CONTINUE")); + exceptionNames.insert(std::make_pair(0x40000021, "STATUS_WX86_EXCEPTION_LASTCHANCE")); + exceptionNames.insert(std::make_pair(0x40000022, "STATUS_WX86_EXCEPTION_CHAIN")); + exceptionNames.insert(std::make_pair(0x40000028, "STATUS_WX86_CREATEWX86TIB")); + exceptionNames.insert(std::make_pair(0x40010003, "DBG_TERMINATE_THREAD")); + exceptionNames.insert(std::make_pair(0x40010004, "DBG_TERMINATE_PROCESS")); + exceptionNames.insert(std::make_pair(0x40010005, "DBG_CONTROL_C")); + exceptionNames.insert(std::make_pair(0x40010006, "DBG_PRINTEXCEPTION_C")); + exceptionNames.insert(std::make_pair(0x40010007, "DBG_RIPEXCEPTION")); + exceptionNames.insert(std::make_pair(0x40010008, "DBG_CONTROL_BREAK")); + exceptionNames.insert(std::make_pair(0x40010009, "DBG_COMMAND_EXCEPTION")); + exceptionNames.insert(std::make_pair(0x80000001, "EXCEPTION_GUARD_PAGE")); + exceptionNames.insert(std::make_pair(0x80000002, "EXCEPTION_DATATYPE_MISALIGNMENT")); + exceptionNames.insert(std::make_pair(0x80000003, "EXCEPTION_BREAKPOINT")); + exceptionNames.insert(std::make_pair(0x80000004, "EXCEPTION_SINGLE_STEP")); + exceptionNames.insert(std::make_pair(0x80000026, "STATUS_LONGJUMP")); + exceptionNames.insert(std::make_pair(0x80000029, "STATUS_UNWIND_CONSOLIDATE")); + exceptionNames.insert(std::make_pair(0x80010001, "DBG_EXCEPTION_NOT_HANDLED")); + exceptionNames.insert(std::make_pair(0xC0000005, "EXCEPTION_ACCESS_VIOLATION")); + exceptionNames.insert(std::make_pair(0xC0000006, "EXCEPTION_IN_PAGE_ERROR")); + exceptionNames.insert(std::make_pair(0xC0000008, "EXCEPTION_INVALID_HANDLE")); + exceptionNames.insert(std::make_pair(0xC000000D, "STATUS_INVALID_PARAMETER")); + exceptionNames.insert(std::make_pair(0xC0000017, "STATUS_NO_MEMORY")); + exceptionNames.insert(std::make_pair(0xC000001D, "EXCEPTION_ILLEGAL_INSTRUCTION")); + exceptionNames.insert(std::make_pair(0xC0000025, "EXCEPTION_NONCONTINUABLE_EXCEPTION")); + exceptionNames.insert(std::make_pair(0xC0000026, "EXCEPTION_INVALID_DISPOSITION")); + exceptionNames.insert(std::make_pair(0xC000008C, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED")); + exceptionNames.insert(std::make_pair(0xC000008D, "EXCEPTION_FLT_DENORMAL_OPERAND")); + exceptionNames.insert(std::make_pair(0xC000008E, "EXCEPTION_FLT_DIVIDE_BY_ZERO")); + exceptionNames.insert(std::make_pair(0xC000008F, "EXCEPTION_FLT_INEXACT_RESULT")); + exceptionNames.insert(std::make_pair(0xC0000090, "EXCEPTION_FLT_INVALID_OPERATION")); + exceptionNames.insert(std::make_pair(0xC0000091, "EXCEPTION_FLT_OVERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000092, "EXCEPTION_FLT_STACK_CHECK")); + exceptionNames.insert(std::make_pair(0xC0000093, "EXCEPTION_FLT_UNDERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000094, "EXCEPTION_INT_DIVIDE_BY_ZERO")); + exceptionNames.insert(std::make_pair(0xC0000095, "EXCEPTION_INT_OVERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000096, "EXCEPTION_PRIV_INSTRUCTION")); + exceptionNames.insert(std::make_pair(0xC00000FD, "EXCEPTION_STACK_OVERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000135, "STATUS_DLL_NOT_FOUND")); + exceptionNames.insert(std::make_pair(0xC0000138, "STATUS_ORDINAL_NOT_FOUND")); + exceptionNames.insert(std::make_pair(0xC0000139, "STATUS_ENTRYPOINT_NOT_FOUND")); + exceptionNames.insert(std::make_pair(0xC000013A, "STATUS_CONTROL_C_EXIT")); + exceptionNames.insert(std::make_pair(0xC0000142, "STATUS_DLL_INIT_FAILED")); + exceptionNames.insert(std::make_pair(0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT")); + exceptionNames.insert(std::make_pair(0xC0000194, "EXCEPTION_POSSIBLE_DEADLOCK")); + exceptionNames.insert(std::make_pair(0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS")); + exceptionNames.insert(std::make_pair(0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS")); + exceptionNames.insert(std::make_pair(0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR")); + exceptionNames.insert(std::make_pair(0xC00002C9, "STATUS_REG_NAT_CONSUMPTION")); + exceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN")); + exceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER")); + exceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE")); + exceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); + exceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); + exceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); + exceptionNames.insert(std::make_pair(0x406D1388, "MS_VC_EXCEPTION")); + exceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); +} + +const char* exceptionnamefromcode(unsigned int ExceptionCode) +{ + if(!exceptionNames.count(ExceptionCode)) + return 0; + return exceptionNames[ExceptionCode]; +} \ No newline at end of file diff --git a/x64_dbg_dbg/exception.h b/x64_dbg_dbg/exception.h new file mode 100644 index 00000000..df0ea2a3 --- /dev/null +++ b/x64_dbg_dbg/exception.h @@ -0,0 +1,7 @@ +#ifndef _EXCEPTION_H +#define _EXCEPTION_H + +void exceptioninit(); +const char* exceptionnamefromcode(unsigned int ExceptionCode); + +#endif //_EXCEPTIONS_H \ No newline at end of file diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 6b11c7c9..0e2109ba 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -21,6 +21,8 @@ + + @@ -63,6 +65,8 @@ + + diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 5f0ef7ad..232a232f 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -168,6 +168,12 @@ Source Files\Utilities + + Source Files\Utilities + + + Source Files\Utilities + @@ -317,5 +323,11 @@ Header Files\Utilities + + Header Files\Utilities + + + Header Files\Utilities + \ No newline at end of file From b10e45dfae387a090b33b62c34a7c926ff5f7b6a Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 4 Jan 2015 22:18:20 +0100 Subject: [PATCH 017/106] GUI+DBG+BRIDGE: resolved issue #92 (context menu api for plugins) --- help/PLUG_SETUPSTRUCT.htm | 30 ++++++---- x64_dbg_bridge/bridgemain.h | 3 + x64_dbg_dbg/_plugins.h | 3 + x64_dbg_dbg/plugin_loader.cpp | 57 ++++++++++++++++++- x64_dbg_dbg/plugin_loader.h | 3 + .../Project/Src/Gui/CPUDisassembly.cpp | 8 ++- x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h | 1 + x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 7 +++ x64_dbg_gui/Project/Src/Gui/CPUDump.h | 1 + x64_dbg_gui/Project/Src/Gui/CPUStack.cpp | 6 ++ x64_dbg_gui/Project/Src/Gui/CPUStack.h | 1 + 11 files changed, 104 insertions(+), 16 deletions(-) diff --git a/help/PLUG_SETUPSTRUCT.htm b/help/PLUG_SETUPSTRUCT.htm index 1869c0f3..6192199f 100644 --- a/help/PLUG_SETUPSTRUCT.htm +++ b/help/PLUG_SETUPSTRUCT.htm @@ -12,18 +12,24 @@ html,body { } - + + - -

plugsetup
This structure is used by the function that allows the -creation of plugin menu entries:

-

- struct PLUG_SETUPSTRUCT -
{
    //data provided by the debugger to -the plugin. -
    [IN] HWND hwndDlg; //GUI window -handle
    [IN] -int hMenu; //plugin menu -handle
+ + +

plugsetup
This structure is used by the function that allows the +creation of plugin menu entries:

+

+ struct PLUG_SETUPSTRUCT +
{
    //data provided by the debugger to +the plugin. +
    [IN] HWND hwndDlg; //GUI window +handle
    [IN] +int hMenu; //plugin menu +handle
    [IN] int hMenuDisasm; +//plugin disasm menu handle
    [IN] int +hMenuDump; //plugin dump menu handle
    [IN] +int hMenuStack; //plugin stack menu +handle
};

diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index eaff79f3..aed57200 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -678,6 +678,9 @@ BRIDGE_IMPEXP bool DbgWinEventGlobal(MSG* message); //Gui defines #define GUI_PLUGIN_MENU 0 +#define GUI_DISASM_MENU 1 +#define GUI_DUMP_MENU 2 +#define GUI_STACK_MENU 3 #define GUI_DISASSEMBLY 0 #define GUI_DUMP 1 diff --git a/x64_dbg_dbg/_plugins.h b/x64_dbg_dbg/_plugins.h index a09d4637..969086e1 100644 --- a/x64_dbg_dbg/_plugins.h +++ b/x64_dbg_dbg/_plugins.h @@ -41,6 +41,9 @@ typedef struct //provided by the debugger HWND hwndDlg; //gui window handle int hMenu; //plugin menu handle + int hMenuDisasm; //plugin disasm menu handle + int hMenuDump; //plugin dump menu handle + int hMenuStack; //plugin stack menu handle } PLUG_SETUPSTRUCT; //callback structures diff --git a/x64_dbg_dbg/plugin_loader.cpp b/x64_dbg_dbg/plugin_loader.cpp index 3e3ad097..03ca8449 100644 --- a/x64_dbg_dbg/plugin_loader.cpp +++ b/x64_dbg_dbg/plugin_loader.cpp @@ -162,7 +162,7 @@ void pluginload(const char* pluginDir) int hNewMenu = GuiMenuAdd(GUI_PLUGIN_MENU, pluginData.initStruct.pluginName); if(hNewMenu == -1) { - dprintf("[PLUGIN] GuiMenuAdd failed for plugin: %s\n", pluginData.initStruct.pluginName); + dprintf("[PLUGIN] GuiMenuAdd(GUI_PLUGIN_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName); pluginData.hMenu = -1; } else @@ -172,7 +172,55 @@ void pluginload(const char* pluginDir) newMenu.hEntryPlugin = -1; newMenu.pluginHandle = pluginData.initStruct.pluginHandle; pluginMenuList.push_back(newMenu); - pluginData.hMenu = hNewMenu; + pluginData.hMenu = newMenu.hEntryMenu; + } + //add disasm plugin menu + hNewMenu = GuiMenuAdd(GUI_DISASM_MENU, pluginData.initStruct.pluginName); + if(hNewMenu == -1) + { + dprintf("[PLUGIN] GuiMenuAdd(GUI_DISASM_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName); + pluginData.hMenu = -1; + } + else + { + PLUG_MENU newMenu; + newMenu.hEntryMenu = hNewMenu; + newMenu.hEntryPlugin = -1; + newMenu.pluginHandle = pluginData.initStruct.pluginHandle; + pluginMenuList.push_back(newMenu); + pluginData.hMenuDisasm = newMenu.hEntryMenu; + } + //add dump plugin menu + hNewMenu = GuiMenuAdd(GUI_DUMP_MENU, pluginData.initStruct.pluginName); + if(hNewMenu == -1) + { + dprintf("[PLUGIN] GuiMenuAdd(GUI_DUMP_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName); + pluginData.hMenu = -1; + } + else + { + PLUG_MENU newMenu; + newMenu.hEntryMenu = hNewMenu; + newMenu.hEntryPlugin = -1; + newMenu.pluginHandle = pluginData.initStruct.pluginHandle; + pluginMenuList.push_back(newMenu); + pluginData.hMenuDump = newMenu.hEntryMenu; + } + //add stack plugin menu + hNewMenu = GuiMenuAdd(GUI_STACK_MENU, pluginData.initStruct.pluginName); + if(hNewMenu == -1) + { + dprintf("[PLUGIN] GuiMenuAdd(GUI_STACK_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName); + pluginData.hMenu = -1; + } + else + { + PLUG_MENU newMenu; + newMenu.hEntryMenu = hNewMenu; + newMenu.hEntryPlugin = -1; + newMenu.pluginHandle = pluginData.initStruct.pluginHandle; + pluginMenuList.push_back(newMenu); + pluginData.hMenuStack = newMenu.hEntryMenu; } pluginList.push_back(pluginData); //setup plugin @@ -180,7 +228,10 @@ void pluginload(const char* pluginDir) { PLUG_SETUPSTRUCT setupStruct; setupStruct.hwndDlg = GuiGetWindowHandle(); - setupStruct.hMenu = hNewMenu; + setupStruct.hMenu = pluginData.hMenu; + setupStruct.hMenuDisasm = pluginData.hMenuDisasm; + setupStruct.hMenuDump = pluginData.hMenuDump; + setupStruct.hMenuStack = pluginData.hMenuStack; pluginData.plugsetup(&setupStruct); } curPluginHandle++; diff --git a/x64_dbg_dbg/plugin_loader.h b/x64_dbg_dbg/plugin_loader.h index 22ca7cda..5f9421f4 100644 --- a/x64_dbg_dbg/plugin_loader.h +++ b/x64_dbg_dbg/plugin_loader.h @@ -24,6 +24,9 @@ struct PLUG_DATA PLUGSTOP plugstop; PLUGSETUP plugsetup; int hMenu; + int hMenuDisasm; + int hMenuDump; + int hMenuStack; PLUG_INITSTRUCT initStruct; }; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp index 01fca735..20fb9492 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp @@ -228,7 +228,6 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event) wMenu->addAction(mEnableHighlightingMode); wMenu->addSeparator(); - wMenu->addAction(mSetLabel); wMenu->addAction(mSetComment); wMenu->addAction(mSetBookmark); @@ -273,6 +272,9 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event) mReferencesMenu->addAction(mReferenceSelectedAddress); wMenu->addMenu(mReferencesMenu); + wMenu->addSeparator(); + wMenu->addActions(mPluginMenu->actions()); + wMenu->exec(event->globalPos()); } } @@ -519,6 +521,10 @@ void CPUDisassembly::setupRightClickContextMenu() this->addAction(mEnableHighlightingMode); connect(mEnableHighlightingMode, SIGNAL(triggered()), this, SLOT(enableHighlightingMode())); + // Plugins + mPluginMenu = new QMenu(this); + Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_DISASM_MENU); + refreshShortcutsSlot(); connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot())); } diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h index f29e486e..b9f8f475 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h @@ -80,6 +80,7 @@ private: QMenu* mReferencesMenu; QMenu* mSearchMenu; QMenu* mCopyMenu; + QMenu* mPluginMenu; QAction* mBinaryEditAction; QAction* mBinaryFillAction; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index ebb20b0d..ef78d205 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -341,6 +341,10 @@ void CPUDump::setupContextMenu() mDisassemblyAction = new QAction("&Disassembly", this); connect(mDisassemblyAction, SIGNAL(triggered()), this, SLOT(disassemblySlot())); + //Plugins + mPluginMenu = new QMenu(this); + Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_DUMP_MENU); + refreshShortcutsSlot(); connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot())); } @@ -498,6 +502,9 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event) mMemoryRemove->setVisible(false); } + wMenu->addSeparator(); + wMenu->addActions(mPluginMenu->actions()); + wMenu->exec(event->globalPos()); //execute context menu } diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.h b/x64_dbg_gui/Project/Src/Gui/CPUDump.h index 4c315d95..4ee2e1a9 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.h @@ -160,6 +160,7 @@ private: QMenu* mSpecialMenu; QMenu* mCustomMenu; + QMenu* mPluginMenu; GotoDialog* mGoto; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp index 2fa0795e..3041bd4d 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp @@ -150,6 +150,9 @@ void CPUStack::setupContextMenu() mFollowStack = new QAction("Follow in &Stack", this); connect(mFollowStack, SIGNAL(triggered()), this, SLOT(followStackSlot())); + mPluginMenu = new QMenu(this); + Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_STACK_MENU); + refreshShortcutsSlot(); connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot())); } @@ -333,6 +336,9 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event) wMenu->addAction(mFollowDump); } + wMenu->addSeparator(); + wMenu->addActions(mPluginMenu->actions()); + wMenu->exec(event->globalPos()); } diff --git a/x64_dbg_gui/Project/Src/Gui/CPUStack.h b/x64_dbg_gui/Project/Src/Gui/CPUStack.h index dd030d21..4170ecfe 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUStack.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUStack.h @@ -57,6 +57,7 @@ private: QAction* mFollowDisasm; QAction* mFollowDump; QAction* mFollowStack; + QMenu* mPluginMenu; GotoDialog* mGoto; }; From d67fcd1aefd12a4181c7ddc5d7f71f8a545657f7 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 4 Jan 2015 23:02:32 +0100 Subject: [PATCH 018/106] GUI: added display of the number of bytes selected in CPUDump --- x64_dbg_gui/Project/Src/BasicView/HexDump.cpp | 7 +++++++ x64_dbg_gui/Project/Src/BasicView/HexDump.h | 3 +++ x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 8 ++++++++ x64_dbg_gui/Project/Src/Gui/CPUDump.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp b/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp index f577ccea..ef3bba90 100644 --- a/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/HexDump.cpp @@ -128,6 +128,7 @@ void HexDump::mouseMoveEvent(QMouseEvent* event) { expandSelectionUpTo(wStartingAddress); mSelection.toIndex += dataSize; + emit selectionUpdated(); } else expandSelectionUpTo(wEndingAddress); @@ -197,7 +198,10 @@ void HexDump::mousePressEvent(QMouseEvent* event) } expandSelectionUpTo(wEndingAddress); if(bUpdateTo) + { mSelection.toIndex += dataSize; + emit selectionUpdated(); + } mGuiState = HexDump::MultiRowsSelectionState; @@ -304,11 +308,13 @@ void HexDump::expandSelectionUpTo(int_t rva) { mSelection.fromIndex = rva; mSelection.toIndex = mSelection.firstSelectedIndex; + emit selectionUpdated(); } else if(rva > mSelection.firstSelectedIndex) { mSelection.fromIndex = mSelection.firstSelectedIndex; mSelection.toIndex = rva; + emit selectionUpdated(); } else if(rva == mSelection.firstSelectedIndex) { @@ -321,6 +327,7 @@ void HexDump::setSingleSelection(int_t rva) mSelection.firstSelectedIndex = rva; mSelection.fromIndex = rva; mSelection.toIndex = rva; + emit selectionUpdated(); } int_t HexDump::getInitialSelection() diff --git a/x64_dbg_gui/Project/Src/BasicView/HexDump.h b/x64_dbg_gui/Project/Src/BasicView/HexDump.h index 9a1e28bf..5822a212 100644 --- a/x64_dbg_gui/Project/Src/BasicView/HexDump.h +++ b/x64_dbg_gui/Project/Src/BasicView/HexDump.h @@ -131,6 +131,9 @@ public: void printDumpAt(int_t parVA, bool select, bool repaint = true); uint_t rvaToVa(int_t rva); +signals: + void selectionUpdated(); + public slots: void printDumpAt(int_t parVA); void debugStateChanged(DBGSTATE state); diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index ef78d205..7f05567f 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -75,6 +75,7 @@ CPUDump::CPUDump(QWidget* parent) : HexDump(parent) connect(Bridge::getBridge(), SIGNAL(dumpAt(int_t)), this, SLOT(printDumpAt(int_t))); connect(Bridge::getBridge(), SIGNAL(selectionDumpGet(SELECTIONDATA*)), this, SLOT(selectionGet(SELECTIONDATA*))); connect(Bridge::getBridge(), SIGNAL(selectionDumpSet(const SELECTIONDATA*)), this, SLOT(selectionSet(const SELECTIONDATA*))); + connect(this, SIGNAL(selectionUpdated()), this, SLOT(selectionUpdatedSlot())); setupContextMenu(); @@ -1314,3 +1315,10 @@ void CPUDump::followStackSlot() QString addrText = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); DbgCmdExec(QString("sdump " + addrText).toUtf8().constData()); } + +void CPUDump::selectionUpdatedSlot() +{ + QString selStart = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + QString selEnd = QString("%1").arg(rvaToVa(getSelectionEnd()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + GuiAddStatusBarMessage(QString("Dump: " + selStart + " -> " + selEnd + QString().sprintf(" (0x%.8X bytes)\n", getSelectionEnd() - getSelectionStart() + 1)).toUtf8().constData()); +} diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.h b/x64_dbg_gui/Project/Src/Gui/CPUDump.h index 4ee2e1a9..99d58c0d 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.h @@ -77,6 +77,8 @@ public slots: void followStackSlot(); void findReferencesSlot(); + void selectionUpdatedSlot(); + private: QMenu* mBreakpointMenu; From 524430794f11a982ab198eb8c69b12639ff17581 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 4 Jan 2015 23:55:07 +0100 Subject: [PATCH 019/106] GUI: added topmost option --- x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 10 ++++++++++ x64_dbg_gui/Project/Src/Gui/MainWindow.h | 1 + x64_dbg_gui/Project/Src/Gui/MainWindow.ui | 16 ++++++++++++++++ x64_dbg_gui/Project/Src/Utils/Configuration.cpp | 1 + x64_dbg_gui/Project/images/topmost.png | Bin 0 -> 628 bytes x64_dbg_gui/Project/resource.qrc | 1 + 6 files changed, 29 insertions(+) create mode 100644 x64_dbg_gui/Project/images/topmost.png diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 382a2e4d..57b9069c 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -176,6 +176,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi connect(ui->actionCalls, SIGNAL(triggered()), this, SLOT(findModularCalls())); connect(ui->actionAppearance, SIGNAL(triggered()), this, SLOT(openAppearance())); connect(ui->actionShortcuts, SIGNAL(triggered()), this, SLOT(openShortcuts())); + connect(ui->actionTopmost, SIGNAL(toggled(bool)), this, SLOT(changeTopmost(bool))); connect(ui->actionCalculator, SIGNAL(triggered()), this, SLOT(openCalculator())); connect(ui->actionPatches, SIGNAL(triggered()), this, SLOT(patchWindow())); connect(ui->actionComments, SIGNAL(triggered()), this, SLOT(displayComments())); @@ -294,6 +295,7 @@ void MainWindow::refreshShortcuts() ui->actionSettings->setShortcut(ConfigShortcut("OptionsPreferences")); ui->actionAppearance->setShortcut(ConfigShortcut("OptionsAppearance")); ui->actionShortcuts->setShortcut(ConfigShortcut("OptionsShortcuts")); + ui->actionTopmost->setShortcut(ConfigShortcut("OptionsTopmost")); ui->actionAbout->setShortcut(ConfigShortcut("HelpAbout")); ui->actionDonate->setShortcut(ConfigShortcut("HelpDonate")); @@ -687,6 +689,14 @@ void MainWindow::openShortcuts() shortcuts.exec(); } +void MainWindow::changeTopmost(bool checked) +{ + if(checked) + SetWindowPos(this->winId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + else + SetWindowPos(this->winId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); +} + void MainWindow::addRecentFile(QString file) { addMRUEntry(file); diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.h b/x64_dbg_gui/Project/Src/Gui/MainWindow.h index a73b5059..00707c8c 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.h +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.h @@ -89,6 +89,7 @@ public slots: void displayCallstack(); void refreshShortcuts(); void openShortcuts(); + void changeTopmost(bool checked); void donate(); void displayAttach(); void detach(); diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.ui b/x64_dbg_gui/Project/Src/Gui/MainWindow.ui index df4201a7..fb4e5146 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.ui +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.ui @@ -107,6 +107,7 @@ + @@ -617,6 +618,21 @@ Skip next instruction + + + true + + + + :/icons/images/topmost.png:/icons/images/topmost.png + + + Topmost + + + Topmost Window + + diff --git a/x64_dbg_gui/Project/Src/Utils/Configuration.cpp b/x64_dbg_gui/Project/Src/Utils/Configuration.cpp index 0bcca800..492a2062 100644 --- a/x64_dbg_gui/Project/Src/Utils/Configuration.cpp +++ b/x64_dbg_gui/Project/Src/Utils/Configuration.cpp @@ -215,6 +215,7 @@ Configuration::Configuration() : QObject() defaultShortcuts.insert("OptionsPreferences", Shortcut(tr("Options -> Preferences"), "", true)); defaultShortcuts.insert("OptionsAppearance", Shortcut(tr("Options -> Appearance"), "", true)); defaultShortcuts.insert("OptionsShortcuts", Shortcut(tr("Options -> Shortcuts"), "", true)); + defaultShortcuts.insert("OptionsTopmost", Shortcut(tr("Options -> Topmost"), "Ctrl+F5", true)); defaultShortcuts.insert("HelpAbout", Shortcut(tr("Help -> About"), "", true)); defaultShortcuts.insert("HelpDonate", Shortcut(tr("Help -> Donate"), "", true)); diff --git a/x64_dbg_gui/Project/images/topmost.png b/x64_dbg_gui/Project/images/topmost.png new file mode 100644 index 0000000000000000000000000000000000000000..cf936261b42eeda36b39f95568d454f53b942965 GIT binary patch literal 628 zcmV-)0*n2LP)6+0$z`;?_L2(g`i+_Mqq1HtdGuWje!O4U`LLPZZ zW0U*7Jm>k+yk|P}z`f_*^YJ^MS{R17@vij-fW**>vm#`wJmRoj7{y9;q57XwVAV^LNa!Fv(ORP87JY(B%W zE8K#c34m|Ke{l63WUoJkHh&3@k;PtyvZa93eT1zthM%8fZ2x{@6B%rdj86IF!1Yd> z8Z@DS|12l{NjjN{5@O=w=IG4$&E1Oq^7U9_S1WWca20g+Vjj_70R{l(Y$ib5sU0=| O0000images/trace.png images/changeargs.png images/arrow-skip.png + images/topmost.png From c6caf21e26a4d777945dbc74e1f78f54d13974f7 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Mon, 5 Jan 2015 14:12:20 +0100 Subject: [PATCH 020/106] DBG: fixed hardware breakpoints on execute --- x64_dbg_dbg/debugger_commands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index a9f7a6e0..4cbec208 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -606,7 +606,7 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]) } } char arg3[deflen] = ""; //size - DWORD titsize; + DWORD titsize = UE_HARDWARE_SIZE_1; if(argget(*argv, arg3, 2, true)) { uint size; From 58347090ed1bddc20ebf71e7f8c7e5cd7ce1cc65 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Mon, 5 Jan 2015 14:34:48 +0100 Subject: [PATCH 021/106] DBG: fixed TLS callbacks + added TLS callback support for DLLs --- x64_dbg_dbg/debugger.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index a43d0b50..e435e1fb 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -653,9 +653,10 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) dputs("Failed to get TLS callback addresses!"); else { + uint ImageBase = GetPE32DataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), 0, UE_IMAGEBASE); for(unsigned int i = 0; i < NumberOfCallBacks; i++) { - sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i], i + 1); + sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + pDebuggedBase, i + 1); cmddirectexec(dbggetcommandlist(), command); } } @@ -816,10 +817,13 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) bpenumall(cbSetModuleBreakpoints, modname); GuiUpdateBreakpointsView(); bool bAlreadySetEntry = false; + + char command[256] = ""; + bool bIsDebuggingThis = false; if(bFileIsDll and !_stricmp(DLLDebugFileName, szFileName) and !bIsAttached) //Set entry breakpoint { + bIsDebuggingThis = true; pDebuggedBase = (uint)base; - char command[256] = ""; if(settingboolget("Events", "EntryBreakpoint")) { bAlreadySetEntry = true; @@ -829,6 +833,31 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) } GuiUpdateBreakpointsView(); + if(settingboolget("Events", "TlsCallbacks")) + { + DWORD NumberOfCallBacks = 0; + TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), 0, &NumberOfCallBacks); + if(NumberOfCallBacks) + { + dprintf("TLS Callbacks: %d\n", NumberOfCallBacks); + Memory TLSCallBacks(NumberOfCallBacks * sizeof(uint), "cbLoadDll:TLSCallBacks"); + if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), TLSCallBacks, &NumberOfCallBacks)) + dputs("Failed to get TLS callback addresses!"); + else + { + uint ImageBase = GetPE32DataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), 0, UE_IMAGEBASE); + for(unsigned int i = 0; i < NumberOfCallBacks; i++) + { + if(bIsDebuggingThis) + sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + (uint)base, i + 1); + else + sprintf(command, "bp "fhex",\"TLS Callback %d (%s)\",ss", TLSCallBacks[i] - ImageBase + (uint)base, i + 1, modname); + cmddirectexec(dbggetcommandlist(), command); + } + } + } + } + if((bBreakOnNextDll || settingboolget("Events", "DllEntry")) && !bAlreadySetEntry) { uint oep = GetPE32Data(DLLDebugFileName, 0, UE_OEP); From 3753a1d340de4ac959b34955c0d1cbd42d07f95e Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Mon, 5 Jan 2015 14:59:06 +0100 Subject: [PATCH 022/106] GUI: show reference count in each reference view --- .../Project/Src/BasicView/ReferenceView.cpp | 17 +++++++++++++++-- .../Project/Src/BasicView/ReferenceView.h | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp index a0d546ec..14906172 100644 --- a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp @@ -2,6 +2,7 @@ #include #include "Configuration.h" #include "Bridge.h" +#include ReferenceView::ReferenceView() { @@ -9,14 +10,25 @@ ReferenceView::ReferenceView() mSearchStartCol = 1; mFollowDumpDefault = false; + QHBoxLayout* layout = new QHBoxLayout(); + // Create search progress bar mSearchProgress = new QProgressBar(); mSearchProgress->setRange(0, 100); mSearchProgress->setTextVisible(false); mSearchProgress->setMaximumHeight(15); + layout->addWidget(mSearchProgress); - // Add the progress bar to the main layout - mMainLayout->addWidget(mSearchProgress); + // Label for the number of references + mCountLabel = new QLabel("tst"); + mCountLabel->setAlignment(Qt::AlignCenter); + mCountLabel->setMaximumHeight(16); + mCountLabel->setMinimumWidth(40); + mCountLabel->setContentsMargins(2, 0, 5, 0); + layout->addWidget(mCountLabel); + + // Add the progress bar and label to the main layout + mMainLayout->addLayout(layout); // Setup signals connect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int, QString)), this, SLOT(addColumnAt(int, QString))); @@ -94,6 +106,7 @@ void ReferenceView::addColumnAt(int width, QString title) void ReferenceView::setRowCount(int_t count) { + emit mCountLabel->setText(QString("%1").arg(count)); mSearchBox->setText(""); mList->setRowCount(count); } diff --git a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.h b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.h index d94b0d4e..e7a25ec5 100644 --- a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.h +++ b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.h @@ -2,6 +2,7 @@ #define REFERENCEVIEW_H #include +#include #include "SearchListView.h" class ReferenceView : public SearchListView @@ -38,6 +39,7 @@ private: QAction* mToggleBreakpoint; QAction* mToggleBookmark; bool mFollowDumpDefault; + QLabel* mCountLabel; }; #endif // REFERENCEVIEW_H From 947cba39d1ba950a0581e0018de2c1c4b5be8f38 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Mon, 5 Jan 2015 14:59:30 +0100 Subject: [PATCH 023/106] GUI: Qt5 fixes --- x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 4 ++-- x64_dbg_gui/Project/Src/main.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 57b9069c..816336ec 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -692,9 +692,9 @@ void MainWindow::openShortcuts() void MainWindow::changeTopmost(bool checked) { if(checked) - SetWindowPos(this->winId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + SetWindowPos((HWND)this->winId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); else - SetWindowPos(this->winId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + SetWindowPos((HWND)this->winId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } void MainWindow::addRecentFile(QString file) diff --git a/x64_dbg_gui/Project/Src/main.cpp b/x64_dbg_gui/Project/Src/main.cpp index bfda6ced..a6eb4122 100644 --- a/x64_dbg_gui/Project/Src/main.cpp +++ b/x64_dbg_gui/Project/Src/main.cpp @@ -66,8 +66,10 @@ int main(int argc, char* argv[]) // Set QString codec to UTF-8 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); +#endif // Init communication with debugger Bridge::initBridge(); From d73f926918948eb5d0976aab88d91cdda4e28f18 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 23 Jan 2015 17:41:01 +0100 Subject: [PATCH 024/106] DBG: split up addrinfo to multiple files --- x64_dbg_dbg/_dbgfunctions.cpp | 1 + x64_dbg_dbg/_exports.cpp | 6 + x64_dbg_dbg/_global.h | 2 +- x64_dbg_dbg/addrinfo.cpp | 1098 +---------------------- x64_dbg_dbg/addrinfo.h | 122 --- x64_dbg_dbg/bookmark.cpp | 162 ++++ x64_dbg_dbg/bookmark.h | 22 + x64_dbg_dbg/breakpoint.cpp | 4 + x64_dbg_dbg/breakpoint.h | 2 - x64_dbg_dbg/comment.cpp | 182 ++++ x64_dbg_dbg/comment.h | 23 + x64_dbg_dbg/debugger.cpp | 1 + x64_dbg_dbg/debugger_commands.cpp | 5 + x64_dbg_dbg/function.cpp | 192 ++++ x64_dbg_dbg/function.h | 24 + x64_dbg_dbg/instruction.cpp | 5 + x64_dbg_dbg/label.cpp | 204 +++++ x64_dbg_dbg/label.h | 24 + x64_dbg_dbg/loop.cpp | 203 +++++ x64_dbg_dbg/loop.h | 25 + x64_dbg_dbg/memory.cpp | 1 + x64_dbg_dbg/module.cpp | 199 ++++ x64_dbg_dbg/module.h | 40 + x64_dbg_dbg/patches.cpp | 3 +- x64_dbg_dbg/reference.cpp | 1 + x64_dbg_dbg/stackinfo.cpp | 1 + x64_dbg_dbg/symbolinfo.cpp | 2 + x64_dbg_dbg/value.cpp | 3 +- x64_dbg_dbg/x64_dbg_dbg.vcxproj | 12 + x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters | 84 +- 30 files changed, 1415 insertions(+), 1238 deletions(-) create mode 100644 x64_dbg_dbg/bookmark.cpp create mode 100644 x64_dbg_dbg/bookmark.h create mode 100644 x64_dbg_dbg/comment.cpp create mode 100644 x64_dbg_dbg/comment.h create mode 100644 x64_dbg_dbg/function.cpp create mode 100644 x64_dbg_dbg/function.h create mode 100644 x64_dbg_dbg/label.cpp create mode 100644 x64_dbg_dbg/label.h create mode 100644 x64_dbg_dbg/loop.cpp create mode 100644 x64_dbg_dbg/loop.h create mode 100644 x64_dbg_dbg/module.cpp create mode 100644 x64_dbg_dbg/module.h diff --git a/x64_dbg_dbg/_dbgfunctions.cpp b/x64_dbg_dbg/_dbgfunctions.cpp index 0ba1b342..fac654e7 100644 --- a/x64_dbg_dbg/_dbgfunctions.cpp +++ b/x64_dbg_dbg/_dbgfunctions.cpp @@ -8,6 +8,7 @@ #include "disasm_fast.h" #include "stackinfo.h" #include "symbolinfo.h" +#include "module.h" static DBGFUNCTIONS _dbgfunctions; diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index 4ae7baff..ce0d01ae 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -15,6 +15,12 @@ #include "disasm_fast.h" #include "plugin_loader.h" #include "_dbgfunctions.h" +#include "module.h" +#include "comment.h" +#include "label.h" +#include "bookmark.h" +#include "function.h" +#include "loop.h" static bool bOnlyCipAutoComments = false; diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index 92f7feed..c3f6fcfd 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -11,9 +11,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index a6bd913d..b49f2d87 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -8,13 +8,12 @@ #include "murmurhash.h" #include "lz4\lz4file.h" #include "patches.h" - -static ModulesInfo modinfo; -static CommentsInfo comments; -static LabelsInfo labels; -static BookmarksInfo bookmarks; -static FunctionsInfo functions; -static LoopsInfo loops; +#include "module.h" +#include "comment.h" +#include "label.h" +#include "bookmark.h" +#include "function.h" +#include "loop.h" //database functions void dbsave() @@ -96,217 +95,15 @@ void dbload() void dbclose() { dbsave(); - CriticalSectionLocker commentLocker(LockComments); - CommentsInfo().swap(comments); - - CriticalSectionLocker labelLocker(LockLabels); - LabelsInfo().swap(labels); - - CriticalSectionLocker bookmarkLocker(LockBookmarks); - BookmarksInfo().swap(bookmarks); - - CriticalSectionLocker functionLocker(LockFunctions); - FunctionsInfo().swap(functions); - - CriticalSectionLocker loopLocker(LockLoops); - LoopsInfo().swap(loops); - + commentclear(); + labelclear(); + bookmarkclear(); + functionclear(); + loopclear(); bpclear(); patchclear(); } -///module functions -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--; - if(len) - len++; - strcpy(name, fullpath + len); - _strlwr(name); - len = (int)strlen(name); - name[MAX_MODULE_SIZE - 1] = 0; //ignore later characters - while(name[len] != '.' and len) - len--; - MODINFO info; - memset(&info, 0, sizeof(MODINFO)); - info.sections.clear(); - info.hash = modhashfromname(name); - if(len) - { - strcpy(info.extension, name + len); - name[len] = 0; //remove extension - } - info.base = base; - info.size = size; - strcpy(info.name, name); - - //process module sections - HANDLE FileHandle; - DWORD LoadedSize; - HANDLE FileMap; - ULONG_PTR FileMapVA; - WString wszFullPath = StringUtils::Utf8ToUtf16(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); - if(SectionCount > 0) - { - for(int i = 0; i < SectionCount; i++) - { - MODSECTIONINFO curSection; - curSection.addr = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALOFFSET) + base; - curSection.size = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALSIZE); - const char* SectionName = (const char*)GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONNAME); - //escape section name when needed - int len = (int)strlen(SectionName); - int escape_count = 0; - for(int k = 0; k < len; k++) - if(SectionName[k] == '\\' or SectionName[k] == '\"' or !isprint(SectionName[k])) - escape_count++; - strcpy_s(curSection.name, StringUtils::Escape(SectionName).c_str()); - info.sections.push_back(curSection); - } - } - StaticFileUnloadW(wszFullPath.c_str(), false, FileHandle, LoadedSize, FileMap, FileMapVA); - } - - //add module to list - CriticalSectionLocker locker(LockModules); - modinfo.insert(std::make_pair(Range(base, base + size - 1), info)); - symupdatemodulelist(); - return true; -} - -bool modunload(uint base) -{ - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(base, base)); - if(found == modinfo.end()) //not found - return false; - modinfo.erase(found); - symupdatemodulelist(); - return true; -} - -void modclear() -{ - CriticalSectionLocker locker(LockModules); - ModulesInfo().swap(modinfo); - symupdatemodulelist(); -} - -bool modnamefromaddr(uint addr, char* modname, bool extension) -{ - if(!modname) - return false; - *modname = '\0'; - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found - return false; - String mod = found->second.name; - if(extension) - mod += found->second.extension; - strcpy_s(modname, MAX_MODULE_SIZE, mod.c_str()); - return true; -} - -uint modbasefromaddr(uint addr) -{ - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found - return 0; - return found->second.base; -} - -uint modhashfromva(uint va) //return a unique hash from a VA -{ - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(va, va)); - if(found == modinfo.end()) //not found - return va; - return found->second.hash + (va - found->second.base); -} - -uint modhashfromname(const char* mod) //return MODINFO.hash -{ - if(!mod or !*mod) - return 0; - int len = (int)strlen(mod); - return murmurhash(mod, len); -} - -uint modbasefromname(const char* modname) -{ - if(!modname or strlen(modname) >= MAX_MODULE_SIZE) - return 0; - CriticalSectionLocker locker(LockModules); - for(ModulesInfo::iterator i = modinfo.begin(); i != modinfo.end(); ++i) - { - MODINFO* curMod = &i->second; - char curmodname[MAX_MODULE_SIZE] = ""; - sprintf(curmodname, "%s%s", curMod->name, curMod->extension); - if(!_stricmp(curmodname, modname)) //with extension - return curMod->base; - if(!_stricmp(curMod->name, modname)) //without extension - return curMod->base; - } - return 0; -} - -uint modsizefromaddr(uint addr) -{ - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found - return 0; - return found->second.size; -} - -bool modsectionsfromaddr(uint addr, std::vector* sections) -{ - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found - return false; - *sections = found->second.sections; - return true; -} - -uint modentryfromaddr(uint addr) -{ - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found - return 0; - return found->second.entry; -} - -int modpathfromaddr(duint addr, char* path, int size) -{ - Memory wszModPath(size * sizeof(wchar_t), "modpathfromaddr:wszModPath"); - if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), wszModPath, size)) - { - *path = '\0'; - return 0; - } - strcpy_s(path, size, StringUtils::Utf16ToUtf8(wszModPath()).c_str()); - return (int)strlen(path); -} - -int modpathfromname(const char* modname, char* path, int size) -{ - return modpathfromaddr(modbasefromname(modname), path, size); -} - ///api functions bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum) { @@ -377,877 +174,4 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum) } } return true; -} - -///comment functions -bool commentset(uint addr, const char* text, bool manual) -{ - if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or text[0] == '\1' or strlen(text) >= MAX_COMMENT_SIZE - 1) - return false; - if(!*text) //NOTE: delete when there is no text - { - commentdel(addr); - return true; - } - COMMENTSINFO comment; - comment.manual = manual; - strcpy(comment.text, text); - modnamefromaddr(addr, comment.mod, true); - comment.addr = addr - modbasefromaddr(addr); - const uint key = modhashfromva(addr); - CriticalSectionLocker locker(LockComments); - if(!comments.insert(std::make_pair(key, comment)).second) //key already present - comments[key] = comment; - return true; -} - -bool commentget(uint addr, char* text) -{ - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockComments); - const CommentsInfo::iterator found = comments.find(modhashfromva(addr)); - if(found == comments.end()) //not found - return false; - strcpy(text, found->second.text); - return true; -} - -bool commentdel(uint addr) -{ - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockComments); - return (comments.erase(modhashfromva(addr)) == 1); -} - -void commentdelrange(uint start, uint end) -{ - if(!DbgIsDebugging()) - return; - bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) - return; - start -= modbase; - end -= modbase; - CriticalSectionLocker locker(LockComments); - CommentsInfo::iterator i = comments.begin(); - while(i != comments.end()) - { - if(i->second.manual) //ignore manual - { - i++; - continue; - } - if(bDelAll || (i->second.addr >= start && i->second.addr < end)) - comments.erase(i++); - else - i++; - } -} - -void commentcachesave(JSON root) -{ - CriticalSectionLocker locker(LockComments); - const JSON jsoncomments = json_array(); - const JSON jsonautocomments = json_array(); - for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i) - { - const COMMENTSINFO curComment = i->second; - JSON curjsoncomment = json_object(); - json_object_set_new(curjsoncomment, "module", json_string(curComment.mod)); - json_object_set_new(curjsoncomment, "address", json_hex(curComment.addr)); - json_object_set_new(curjsoncomment, "text", json_string(curComment.text)); - if(curComment.manual) - json_array_append_new(jsoncomments, curjsoncomment); - else - json_array_append_new(jsonautocomments, curjsoncomment); - } - if(json_array_size(jsoncomments)) - json_object_set(root, "comments", jsoncomments); - json_decref(jsoncomments); - if(json_array_size(jsonautocomments)) - json_object_set(root, "autocomments", jsonautocomments); - json_decref(jsonautocomments); -} - -void commentcacheload(JSON root) -{ - CriticalSectionLocker locker(LockComments); - comments.clear(); - const JSON jsoncomments = json_object_get(root, "comments"); - if(jsoncomments) - { - size_t i; - JSON value; - json_array_foreach(jsoncomments, i, value) - { - COMMENTSINFO curComment; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curComment.mod, mod); - else - *curComment.mod = '\0'; - curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); - curComment.manual = true; - const char* text = json_string_value(json_object_get(value, "text")); - if(text) - strcpy(curComment.text, text); - else - continue; //skip - const uint key = modhashfromname(curComment.mod) + curComment.addr; - comments.insert(std::make_pair(key, curComment)); - } - } - JSON jsonautocomments = json_object_get(root, "autocomments"); - if(jsonautocomments) - { - size_t i; - JSON value; - json_array_foreach(jsonautocomments, i, value) - { - COMMENTSINFO curComment; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curComment.mod, mod); - else - *curComment.mod = '\0'; - curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); - curComment.manual = false; - const char* text = json_string_value(json_object_get(value, "text")); - if(text) - strcpy_s(curComment.text, text); - else - continue; //skip - const uint key = modhashfromname(curComment.mod) + curComment.addr; - comments.insert(std::make_pair(key, curComment)); - } - } -} - -bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize) -{ - if(!DbgIsDebugging()) - return false; - if(!commentlist && !cbsize) - return false; - CriticalSectionLocker locker(LockComments); - if(!commentlist && cbsize) - { - *cbsize = comments.size() * sizeof(COMMENTSINFO); - return true; - } - int j = 0; - for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i, j++) - { - commentlist[j] = i->second; - commentlist[j].addr += modbasefromname(commentlist[j].mod); - } - return true; -} - -///label functions -bool labelset(uint addr, const char* text, bool manual) -{ - if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text) >= MAX_LABEL_SIZE - 1 or strstr(text, "&")) - return false; - if(!*text) //NOTE: delete when there is no text - { - labeldel(addr); - return true; - } - LABELSINFO label; - label.manual = manual; - strcpy(label.text, text); - modnamefromaddr(addr, label.mod, true); - label.addr = addr - modbasefromaddr(addr); - uint key = modhashfromva(addr); - CriticalSectionLocker locker(LockLabels); - if(!labels.insert(std::make_pair(modhashfromva(key), label)).second) //already present - labels[key] = label; - return true; -} - -bool labelfromstring(const char* text, uint* addr) -{ - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockLabels); - for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i) - { - if(!strcmp(i->second.text, text)) - { - if(addr) - *addr = i->second.addr + modbasefromname(i->second.mod); - return true; - } - } - return false; -} - -bool labelget(uint addr, char* text) -{ - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockLabels); - const LabelsInfo::iterator found = labels.find(modhashfromva(addr)); - if(found == labels.end()) //not found - return false; - if(text) - strcpy(text, found->second.text); - return true; -} - -bool labeldel(uint addr) -{ - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockLabels); - return (labels.erase(modhashfromva(addr)) > 0); -} - -void labeldelrange(uint start, uint end) -{ - if(!DbgIsDebugging()) - return; - bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) - return; - start -= modbase; - end -= modbase; - CriticalSectionLocker locker(LockLabels); - LabelsInfo::iterator i = labels.begin(); - while(i != labels.end()) - { - if(i->second.manual) //ignore manual - { - i++; - continue; - } - if(bDelAll || (i->second.addr >= start && i->second.addr < end)) - labels.erase(i++); - else - i++; - } -} - -void labelcachesave(JSON root) -{ - CriticalSectionLocker locker(LockLabels); - const JSON jsonlabels = json_array(); - const JSON jsonautolabels = json_array(); - for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i) - { - const LABELSINFO curLabel = i->second; - JSON curjsonlabel = json_object(); - json_object_set_new(curjsonlabel, "module", json_string(curLabel.mod)); - json_object_set_new(curjsonlabel, "address", json_hex(curLabel.addr)); - json_object_set_new(curjsonlabel, "text", json_string(curLabel.text)); - if(curLabel.manual) - json_array_append_new(jsonlabels, curjsonlabel); - else - json_array_append_new(jsonautolabels, curjsonlabel); - } - if(json_array_size(jsonlabels)) - json_object_set(root, "labels", jsonlabels); - json_decref(jsonlabels); - if(json_array_size(jsonautolabels)) - json_object_set(root, "autolabels", jsonautolabels); - json_decref(jsonautolabels); -} - -void labelcacheload(JSON root) -{ - CriticalSectionLocker locker(LockLabels); - labels.clear(); - const JSON jsonlabels = json_object_get(root, "labels"); - if(jsonlabels) - { - size_t i; - JSON value; - json_array_foreach(jsonlabels, i, value) - { - LABELSINFO curLabel; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLabel.mod, mod); - else - *curLabel.mod = '\0'; - curLabel.addr = (uint)json_hex_value(json_object_get(value, "address")); - curLabel.manual = true; - const char* text = json_string_value(json_object_get(value, "text")); - if(text) - strcpy(curLabel.text, text); - else - continue; //skip - int len = (int)strlen(curLabel.text); - for(int i = 0; i < len; i++) - if(curLabel.text[i] == '&') - curLabel.text[i] = ' '; - const uint key = modhashfromname(curLabel.mod) + curLabel.addr; - labels.insert(std::make_pair(key, curLabel)); - } - } - JSON jsonautolabels = json_object_get(root, "autolabels"); - if(jsonautolabels) - { - size_t i; - JSON value; - json_array_foreach(jsonautolabels, i, value) - { - LABELSINFO curLabel; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLabel.mod, mod); - else - *curLabel.mod = '\0'; - curLabel.addr = (uint)json_hex_value(json_object_get(value, "address")); - curLabel.manual = false; - const char* text = json_string_value(json_object_get(value, "text")); - if(text) - strcpy_s(curLabel.text, text); - else - continue; //skip - const uint key = modhashfromname(curLabel.mod) + curLabel.addr; - labels.insert(std::make_pair(key, curLabel)); - } - } -} - -bool labelenum(LABELSINFO* labellist, size_t* cbsize) -{ - if(!DbgIsDebugging()) - return false; - if(!labellist && !cbsize) - return false; - CriticalSectionLocker locker(LockLabels); - if(!labellist && cbsize) - { - *cbsize = labels.size() * sizeof(LABELSINFO); - return true; - } - int j = 0; - for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i, j++) - { - labellist[j] = i->second; - labellist[j].addr += modbasefromname(labellist[j].mod); - } - return true; -} - -///bookmark functions -bool bookmarkset(uint addr, bool manual) -{ - if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr)) - return false; - BOOKMARKSINFO bookmark; - modnamefromaddr(addr, bookmark.mod, true); - bookmark.addr = addr - modbasefromaddr(addr); - bookmark.manual = manual; - CriticalSectionLocker locker(LockBookmarks); - if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second) - return bookmarkdel(addr); - return true; -} - -bool bookmarkget(uint addr) -{ - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockBookmarks); - if(bookmarks.count(modhashfromva(addr))) - return true; - return false; -} - -bool bookmarkdel(uint addr) -{ - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockBookmarks); - return (bookmarks.erase(modhashfromva(addr)) > 0); -} - -void bookmarkdelrange(uint start, uint end) -{ - if(!DbgIsDebugging()) - return; - bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) - return; - start -= modbase; - end -= modbase; - CriticalSectionLocker locker(LockBookmarks); - BookmarksInfo::iterator i = bookmarks.begin(); - while(i != bookmarks.end()) - { - if(i->second.manual) //ignore manual - { - i++; - continue; - } - if(bDelAll || (i->second.addr >= start && i->second.addr < end)) - bookmarks.erase(i++); - else - i++; - } -} - -void bookmarkcachesave(JSON root) -{ - CriticalSectionLocker locker(LockBookmarks); - const JSON jsonbookmarks = json_array(); - const JSON jsonautobookmarks = json_array(); - for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i) - { - const BOOKMARKSINFO curBookmark = i->second; - JSON curjsonbookmark = json_object(); - json_object_set_new(curjsonbookmark, "module", json_string(curBookmark.mod)); - json_object_set_new(curjsonbookmark, "address", json_hex(curBookmark.addr)); - if(curBookmark.manual) - json_array_append_new(jsonbookmarks, curjsonbookmark); - else - json_array_append_new(jsonautobookmarks, curjsonbookmark); - } - if(json_array_size(jsonbookmarks)) - json_object_set(root, "bookmarks", jsonbookmarks); - json_decref(jsonbookmarks); - if(json_array_size(jsonautobookmarks)) - json_object_set(root, "autobookmarks", jsonautobookmarks); - json_decref(jsonautobookmarks); -} - -void bookmarkcacheload(JSON root) -{ - CriticalSectionLocker locker(LockBookmarks); - bookmarks.clear(); - const JSON jsonbookmarks = json_object_get(root, "bookmarks"); - if(jsonbookmarks) - { - size_t i; - JSON value; - json_array_foreach(jsonbookmarks, i, value) - { - BOOKMARKSINFO curBookmark; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curBookmark.mod, mod); - else - *curBookmark.mod = '\0'; - curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); - curBookmark.manual = true; - const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; - bookmarks.insert(std::make_pair(key, curBookmark)); - } - } - JSON jsonautobookmarks = json_object_get(root, "autobookmarks"); - if(jsonautobookmarks) - { - size_t i; - JSON value; - json_array_foreach(jsonautobookmarks, i, value) - { - BOOKMARKSINFO curBookmark; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curBookmark.mod, mod); - else - *curBookmark.mod = '\0'; - curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); - curBookmark.manual = false; - const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; - bookmarks.insert(std::make_pair(key, curBookmark)); - } - } -} - -bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) -{ - if(!DbgIsDebugging()) - return false; - if(!bookmarklist && !cbsize) - return false; - CriticalSectionLocker locker(LockBookmarks); - if(!bookmarklist && cbsize) - { - *cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO); - return true; - } - int j = 0; - for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i, j++) - { - bookmarklist[j] = i->second; - bookmarklist[j].addr += modbasefromname(bookmarklist[j].mod); - } - return true; -} - -///function database -bool functionadd(uint start, uint end, bool manual) -{ - if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) - return false; - const uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same module - return false; - if(functionoverlaps(start, end)) - return false; - FUNCTIONSINFO function; - modnamefromaddr(start, function.mod, true); - function.start = start - modbase; - function.end = end - modbase; - function.manual = manual; - CriticalSectionLocker locker(LockFunctions); - functions.insert(std::make_pair(ModuleRange(modhashfromva(modbase), Range(function.start, function.end)), function)); - return true; -} - -bool functionget(uint addr, uint* start, uint* end) -{ - if(!DbgIsDebugging()) - return false; - uint modbase = modbasefromaddr(addr); - CriticalSectionLocker locker(LockFunctions); - const FunctionsInfo::iterator found = functions.find(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))); - if(found == functions.end()) //not found - return false; - if(start) - *start = found->second.start + modbase; - if(end) - *end = found->second.end + modbase; - return true; -} - -bool functionoverlaps(uint start, uint end) -{ - if(!DbgIsDebugging() or end < start) - return false; - const uint modbase = modbasefromaddr(start); - CriticalSectionLocker locker(LockFunctions); - return (functions.count(ModuleRange(modhashfromva(modbase), Range(start - modbase, end - modbase))) > 0); -} - -bool functiondel(uint addr) -{ - if(!DbgIsDebugging()) - return false; - const uint modbase = modbasefromaddr(addr); - CriticalSectionLocker locker(LockFunctions); - return (functions.erase(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))) > 0); -} - -void functiondelrange(uint start, uint end) -{ - if(!DbgIsDebugging()) - return; - bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) - return; - start -= modbase; - end -= modbase; - CriticalSectionLocker locker(LockFunctions); - FunctionsInfo::iterator i = functions.begin(); - while(i != functions.end()) - { - if(i->second.manual) //ignore manual - { - i++; - continue; - } - if(bDelAll or !(i->second.start <= end and i->second.end >= start)) - functions.erase(i++); - else - i++; - } -} - -void functioncachesave(JSON root) -{ - CriticalSectionLocker locker(LockFunctions); - const JSON jsonfunctions = json_array(); - const JSON jsonautofunctions = json_array(); - for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i) - { - const FUNCTIONSINFO curFunction = i->second; - JSON curjsonfunction = json_object(); - json_object_set_new(curjsonfunction, "module", json_string(curFunction.mod)); - json_object_set_new(curjsonfunction, "start", json_hex(curFunction.start)); - json_object_set_new(curjsonfunction, "end", json_hex(curFunction.end)); - if(curFunction.manual) - json_array_append_new(jsonfunctions, curjsonfunction); - else - json_array_append_new(jsonautofunctions, curjsonfunction); - } - if(json_array_size(jsonfunctions)) - json_object_set(root, "functions", jsonfunctions); - json_decref(jsonfunctions); - if(json_array_size(jsonautofunctions)) - json_object_set(root, "autofunctions", jsonautofunctions); - json_decref(jsonautofunctions); -} - -void functioncacheload(JSON root) -{ - CriticalSectionLocker locker(LockFunctions); - functions.clear(); - const JSON jsonfunctions = json_object_get(root, "functions"); - if(jsonfunctions) - { - size_t i; - JSON value; - json_array_foreach(jsonfunctions, i, value) - { - FUNCTIONSINFO curFunction; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curFunction.mod, mod); - else - *curFunction.mod = '\0'; - curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); - curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); - if(curFunction.end < curFunction.start) - continue; //invalid function - curFunction.manual = true; - const uint key = modhashfromname(curFunction.mod); - functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); - } - } - JSON jsonautofunctions = json_object_get(root, "autofunctions"); - if(jsonautofunctions) - { - size_t i; - JSON value; - json_array_foreach(jsonautofunctions, i, value) - { - FUNCTIONSINFO curFunction; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curFunction.mod, mod); - else - *curFunction.mod = '\0'; - curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); - curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); - if(curFunction.end < curFunction.start) - continue; //invalid function - curFunction.manual = true; - const uint key = modhashfromname(curFunction.mod); - functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); - } - } -} - -bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize) -{ - if(!DbgIsDebugging()) - return false; - if(!functionlist && !cbsize) - return false; - CriticalSectionLocker locker(LockFunctions); - if(!functionlist && cbsize) - { - *cbsize = functions.size() * sizeof(FUNCTIONSINFO); - return true; - } - int j = 0; - for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i, j++) - { - functionlist[j] = i->second; - uint modbase = modbasefromname(functionlist[j].mod); - functionlist[j].start += modbase; - functionlist[j].end += modbase; - } - return true; -} - -//loop database -bool loopadd(uint start, uint end, bool manual) -{ - if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) - return false; - const uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same mem page - return false; - int finaldepth; - if(loopoverlaps(0, start, end, &finaldepth)) //loop cannot overlap another loop - return false; - LOOPSINFO loop; - modnamefromaddr(start, loop.mod, true); - loop.start = start - modbase; - loop.end = end - modbase; - loop.depth = finaldepth; - if(finaldepth) - loopget(finaldepth - 1, start, &loop.parent, 0); - else - loop.parent = 0; - loop.manual = manual; - CriticalSectionLocker locker(LockLoops); - loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(modhashfromva(modbase), Range(loop.start, loop.end))), loop)); - return true; -} - -//get the start/end of a loop at a certain depth and addr -bool loopget(int depth, uint addr, uint* start, uint* end) -{ - if(!DbgIsDebugging()) - return false; - const uint modbase = modbasefromaddr(addr); - CriticalSectionLocker locker(LockLoops); - LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase)))); - if(found == loops.end()) //not found - return false; - if(start) - *start = found->second.start + modbase; - if(end) - *end = found->second.end + modbase; - return true; -} - -//check if a loop overlaps a range, inside is not overlapping -bool loopoverlaps(int depth, uint start, uint end, int* finaldepth) -{ - if(!DbgIsDebugging()) - return false; - - const uint modbase = modbasefromaddr(start); - uint curStart = start - modbase; - uint curEnd = end - modbase; - const uint key = modhashfromva(modbase); - - CriticalSectionLocker locker(LockLoops); - - //check if the new loop fits in the old loop - for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i) - { - if(i->first.second.first != key) //only look in the current module - continue; - LOOPSINFO* curLoop = &i->second; - if(curLoop->start < curStart and curLoop->end > curEnd and curLoop->depth == depth) - return loopoverlaps(depth + 1, curStart, curEnd, finaldepth); - } - - if(finaldepth) - *finaldepth = depth; - - //check for loop overlaps - for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i) - { - if(i->first.second.first != key) //only look in the current module - continue; - LOOPSINFO* curLoop = &i->second; - if(curLoop->start <= curEnd and curLoop->end >= curStart and curLoop->depth == depth) - return true; - } - return false; -} - -//this should delete a loop and all sub-loops that matches a certain addr -bool loopdel(int depth, uint addr) -{ - return false; -} - -void loopcachesave(JSON root) -{ - CriticalSectionLocker locker(LockLoops); - const JSON jsonloops = json_array(); - const JSON jsonautoloops = json_array(); - for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i) - { - const LOOPSINFO curLoop = i->second; - JSON curjsonloop = json_object(); - json_object_set_new(curjsonloop, "module", json_string(curLoop.mod)); - json_object_set_new(curjsonloop, "start", json_hex(curLoop.start)); - json_object_set_new(curjsonloop, "end", json_hex(curLoop.end)); - json_object_set_new(curjsonloop, "depth", json_integer(curLoop.depth)); - json_object_set_new(curjsonloop, "parent", json_hex(curLoop.parent)); - if(curLoop.manual) - json_array_append_new(jsonloops, curjsonloop); - else - json_array_append_new(jsonautoloops, curjsonloop); - } - if(json_array_size(jsonloops)) - json_object_set(root, "loops", jsonloops); - json_decref(jsonloops); - if(json_array_size(jsonautoloops)) - json_object_set(root, "autoloops", jsonautoloops); - json_decref(jsonautoloops); -} - -void loopcacheload(JSON root) -{ - CriticalSectionLocker locker(LockLoops); - loops.clear(); - const JSON jsonloops = json_object_get(root, "loops"); - if(jsonloops) - { - size_t i; - JSON value; - json_array_foreach(jsonloops, i, value) - { - LOOPSINFO curLoop; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLoop.mod, mod); - else - *curLoop.mod = '\0'; - curLoop.start = (uint)json_hex_value(json_object_get(value, "start")); - curLoop.end = (uint)json_hex_value(json_object_get(value, "end")); - curLoop.depth = (int)json_integer_value(json_object_get(value, "depth")); - curLoop.parent = (uint)json_hex_value(json_object_get(value, "parent")); - if(curLoop.end < curLoop.start) - continue; //invalid loop - curLoop.manual = true; - loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); - } - } - JSON jsonautoloops = json_object_get(root, "autoloops"); - if(jsonautoloops) - { - size_t i; - JSON value; - json_array_foreach(jsonautoloops, i, value) - { - LOOPSINFO curLoop; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLoop.mod, mod); - else - *curLoop.mod = '\0'; - curLoop.start = (uint)json_hex_value(json_object_get(value, "start")); - curLoop.end = (uint)json_hex_value(json_object_get(value, "end")); - curLoop.depth = (int)json_integer_value(json_object_get(value, "depth")); - curLoop.parent = (uint)json_hex_value(json_object_get(value, "parent")); - if(curLoop.end < curLoop.start) - continue; //invalid loop - curLoop.manual = false; - loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); - } - } -} - -bool loopenum(LOOPSINFO* looplist, size_t* cbsize) -{ - if(!DbgIsDebugging()) - return false; - if(!looplist && !cbsize) - return false; - CriticalSectionLocker locker(LockLoops); - if(!looplist && cbsize) - { - *cbsize = loops.size() * sizeof(LOOPSINFO); - return true; - } - int j = 0; - for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i, j++) - { - looplist[j] = i->second; - uint modbase = modbasefromname(looplist[j].mod); - looplist[j].start += modbase; - looplist[j].end += modbase; - } - return true; } \ No newline at end of file diff --git a/x64_dbg_dbg/addrinfo.h b/x64_dbg_dbg/addrinfo.h index 11599fd2..5d3f1e18 100644 --- a/x64_dbg_dbg/addrinfo.h +++ b/x64_dbg_dbg/addrinfo.h @@ -52,72 +52,6 @@ struct DepthModuleRangeCompare } }; -//structures -struct MODSECTIONINFO -{ - uint addr; //va - uint size; //virtual size - char name[50]; -}; - -struct MODINFO -{ - uint base; //module base - uint size; //module size - uint hash; //full module name hash - uint entry; //entry point - char name[MAX_MODULE_SIZE]; //module name (without extension) - char extension[MAX_MODULE_SIZE]; //file extension - std::vector sections; -}; -typedef std::map ModulesInfo; - -struct COMMENTSINFO -{ - char mod[MAX_MODULE_SIZE]; - uint addr; - char text[MAX_COMMENT_SIZE]; - bool manual; -}; -typedef std::map CommentsInfo; - -struct LABELSINFO -{ - char mod[MAX_MODULE_SIZE]; - uint addr; - char text[MAX_LABEL_SIZE]; - bool manual; -}; -typedef std::map LabelsInfo; - -struct BOOKMARKSINFO -{ - char mod[MAX_MODULE_SIZE]; - uint addr; - bool manual; -}; -typedef std::map BookmarksInfo; - -struct FUNCTIONSINFO -{ - char mod[MAX_MODULE_SIZE]; - uint start; - uint end; - bool manual; -}; -typedef std::map FunctionsInfo; - -struct LOOPSINFO -{ - char mod[MAX_MODULE_SIZE]; - uint start; - uint end; - uint parent; - int depth; - bool manual; -}; -typedef std::map LoopsInfo; - //typedefs typedef void (*EXPORTENUMCALLBACK)(uint base, const char* mod, const char* name, uint addr); @@ -125,62 +59,6 @@ void dbsave(); void dbload(); void dbclose(); -bool modload(uint base, uint size, const char* fullpath); -bool modunload(uint base); -void modclear(); -bool modnamefromaddr(uint addr, char* modname, bool extension); -uint modbasefromaddr(uint addr); -uint modhashfromva(uint va); -uint modhashfromname(const char* mod); -uint modbasefromname(const char* modname); -uint modsizefromaddr(uint addr); -bool modsectionsfromaddr(uint addr, std::vector* sections); -uint modentryfromaddr(uint addr); -int modpathfromaddr(duint addr, char* path, int size); -int modpathfromname(const char* modname, char* path, int size); - bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum); -bool commentset(uint addr, const char* text, bool manual); -bool commentget(uint addr, char* text); -bool commentdel(uint addr); -void commentdelrange(uint start, uint end); -void commentcachesave(JSON root); -void commentcacheload(JSON root); -bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize); - -bool labelset(uint addr, const char* text, bool manual); -bool labelfromstring(const char* text, uint* addr); -bool labelget(uint addr, char* text); -bool labeldel(uint addr); -void labeldelrange(uint start, uint end); -void labelcachesave(JSON root); -void labelcacheload(JSON root); -bool labelenum(LABELSINFO* labellist, size_t* cbsize); - -bool bookmarkset(uint addr, bool manual); -bool bookmarkget(uint addr); -bool bookmarkdel(uint addr); -void bookmarkdelrange(uint start, uint end); -void bookmarkcachesave(JSON root); -void bookmarkcacheload(JSON root); -bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize); - -bool functionadd(uint start, uint end, bool manual); -bool functionget(uint addr, uint* start, uint* end); -bool functionoverlaps(uint start, uint end); -bool functiondel(uint addr); -void functiondelrange(uint start, uint end); -void functioncachesave(JSON root); -void functioncacheload(JSON root); -bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize); - -bool loopadd(uint start, uint end, bool manual); -bool loopget(int depth, uint addr, uint* start, uint* end); -bool loopoverlaps(int depth, uint start, uint end, int* finaldepth); -bool loopdel(int depth, uint addr); -void loopcachesave(JSON root); -void loopcacheload(JSON root); -bool loopenum(LOOPSINFO* looplist, size_t* cbsize); - #endif // _ADDRINFO_H diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp new file mode 100644 index 00000000..71028bda --- /dev/null +++ b/x64_dbg_dbg/bookmark.cpp @@ -0,0 +1,162 @@ +#include "bookmark.h" +#include "threading.h" +#include "module.h" +#include "debugger.h" +#include "memory.h" + +typedef std::map BookmarksInfo; + +static BookmarksInfo bookmarks; + +bool bookmarkset(uint addr, bool manual) +{ + if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr)) + return false; + BOOKMARKSINFO bookmark; + modnamefromaddr(addr, bookmark.mod, true); + bookmark.addr = addr - modbasefromaddr(addr); + bookmark.manual = manual; + CriticalSectionLocker locker(LockBookmarks); + if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second) + return bookmarkdel(addr); + return true; +} + +bool bookmarkget(uint addr) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockBookmarks); + if(bookmarks.count(modhashfromva(addr))) + return true; + return false; +} + +bool bookmarkdel(uint addr) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockBookmarks); + return (bookmarks.erase(modhashfromva(addr)) > 0); +} + +void bookmarkdelrange(uint start, uint end) +{ + if(!DbgIsDebugging()) + return; + bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) + return; + start -= modbase; + end -= modbase; + CriticalSectionLocker locker(LockBookmarks); + BookmarksInfo::iterator i = bookmarks.begin(); + while(i != bookmarks.end()) + { + if(i->second.manual) //ignore manual + { + i++; + continue; + } + if(bDelAll || (i->second.addr >= start && i->second.addr < end)) + bookmarks.erase(i++); + else + i++; + } +} + +void bookmarkcachesave(JSON root) +{ + CriticalSectionLocker locker(LockBookmarks); + const JSON jsonbookmarks = json_array(); + const JSON jsonautobookmarks = json_array(); + for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i) + { + const BOOKMARKSINFO curBookmark = i->second; + JSON curjsonbookmark = json_object(); + json_object_set_new(curjsonbookmark, "module", json_string(curBookmark.mod)); + json_object_set_new(curjsonbookmark, "address", json_hex(curBookmark.addr)); + if(curBookmark.manual) + json_array_append_new(jsonbookmarks, curjsonbookmark); + else + json_array_append_new(jsonautobookmarks, curjsonbookmark); + } + if(json_array_size(jsonbookmarks)) + json_object_set(root, "bookmarks", jsonbookmarks); + json_decref(jsonbookmarks); + if(json_array_size(jsonautobookmarks)) + json_object_set(root, "autobookmarks", jsonautobookmarks); + json_decref(jsonautobookmarks); +} + +void bookmarkcacheload(JSON root) +{ + CriticalSectionLocker locker(LockBookmarks); + bookmarks.clear(); + const JSON jsonbookmarks = json_object_get(root, "bookmarks"); + if(jsonbookmarks) + { + size_t i; + JSON value; + json_array_foreach(jsonbookmarks, i, value) + { + BOOKMARKSINFO curBookmark; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curBookmark.mod, mod); + else + *curBookmark.mod = '\0'; + curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); + curBookmark.manual = true; + const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; + bookmarks.insert(std::make_pair(key, curBookmark)); + } + } + JSON jsonautobookmarks = json_object_get(root, "autobookmarks"); + if(jsonautobookmarks) + { + size_t i; + JSON value; + json_array_foreach(jsonautobookmarks, i, value) + { + BOOKMARKSINFO curBookmark; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curBookmark.mod, mod); + else + *curBookmark.mod = '\0'; + curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); + curBookmark.manual = false; + const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; + bookmarks.insert(std::make_pair(key, curBookmark)); + } + } +} + +bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) +{ + if(!DbgIsDebugging()) + return false; + if(!bookmarklist && !cbsize) + return false; + CriticalSectionLocker locker(LockBookmarks); + if(!bookmarklist && cbsize) + { + *cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO); + return true; + } + int j = 0; + for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i, j++) + { + bookmarklist[j] = i->second; + bookmarklist[j].addr += modbasefromname(bookmarklist[j].mod); + } + return true; +} + +void bookmarkclear() +{ + CriticalSectionLocker locker(LockBookmarks); + BookmarksInfo().swap(bookmarks); +} \ No newline at end of file diff --git a/x64_dbg_dbg/bookmark.h b/x64_dbg_dbg/bookmark.h new file mode 100644 index 00000000..1ee9ee82 --- /dev/null +++ b/x64_dbg_dbg/bookmark.h @@ -0,0 +1,22 @@ +#ifndef _BOOKMARK_H +#define _BOOKMARK_H + +#include "_global.h" + +struct BOOKMARKSINFO +{ + char mod[MAX_MODULE_SIZE]; + uint addr; + bool manual; +}; + +bool bookmarkset(uint addr, bool manual); +bool bookmarkget(uint addr); +bool bookmarkdel(uint addr); +void bookmarkdelrange(uint start, uint end); +void bookmarkcachesave(JSON root); +void bookmarkcacheload(JSON root); +bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize); +void bookmarkclear(); + +#endif //_BOOKMARK_H \ No newline at end of file diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index 5966ccee..0f44e137 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -4,6 +4,10 @@ #include "console.h" #include "memory.h" #include "threading.h" +#include "module.h" + +typedef std::pair BreakpointKey; +typedef std::map BreakpointsInfo; static BreakpointsInfo breakpoints; diff --git a/x64_dbg_dbg/breakpoint.h b/x64_dbg_dbg/breakpoint.h index 931913f3..bda1828c 100644 --- a/x64_dbg_dbg/breakpoint.h +++ b/x64_dbg_dbg/breakpoint.h @@ -36,8 +36,6 @@ struct BREAKPOINT //typedefs typedef bool (*BPENUMCALLBACK)(const BREAKPOINT* bp); -typedef std::pair BreakpointKey; -typedef std::map BreakpointsInfo; //functions int bpgetlist(std::vector* list); diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp new file mode 100644 index 00000000..fe74c41e --- /dev/null +++ b/x64_dbg_dbg/comment.cpp @@ -0,0 +1,182 @@ +#include "comment.h" +#include "threading.h" +#include "module.h" +#include "debugger.h" +#include "memory.h" + +typedef std::map CommentsInfo; + +static CommentsInfo comments; + +bool commentset(uint addr, const char* text, bool manual) +{ + if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or text[0] == '\1' or strlen(text) >= MAX_COMMENT_SIZE - 1) + return false; + if(!*text) //NOTE: delete when there is no text + { + commentdel(addr); + return true; + } + COMMENTSINFO comment; + comment.manual = manual; + strcpy(comment.text, text); + modnamefromaddr(addr, comment.mod, true); + comment.addr = addr - modbasefromaddr(addr); + const uint key = modhashfromva(addr); + CriticalSectionLocker locker(LockComments); + if(!comments.insert(std::make_pair(key, comment)).second) //key already present + comments[key] = comment; + return true; +} + +bool commentget(uint addr, char* text) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockComments); + const CommentsInfo::iterator found = comments.find(modhashfromva(addr)); + if(found == comments.end()) //not found + return false; + strcpy(text, found->second.text); + return true; +} + +bool commentdel(uint addr) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockComments); + return (comments.erase(modhashfromva(addr)) == 1); +} + +void commentdelrange(uint start, uint end) +{ + if(!DbgIsDebugging()) + return; + bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) + return; + start -= modbase; + end -= modbase; + CriticalSectionLocker locker(LockComments); + CommentsInfo::iterator i = comments.begin(); + while(i != comments.end()) + { + if(i->second.manual) //ignore manual + { + i++; + continue; + } + if(bDelAll || (i->second.addr >= start && i->second.addr < end)) + comments.erase(i++); + else + i++; + } +} + +void commentcachesave(JSON root) +{ + CriticalSectionLocker locker(LockComments); + const JSON jsoncomments = json_array(); + const JSON jsonautocomments = json_array(); + for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i) + { + const COMMENTSINFO curComment = i->second; + JSON curjsoncomment = json_object(); + json_object_set_new(curjsoncomment, "module", json_string(curComment.mod)); + json_object_set_new(curjsoncomment, "address", json_hex(curComment.addr)); + json_object_set_new(curjsoncomment, "text", json_string(curComment.text)); + if(curComment.manual) + json_array_append_new(jsoncomments, curjsoncomment); + else + json_array_append_new(jsonautocomments, curjsoncomment); + } + if(json_array_size(jsoncomments)) + json_object_set(root, "comments", jsoncomments); + json_decref(jsoncomments); + if(json_array_size(jsonautocomments)) + json_object_set(root, "autocomments", jsonautocomments); + json_decref(jsonautocomments); +} + +void commentcacheload(JSON root) +{ + CriticalSectionLocker locker(LockComments); + comments.clear(); + const JSON jsoncomments = json_object_get(root, "comments"); + if(jsoncomments) + { + size_t i; + JSON value; + json_array_foreach(jsoncomments, i, value) + { + COMMENTSINFO curComment; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curComment.mod, mod); + else + *curComment.mod = '\0'; + curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); + curComment.manual = true; + const char* text = json_string_value(json_object_get(value, "text")); + if(text) + strcpy(curComment.text, text); + else + continue; //skip + const uint key = modhashfromname(curComment.mod) + curComment.addr; + comments.insert(std::make_pair(key, curComment)); + } + } + JSON jsonautocomments = json_object_get(root, "autocomments"); + if(jsonautocomments) + { + size_t i; + JSON value; + json_array_foreach(jsonautocomments, i, value) + { + COMMENTSINFO curComment; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curComment.mod, mod); + else + *curComment.mod = '\0'; + curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); + curComment.manual = false; + const char* text = json_string_value(json_object_get(value, "text")); + if(text) + strcpy_s(curComment.text, text); + else + continue; //skip + const uint key = modhashfromname(curComment.mod) + curComment.addr; + comments.insert(std::make_pair(key, curComment)); + } + } +} + +bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize) +{ + if(!DbgIsDebugging()) + return false; + if(!commentlist && !cbsize) + return false; + CriticalSectionLocker locker(LockComments); + if(!commentlist && cbsize) + { + *cbsize = comments.size() * sizeof(COMMENTSINFO); + return true; + } + int j = 0; + for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i, j++) + { + commentlist[j] = i->second; + commentlist[j].addr += modbasefromname(commentlist[j].mod); + } + return true; +} + +void commentclear() +{ + CriticalSectionLocker locker(LockComments); + CommentsInfo().swap(comments); +} \ No newline at end of file diff --git a/x64_dbg_dbg/comment.h b/x64_dbg_dbg/comment.h new file mode 100644 index 00000000..3f25f6ef --- /dev/null +++ b/x64_dbg_dbg/comment.h @@ -0,0 +1,23 @@ +#ifndef _COMMENT_H +#define _COMMENT_H + +#include "_global.h" + +struct COMMENTSINFO +{ + char mod[MAX_MODULE_SIZE]; + uint addr; + char text[MAX_COMMENT_SIZE]; + bool manual; +}; + +bool commentset(uint addr, const char* text, bool manual); +bool commentget(uint addr, char* text); +bool commentdel(uint addr); +void commentdelrange(uint start, uint end); +void commentcachesave(JSON root); +void commentcacheload(JSON root); +bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize); +void commentclear(); + +#endif //_COMMENT_H \ No newline at end of file diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index e435e1fb..207de91e 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -12,6 +12,7 @@ #include "x64_dbg.h" #include "exception.h" #include "error.h" +#include "module.h" static PROCESS_INFORMATION g_pi = {0, 0, 0, 0}; static char szBaseFileName[MAX_PATH] = ""; diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 4cbec208..798ee4f7 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -11,6 +11,11 @@ #include "symbolinfo.h" #include "assemble.h" #include "disasm_fast.h" +#include "module.h" +#include "comment.h" +#include "label.h" +#include "bookmark.h" +#include "function.h" static bool bScyllaLoaded = false; uint LoadLibThreadID; diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp new file mode 100644 index 00000000..b68ece65 --- /dev/null +++ b/x64_dbg_dbg/function.cpp @@ -0,0 +1,192 @@ +#include "function.h" +#include "module.h" +#include "debugger.h" +#include "memory.h" +#include "threading.h" + +typedef std::map FunctionsInfo; + +static FunctionsInfo functions; + +bool functionadd(uint start, uint end, bool manual) +{ + if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) + return false; + const uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same module + return false; + if(functionoverlaps(start, end)) + return false; + FUNCTIONSINFO function; + modnamefromaddr(start, function.mod, true); + function.start = start - modbase; + function.end = end - modbase; + function.manual = manual; + CriticalSectionLocker locker(LockFunctions); + functions.insert(std::make_pair(ModuleRange(modhashfromva(modbase), Range(function.start, function.end)), function)); + return true; +} + +bool functionget(uint addr, uint* start, uint* end) +{ + if(!DbgIsDebugging()) + return false; + uint modbase = modbasefromaddr(addr); + CriticalSectionLocker locker(LockFunctions); + const FunctionsInfo::iterator found = functions.find(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))); + if(found == functions.end()) //not found + return false; + if(start) + *start = found->second.start + modbase; + if(end) + *end = found->second.end + modbase; + return true; +} + +bool functionoverlaps(uint start, uint end) +{ + if(!DbgIsDebugging() or end < start) + return false; + const uint modbase = modbasefromaddr(start); + CriticalSectionLocker locker(LockFunctions); + return (functions.count(ModuleRange(modhashfromva(modbase), Range(start - modbase, end - modbase))) > 0); +} + +bool functiondel(uint addr) +{ + if(!DbgIsDebugging()) + return false; + const uint modbase = modbasefromaddr(addr); + CriticalSectionLocker locker(LockFunctions); + return (functions.erase(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))) > 0); +} + +void functiondelrange(uint start, uint end) +{ + if(!DbgIsDebugging()) + return; + bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) + return; + start -= modbase; + end -= modbase; + CriticalSectionLocker locker(LockFunctions); + FunctionsInfo::iterator i = functions.begin(); + while(i != functions.end()) + { + if(i->second.manual) //ignore manual + { + i++; + continue; + } + if(bDelAll or !(i->second.start <= end and i->second.end >= start)) + functions.erase(i++); + else + i++; + } +} + +void functioncachesave(JSON root) +{ + CriticalSectionLocker locker(LockFunctions); + const JSON jsonfunctions = json_array(); + const JSON jsonautofunctions = json_array(); + for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i) + { + const FUNCTIONSINFO curFunction = i->second; + JSON curjsonfunction = json_object(); + json_object_set_new(curjsonfunction, "module", json_string(curFunction.mod)); + json_object_set_new(curjsonfunction, "start", json_hex(curFunction.start)); + json_object_set_new(curjsonfunction, "end", json_hex(curFunction.end)); + if(curFunction.manual) + json_array_append_new(jsonfunctions, curjsonfunction); + else + json_array_append_new(jsonautofunctions, curjsonfunction); + } + if(json_array_size(jsonfunctions)) + json_object_set(root, "functions", jsonfunctions); + json_decref(jsonfunctions); + if(json_array_size(jsonautofunctions)) + json_object_set(root, "autofunctions", jsonautofunctions); + json_decref(jsonautofunctions); +} + +void functioncacheload(JSON root) +{ + CriticalSectionLocker locker(LockFunctions); + functions.clear(); + const JSON jsonfunctions = json_object_get(root, "functions"); + if(jsonfunctions) + { + size_t i; + JSON value; + json_array_foreach(jsonfunctions, i, value) + { + FUNCTIONSINFO curFunction; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curFunction.mod, mod); + else + *curFunction.mod = '\0'; + curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); + curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); + if(curFunction.end < curFunction.start) + continue; //invalid function + curFunction.manual = true; + const uint key = modhashfromname(curFunction.mod); + functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); + } + } + JSON jsonautofunctions = json_object_get(root, "autofunctions"); + if(jsonautofunctions) + { + size_t i; + JSON value; + json_array_foreach(jsonautofunctions, i, value) + { + FUNCTIONSINFO curFunction; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curFunction.mod, mod); + else + *curFunction.mod = '\0'; + curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); + curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); + if(curFunction.end < curFunction.start) + continue; //invalid function + curFunction.manual = true; + const uint key = modhashfromname(curFunction.mod); + functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); + } + } +} + +bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize) +{ + if(!DbgIsDebugging()) + return false; + if(!functionlist && !cbsize) + return false; + CriticalSectionLocker locker(LockFunctions); + if(!functionlist && cbsize) + { + *cbsize = functions.size() * sizeof(FUNCTIONSINFO); + return true; + } + int j = 0; + for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i, j++) + { + functionlist[j] = i->second; + uint modbase = modbasefromname(functionlist[j].mod); + functionlist[j].start += modbase; + functionlist[j].end += modbase; + } + return true; +} + +void functionclear() +{ + CriticalSectionLocker locker(LockFunctions); + FunctionsInfo().swap(functions); +} \ No newline at end of file diff --git a/x64_dbg_dbg/function.h b/x64_dbg_dbg/function.h new file mode 100644 index 00000000..53f4adda --- /dev/null +++ b/x64_dbg_dbg/function.h @@ -0,0 +1,24 @@ +#ifndef _FUNCTION_H +#define _FUNCTION_H + +#include "addrinfo.h" + +struct FUNCTIONSINFO +{ + char mod[MAX_MODULE_SIZE]; + uint start; + uint end; + bool manual; +}; + +bool functionadd(uint start, uint end, bool manual); +bool functionget(uint addr, uint* start, uint* end); +bool functionoverlaps(uint start, uint end); +bool functiondel(uint addr); +void functiondelrange(uint start, uint end); +void functioncachesave(JSON root); +void functioncacheload(JSON root); +bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize); +void functionclear(); + +#endif //_FUNCTION_H \ No newline at end of file diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index 027ad13f..1c683925 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -12,6 +12,11 @@ #include "disasm_fast.h" #include "reference.h" #include "disasm_helper.h" +#include "comment.h" +#include "label.h" +#include "bookmark.h" +#include "function.h" +#include "loop.h" static bool bRefinit = false; diff --git a/x64_dbg_dbg/label.cpp b/x64_dbg_dbg/label.cpp new file mode 100644 index 00000000..3e05b1d8 --- /dev/null +++ b/x64_dbg_dbg/label.cpp @@ -0,0 +1,204 @@ +#include "label.h" +#include "threading.h" +#include "module.h" +#include "memory.h" +#include "debugger.h" + +typedef std::map LabelsInfo; + +static LabelsInfo labels; + +bool labelset(uint addr, const char* text, bool manual) +{ + if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text) >= MAX_LABEL_SIZE - 1 or strstr(text, "&")) + return false; + if(!*text) //NOTE: delete when there is no text + { + labeldel(addr); + return true; + } + LABELSINFO label; + label.manual = manual; + strcpy(label.text, text); + modnamefromaddr(addr, label.mod, true); + label.addr = addr - modbasefromaddr(addr); + uint key = modhashfromva(addr); + CriticalSectionLocker locker(LockLabels); + if(!labels.insert(std::make_pair(modhashfromva(key), label)).second) //already present + labels[key] = label; + return true; +} + +bool labelfromstring(const char* text, uint* addr) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockLabels); + for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i) + { + if(!strcmp(i->second.text, text)) + { + if(addr) + *addr = i->second.addr + modbasefromname(i->second.mod); + return true; + } + } + return false; +} + +bool labelget(uint addr, char* text) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockLabels); + const LabelsInfo::iterator found = labels.find(modhashfromva(addr)); + if(found == labels.end()) //not found + return false; + if(text) + strcpy(text, found->second.text); + return true; +} + +bool labeldel(uint addr) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockLabels); + return (labels.erase(modhashfromva(addr)) > 0); +} + +void labeldelrange(uint start, uint end) +{ + if(!DbgIsDebugging()) + return; + bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) + return; + start -= modbase; + end -= modbase; + CriticalSectionLocker locker(LockLabels); + LabelsInfo::iterator i = labels.begin(); + while(i != labels.end()) + { + if(i->second.manual) //ignore manual + { + i++; + continue; + } + if(bDelAll || (i->second.addr >= start && i->second.addr < end)) + labels.erase(i++); + else + i++; + } +} + +void labelcachesave(JSON root) +{ + CriticalSectionLocker locker(LockLabels); + const JSON jsonlabels = json_array(); + const JSON jsonautolabels = json_array(); + for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i) + { + const LABELSINFO curLabel = i->second; + JSON curjsonlabel = json_object(); + json_object_set_new(curjsonlabel, "module", json_string(curLabel.mod)); + json_object_set_new(curjsonlabel, "address", json_hex(curLabel.addr)); + json_object_set_new(curjsonlabel, "text", json_string(curLabel.text)); + if(curLabel.manual) + json_array_append_new(jsonlabels, curjsonlabel); + else + json_array_append_new(jsonautolabels, curjsonlabel); + } + if(json_array_size(jsonlabels)) + json_object_set(root, "labels", jsonlabels); + json_decref(jsonlabels); + if(json_array_size(jsonautolabels)) + json_object_set(root, "autolabels", jsonautolabels); + json_decref(jsonautolabels); +} + +void labelcacheload(JSON root) +{ + CriticalSectionLocker locker(LockLabels); + labels.clear(); + const JSON jsonlabels = json_object_get(root, "labels"); + if(jsonlabels) + { + size_t i; + JSON value; + json_array_foreach(jsonlabels, i, value) + { + LABELSINFO curLabel; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curLabel.mod, mod); + else + *curLabel.mod = '\0'; + curLabel.addr = (uint)json_hex_value(json_object_get(value, "address")); + curLabel.manual = true; + const char* text = json_string_value(json_object_get(value, "text")); + if(text) + strcpy(curLabel.text, text); + else + continue; //skip + int len = (int)strlen(curLabel.text); + for(int i = 0; i < len; i++) + if(curLabel.text[i] == '&') + curLabel.text[i] = ' '; + const uint key = modhashfromname(curLabel.mod) + curLabel.addr; + labels.insert(std::make_pair(key, curLabel)); + } + } + JSON jsonautolabels = json_object_get(root, "autolabels"); + if(jsonautolabels) + { + size_t i; + JSON value; + json_array_foreach(jsonautolabels, i, value) + { + LABELSINFO curLabel; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curLabel.mod, mod); + else + *curLabel.mod = '\0'; + curLabel.addr = (uint)json_hex_value(json_object_get(value, "address")); + curLabel.manual = false; + const char* text = json_string_value(json_object_get(value, "text")); + if(text) + strcpy_s(curLabel.text, text); + else + continue; //skip + const uint key = modhashfromname(curLabel.mod) + curLabel.addr; + labels.insert(std::make_pair(key, curLabel)); + } + } +} + +bool labelenum(LABELSINFO* labellist, size_t* cbsize) +{ + if(!DbgIsDebugging()) + return false; + if(!labellist && !cbsize) + return false; + CriticalSectionLocker locker(LockLabels); + if(!labellist && cbsize) + { + *cbsize = labels.size() * sizeof(LABELSINFO); + return true; + } + int j = 0; + for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i, j++) + { + labellist[j] = i->second; + labellist[j].addr += modbasefromname(labellist[j].mod); + } + return true; +} + +void labelclear() +{ + CriticalSectionLocker locker(LockLabels); + LabelsInfo().swap(labels); +} \ No newline at end of file diff --git a/x64_dbg_dbg/label.h b/x64_dbg_dbg/label.h new file mode 100644 index 00000000..3b4d06fd --- /dev/null +++ b/x64_dbg_dbg/label.h @@ -0,0 +1,24 @@ +#ifndef _LABEL_H +#define _LABEL_H + +#include "_global.h" + +struct LABELSINFO +{ + char mod[MAX_MODULE_SIZE]; + uint addr; + char text[MAX_LABEL_SIZE]; + bool manual; +}; + +bool labelset(uint addr, const char* text, bool manual); +bool labelfromstring(const char* text, uint* addr); +bool labelget(uint addr, char* text); +bool labeldel(uint addr); +void labeldelrange(uint start, uint end); +void labelcachesave(JSON root); +void labelcacheload(JSON root); +bool labelenum(LABELSINFO* labellist, size_t* cbsize); +void labelclear(); + +#endif //_LABEL_H \ No newline at end of file diff --git a/x64_dbg_dbg/loop.cpp b/x64_dbg_dbg/loop.cpp new file mode 100644 index 00000000..94979a61 --- /dev/null +++ b/x64_dbg_dbg/loop.cpp @@ -0,0 +1,203 @@ +#include "loop.h" +#include "debugger.h" +#include "memory.h" +#include "threading.h" +#include "module.h" + +typedef std::map LoopsInfo; + +static LoopsInfo loops; + +bool loopadd(uint start, uint end, bool manual) +{ + if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) + return false; + const uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same mem page + return false; + int finaldepth; + if(loopoverlaps(0, start, end, &finaldepth)) //loop cannot overlap another loop + return false; + LOOPSINFO loop; + modnamefromaddr(start, loop.mod, true); + loop.start = start - modbase; + loop.end = end - modbase; + loop.depth = finaldepth; + if(finaldepth) + loopget(finaldepth - 1, start, &loop.parent, 0); + else + loop.parent = 0; + loop.manual = manual; + CriticalSectionLocker locker(LockLoops); + loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(modhashfromva(modbase), Range(loop.start, loop.end))), loop)); + return true; +} + +//get the start/end of a loop at a certain depth and addr +bool loopget(int depth, uint addr, uint* start, uint* end) +{ + if(!DbgIsDebugging()) + return false; + const uint modbase = modbasefromaddr(addr); + CriticalSectionLocker locker(LockLoops); + LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase)))); + if(found == loops.end()) //not found + return false; + if(start) + *start = found->second.start + modbase; + if(end) + *end = found->second.end + modbase; + return true; +} + +//check if a loop overlaps a range, inside is not overlapping +bool loopoverlaps(int depth, uint start, uint end, int* finaldepth) +{ + if(!DbgIsDebugging()) + return false; + + const uint modbase = modbasefromaddr(start); + uint curStart = start - modbase; + uint curEnd = end - modbase; + const uint key = modhashfromva(modbase); + + CriticalSectionLocker locker(LockLoops); + + //check if the new loop fits in the old loop + for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i) + { + if(i->first.second.first != key) //only look in the current module + continue; + LOOPSINFO* curLoop = &i->second; + if(curLoop->start < curStart and curLoop->end > curEnd and curLoop->depth == depth) + return loopoverlaps(depth + 1, curStart, curEnd, finaldepth); + } + + if(finaldepth) + *finaldepth = depth; + + //check for loop overlaps + for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i) + { + if(i->first.second.first != key) //only look in the current module + continue; + LOOPSINFO* curLoop = &i->second; + if(curLoop->start <= curEnd and curLoop->end >= curStart and curLoop->depth == depth) + return true; + } + return false; +} + +//this should delete a loop and all sub-loops that matches a certain addr +bool loopdel(int depth, uint addr) +{ + return false; +} + +void loopcachesave(JSON root) +{ + CriticalSectionLocker locker(LockLoops); + const JSON jsonloops = json_array(); + const JSON jsonautoloops = json_array(); + for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i) + { + const LOOPSINFO curLoop = i->second; + JSON curjsonloop = json_object(); + json_object_set_new(curjsonloop, "module", json_string(curLoop.mod)); + json_object_set_new(curjsonloop, "start", json_hex(curLoop.start)); + json_object_set_new(curjsonloop, "end", json_hex(curLoop.end)); + json_object_set_new(curjsonloop, "depth", json_integer(curLoop.depth)); + json_object_set_new(curjsonloop, "parent", json_hex(curLoop.parent)); + if(curLoop.manual) + json_array_append_new(jsonloops, curjsonloop); + else + json_array_append_new(jsonautoloops, curjsonloop); + } + if(json_array_size(jsonloops)) + json_object_set(root, "loops", jsonloops); + json_decref(jsonloops); + if(json_array_size(jsonautoloops)) + json_object_set(root, "autoloops", jsonautoloops); + json_decref(jsonautoloops); +} + +void loopcacheload(JSON root) +{ + CriticalSectionLocker locker(LockLoops); + loops.clear(); + const JSON jsonloops = json_object_get(root, "loops"); + if(jsonloops) + { + size_t i; + JSON value; + json_array_foreach(jsonloops, i, value) + { + LOOPSINFO curLoop; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curLoop.mod, mod); + else + *curLoop.mod = '\0'; + curLoop.start = (uint)json_hex_value(json_object_get(value, "start")); + curLoop.end = (uint)json_hex_value(json_object_get(value, "end")); + curLoop.depth = (int)json_integer_value(json_object_get(value, "depth")); + curLoop.parent = (uint)json_hex_value(json_object_get(value, "parent")); + if(curLoop.end < curLoop.start) + continue; //invalid loop + curLoop.manual = true; + loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); + } + } + JSON jsonautoloops = json_object_get(root, "autoloops"); + if(jsonautoloops) + { + size_t i; + JSON value; + json_array_foreach(jsonautoloops, i, value) + { + LOOPSINFO curLoop; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy(curLoop.mod, mod); + else + *curLoop.mod = '\0'; + curLoop.start = (uint)json_hex_value(json_object_get(value, "start")); + curLoop.end = (uint)json_hex_value(json_object_get(value, "end")); + curLoop.depth = (int)json_integer_value(json_object_get(value, "depth")); + curLoop.parent = (uint)json_hex_value(json_object_get(value, "parent")); + if(curLoop.end < curLoop.start) + continue; //invalid loop + curLoop.manual = false; + loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); + } + } +} + +bool loopenum(LOOPSINFO* looplist, size_t* cbsize) +{ + if(!DbgIsDebugging()) + return false; + if(!looplist && !cbsize) + return false; + CriticalSectionLocker locker(LockLoops); + if(!looplist && cbsize) + { + *cbsize = loops.size() * sizeof(LOOPSINFO); + return true; + } + int j = 0; + for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i, j++) + { + looplist[j] = i->second; + uint modbase = modbasefromname(looplist[j].mod); + looplist[j].start += modbase; + looplist[j].end += modbase; + } + return true; +} + +void loopclear() +{ + CriticalSectionLocker locker(LockLoops); + LoopsInfo().swap(loops); +} \ No newline at end of file diff --git a/x64_dbg_dbg/loop.h b/x64_dbg_dbg/loop.h new file mode 100644 index 00000000..14b87c1d --- /dev/null +++ b/x64_dbg_dbg/loop.h @@ -0,0 +1,25 @@ +#ifndef _LOOP_H +#define _LOOP_H + +#include "addrinfo.h" + +struct LOOPSINFO +{ + char mod[MAX_MODULE_SIZE]; + uint start; + uint end; + uint parent; + int depth; + bool manual; +}; + +bool loopadd(uint start, uint end, bool manual); +bool loopget(int depth, uint addr, uint* start, uint* end); +bool loopoverlaps(int depth, uint start, uint end, int* finaldepth); +bool loopdel(int depth, uint addr); +void loopcachesave(JSON root); +void loopcacheload(JSON root); +bool loopenum(LOOPSINFO* looplist, size_t* cbsize); +void loopclear(); + +#endif //_LOOP_H \ No newline at end of file diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index cbc77812..15b60bb5 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -3,6 +3,7 @@ #include "patches.h" #include "console.h" #include "threading.h" +#include "module.h" MemoryMap memoryPages; bool bListAllPages = false; diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp new file mode 100644 index 00000000..87142f80 --- /dev/null +++ b/x64_dbg_dbg/module.cpp @@ -0,0 +1,199 @@ +#include "module.h" +#include "debugger.h" +#include "threading.h" +#include "symbolinfo.h" +#include "murmurhash.h" + +static ModulesInfo modinfo; + +///module functions +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--; + if(len) + len++; + strcpy(name, fullpath + len); + _strlwr(name); + len = (int)strlen(name); + name[MAX_MODULE_SIZE - 1] = 0; //ignore later characters + while(name[len] != '.' and len) + len--; + MODINFO info; + memset(&info, 0, sizeof(MODINFO)); + info.sections.clear(); + info.hash = modhashfromname(name); + if(len) + { + strcpy(info.extension, name + len); + name[len] = 0; //remove extension + } + info.base = base; + info.size = size; + strcpy(info.name, name); + + //process module sections + HANDLE FileHandle; + DWORD LoadedSize; + HANDLE FileMap; + ULONG_PTR FileMapVA; + WString wszFullPath = StringUtils::Utf8ToUtf16(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); + if(SectionCount > 0) + { + for(int i = 0; i < SectionCount; i++) + { + MODSECTIONINFO curSection; + curSection.addr = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALOFFSET) + base; + curSection.size = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALSIZE); + const char* SectionName = (const char*)GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONNAME); + //escape section name when needed + int len = (int)strlen(SectionName); + int escape_count = 0; + for(int k = 0; k < len; k++) + if(SectionName[k] == '\\' or SectionName[k] == '\"' or !isprint(SectionName[k])) + escape_count++; + strcpy_s(curSection.name, StringUtils::Escape(SectionName).c_str()); + info.sections.push_back(curSection); + } + } + StaticFileUnloadW(wszFullPath.c_str(), false, FileHandle, LoadedSize, FileMap, FileMapVA); + } + + //add module to list + CriticalSectionLocker locker(LockModules); + modinfo.insert(std::make_pair(Range(base, base + size - 1), info)); + symupdatemodulelist(); + return true; +} + +bool modunload(uint base) +{ + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(base, base)); + if(found == modinfo.end()) //not found + return false; + modinfo.erase(found); + symupdatemodulelist(); + return true; +} + +void modclear() +{ + CriticalSectionLocker locker(LockModules); + ModulesInfo().swap(modinfo); + symupdatemodulelist(); +} + +bool modnamefromaddr(uint addr, char* modname, bool extension) +{ + if(!modname) + return false; + *modname = '\0'; + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found + return false; + String mod = found->second.name; + if(extension) + mod += found->second.extension; + strcpy_s(modname, MAX_MODULE_SIZE, mod.c_str()); + return true; +} + +uint modbasefromaddr(uint addr) +{ + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found + return 0; + return found->second.base; +} + +uint modhashfromva(uint va) //return a unique hash from a VA +{ + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(va, va)); + if(found == modinfo.end()) //not found + return va; + return found->second.hash + (va - found->second.base); +} + +uint modhashfromname(const char* mod) //return MODINFO.hash +{ + if(!mod or !*mod) + return 0; + int len = (int)strlen(mod); + return murmurhash(mod, len); +} + +uint modbasefromname(const char* modname) +{ + if(!modname or strlen(modname) >= MAX_MODULE_SIZE) + return 0; + CriticalSectionLocker locker(LockModules); + for(ModulesInfo::iterator i = modinfo.begin(); i != modinfo.end(); ++i) + { + MODINFO* curMod = &i->second; + char curmodname[MAX_MODULE_SIZE] = ""; + sprintf(curmodname, "%s%s", curMod->name, curMod->extension); + if(!_stricmp(curmodname, modname)) //with extension + return curMod->base; + if(!_stricmp(curMod->name, modname)) //without extension + return curMod->base; + } + return 0; +} + +uint modsizefromaddr(uint addr) +{ + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found + return 0; + return found->second.size; +} + +bool modsectionsfromaddr(uint addr, std::vector* sections) +{ + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found + return false; + *sections = found->second.sections; + return true; +} + +uint modentryfromaddr(uint addr) +{ + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found + return 0; + return found->second.entry; +} + +int modpathfromaddr(duint addr, char* path, int size) +{ + Memory wszModPath(size * sizeof(wchar_t), "modpathfromaddr:wszModPath"); + if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), wszModPath, size)) + { + *path = '\0'; + return 0; + } + strcpy_s(path, size, StringUtils::Utf16ToUtf8(wszModPath()).c_str()); + return (int)strlen(path); +} + +int modpathfromname(const char* modname, char* path, int size) +{ + return modpathfromaddr(modbasefromname(modname), path, size); +} diff --git a/x64_dbg_dbg/module.h b/x64_dbg_dbg/module.h new file mode 100644 index 00000000..95edba18 --- /dev/null +++ b/x64_dbg_dbg/module.h @@ -0,0 +1,40 @@ +#ifndef _MODULE_H +#define _MODULE_H + +#include "_global.h" +#include "addrinfo.h" + +struct MODSECTIONINFO +{ + uint addr; //va + uint size; //virtual size + char name[50]; +}; + +struct MODINFO +{ + uint base; //module base + uint size; //module size + uint hash; //full module name hash + uint entry; //entry point + char name[MAX_MODULE_SIZE]; //module name (without extension) + char extension[MAX_MODULE_SIZE]; //file extension + std::vector sections; +}; +typedef std::map ModulesInfo; + +bool modload(uint base, uint size, const char* fullpath); +bool modunload(uint base); +void modclear(); +bool modnamefromaddr(uint addr, char* modname, bool extension); +uint modbasefromaddr(uint addr); +uint modhashfromva(uint va); +uint modhashfromname(const char* mod); +uint modbasefromname(const char* modname); +uint modsizefromaddr(uint addr); +bool modsectionsfromaddr(uint addr, std::vector* sections); +uint modentryfromaddr(uint addr); +int modpathfromaddr(duint addr, char* path, int size); +int modpathfromname(const char* modname, char* path, int size); + +#endif //_MODULE_H \ No newline at end of file diff --git a/x64_dbg_dbg/patches.cpp b/x64_dbg_dbg/patches.cpp index 5cceca68..8b8461b6 100644 --- a/x64_dbg_dbg/patches.cpp +++ b/x64_dbg_dbg/patches.cpp @@ -4,6 +4,7 @@ #include "debugger.h" #include "console.h" #include "threading.h" +#include "module.h" static PatchesInfo patches; @@ -122,7 +123,7 @@ bool patchenum(PATCHINFO* patcheslist, size_t* cbsize) CriticalSectionLocker locker(LockPatches); if(!patcheslist && cbsize) { - *cbsize = patches.size() * sizeof(LOOPSINFO); + *cbsize = patches.size() * sizeof(PATCHINFO); return true; } int j = 0; diff --git a/x64_dbg_dbg/reference.cpp b/x64_dbg_dbg/reference.cpp index a696ede8..0f7e3ccd 100644 --- a/x64_dbg_dbg/reference.cpp +++ b/x64_dbg_dbg/reference.cpp @@ -2,6 +2,7 @@ #include "debugger.h" #include "memory.h" #include "console.h" +#include "module.h" int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent, const char* name) { diff --git a/x64_dbg_dbg/stackinfo.cpp b/x64_dbg_dbg/stackinfo.cpp index 59898d83..db964289 100644 --- a/x64_dbg_dbg/stackinfo.cpp +++ b/x64_dbg_dbg/stackinfo.cpp @@ -6,6 +6,7 @@ #include "BeaEngine\BeaEngine.h" #include "addrinfo.h" #include "_exports.h" +#include "module.h" bool stackcommentget(uint addr, STACK_COMMENT* comment) { diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index a06b73ef..a7a8bcf3 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -2,6 +2,8 @@ #include "debugger.h" #include "addrinfo.h" #include "console.h" +#include "module.h" +#include "label.h" struct SYMBOLCBDATA { diff --git a/x64_dbg_dbg/value.cpp b/x64_dbg_dbg/value.cpp index 918d454f..c3f09af6 100644 --- a/x64_dbg_dbg/value.cpp +++ b/x64_dbg_dbg/value.cpp @@ -6,7 +6,8 @@ #include "memory.h" #include "addrinfo.h" #include "symbolinfo.h" -#include +#include "module.h" +#include "label.h" static bool dosignedcalc = false; diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 0e2109ba..b8f5a547 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -14,8 +14,10 @@ + + @@ -23,11 +25,15 @@ + + + + @@ -55,8 +61,10 @@ + + @@ -67,16 +75,20 @@ + + + + diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 232a232f..357085da 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -123,15 +123,9 @@ Source Files\Utilities - - Source Files\Utilities - Source Files\Core - - Source Files\Utilities - Source Files\Utilities @@ -144,9 +138,6 @@ Source Files\Information - - Source Files\Utilities - Source Files\Debugger Core @@ -168,11 +159,38 @@ Source Files\Utilities - - Source Files\Utilities + + Source Files\Information + + + Source Files\Information + + + Source Files\Information + + + Source Files\Information + + + Source Files\Information + + + Source Files\Information - Source Files\Utilities + Source Files\Information + + + Source Files\Information + + + Source Files\Information + + + Source Files\Information + + + Source Files\Information @@ -287,21 +305,12 @@ Header Files\Utilities - - Header Files\Utilities - - - Header Files\Utilities - Header Files\Utilities Header Files\Utilities - - Header Files\Utilities - Header Files\Utilities @@ -323,11 +332,38 @@ Header Files\Utilities - - Header Files\Utilities + + Header Files\Information + + + Header Files\Information + + + Header Files\Information + + + Header Files\Information + + + Header Files\Information + + + Header Files\Information + + + Header Files\Information - Header Files\Utilities + Header Files\Information + + + Header Files\Information + + + Header Files\Information + + + Header Files\Information \ No newline at end of file From 4a955c6b13810340beef2cf87338020773998c86 Mon Sep 17 00:00:00 2001 From: zerosum0x0 Date: Sun, 1 Feb 2015 08:37:01 -0700 Subject: [PATCH 025/106] Fixes for three C4313 warnings on sprintf. --- x64_dbg_dbg/debugger.cpp | 6 +++--- x64_dbg_dbg/debugger_commands.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 207de91e..5d4b4a13 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -657,7 +657,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) uint ImageBase = GetPE32DataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), 0, UE_IMAGEBASE); for(unsigned int i = 0; i < NumberOfCallBacks; i++) { - sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + pDebuggedBase, i + 1); + sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + pDebuggedBase, i + 1); cmddirectexec(dbggetcommandlist(), command); } } @@ -666,7 +666,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) if(settingboolget("Events", "EntryBreakpoint")) { - sprintf(command, "bp "fhex",\"entry breakpoint\",ss", CreateProcessInfo->lpStartAddress); + sprintf(command, "bp "fhex",\"entry breakpoint\",ss", (uint)CreateProcessInfo->lpStartAddress); cmddirectexec(dbggetcommandlist(), command); } } @@ -706,7 +706,7 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) if(settingboolget("Events", "ThreadEntry")) { char command[256] = ""; - sprintf(command, "bp "fhex",\"Thread %X\",ss", CreateThread->lpStartAddress, dwThreadId); + sprintf(command, "bp "fhex",\"Thread %X\",ss", (uint)CreateThread->lpStartAddress, dwThreadId); cmddirectexec(dbggetcommandlist(), command); } diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 798ee4f7..23e29003 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -1846,7 +1846,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) // Arch specific asm code #ifdef _WIN64 - sprintf(command, "mov rcx, "fhex, DLLNameMem); + sprintf(command, "mov rcx, "fhex, (uint)DLLNameMem); #else sprintf(command, "push "fhex, DLLNameMem); #endif // _WIN64 From 6f36c0d69b4c0426625ee4a9e1e948c6fd90caf0 Mon Sep 17 00:00:00 2001 From: zerosum0x0 Date: Sun, 1 Feb 2015 08:49:39 -0700 Subject: [PATCH 026/106] applied formatting --- x64_dbg_dbg/debugger.cpp | 6 +++--- x64_dbg_dbg/debugger_commands.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 5d4b4a13..2abe86b7 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -657,7 +657,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) uint ImageBase = GetPE32DataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), 0, UE_IMAGEBASE); for(unsigned int i = 0; i < NumberOfCallBacks; i++) { - sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + pDebuggedBase, i + 1); + sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + pDebuggedBase, i + 1); cmddirectexec(dbggetcommandlist(), command); } } @@ -666,7 +666,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) if(settingboolget("Events", "EntryBreakpoint")) { - sprintf(command, "bp "fhex",\"entry breakpoint\",ss", (uint)CreateProcessInfo->lpStartAddress); + sprintf(command, "bp "fhex",\"entry breakpoint\",ss", (uint)CreateProcessInfo->lpStartAddress); cmddirectexec(dbggetcommandlist(), command); } } @@ -706,7 +706,7 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) if(settingboolget("Events", "ThreadEntry")) { char command[256] = ""; - sprintf(command, "bp "fhex",\"Thread %X\",ss", (uint)CreateThread->lpStartAddress, dwThreadId); + sprintf(command, "bp "fhex",\"Thread %X\",ss", (uint)CreateThread->lpStartAddress, dwThreadId); cmddirectexec(dbggetcommandlist(), command); } diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 23e29003..21e7d33e 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -1846,7 +1846,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) // Arch specific asm code #ifdef _WIN64 - sprintf(command, "mov rcx, "fhex, (uint)DLLNameMem); + sprintf(command, "mov rcx, "fhex, (uint)DLLNameMem); #else sprintf(command, "push "fhex, DLLNameMem); #endif // _WIN64 From 5eac008849692f97abd694ec5cd7a63fb5c18a3a Mon Sep 17 00:00:00 2001 From: zerosum0x0 Date: Sun, 1 Feb 2015 16:02:53 -0700 Subject: [PATCH 027/106] Added buffer sizes for strcpy_s --- x64_dbg_dbg/argument.cpp | 8 ++++---- x64_dbg_dbg/command.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x64_dbg_dbg/argument.cpp b/x64_dbg_dbg/argument.cpp index a0b160a8..0ef94b99 100644 --- a/x64_dbg_dbg/argument.cpp +++ b/x64_dbg_dbg/argument.cpp @@ -29,7 +29,7 @@ void argformat(char* cmd) char command_[deflen] = ""; char* command = command_; - strcpy(command, cmd); + strcpy_s(command, deflen, cmd); while(*command == ' ') command++; @@ -112,7 +112,7 @@ void argformat(char* cmd) j += sprintf(temp + j, "%c", arguments[i]); } arguments = arguments_; - strcpy(arguments, temp); + strcpy_s(arguments, deflen, temp); } len = (int)strlen(arguments); for(int i = 0; i < len; i++) @@ -128,7 +128,7 @@ void argformat(char* cmd) i += 2; j += sprintf(temp + j, "%c", arguments[i]); } - strcpy(arguments, temp); + strcpy_s(arguments, deflen, temp); len = (int)strlen(arguments); for(int i = 0, j = 0; i < len; i++) @@ -137,7 +137,7 @@ void argformat(char* cmd) i++; j += sprintf(temp + j, "%c", arguments[i]); } - strcpy(arguments, temp); + strcpy_s(arguments, deflen, temp); len = (int)strlen(arguments); for(int i = 0; i < len; i++) diff --git a/x64_dbg_dbg/command.cpp b/x64_dbg_dbg/command.cpp index 08d10c45..929fa128 100644 --- a/x64_dbg_dbg/command.cpp +++ b/x64_dbg_dbg/command.cpp @@ -75,7 +75,7 @@ bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool d COMMAND* cmdget(COMMAND* command_list, const char* cmd) { char new_cmd[deflen] = ""; - strcpy_s(new_cmd, cmd); + strcpy_s(new_cmd, deflen, cmd); int len = (int)strlen(new_cmd); int start = 0; while(new_cmd[start] != ' ' and start < len) From 7b5ea5f878d55ce8d9ff00e474abf5b8edf7df68 Mon Sep 17 00:00:00 2001 From: zerosum0x0 Date: Sun, 1 Feb 2015 16:04:33 -0700 Subject: [PATCH 028/106] strcpy_s patch for bridgemain.cpp --- x64_dbg_bridge/bridgemain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.cpp b/x64_dbg_bridge/bridgemain.cpp index 4e266ed9..2a53c064 100644 --- a/x64_dbg_bridge/bridgemain.cpp +++ b/x64_dbg_bridge/bridgemain.cpp @@ -296,7 +296,7 @@ BRIDGE_IMPEXP bool DbgSetCommentAt(duint addr, const char* text) ADDRINFO info; memset(&info, 0, sizeof(info)); info.flags = flagcomment; - strcpy(info.comment, text); + strcpy_s(info.comment, MAX_COMMENT_SIZE, text); if(!_dbg_addrinfoset(addr, &info)) return false; return true; @@ -311,7 +311,7 @@ BRIDGE_IMPEXP bool DbgGetModuleAt(duint addr, char* text) info.flags = flagmodule; if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info)) return false; - strcpy(text, info.module); + strcpy_s(text, MAX_MODULE_SIZE, info.module); return true; } From ca1bca2e5837ded39cd58094bff57037ae8ecdbd Mon Sep 17 00:00:00 2001 From: zerosum0x0 Date: Sun, 1 Feb 2015 16:06:44 -0700 Subject: [PATCH 029/106] strcpy_s patches --- x64_dbg_bridge/bridgemain.cpp | 4 ++-- x64_dbg_dbg/argument.cpp | 8 ++++---- x64_dbg_dbg/command.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.cpp b/x64_dbg_bridge/bridgemain.cpp index 2a53c064..407f43ed 100644 --- a/x64_dbg_bridge/bridgemain.cpp +++ b/x64_dbg_bridge/bridgemain.cpp @@ -296,7 +296,7 @@ BRIDGE_IMPEXP bool DbgSetCommentAt(duint addr, const char* text) ADDRINFO info; memset(&info, 0, sizeof(info)); info.flags = flagcomment; - strcpy_s(info.comment, MAX_COMMENT_SIZE, text); + strcpy_s(info.comment, MAX_COMMENT_SIZE, text); if(!_dbg_addrinfoset(addr, &info)) return false; return true; @@ -311,7 +311,7 @@ BRIDGE_IMPEXP bool DbgGetModuleAt(duint addr, char* text) info.flags = flagmodule; if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info)) return false; - strcpy_s(text, MAX_MODULE_SIZE, info.module); + strcpy_s(text, MAX_MODULE_SIZE, info.module); return true; } diff --git a/x64_dbg_dbg/argument.cpp b/x64_dbg_dbg/argument.cpp index 0ef94b99..9f89082e 100644 --- a/x64_dbg_dbg/argument.cpp +++ b/x64_dbg_dbg/argument.cpp @@ -29,7 +29,7 @@ void argformat(char* cmd) char command_[deflen] = ""; char* command = command_; - strcpy_s(command, deflen, cmd); + strcpy_s(command, deflen, cmd); while(*command == ' ') command++; @@ -112,7 +112,7 @@ void argformat(char* cmd) j += sprintf(temp + j, "%c", arguments[i]); } arguments = arguments_; - strcpy_s(arguments, deflen, temp); + strcpy_s(arguments, deflen, temp); } len = (int)strlen(arguments); for(int i = 0; i < len; i++) @@ -128,7 +128,7 @@ void argformat(char* cmd) i += 2; j += sprintf(temp + j, "%c", arguments[i]); } - strcpy_s(arguments, deflen, temp); + strcpy_s(arguments, deflen, temp); len = (int)strlen(arguments); for(int i = 0, j = 0; i < len; i++) @@ -137,7 +137,7 @@ void argformat(char* cmd) i++; j += sprintf(temp + j, "%c", arguments[i]); } - strcpy_s(arguments, deflen, temp); + strcpy_s(arguments, deflen, temp); len = (int)strlen(arguments); for(int i = 0; i < len; i++) diff --git a/x64_dbg_dbg/command.cpp b/x64_dbg_dbg/command.cpp index 929fa128..62be270d 100644 --- a/x64_dbg_dbg/command.cpp +++ b/x64_dbg_dbg/command.cpp @@ -75,7 +75,7 @@ bool cmdnew(COMMAND* command_list, const char* name, CBCOMMAND cbCommand, bool d COMMAND* cmdget(COMMAND* command_list, const char* cmd) { char new_cmd[deflen] = ""; - strcpy_s(new_cmd, deflen, cmd); + strcpy_s(new_cmd, deflen, cmd); int len = (int)strlen(new_cmd); int start = 0; while(new_cmd[start] != ' ' and start < len) From d1c92eeb553e37a32158b63c8bc1a16a273b6f29 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Mon, 2 Feb 2015 00:58:25 +0100 Subject: [PATCH 030/106] DBG: fixed most strcpy_s problems --- x64_dbg_bridge/bridgemain.cpp | 6 ++-- x64_dbg_bridge/bridgemain.h | 1 + x64_dbg_dbg/_dbgfunctions.cpp | 4 +-- x64_dbg_dbg/_exports.cpp | 6 ++-- x64_dbg_dbg/_global.cpp | 4 +-- x64_dbg_dbg/argument.cpp | 10 +++---- x64_dbg_dbg/assemble.cpp | 4 +-- x64_dbg_dbg/bookmark.cpp | 4 +-- x64_dbg_dbg/breakpoint.cpp | 4 +-- x64_dbg_dbg/comment.cpp | 10 +++---- x64_dbg_dbg/debugger.cpp | 34 +++++++++++----------- x64_dbg_dbg/debugger_commands.cpp | 12 ++++---- x64_dbg_dbg/disasm_fast.cpp | 10 +++---- x64_dbg_dbg/disasm_helper.cpp | 8 ++--- x64_dbg_dbg/function.cpp | 4 +-- x64_dbg_dbg/instruction.cpp | 14 ++++----- x64_dbg_dbg/label.cpp | 10 +++---- x64_dbg_dbg/loop.cpp | 4 +-- x64_dbg_dbg/module.cpp | 6 ++-- x64_dbg_dbg/patches.cpp | 10 +++---- x64_dbg_dbg/plugin_loader.cpp | 2 +- x64_dbg_dbg/simplescript.cpp | 22 +++++++------- x64_dbg_dbg/stackinfo.cpp | 12 ++++---- x64_dbg_dbg/symbolinfo.cpp | 2 +- x64_dbg_dbg/thread.cpp | 2 +- x64_dbg_dbg/value.cpp | 13 +++++---- x64_dbg_dbg/x64_dbg.cpp | 12 ++++---- x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp | 2 +- 28 files changed, 117 insertions(+), 115 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.cpp b/x64_dbg_bridge/bridgemain.cpp index 407f43ed..0fb52c97 100644 --- a/x64_dbg_bridge/bridgemain.cpp +++ b/x64_dbg_bridge/bridgemain.cpp @@ -259,7 +259,7 @@ BRIDGE_IMPEXP bool DbgGetLabelAt(duint addr, SEGMENTREG segment, char* text) //( return false; sprintf_s(info.label, "&%s", ptrinfo.label); } - strcpy(text, info.label); + strcpy_s(text, MAX_LABEL_SIZE, info.label); return true; } @@ -270,7 +270,7 @@ BRIDGE_IMPEXP bool DbgSetLabelAt(duint addr, const char* text) ADDRINFO info; memset(&info, 0, sizeof(info)); info.flags = flaglabel; - strcpy(info.label, text); + strcpy_s(info.label, text); if(!_dbg_addrinfoset(addr, &info)) return false; return true; @@ -285,7 +285,7 @@ BRIDGE_IMPEXP bool DbgGetCommentAt(duint addr, char* text) //comment (not live) info.flags = flagcomment; if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info)) return false; - strcpy(text, info.comment); + strcpy_s(text, MAX_COMMENT_SIZE, info.comment); return true; } diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index aed57200..c64fe3c1 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -60,6 +60,7 @@ BRIDGE_IMPEXP int BridgeGetDbgVersion(); #define MAX_STRING_SIZE 512 #define MAX_ERROR_SIZE 512 #define RIGHTS_STRING_SIZE (sizeof("ERWCG") + 1) +#define MAX_SECTION_SIZE 10 #define TYPE_VALUE 1 #define TYPE_MEMORY 2 diff --git a/x64_dbg_dbg/_dbgfunctions.cpp b/x64_dbg_dbg/_dbgfunctions.cpp index fac654e7..57bc9934 100644 --- a/x64_dbg_dbg/_dbgfunctions.cpp +++ b/x64_dbg_dbg/_dbgfunctions.cpp @@ -42,7 +42,7 @@ static bool _sectionfromaddr(duint addr, char* section) { const char* name = (const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME); if(section) - strcpy(section, name); + strcpy_s(section, MAX_SECTION_SIZE, name); //maxi StaticFileUnloadW(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA); return true; } @@ -131,7 +131,7 @@ static bool _getjit(char* jit, bool jit64) { if(!dbggetjit(jit_tmp, jit64 ? x64 : x32, &dummy, NULL)) return false; - strcpy(jit, jit_tmp); + strcpy_s(jit, MAX_SETTING_SIZE, jit_tmp); } else // if jit input == NULL: it returns false if there are not an OLD JIT STORED. { diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index ce0d01ae..e0e89df8 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -163,7 +163,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR if(SymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) and !dwDisplacement) { char filename[deflen] = ""; - strcpy(filename, line.FileName); + strcpy_s(filename, line.FileName); int len = (int)strlen(filename); while(filename[len] != '\\' and len != 0) len--; @@ -568,8 +568,8 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap) //TODO: fix this if(memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr)) curBp.active = true; - strcpy(curBp.mod, list[i].mod); - strcpy(curBp.name, list[i].name); + strcpy_s(curBp.mod, list[i].mod); + strcpy_s(curBp.name, list[i].name); curBp.singleshoot = list[i].singleshoot; curBp.slot = slot; if(curBp.active) diff --git a/x64_dbg_dbg/_global.cpp b/x64_dbg_dbg/_global.cpp index eb935d7a..3e1fc67e 100644 --- a/x64_dbg_dbg/_global.cpp +++ b/x64_dbg_dbg/_global.cpp @@ -111,7 +111,7 @@ void formathex(char* string) for(int i = 0, j = 0; i < len; i++) if(isxdigit(string[i])) j += sprintf(new_string + j, "%c", string[i]); - strcpy(string, new_string); + strcpy_s(string, len + 1, new_string); } void formatdec(char* string) @@ -123,7 +123,7 @@ void formatdec(char* string) for(int i = 0, j = 0; i < len; i++) if(isdigit(string[i])) j += sprintf(new_string + j, "%c", string[i]); - strcpy(string, new_string); + strcpy_s(string, len + 1, new_string); } bool FileExists(const char* file) diff --git a/x64_dbg_dbg/argument.cpp b/x64_dbg_dbg/argument.cpp index 9f89082e..85b23cc6 100644 --- a/x64_dbg_dbg/argument.cpp +++ b/x64_dbg_dbg/argument.cpp @@ -150,7 +150,7 @@ void argformat(char* cmd) if(strlen(arguments)) sprintf(cmd, "%s %s", command, arguments); else - strcpy(cmd, command); + strcpy_s(cmd, deflen, command); } /* @@ -173,7 +173,7 @@ int arggetcount(const char* cmd) arg_count = 1; char temp_[deflen] = ""; char* temp = temp_ + 1; - strcpy(temp, cmd); + strcpy_s(temp, deflen - 1, cmd); for(int i = start; i < len; i++) if(temp[i] == '\\' and (i < len - 1 and temp[i + 1] == '\\')) { @@ -213,7 +213,7 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional) start++; char temp_[deflen] = ""; char* temp = temp_ + 1; - strcpy(temp, cmd + start); + strcpy_s(temp, deflen - 1, cmd + start); int len = (int)strlen(temp); for(int i = 0; i < len; i++) @@ -253,7 +253,7 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional) memcpy(temp, new_temp, len + 1); if(arg_num == 0) //first argument { - strcpy(arg, temp); + strcpy_s(arg, deflen, temp); return true; } for(int i = 0, j = 0; i < len; i++) @@ -262,7 +262,7 @@ bool argget(const char* cmd, char* arg, int arg_num, bool optional) j++; if(j == arg_num) { - strcpy(arg, temp + i + 1); + strcpy_s(arg, deflen, temp + i + 1); return true; } } diff --git a/x64_dbg_dbg/assemble.cpp b/x64_dbg_dbg/assemble.cpp index 3250447d..6c6f1f11 100644 --- a/x64_dbg_dbg/assemble.cpp +++ b/x64_dbg_dbg/assemble.cpp @@ -34,11 +34,11 @@ bool assemble(uint addr, unsigned char* dest, int* size, const char* instruction size_t pos = instr.find(" short "); if(pos != String::npos) instr.erase(pos, 6); - strcpy(parse.instr, instr.c_str()); + strcpy_s(parse.instr, instr.c_str()); if(XEDParseAssemble(&parse) == XEDPARSE_ERROR) { if(error) - strcpy(error, parse.error); + strcpy_s(error, MAX_ERROR_SIZE, parse.error); return false; } diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 71028bda..7f66977d 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -104,7 +104,7 @@ void bookmarkcacheload(JSON root) BOOKMARKSINFO curBookmark; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curBookmark.mod, mod); + strcpy_s(curBookmark.mod, mod); else *curBookmark.mod = '\0'; curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); @@ -123,7 +123,7 @@ void bookmarkcacheload(JSON root) BOOKMARKSINFO curBookmark; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curBookmark.mod, mod); + strcpy_s(curBookmark.mod, mod); else *curBookmark.mod = '\0'; curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index 0f44e137..f673d0f1 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -193,8 +193,8 @@ void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge) bridge->active = bp->active; bridge->addr = bp->addr; bridge->enabled = bp->enabled; - strcpy(bridge->mod, bp->mod); - strcpy(bridge->name, bp->name); + strcpy_s(bridge->mod, bp->mod); + strcpy_s(bridge->name, bp->name); bridge->singleshoot = bp->singleshoot; switch(bp->type) { diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index fe74c41e..ab9c1db8 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -19,7 +19,7 @@ bool commentset(uint addr, const char* text, bool manual) } COMMENTSINFO comment; comment.manual = manual; - strcpy(comment.text, text); + strcpy_s(comment.text, text); modnamefromaddr(addr, comment.mod, true); comment.addr = addr - modbasefromaddr(addr); const uint key = modhashfromva(addr); @@ -37,7 +37,7 @@ bool commentget(uint addr, char* text) const CommentsInfo::iterator found = comments.find(modhashfromva(addr)); if(found == comments.end()) //not found return false; - strcpy(text, found->second.text); + strcpy_s(text, MAX_COMMENT_SIZE, found->second.text); return true; } @@ -114,14 +114,14 @@ void commentcacheload(JSON root) COMMENTSINFO curComment; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curComment.mod, mod); + strcpy_s(curComment.mod, mod); else *curComment.mod = '\0'; curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); curComment.manual = true; const char* text = json_string_value(json_object_get(value, "text")); if(text) - strcpy(curComment.text, text); + strcpy_s(curComment.text, text); else continue; //skip const uint key = modhashfromname(curComment.mod) + curComment.addr; @@ -138,7 +138,7 @@ void commentcacheload(JSON root) COMMENTSINFO curComment; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curComment.mod, mod); + strcpy_s(curComment.mod, mod); else *curComment.mod = '\0'; curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 2abe86b7..0210b5f7 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -434,7 +434,7 @@ static BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode if(strstr(text, " bytes - ")) { Memory newtext(len + 1, "SymRegisterCallbackProc64:newtext"); - strcpy(newtext, text); + strcpy_s(newtext, len + 1, text); strstr(newtext, " bytes - ")[8] = 0; GuiSymbolLogAdd(newtext); suspress = true; @@ -598,7 +598,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) { wchar_t wszFileName[MAX_PATH] = L""; if(!DevicePathFromFileHandleW(CreateProcessInfo->hFile, wszFileName, sizeof(wszFileName))) - strcpy(DebugFileName, "??? (GetFileNameFromHandle failed!)"); + strcpy_s(DebugFileName, "??? (GetFileNameFromHandle failed!)"); else strcpy_s(DebugFileName, MAX_PATH, StringUtils::Utf16ToUtf8(wszFileName).c_str()); } @@ -801,7 +801,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) { wchar_t wszFileName[MAX_PATH] = L""; if(!DevicePathFromFileHandleW(LoadDll->hFile, wszFileName, sizeof(wszFileName))) - strcpy(DLLDebugFileName, "??? (GetFileNameFromHandle failed!)"); + strcpy_s(DLLDebugFileName, "??? (GetFileNameFromHandle failed!)"); else strcpy_s(DLLDebugFileName, MAX_PATH, StringUtils::Utf16ToUtf8(wszFileName).c_str()); } @@ -1126,12 +1126,12 @@ DWORD WINAPI threadDebugLoop(void* lpParameter) //inform GUI we started without problems GuiSetDebugState(initialized); //set GUI title - strcpy(szBaseFileName, szFileName); + strcpy_s(szBaseFileName, szFileName); int len = (int)strlen(szBaseFileName); while(szBaseFileName[len] != '\\' and len) len--; if(len) - strcpy(szBaseFileName, szBaseFileName + len + 1); + strcpy_s(szBaseFileName, szBaseFileName + len + 1); GuiUpdateWindowTitle(szBaseFileName); //call plugin callback PLUG_CB_INITDEBUG initInfo; @@ -1497,35 +1497,35 @@ bool dbgpagerightstostring(DWORD protect, char* rights) switch(protect & 0xFF) { case PAGE_EXECUTE: - strcpy(rights, "E---"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "E---"); break; case PAGE_EXECUTE_READ: - strcpy(rights, "ER--"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "ER--"); break; case PAGE_EXECUTE_READWRITE: - strcpy(rights, "ERW-"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "ERW-"); break; case PAGE_EXECUTE_WRITECOPY: - strcpy(rights, "ERWC"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "ERWC"); break; case PAGE_NOACCESS: - strcpy(rights, "----"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "----"); break; case PAGE_READONLY: - strcpy(rights, "-R--"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "-R--"); break; case PAGE_READWRITE: - strcpy(rights, "-RW-"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "-RW-"); break; case PAGE_WRITECOPY: - strcpy(rights, "-RWC"); + strcpy_s(rights, RIGHTS_STRING_SIZE, "-RWC"); break; } if(protect & PAGE_GUARD) - strcat(rights, "G"); + strcat_s(rights, RIGHTS_STRING_SIZE, "G"); else - strcat(rights, "-"); + strcat_s(rights, RIGHTS_STRING_SIZE, "-"); return true; } @@ -1671,9 +1671,9 @@ bool dbggetdefjit(char* jit_entry) path[0] = '"'; wchar_t wszPath[MAX_PATH] = L""; GetModuleFileNameW(GetModuleHandleW(NULL), wszPath, MAX_PATH); - strcpy(&path[1], StringUtils::Utf16ToUtf8(wszPath).c_str()); + strcpy_s(&path[1], JIT_ENTRY_DEF_SIZE - 1, StringUtils::Utf16ToUtf8(wszPath).c_str()); strcat(path, ATTACH_CMD_LINE); - strcpy(jit_entry, path); + strcpy_s(jit_entry, JIT_ENTRY_DEF_SIZE, path); return true; } diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 21e7d33e..5aa69737 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -79,14 +79,14 @@ CMDRESULT cbDebugInit(int argc, char* argv[]) argget(*argv, arg3, 2, true); static char currentfolder[deflen] = ""; - strcpy(currentfolder, arg1); + strcpy_s(currentfolder, arg1); int len = (int)strlen(currentfolder); while(currentfolder[len] != '\\' and len != 0) len--; currentfolder[len] = 0; if(DirExists(arg3)) - strcpy(currentfolder, arg3); + strcpy_s(currentfolder, arg3); //initialize wait(WAITID_STOP); //wait for the debugger to stop waitclear(); //clear waiting flags NOTE: thread-unsafe @@ -180,7 +180,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] bool has_arg2 = argget(*argv, argtype, 2, true); if(!has_arg2 and (scmp(argname, "ss") or scmp(argname, "long") or scmp(argname, "ud2"))) { - strcpy(argtype, argname); + strcpy_s(argtype, argname); *argname = 0; } _strlwr(argtype); @@ -483,7 +483,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]) else if(*arg2 == '0') restore = false; else - strcpy(arg3, arg2); + strcpy_s(arg3, arg2); } DWORD type = UE_MEMORY; if(*arg3) @@ -1379,7 +1379,7 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) const char* szSymbolStore = szDefaultStore; if(!BridgeSettingGet("Symbols", "DefaultStore", szDefaultStore)) //get default symbol store from settings { - strcpy(szDefaultStore, "http://msdl.microsoft.com/download/symbols"); + strcpy_s(szDefaultStore, "http://msdl.microsoft.com/download/symbols"); BridgeSettingSet("Symbols", "DefaultStore", szDefaultStore); } if(argc < 2) //no arguments @@ -1838,7 +1838,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) int counter = 0; uint LoadLibraryA = 0; char command[50] = ""; - char error[256] = ""; + char error[MAX_ERROR_SIZE] = ""; GetFullContextDataEx(LoadLibThread, &backupctx); diff --git a/x64_dbg_dbg/disasm_fast.cpp b/x64_dbg_dbg/disasm_fast.cpp index 4eaf34ee..c68e5052 100644 --- a/x64_dbg_dbg/disasm_fast.cpp +++ b/x64_dbg_dbg/disasm_fast.cpp @@ -23,7 +23,7 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo) //zero basicinfo memset(basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO)); //copy instruction text - strcpy(basicinfo->instruction, disasm->CompleteInstr); + strcpy_s(basicinfo->instruction, disasm->CompleteInstr); //find immidiat if(disasm->Instruction.BranchType == 0) //no branch { @@ -55,7 +55,7 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo) { basicinfo->type |= TYPE_MEMORY; basicinfo->memory.value = (ULONG_PTR)disasm->Argument1.Memory.Displacement; - strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); + strcpy_s(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); } basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize); } @@ -65,7 +65,7 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo) { basicinfo->type |= TYPE_MEMORY; basicinfo->memory.value = (ULONG_PTR)disasm->Argument2.Memory.Displacement; - strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); + strcpy_s(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); } basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize); } @@ -82,14 +82,14 @@ void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo) { basicinfo->type |= TYPE_MEMORY; basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue; - strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); + strcpy_s(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize); } else if((disasm->Argument2.ArgType & RELATIVE_) == RELATIVE_) { basicinfo->type |= TYPE_MEMORY; basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue; - strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); + strcpy_s(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize); } } diff --git a/x64_dbg_dbg/disasm_helper.cpp b/x64_dbg_dbg/disasm_helper.cpp index 17cc9a20..cdee9c63 100644 --- a/x64_dbg_dbg/disasm_helper.cpp +++ b/x64_dbg_dbg/disasm_helper.cpp @@ -127,9 +127,9 @@ const char* disasmtext(uint addr) int len = Disasm(&disasm); static char instruction[INSTRUCT_LENGTH] = ""; if(len == UNKNOWN_OPCODE) - strcpy(instruction, "???"); + strcpy_s(instruction, "???"); else - strcpy(instruction, disasm.CompleteInstr); + strcpy_s(instruction, disasm.CompleteInstr); return instruction; } @@ -166,7 +166,7 @@ static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG if(!*argmnemonic) return false; arg->memvalue = 0; - strcpy(arg->mnemonic, argmnemonic); + strcpy_s(arg->mnemonic, argmnemonic); if((argtype & MEMORY_TYPE) == MEMORY_TYPE) { arg->type = arg_memory; @@ -233,7 +233,7 @@ void disasmget(unsigned char* buffer, uint addr, DISASM_INSTR* instr) disasm.VirtualAddr = addr; disasm.EIP = (UIntPtr)buffer; int len = Disasm(&disasm); - strcpy(instr->instruction, disasm.CompleteInstr); + strcpy_s(instr->instruction, disasm.CompleteInstr); if(len == UNKNOWN_OPCODE) { instr->instr_size = 1; diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp index b68ece65..cc5406d6 100644 --- a/x64_dbg_dbg/function.cpp +++ b/x64_dbg_dbg/function.cpp @@ -126,7 +126,7 @@ void functioncacheload(JSON root) FUNCTIONSINFO curFunction; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curFunction.mod, mod); + strcpy_s(curFunction.mod, mod); else *curFunction.mod = '\0'; curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); @@ -148,7 +148,7 @@ void functioncacheload(JSON root) FUNCTIONSINFO curFunction; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curFunction.mod, mod); + strcpy_s(curFunction.mod, mod); else *curFunction.mod = '\0'; curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index 1c683925..6d34de84 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -240,7 +240,7 @@ CMDRESULT cbInstrVarList(int argc, char* argv[]) if(variables[i].alias.length()) continue; char name[deflen] = ""; - strcpy(name, variables[i].name.c_str()); + strcpy_s(name, variables[i].name.c_str()); uint value = (uint)variables[i].value.u.value; if(variables[i].type != VAR_HIDDEN) { @@ -429,7 +429,7 @@ CMDRESULT cbAssemble(int argc, char* argv[]) bool fillnop = false; if(argc > 3) fillnop = true; - char error[256] = ""; + char error[MAX_ERROR_SIZE] = ""; int size = 0; if(!assembleat(addr, argv[2], &size, error, fillnop)) { @@ -1076,9 +1076,9 @@ CMDRESULT cbInstrFind(int argc, char* argv[]) char pattern[deflen] = ""; //remove # from the start and end of the pattern (ODBGScript support) if(argv[2][0] == '#') - strcpy(pattern, argv[2] + 1); + strcpy_s(pattern, argv[2] + 1); else - strcpy(pattern, argv[2]); + strcpy_s(pattern, argv[2]); int len = (int)strlen(pattern); if(pattern[len - 1] == '#') pattern[len - 1] = '\0'; @@ -1128,9 +1128,9 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[]) char pattern[deflen] = ""; //remove # from the start and end of the pattern (ODBGScript support) if(argv[2][0] == '#') - strcpy(pattern, argv[2] + 1); + strcpy_s(pattern, argv[2] + 1); else - strcpy(pattern, argv[2]); + strcpy_s(pattern, argv[2]); int len = (int)strlen(pattern); if(pattern[len - 1] == '#') pattern[len - 1] = '\0'; @@ -1513,7 +1513,7 @@ CMDRESULT cbInstrFindAsm(int argc, char* argv[]) unsigned char dest[16]; int asmsize = 0; - char error[256] = ""; + char error[MAX_ERROR_SIZE] = ""; if(!assemble(addr + size / 2, dest, &asmsize, argv[1], error)) { dprintf("failed to assemble \"%s\" (%s)!\n", argv[1], error); diff --git a/x64_dbg_dbg/label.cpp b/x64_dbg_dbg/label.cpp index 3e05b1d8..9421ef7f 100644 --- a/x64_dbg_dbg/label.cpp +++ b/x64_dbg_dbg/label.cpp @@ -19,7 +19,7 @@ bool labelset(uint addr, const char* text, bool manual) } LABELSINFO label; label.manual = manual; - strcpy(label.text, text); + strcpy_s(label.text, text); modnamefromaddr(addr, label.mod, true); label.addr = addr - modbasefromaddr(addr); uint key = modhashfromva(addr); @@ -55,7 +55,7 @@ bool labelget(uint addr, char* text) if(found == labels.end()) //not found return false; if(text) - strcpy(text, found->second.text); + strcpy_s(text, MAX_LABEL_SIZE, found->second.text); return true; } @@ -132,14 +132,14 @@ void labelcacheload(JSON root) LABELSINFO curLabel; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLabel.mod, mod); + strcpy_s(curLabel.mod, mod); else *curLabel.mod = '\0'; curLabel.addr = (uint)json_hex_value(json_object_get(value, "address")); curLabel.manual = true; const char* text = json_string_value(json_object_get(value, "text")); if(text) - strcpy(curLabel.text, text); + strcpy_s(curLabel.text, text); else continue; //skip int len = (int)strlen(curLabel.text); @@ -160,7 +160,7 @@ void labelcacheload(JSON root) LABELSINFO curLabel; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLabel.mod, mod); + strcpy_s(curLabel.mod, mod); else *curLabel.mod = '\0'; curLabel.addr = (uint)json_hex_value(json_object_get(value, "address")); diff --git a/x64_dbg_dbg/loop.cpp b/x64_dbg_dbg/loop.cpp index 94979a61..a390513d 100644 --- a/x64_dbg_dbg/loop.cpp +++ b/x64_dbg_dbg/loop.cpp @@ -135,7 +135,7 @@ void loopcacheload(JSON root) LOOPSINFO curLoop; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLoop.mod, mod); + strcpy_s(curLoop.mod, mod); else *curLoop.mod = '\0'; curLoop.start = (uint)json_hex_value(json_object_get(value, "start")); @@ -158,7 +158,7 @@ void loopcacheload(JSON root) LOOPSINFO curLoop; const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy(curLoop.mod, mod); + strcpy_s(curLoop.mod, mod); else *curLoop.mod = '\0'; curLoop.start = (uint)json_hex_value(json_object_get(value, "start")); diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 87142f80..3d4c91cf 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -18,7 +18,7 @@ bool modload(uint base, uint size, const char* fullpath) len--; if(len) len++; - strcpy(name, fullpath + len); + strcpy_s(name, fullpath + len); _strlwr(name); len = (int)strlen(name); name[MAX_MODULE_SIZE - 1] = 0; //ignore later characters @@ -30,12 +30,12 @@ bool modload(uint base, uint size, const char* fullpath) info.hash = modhashfromname(name); if(len) { - strcpy(info.extension, name + len); + strcpy_s(info.extension, name + len); name[len] = 0; //remove extension } info.base = base; info.size = size; - strcpy(info.name, name); + strcpy_s(info.name, name); //process module sections HANDLE FileHandle; diff --git a/x64_dbg_dbg/patches.cpp b/x64_dbg_dbg/patches.cpp index 8b8461b6..c567aec7 100644 --- a/x64_dbg_dbg/patches.cpp +++ b/x64_dbg_dbg/patches.cpp @@ -141,11 +141,11 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha if(!count) { if(error) - strcpy(error, "no patches to apply"); + strcpy_s(error, MAX_ERROR_SIZE, "no patches to apply"); return -1; } char modname[MAX_MODULE_SIZE] = ""; - strcpy(modname, patchlist[0].mod); + strcpy_s(modname, patchlist[0].mod); //check if all patches are in the same module for(int i = 0; i < count; i++) if(_stricmp(patchlist[i].mod, modname)) @@ -171,7 +171,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha if(!CopyFileW(szOriginalName, StringUtils::Utf8ToUtf16(szFileName).c_str(), false)) { if(error) - strcpy(error, "failed to make a copy of the original file (patch target is in use?)"); + strcpy_s(error, MAX_ERROR_SIZE, "failed to make a copy of the original file (patch target is in use?)"); return -1; } HANDLE FileHandle; @@ -193,11 +193,11 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha if(!StaticFileUnloadW(StringUtils::Utf8ToUtf16(szFileName).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA)) { if(error) - strcpy(error, "StaticFileUnload failed"); + strcpy_s(error, MAX_ERROR_SIZE, "StaticFileUnload failed"); return -1; } return patched; } - strcpy(error, "StaticFileLoad failed"); + strcpy_s(error, MAX_ERROR_SIZE, "StaticFileLoad failed"); return -1; } diff --git a/x64_dbg_dbg/plugin_loader.cpp b/x64_dbg_dbg/plugin_loader.cpp index 03ca8449..1e8fc555 100644 --- a/x64_dbg_dbg/plugin_loader.cpp +++ b/x64_dbg_dbg/plugin_loader.cpp @@ -315,7 +315,7 @@ bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cb return false; PLUG_COMMAND plugCmd; plugCmd.pluginHandle = pluginHandle; - strcpy(plugCmd.command, command); + strcpy_s(plugCmd.command, command); if(!dbgcmdnew(command, (CBCOMMAND)cbCommand, debugonly)) return false; pluginCommandList.push_back(plugCmd); diff --git a/x64_dbg_dbg/simplescript.cpp b/x64_dbg_dbg/simplescript.cpp index b28837b1..0617a51d 100644 --- a/x64_dbg_dbg/simplescript.cpp +++ b/x64_dbg_dbg/simplescript.cpp @@ -98,7 +98,7 @@ static bool scriptcreatelinemap(const char* filename) int add = 0; while(temp[add] == ' ') add++; - strcpy(entry.raw, temp + add); + strcpy_s(entry.raw, temp + add); *temp = 0; j = 0; i++; @@ -110,7 +110,7 @@ static bool scriptcreatelinemap(const char* filename) int add = 0; while(temp[add] == ' ') add++; - strcpy(entry.raw, temp + add); + strcpy_s(entry.raw, temp + add); *temp = 0; j = 0; linemap.push_back(entry); @@ -121,7 +121,7 @@ static bool scriptcreatelinemap(const char* filename) int add = 0; while(temp[add] == ' ') add++; - strcpy(entry.raw, temp + add); + strcpy_s(entry.raw, temp + add); *temp = 0; j = 0; linemap.push_back(entry); @@ -132,7 +132,7 @@ static bool scriptcreatelinemap(const char* filename) if(*temp) { memset(&entry, 0, sizeof(entry)); - strcpy(entry.raw, temp); + strcpy_s(entry.raw, temp); linemap.push_back(entry); } unsigned int linemapsize = (unsigned int)linemap.size(); @@ -152,7 +152,7 @@ static bool scriptcreatelinemap(const char* filename) { if(*(comment - 1) == ' ') //space before comment { - strcpy(line_comment, comment); + strcpy_s(line_comment, comment); *(comment - 1) = '\0'; } else //no space before comment @@ -170,7 +170,7 @@ static bool scriptcreatelinemap(const char* filename) else if(!strncmp(cur.raw, "//", 2)) //comment { cur.type = linecomment; - strcpy(cur.u.comment, cur.raw); + strcpy_s(cur.u.comment, cur.raw); } else if(cur.raw[rawlen - 1] == ':') //label { @@ -203,20 +203,20 @@ static bool scriptcreatelinemap(const char* filename) cur.type = linebranch; cur.u.branch.type = scriptgetbranchtype(cur.raw); char newraw[MAX_SCRIPT_LINE_SIZE] = ""; - strcpy(newraw, cur.raw); + strcpy_s(newraw, cur.raw); argformat(newraw); int len = (int)strlen(newraw); for(int i = 0; i < len; i++) if(newraw[i] == ' ') { - strcpy(cur.u.branch.branchlabel, newraw + i + 1); + strcpy_s(cur.u.branch.branchlabel, newraw + i + 1); break; } } else { cur.type = linecommand; - strcpy(cur.u.command, cur.raw); + strcpy_s(cur.u.command, cur.raw); } //append the comment to the raw line again @@ -246,8 +246,8 @@ static bool scriptcreatelinemap(const char* filename) { memset(&entry, 0, sizeof(entry)); entry.type = linecommand; - strcpy(entry.raw, "ret"); - strcpy(entry.u.command, "ret"); + strcpy_s(entry.raw, "ret"); + strcpy_s(entry.u.command, "ret"); linemap.push_back(entry); } return true; diff --git a/x64_dbg_dbg/stackinfo.cpp b/x64_dbg_dbg/stackinfo.cpp index db964289..89ebb514 100644 --- a/x64_dbg_dbg/stackinfo.cpp +++ b/x64_dbg_dbg/stackinfo.cpp @@ -42,7 +42,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) ADDRINFO addrinfo; addrinfo.flags = flaglabel; if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) - strcpy(label, addrinfo.label); + strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; modnamefromaddr(data, module, false); char returnToAddr[MAX_COMMENT_SIZE] = ""; @@ -58,7 +58,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) *label = 0; addrinfo.flags = flaglabel; if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) - strcpy(label, addrinfo.label); + strcpy_s(label, addrinfo.label); *module = 0; modnamefromaddr(data, module, false); char returnFromAddr[MAX_COMMENT_SIZE] = ""; @@ -71,7 +71,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) } else sprintf_s(comment->comment, "return to %s from ???", returnToAddr); - strcpy(comment->color, "#ff0000"); + strcpy_s(comment->color, "#ff0000"); return true; } @@ -92,7 +92,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) ADDRINFO addrinfo; addrinfo.flags = flaglabel; if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) - strcpy(label, addrinfo.label); + strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; modnamefromaddr(data, module, false); char addrInfo[MAX_COMMENT_SIZE] = ""; @@ -151,7 +151,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) ADDRINFO addrinfo; addrinfo.flags = flaglabel; if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) - strcpy(label, addrinfo.label); + strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; modnamefromaddr(data, module, false); char returnToAddr[MAX_COMMENT_SIZE] = ""; @@ -174,7 +174,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) *label = 0; addrinfo.flags = flaglabel; if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) - strcpy(label, addrinfo.label); + strcpy_s(label, addrinfo.label); *module = 0; modnamefromaddr(data, module, false); char returnFromAddr[MAX_COMMENT_SIZE] = ""; diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index a7a8bcf3..37162335 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -18,7 +18,7 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID memset(&curSymbol, 0, sizeof(SYMBOLINFO)); curSymbol.addr = (duint)pSymInfo->Address; curSymbol.decoratedSymbol = (char*)BridgeAlloc(len + 1); - strcpy(curSymbol.decoratedSymbol, pSymInfo->Name); + strcpy_s(curSymbol.decoratedSymbol, len + 1, pSymInfo->Name); curSymbol.undecoratedSymbol = (char*)BridgeAlloc(MAX_SYM_NAME); if(strstr(pSymInfo->Name, "Ordinal")) { diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index b1310657..e7063cc0 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -18,7 +18,7 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread) curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase; *curInfo.threadName = '\0'; if(!threadNum) - strcpy(curInfo.threadName, "Main Thread"); + strcpy_s(curInfo.threadName, "Main Thread"); CriticalSectionLocker locker(LockThreads); threadList.push_back(curInfo); threadNum++; diff --git a/x64_dbg_dbg/value.cpp b/x64_dbg_dbg/value.cpp index c3f09af6..055a8e41 100644 --- a/x64_dbg_dbg/value.cpp +++ b/x64_dbg_dbg/value.cpp @@ -1409,9 +1409,9 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, } } else - strcpy(newstring, string); + strcpy_s(newstring, len * 2, string); Memory string_(len + 256, "valfromstring:string_"); - strcpy(string_, newstring); + strcpy_s(string_, len + 256, newstring); int add = 0; bool negative = (*string_ == '-'); while(mathisoperator(string_[add + negative]) > 2) @@ -1463,7 +1463,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, } } else - strcpy(newstring, string); + strcpy_s(newstring, len * 2, string); int read_size = sizeof(uint); int add = 1; if(newstring[2] == ':' and isdigit((newstring[1]))) //@n: (number of bytes to read) @@ -2010,7 +2010,7 @@ bool valtostring(const char* string, uint* value, bool silent) } } else - strcpy(newstring, string); + strcpy_s(newstring, len * 2, string); int read_size = sizeof(uint); int add = 1; if(newstring[2] == ':' and isdigit((newstring[1]))) @@ -2044,8 +2044,9 @@ bool valtostring(const char* string, uint* value, bool silent) return false; } bool ok = setregister(string, *value); - Memory regName(strlen(string) + 1, "valtostring:regname"); - strcpy(regName, string); + int len = (int)strlen(string); + Memory regName(len + 1, "valtostring:regname"); + strcpy_s(regName, len + 1, string); _strlwr(regName); if(strstr(regName, "ip")) DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), false); //update disassembly + register view diff --git a/x64_dbg_dbg/x64_dbg.cpp b/x64_dbg_dbg/x64_dbg.cpp index 8963663b..ff2b7dba 100644 --- a/x64_dbg_dbg/x64_dbg.cpp +++ b/x64_dbg_dbg/x64_dbg.cpp @@ -201,7 +201,7 @@ static bool cbCommandProvider(char* cmd, int maxlen) dprintf("command cut at ~%d characters\n", deflen); newcmd[deflen - 2] = 0; } - strcpy(cmd, newcmd); + strcpy_s(cmd, deflen, newcmd); efree(newcmd, "cbCommandProvider:newcmd"); //free allocated command return true; } @@ -210,7 +210,7 @@ extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd) { int len = (int)strlen(cmd); char* newcmd = (char*)emalloc((len + 1) * sizeof(char), "_dbg_dbgcmdexec:newcmd"); - strcpy(newcmd, cmd); + strcpy_s(newcmd, len + 1, cmd); return msgsend(gMsgStack, 0, (uint)newcmd, 0); } @@ -248,14 +248,14 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit() while(dir[len] != '\\') len--; dir[len] = 0; - strcpy(alloctrace, dir); + strcpy_s(alloctrace, dir); PathAppendA(alloctrace, "\\alloctrace.txt"); DeleteFileW(StringUtils::Utf8ToUtf16(alloctrace).c_str()); setalloctrace(alloctrace); - strcpy(dbbasepath, dir); //debug directory + strcpy_s(dbbasepath, dir); //debug directory PathAppendA(dbbasepath, "db"); CreateDirectoryW(StringUtils::Utf8ToUtf16(dbbasepath).c_str(), 0); //create database directory - strcpy(szSymbolCachePath, dir); + strcpy_s(szSymbolCachePath, dir); PathAppendA(szSymbolCachePath, "symbols"); SetCurrentDirectoryW(StringUtils::Utf8ToUtf16(dir).c_str());; gMsgStack = msgallocstack(); @@ -265,7 +265,7 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit() registercommands(); hCommandLoopThread = CreateThread(0, 0, DbgCommandLoopThread, 0, 0, 0); char plugindir[deflen] = ""; - strcpy(plugindir, dir); + strcpy_s(plugindir, dir); PathAppendA(plugindir, "plugins"); CreateDirectoryW(StringUtils::Utf8ToUtf16(plugindir).c_str(), 0); pluginload(plugindir); diff --git a/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp b/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp index 5900859b..7d033177 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp @@ -181,7 +181,7 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA) else info = QString(mod) + " | "; } - char section[10] = ""; + char section[MAX_SECTION_SIZE] = ""; if(DbgFunctions()->SectionFromAddr(parVA, section)) info += "\"" + QString(section) + "\":"; info += QString("%1").arg(parVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); From 59038b5e942047d3cc812294f9d974847acdc034 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Mon, 2 Feb 2015 01:05:11 +0100 Subject: [PATCH 031/106] DBG: added separate file for pattern finding --- x64_dbg_dbg/instruction.cpp | 5 +- x64_dbg_dbg/memory.cpp | 102 +------------- x64_dbg_dbg/memory.h | 12 -- x64_dbg_dbg/patternfind.cpp | 169 ++++++++++++++++++++++++ x64_dbg_dbg/patternfind.h | 35 +++++ x64_dbg_dbg/x64_dbg_dbg.vcxproj | 2 + x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters | 6 + 7 files changed, 216 insertions(+), 115 deletions(-) create mode 100644 x64_dbg_dbg/patternfind.cpp create mode 100644 x64_dbg_dbg/patternfind.h diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index 6d34de84..f9cba729 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -17,6 +17,7 @@ #include "bookmark.h" #include "function.h" #include "loop.h" +#include "patternfind.h" static bool bRefinit = false; @@ -1106,7 +1107,7 @@ CMDRESULT cbInstrFind(int argc, char* argv[]) } else find_size = size - start; - uint foundoffset = memfindpattern(data + start, find_size, pattern); + uint foundoffset = patternfind(data + start, find_size, pattern); uint result = 0; if(foundoffset != -1) result = addr + foundoffset; @@ -1179,7 +1180,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[]) while(refCount < 5000) { int patternsize = 0; - uint foundoffset = memfindpattern(data + start + i, find_size - i, pattern, &patternsize); + uint foundoffset = patternfind(data + start + i, find_size - i, pattern, &patternsize); if(foundoffset == -1) break; i += foundoffset + 1; diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 15b60bb5..03074db3 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -221,104 +221,4 @@ void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect) void memfree(HANDLE hProcess, uint addr) { VirtualFreeEx(hProcess, (void*)addr, 0, MEM_RELEASE); -} - -static int formathexpattern(char* string) -{ - int len = (int)strlen(string); - _strupr(string); - Memory new_string(len + 1, "formathexpattern:new_string"); - memset(new_string, 0, len + 1); - for(int i = 0, j = 0; i < len; i++) - if(string[i] == '?' or isxdigit(string[i])) - j += sprintf(new_string + j, "%c", string[i]); - strcpy(string, new_string); - return (int)strlen(string); -} - -static bool patterntransform(const char* text, std::vector* pattern) -{ - if(!text or !pattern) - return false; - pattern->clear(); - int len = (int)strlen(text); - if(!len) - return false; - Memory newtext(len + 2, "transformpattern:newtext"); - strcpy(newtext, text); - len = formathexpattern(newtext); - if(len % 2) //not a multiple of 2 - { - newtext[len] = '?'; - newtext[len + 1] = '\0'; - len++; - } - PATTERNBYTE newByte; - for(int i = 0, j = 0; i < len; i++) - { - if(newtext[i] == '?') //wildcard - { - newByte.n[j].all = true; //match anything - newByte.n[j].n = 0; - j++; - } - else //hex - { - char x[2] = ""; - *x = newtext[i]; - unsigned int val = 0; - sscanf(x, "%x", &val); - newByte.n[j].all = false; - newByte.n[j].n = val & 0xF; - j++; - } - - if(j == 2) //two nibbles = one byte - { - j = 0; - pattern->push_back(newByte); - } - } - return true; -} - -static bool patternmatchbyte(unsigned char byte, PATTERNBYTE* pbyte) -{ - unsigned char n1 = (byte >> 4) & 0xF; - unsigned char n2 = byte & 0xF; - int matched = 0; - if(pbyte->n[0].all) - matched++; - else if(pbyte->n[0].n == n1) - matched++; - if(pbyte->n[1].all) - matched++; - else if(pbyte->n[1].n == n2) - matched++; - return (matched == 2); -} - -uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* patternsize) -{ - std::vector searchpattern; - if(!patterntransform(pattern, &searchpattern)) - return -1; - int searchpatternsize = (int)searchpattern.size(); - if(patternsize) - *patternsize = searchpatternsize; - for(uint i = 0, pos = 0; i < size; i++) //search for the pattern - { - if(patternmatchbyte(data[i], &searchpattern.at(pos))) //check if our pattern matches the current byte - { - pos++; - if(pos == searchpatternsize) //everything matched - return i - searchpatternsize + 1; - } - else if(pos > 0) //fix by Computer_Angel - { - i -= pos; // return to previous byte - pos = 0; //reset current pattern position - } - } - return -1; -} +} \ No newline at end of file diff --git a/x64_dbg_dbg/memory.h b/x64_dbg_dbg/memory.h index 4f6c8276..c17c6f18 100644 --- a/x64_dbg_dbg/memory.h +++ b/x64_dbg_dbg/memory.h @@ -9,17 +9,6 @@ typedef std::map MemoryMap; extern MemoryMap memoryPages; extern bool bListAllPages; -struct PATTERNNIBBLE -{ - unsigned char n; - bool all; -}; - -struct PATTERNBYTE -{ - PATTERNNIBBLE n[2]; -}; - void memupdatemap(HANDLE hProcess); uint memfindbaseaddr(uint addr, uint* size, bool refresh = false); bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead); @@ -28,6 +17,5 @@ bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T bool memisvalidreadptr(HANDLE hProcess, uint addr); void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect); void memfree(HANDLE hProcess, uint addr); -uint memfindpattern(unsigned char* data, uint size, const char* pattern, int* patternsize = 0); #endif // _MEMORY_H diff --git a/x64_dbg_dbg/patternfind.cpp b/x64_dbg_dbg/patternfind.cpp new file mode 100644 index 00000000..069451bd --- /dev/null +++ b/x64_dbg_dbg/patternfind.cpp @@ -0,0 +1,169 @@ +#include "patternfind.h" +#include +#include + +using namespace std; + +struct PatternByte +{ + struct PatternNibble + { + unsigned char data; + bool wildcard; + } nibble[2]; +}; + +static string formathexpattern(string patterntext) +{ + string result; + int len = patterntext.length(); + for(int i = 0; i < len; i++) + if(patterntext[i] == '?' || isxdigit(patterntext[i])) + result += toupper(patterntext[i]); + return result; +} + +static int hexchtoint(char ch) +{ + if(ch >= '0' && ch <= '9') + return ch - '0'; + else if(ch >= 'A' && ch <= 'F') + return ch - 'A' + 10; + else if(ch >= 'a' && ch <= 'f') + return ch - 'a' + 10; + return 0; +} + +static bool patterntransform(string patterntext, vector & pattern) +{ + pattern.clear(); + patterntext = formathexpattern(patterntext); + int len = patterntext.length(); + if(!len) + return false; + + if(len % 2) //not a multiple of 2 + { + patterntext += '?'; + len++; + } + + PatternByte newByte; + for(int i = 0, j = 0; i < len; i++) + { + if(patterntext[i] == '?') //wildcard + { + newByte.nibble[j].wildcard = true; //match anything + } + else //hex + { + newByte.nibble[j].wildcard = false; + newByte.nibble[j].data = hexchtoint(patterntext[i]) & 0xF; + } + + j++; + if(j == 2) //two nibbles = one byte + { + j = 0; + pattern.push_back(newByte); + } + } + return true; +} + +static bool patternmatchbyte(unsigned char byte, const PatternByte & pbyte) +{ + int matched = 0; + + unsigned char n1 = (byte >> 4) & 0xF; + if(pbyte.nibble[0].wildcard) + matched++; + else if(pbyte.nibble[0].data == n1) + matched++; + + unsigned char n2 = byte & 0xF; + if(pbyte.nibble[1].wildcard) + matched++; + else if(pbyte.nibble[1].data == n2) + matched++; + + return (matched == 2); +} + +size_t patternfind(unsigned char* data, size_t datasize, const char* pattern, int* patternsize) +{ + vector searchpattern; + if(!patterntransform(pattern, searchpattern)) + return -1; + size_t searchpatternsize = searchpattern.size(); + if(patternsize) + *patternsize = (int)searchpatternsize; + for(size_t i = 0, pos = 0; i < datasize; i++) //search for the pattern + { + if(patternmatchbyte(data[i], searchpattern.at(pos))) //check if our pattern matches the current byte + { + pos++; + if(pos == searchpatternsize) //everything matched + return i - searchpatternsize + 1; + } + else if(pos > 0) //fix by Computer_Angel + { + i -= pos; + pos = 0; //reset current pattern position + } + } + return -1; +} + +size_t patternfind(unsigned char* data, size_t datasize, unsigned char* pattern, size_t patternsize) +{ + if(patternsize > datasize) + patternsize = datasize; + for(size_t i = 0, pos = 0; i < datasize; i++) + { + if(data[i] == pattern[pos]) + { + pos++; + if(pos == patternsize) + return i - patternsize + 1; + } + else if(pos > 0) + { + i -= pos; + pos = 0; //reset current pattern position + } + } + return -1; +} + +static void patternwritebyte(unsigned char* byte, const PatternByte & pbyte) +{ + unsigned char n1 = (*byte >> 4) & 0xF; + unsigned char n2 = *byte & 0xF; + if(!pbyte.nibble[0].wildcard) + n1 = pbyte.nibble[0].data; + if(!pbyte.nibble[1].wildcard) + n2 = pbyte.nibble[1].data; + *byte = ((n1 << 4) & 0xF0) | (n2 & 0xF); +} + +void patternwrite(unsigned char* data, size_t datasize, const char* pattern) +{ + vector writepattern; + if(!patterntransform(pattern, writepattern)) + return; + size_t writepatternsize = writepattern.size(); + if(writepatternsize > datasize) + writepatternsize = datasize; + for(size_t i = 0; i < writepatternsize; i++) + patternwritebyte(&data[i], writepattern.at(i)); +} + +bool patternsnr(unsigned char* data, size_t datasize, const char* searchpattern, const char* replacepattern) +{ + size_t found = patternfind(data, datasize, searchpattern); + if(found == -1) + return false; + patternwrite(data + found, datasize - found, replacepattern); + return true; +} diff --git a/x64_dbg_dbg/patternfind.h b/x64_dbg_dbg/patternfind.h new file mode 100644 index 00000000..ce1102a2 --- /dev/null +++ b/x64_dbg_dbg/patternfind.h @@ -0,0 +1,35 @@ +#ifndef _PATTERNFIND_H +#define _PATTERNFIND_H + +//returns: offset to data when found, -1 when not found +size_t patternfind( + unsigned char* data, //data + size_t datasize, //size of data + const char* pattern, //pattern to search + int* patternsize = 0 //outputs the number of bytes the pattern is +); + +//returns: offset to data when found, -1 when not found +size_t patternfind( + unsigned char* data, //data + size_t datasize, //size of data + unsigned char* pattern, //bytes to search + size_t patternsize //size of bytes to search +); + +//returns: nothing +void patternwrite( + unsigned char* data, //data + size_t datasize, //size of data + const char* pattern //pattern to write +); + +//returns: true on success, false on failure +bool patternsnr( + unsigned char* data, //data + size_t datasize, //size of data + const char* searchpattern, //pattern to search + const char* replacepattern //pattern to write +); + +#endif // _PATTERNFIND_H diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index b8f5a547..0f88f150 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -37,6 +37,7 @@ + @@ -92,6 +93,7 @@ + diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 357085da..2538b0a5 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -192,6 +192,9 @@ Source Files\Information + + Source Files\Utilities + @@ -365,5 +368,8 @@ Header Files\Information + + Header Files\Utilities + \ No newline at end of file From 9d78dfbbd6cd968f6c16b1ffdbb45e6bba11b2f2 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Wed, 4 Feb 2015 00:02:34 +0100 Subject: [PATCH 032/106] GUI: close all tabs button in reference view + fixed annoying next line selection in references --- .../Project/Src/BasicView/ReferenceView.cpp | 1 - x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp | 15 ++++++--------- x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp | 13 +++++++++++++ x64_dbg_gui/Project/Src/Gui/ReferenceManager.h | 3 +++ x64_dbg_gui/Project/images/close-all-tabs.png | Bin 0 -> 544 bytes x64_dbg_gui/Project/resource.qrc | 1 + 6 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 x64_dbg_gui/Project/images/close-all-tabs.png diff --git a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp index 14906172..b9d335cf 100644 --- a/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/ReferenceView.cpp @@ -201,7 +201,6 @@ void ReferenceView::toggleBreakpoint() } DbgCmdExec(wCmd.toUtf8().constData()); - this->mSearchList->selectNext(); } void ReferenceView::toggleBookmark() diff --git a/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp b/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp index 74266e41..a6106ed1 100644 --- a/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp @@ -59,10 +59,13 @@ BreakpointsView::BreakpointsView(QWidget* parent) : QWidget(parent) connect(Bridge::getBridge(), SIGNAL(updateBreakpoints()), this, SLOT(reloadData())); connect(mHardBPTable, SIGNAL(contextMenuSignal(const QPoint &)), this, SLOT(hardwareBPContextMenuSlot(const QPoint &))); connect(mHardBPTable, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickHardwareSlot())); + connect(mHardBPTable, SIGNAL(enterPressedSignal()), this, SLOT(doubleClickHardwareSlot())); connect(mSoftBPTable, SIGNAL(contextMenuSignal(const QPoint &)), this, SLOT(softwareBPContextMenuSlot(const QPoint &))); connect(mSoftBPTable, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickSoftwareSlot())); + connect(mSoftBPTable, SIGNAL(enterPressedSignal()), this, SLOT(doubleClickSoftwareSlot())); connect(mMemBPTable, SIGNAL(contextMenuSignal(const QPoint &)), this, SLOT(memoryBPContextMenuSlot(const QPoint &))); connect(mMemBPTable, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickMemorySlot())); + connect(mMemBPTable, SIGNAL(enterPressedSignal()), this, SLOT(doubleClickMemorySlot())); } @@ -292,9 +295,7 @@ void BreakpointsView::enableDisableHardBPActionSlot() { 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); + table->selectNext(); } void BreakpointsView::doubleClickHardwareSlot() @@ -402,9 +403,7 @@ void BreakpointsView::enableDisableSoftBPActionSlot() { 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); + table->selectNext(); } void BreakpointsView::doubleClickSoftwareSlot() @@ -512,9 +511,7 @@ void BreakpointsView::enableDisableMemBPActionSlot() { 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); + table->selectNext(); } void BreakpointsView::doubleClickMemorySlot() diff --git a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp index cf3be367..afdc1f20 100644 --- a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.cpp @@ -6,6 +6,14 @@ ReferenceManager::ReferenceManager(QWidget* parent) : QTabWidget(parent) setMovable(true); setTabsClosable(true); mCurrentReferenceView = 0; + + //Close All Tabs + mCloseAllTabs = new QPushButton(this); + mCloseAllTabs->setIcon(QIcon(":/icons/images/close-all-tabs.png")); + mCloseAllTabs->setToolTip("Close All Tabs"); + connect(mCloseAllTabs, SIGNAL(clicked()), this, SLOT(closeAllTabs())); + setCornerWidget(mCloseAllTabs, Qt::TopLeftCorner); + connect(Bridge::getBridge(), SIGNAL(referenceInitialize(QString)), this, SLOT(newReferenceView(QString))); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); } @@ -30,3 +38,8 @@ void ReferenceManager::closeTab(int index) { removeTab(index); } + +void ReferenceManager::closeAllTabs() +{ + clear(); +} diff --git a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h index 5a54b6ce..3cf87575 100644 --- a/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h +++ b/x64_dbg_gui/Project/Src/Gui/ReferenceManager.h @@ -2,6 +2,7 @@ #define REFERENCEMANAGER_H #include +#include #include "ReferenceView.h" class ReferenceManager : public QTabWidget @@ -14,12 +15,14 @@ public: private slots: void newReferenceView(QString name); void closeTab(int index); + void closeAllTabs(); signals: void showCpu(); private: ReferenceView* mCurrentReferenceView; + QPushButton* mCloseAllTabs; }; #endif // REFERENCEMANAGER_H diff --git a/x64_dbg_gui/Project/images/close-all-tabs.png b/x64_dbg_gui/Project/images/close-all-tabs.png new file mode 100644 index 0000000000000000000000000000000000000000..6b9fa6dd36ee8165272a13dd263f573507c78ca6 GIT binary patch literal 544 zcmV+*0^j|KP)L-ku(! z6_?D-?!0+#=VtbVZQGdTnZt~apI_HPK#=zVadHM((E`e*C+RoFb)Qo8-U{Lb7{`Tz zw4B8FZ|o?Wox+p=1wp47C;7ar*Xu~;a?<=sjPv>+otDjJ6FaGt!YnNyxQQhp)G1V! zk;r6ZtyV)c8pTbiRAnHRNXTxti%=+p$4aG2*+mMM&xrdiU^`VPk^N*+HX98^7!HT% zwA%;A{T)GxeQ|RcxyzV%! z$AbYD+)i1R64zB?q}NmTz}5|04~J#YG_goA*Eq(QJvp7pG14hUj1pZ^t>3S*xqHUO ze~r;}zTY_XkZ*}d@gm!;N90h8nBQenBUZ_ukZKNicn*hc_Pmc!Jn|2=s<~}>!Sb>Qm3!QP46b_JFw5YU70Tu$X}=T}ez@@t%j iG9vD)nDux55?}x$+|UyQVK_bj0000images/changeargs.png images/arrow-skip.png images/topmost.png + images/close-all-tabs.png From dd82db43cca3840405c73ae2359b3f4e3b171509 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Wed, 4 Feb 2015 00:27:49 +0100 Subject: [PATCH 033/106] DBG: fixed a small bug with the memory map on process start --- x64_dbg_dbg/debugger.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 0210b5f7..0bde1dad 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -604,6 +604,9 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) } dprintf("Process Started: "fhex" %s\n", base, DebugFileName); + memupdatemap(fdProcessInfo->hProcess); + GuiDumpAt(memfindbaseaddr(GetContextData(UE_CIP), 0)+PAGE_SIZE); //dump somewhere + //init program database int len = (int)strlen(szFileName); while(szFileName[len] != '\\' && len != 0) From e46c3d879d13cc6bbb21991ac587e436d904ccba Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Wed, 4 Feb 2015 02:02:42 +0100 Subject: [PATCH 034/106] GUI: report bug option + small GUI changes --- x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 17 ++++++++++++++++- x64_dbg_gui/Project/Src/Gui/MainWindow.h | 1 + x64_dbg_gui/Project/Src/Gui/MainWindow.ui | 18 +++++++++++++++++- .../Project/Src/Utils/Configuration.cpp | 1 + x64_dbg_gui/Project/images/bug-report.png | Bin 0 -> 773 bytes x64_dbg_gui/Project/resource.qrc | 1 + 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 x64_dbg_gui/Project/images/bug-report.png diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 816336ec..10284053 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -186,6 +186,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi connect(ui->actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdates())); connect(ui->actionCallStack, SIGNAL(triggered()), this, SLOT(displayCallstack())); connect(ui->actionDonate, SIGNAL(triggered()), this, SLOT(donate())); + connect(ui->actionReportBug, SIGNAL(triggered()), this, SLOT(reportBug())); connect(ui->actionAttach, SIGNAL(triggered()), this, SLOT(displayAttach())); connect(ui->actionDetach, SIGNAL(triggered()), this, SLOT(detach())); connect(ui->actionChangeCommandLine, SIGNAL(triggered()), this, SLOT(changeCommandLine())); @@ -301,6 +302,7 @@ void MainWindow::refreshShortcuts() ui->actionDonate->setShortcut(ConfigShortcut("HelpDonate")); ui->actionCheckUpdates->setShortcut(ConfigShortcut("HelpCheckForUpdates")); ui->actionCalculator->setShortcut(ConfigShortcut("HelpCalculator")); + ui->actionReportBug->setShortcut(ConfigShortcut("HelpReportBug")); ui->actionStrings->setShortcut(ConfigShortcut("ActionFindStrings")); ui->actionCalls->setShortcut(ConfigShortcut("ActionFindIntermodularCalls")); @@ -969,7 +971,20 @@ void MainWindow::donate() msg.setDefaultButton(QMessageBox::Ok); if(msg.exec() != QMessageBox::Ok) return; - QDesktopServices::openUrl(QUrl("https://blockchain.info/address/1GuXgtCrLk4aYgivAT7xAi8zVHWk5CkEoY")); + QDesktopServices::openUrl(QUrl("http://donate.x64dbg.com")); +} + +void MainWindow::reportBug() +{ + QMessageBox msg(QMessageBox::Information, "Report Bug", "You will be taken to a website where you can report a bug.\nMake sure to fill in as much information as possible."); + msg.setWindowIcon(QIcon(":/icons/images/bug-report.png")); + msg.setParent(this, Qt::Dialog); + msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint)); + msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msg.setDefaultButton(QMessageBox::Ok); + if(msg.exec() != QMessageBox::Ok) + return; + QDesktopServices::openUrl(QUrl("http://report.x64dbg.com")); } void MainWindow::displayAttach() diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.h b/x64_dbg_gui/Project/Src/Gui/MainWindow.h index 00707c8c..dfab6940 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.h +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.h @@ -91,6 +91,7 @@ public slots: void openShortcuts(); void changeTopmost(bool checked); void donate(); + void reportBug(); void displayAttach(); void detach(); void changeCommandLine(); diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.ui b/x64_dbg_gui/Project/Src/Gui/MainWindow.ui index fb4e5146..795e2188 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.ui +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.ui @@ -91,6 +91,7 @@ + @@ -165,8 +166,11 @@ - + + + + @@ -633,6 +637,18 @@ Topmost Window + + + + :/icons/images/bug-report.png:/icons/images/bug-report.png + + + &Report Bug + + + Report Bug + + diff --git a/x64_dbg_gui/Project/Src/Utils/Configuration.cpp b/x64_dbg_gui/Project/Src/Utils/Configuration.cpp index 492a2062..8ed1e346 100644 --- a/x64_dbg_gui/Project/Src/Utils/Configuration.cpp +++ b/x64_dbg_gui/Project/Src/Utils/Configuration.cpp @@ -221,6 +221,7 @@ Configuration::Configuration() : QObject() defaultShortcuts.insert("HelpDonate", Shortcut(tr("Help -> Donate"), "", true)); defaultShortcuts.insert("HelpCheckForUpdates", Shortcut(tr("Help -> Check for Updates"), "", true)); defaultShortcuts.insert("HelpCalculator", Shortcut(tr("Help -> Calculator"), "?")); + defaultShortcuts.insert("HelpReportBug", Shortcut(tr("Help -> Report Bug"), "", true)); defaultShortcuts.insert("ActionFindStrings", Shortcut(tr("Actions -> Find Strings"), "", true)); defaultShortcuts.insert("ActionFindIntermodularCalls", Shortcut(tr("Actions -> Find Intermodular Calls"), "", true)); diff --git a/x64_dbg_gui/Project/images/bug-report.png b/x64_dbg_gui/Project/images/bug-report.png new file mode 100644 index 0000000000000000000000000000000000000000..fe12b19946c04cca1a7ad8d79806ee358a354efe GIT binary patch literal 773 zcmV+g1N!`lP)uaqc_9R10nI^LE)kyQ8*Ahh`$iU zC84xiLfif6c6_s48ly+w=9@R)oA=(nc{9T}=lCCC^0*9$9MxS5MhG|m@#L5yJoDy~ z=U1QB#PMNccxLQJUw2z~*YL&R^Fj+Q>~)_%MDqU5@jz6-3p^P{xZ&~iP$}J>))I+? zEVSUlF4nzDg?}v$3d&xh6p>5xm!qjYsbuoB^|JBG?dw7SqtAG{tHC7T@7(EXeLd_7hZBs$fy3 zBY;6F@ny0l8Hy+3NF7gM{?$A(=Q40i2f1u6#AkV)$xQfxZ`YuRfl8`%wF=GHFci5W zBhnm!BuOY2$|&ZGFtUb%5;SgdZ|~gZ^;0-PTX=*D-q9krY|FJPHf+a+EX$r2T-e3B z@bmmdoR`4CDDD3Zp^xUDN~Mx%OB6((tjeAiT-Y%XJ;28j3cnHU7jfc9B`SNI61||T zMbb;zjcmb|Z8)+6DI|GXaA8M_g4z0-NQv(2__rUq3$ zxBA}c9lD_YeY@wTXBQdTeRhntF^>T>qlxAZlj-Euj^2(#D{og;^`K#4U%(PK=EUIX z%!lVoi~hS=RH(XIGq>DTcSGx&(t*eT~R(KwxRb3nPu5MUW7 zZ1+uhS|O-D0zTgr*Ly~H)k(O#i-H#@coh4C_$|Nyq3b=A>AS@S00000NkvXXu0mjf DKoV|a literal 0 HcmV?d00001 diff --git a/x64_dbg_gui/Project/resource.qrc b/x64_dbg_gui/Project/resource.qrc index 0036a6e7..b2790047 100644 --- a/x64_dbg_gui/Project/resource.qrc +++ b/x64_dbg_gui/Project/resource.qrc @@ -50,5 +50,6 @@ images/arrow-skip.png images/topmost.png images/close-all-tabs.png + images/bug-report.png From 9120de5f84e97be4678941b3a73cc15de62e9fdc Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sat, 7 Feb 2015 19:27:38 +0100 Subject: [PATCH 035/106] DBG: rmp.cpp (start of better readmemory code) --- rpm.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 rpm.cpp diff --git a/rpm.cpp b/rpm.cpp new file mode 100644 index 00000000..fc354e12 --- /dev/null +++ b/rpm.cpp @@ -0,0 +1,93 @@ +#include +#include +#include + +#define uint size_t +#define PAGE_SIZE 0x1000 + +#ifdef _WIN64 +#define HIGHEST_USER_ADDR 0x7FFFFFEFFFF +#else //x86 +#define HIGHEST_USER_ADDR 0x7FFEFFFF +#endif // _WIN64 + +bool readblock(uint addr, unsigned char block[PAGE_SIZE]) +{ + printf("readblock(%X[%X])\n", addr, PAGE_SIZE); + memset(block, 0xFF, PAGE_SIZE); + return true; +} + +bool memread(uint addr, unsigned char* data, uint size) +{ + //check if the address is inside user space + if(addr > HIGHEST_USER_ADDR) + return false; + + puts("-start-"); + printf(" addr: %X\n size: %X\n", addr, size); + + //calculate the start page + uint start = addr & ~(PAGE_SIZE - 1); + printf(" start: %X\n", start); + + //calculate the end page + uint end = addr + size; + uint x = end & (PAGE_SIZE - 1); + if(x) + end += (PAGE_SIZE - x); + printf(" end: %X\n", end); + + //calculate the number of pages to read + uint npages = (end - start) / PAGE_SIZE; + printf("npages: %d\n\n", npages); + + //go over all pages + for(uint i = 0, j = start; i < npages; i++) + { + //read one page (j should always align with PAGE_SIZE) + unsigned char block[PAGE_SIZE]; + if(!readblock(j, block)) + { + return false; + } + + //these are the offsets and sizes in the block to write to append to the output buffer + uint roffset = 0; + uint rsize = PAGE_SIZE; + + if(i == npages - 1) //last page (first because there might only be one page) + { + rsize = size - (j - start); //remaining size + } + else if(i == 0) //first page + { + roffset = addr & (PAGE_SIZE - 1); + rsize = PAGE_SIZE - roffset; + } + + printf("roffset: %X\n rsize: %X\n", roffset, rsize); + puts(""); + + //copy the required block data in the output buffer + memcpy(data, block + roffset, rsize); + data += rsize; + + j += rsize; + } + + puts("--end--\n"); + return true; +} + +int main() +{ + unsigned char out[0x10000] = {0}; + memread(0x12A45, out, 0x3456); + memread(0x12000, out, 0x456); + memread(0x12000, out, 0x3456); + memread(0x12000, out, 0x4000); + memread(0x12ff0, out, 0x16); + memread(0x100, out, 0x3090); + return 0; +} \ No newline at end of file From 1f080ede2c05c183005c534e903694ba4496c763 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 20 Feb 2015 17:57:30 +0100 Subject: [PATCH 036/106] GUI: update hex when editing ascii/unicode in HexEditDialog --- x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp | 10 ++++++++++ x64_dbg_gui/Project/Src/Gui/HexEditDialog.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp index 97cf167a..9abd93d1 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp @@ -122,3 +122,13 @@ void HexEditDialog::dataChangedSlot() ui->lineEditAscii->setText(ascii); ui->lineEditUnicode->setText(unicode); } + +void HexEditDialog::on_lineEditAscii_textEdited(const QString &arg1) +{ + on_btnAscii2Hex_clicked(); +} + +void HexEditDialog::on_lineEditUnicode_textEdited(const QString &arg1) +{ + on_btnUnicode2Hex_clicked(); +} diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h index 752ae6e6..13dd455f 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h @@ -28,6 +28,8 @@ private slots: void on_btnUnicode2Hex_clicked(); void on_chkKeepSize_toggled(bool checked); void dataChangedSlot(); + void on_lineEditAscii_textEdited(const QString &arg1); + void on_lineEditUnicode_textEdited(const QString &arg1); private: Ui::HexEditDialog* ui; From 0f1923d65e1cab402726f23f2b3878795974af00 Mon Sep 17 00:00:00 2001 From: Nukem Date: Tue, 10 Mar 2015 20:13:37 -0400 Subject: [PATCH 037/106] Order exception list by number --- x64_dbg_dbg/exception.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x64_dbg_dbg/exception.cpp b/x64_dbg_dbg/exception.cpp index 8e000e6b..fd10b4fa 100644 --- a/x64_dbg_dbg/exception.cpp +++ b/x64_dbg_dbg/exception.cpp @@ -5,6 +5,7 @@ static std::map exceptionNames; void exceptioninit() { + exceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); exceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); exceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); exceptionNames.insert(std::make_pair(0x4000001D, "STATUS_WX86_CONTINUE")); @@ -21,6 +22,7 @@ void exceptioninit() exceptionNames.insert(std::make_pair(0x40010007, "DBG_RIPEXCEPTION")); exceptionNames.insert(std::make_pair(0x40010008, "DBG_CONTROL_BREAK")); exceptionNames.insert(std::make_pair(0x40010009, "DBG_COMMAND_EXCEPTION")); + exceptionNames.insert(std::make_pair(0x406D1388, "MS_VC_EXCEPTION")); exceptionNames.insert(std::make_pair(0x80000001, "EXCEPTION_GUARD_PAGE")); exceptionNames.insert(std::make_pair(0x80000002, "EXCEPTION_DATATYPE_MISALIGNMENT")); exceptionNames.insert(std::make_pair(0x80000003, "EXCEPTION_BREAKPOINT")); @@ -55,6 +57,7 @@ void exceptioninit() exceptionNames.insert(std::make_pair(0xC0000142, "STATUS_DLL_INIT_FAILED")); exceptionNames.insert(std::make_pair(0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT")); exceptionNames.insert(std::make_pair(0xC0000194, "EXCEPTION_POSSIBLE_DEADLOCK")); + exceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); exceptionNames.insert(std::make_pair(0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS")); exceptionNames.insert(std::make_pair(0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS")); exceptionNames.insert(std::make_pair(0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR")); @@ -62,16 +65,14 @@ void exceptioninit() exceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN")); exceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER")); exceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE")); - exceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); exceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); exceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); - exceptionNames.insert(std::make_pair(0x406D1388, "MS_VC_EXCEPTION")); - exceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); } const char* exceptionnamefromcode(unsigned int ExceptionCode) { if(!exceptionNames.count(ExceptionCode)) - return 0; + return nullptr; + return exceptionNames[ExceptionCode]; } \ No newline at end of file From 125f07ff6c9ab84e83b65405d1a0a16270648128 Mon Sep 17 00:00:00 2001 From: Nukem Date: Tue, 10 Mar 2015 21:24:47 -0400 Subject: [PATCH 038/106] Refactor CriticalSectionLocker --- x64_dbg_dbg/threading.cpp | 69 ++++++++++++++++++++++++++------------- x64_dbg_dbg/threading.h | 22 ++++++++----- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/x64_dbg_dbg/threading.cpp b/x64_dbg_dbg/threading.cpp index 0ef8a16d..8c303968 100644 --- a/x64_dbg_dbg/threading.cpp +++ b/x64_dbg_dbg/threading.cpp @@ -28,53 +28,78 @@ bool waitislocked(WAIT_ID id) return waitarray[id]; } -CRITICAL_SECTION CriticalSectionLocker::locks[LockLast] = {}; -bool CriticalSectionLocker::bInitDone = false; +bool CriticalSectionLocker::m_Initialized = false; +CRITICAL_SECTION CriticalSectionLocker::m_Locks[LockLast]; void CriticalSectionLocker::Initialize() { - if(bInitDone) + if(m_Initialized) return; + + // Destroy previous data if any existed + memset(m_Locks, 0, sizeof(m_Locks)); + for(int i = 0; i < LockLast; i++) - InitializeCriticalSection(&locks[i]); - bInitDone = true; + InitializeCriticalSection(&m_Locks[i]); + + m_Initialized = true; } void CriticalSectionLocker::Deinitialize() { - if(!bInitDone) + if(!m_Initialized) return; + for(int i = 0; i < LockLast; i++) { - EnterCriticalSection(&locks[i]); //obtain ownership - DeleteCriticalSection(&locks[i]); + // Wait for the lock's ownership to be released + EnterCriticalSection(&m_Locks[i]); + LeaveCriticalSection(&m_Locks[i]); + + // Render the lock data invalid + DeleteCriticalSection(&m_Locks[i]); } - bInitDone = false; + + m_Initialized = false; } -CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock) +CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock LockIndex) { - Initialize(); //initialize critical sections - gLock = lock; + m_Section = &m_Locks[LockIndex]; + m_LockCount = 0; - EnterCriticalSection(&locks[gLock]); - Locked = true; + Lock(); } CriticalSectionLocker::~CriticalSectionLocker() { - if(Locked) - LeaveCriticalSection(&locks[gLock]); + if(m_LockCount > 0) + LeaveCriticalSection(m_Section); + + // TODO: Assert that the lock count is zero on destructor } -void CriticalSectionLocker::unlock() +void CriticalSectionLocker::Unlock() { - Locked = false; - LeaveCriticalSection(&locks[gLock]); + m_LockCount--; + LeaveCriticalSection(m_Section); } -void CriticalSectionLocker::relock() +void CriticalSectionLocker::Lock() { - EnterCriticalSection(&locks[gLock]); - Locked = true; + EnterCriticalSection(m_Section); + m_LockCount++; +} + +bool CriticalSectionLocker::TryLock() +{ + // Only enter the critical section if it's currently owned by the + // thread, or if it is not being used at all + if(TryEnterCriticalSection(m_Section)) + { + Lock(); + return true; + } + + return false; } \ No newline at end of file diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 1ccb95e4..512116a4 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -18,6 +18,9 @@ void lock(WAIT_ID id); void unlock(WAIT_ID id); bool waitislocked(WAIT_ID id); +#define EXCLUSIVE_ACQUIRE(Index) CriticalSectionLocker __ThreadLock(Index); +#define EXCLUSIVE_RELEASE() __ThreadLock.Unlock(); + enum CriticalSectionLock { LockMemoryPages, @@ -38,19 +41,22 @@ enum CriticalSectionLock class CriticalSectionLocker { public: + static void Initialize(); static void Deinitialize(); - CriticalSectionLocker(CriticalSectionLock lock); + + CriticalSectionLocker(CriticalSectionLock LockIndex); ~CriticalSectionLocker(); - void unlock(); - void relock(); + + void Unlock(); + void Lock(); + bool TryLock(); private: - static void Initialize(); - static bool bInitDone; - static CRITICAL_SECTION locks[LockLast]; + static bool m_Initialized; + static CRITICAL_SECTION m_Locks[LockLast]; - CriticalSectionLock gLock; - bool Locked; + CRITICAL_SECTION* m_Section; + BYTE m_LockCount; }; #endif // _THREADING_H From 47306590cc6cce5577e98f9bc1e51b8bc9418831 Mon Sep 17 00:00:00 2001 From: Nukem Date: Tue, 10 Mar 2015 21:25:18 -0400 Subject: [PATCH 039/106] Refactor Thread.cpp/.h --- x64_dbg_bridge/bridgemain.h | 4 +- x64_dbg_dbg/_exports.cpp | 2 +- x64_dbg_dbg/debugger.cpp | 32 ++--- x64_dbg_dbg/debugger_commands.cpp | 36 ++--- x64_dbg_dbg/thread.cpp | 231 +++++++++++++++++++++--------- x64_dbg_dbg/thread.h | 16 +-- 6 files changed, 205 insertions(+), 116 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index c64fe3c1..28cbfa2c 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -540,8 +540,8 @@ typedef struct typedef struct { int ThreadNumber; - HANDLE hThread; - DWORD dwThreadId; + HANDLE Handle; + DWORD ThreadId; duint ThreadStartAddress; duint ThreadLocalBase; char threadName[MAX_THREAD_NAME_SIZE]; diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index e0e89df8..8c7c46ac 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -719,7 +719,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_GET_THREAD_LIST: { - threadgetlist((THREADLIST*)param1); + ThreadGetList((THREADLIST*)param1); } break; diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 0bde1dad..4c744b4d 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -203,14 +203,14 @@ void DebugUpdateGui(uint disasm_addr, bool stack) else sprintf(modtext, "Module: %s - ", modname); char title[1024] = ""; - sprintf(title, "File: %s - PID: %X - %sThread: %X", szBaseFileName, fdProcessInfo->dwProcessId, modtext, threadgetid(hActiveThread)); + sprintf(title, "File: %s - PID: %X - %sThread: %X", szBaseFileName, fdProcessInfo->dwProcessId, modtext, ThreadGetId(hActiveThread)); GuiUpdateWindowTitle(title); GuiUpdateAllViews(); } void cbUserBreakpoint() { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); BREAKPOINT bp; BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; @@ -260,7 +260,7 @@ void cbUserBreakpoint() void cbHardwareBreakpoint(void* ExceptionAddress) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); uint cip = GetContextDataEx(hActiveThread, UE_CIP); BREAKPOINT bp; BRIDGEBP pluginBp; @@ -335,7 +335,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress) void cbMemoryBreakpoint(void* ExceptionAddress) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); uint cip = GetContextDataEx(hActiveThread, UE_CIP); uint size; uint base = memfindbaseaddr((uint)ExceptionAddress, &size, true); @@ -540,7 +540,7 @@ static bool cbRemoveModuleBreakpoints(const BREAKPOINT* bp) void cbStep() { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); isStepping = false; GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); @@ -559,7 +559,7 @@ void cbStep() static void cbRtrFinalStep() { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); //lock @@ -605,7 +605,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) dprintf("Process Started: "fhex" %s\n", base, DebugFileName); memupdatemap(fdProcessInfo->hProcess); - GuiDumpAt(memfindbaseaddr(GetContextData(UE_CIP), 0)+PAGE_SIZE); //dump somewhere + GuiDumpAt(memfindbaseaddr(GetContextData(UE_CIP), 0) + PAGE_SIZE); //dump somewhere //init program database int len = (int)strlen(szFileName); @@ -704,7 +704,7 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) { threadcreate(CreateThread); //update thread list DWORD dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; - hActiveThread = threadgethandle(dwThreadId); + hActiveThread = ThreadGetHandle(dwThreadId); if(settingboolget("Events", "ThreadEntry")) { @@ -739,7 +739,7 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) static void cbExitThread(EXIT_THREAD_DEBUG_INFO* ExitThread) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); DWORD dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; PLUG_CB_EXITTHREAD callbackInfo; callbackInfo.ExitThread = ExitThread; @@ -765,7 +765,7 @@ static void cbExitThread(EXIT_THREAD_DEBUG_INFO* ExitThread) static void cbSystemBreakpoint(void* ExceptionData) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); //log message if(bIsAttached) dputs("Attach breakpoint reached!"); @@ -797,7 +797,7 @@ static void cbSystemBreakpoint(void* ExceptionData) static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); void* base = LoadDll->lpBaseOfDll; char DLLDebugFileName[deflen] = ""; if(!GetFileNameFromHandle(LoadDll->hFile, DLLDebugFileName)) @@ -900,7 +900,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); PLUG_CB_UNLOADDLL callbackInfo; callbackInfo.UnloadDll = UnloadDll; plugincbcall(CB_UNLOADDLL, &callbackInfo); @@ -934,7 +934,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); PLUG_CB_OUTPUTDEBUGSTRING callbackInfo; callbackInfo.DebugString = DebugString; plugincbcall(CB_OUTPUTDEBUGSTRING, &callbackInfo); @@ -973,7 +973,7 @@ static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) { - hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); PLUG_CB_EXCEPTION callbackInfo; callbackInfo.Exception = ExceptionData; unsigned int ExceptionCode = ExceptionData->ExceptionRecord.ExceptionCode; @@ -1019,14 +1019,14 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) memcpy(&nameInfo, ExceptionData->ExceptionRecord.ExceptionInformation, sizeof(THREADNAME_INFO)); if(nameInfo.dwThreadID == -1) //current thread nameInfo.dwThreadID = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; - if(nameInfo.dwType == 0x1000 and nameInfo.dwFlags == 0 and threadisvalid(nameInfo.dwThreadID)) //passed basic checks + if(nameInfo.dwType == 0x1000 and nameInfo.dwFlags == 0 and ThreadIsValid(nameInfo.dwThreadID)) //passed basic checks { Memory ThreadName(MAX_THREAD_NAME_SIZE, "cbException:ThreadName"); if(memread(fdProcessInfo->hProcess, nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0)) { String ThreadNameEscaped = StringUtils::Escape(ThreadName); dprintf("SetThreadName(%X, \"%s\")\n", nameInfo.dwThreadID, ThreadNameEscaped.c_str()); - threadsetname(nameInfo.dwThreadID, ThreadNameEscaped.c_str()); + ThreadSetName(nameInfo.dwThreadID, ThreadNameEscaped.c_str()); } } } diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 5aa69737..ed586f34 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -1035,13 +1035,13 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[]) if(argc > 1) if(!valfromstring(argv[1], &threadid, false)) return STATUS_ERROR; - if(!threadisvalid((DWORD)threadid)) //check if the thread is valid + if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //switch thread - hActiveThread = threadgethandle((DWORD)threadid); + hActiveThread = ThreadGetHandle((DWORD)threadid); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); dputs("Thread switched!"); return STATUS_CONTINUE; @@ -1053,13 +1053,13 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[]) if(argc > 1) if(!valfromstring(argv[1], &threadid, false)) return STATUS_ERROR; - if(!threadisvalid((DWORD)threadid)) //check if the thread is valid + if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //suspend thread - if(SuspendThread(threadgethandle((DWORD)threadid)) == -1) + if(SuspendThread(ThreadGetHandle((DWORD)threadid)) == -1) { dputs("Error suspending thread"); return STATUS_ERROR; @@ -1075,13 +1075,13 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[]) if(argc > 1) if(!valfromstring(argv[1], &threadid, false)) return STATUS_ERROR; - if(!threadisvalid((DWORD)threadid)) //check if the thread is valid + if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //resume thread - if(ResumeThread(threadgethandle((DWORD)threadid)) == -1) + if(ResumeThread(ThreadGetHandle((DWORD)threadid)) == -1) { dputs("Error resuming thread"); return STATUS_ERROR; @@ -1101,13 +1101,13 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[]) if(argc > 2) if(!valfromstring(argv[2], &exitcode, false)) return STATUS_ERROR; - if(!threadisvalid((DWORD)threadid)) //check if the thread is valid + if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //terminate thread - if(TerminateThread(threadgethandle((DWORD)threadid), (DWORD)exitcode) != 0) + if(TerminateThread(ThreadGetHandle((DWORD)threadid), (DWORD)exitcode) != 0) { GuiUpdateAllViews(); dputs("Thread terminated"); @@ -1119,8 +1119,8 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[]) CMDRESULT cbDebugSuspendAllThreads(int argc, char* argv[]) { - int threadCount = threadgetcount(); - int suspendedCount = threadsuspendall(); + int threadCount = ThreadGetCount(); + int suspendedCount = ThreadSuspendAll(); dprintf("%d/%d thread(s) suspended\n", suspendedCount, threadCount); GuiUpdateAllViews(); return STATUS_CONTINUE; @@ -1128,8 +1128,8 @@ CMDRESULT cbDebugSuspendAllThreads(int argc, char* argv[]) CMDRESULT cbDebugResumeAllThreads(int argc, char* argv[]) { - int threadCount = threadgetcount(); - int resumeCount = threadresumeall(); + int threadCount = ThreadGetCount(); + int resumeCount = ThreadResumeAll(); dprintf("%d/%d thread(s) resumed\n", resumeCount, threadCount); GuiUpdateAllViews(); return STATUS_CONTINUE; @@ -1185,13 +1185,13 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[]) return STATUS_ERROR; } } - if(!threadisvalid((DWORD)threadid)) //check if the thread is valid + if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //set thread priority - if(SetThreadPriority(threadgethandle((DWORD)threadid), (int)priority) == 0) + if(SetThreadPriority(ThreadGetHandle((DWORD)threadid), (int)priority) == 0) { dputs("Error setting thread priority"); return STATUS_ERROR; @@ -1817,7 +1817,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) } LoadLibThreadID = fdProcessInfo->dwThreadId; - HANDLE LoadLibThread = threadgethandle((DWORD)LoadLibThreadID); + HANDLE LoadLibThread = ThreadGetHandle((DWORD)LoadLibThreadID); DLLNameMem = VirtualAllocEx(fdProcessInfo->hProcess, NULL, strlen(argv[1]) + 1, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); ASMAddr = VirtualAllocEx(fdProcessInfo->hProcess, NULL, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); @@ -1869,7 +1869,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) SetContextDataEx(LoadLibThread, UE_CIP, (uint)ASMAddr); SetBPX((uint)ASMAddr + counter, UE_SINGLESHOOT | UE_BREAKPOINT_TYPE_INT3, (void*)cbLoadLibBPX); - threadsuspendall(); + ThreadSuspendAll(); ResumeThread(LoadLibThread); unlock(WAITID_RUN); @@ -1880,7 +1880,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) void cbLoadLibBPX() { uint LibAddr = 0; - HANDLE LoadLibThread = threadgethandle((DWORD)LoadLibThreadID); + HANDLE LoadLibThread = ThreadGetHandle((DWORD)LoadLibThreadID); #ifdef _WIN64 LibAddr = GetContextDataEx(LoadLibThread, UE_RAX); #else @@ -1891,7 +1891,7 @@ void cbLoadLibBPX() SetFullContextDataEx(LoadLibThread, &backupctx); VirtualFreeEx(fdProcessInfo->hProcess, DLLNameMem, 0, MEM_RELEASE); VirtualFreeEx(fdProcessInfo->hProcess, ASMAddr, 0, MEM_RELEASE); - threadresumeall(); + ThreadResumeAll(); //update GUI GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index e7063cc0..59279f4c 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -6,150 +6,239 @@ static std::vector threadList; static int threadNum; -static int currentThread; void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread) { THREADINFO curInfo; - curInfo.ThreadNumber = threadNum; - curInfo.hThread = CreateThread->hThread; - curInfo.dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; - curInfo.ThreadStartAddress = (uint)CreateThread->lpStartAddress; - curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase; - *curInfo.threadName = '\0'; - if(!threadNum) + memset(&curInfo, 0, sizeof(THREADINFO)); + + curInfo.ThreadNumber = threadNum; + curInfo.Handle = CreateThread->hThread; + curInfo.ThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; + curInfo.ThreadStartAddress = (uint)CreateThread->lpStartAddress; + curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase; + + // The first thread (#0) is always the main program thread + if(threadNum <= 0) strcpy_s(curInfo.threadName, "Main Thread"); - CriticalSectionLocker locker(LockThreads); + + // Modify global thread list + EXCLUSIVE_ACQUIRE(LockThreads); threadList.push_back(curInfo); threadNum++; - locker.unlock(); //prevent possible deadlocks + EXCLUSIVE_RELEASE(); + + // Notify GUI GuiUpdateThreadView(); } void threadexit(DWORD dwThreadId) { - CriticalSectionLocker locker(LockThreads); - for(unsigned int i = 0; i < threadList.size(); i++) - if(threadList.at(i).dwThreadId == dwThreadId) + EXCLUSIVE_ACQUIRE(LockThreads); + + for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + { + if(itr->ThreadId == dwThreadId) { - threadList.erase(threadList.begin() + i); + threadList.erase(itr); break; } - locker.unlock(); //prevent possible deadlocks + } + + EXCLUSIVE_RELEASE(); GuiUpdateThreadView(); } void threadclear() { threadNum = 0; - CriticalSectionLocker locker(LockThreads); - std::vector().swap(threadList); - locker.unlock(); //prevent possible deadlocks + + // Clear the current array of threads + EXCLUSIVE_ACQUIRE(LockThreads); + threadList.clear(); + EXCLUSIVE_RELEASE(); + + // Update the GUI's list GuiUpdateThreadView(); } -static THREADWAITREASON GetThreadWaitReason(DWORD dwThreadId) +bool ThreadGetTeb(uint TEBAddress, TEB* Teb) { - //TODO: implement this + // + // TODO: Keep a cached copy of this inside of the vector + // + memset(Teb, 0, sizeof(TEB)); + + return memread(fdProcessInfo->hProcess, (void*)TEBAddress, Teb, sizeof(TEB), nullptr); +} + +int ThreadGetSuspendCount(HANDLE Thread) +{ + // + // Suspend a thread in order to get the previous suspension count + // WARNING: This function is very bad (threads should not be randomly interrupted) + // + int suspendCount = (int)SuspendThread(Thread); + + if(suspendCount == -1) + return 0; + + // Resume the thread's normal execution + ResumeThread(Thread); + + return suspendCount; +} + +THREADPRIORITY ThreadGetPriority(HANDLE Thread) +{ + return (THREADPRIORITY)GetThreadPriority(Thread); +} + +THREADWAITREASON ThreadGetWaitReason(HANDLE Thread) +{ + UNREFERENCED_PARAMETER(Thread); + + //TODO: Implement this return _Executive; } -static DWORD GetThreadLastError(uint tebAddress) +DWORD ThreadGetLastError(uint tebAddress) { TEB teb; - memset(&teb, 0, sizeof(TEB)); - if(!memread(fdProcessInfo->hProcess, (void*)tebAddress, &teb, sizeof(TEB), 0)) + if(!ThreadGetTeb(tebAddress, &teb)) + { + // TODO: Assert return 0; + } + return teb.LastErrorValue; } -void threadgetlist(THREADLIST* list) +void ThreadGetList(THREADLIST* list) { - CriticalSectionLocker locker(LockThreads); - int count = (int)threadList.size(); - list->count = count; - if(!count) + EXCLUSIVE_ACQUIRE(LockThreads); + + // + // This function converts a C++ std::vector to a C-style THREADLIST[] + // Also assume BridgeAlloc zeros the returned buffer + // + size_t count = threadList.size(); + + if(count <= 0) return; - list->list = (THREADALLINFO*)BridgeAlloc(count * sizeof(THREADALLINFO)); - for(int i = 0; i < count; i++) + + list->count = (int)count; + list->list = (THREADALLINFO*)BridgeAlloc(count * sizeof(THREADALLINFO)); + + // Fill out the list data + for(size_t i = 0; i < count; i++) { - if(hActiveThread == threadList.at(i).hThread) - currentThread = i; - memset(&list->list[i], 0, sizeof(THREADALLINFO)); - memcpy(&list->list[i].BasicInfo, &threadList.at(i), sizeof(THREADINFO)); - HANDLE hThread = list->list[i].BasicInfo.hThread; - list->list[i].ThreadCip = GetContextDataEx(hThread, UE_CIP); - list->list[i].SuspendCount = SuspendThread(hThread); - ResumeThread(hThread); - list->list[i].Priority = (THREADPRIORITY)GetThreadPriority(list->list[i].BasicInfo.hThread); - list->list[i].WaitReason = GetThreadWaitReason(list->list[i].BasicInfo.dwThreadId); - list->list[i].LastError = GetThreadLastError(list->list[i].BasicInfo.ThreadLocalBase); + HANDLE threadHandle = threadList[i].Handle; + + // Get the debugger's current thread index + if(threadHandle == hActiveThread) + list->CurrentThread = (int)i; + + memcpy(&list->list[i].BasicInfo, &threadList[i], sizeof(THREADINFO)); + + list->list[i].ThreadCip = GetContextDataEx(threadHandle, UE_CIP); + list->list[i].SuspendCount = ThreadGetSuspendCount(threadHandle); + list->list[i].Priority = ThreadGetPriority(threadHandle); + list->list[i].WaitReason = ThreadGetWaitReason(threadHandle); + list->list[i].LastError = ThreadGetLastError(list->list[i].BasicInfo.ThreadLocalBase); } - list->CurrentThread = currentThread; } -bool threadisvalid(DWORD dwThreadId) +bool ThreadIsValid(DWORD dwThreadId) { - CriticalSectionLocker locker(LockThreads); - for(unsigned int i = 0; i < threadList.size(); i++) - if(threadList.at(i).dwThreadId == dwThreadId) + EXCLUSIVE_ACQUIRE(LockThreads); + + for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + { + if(itr->ThreadId == dwThreadId) return true; + } + return false; } -bool threadsetname(DWORD dwThreadId, const char* name) +bool ThreadSetName(DWORD dwThreadId, const char* name) { - CriticalSectionLocker locker(LockThreads); - for(unsigned int i = 0; i < threadList.size(); i++) - if(threadList.at(i).dwThreadId == dwThreadId) + EXCLUSIVE_ACQUIRE(LockThreads); + + for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + { + if(itr->ThreadId == dwThreadId) { if(name) - strcpy_s(threadList.at(i).threadName, name); + strcpy_s(itr->threadName, name); else - *threadList.at(i).threadName = '\0'; + itr->threadName[0] = '\0'; } + } + return false; } -HANDLE threadgethandle(DWORD dwThreadId) +HANDLE ThreadGetHandle(DWORD dwThreadId) { - CriticalSectionLocker locker(LockThreads); - for(unsigned int i = 0; i < threadList.size(); i++) - if(threadList.at(i).dwThreadId == dwThreadId) - return threadList.at(i).hThread; + EXCLUSIVE_ACQUIRE(LockThreads); + + for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + { + if(itr->ThreadId == dwThreadId) + return itr->Handle; + } + + // TODO: Set an assert if the handle is never found, + // using a bad handle causes random/silent issues everywhere return 0; } -DWORD threadgetid(HANDLE hThread) +DWORD ThreadGetId(HANDLE hThread) { - CriticalSectionLocker locker(LockThreads); - for(unsigned int i = 0; i < threadList.size(); i++) - if(threadList.at(i).hThread == hThread) - return threadList.at(i).dwThreadId; + EXCLUSIVE_ACQUIRE(LockThreads); + + for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + { + if(itr->Handle == hThread) + return itr->ThreadId; + } + + // TODO: Same problem with threadgethandle() + // TODO: Different handles can map to the same thread return 0; } -int threadgetcount() +int ThreadGetCount() { return (int)threadList.size(); } -int threadsuspendall() +int ThreadSuspendAll() { - CriticalSectionLocker locker(LockThreads); + EXCLUSIVE_ACQUIRE(LockThreads); + int count = 0; - for(unsigned int i = 0; i < threadList.size(); i++) - if(SuspendThread(threadList.at(i).hThread) != -1) + for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + { + if(SuspendThread(itr->Handle) != -1) count++; + } + return count; } -int threadresumeall() +int ThreadResumeAll() { - CriticalSectionLocker locker(LockThreads); + EXCLUSIVE_ACQUIRE(LockThreads); + int count = 0; - for(unsigned int i = 0; i < threadList.size(); i++) - if(ResumeThread(threadList.at(i).hThread) != -1) + for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + { + if(ResumeThread(itr->Handle) != -1) count++; + } + return count; } \ No newline at end of file diff --git a/x64_dbg_dbg/thread.h b/x64_dbg_dbg/thread.h index eaacbaef..22276dc3 100644 --- a/x64_dbg_dbg/thread.h +++ b/x64_dbg_dbg/thread.h @@ -8,13 +8,13 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread); void threadexit(DWORD dwThreadId); void threadclear(); -void threadgetlist(THREADLIST* list); -bool threadisvalid(DWORD dwThreadId); -bool threadsetname(DWORD dwTHreadId, const char* name); -HANDLE threadgethandle(DWORD dwThreadId); -DWORD threadgetid(HANDLE hThread); -int threadgetcount(); -int threadsuspendall(); -int threadresumeall(); +void ThreadGetList(THREADLIST* list); +bool ThreadIsValid(DWORD dwThreadId); +bool ThreadSetName(DWORD dwTHreadId, const char* name); +HANDLE ThreadGetHandle(DWORD dwThreadId); +DWORD ThreadGetId(HANDLE hThread); +int ThreadGetCount(); +int ThreadSuspendAll(); +int ThreadResumeAll(); #endif //_THREAD_H From 0a69aa95e90a62387e9a1861e4a96d6f31be7716 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 11 Mar 2015 18:14:25 -0400 Subject: [PATCH 040/106] Begin using shared locks --- x64_dbg_dbg/_global.h | 2 +- x64_dbg_dbg/error.cpp | 3 +- x64_dbg_dbg/module.cpp | 131 ++++++++++++++++++++++++++------------ x64_dbg_dbg/thread.cpp | 31 ++++++--- x64_dbg_dbg/threading.cpp | 48 +++++++------- x64_dbg_dbg/threading.h | 22 +++++-- 6 files changed, 155 insertions(+), 82 deletions(-) diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index c3f6fcfd..b752b2b7 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -1,7 +1,7 @@ #ifndef _GLOBAL_H #define _GLOBAL_H -#define _WIN32_WINNT 0x0501 +#define _WIN32_WINNT 0x0600 #define WINVER 0x0501 #define _WIN32_IE 0x0500 diff --git a/x64_dbg_dbg/error.cpp b/x64_dbg_dbg/error.cpp index c950011d..a23875eb 100644 --- a/x64_dbg_dbg/error.cpp +++ b/x64_dbg_dbg/error.cpp @@ -2197,6 +2197,7 @@ void errorinit() const char* errornamefromcode(unsigned int ErrorCode) { if(!errorNames.count(ErrorCode)) - return 0; + return nullptr; + return errorNames[ErrorCode]; } \ No newline at end of file diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 3d4c91cf..91e82c0f 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -77,10 +77,12 @@ bool modload(uint base, uint size, const char* fullpath) bool modunload(uint base) { - CriticalSectionLocker locker(LockModules); + EXCLUSIVE_ACQUIRE(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(base, base)); if(found == modinfo.end()) //not found return false; + modinfo.erase(found); symupdatemodulelist(); return true; @@ -88,8 +90,12 @@ bool modunload(uint base) void modclear() { - CriticalSectionLocker locker(LockModules); - ModulesInfo().swap(modinfo); + EXCLUSIVE_ACQUIRE(LockModules); + + // Remove all modules in the list + modinfo.clear(); + + // Tell the symbol updater symupdatemodulelist(); } @@ -97,98 +103,143 @@ bool modnamefromaddr(uint addr, char* modname, bool extension) { if(!modname) return false; - *modname = '\0'; - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found + + SHARED_ACQUIRE(LockModules); + + // Was the module found with this address? + auto found = modinfo.find(Range(addr, addr)); + + if(found == modinfo.end()) return false; - String mod = found->second.name; + + // Zero buffer first + memset(modname, 0, MAX_MODULE_SIZE); + + // Append the module path/name + strcat_s(modname, MAX_MODULE_SIZE, found->second.name); + + // Append the extension if(extension) - mod += found->second.extension; - strcpy_s(modname, MAX_MODULE_SIZE, mod.c_str()); + strcat_s(modname, MAX_MODULE_SIZE, found->second.extension); + return true; } uint modbasefromaddr(uint addr) { - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found + SHARED_ACQUIRE(LockModules); + + // Was the module found with this address? + auto found = modinfo.find(Range(addr, addr)); + + if(found == modinfo.end()) return 0; + return found->second.base; } -uint modhashfromva(uint va) //return a unique hash from a VA +uint modhashfromva(uint va) { - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(va, va)); - if(found == modinfo.end()) //not found + // + // Returns a unique hash from a virtual address + // + SHARED_ACQUIRE(LockModules); + + // Was the module found with this address? + auto found = modinfo.find(Range(va, va)); + + if(found == modinfo.end()) return va; + return found->second.hash + (va - found->second.base); } -uint modhashfromname(const char* mod) //return MODINFO.hash +uint modhashfromname(const char* mod) { - if(!mod or !*mod) + // + // return MODINFO.hash (based on the name) + // + if(!mod || !mod[0]) return 0; - int len = (int)strlen(mod); - return murmurhash(mod, len); + + return murmurhash(mod, (int)strlen(mod)); } uint modbasefromname(const char* modname) { - if(!modname or strlen(modname) >= MAX_MODULE_SIZE) + if(!modname || strlen(modname) >= MAX_MODULE_SIZE) return 0; - CriticalSectionLocker locker(LockModules); - for(ModulesInfo::iterator i = modinfo.begin(); i != modinfo.end(); ++i) + + SHARED_ACQUIRE(LockModules); + + for(auto itr = modinfo.begin(); itr != modinfo.end(); itr++) { - MODINFO* curMod = &i->second; - char curmodname[MAX_MODULE_SIZE] = ""; - sprintf(curmodname, "%s%s", curMod->name, curMod->extension); - if(!_stricmp(curmodname, modname)) //with extension - return curMod->base; - if(!_stricmp(curMod->name, modname)) //without extension - return curMod->base; + char curmodname[MAX_MODULE_SIZE]; + sprintf(curmodname, "%s%s", itr->second.name, itr->second.extension); + + // Test with extension + if(!_stricmp(curmodname, modname)) + return itr->second.base; + + // Test without extension + if(!_stricmp(itr->second.name, modname)) + return itr->second.base; } + return 0; } uint modsizefromaddr(uint addr) { - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found + SHARED_ACQUIRE(LockModules); + + // Was the module found with this address? + auto found = modinfo.find(Range(addr, addr)); + + if(found == modinfo.end()) return 0; + return found->second.size; } bool modsectionsfromaddr(uint addr, std::vector* sections) { - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); - if(found == modinfo.end()) //not found + SHARED_ACQUIRE(LockModules); + + // Was the module found with this address? + auto found = modinfo.find(Range(addr, addr)); + + if(found == modinfo.end()) return false; + + // Copy vector <-> vector *sections = found->second.sections; return true; } uint modentryfromaddr(uint addr) { - CriticalSectionLocker locker(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + SHARED_ACQUIRE(LockModules); + + // Was the module found with this address? + auto found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found return 0; + return found->second.entry; } int modpathfromaddr(duint addr, char* path, int size) { Memory wszModPath(size * sizeof(wchar_t), "modpathfromaddr:wszModPath"); + if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), wszModPath, size)) { *path = '\0'; return 0; } + strcpy_s(path, size, StringUtils::Utf16ToUtf8(wszModPath()).c_str()); return (int)strlen(path); } @@ -196,4 +247,4 @@ int modpathfromaddr(duint addr, char* path, int size) int modpathfromname(const char* modname, char* path, int size) { return modpathfromaddr(modbasefromname(modname), path, size); -} +} \ No newline at end of file diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index 59279f4c..149b3b04 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -65,7 +65,7 @@ void threadclear() bool ThreadGetTeb(uint TEBAddress, TEB* Teb) { // - // TODO: Keep a cached copy of this inside of the vector + // TODO: Keep a cached copy inside the vector // memset(Teb, 0, sizeof(TEB)); @@ -107,7 +107,7 @@ DWORD ThreadGetLastError(uint tebAddress) TEB teb; if(!ThreadGetTeb(tebAddress, &teb)) { - // TODO: Assert + // TODO: Assert (Why would the TEB fail?) return 0; } @@ -116,7 +116,7 @@ DWORD ThreadGetLastError(uint tebAddress) void ThreadGetList(THREADLIST* list) { - EXCLUSIVE_ACQUIRE(LockThreads); + SHARED_ACQUIRE(LockThreads); // // This function converts a C++ std::vector to a C-style THREADLIST[] @@ -151,7 +151,7 @@ void ThreadGetList(THREADLIST* list) bool ThreadIsValid(DWORD dwThreadId) { - EXCLUSIVE_ACQUIRE(LockThreads); + SHARED_ACQUIRE(LockThreads); for(auto itr = threadList.begin(); itr != threadList.end(); itr++) { @@ -166,6 +166,7 @@ bool ThreadSetName(DWORD dwThreadId, const char* name) { EXCLUSIVE_ACQUIRE(LockThreads); + // This modifies a variable (name), so an exclusive lock is required for(auto itr = threadList.begin(); itr != threadList.end(); itr++) { if(itr->ThreadId == dwThreadId) @@ -182,7 +183,7 @@ bool ThreadSetName(DWORD dwThreadId, const char* name) HANDLE ThreadGetHandle(DWORD dwThreadId) { - EXCLUSIVE_ACQUIRE(LockThreads); + SHARED_ACQUIRE(LockThreads); for(auto itr = threadList.begin(); itr != threadList.end(); itr++) { @@ -197,16 +198,24 @@ HANDLE ThreadGetHandle(DWORD dwThreadId) DWORD ThreadGetId(HANDLE hThread) { - EXCLUSIVE_ACQUIRE(LockThreads); + SHARED_ACQUIRE(LockThreads); + // Search for the ID in the local list for(auto itr = threadList.begin(); itr != threadList.end(); itr++) { if(itr->Handle == hThread) return itr->ThreadId; } + // Wasn't found, check with Windows + // This also returns 0 on error + /* + REQUIRES VISTA+ + + return GetThreadId(hThread); + */ + // TODO: Same problem with threadgethandle() - // TODO: Different handles can map to the same thread return 0; } @@ -217,7 +226,10 @@ int ThreadGetCount() int ThreadSuspendAll() { - EXCLUSIVE_ACQUIRE(LockThreads); + // + // SuspendThread does not modify any internal variables + // + SHARED_ACQUIRE(LockThreads); int count = 0; for(auto itr = threadList.begin(); itr != threadList.end(); itr++) @@ -231,6 +243,9 @@ int ThreadSuspendAll() int ThreadResumeAll() { + // + // ResumeThread does not modify any internal variables + // EXCLUSIVE_ACQUIRE(LockThreads); int count = 0; diff --git a/x64_dbg_dbg/threading.cpp b/x64_dbg_dbg/threading.cpp index 8c303968..fbe0cfa9 100644 --- a/x64_dbg_dbg/threading.cpp +++ b/x64_dbg_dbg/threading.cpp @@ -29,7 +29,7 @@ bool waitislocked(WAIT_ID id) } bool CriticalSectionLocker::m_Initialized = false; -CRITICAL_SECTION CriticalSectionLocker::m_Locks[LockLast]; +SRWLOCK CriticalSectionLocker::m_Locks[LockLast]; void CriticalSectionLocker::Initialize() { @@ -40,7 +40,7 @@ void CriticalSectionLocker::Initialize() memset(m_Locks, 0, sizeof(m_Locks)); for(int i = 0; i < LockLast; i++) - InitializeCriticalSection(&m_Locks[i]); + InitializeSRWLock(&m_Locks[i]); m_Initialized = true; } @@ -53,28 +53,28 @@ void CriticalSectionLocker::Deinitialize() for(int i = 0; i < LockLast; i++) { // Wait for the lock's ownership to be released - EnterCriticalSection(&m_Locks[i]); - LeaveCriticalSection(&m_Locks[i]); + AcquireSRWLockExclusive(&m_Locks[i]); + ReleaseSRWLockExclusive(&m_Locks[i]); - // Render the lock data invalid - DeleteCriticalSection(&m_Locks[i]); + // Invalidate data + memset(&m_Locks[i], 0, sizeof(SRWLOCK)); } m_Initialized = false; } -CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock LockIndex) +CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock LockIndex, bool Shared) { - m_Section = &m_Locks[LockIndex]; + m_Lock = &m_Locks[LockIndex]; m_LockCount = 0; - Lock(); + Lock(Shared); } CriticalSectionLocker::~CriticalSectionLocker() { if(m_LockCount > 0) - LeaveCriticalSection(m_Section); + Unlock(); // TODO: Assert that the lock count is zero on destructor } @@ -82,24 +82,20 @@ CriticalSectionLocker::~CriticalSectionLocker() void CriticalSectionLocker::Unlock() { m_LockCount--; - LeaveCriticalSection(m_Section); + + if(m_Shared) + ReleaseSRWLockShared(m_Lock); + else + ReleaseSRWLockExclusive(m_Lock); } -void CriticalSectionLocker::Lock() +void CriticalSectionLocker::Lock(bool Shared) { - EnterCriticalSection(m_Section); + if(Shared) + AcquireSRWLockShared(m_Lock); + else + AcquireSRWLockExclusive(m_Lock); + + m_Shared = Shared; m_LockCount++; -} - -bool CriticalSectionLocker::TryLock() -{ - // Only enter the critical section if it's currently owned by the - // thread, or if it is not being used at all - if(TryEnterCriticalSection(m_Section)) - { - Lock(); - return true; - } - - return false; } \ No newline at end of file diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 512116a4..061bc43f 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -18,9 +18,19 @@ void lock(WAIT_ID id); void unlock(WAIT_ID id); bool waitislocked(WAIT_ID id); -#define EXCLUSIVE_ACQUIRE(Index) CriticalSectionLocker __ThreadLock(Index); +// +// THREAD SYNCHRONIZATION +// +// Better, but requires VISTA+ +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa904937%28v=vs.85%29.aspx +// + +#define EXCLUSIVE_ACQUIRE(Index) CriticalSectionLocker __ThreadLock(Index, false); #define EXCLUSIVE_RELEASE() __ThreadLock.Unlock(); +#define SHARED_ACQUIRE(Index) CriticalSectionLocker __SThreadLock(Index, true); +#define SHARED_RELEASE() __SThreadLock.Unlock(); + enum CriticalSectionLock { LockMemoryPages, @@ -44,18 +54,18 @@ public: static void Initialize(); static void Deinitialize(); - CriticalSectionLocker(CriticalSectionLock LockIndex); + CriticalSectionLocker(CriticalSectionLock LockIndex, bool Shared); ~CriticalSectionLocker(); void Unlock(); - void Lock(); - bool TryLock(); + void Lock(bool Shared); private: static bool m_Initialized; - static CRITICAL_SECTION m_Locks[LockLast]; + static SRWLOCK m_Locks[LockLast]; - CRITICAL_SECTION* m_Section; + SRWLOCK* m_Lock; + bool m_Shared; BYTE m_LockCount; }; From c36f4708a7fdc84d8e84b73c4b9d747dbc407975 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 11 Mar 2015 19:16:22 -0400 Subject: [PATCH 041/106] Refactor bookmark.cpp --- x64_dbg_dbg/bookmark.cpp | 199 +++++++++++++++++++++++---------------- x64_dbg_dbg/threading.h | 8 +- 2 files changed, 124 insertions(+), 83 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 7f66977d..39785f54 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -10,153 +10,188 @@ static BookmarksInfo bookmarks; bool bookmarkset(uint addr, bool manual) { - if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr)) + // CHECK: Export call + if(!DbgIsDebugging()) return false; + + // Validate the incoming address + if(!memisvalidreadptr(fdProcessInfo->hProcess, addr)) + return false; + BOOKMARKSINFO bookmark; modnamefromaddr(addr, bookmark.mod, true); - bookmark.addr = addr - modbasefromaddr(addr); + bookmark.addr = addr - modbasefromaddr(addr); bookmark.manual = manual; - CriticalSectionLocker locker(LockBookmarks); + + // Exclusive lock to insert new data + EXCLUSIVE_ACQUIRE(LockBookmarks); + if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second) return bookmarkdel(addr); + return true; } bool bookmarkget(uint addr) { - if(!DbgIsDebugging()) - return false; - CriticalSectionLocker locker(LockBookmarks); - if(bookmarks.count(modhashfromva(addr))) - return true; - return false; + SHARED_ACQUIRE(LockBookmarks); + return (bookmarks.count(modhashfromva(addr)) > 0); } bool bookmarkdel(uint addr) { + // CHECK: Export call if(!DbgIsDebugging()) return false; - CriticalSectionLocker locker(LockBookmarks); + + EXCLUSIVE_ACQUIRE(LockBookmarks); return (bookmarks.erase(modhashfromva(addr)) > 0); } void bookmarkdelrange(uint start, uint end) { + // CHECK: Export call if(!DbgIsDebugging()) return; - bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) - return; - start -= modbase; - end -= modbase; - CriticalSectionLocker locker(LockBookmarks); - BookmarksInfo::iterator i = bookmarks.begin(); - while(i != bookmarks.end()) + + // Are all bookmarks going to be deleted? + if(start == 0x00000000 && end == 0xFFFFFFFF) { - if(i->second.manual) //ignore manual + EXCLUSIVE_ACQUIRE(LockBookmarks); + bookmarks.clear(); + } + else + { + // Make sure 'start' and 'end' reference the same module + uint modbase = modbasefromaddr(start); + + if(modbase != modbasefromaddr(end)) + return; + + start -= modbase; + end -= modbase; + + EXCLUSIVE_ACQUIRE(LockBookmarks); + for(auto itr = bookmarks.begin(); itr != bookmarks.end();) { - i++; - continue; + // Ignore manually set entries + if(itr->second.manual) + { + itr++; + continue; + } + + if(itr->second.addr >= start && itr->second.addr < end) + bookmarks.erase(itr); + + itr++; } - if(bDelAll || (i->second.addr >= start && i->second.addr < end)) - bookmarks.erase(i++); - else - i++; } } void bookmarkcachesave(JSON root) { - CriticalSectionLocker locker(LockBookmarks); - const JSON jsonbookmarks = json_array(); - const JSON jsonautobookmarks = json_array(); - for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i) + EXCLUSIVE_ACQUIRE(LockBookmarks); + + const JSON jsonbookmarks = json_array(); + const JSON jsonautobookmarks = json_array(); + + // Save to the JSON root + for(auto itr = bookmarks.begin(); itr != bookmarks.end(); itr++) { - const BOOKMARKSINFO curBookmark = i->second; JSON curjsonbookmark = json_object(); - json_object_set_new(curjsonbookmark, "module", json_string(curBookmark.mod)); - json_object_set_new(curjsonbookmark, "address", json_hex(curBookmark.addr)); - if(curBookmark.manual) + + json_object_set_new(curjsonbookmark, "module", json_string(itr->second.mod)); + json_object_set_new(curjsonbookmark, "address", json_hex(itr->second.addr)); + + if(itr->second.manual) json_array_append_new(jsonbookmarks, curjsonbookmark); else json_array_append_new(jsonautobookmarks, curjsonbookmark); } + if(json_array_size(jsonbookmarks)) json_object_set(root, "bookmarks", jsonbookmarks); - json_decref(jsonbookmarks); + if(json_array_size(jsonautobookmarks)) json_object_set(root, "autobookmarks", jsonautobookmarks); + + json_decref(jsonbookmarks); json_decref(jsonautobookmarks); } void bookmarkcacheload(JSON root) { - CriticalSectionLocker locker(LockBookmarks); + EXCLUSIVE_ACQUIRE(LockBookmarks); + + auto AddBookmarks = [](const JSON Object, bool Manual) + { + size_t i; + JSON value; + + json_array_foreach(Object, i, value) + { + BOOKMARKSINFO bookmarkInfo; + memset(&bookmarkInfo, 0, sizeof(BOOKMARKSINFO)); + + // Load the module name + const char* mod = json_string_value(json_object_get(value, "module")); + + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy_s(bookmarkInfo.mod, mod); + + // Load address and set auto-generated flag + bookmarkInfo.addr = (uint)json_hex_value(json_object_get(value, "address")); + bookmarkInfo.manual = Manual; + + const uint key = modhashfromname(bookmarkInfo.mod) + bookmarkInfo.addr; + bookmarks.insert(std::make_pair(key, bookmarkInfo)); + } + }; + + // Remove existing entries bookmarks.clear(); - const JSON jsonbookmarks = json_object_get(root, "bookmarks"); + + const JSON jsonbookmarks = json_object_get(root, "bookmarks"); + const JSON jsonautobookmarks = json_object_get(root, "autobookmarks"); + + // Load user-set bookmarks if(jsonbookmarks) - { - size_t i; - JSON value; - json_array_foreach(jsonbookmarks, i, value) - { - BOOKMARKSINFO curBookmark; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(curBookmark.mod, mod); - else - *curBookmark.mod = '\0'; - curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); - curBookmark.manual = true; - const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; - bookmarks.insert(std::make_pair(key, curBookmark)); - } - } - JSON jsonautobookmarks = json_object_get(root, "autobookmarks"); + AddBookmarks(jsonbookmarks, true); + + // Load auto-set bookmarks if(jsonautobookmarks) - { - size_t i; - JSON value; - json_array_foreach(jsonautobookmarks, i, value) - { - BOOKMARKSINFO curBookmark; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(curBookmark.mod, mod); - else - *curBookmark.mod = '\0'; - curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); - curBookmark.manual = false; - const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; - bookmarks.insert(std::make_pair(key, curBookmark)); - } - } + AddBookmarks(jsonbookmarks, false); } bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) { - if(!DbgIsDebugging()) - return false; + // The array container must be set, or the size must be set, or both if(!bookmarklist && !cbsize) return false; - CriticalSectionLocker locker(LockBookmarks); - if(!bookmarklist && cbsize) + + SHARED_ACQUIRE(LockBookmarks); + + // Return the size if set + if(cbsize) { *cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO); return true; } - int j = 0; - for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i, j++) + + // TODO: only ModBaseFromName seems wrong + for(auto itr = bookmarks.begin(); itr != bookmarks.end(); itr++, bookmarklist++) { - bookmarklist[j] = i->second; - bookmarklist[j].addr += modbasefromname(bookmarklist[j].mod); + *bookmarklist = itr->second; + bookmarklist->addr += modbasefromname(bookmarklist->mod); } + return true; } void bookmarkclear() { - CriticalSectionLocker locker(LockBookmarks); - BookmarksInfo().swap(bookmarks); + EXCLUSIVE_ACQUIRE(LockBookmarks); + + bookmarks.clear(); } \ No newline at end of file diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 061bc43f..ce534ed5 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -24,7 +24,6 @@ bool waitislocked(WAIT_ID id); // Better, but requires VISTA+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa904937%28v=vs.85%29.aspx // - #define EXCLUSIVE_ACQUIRE(Index) CriticalSectionLocker __ThreadLock(Index, false); #define EXCLUSIVE_RELEASE() __ThreadLock.Unlock(); @@ -45,6 +44,13 @@ enum CriticalSectionLock LockPatches, LockThreads, LockDprintf, + + // This is defined because of a bug in the Windows 8.1 kernel; + // Calling VirtualQuery/VirtualProtect/ReadProcessMemory can and will cause + // a deadlock. + // https://bitbucket.org/mrexodia/x64_dbg/issue/247/x64-dbg-bug-string-references-function + LockWin8Workaround, + LockLast }; From c84b2e40c8c7c6e30b4db8a96e3363d2614dd0ee Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 15 Mar 2015 21:27:35 -0400 Subject: [PATCH 042/106] VS2013 project --- x64_dbg_bridge/x64_dbg_bridge.vcxproj | 2 ++ x64_dbg_dbg/x64_dbg_dbg.vcxproj | 2 ++ x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters | 4 ---- x64_dbg_exe/x64_dbg_exe.vcxproj | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x64_dbg_bridge/x64_dbg_bridge.vcxproj b/x64_dbg_bridge/x64_dbg_bridge.vcxproj index a68af05d..06f3aef2 100644 --- a/x64_dbg_bridge/x64_dbg_bridge.vcxproj +++ b/x64_dbg_bridge/x64_dbg_bridge.vcxproj @@ -27,10 +27,12 @@ DynamicLibrary false + v120 DynamicLibrary false + v120 diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 0f88f150..92324802 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -122,10 +122,12 @@ DynamicLibrary false + v120 DynamicLibrary false + v120 diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 2538b0a5..ec5e4f57 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -9,10 +9,6 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - {44fd9eb7-2017-49b8-8d9a-dec680632343} diff --git a/x64_dbg_exe/x64_dbg_exe.vcxproj b/x64_dbg_exe/x64_dbg_exe.vcxproj index 4e831d7c..f6e1706e 100644 --- a/x64_dbg_exe/x64_dbg_exe.vcxproj +++ b/x64_dbg_exe/x64_dbg_exe.vcxproj @@ -31,10 +31,12 @@ Application false + v120 Application false + v120 From 3d454323e4a3d1cdf9946babbfc4d6e6ccb4a83e Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 15 Mar 2015 21:30:12 -0400 Subject: [PATCH 043/106] More module refactoring/de-duplication --- x64_dbg_dbg/_dbgfunctions.cpp | 14 +- x64_dbg_dbg/_exports.cpp | 5 +- x64_dbg_dbg/addrinfo.cpp | 2 +- x64_dbg_dbg/bookmark.cpp | 18 +-- x64_dbg_dbg/breakpoint.cpp | 26 ++-- x64_dbg_dbg/comment.cpp | 20 +-- x64_dbg_dbg/debugger.cpp | 24 ++-- x64_dbg_dbg/debugger_commands.cpp | 12 +- x64_dbg_dbg/function.cpp | 34 ++--- x64_dbg_dbg/label.cpp | 24 ++-- x64_dbg_dbg/loop.cpp | 56 +++++--- x64_dbg_dbg/memory.cpp | 6 +- x64_dbg_dbg/module.cpp | 227 ++++++++++++++++-------------- x64_dbg_dbg/module.h | 59 ++++---- x64_dbg_dbg/patches.cpp | 22 +-- x64_dbg_dbg/reference.cpp | 2 +- x64_dbg_dbg/stackinfo.cpp | 10 +- x64_dbg_dbg/symbolinfo.cpp | 4 +- x64_dbg_dbg/thread.cpp | 147 +++++++++---------- x64_dbg_dbg/thread.h | 22 +-- x64_dbg_dbg/value.cpp | 12 +- 21 files changed, 389 insertions(+), 357 deletions(-) diff --git a/x64_dbg_dbg/_dbgfunctions.cpp b/x64_dbg_dbg/_dbgfunctions.cpp index 57bc9934..a7c75063 100644 --- a/x64_dbg_dbg/_dbgfunctions.cpp +++ b/x64_dbg_dbg/_dbgfunctions.cpp @@ -24,7 +24,7 @@ static bool _assembleatex(duint addr, const char* instruction, char* error, bool static bool _sectionfromaddr(duint addr, char* section) { - HMODULE hMod = (HMODULE)modbasefromaddr(addr); + HMODULE hMod = (HMODULE)ModBaseFromAddr(addr); if(!hMod) return false; wchar_t curModPath[MAX_PATH] = L""; @@ -169,10 +169,10 @@ void dbgfunctionsinit() { _dbgfunctions.AssembleAtEx = _assembleatex; _dbgfunctions.SectionFromAddr = _sectionfromaddr; - _dbgfunctions.ModNameFromAddr = modnamefromaddr; - _dbgfunctions.ModBaseFromAddr = modbasefromaddr; - _dbgfunctions.ModBaseFromName = modbasefromname; - _dbgfunctions.ModSizeFromAddr = modsizefromaddr; + _dbgfunctions.ModNameFromAddr = ModNameFromAddr; + _dbgfunctions.ModBaseFromAddr = ModBaseFromAddr; + _dbgfunctions.ModBaseFromName = ModBaseFromName; + _dbgfunctions.ModSizeFromAddr = ModSizeFromAddr; _dbgfunctions.Assemble = assemble; _dbgfunctions.PatchGet = _patchget; _dbgfunctions.PatchInRange = _patchinrange; @@ -181,8 +181,8 @@ void dbgfunctionsinit() _dbgfunctions.PatchEnum = (PATCHENUM)patchenum; _dbgfunctions.PatchRestore = _patchrestore; _dbgfunctions.PatchFile = (PATCHFILE)patchfile; - _dbgfunctions.ModPathFromAddr = modpathfromaddr; - _dbgfunctions.ModPathFromName = modpathfromname; + _dbgfunctions.ModPathFromAddr = ModPathFromAddr; + _dbgfunctions.ModPathFromName = ModPathFromName; _dbgfunctions.DisasmFast = disasmfast; _dbgfunctions.MemUpdateMap = _memupdatemap; _dbgfunctions.GetCallStack = _getcallstack; diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index 8c7c46ac..a166eb95 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -69,6 +69,7 @@ extern "C" DLL_EXPORT bool _dbg_isdebugging() { if(IsFileBeingDebugged()) return true; + return false; } @@ -93,7 +94,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR bool retval = false; if(addrinfo->flags & flagmodule) //get module { - if(modnamefromaddr(addr, addrinfo->module, false)) //get module name + if(ModNameFromAddr(addr, addrinfo->module, false)) //get module name retval = true; } if(addrinfo->flags & flaglabel) @@ -701,7 +702,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_MODBASE_FROM_NAME: { - return modbasefromname((const char*)param1); + return ModBaseFromName((const char*)param1); } break; diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index b49f2d87..07f4b451 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -123,7 +123,7 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum) if(!export_dir.NumberOfFunctions or !NumberOfNames) //no named exports return false; char modname[MAX_MODULE_SIZE] = ""; - modnamefromaddr(base, modname, true); + ModNameFromAddr(base, modname, true); uint original_name_va = export_dir.Name + base; char original_name[deflen] = ""; memset(original_name, 0, sizeof(original_name)); diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 39785f54..fae3011a 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -19,14 +19,14 @@ bool bookmarkset(uint addr, bool manual) return false; BOOKMARKSINFO bookmark; - modnamefromaddr(addr, bookmark.mod, true); - bookmark.addr = addr - modbasefromaddr(addr); + ModNameFromAddr(addr, bookmark.mod, true); + bookmark.addr = addr - ModBaseFromAddr(addr); bookmark.manual = manual; // Exclusive lock to insert new data EXCLUSIVE_ACQUIRE(LockBookmarks); - if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second) + if(!bookmarks.insert(std::make_pair(ModHashFromAddr(addr), bookmark)).second) return bookmarkdel(addr); return true; @@ -35,7 +35,7 @@ bool bookmarkset(uint addr, bool manual) bool bookmarkget(uint addr) { SHARED_ACQUIRE(LockBookmarks); - return (bookmarks.count(modhashfromva(addr)) > 0); + return (bookmarks.count(ModHashFromAddr(addr)) > 0); } bool bookmarkdel(uint addr) @@ -45,7 +45,7 @@ bool bookmarkdel(uint addr) return false; EXCLUSIVE_ACQUIRE(LockBookmarks); - return (bookmarks.erase(modhashfromva(addr)) > 0); + return (bookmarks.erase(ModHashFromAddr(addr)) > 0); } void bookmarkdelrange(uint start, uint end) @@ -63,9 +63,9 @@ void bookmarkdelrange(uint start, uint end) else { // Make sure 'start' and 'end' reference the same module - uint modbase = modbasefromaddr(start); + uint modbase = ModBaseFromAddr(start); - if(modbase != modbasefromaddr(end)) + if(modbase != ModBaseFromAddr(end)) return; start -= modbase; @@ -144,7 +144,7 @@ void bookmarkcacheload(JSON root) bookmarkInfo.addr = (uint)json_hex_value(json_object_get(value, "address")); bookmarkInfo.manual = Manual; - const uint key = modhashfromname(bookmarkInfo.mod) + bookmarkInfo.addr; + const uint key = ModHashFromName(bookmarkInfo.mod) + bookmarkInfo.addr; bookmarks.insert(std::make_pair(key, bookmarkInfo)); } }; @@ -183,7 +183,7 @@ bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) for(auto itr = bookmarks.begin(); itr != bookmarks.end(); itr++, bookmarklist++) { *bookmarklist = itr->second; - bookmarklist->addr += modbasefromname(bookmarklist->mod); + bookmarklist->addr += ModBaseFromName(bookmarklist->mod); } return true; diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index f673d0f1..bc9bcd56 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -21,7 +21,7 @@ int bpgetlist(std::vector* list) for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) { curBp = i->second; - curBp.addr += modbasefromname(curBp.mod); + curBp.addr += ModBaseFromName(curBp.mod); curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); count++; if(list) @@ -35,8 +35,8 @@ bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE ty if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or bpget(addr, type, name, 0)) return false; BREAKPOINT bp; - modnamefromaddr(addr, bp.mod, true); - uint modbase = modbasefromaddr(addr); + ModNameFromAddr(addr, bp.mod, true); + uint modbase = ModBaseFromAddr(addr); bp.active = true; bp.addr = addr - modbase; bp.enabled = enabled; @@ -49,7 +49,7 @@ bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE ty bp.titantype = titantype; bp.type = type; CriticalSectionLocker locker(LockBreakpoints); - breakpoints.insert(std::make_pair(BreakpointKey(type, modhashfromva(addr)), bp)); + breakpoints.insert(std::make_pair(BreakpointKey(type, ModHashFromAddr(addr)), bp)); return true; } @@ -61,13 +61,13 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp) CriticalSectionLocker locker(LockBreakpoints); if(!name) { - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); if(found == breakpoints.end()) //not found return false; if(!bp) return true; curBp = found->second; - curBp.addr += modbasefromaddr(addr); + curBp.addr += ModBaseFromAddr(addr); curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); *bp = curBp; return true; @@ -81,7 +81,7 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp) { if(bp) { - curBp.addr += modbasefromname(curBp.mod); + curBp.addr += ModBaseFromName(curBp.mod); curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); *bp = curBp; } @@ -97,7 +97,7 @@ bool bpdel(uint addr, BP_TYPE type) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockBreakpoints); - return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0); + return (breakpoints.erase(BreakpointKey(type, ModHashFromAddr(addr))) > 0); } bool bpenable(uint addr, BP_TYPE type, bool enable) @@ -105,7 +105,7 @@ bool bpenable(uint addr, BP_TYPE type, bool enable) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); if(found == breakpoints.end()) //not found return false; breakpoints[found->first].enabled = enable; @@ -117,7 +117,7 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name) if(!DbgIsDebugging() or !name or !*name) return false; CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); if(found == breakpoints.end()) //not found return false; strcpy_s(breakpoints[found->first].name, name); @@ -129,7 +129,7 @@ bool bpsettitantype(uint addr, BP_TYPE type, int titantype) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); if(found == breakpoints.end()) //not found return false; breakpoints[found->first].titantype = titantype; @@ -149,7 +149,7 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module) BreakpointsInfo::iterator j = i; ++i; curBp = j->second; - curBp.addr += modbasefromname(curBp.mod); //RVA to VA + curBp.addr += ModBaseFromName(curBp.mod); //RVA to VA curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing? if(module and * module) { @@ -263,7 +263,7 @@ void bpcacheload(JSON root) const char* mod = json_string_value(json_object_get(value, "module")); if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) strcpy_s(curBreakpoint.mod, mod); - const uint key = modhashfromname(curBreakpoint.mod) + curBreakpoint.addr; + const uint key = ModHashFromName(curBreakpoint.mod) + curBreakpoint.addr; breakpoints.insert(std::make_pair(BreakpointKey(curBreakpoint.type, key), curBreakpoint)); } } diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index ab9c1db8..a42b5940 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -20,9 +20,9 @@ bool commentset(uint addr, const char* text, bool manual) COMMENTSINFO comment; comment.manual = manual; strcpy_s(comment.text, text); - modnamefromaddr(addr, comment.mod, true); - comment.addr = addr - modbasefromaddr(addr); - const uint key = modhashfromva(addr); + ModNameFromAddr(addr, comment.mod, true); + comment.addr = addr - ModBaseFromAddr(addr); + const uint key = ModHashFromAddr(addr); CriticalSectionLocker locker(LockComments); if(!comments.insert(std::make_pair(key, comment)).second) //key already present comments[key] = comment; @@ -34,7 +34,7 @@ bool commentget(uint addr, char* text) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockComments); - const CommentsInfo::iterator found = comments.find(modhashfromva(addr)); + const CommentsInfo::iterator found = comments.find(ModHashFromAddr(addr)); if(found == comments.end()) //not found return false; strcpy_s(text, MAX_COMMENT_SIZE, found->second.text); @@ -46,7 +46,7 @@ bool commentdel(uint addr) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockComments); - return (comments.erase(modhashfromva(addr)) == 1); + return (comments.erase(ModHashFromAddr(addr)) == 1); } void commentdelrange(uint start, uint end) @@ -54,8 +54,8 @@ void commentdelrange(uint start, uint end) if(!DbgIsDebugging()) return; bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) + uint modbase = ModBaseFromAddr(start); + if(modbase != ModBaseFromAddr(end)) return; start -= modbase; end -= modbase; @@ -124,7 +124,7 @@ void commentcacheload(JSON root) strcpy_s(curComment.text, text); else continue; //skip - const uint key = modhashfromname(curComment.mod) + curComment.addr; + const uint key = ModHashFromName(curComment.mod) + curComment.addr; comments.insert(std::make_pair(key, curComment)); } } @@ -148,7 +148,7 @@ void commentcacheload(JSON root) strcpy_s(curComment.text, text); else continue; //skip - const uint key = modhashfromname(curComment.mod) + curComment.addr; + const uint key = ModHashFromName(curComment.mod) + curComment.addr; comments.insert(std::make_pair(key, curComment)); } } @@ -170,7 +170,7 @@ bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize) for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i, j++) { commentlist[j] = i->second; - commentlist[j].addr += modbasefromname(commentlist[j].mod); + commentlist[j].addr += ModBaseFromName(commentlist[j].mod); } return true; } diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 4c744b4d..d2e59f15 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -198,7 +198,7 @@ void DebugUpdateGui(uint disasm_addr, bool stack) } char modname[MAX_MODULE_SIZE] = ""; char modtext[MAX_MODULE_SIZE * 2] = ""; - if(!modnamefromaddr(disasm_addr, modname, true)) + if(!ModNameFromAddr(disasm_addr, modname, true)) *modname = 0; else sprintf(modtext, "Module: %s - ", modname); @@ -637,7 +637,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) dbggetprivateusage(fdProcessInfo->hProcess, true); memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; - if(modnamefromaddr((uint)base, modname, true)) + if(ModNameFromAddr((uint)base, modname, true)) bpenumall(cbSetModuleBreakpoints, modname); GuiUpdateBreakpointsView(); if(!bFileIsDll and !bIsAttached) //Set entry breakpoint @@ -688,7 +688,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) threadInfo.hThread = CreateProcessInfo->hThread; threadInfo.lpStartAddress = CreateProcessInfo->lpStartAddress; threadInfo.lpThreadLocalBase = CreateProcessInfo->lpThreadLocalBase; - threadcreate(&threadInfo); + ThreadCreate(&threadInfo); } static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess) @@ -702,7 +702,7 @@ static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess) static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) { - threadcreate(CreateThread); //update thread list + ThreadCreate(CreateThread); //update thread list DWORD dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; hActiveThread = ThreadGetHandle(dwThreadId); @@ -745,7 +745,7 @@ static void cbExitThread(EXIT_THREAD_DEBUG_INFO* ExitThread) callbackInfo.ExitThread = ExitThread; callbackInfo.dwThreadId = dwThreadId; plugincbcall(CB_EXITTHREAD, &callbackInfo); - threadexit(dwThreadId); + ThreadExit(dwThreadId); dprintf("Thread %X exit\n", dwThreadId); if(settingboolget("Events", "ThreadEnd")) @@ -817,7 +817,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) dbggetprivateusage(fdProcessInfo->hProcess, true); memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; - if(modnamefromaddr((uint)base, modname, true)) + if(ModNameFromAddr((uint)base, modname, true)) bpenumall(cbSetModuleBreakpoints, modname); GuiUpdateBreakpointsView(); bool bAlreadySetEntry = false; @@ -907,7 +907,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) void* base = UnloadDll->lpBaseOfDll; char modname[256] = "???"; - if(modnamefromaddr((uint)base, modname, true)) + if(ModNameFromAddr((uint)base, modname, true)) bpenumall(cbRemoveModuleBreakpoints, modname); GuiUpdateBreakpointsView(); SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base); @@ -928,7 +928,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) wait(WAITID_RUN); } - modunload((uint)base); + ModUnload((uint)base); } static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) @@ -1151,8 +1151,8 @@ DWORD WINAPI threadDebugLoop(void* lpParameter) RemoveAllBreakPoints(UE_OPTION_REMOVEALL); //remove all breakpoints //cleanup dbclose(); - modclear(); - threadclear(); + ModClear(); + ThreadClear(); GuiSetDebugState(stopped); dputs("debugging stopped!"); varset("$hp", (uint)0, true); @@ -1367,8 +1367,8 @@ DWORD WINAPI threadAttachLoop(void* lpParameter) RemoveAllBreakPoints(UE_OPTION_REMOVEALL); //remove all breakpoints //cleanup dbclose(); - modclear(); - threadclear(); + ModClear(); + ThreadClear(); GuiSetDebugState(stopped); dputs("debugging stopped!"); varset("$hp", (uint)0, true); diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index ed586f34..890df723 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -1119,18 +1119,16 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[]) CMDRESULT cbDebugSuspendAllThreads(int argc, char* argv[]) { - int threadCount = ThreadGetCount(); - int suspendedCount = ThreadSuspendAll(); - dprintf("%d/%d thread(s) suspended\n", suspendedCount, threadCount); + dprintf("%d/%d thread(s) suspended\n", ThreadSuspendAll(), ThreadGetCount()); + GuiUpdateAllViews(); return STATUS_CONTINUE; } CMDRESULT cbDebugResumeAllThreads(int argc, char* argv[]) { - int threadCount = ThreadGetCount(); - int resumeCount = ThreadResumeAll(); - dprintf("%d/%d thread(s) resumed\n", resumeCount, threadCount); + dprintf("%d/%d thread(s) resumed\n", ThreadResumeAll(), ThreadGetCount()); + GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1390,7 +1388,7 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) return STATUS_CONTINUE; } //get some module information - uint modbase = modbasefromname(argv[1]); + uint modbase = ModBaseFromName(argv[1]); if(!modbase) { dprintf("Invalid module \"%s\"!\n", argv[1]); diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp index cc5406d6..e24c01e5 100644 --- a/x64_dbg_dbg/function.cpp +++ b/x64_dbg_dbg/function.cpp @@ -12,18 +12,18 @@ bool functionadd(uint start, uint end, bool manual) { if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) return false; - const uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same module + const uint modbase = ModBaseFromAddr(start); + if(modbase != ModBaseFromAddr(end)) //the function boundaries are not in the same module return false; if(functionoverlaps(start, end)) return false; FUNCTIONSINFO function; - modnamefromaddr(start, function.mod, true); + ModNameFromAddr(start, function.mod, true); function.start = start - modbase; function.end = end - modbase; function.manual = manual; CriticalSectionLocker locker(LockFunctions); - functions.insert(std::make_pair(ModuleRange(modhashfromva(modbase), Range(function.start, function.end)), function)); + functions.insert(std::make_pair(ModuleRange(ModHashFromAddr(modbase), Range(function.start, function.end)), function)); return true; } @@ -31,9 +31,9 @@ bool functionget(uint addr, uint* start, uint* end) { if(!DbgIsDebugging()) return false; - uint modbase = modbasefromaddr(addr); + uint modbase = ModBaseFromAddr(addr); CriticalSectionLocker locker(LockFunctions); - const FunctionsInfo::iterator found = functions.find(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))); + const FunctionsInfo::iterator found = functions.find(ModuleRange(ModHashFromAddr(modbase), Range(addr - modbase, addr - modbase))); if(found == functions.end()) //not found return false; if(start) @@ -47,18 +47,18 @@ bool functionoverlaps(uint start, uint end) { if(!DbgIsDebugging() or end < start) return false; - const uint modbase = modbasefromaddr(start); + const uint modbase = ModBaseFromAddr(start); CriticalSectionLocker locker(LockFunctions); - return (functions.count(ModuleRange(modhashfromva(modbase), Range(start - modbase, end - modbase))) > 0); + return (functions.count(ModuleRange(ModHashFromAddr(modbase), Range(start - modbase, end - modbase))) > 0); } bool functiondel(uint addr) { if(!DbgIsDebugging()) return false; - const uint modbase = modbasefromaddr(addr); + const uint modbase = ModBaseFromAddr(addr); CriticalSectionLocker locker(LockFunctions); - return (functions.erase(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))) > 0); + return (functions.erase(ModuleRange(ModHashFromAddr(modbase), Range(addr - modbase, addr - modbase))) > 0); } void functiondelrange(uint start, uint end) @@ -66,8 +66,8 @@ void functiondelrange(uint start, uint end) if(!DbgIsDebugging()) return; bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) + uint modbase = ModBaseFromAddr(start); + if(modbase != ModBaseFromAddr(end)) return; start -= modbase; end -= modbase; @@ -134,8 +134,8 @@ void functioncacheload(JSON root) if(curFunction.end < curFunction.start) continue; //invalid function curFunction.manual = true; - const uint key = modhashfromname(curFunction.mod); - functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); + const uint key = ModHashFromName(curFunction.mod); + functions.insert(std::make_pair(ModuleRange(ModHashFromName(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); } } JSON jsonautofunctions = json_object_get(root, "autofunctions"); @@ -156,8 +156,8 @@ void functioncacheload(JSON root) if(curFunction.end < curFunction.start) continue; //invalid function curFunction.manual = true; - const uint key = modhashfromname(curFunction.mod); - functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); + const uint key = ModHashFromName(curFunction.mod); + functions.insert(std::make_pair(ModuleRange(ModHashFromName(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); } } } @@ -178,7 +178,7 @@ bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize) for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i, j++) { functionlist[j] = i->second; - uint modbase = modbasefromname(functionlist[j].mod); + uint modbase = ModBaseFromName(functionlist[j].mod); functionlist[j].start += modbase; functionlist[j].end += modbase; } diff --git a/x64_dbg_dbg/label.cpp b/x64_dbg_dbg/label.cpp index 9421ef7f..7f6ad248 100644 --- a/x64_dbg_dbg/label.cpp +++ b/x64_dbg_dbg/label.cpp @@ -20,11 +20,11 @@ bool labelset(uint addr, const char* text, bool manual) LABELSINFO label; label.manual = manual; strcpy_s(label.text, text); - modnamefromaddr(addr, label.mod, true); - label.addr = addr - modbasefromaddr(addr); - uint key = modhashfromva(addr); + ModNameFromAddr(addr, label.mod, true); + label.addr = addr - ModBaseFromAddr(addr); + uint key = ModHashFromAddr(addr); CriticalSectionLocker locker(LockLabels); - if(!labels.insert(std::make_pair(modhashfromva(key), label)).second) //already present + if(!labels.insert(std::make_pair(ModHashFromAddr(key), label)).second) //already present labels[key] = label; return true; } @@ -39,7 +39,7 @@ bool labelfromstring(const char* text, uint* addr) if(!strcmp(i->second.text, text)) { if(addr) - *addr = i->second.addr + modbasefromname(i->second.mod); + *addr = i->second.addr + ModBaseFromName(i->second.mod); return true; } } @@ -51,7 +51,7 @@ bool labelget(uint addr, char* text) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockLabels); - const LabelsInfo::iterator found = labels.find(modhashfromva(addr)); + const LabelsInfo::iterator found = labels.find(ModHashFromAddr(addr)); if(found == labels.end()) //not found return false; if(text) @@ -64,7 +64,7 @@ bool labeldel(uint addr) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockLabels); - return (labels.erase(modhashfromva(addr)) > 0); + return (labels.erase(ModHashFromAddr(addr)) > 0); } void labeldelrange(uint start, uint end) @@ -72,8 +72,8 @@ void labeldelrange(uint start, uint end) if(!DbgIsDebugging()) return; bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) + uint modbase = ModBaseFromAddr(start); + if(modbase != ModBaseFromAddr(end)) return; start -= modbase; end -= modbase; @@ -146,7 +146,7 @@ void labelcacheload(JSON root) for(int i = 0; i < len; i++) if(curLabel.text[i] == '&') curLabel.text[i] = ' '; - const uint key = modhashfromname(curLabel.mod) + curLabel.addr; + const uint key = ModHashFromName(curLabel.mod) + curLabel.addr; labels.insert(std::make_pair(key, curLabel)); } } @@ -170,7 +170,7 @@ void labelcacheload(JSON root) strcpy_s(curLabel.text, text); else continue; //skip - const uint key = modhashfromname(curLabel.mod) + curLabel.addr; + const uint key = ModHashFromName(curLabel.mod) + curLabel.addr; labels.insert(std::make_pair(key, curLabel)); } } @@ -192,7 +192,7 @@ bool labelenum(LABELSINFO* labellist, size_t* cbsize) for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i, j++) { labellist[j] = i->second; - labellist[j].addr += modbasefromname(labellist[j].mod); + labellist[j].addr += ModBaseFromName(labellist[j].mod); } return true; } diff --git a/x64_dbg_dbg/loop.cpp b/x64_dbg_dbg/loop.cpp index a390513d..584c3403 100644 --- a/x64_dbg_dbg/loop.cpp +++ b/x64_dbg_dbg/loop.cpp @@ -12,14 +12,14 @@ bool loopadd(uint start, uint end, bool manual) { if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) return false; - const uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same mem page + const uint modbase = ModBaseFromAddr(start); + if(modbase != ModBaseFromAddr(end)) //the function boundaries are not in the same mem page return false; int finaldepth; if(loopoverlaps(0, start, end, &finaldepth)) //loop cannot overlap another loop return false; LOOPSINFO loop; - modnamefromaddr(start, loop.mod, true); + ModNameFromAddr(start, loop.mod, true); loop.start = start - modbase; loop.end = end - modbase; loop.depth = finaldepth; @@ -29,7 +29,7 @@ bool loopadd(uint start, uint end, bool manual) loop.parent = 0; loop.manual = manual; CriticalSectionLocker locker(LockLoops); - loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(modhashfromva(modbase), Range(loop.start, loop.end))), loop)); + loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(ModHashFromAddr(modbase), Range(loop.start, loop.end))), loop)); return true; } @@ -38,9 +38,9 @@ bool loopget(int depth, uint addr, uint* start, uint* end) { if(!DbgIsDebugging()) return false; - const uint modbase = modbasefromaddr(addr); + const uint modbase = ModBaseFromAddr(addr); CriticalSectionLocker locker(LockLoops); - LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase)))); + LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(ModHashFromAddr(modbase), Range(addr - modbase, addr - modbase)))); if(found == loops.end()) //not found return false; if(start) @@ -56,10 +56,10 @@ bool loopoverlaps(int depth, uint start, uint end, int* finaldepth) if(!DbgIsDebugging()) return false; - const uint modbase = modbasefromaddr(start); + const uint modbase = ModBaseFromAddr(start); uint curStart = start - modbase; uint curEnd = end - modbase; - const uint key = modhashfromva(modbase); + const uint key = ModHashFromAddr(modbase); CriticalSectionLocker locker(LockLoops); @@ -145,7 +145,7 @@ void loopcacheload(JSON root) if(curLoop.end < curLoop.start) continue; //invalid loop curLoop.manual = true; - loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); + loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(ModHashFromName(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); } } JSON jsonautoloops = json_object_get(root, "autoloops"); @@ -168,36 +168,46 @@ void loopcacheload(JSON root) if(curLoop.end < curLoop.start) continue; //invalid loop curLoop.manual = false; - loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); + loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(ModHashFromName(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); } } } bool loopenum(LOOPSINFO* looplist, size_t* cbsize) { - if(!DbgIsDebugging()) - return false; + // If looplist or size is not requested, fail if(!looplist && !cbsize) return false; - CriticalSectionLocker locker(LockLoops); - if(!looplist && cbsize) + + SHARED_ACQUIRE(LockLoops); + + // See if the caller requested an output size + if(cbsize) { *cbsize = loops.size() * sizeof(LOOPSINFO); - return true; + + if(!looplist) + return true; } - int j = 0; - for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i, j++) + + for(auto itr = loops.begin(); itr != loops.end(); itr++) { - looplist[j] = i->second; - uint modbase = modbasefromname(looplist[j].mod); - looplist[j].start += modbase; - looplist[j].end += modbase; + *looplist = itr->second; + + // Adjust the offset to a real virtual address + uint modbase = ModBaseFromName(looplist->mod); + looplist->start += modbase; + looplist->end += modbase; + + looplist++; } + return true; } void loopclear() { - CriticalSectionLocker locker(LockLoops); - LoopsInfo().swap(loops); + EXCLUSIVE_ACQUIRE(LockLoops); + + loops.clear(); } \ No newline at end of file diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 03074db3..5bdde6c7 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -27,7 +27,7 @@ void memupdatemap(HANDLE hProcess) curAllocationBase = (uint)mbi.AllocationBase; MEMPAGE curPage; *curPage.info = 0; - modnamefromaddr(MyAddress, curPage.info, true); + ModNameFromAddr(MyAddress, curPage.info, true); memcpy(&curPage.mbi, &mbi, sizeof(mbi)); pageVector.push_back(curPage); } @@ -50,11 +50,11 @@ void memupdatemap(HANDLE hProcess) if(!pageVector.at(i).info[0] || (scmp(curMod, pageVector.at(i).info) && !bListAllPages)) //there is a module continue; //skip non-modules strcpy(curMod, pageVector.at(i).info); - uint base = modbasefromname(pageVector.at(i).info); + uint base = ModBaseFromName(pageVector.at(i).info); if(!base) continue; std::vector sections; - if(!modsectionsfromaddr(base, §ions)) + if(!ModSectionsFromAddr(base, §ions)) continue; int SectionNumber = (int)sections.size(); if(!SectionNumber) //no sections = skip diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 91e82c0f..71adf766 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -6,155 +6,186 @@ static ModulesInfo modinfo; -///module functions -bool modload(uint base, uint size, const char* fullpath) +bool ModLoad(uint base, uint size, const char* fullpath) { + // + // Handle a new module being loaded + // + // TODO: Do loaded modules always require a path? if(!base or !size or !fullpath) return false; - char name[deflen] = ""; - int len = (int)strlen(fullpath); - while(fullpath[len] != '\\' and len) - len--; - if(len) - len++; - strcpy_s(name, fullpath + len); - _strlwr(name); - len = (int)strlen(name); - name[MAX_MODULE_SIZE - 1] = 0; //ignore later characters - while(name[len] != '.' and len) - len--; MODINFO info; - memset(&info, 0, sizeof(MODINFO)); - info.sections.clear(); - info.hash = modhashfromname(name); - if(len) + + // + // Break the module path into a directory and file name + // + char dir[deflen]; + char* file; + + GetFullPathNameA(fullpath, deflen, dir, &file); + + // Make everything lowercase + _strlwr(dir); + + // Copy the extension into the module struct { - strcpy_s(info.extension, name + len); - name[len] = 0; //remove extension + char* extensionPos = strrchr(file, '.'); + + if(extensionPos) + { + extensionPos[0] = '\0'; + strcpy_s(info.extension, extensionPos + 1); + } } + + // Copy the name to the module struct + strcpy_s(info.name, file); + + // + // Module base address/size/hash index + // + info.hash = ModHashFromName(info.name); info.base = base; info.size = size; - strcpy_s(info.name, name); - //process module sections - HANDLE FileHandle; - DWORD LoadedSize; - HANDLE FileMap; - ULONG_PTR FileMapVA; + // + // Process module sections + // + info.sections.clear(); + WString wszFullPath = StringUtils::Utf8ToUtf16(fullpath); - if(StaticFileLoadW(wszFullPath.c_str(), UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA)) + if(StaticFileLoadW(wszFullPath.c_str(), UE_ACCESS_READ, false, &info.Handle, &info.FileMapSize, &info.MapHandle, &info.FileMapVA)) { - info.entry = GetPE32DataFromMappedFile(FileMapVA, 0, UE_OEP) + info.base; //get entry point - int SectionCount = (int)GetPE32DataFromMappedFile(FileMapVA, 0, UE_SECTIONNUMBER); - if(SectionCount > 0) + // Get the entry point + info.entry = GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_OEP) + info.base; + + int sectionCount = (int)GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_SECTIONNUMBER); + for(int i = 0; i < sectionCount; i++) { - for(int i = 0; i < SectionCount; i++) - { - MODSECTIONINFO curSection; - curSection.addr = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALOFFSET) + base; - curSection.size = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALSIZE); - const char* SectionName = (const char*)GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONNAME); - //escape section name when needed - int len = (int)strlen(SectionName); - int escape_count = 0; - for(int k = 0; k < len; k++) - if(SectionName[k] == '\\' or SectionName[k] == '\"' or !isprint(SectionName[k])) - escape_count++; - strcpy_s(curSection.name, StringUtils::Escape(SectionName).c_str()); - info.sections.push_back(curSection); - } + MODSECTIONINFO curSection; + + curSection.addr = GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONVIRTUALOFFSET) + info.base; + curSection.size = GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONVIRTUALSIZE); + const char* sectionName = (const char*)GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONNAME); + + // Escape section name when needed + strcpy_s(curSection.name, StringUtils::Escape(sectionName).c_str()); + + // Add entry to the vector + info.sections.push_back(curSection); } - StaticFileUnloadW(wszFullPath.c_str(), false, FileHandle, LoadedSize, FileMap, FileMapVA); } - //add module to list - CriticalSectionLocker locker(LockModules); + // Add module to list + EXCLUSIVE_ACQUIRE(LockModules); modinfo.insert(std::make_pair(Range(base, base + size - 1), info)); + EXCLUSIVE_RELEASE(LockModules); + symupdatemodulelist(); return true; } -bool modunload(uint base) +bool ModUnload(uint base) { EXCLUSIVE_ACQUIRE(LockModules); - const ModulesInfo::iterator found = modinfo.find(Range(base, base)); - if(found == modinfo.end()) //not found + // Find the iterator index + const auto found = modinfo.find(Range(base, base)); + + if(found == modinfo.end()) return false; + // Remove it from the list modinfo.erase(found); + + // Unload everything from TitanEngine + StaticFileUnloadW(nullptr, false, found->second.Handle, found->second.FileMapSize, found->second.MapHandle, found->second.FileMapVA); + + // Update symbols symupdatemodulelist(); return true; } -void modclear() +void ModClear() { - EXCLUSIVE_ACQUIRE(LockModules); - // Remove all modules in the list + EXCLUSIVE_ACQUIRE(LockModules); modinfo.clear(); + EXCLUSIVE_RELEASE(LockModules); // Tell the symbol updater symupdatemodulelist(); } -bool modnamefromaddr(uint addr, char* modname, bool extension) +MODINFO* ModInfoFromAddr(uint addr) +{ + // + // NOTE: THIS DOES _NOT_ USE LOCKS + // + auto found = modinfo.find(Range(addr, addr)); + + // Was the module found with this address? + if(found == modinfo.end()) + return nullptr; + + return &found->second; +} + +bool ModNameFromAddr(uint addr, char* modname, bool extension) { if(!modname) return false; SHARED_ACQUIRE(LockModules); - // Was the module found with this address? - auto found = modinfo.find(Range(addr, addr)); + // Get a pointer to module information + auto module = ModInfoFromAddr(addr); - if(found == modinfo.end()) + if(!module) return false; // Zero buffer first memset(modname, 0, MAX_MODULE_SIZE); // Append the module path/name - strcat_s(modname, MAX_MODULE_SIZE, found->second.name); + strcat_s(modname, MAX_MODULE_SIZE, module->name); // Append the extension if(extension) - strcat_s(modname, MAX_MODULE_SIZE, found->second.extension); + strcat_s(modname, MAX_MODULE_SIZE, module->extension); return true; } -uint modbasefromaddr(uint addr) +uint ModBaseFromAddr(uint addr) { SHARED_ACQUIRE(LockModules); - // Was the module found with this address? - auto found = modinfo.find(Range(addr, addr)); + auto module = ModInfoFromAddr(addr); - if(found == modinfo.end()) + if(!module) return 0; - return found->second.base; + return module->base; } -uint modhashfromva(uint va) +uint ModHashFromAddr(uint addr) { // // Returns a unique hash from a virtual address // SHARED_ACQUIRE(LockModules); - // Was the module found with this address? - auto found = modinfo.find(Range(va, va)); + auto module = ModInfoFromAddr(addr); - if(found == modinfo.end()) - return va; + if(!module) + return addr; - return found->second.hash + (va - found->second.base); + return module->hash + (addr - module->base); } -uint modhashfromname(const char* mod) +uint ModHashFromName(const char* mod) { // // return MODINFO.hash (based on the name) @@ -165,7 +196,7 @@ uint modhashfromname(const char* mod) return murmurhash(mod, (int)strlen(mod)); } -uint modbasefromname(const char* modname) +uint ModBaseFromName(const char* modname) { if(!modname || strlen(modname) >= MAX_MODULE_SIZE) return 0; @@ -177,74 +208,64 @@ uint modbasefromname(const char* modname) char curmodname[MAX_MODULE_SIZE]; sprintf(curmodname, "%s%s", itr->second.name, itr->second.extension); - // Test with extension - if(!_stricmp(curmodname, modname)) - return itr->second.base; - - // Test without extension - if(!_stricmp(itr->second.name, modname)) + // Test with and without extension + if(!_stricmp(curmodname, modname) || !_stricmp(itr->second.name, modname)) return itr->second.base; } return 0; } -uint modsizefromaddr(uint addr) +uint ModSizeFromAddr(uint addr) { SHARED_ACQUIRE(LockModules); - // Was the module found with this address? - auto found = modinfo.find(Range(addr, addr)); + auto module = ModInfoFromAddr(addr); - if(found == modinfo.end()) + if(!module) return 0; - return found->second.size; + return module->size; } -bool modsectionsfromaddr(uint addr, std::vector* sections) +bool ModSectionsFromAddr(uint addr, std::vector* sections) { SHARED_ACQUIRE(LockModules); - // Was the module found with this address? - auto found = modinfo.find(Range(addr, addr)); + auto module = ModInfoFromAddr(addr); - if(found == modinfo.end()) + if(!module) return false; // Copy vector <-> vector - *sections = found->second.sections; + *sections = module->sections; return true; } -uint modentryfromaddr(uint addr) +uint ModEntryFromAddr(uint addr) { SHARED_ACQUIRE(LockModules); - // Was the module found with this address? - auto found = modinfo.find(Range(addr, addr)); + auto module = ModInfoFromAddr(addr); - if(found == modinfo.end()) //not found + if(!module) return 0; - return found->second.entry; + return module->entry; } -int modpathfromaddr(duint addr, char* path, int size) +int ModPathFromAddr(duint addr, char* path, int size) { - Memory wszModPath(size * sizeof(wchar_t), "modpathfromaddr:wszModPath"); + auto module = ModInfoFromAddr(addr); - if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), wszModPath, size)) - { - *path = '\0'; + if(!module) return 0; - } - strcpy_s(path, size, StringUtils::Utf16ToUtf8(wszModPath()).c_str()); + strcpy_s(path, size, module->path); return (int)strlen(path); } -int modpathfromname(const char* modname, char* path, int size) +int ModPathFromName(const char* modname, char* path, int size) { - return modpathfromaddr(modbasefromname(modname), path, size); + return ModPathFromAddr(ModBaseFromName(modname), path, size); } \ No newline at end of file diff --git a/x64_dbg_dbg/module.h b/x64_dbg_dbg/module.h index 95edba18..c59cb97c 100644 --- a/x64_dbg_dbg/module.h +++ b/x64_dbg_dbg/module.h @@ -1,40 +1,47 @@ -#ifndef _MODULE_H -#define _MODULE_H +#pragma once #include "_global.h" #include "addrinfo.h" struct MODSECTIONINFO { - uint addr; //va - uint size; //virtual size - char name[50]; + uint addr; // Virtual address + uint size; // Virtual size + char name[50]; // Escaped section name }; struct MODINFO { - uint base; //module base - uint size; //module size - uint hash; //full module name hash - uint entry; //entry point - char name[MAX_MODULE_SIZE]; //module name (without extension) - char extension[MAX_MODULE_SIZE]; //file extension + uint base; // Module base + uint size; // Module size + uint hash; // Full module name hash + uint entry; // Entry point + + char name[MAX_MODULE_SIZE]; // Module name (without extension) + char extension[MAX_MODULE_SIZE]; // File extension + char path[MAX_PATH]; // File path (in UTF8) + + HANDLE Handle; // Handle to the file opened by TitanEngine + HANDLE MapHandle; // Handle to the memory map + ULONG_PTR FileMapVA; // File map virtual address (Debugger local) + DWORD FileMapSize; // File map virtual size + std::vector sections; }; + typedef std::map ModulesInfo; -bool modload(uint base, uint size, const char* fullpath); -bool modunload(uint base); -void modclear(); -bool modnamefromaddr(uint addr, char* modname, bool extension); -uint modbasefromaddr(uint addr); -uint modhashfromva(uint va); -uint modhashfromname(const char* mod); -uint modbasefromname(const char* modname); -uint modsizefromaddr(uint addr); -bool modsectionsfromaddr(uint addr, std::vector* sections); -uint modentryfromaddr(uint addr); -int modpathfromaddr(duint addr, char* path, int size); -int modpathfromname(const char* modname, char* path, int size); - -#endif //_MODULE_H \ No newline at end of file +bool ModLoad(uint base, uint size, const char* fullpath); +bool ModUnload(uint base); +void ModClear(); +MODINFO* ModInfoFromAddr(uint addr); +bool ModNameFromAddr(uint addr, char* modname, bool extension); +uint ModBaseFromAddr(uint addr); +uint ModHashFromAddr(uint addr); +uint ModHashFromName(const char* mod); +uint ModBaseFromName(const char* modname); +uint ModSizeFromAddr(uint addr); +bool ModSectionsFromAddr(uint addr, std::vector* sections); +uint ModEntryFromAddr(uint addr); +int ModPathFromAddr(duint addr, char* path, int size); +int ModPathFromName(const char* modname, char* path, int size); \ No newline at end of file diff --git a/x64_dbg_dbg/patches.cpp b/x64_dbg_dbg/patches.cpp index c567aec7..2b9f6ef5 100644 --- a/x64_dbg_dbg/patches.cpp +++ b/x64_dbg_dbg/patches.cpp @@ -15,11 +15,11 @@ bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte) if(oldbyte == newbyte) return true; //no need to make a patch for a byte that is equal to itself PATCHINFO newPatch; - newPatch.addr = addr - modbasefromaddr(addr); - modnamefromaddr(addr, newPatch.mod, true); + newPatch.addr = addr - ModBaseFromAddr(addr); + ModNameFromAddr(addr, newPatch.mod, true); newPatch.oldbyte = oldbyte; newPatch.newbyte = newbyte; - uint key = modhashfromva(addr); + uint key = ModHashFromAddr(addr); CriticalSectionLocker locker(LockPatches); PatchesInfo::iterator found = patches.find(key); if(found != patches.end()) //we found a patch on the specified address @@ -45,13 +45,13 @@ bool patchget(uint addr, PATCHINFO* patch) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockPatches); - PatchesInfo::iterator found = patches.find(modhashfromva(addr)); + PatchesInfo::iterator found = patches.find(ModHashFromAddr(addr)); if(found == patches.end()) //not found return false; if(patch) { *patch = found->second; - patch->addr += modbasefromaddr(addr); + patch->addr += ModBaseFromAddr(addr); return true; } return (found->second.oldbyte != found->second.newbyte); @@ -62,11 +62,11 @@ bool patchdel(uint addr, bool restore) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockPatches); - PatchesInfo::iterator found = patches.find(modhashfromva(addr)); + PatchesInfo::iterator found = patches.find(ModHashFromAddr(addr)); if(found == patches.end()) //not found return false; if(restore) - memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr + modbasefromaddr(addr)), &found->second.oldbyte, sizeof(char), 0); + memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr + ModBaseFromAddr(addr)), &found->second.oldbyte, sizeof(char), 0); patches.erase(found); return true; } @@ -76,8 +76,8 @@ void patchdelrange(uint start, uint end, bool restore) if(!DbgIsDebugging()) return; bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = modbasefromaddr(start); - if(modbase != modbasefromaddr(end)) + uint modbase = ModBaseFromAddr(start); + if(modbase != ModBaseFromAddr(end)) return; start -= modbase; end -= modbase; @@ -130,7 +130,7 @@ bool patchenum(PATCHINFO* patcheslist, size_t* cbsize) for(PatchesInfo::iterator i = patches.begin(); i != patches.end(); ++i, j++) { patcheslist[j] = i->second; - uint modbase = modbasefromname(patcheslist[j].mod); + uint modbase = ModBaseFromName(patcheslist[j].mod); patcheslist[j].addr += modbase; } return true; @@ -154,7 +154,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha sprintf(error, "not all patches are in module %s", modname); return -1; } - uint modbase = modbasefromname(modname); + uint modbase = ModBaseFromName(modname); if(!modbase) //module not loaded { if(error) diff --git a/x64_dbg_dbg/reference.cpp b/x64_dbg_dbg/reference.cpp index 0f7e3ccd..03254508 100644 --- a/x64_dbg_dbg/reference.cpp +++ b/x64_dbg_dbg/reference.cpp @@ -53,7 +53,7 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent, cons refinfo.userinfo = userinfo; char fullName[deflen] = ""; char modname[MAX_MODULE_SIZE] = ""; - if(modnamefromaddr(start_addr, modname, true)) + if(ModNameFromAddr(start_addr, modname, true)) sprintf_s(fullName, "%s (%s)", name, modname); else sprintf_s(fullName, "%s (%p)", name, start_addr); diff --git a/x64_dbg_dbg/stackinfo.cpp b/x64_dbg_dbg/stackinfo.cpp index 89ebb514..9b92c83f 100644 --- a/x64_dbg_dbg/stackinfo.cpp +++ b/x64_dbg_dbg/stackinfo.cpp @@ -44,7 +44,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; - modnamefromaddr(data, module, false); + ModNameFromAddr(data, module, false); char returnToAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnToAddr, "%s.", module); @@ -60,7 +60,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); *module = 0; - modnamefromaddr(data, module, false); + ModNameFromAddr(data, module, false); char returnFromAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnFromAddr, "%s.", module); @@ -94,7 +94,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; - modnamefromaddr(data, module, false); + ModNameFromAddr(data, module, false); char addrInfo[MAX_COMMENT_SIZE] = ""; if(*module) //module { @@ -153,7 +153,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; - modnamefromaddr(data, module, false); + ModNameFromAddr(data, module, false); char returnToAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnToAddr, "%s.", module); @@ -176,7 +176,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); *module = 0; - modnamefromaddr(data, module, false); + ModNameFromAddr(data, module, false); char returnFromAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnFromAddr, "%s.", module); diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 37162335..07cb2e40 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -59,7 +59,7 @@ static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID User SYMBOLMODULEINFO curModule; memset(&curModule, 0, sizeof(SYMBOLMODULEINFO)); curModule.base = BaseOfDll; - modnamefromaddr(BaseOfDll, curModule.name, true); + ModNameFromAddr(BaseOfDll, curModule.name, true); ((std::vector*)UserContext)->push_back(curModule); return TRUE; } @@ -166,7 +166,7 @@ const char* symgetsymbolicname(uint addr) if(retval) { char modname[MAX_MODULE_SIZE] = ""; - if(modnamefromaddr(addr, modname, false)) + if(ModNameFromAddr(addr, modname, false)) sprintf(symbolicname, "%s.%s", modname, label); else sprintf(symbolicname, "<%s>", label); diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index 149b3b04..4070c1cf 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -5,34 +5,32 @@ #include "threading.h" static std::vector threadList; -static int threadNum; -void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread) +void ThreadCreate(CREATE_THREAD_DEBUG_INFO* CreateThread) { THREADINFO curInfo; memset(&curInfo, 0, sizeof(THREADINFO)); - curInfo.ThreadNumber = threadNum; + curInfo.ThreadNumber = ThreadGetCount(); curInfo.Handle = CreateThread->hThread; curInfo.ThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; curInfo.ThreadStartAddress = (uint)CreateThread->lpStartAddress; curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase; // The first thread (#0) is always the main program thread - if(threadNum <= 0) + if(curInfo.ThreadNumber <= 0) strcpy_s(curInfo.threadName, "Main Thread"); // Modify global thread list EXCLUSIVE_ACQUIRE(LockThreads); threadList.push_back(curInfo); - threadNum++; EXCLUSIVE_RELEASE(); // Notify GUI GuiUpdateThreadView(); } -void threadexit(DWORD dwThreadId) +void ThreadExit(DWORD dwThreadId) { EXCLUSIVE_ACQUIRE(LockThreads); @@ -49,10 +47,8 @@ void threadexit(DWORD dwThreadId) GuiUpdateThreadView(); } -void threadclear() +void ThreadClear() { - threadNum = 0; - // Clear the current array of threads EXCLUSIVE_ACQUIRE(LockThreads); threadList.clear(); @@ -62,56 +58,9 @@ void threadclear() GuiUpdateThreadView(); } -bool ThreadGetTeb(uint TEBAddress, TEB* Teb) +int ThreadGetCount() { - // - // TODO: Keep a cached copy inside the vector - // - memset(Teb, 0, sizeof(TEB)); - - return memread(fdProcessInfo->hProcess, (void*)TEBAddress, Teb, sizeof(TEB), nullptr); -} - -int ThreadGetSuspendCount(HANDLE Thread) -{ - // - // Suspend a thread in order to get the previous suspension count - // WARNING: This function is very bad (threads should not be randomly interrupted) - // - int suspendCount = (int)SuspendThread(Thread); - - if(suspendCount == -1) - return 0; - - // Resume the thread's normal execution - ResumeThread(Thread); - - return suspendCount; -} - -THREADPRIORITY ThreadGetPriority(HANDLE Thread) -{ - return (THREADPRIORITY)GetThreadPriority(Thread); -} - -THREADWAITREASON ThreadGetWaitReason(HANDLE Thread) -{ - UNREFERENCED_PARAMETER(Thread); - - //TODO: Implement this - return _Executive; -} - -DWORD ThreadGetLastError(uint tebAddress) -{ - TEB teb; - if(!ThreadGetTeb(tebAddress, &teb)) - { - // TODO: Assert (Why would the TEB fail?) - return 0; - } - - return teb.LastErrorValue; + return (int)threadList.size(); } void ThreadGetList(THREADLIST* list) @@ -162,19 +111,72 @@ bool ThreadIsValid(DWORD dwThreadId) return false; } +bool ThreadGetTeb(uint TEBAddress, TEB* Teb) +{ + // + // TODO: Keep a cached copy inside the vector + // + memset(Teb, 0, sizeof(TEB)); + + return memread(fdProcessInfo->hProcess, (void*)TEBAddress, Teb, sizeof(TEB), nullptr); +} + +int ThreadGetSuspendCount(HANDLE Thread) +{ + // + // Suspend a thread in order to get the previous suspension count + // WARNING: This function is very bad (threads should not be randomly interrupted) + // + int suspendCount = (int)SuspendThread(Thread); + + if(suspendCount == -1) + return 0; + + // Resume the thread's normal execution + ResumeThread(Thread); + + return suspendCount; +} + +THREADPRIORITY ThreadGetPriority(HANDLE Thread) +{ + return (THREADPRIORITY)GetThreadPriority(Thread); +} + +THREADWAITREASON ThreadGetWaitReason(HANDLE Thread) +{ + UNREFERENCED_PARAMETER(Thread); + + // TODO: Implement this + return _Executive; +} + +DWORD ThreadGetLastError(uint tebAddress) +{ + TEB teb; + if(!ThreadGetTeb(tebAddress, &teb)) + { + // TODO: Assert (Why would the TEB fail?) + return 0; + } + + return teb.LastErrorValue; +} + bool ThreadSetName(DWORD dwThreadId, const char* name) { EXCLUSIVE_ACQUIRE(LockThreads); - // This modifies a variable (name), so an exclusive lock is required + // Modifies a variable (name), so an exclusive lock is required for(auto itr = threadList.begin(); itr != threadList.end(); itr++) { if(itr->ThreadId == dwThreadId) { - if(name) - strcpy_s(itr->threadName, name); - else - itr->threadName[0] = '\0'; + if(!name) + name = ""; + + strcpy_s(itr->threadName, name); + return true; } } @@ -208,20 +210,11 @@ DWORD ThreadGetId(HANDLE hThread) } // Wasn't found, check with Windows - // This also returns 0 on error - /* - REQUIRES VISTA+ + DWORD id = GetThreadId(hThread); - return GetThreadId(hThread); - */ - - // TODO: Same problem with threadgethandle() - return 0; -} - -int ThreadGetCount() -{ - return (int)threadList.size(); + // Returns 0 on error; + // TODO: Same problem with ThreadGetHandle() + return id; } int ThreadSuspendAll() @@ -246,7 +239,7 @@ int ThreadResumeAll() // // ResumeThread does not modify any internal variables // - EXCLUSIVE_ACQUIRE(LockThreads); + SHARED_ACQUIRE(LockThreads); int count = 0; for(auto itr = threadList.begin(); itr != threadList.end(); itr++) diff --git a/x64_dbg_dbg/thread.h b/x64_dbg_dbg/thread.h index 22276dc3..5eb62bd2 100644 --- a/x64_dbg_dbg/thread.h +++ b/x64_dbg_dbg/thread.h @@ -1,20 +1,22 @@ -#ifndef _THREAD_H -#define _THREAD_H +#pragma once #include "_global.h" #include "debugger.h" -//functions -void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread); -void threadexit(DWORD dwThreadId); -void threadclear(); +void ThreadCreate(CREATE_THREAD_DEBUG_INFO* CreateThread); +void ThreadExit(DWORD dwThreadId); +void ThreadClear(); +int ThreadGetCount(); void ThreadGetList(THREADLIST* list); bool ThreadIsValid(DWORD dwThreadId); bool ThreadSetName(DWORD dwTHreadId, const char* name); +bool ThreadGetTeb(uint TEBAddress, TEB* Teb); +int ThreadGetSuspendCount(HANDLE Thread); +THREADPRIORITY ThreadGetPriority(HANDLE Thread); +THREADWAITREASON ThreadGetWaitReason(HANDLE Thread); +DWORD ThreadGetLastError(uint tebAddress); +bool ThreadSetName(DWORD dwThreadId, const char* name); HANDLE ThreadGetHandle(DWORD dwThreadId); DWORD ThreadGetId(HANDLE hThread); -int ThreadGetCount(); int ThreadSuspendAll(); -int ThreadResumeAll(); - -#endif //_THREAD_H +int ThreadResumeAll(); \ No newline at end of file diff --git a/x64_dbg_dbg/value.cpp b/x64_dbg_dbg/value.cpp index 055a8e41..000038bd 100644 --- a/x64_dbg_dbg/value.cpp +++ b/x64_dbg_dbg/value.cpp @@ -1189,7 +1189,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print SELECTIONDATA seldata; memset(&seldata, 0, sizeof(seldata)); GuiSelectionGet(GUI_DISASSEMBLY, &seldata); - if(!modnamefromaddr(seldata.start, modname, true)) + if(!ModNameFromAddr(seldata.start, modname, true)) return false; } else @@ -1200,7 +1200,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print apiname++; if(!strlen(apiname)) return false; - uint modbase = modbasefromname(modname); + uint modbase = ModBaseFromName(modname); wchar_t szModName[MAX_PATH] = L""; if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModName, MAX_PATH)) { @@ -2094,7 +2094,7 @@ bool valtostring(const char* string, uint* value, bool silent) uint valfileoffsettova(const char* modname, uint offset) { char modpath[MAX_PATH] = ""; - if(modpathfromname(modname, modpath, MAX_PATH)) + if(ModPathFromName(modname, modpath, MAX_PATH)) { HANDLE FileHandle; DWORD LoadedSize; @@ -2106,7 +2106,7 @@ uint valfileoffsettova(const char* modname, uint offset) FileMapVA + (ULONG_PTR)offset, //Offset inside FileMapVA false); //Return without ImageBase StaticFileUnloadW(StringUtils::Utf8ToUtf16(modpath).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA); - return offset < LoadedSize ? (duint)rva + modbasefromname(modname) : 0; + return offset < LoadedSize ? (duint)rva + ModBaseFromName(modname) : 0; } } return 0; @@ -2115,7 +2115,7 @@ uint valfileoffsettova(const char* modname, uint offset) uint valvatofileoffset(uint va) { char modpath[MAX_PATH] = ""; - if(modpathfromaddr(va, modpath, MAX_PATH)) + if(ModPathFromAddr(va, modpath, MAX_PATH)) { HANDLE FileHandle; DWORD LoadedSize; @@ -2123,7 +2123,7 @@ uint valvatofileoffset(uint va) ULONG_PTR FileMapVA; if(StaticFileLoadW(StringUtils::Utf8ToUtf16(modpath).c_str(), UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA)) { - ULONGLONG offset = ConvertVAtoFileOffsetEx(FileMapVA, LoadedSize, 0, va - modbasefromaddr(va), true, false); + ULONGLONG offset = ConvertVAtoFileOffsetEx(FileMapVA, LoadedSize, 0, va - ModBaseFromAddr(va), true, false); StaticFileUnloadW(StringUtils::Utf8ToUtf16(modpath).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA); return (duint)offset; } From 9bad5fceeae1790e4421a68009d9611425d89218 Mon Sep 17 00:00:00 2001 From: ultra Date: Sun, 15 Mar 2015 21:43:24 -0400 Subject: [PATCH 044/106] settings gui scaling support --- .../Project/Src/Gui/SettingsDialog.cpp | 3 +- x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui | 1001 ++++++++--------- 2 files changed, 458 insertions(+), 546 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp index c631bb41..f1b14186 100644 --- a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp @@ -12,9 +12,8 @@ SettingsDialog::SettingsDialog(QWidget* parent) : ui->setupUi(this); //set window flags #if QT_VERSION < QT_VERSION_CHECK(5,0,0) - setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); + setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); #endif - setFixedSize(this->size()); //fixed size setModal(true); LoadSettings(); //load settings from file connect(Bridge::getBridge(), SIGNAL(setLastException(uint)), this, SLOT(setLastException(uint))); diff --git a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui index 2e422f0d..cb9a94af 100644 --- a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui +++ b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui @@ -26,553 +26,468 @@ true - - - - 2 - 2 - 301 - 181 - - - - true - - - 0 - - - - Events - - - - - 10 - 10 - 241 - 16 - + + + + + true - - Break on: + + 0 + + + Events + + + + + + Break on: + + + + + + + System Breakpoint* + + + false + + + + + + + DLL Load + + + + + + + DLL Unload + + + + + + + TLS Callbacks* + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + DLL Entry + + + + + + + Attach Breakpoint + + + + + + + Entry Breakpoint* + + + false + + + + + + + Thread Entry + + + + + + + Thread Start + + + + + + + Thread End + + + + + + + Debug Strings + + + + + + + + Engine + + + + + + + 0 + 0 + + + + Calculation Type: + + + + + + + QLayout::SetNoConstraint + + + + + &Signed + + + true + + + + + + + &Unsigned + + + + + + + + + + 0 + 0 + + + + Default Breakpoint Type: + + + + + + + + + INT3 + + + true + + + + + + + Long INT3 + + + + + + + UD2 + + + + + + + + + Undecorate Symbol Names + + + + + + + Enable Debug &Privilege + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Exceptions + + + + + + Ignored Exceptions: + + + + + + + + + + Courier New + 8 + + + + Qt::ScrollBarAlwaysOn + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Add &Range + + + + + + + &Delete Range + + + + + + + Add &Last + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Disasm + + + + + + Argument Spaces + + + + + + + Memory Spaces + + + + + + + Uppercase + + + + + + + Autocomments only on CIP + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Misc + + + + + + Set x64_dbg as Just In Time Debugger + + + + + + + + + JIT: + + + + + + + true + + + + + + + + + Confirm before attaching + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + - - - - 20 - 30 - 121 - 17 - - - - System Breakpoint* - - - false - - - - - - 20 - 50 - 121 - 17 - - - - TLS Callbacks* - - - false - - - - - - 20 - 70 - 121 - 17 - - - - Entry Breakpoint* - - - false - - - - - - 150 - 30 - 101 - 17 - - - - DLL Load - - - - - - 150 - 50 - 101 - 17 - - - - DLL Unload - - - - - - 150 - 70 - 101 - 17 - - - - Thread Start - - - - - - 150 - 90 - 101 - 17 - - - - Thread End - - - - - - 150 - 110 - 101 - 17 - - - - Debug Strings - - - - - - 20 - 90 - 121 - 17 - - - - DLL Entry - - - - - - 20 - 110 - 121 - 17 - - - - Thread Entry - - - - - - 20 - 130 - 121 - 17 - - - - Attach Breakpoint - - - - - - Engine - - - - - 10 - 10 - 241 - 16 - - - - Calculation Type: - - - - - - 10 - 60 - 241 - 16 - - - - Default Breakpoint Type: - - - - - - 20 - 30 - 231 - 19 - - - - - - - &Signed - - - true - - - - - - - &Unsigned - - - - - - - - - 20 - 80 - 231 - 19 - - - - - - - INT3 - - - true - - - - - - - Long INT3 - - - - - - - UD2 - - - - - - - - - 10 - 110 - 241 - 17 - - - - Undecorate Symbol Names - - - - - - 10 - 130 - 241 - 17 - - - - Enable Debug &Privilege - - - - - - Exceptions - - - - - 10 - 30 - 151 - 111 - - - - - Courier New - 8 - - - - Qt::ScrollBarAlwaysOn - - - - - - 10 - 10 - 241 - 16 - - - - Ignored Exceptions: - - - - - - 170 - 30 - 77 - 83 - - - - - - - Add &Range - - - - - - - &Delete Range - - - - - - - Add &Last - - - - - - - - - Disasm - - - - - 10 - 10 - 241 - 17 - - - - Argument Spaces - - - - - - 10 - 30 - 241 - 17 - - - - Memory Spaces - - - - - - 10 - 50 - 241 - 17 - - - - Uppercase - - - - - - 10 - 70 - 241 - 17 - - - - Autocomments only on CIP - - - - - - Misc - - - - - 10 - 10 - 281 - 17 - - - - Set x64_dbg as Just In Time Debugger - - - - - - 10 - 30 - 281 - 22 - - - - - - - JIT: - - - - - - - true - - - - - - - - - 150 - 60 - 141 - 17 - - - - Confirm before attaching - - - - - - 10 - 80 - 271 - 31 - - - - - - - - - - - - 100 - 190 - 75 - 23 - - - - Save - - - true - - - - - - 180 - 190 - 75 - 23 - - - - Cancel - - + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Save + + + true + + + + + + + Cancel + + + + + + - tabWidget - chkSystemBreakpoint - chkTlsCallbacks - chkEntryBreakpoint - chkDllEntry - chkThreadEntry - chkDllLoad - chkDllUnload - chkThreadStart - chkThreadEnd - chkDebugStrings radioSigned radioUnsigned radioInt3Short @@ -584,8 +499,6 @@ btnAddRange btnDeleteRange btnAddLast - btnSave - btnCancel From d38817c9acbd660dc82aa94bb99fb21386b38ec2 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 15 Mar 2015 22:33:29 -0400 Subject: [PATCH 045/106] Missing thread lock --- x64_dbg_dbg/thread.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index 4070c1cf..5e7e4b0d 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -60,6 +60,7 @@ void ThreadClear() int ThreadGetCount() { + SHARED_ACQUIRE(LockThreads); return (int)threadList.size(); } From 722665fe53649222665bf7410e0e28a53c5c0d4c Mon Sep 17 00:00:00 2001 From: Nukem Date: Mon, 16 Mar 2015 22:47:40 -0400 Subject: [PATCH 046/106] Use foreach() loops in thread.cpp --- x64_dbg_dbg/thread.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index 5e7e4b0d..67be502a 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -103,9 +103,9 @@ bool ThreadIsValid(DWORD dwThreadId) { SHARED_ACQUIRE(LockThreads); - for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + for(auto & entry : threadList) { - if(itr->ThreadId == dwThreadId) + if(entry.ThreadId == dwThreadId) return true; } @@ -169,14 +169,14 @@ bool ThreadSetName(DWORD dwThreadId, const char* name) EXCLUSIVE_ACQUIRE(LockThreads); // Modifies a variable (name), so an exclusive lock is required - for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + for(auto & entry : threadList) { - if(itr->ThreadId == dwThreadId) + if(entry.ThreadId == dwThreadId) { if(!name) name = ""; - strcpy_s(itr->threadName, name); + strcpy_s(entry.threadName, name); return true; } } @@ -188,10 +188,10 @@ HANDLE ThreadGetHandle(DWORD dwThreadId) { SHARED_ACQUIRE(LockThreads); - for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + for(auto & entry : threadList) { - if(itr->ThreadId == dwThreadId) - return itr->Handle; + if(entry.ThreadId == dwThreadId) + return entry.Handle; } // TODO: Set an assert if the handle is never found, @@ -204,10 +204,10 @@ DWORD ThreadGetId(HANDLE hThread) SHARED_ACQUIRE(LockThreads); // Search for the ID in the local list - for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + for(auto & entry : threadList) { - if(itr->Handle == hThread) - return itr->ThreadId; + if(entry.Handle == hThread) + return entry.ThreadId; } // Wasn't found, check with Windows @@ -226,9 +226,9 @@ int ThreadSuspendAll() SHARED_ACQUIRE(LockThreads); int count = 0; - for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + for(auto & entry : threadList) { - if(SuspendThread(itr->Handle) != -1) + if(SuspendThread(entry.Handle) != -1) count++; } @@ -243,9 +243,9 @@ int ThreadResumeAll() SHARED_ACQUIRE(LockThreads); int count = 0; - for(auto itr = threadList.begin(); itr != threadList.end(); itr++) + for(auto & entry : threadList) { - if(ResumeThread(itr->Handle) != -1) + if(ResumeThread(entry.Handle) != -1) count++; } From 61c731693c0fd9c32a27415e6044d7fdc8a3ee96 Mon Sep 17 00:00:00 2001 From: Nukem Date: Tue, 17 Mar 2015 16:46:06 -0400 Subject: [PATCH 047/106] Refactor symbolinfo.cpp/.h --- x64_dbg_dbg/_dbgfunctions.cpp | 2 +- x64_dbg_dbg/_exports.cpp | 2 +- x64_dbg_dbg/debugger.cpp | 10 +- x64_dbg_dbg/debugger_commands.cpp | 2 +- x64_dbg_dbg/module.cpp | 10 +- x64_dbg_dbg/symbolinfo.cpp | 229 ++++++++++++++++++------------ x64_dbg_dbg/symbolinfo.h | 15 +- x64_dbg_dbg/value.cpp | 2 +- 8 files changed, 158 insertions(+), 114 deletions(-) diff --git a/x64_dbg_dbg/_dbgfunctions.cpp b/x64_dbg_dbg/_dbgfunctions.cpp index a7c75063..79fbdd6f 100644 --- a/x64_dbg_dbg/_dbgfunctions.cpp +++ b/x64_dbg_dbg/_dbgfunctions.cpp @@ -186,7 +186,7 @@ void dbgfunctionsinit() _dbgfunctions.DisasmFast = disasmfast; _dbgfunctions.MemUpdateMap = _memupdatemap; _dbgfunctions.GetCallStack = _getcallstack; - _dbgfunctions.SymbolDownloadAllSymbols = symdownloadallsymbols; + _dbgfunctions.SymbolDownloadAllSymbols = SymDownloadAllSymbols; _dbgfunctions.GetJit = _getjit; _dbgfunctions.GetJitAuto = _getjitauto; _dbgfunctions.GetDefJit = dbggetdefjit; diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index a166eb95..d87a61e2 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -690,7 +690,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_SYMBOL_ENUM: { SYMBOLCBINFO* cbInfo = (SYMBOLCBINFO*)param1; - symenum(cbInfo->base, cbInfo->cbSymbolEnum, cbInfo->user); + SymEnum(cbInfo->base, cbInfo->cbSymbolEnum, cbInfo->user); } break; diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index d2e59f15..b3865df1 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -225,7 +225,7 @@ void cbUserBreakpoint() bptype = "UD2"; else if((titantype & UE_BREAKPOINT_TYPE_LONG_INT3) == UE_BREAKPOINT_TYPE_LONG_INT3) bptype = "LONG INT3"; - const char* symbolicname = symgetsymbolicname(bp.addr); + const char* symbolicname = SymGetSymbolicName(bp.addr); if(symbolicname) { if(*bp.name) @@ -302,7 +302,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress) bptype = "write"; break; } - const char* symbolicname = symgetsymbolicname(bp.addr); + const char* symbolicname = SymGetSymbolicName(bp.addr); if(symbolicname) { if(*bp.name) @@ -363,7 +363,7 @@ void cbMemoryBreakpoint(void* ExceptionAddress) bptype = " (read/write/execute)"; break; } - const char* symbolicname = symgetsymbolicname(bp.addr); + const char* symbolicname = SymGetSymbolicName(bp.addr); if(symbolicname) { if(*bp.name) @@ -633,7 +633,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(modInfo); if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) - modload((uint)base, modInfo.ImageSize, modInfo.ImageName); + ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; @@ -813,7 +813,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) - modload((uint)base, modInfo.ImageSize, modInfo.ImageName); + ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 890df723..9d53ce22 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -1382,7 +1382,7 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) } if(argc < 2) //no arguments { - symdownloadallsymbols(szSymbolStore); //download symbols for all modules + SymDownloadAllSymbols(szSymbolStore); //download symbols for all modules GuiSymbolRefreshCurrent(); dputs("Done! See symbol log for more information"); return STATUS_CONTINUE; diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 71adf766..69f5640d 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -80,9 +80,9 @@ bool ModLoad(uint base, uint size, const char* fullpath) // Add module to list EXCLUSIVE_ACQUIRE(LockModules); modinfo.insert(std::make_pair(Range(base, base + size - 1), info)); - EXCLUSIVE_RELEASE(LockModules); + EXCLUSIVE_RELEASE(); - symupdatemodulelist(); + SymUpdateModuleList(); return true; } @@ -103,7 +103,7 @@ bool ModUnload(uint base) StaticFileUnloadW(nullptr, false, found->second.Handle, found->second.FileMapSize, found->second.MapHandle, found->second.FileMapVA); // Update symbols - symupdatemodulelist(); + SymUpdateModuleList(); return true; } @@ -112,10 +112,10 @@ void ModClear() // Remove all modules in the list EXCLUSIVE_ACQUIRE(LockModules); modinfo.clear(); - EXCLUSIVE_RELEASE(LockModules); + EXCLUSIVE_RELEASE(); // Tell the symbol updater - symupdatemodulelist(); + SymUpdateModuleList(); } MODINFO* ModInfoFromAddr(uint addr) diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 07cb2e40..6de22eea 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -11,45 +11,41 @@ struct SYMBOLCBDATA void* user; }; -static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext) +static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO SymInfo, ULONG SymbolSize, PVOID UserContext) { - int len = (int)strlen(pSymInfo->Name); SYMBOLINFO curSymbol; memset(&curSymbol, 0, sizeof(SYMBOLINFO)); - curSymbol.addr = (duint)pSymInfo->Address; - curSymbol.decoratedSymbol = (char*)BridgeAlloc(len + 1); - strcpy_s(curSymbol.decoratedSymbol, len + 1, pSymInfo->Name); + + curSymbol.addr = (duint)SymInfo->Address; + curSymbol.decoratedSymbol = (char*)BridgeAlloc(strlen(SymInfo->Name) + 1); curSymbol.undecoratedSymbol = (char*)BridgeAlloc(MAX_SYM_NAME); - if(strstr(pSymInfo->Name, "Ordinal")) + strcpy_s(curSymbol.decoratedSymbol, strlen(SymInfo->Name) + 1, SymInfo->Name); + + // Skip bad ordinals + if(strstr(SymInfo->Name, "Ordinal")) { - //skip bad ordinals - if(pSymInfo->Address == pSymInfo->ModBase) + // Does the symbol point to the module base? + if(SymInfo->Address == SymInfo->ModBase) return TRUE; } - if(!UnDecorateSymbolName(pSymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) + + // Convert a mangled/decorated C++ name to a readable format + if(!UnDecorateSymbolName(SymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) { BridgeFree(curSymbol.undecoratedSymbol); - curSymbol.undecoratedSymbol = 0; + curSymbol.undecoratedSymbol = nullptr; } else if(!strcmp(curSymbol.decoratedSymbol, curSymbol.undecoratedSymbol)) { BridgeFree(curSymbol.undecoratedSymbol); - curSymbol.undecoratedSymbol = 0; + curSymbol.undecoratedSymbol = nullptr; } + SYMBOLCBDATA* cbData = (SYMBOLCBDATA*)UserContext; cbData->cbSymbolEnum(&curSymbol, cbData->user); return TRUE; } -void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user) -{ - SYMBOLCBDATA symbolCbData; - symbolCbData.cbSymbolEnum = cbSymbolEnum; - symbolCbData.user = user; - char mask[] = "*"; - SymEnumSymbols(fdProcessInfo->hProcess, base, mask, EnumSymbols, &symbolCbData); -} - #ifdef _WIN64 static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) #else @@ -57,120 +53,171 @@ static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID User #endif //_WIN64 { SYMBOLMODULEINFO curModule; - memset(&curModule, 0, sizeof(SYMBOLMODULEINFO)); curModule.base = BaseOfDll; ModNameFromAddr(BaseOfDll, curModule.name, true); + ((std::vector*)UserContext)->push_back(curModule); return TRUE; } -void symupdatemodulelist() +void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData) { - std::vector modList; - modList.clear(); - SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); - int modcount = (int)modList.size(); - SYMBOLMODULEINFO* modListBridge = (SYMBOLMODULEINFO*)BridgeAlloc(sizeof(SYMBOLMODULEINFO) * modcount); - for(int i = 0; i < modcount; i++) - memcpy(&modListBridge[i], &modList.at(i), sizeof(SYMBOLMODULEINFO)); - GuiSymbolUpdateModuleList(modcount, modListBridge); + SYMBOLCBDATA symbolCbData; + symbolCbData.cbSymbolEnum = EnumCallback; + symbolCbData.user = UserData; + + // Enumerate every single symbol for the module in 'base' + if(!SymEnumSymbols(fdProcessInfo->hProcess, Base, "*", EnumSymbols, &symbolCbData)) + dputs("SymEnumSymbols failed!"); } -void symdownloadallsymbols(const char* szSymbolStore) +void SymUpdateModuleList() { - if(!szSymbolStore) - szSymbolStore = "http://msdl.microsoft.com/download/symbols"; + // Build the vector of modules std::vector modList; - modList.clear(); - SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); - int modcount = (int)modList.size(); - if(!modcount) + + if(!SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList)) + dputs("SymEnumerateModules failed!"); + + // Send the module data to the GUI for updating + GuiSymbolUpdateModuleList((int)modList.size(), modList.data()); +} + +void SymDownloadAllSymbols(const char* SymbolStore) +{ + // Default to Microsoft's symbol server + if(!SymbolStore) + SymbolStore = "http://msdl.microsoft.com/download/symbols"; + + // Build the vector of modules + std::vector modList; + + if(!SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList)) + dputs("SymEnumerateModules failed!"); + + // Skip loading if there aren't any found modules + if(modList.size() <= 0) return; - char szOldSearchPath[MAX_PATH] = ""; - if(!SymGetSearchPath(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current path + + // Backup the current symbol search path + char oldSearchPath[MAX_PATH]; + + if(!SymGetSearchPath(fdProcessInfo->hProcess, oldSearchPath, MAX_PATH)) { dputs("SymGetSearchPath failed!"); return; } - char szServerSearchPath[MAX_PATH * 2] = ""; - sprintf_s(szServerSearchPath, "SRV*%s*%s", szSymbolCachePath, szSymbolStore); - if(!SymSetSearchPath(fdProcessInfo->hProcess, szServerSearchPath)) //update search path + + // Use the custom server path and directory + char customSearchPath[MAX_PATH * 2]; + sprintf_s(customSearchPath, "SRV*%s*%s", szSymbolCachePath, SymbolStore); + + if(!SymSetSearchPath(fdProcessInfo->hProcess, customSearchPath)) { dputs("SymSetSearchPath (1) failed!"); return; } - for(int i = 0; i < modcount; i++) //reload all modules + + // Reload all modules + for(auto & module : modList) { - dprintf("downloading symbols for %s...\n", modList.at(i).name); - uint modbase = modList.at(i).base; - wchar_t szModulePath[MAX_PATH] = L""; - if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModulePath, MAX_PATH)) + dprintf("Downloading symbols for %s...\n", module.name); + + wchar_t modulePath[MAX_PATH]; + if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)module.base, modulePath, MAX_PATH)) { - dprintf("GetModuleFileNameExW("fhex") failed!\n", modbase); + dprintf("GetModuleFileNameExW("fhex") failed!\n", module.base); continue; } - if(!SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) + + if(!SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)module.base)) { - dprintf("SymUnloadModule64("fhex") failed!\n", modbase); + dprintf("SymUnloadModule64("fhex") failed!\n", module.base); continue; } - if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(szModulePath).c_str(), 0, (DWORD64)modbase, 0, 0, 0)) + + if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(modulePath).c_str(), 0, (DWORD64)module.base, 0, 0, 0)) { - dprintf("SymLoadModuleEx("fhex") failed!\n", modbase); + dprintf("SymLoadModuleEx("fhex") failed!\n", module.base); continue; } } - if(!SymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath)) //restore search path - { + + // Restore the old search path + if(!SymSetSearchPath(fdProcessInfo->hProcess, oldSearchPath)) dputs("SymSetSearchPath (2) failed!"); - } } -bool symfromname(const char* name, uint* addr) +bool SymAddrFromName(const char* Name, uint* Address) { - if(!name or !strlen(name) or !addr or !_strnicmp(name, "ordinal", 7)) //skip 'OrdinalXXX' + if(!Name || Name[0] == '\0') return false; + + if(!Address) + return false; + + // Skip 'OrdinalXXX' + if(!_strnicmp(Name, "Ordinal", 7)) + return false; + + // According to MSDN: + // Note that the total size of the data is the SizeOfStruct + (MaxNameLen - 1) * sizeof(TCHAR) char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)]; - PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; - pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); - pSymbol->MaxNameLen = MAX_LABEL_SIZE; - if(!SymFromName(fdProcessInfo->hProcess, name, pSymbol)) + + PSYMBOL_INFO symbol = (PSYMBOL_INFO)&buffer; + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_LABEL_SIZE; + + if(!SymFromName(fdProcessInfo->hProcess, Name, symbol)) return false; - *addr = (uint)pSymbol->Address; + + *Address = (uint)symbol->Address; return true; } -const char* symgetsymbolicname(uint addr) +const char* SymGetSymbolicName(uint Address) { - //[modname.]symbolname - static char symbolicname[MAX_MODULE_SIZE + MAX_SYM_NAME] = ""; - char label[MAX_SYM_NAME] = ""; - bool retval = false; - if(labelget(addr, label)) //user labels have priority - retval = true; - else //no user labels + // + // This resolves an address to a module and symbol: + // [modname.]symbolname + // + char label[MAX_SYM_NAME]; + + // User labels have priority, but if one wasn't found, + // default to a symbol lookup + if(!labelget(Address, label)) { - DWORD64 displacement = 0; char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)]; - PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; - pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); - pSymbol->MaxNameLen = MAX_LABEL_SIZE; - if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement) - { - pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0'; - if(!bUndecorateSymbolNames or !UnDecorateSymbolName(pSymbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) - strcpy_s(label, pSymbol->Name); - retval = true; - } + + PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_LABEL_SIZE; + + // Perform a symbol lookup + DWORD64 displacement = 0; + + if(!SymFromAddr(fdProcessInfo->hProcess, (DWORD64)Address, &displacement, symbol)) + return nullptr; + + // If the symbol wasn't at offset 0 (start from the beginning) ignore it + if(displacement != 0) + return nullptr; + + // Terminate the string for sanity + symbol->Name[symbol->MaxNameLen - 1] = '\0'; + + if(!bUndecorateSymbolNames || !UnDecorateSymbolName(symbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) + strcpy_s(label, symbol->Name); } - if(retval) - { - char modname[MAX_MODULE_SIZE] = ""; - if(ModNameFromAddr(addr, modname, false)) - sprintf(symbolicname, "%s.%s", modname, label); - else - sprintf(symbolicname, "<%s>", label); - return symbolicname; - } - return 0; + + // TODO: FIXME: STATIC VARIABLE + static char symbolicname[MAX_MODULE_SIZE + MAX_SYM_NAME]; + char modname[MAX_MODULE_SIZE]; + + if(ModNameFromAddr(Address, modname, false)) + sprintf_s(symbolicname, "%s.%s", modname, label); + else + sprintf_s(symbolicname, "<%s>", label); + + return symbolicname; } diff --git a/x64_dbg_dbg/symbolinfo.h b/x64_dbg_dbg/symbolinfo.h index b5f9eab1..873b917b 100644 --- a/x64_dbg_dbg/symbolinfo.h +++ b/x64_dbg_dbg/symbolinfo.h @@ -1,12 +1,9 @@ -#ifndef _SYMBOLINFO_H -#define _SYMBOLINFO_H +#pragma once #include "_global.h" -void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user); -void symupdatemodulelist(); -void symdownloadallsymbols(const char* szSymbolStore); -bool symfromname(const char* name, uint* addr); -const char* symgetsymbolicname(uint addr); - -#endif //_SYMBOLINFO_H +void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData); +void SymUpdateModuleList(); +void SymDownloadAllSymbols(const char* SymbolStore); +bool SymAddrFromName(const char* Name, uint* Address); +const char* SymGetSymbolicName(uint Address); \ No newline at end of file diff --git a/x64_dbg_dbg/value.cpp b/x64_dbg_dbg/value.cpp index 000038bd..a9ab2ff2 100644 --- a/x64_dbg_dbg/value.cpp +++ b/x64_dbg_dbg/value.cpp @@ -1559,7 +1559,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, return true; else if(labelfromstring(string, value)) //then come labels return true; - else if(symfromname(string, value)) //then come symbols + else if(SymAddrFromName(string, value)) //then come symbols return true; else if(varget(string, value, value_size, 0)) //finally variables { From ebb46e67a02f0dd0d486038b032bb311167b5b24 Mon Sep 17 00:00:00 2001 From: Nukem Date: Tue, 17 Mar 2015 21:24:24 -0400 Subject: [PATCH 048/106] Refactor breakpoint.cpp/.h --- x64_dbg_dbg/_exports.cpp | 12 +- x64_dbg_dbg/addrinfo.cpp | 6 +- x64_dbg_dbg/breakpoint.cpp | 452 +++++++++++++++++++----------- x64_dbg_dbg/breakpoint.h | 40 ++- x64_dbg_dbg/debugger.cpp | 48 ++-- x64_dbg_dbg/debugger_commands.cpp | 108 +++---- x64_dbg_dbg/module.cpp | 6 - 7 files changed, 390 insertions(+), 282 deletions(-) diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index d87a61e2..f150d3e5 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -318,20 +318,20 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr) static uint cacheAddr; static int cacheBpCount; static int cacheResult; - int bpcount = bpgetlist(0); + int bpcount = BpGetList(nullptr); if(cacheAddr != addr or cacheBpCount != bpcount) { BREAKPOINT bp; cacheAddr = addr; cacheResult = 0; cacheBpCount = bpcount; - if(bpget(addr, BPNORMAL, 0, &bp)) + if(BpGet(addr, BPNORMAL, 0, &bp)) if(bp.enabled) cacheResult |= bp_normal; - if(bpget(addr, BPHARDWARE, 0, &bp)) + if(BpGet(addr, BPHARDWARE, 0, &bp)) if(bp.enabled) cacheResult |= bp_hardware; - if(bpget(addr, BPMEMORY, 0, &bp)) + if(BpGet(addr, BPMEMORY, 0, &bp)) if(bp.enabled) cacheResult |= bp_memory; } @@ -504,7 +504,7 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap) if(!bpmap) return 0; std::vector list; - int bpcount = bpgetlist(&list); + int bpcount = BpGetList(&list); if(bpcount == 0) { bpmap->count = 0; @@ -867,7 +867,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_IS_BP_DISABLED: { BREAKPOINT bp; - if(bpget((uint)param1, BPNORMAL, 0, &bp)) + if(BpGet((uint)param1, BPNORMAL, 0, &bp)) return !(uint)bp.enabled; return (uint)false; } diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index 07f4b451..ed4bb65c 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -26,7 +26,7 @@ void dbsave() bookmarkcachesave(root); functioncachesave(root); loopcachesave(root); - bpcachesave(root); + BpCacheSave(root); WString wdbpath = StringUtils::Utf8ToUtf16(dbpath); if(json_object_size(root)) { @@ -87,7 +87,7 @@ void dbload() bookmarkcacheload(root); functioncacheload(root); loopcacheload(root); - bpcacheload(root); + BpCacheLoad(root); json_decref(root); //free root dprintf("%ums\n", GetTickCount() - ticks); } @@ -100,7 +100,7 @@ void dbclose() bookmarkclear(); functionclear(); loopclear(); - bpclear(); + BpClear(); patchclear(); } diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index bc9bcd56..9b4b24d8 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -11,266 +11,386 @@ typedef std::map BreakpointsInfo; static BreakpointsInfo breakpoints; -int bpgetlist(std::vector* list) +BREAKPOINT* BpInfoFromAddr(BP_TYPE Type, uint Address) { - if(!DbgIsDebugging()) - return false; - BREAKPOINT curBp; - int count = 0; - CriticalSectionLocker locker(LockBreakpoints); - for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) - { - curBp = i->second; - curBp.addr += ModBaseFromName(curBp.mod); - curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); - count++; - if(list) - list->push_back(curBp); - } - return count; + // + // NOTE: THIS DOES _NOT_ USE LOCKS + // + auto found = breakpoints.find(BreakpointKey(Type, ModHashFromAddr(Address))); + + // Was the module found with this address? + if(found == breakpoints.end()) + return nullptr; + + return &found->second; } -bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name) +int BpGetList(std::vector* List) { - if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or bpget(addr, type, name, 0)) + // CHECK: Exported function + if(!DbgIsDebugging()) return false; + + SHARED_ACQUIRE(LockBreakpoints); + + // Did the caller request an output? + if(List) + { + // Enumerate all breakpoints in the global list, fixing the relative + // offset to a virtual address + for(auto & i : breakpoints) + { + BREAKPOINT currentBp = i.second; + currentBp.addr += ModBaseFromName(currentBp.mod); + currentBp.active = memisvalidreadptr(fdProcessInfo->hProcess, currentBp.addr); + + List->push_back(currentBp); + } + } + + return breakpoints.size(); +} + +bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name) +{ + // CHECK: Command function + if(!DbgIsDebugging()) + return false; + + // Fail if the address is a bad memory region + if(!memisvalidreadptr(fdProcessInfo->hProcess, Address)) + return false; + + // Fail if the breakpoint already exists + if(BpGet(Address, Type, Name, nullptr)) + return false; + + // Default to an empty name if one wasn't supplied + if(!Name) + Name = ""; + BREAKPOINT bp; - ModNameFromAddr(addr, bp.mod, true); - uint modbase = ModBaseFromAddr(addr); - bp.active = true; - bp.addr = addr - modbase; - bp.enabled = enabled; - if(name and * name) - strcpy_s(bp.name, name); - else - *bp.name = '\0'; - bp.oldbytes = oldbytes; - bp.singleshoot = singleshoot; - bp.titantype = titantype; - bp.type = type; - CriticalSectionLocker locker(LockBreakpoints); - breakpoints.insert(std::make_pair(BreakpointKey(type, ModHashFromAddr(addr)), bp)); + memset(&bp, 0, sizeof(BREAKPOINT)); + + ModNameFromAddr(Address, bp.mod, true); + strcpy_s(bp.name, Name); + + bp.active = true; + bp.addr = Address - ModBaseFromAddr(Address); + bp.enabled = Enable; + bp.oldbytes = OldBytes; + bp.singleshoot = Singleshot; + bp.titantype = TitanType; + bp.type = Type; + + // Insert new entry to the global list + EXCLUSIVE_ACQUIRE(LockBreakpoints); + + breakpoints.insert(std::make_pair(BreakpointKey(Type, ModHashFromAddr(Address)), bp)); return true; } -bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp) +bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp) { + // CHECK: Export/Command function if(!DbgIsDebugging()) return false; - BREAKPOINT curBp; - CriticalSectionLocker locker(LockBreakpoints); - if(!name) + + SHARED_ACQUIRE(LockBreakpoints); + + // Name is optional + if(!Name || Name[0] == '\0') { - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); - if(found == breakpoints.end()) //not found + // Perform a lookup by an address only + BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); + + if(!bpInfo) return false; - if(!bp) + + // Succeed even if the user didn't request anything + if(!Bp) return true; - curBp = found->second; - curBp.addr += ModBaseFromAddr(addr); - curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); - *bp = curBp; + + *Bp = *bpInfo; + Bp->addr += ModBaseFromAddr(Address); + Bp->active = memisvalidreadptr(fdProcessInfo->hProcess, Bp->addr); return true; } - for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) + + // Do a lookup by breakpoint name + for(auto & i : breakpoints) { - curBp = i->second; - if(name and * name) + // Do the names match? + if(strcmp(Name, i.second.name) != 0) + continue; + + // Fill out the optional user buffer + if(Bp) { - if(!strcmp(name, curBp.name)) - { - if(bp) - { - curBp.addr += ModBaseFromName(curBp.mod); - curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); - *bp = curBp; - } - return true; - } + *Bp = i.second; + Bp->addr += ModBaseFromAddr(Address); + Bp->active = memisvalidreadptr(fdProcessInfo->hProcess, Bp->addr); } + + // Return true if the name was found at all + return true; } + return false; } -bool bpdel(uint addr, BP_TYPE type) +bool BpDelete(uint Address, BP_TYPE Type) { + // CHECK: Command function if(!DbgIsDebugging()) return false; - CriticalSectionLocker locker(LockBreakpoints); - return (breakpoints.erase(BreakpointKey(type, ModHashFromAddr(addr))) > 0); + + // Erase the index from the global list + EXCLUSIVE_ACQUIRE(LockBreakpoints); + + return (breakpoints.erase(BreakpointKey(Type, ModHashFromAddr(Address))) > 0); } -bool bpenable(uint addr, BP_TYPE type, bool enable) +bool BpEnable(uint Address, BP_TYPE Type, bool Enable) { + // CHECK: Command function if(!DbgIsDebugging()) return false; - CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); - if(found == breakpoints.end()) //not found + + EXCLUSIVE_ACQUIRE(LockBreakpoints); + + // Check if the breakpoint exists first + BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); + + if(!bpInfo) return false; - breakpoints[found->first].enabled = enable; + + bpInfo->enabled = Enable; return true; } -bool bpsetname(uint addr, BP_TYPE type, const char* name) +bool BpSetName(uint Address, BP_TYPE Type, const char* Name) { - if(!DbgIsDebugging() or !name or !*name) + // CHECK: Future(?); This is not used anywhere + if(!DbgIsDebugging()) return false; - CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); - if(found == breakpoints.end()) //not found + + // If a name wasn't supplied, set to nothing + if(!Name) + Name = ""; + + EXCLUSIVE_ACQUIRE(LockBreakpoints); + + // Check if the breakpoint exists first + BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); + + if(!bpInfo) return false; - strcpy_s(breakpoints[found->first].name, name); + + strcpy_s(bpInfo->name, Name); return true; } -bool bpsettitantype(uint addr, BP_TYPE type, int titantype) +bool BpSetTitanType(uint Address, BP_TYPE Type, int TitanType) { + // CHECK: Command function if(!DbgIsDebugging()) return false; - CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr))); - if(found == breakpoints.end()) //not found + + EXCLUSIVE_ACQUIRE(LockBreakpoints); + + // Set the TitanEngine type, separate from BP_TYPE + BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); + + if(!bpInfo) return false; - breakpoints[found->first].titantype = titantype; + + bpInfo->titantype = TitanType; return true; } -bool bpenumall(BPENUMCALLBACK cbEnum, const char* module) +bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module) { if(!DbgIsDebugging()) return false; - bool retval = true; - BREAKPOINT curBp; - CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo::iterator i = breakpoints.begin(); - while(i != breakpoints.end()) + + SHARED_ACQUIRE(LockBreakpoints); + + // Loop each entry, executing the user's callback + bool callbackStatus = false; + + for(auto & i : breakpoints) { - BreakpointsInfo::iterator j = i; - ++i; - curBp = j->second; - curBp.addr += ModBaseFromName(curBp.mod); //RVA to VA - curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing? - if(module and * module) + BREAKPOINT bpInfo = i.second; + bpInfo.addr += ModBaseFromName(bpInfo.mod); + bpInfo.active = memisvalidreadptr(fdProcessInfo->hProcess, bpInfo.addr); + + // If a module name was sent, check it + if(Module && Module[0] != '\0') { - if(!strcmp(curBp.mod, module)) - { - if(!cbEnum(&curBp)) - retval = false; - } - } - else - { - if(!cbEnum(&curBp)) - retval = false; + if(strcmp(bpInfo.mod, Module) != 0) + continue; } + + // Execute the callback + if(!EnumCallback(&bpInfo)) + callbackStatus = false; } - return retval; + + return callbackStatus; } -bool bpenumall(BPENUMCALLBACK cbEnum) +bool BpEnumAll(BPENUMCALLBACK EnumCallback) { - return bpenumall(cbEnum, 0); + return BpEnumAll(EnumCallback, nullptr); } -int bpgetcount(BP_TYPE type, bool enabledonly) +int BpGetCount(BP_TYPE Type, bool EnabledOnly) { + SHARED_ACQUIRE(LockBreakpoints); + + // Count the number of enabled/disabled breakpoint types int count = 0; - CriticalSectionLocker locker(LockBreakpoints); - for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) + + for(auto & i : breakpoints) { - if(i->first.first == type && (!enabledonly || i->second.enabled)) - count++; + // Check if the type matches + if(i.first.first != Type) + continue; + + // If it's not enabled, skip it + if(EnabledOnly && !i.second.enabled) + continue; + + count++; } + return count; } -void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge) +void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp) { - if(!bp or !bridge) + // + // Convert a debugger breakpoint to an open/exported + // bridge breakpoint + // + // TOOD: ASSERT(?) These should never be null + if(!Bp or !BridgeBp) return; - memset(bridge, 0, sizeof(BRIDGEBP)); - bridge->active = bp->active; - bridge->addr = bp->addr; - bridge->enabled = bp->enabled; - strcpy_s(bridge->mod, bp->mod); - strcpy_s(bridge->name, bp->name); - bridge->singleshoot = bp->singleshoot; - switch(bp->type) + + memset(BridgeBp, 0, sizeof(BRIDGEBP)); + strcpy_s(BridgeBp->mod, Bp->mod); + strcpy_s(BridgeBp->name, Bp->name); + + BridgeBp->active = Bp->active; + BridgeBp->addr = Bp->addr; + BridgeBp->enabled = Bp->enabled; + BridgeBp->singleshoot = Bp->singleshoot; + + switch(Bp->type) { case BPNORMAL: - bridge->type = bp_normal; + BridgeBp->type = bp_normal; break; case BPHARDWARE: - bridge->type = bp_hardware; + BridgeBp->type = bp_hardware; break; case BPMEMORY: - bridge->type = bp_memory; - break; //so that's why it didn't show in the gui. + BridgeBp->type = bp_memory; + break; default: - bridge->type = bp_none; + BridgeBp->type = bp_none; break; } } -void bpcachesave(JSON root) +void BpCacheSave(JSON Root) { - CriticalSectionLocker locker(LockBreakpoints); + EXCLUSIVE_ACQUIRE(LockBreakpoints); + + // Create a JSON array to store each sub-object with a breakpoint const JSON jsonbreakpoints = json_array(); - for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) + + // Loop all breakpoints + for(auto & i : breakpoints) { - const BREAKPOINT curBreakpoint = i->second; - if(curBreakpoint.singleshoot) - continue; //skip - JSON curjsonbreakpoint = json_object(); - json_object_set_new(curjsonbreakpoint, "address", json_hex(curBreakpoint.addr)); - json_object_set_new(curjsonbreakpoint, "enabled", json_boolean(curBreakpoint.enabled)); - if(curBreakpoint.type == BPNORMAL) - json_object_set_new(curjsonbreakpoint, "oldbytes", json_hex(curBreakpoint.oldbytes)); - json_object_set_new(curjsonbreakpoint, "type", json_integer(curBreakpoint.type)); - json_object_set_new(curjsonbreakpoint, "titantype", json_hex(curBreakpoint.titantype)); - json_object_set_new(curjsonbreakpoint, "name", json_string(curBreakpoint.name)); - json_object_set_new(curjsonbreakpoint, "module", json_string(curBreakpoint.mod)); - json_array_append_new(jsonbreakpoints, curjsonbreakpoint); + auto & breakpoint = i.second; + + // Ignore single-shot breakpoints + if(breakpoint.singleshoot) + continue; + + JSON jsonObj = json_object(); + json_object_set_new(jsonObj, "address", json_hex(breakpoint.addr)); + json_object_set_new(jsonObj, "enabled", json_boolean(breakpoint.enabled)); + + // "Normal" breakpoints save the old data + if(breakpoint.type == BPNORMAL) + json_object_set_new(jsonObj, "oldbytes", json_hex(breakpoint.oldbytes)); + + json_object_set_new(jsonObj, "type", json_integer(breakpoint.type)); + json_object_set_new(jsonObj, "titantype", json_hex(breakpoint.titantype)); + json_object_set_new(jsonObj, "name", json_string(breakpoint.name)); + json_object_set_new(jsonObj, "module", json_string(breakpoint.mod)); + json_array_append_new(jsonbreakpoints, jsonObj); } + if(json_array_size(jsonbreakpoints)) - json_object_set(root, "breakpoints", jsonbreakpoints); + json_object_set(Root, "breakpoints", jsonbreakpoints); + + // Notify garbage collector json_decref(jsonbreakpoints); } -void bpcacheload(JSON root) +void BpCacheLoad(JSON Root) { - CriticalSectionLocker locker(LockBreakpoints); + EXCLUSIVE_ACQUIRE(LockBreakpoints); + + // Remove all existing elements breakpoints.clear(); - const JSON jsonbreakpoints = json_object_get(root, "breakpoints"); - if(jsonbreakpoints) + + // Get a handle to the root object -> breakpoints subtree + const JSON jsonbreakpoints = json_object_get(Root, "breakpoints"); + + // Return if there was nothing to load + if(!jsonbreakpoints) + return; + + size_t i; + JSON value; + json_array_foreach(jsonbreakpoints, i, value) { - size_t i; - JSON value; - json_array_foreach(jsonbreakpoints, i, value) - { - BREAKPOINT curBreakpoint; - memset(&curBreakpoint, 0, sizeof(BREAKPOINT)); - curBreakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type")); - if(curBreakpoint.type == BPNORMAL) - curBreakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes")); - curBreakpoint.addr = (uint)json_hex_value(json_object_get(value, "address")); - curBreakpoint.enabled = json_boolean_value(json_object_get(value, "enabled")); - curBreakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype")); - const char* name = json_string_value(json_object_get(value, "name")); - if(name) - strcpy_s(curBreakpoint.name, name); - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(curBreakpoint.mod, mod); - const uint key = ModHashFromName(curBreakpoint.mod) + curBreakpoint.addr; - breakpoints.insert(std::make_pair(BreakpointKey(curBreakpoint.type, key), curBreakpoint)); - } + BREAKPOINT breakpoint; + memset(&breakpoint, 0, sizeof(BREAKPOINT)); + + if(breakpoint.type == BPNORMAL) + breakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes")); + breakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type")); + breakpoint.addr = (uint)json_hex_value(json_object_get(value, "address")); + breakpoint.enabled = json_boolean_value(json_object_get(value, "enabled")); + breakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype")); + + // Name + const char* name = json_string_value(json_object_get(value, "name")); + + if(name) + strcpy_s(breakpoint.name, name); + + // Module + const char* mod = json_string_value(json_object_get(value, "module")); + + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy_s(breakpoint.mod, mod); + + // Build the hash map key: MOD_HASH + ADDRESS + const uint key = ModHashFromName(breakpoint.mod) + breakpoint.addr; + breakpoints.insert(std::make_pair(BreakpointKey(breakpoint.type, key), breakpoint)); } } -void bpclear() +void BpClear() { - CriticalSectionLocker locker(LockBreakpoints); - BreakpointsInfo().swap(breakpoints); + EXCLUSIVE_ACQUIRE(LockBreakpoints); + breakpoints.clear(); + EXCLUSIVE_RELEASE(); } \ No newline at end of file diff --git a/x64_dbg_dbg/breakpoint.h b/x64_dbg_dbg/breakpoint.h index bda1828c..e30bb70f 100644 --- a/x64_dbg_dbg/breakpoint.h +++ b/x64_dbg_dbg/breakpoint.h @@ -1,10 +1,8 @@ -#ifndef _BREAKPOINT_H -#define _BREAKPOINT_H +#pragma once #include "_global.h" #include "TitanEngine\TitanEngine.h" -//macros #define TITANSETDRX(titantype, drx) titantype &= 0x0FF; titantype |= (drx<<8) #define TITANGETDRX(titantype) (titantype >> 8) & 0xF #define TITANSETTYPE(titantype, type) titantype &= 0xF0F; titantype |= (type<<4) @@ -12,7 +10,6 @@ #define TITANSETSIZE(titantype, size) titantype &= 0xFF0; titantype |= size; #define TITANGETSIZE(titantype) titantype & 0xF -//enums enum BP_TYPE { BPNORMAL = 0, @@ -20,7 +17,6 @@ enum BP_TYPE BPMEMORY = 2 }; -//structs struct BREAKPOINT { uint addr; @@ -34,23 +30,21 @@ struct BREAKPOINT char mod[MAX_MODULE_SIZE]; }; -//typedefs +// Breakpoint enumeration callback typedef bool (*BPENUMCALLBACK)(const BREAKPOINT* bp); -//functions -int bpgetlist(std::vector* list); -bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name); -bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp); -bool bpdel(uint addr, BP_TYPE type); -bool bpenable(uint addr, BP_TYPE type, bool enable); -bool bpsetname(uint addr, BP_TYPE type, const char* name); -bool bpsettitantype(uint addr, BP_TYPE type, int titantype); -bool bpenumall(BPENUMCALLBACK cbEnum); -bool bpenumall(BPENUMCALLBACK cbEnum, const char* module); -int bpgetcount(BP_TYPE type, bool enabledonly = false); -void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge); -void bpcachesave(JSON root); -void bpcacheload(JSON root); -void bpclear(); - -#endif // _BREAKPOINT_H +BREAKPOINT* BpInfoFromAddr(BP_TYPE Type, uint Address); +int BpGetList(std::vector* List); +bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name); +bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp); +bool BpDelete(uint Address, BP_TYPE Type); +bool BpEnable(uint Address, BP_TYPE Type, bool Enable); +bool BpSetName(uint Address, BP_TYPE Type, const char* Name); +bool BpSetTitanType(uint Address, BP_TYPE Type, int TitanType); +bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module); +bool BpEnumAll(BPENUMCALLBACK EnumCallback); +int BpGetCount(BP_TYPE Type, bool EnabledOnly); +void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp); +void BpCacheSave(JSON Root); +void BpCacheLoad(JSON Root); +void BpClear(); \ No newline at end of file diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index b3865df1..83572402 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -82,7 +82,7 @@ uint dbgdebuggedbase() void dbgdisablebpx() { std::vector list; - int bpcount = bpgetlist(&list); + int bpcount = BpGetList(&list); for(int i = 0; i < bpcount; i++) { if(list[i].type == BPNORMAL and IsBPXEnabled(list[i].addr)) @@ -93,7 +93,7 @@ void dbgdisablebpx() void dbgenablebpx() { std::vector list; - int bpcount = bpgetlist(&list); + int bpcount = BpGetList(&list); for(int i = 0; i < bpcount; i++) { if(list[i].type == BPNORMAL and !IsBPXEnabled(list[i].addr) and list[i].enabled) @@ -215,7 +215,7 @@ void cbUserBreakpoint() BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; - if(!bpget(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled) + if(!BpGet(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled) dputs("Breakpoint reached not in list!"); else { @@ -241,8 +241,8 @@ void cbUserBreakpoint() dprintf("%s breakpoint at "fhex"!\n", bptype, bp.addr); } if(bp.singleshoot) - bpdel(bp.addr, BPNORMAL); - bptobridge(&bp, &pluginBp); + BpDelete(bp.addr, BPNORMAL); + BpToBridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; } GuiSetDebugState(paused); @@ -266,7 +266,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress) BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; - if(!bpget((uint)ExceptionAddress, BPHARDWARE, 0, &bp)) + if(!BpGet((uint)ExceptionAddress, BPHARDWARE, 0, &bp)) dputs("Hardware breakpoint reached not in list!"); else { @@ -317,7 +317,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress) else dprintf("Hardware breakpoint (%s%s) at "fhex"!\n", bpsize, bptype, bp.addr); } - bptobridge(&bp, &pluginBp); + BpToBridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; } GuiSetDebugState(paused); @@ -343,7 +343,7 @@ void cbMemoryBreakpoint(void* ExceptionAddress) BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; - if(!bpget(base, BPMEMORY, 0, &bp)) + if(!BpGet(base, BPMEMORY, 0, &bp)) dputs("Memory breakpoint reached not in list!"); else { @@ -378,11 +378,11 @@ void cbMemoryBreakpoint(void* ExceptionAddress) else dprintf("Memory breakpoint%s at "fhex" ("fhex")!\n", bptype, bp.addr, ExceptionAddress); } - bptobridge(&bp, &pluginBp); + BpToBridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; } if(bp.singleshoot) - bpdel(bp.addr, BPMEMORY); //delete from breakpoint list + BpDelete(bp.addr, BPMEMORY); //delete from breakpoint list GuiSetDebugState(paused); DebugUpdateGui(cip, true); //lock @@ -503,7 +503,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp) } int titantype = bp->titantype; TITANSETDRX(titantype, drx); - bpsettitantype(bp->addr, BPHARDWARE, titantype); + BpSetTitanType(bp->addr, BPHARDWARE, titantype); if(!SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) dprintf("Could not set hardware breakpoint "fhex"!\n", bp->addr); } @@ -638,7 +638,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; if(ModNameFromAddr((uint)base, modname, true)) - bpenumall(cbSetModuleBreakpoints, modname); + BpEnumAll(cbSetModuleBreakpoints, modname); GuiUpdateBreakpointsView(); if(!bFileIsDll and !bIsAttached) //Set entry breakpoint { @@ -818,7 +818,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; if(ModNameFromAddr((uint)base, modname, true)) - bpenumall(cbSetModuleBreakpoints, modname); + BpEnumAll(cbSetModuleBreakpoints, modname); GuiUpdateBreakpointsView(); bool bAlreadySetEntry = false; @@ -908,7 +908,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) void* base = UnloadDll->lpBaseOfDll; char modname[256] = "???"; if(ModNameFromAddr((uint)base, modname, true)) - bpenumall(cbRemoveModuleBreakpoints, modname); + BpEnumAll(cbRemoveModuleBreakpoints, modname); GuiUpdateBreakpointsView(); SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base); dprintf("DLL Unloaded: "fhex" %s\n", base, modname); @@ -1163,7 +1163,7 @@ DWORD WINAPI threadDebugLoop(void* lpParameter) bool cbDeleteAllBreakpoints(const BREAKPOINT* bp) { - if(bpdel(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr))) + if(BpDelete(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr))) return true; dprintf("Delete breakpoint failed: "fhex"\n", bp->addr); @@ -1175,7 +1175,7 @@ bool cbEnableAllBreakpoints(const BREAKPOINT* bp) if(bp->type != BPNORMAL or bp->enabled) return true; - if(!bpenable(bp->addr, BPNORMAL, true) or !SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint)) + if(!BpEnable(bp->addr, BPNORMAL, true) or !SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint)) { dprintf("Could not enable breakpoint "fhex"\n", bp->addr); return false; @@ -1188,7 +1188,7 @@ bool cbDisableAllBreakpoints(const BREAKPOINT* bp) if(bp->type != BPNORMAL or !bp->enabled) return true; - if(!bpenable(bp->addr, BPNORMAL, false) or !DeleteBPX(bp->addr)) + if(!BpEnable(bp->addr, BPNORMAL, false) or !DeleteBPX(bp->addr)) { dprintf("Could not disable breakpoint "fhex"\n", bp->addr); return false; @@ -1208,8 +1208,8 @@ bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp) } int titantype = bp->titantype; TITANSETDRX(titantype, drx); - bpsettitantype(bp->addr, BPHARDWARE, titantype); - if(!bpenable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) + BpSetTitanType(bp->addr, BPHARDWARE, titantype); + if(!BpEnable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) { dprintf("could not enable hardware breakpoint "fhex"\n", bp->addr); return false; @@ -1221,7 +1221,7 @@ bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp) { if(bp->type != BPHARDWARE or !bp->enabled) return true; - if(!bpenable(bp->addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) + if(!BpEnable(bp->addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { dprintf("Could not disable hardware breakpoint "fhex"\n", bp->addr); return false; @@ -1235,7 +1235,7 @@ bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp) return true; uint size = 0; memfindbaseaddr(bp->addr, &size); - if(!bpenable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) + if(!BpEnable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) { dprintf("Could not enable memory breakpoint "fhex"\n", bp->addr); return false; @@ -1247,7 +1247,7 @@ bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp) { if(bp->type != BPMEMORY or !bp->enabled) return true; - if(!bpenable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) + if(!BpEnable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { dprintf("Could not disable memory breakpoint "fhex"\n", bp->addr); return false; @@ -1283,7 +1283,7 @@ bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp) return true; uint size; memfindbaseaddr(bp->addr, &size); - if(!bpdel(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size)) + if(!BpDelete(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", bp->addr); return STATUS_ERROR; @@ -1295,7 +1295,7 @@ bool cbDeleteAllHardwareBreakpoints(const BREAKPOINT* bp) { if(!bp->enabled) return true; - if(!bpdel(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) + if(!BpDelete(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { dprintf("Delete hardware breakpoint failed: "fhex"\n", bp->addr); return STATUS_ERROR; diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 9d53ce22..2e93d8b7 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -209,7 +209,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] const char* bpname = 0; if(*argname) bpname = argname; - if(bpget(addr, BPNORMAL, bpname, 0)) + if(BpGet(addr, BPNORMAL, bpname, 0)) { dputs("Breakpoint already set!"); return STATUS_CONTINUE; @@ -224,7 +224,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] dprintf("Error setting breakpoint at "fhex"! (memread)\n", addr); return STATUS_ERROR; } - else if(!bpnew(addr, true, singleshoot, oldbytes, BPNORMAL, type, bpname)) + else if(!BpNew(addr, true, singleshoot, oldbytes, BPNORMAL, type, bpname)) { dprintf("Error setting breakpoint at "fhex"! (bpnew)\n", addr); return STATUS_ERROR; @@ -244,21 +244,21 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!bpgetcount(BPNORMAL)) + if(!BpGetCount(BPNORMAL)) { dputs("No breakpoints to delete!"); return STATUS_CONTINUE; } - if(!bpenumall(cbDeleteAllBreakpoints)) //at least one deletion failed + if(!BpEnumAll(cbDeleteAllBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name + if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name { - if(!bpdel(found.addr, BPNORMAL)) + if(!BpDelete(found.addr, BPNORMAL)) { dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr); return STATUS_ERROR; @@ -272,12 +272,12 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint { dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } - if(!bpdel(found.addr, BPNORMAL)) + if(!BpDelete(found.addr, BPNORMAL)) { dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr); return STATUS_ERROR; @@ -298,21 +298,21 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //enable all breakpoints { - if(!bpgetcount(BPNORMAL)) + if(!BpGetCount(BPNORMAL)) { dputs("No breakpoints to enable!"); return STATUS_CONTINUE; } - if(!bpenumall(cbEnableAllBreakpoints)) //at least one enable failed + if(!BpEnumAll(cbEnableAllBreakpoints)) //at least one enable failed return STATUS_ERROR; dputs("All breakpoints enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name + if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name { - if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) + if(!BpEnable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) { dprintf("Could not enable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -321,7 +321,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint { dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -332,7 +332,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) GuiUpdateAllViews(); return STATUS_CONTINUE; } - if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) + if(!BpEnable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) { dprintf("Could not enable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -347,21 +347,21 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!bpgetcount(BPNORMAL)) + if(!BpGetCount(BPNORMAL)) { dputs("No breakpoints to disable!"); return STATUS_CONTINUE; } - if(!bpenumall(cbDisableAllBreakpoints)) //at least one deletion failed + if(!BpEnumAll(cbDisableAllBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All breakpoints disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name + if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name { - if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) + if(!BpEnable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) { dprintf("Could not disable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -370,7 +370,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint { dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -380,7 +380,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) dputs("Breakpoint already disabled!"); return STATUS_CONTINUE; } - if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) + if(!BpEnable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) { dprintf("Could not disable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -392,7 +392,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) CMDRESULT cbDebugBplist(int argc, char* argv[]) { - bpenumall(cbBreakpointList); + BpEnumAll(cbBreakpointList); return STATUS_CONTINUE; } @@ -509,12 +509,12 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]) bool singleshoot = false; if(!restore) singleshoot = true; - if(bpget(base, BPMEMORY, 0, 0)) + if(BpGet(base, BPMEMORY, 0, 0)) { dputs("Hardware breakpoint already set!"); return STATUS_CONTINUE; } - if(!bpnew(base, true, singleshoot, 0, BPMEMORY, type, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint)) + if(!BpNew(base, true, singleshoot, 0, BPMEMORY, type, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint)) { dputs("Error setting memory breakpoint!"); return STATUS_ERROR; @@ -529,23 +529,23 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!bpgetcount(BPMEMORY)) + if(!BpGetCount(BPMEMORY)) { dputs("no memory breakpoints to delete!"); return STATUS_CONTINUE; } - if(!bpenumall(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed + if(!BpEnumAll(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All memory breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(bpget(0, BPMEMORY, arg1, &found)) //found a breakpoint with name + if(BpGet(0, BPMEMORY, arg1, &found)) //found a breakpoint with name { uint size; memfindbaseaddr(found.addr, &size); - if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) + if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -553,14 +553,14 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid breakpoint { dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } uint size; memfindbaseaddr(found.addr, &size); - if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) + if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -655,12 +655,12 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]) TITANSETTYPE(titantype, type); TITANSETSIZE(titantype, titsize); //TODO: hwbp in multiple threads TEST - if(bpget(addr, BPHARDWARE, 0, 0)) + if(BpGet(addr, BPHARDWARE, 0, 0)) { dputs("Hardware breakpoint already set!"); return STATUS_CONTINUE; } - if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0)) + if(!BpNew(addr, true, false, 0, BPHARDWARE, titantype, 0)) { dputs("error setting hardware breakpoint (bpnew)!"); return STATUS_ERROR; @@ -680,21 +680,21 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!bpgetcount(BPHARDWARE)) + if(!BpGetCount(BPHARDWARE)) { dputs("No hardware breakpoints to delete!"); return STATUS_CONTINUE; } - if(!bpenumall(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed + if(!BpEnumAll(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All hardware breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(bpget(0, BPHARDWARE, arg1, &found)) //found a breakpoint with name + if(BpGet(0, BPHARDWARE, arg1, &found)) //found a breakpoint with name { - if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) + if(!BpDelete(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -702,12 +702,12 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid breakpoint { dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } - if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) + if(!BpDelete(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -1210,12 +1210,12 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) } if(!argget(*argv, arg1, 0, true)) //enable all hardware breakpoints { - if(!bpgetcount(BPHARDWARE)) + if(!BpGetCount(BPHARDWARE)) { dputs("No hardware breakpoints to enable!"); return STATUS_CONTINUE; } - if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed + if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed return STATUS_ERROR; dputs("All hardware breakpoints enabled!"); GuiUpdateAllViews(); @@ -1223,7 +1223,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint { dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1235,8 +1235,8 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } TITANSETDRX(found.titantype, drx); - bpsettitantype(found.addr, BPHARDWARE, found.titantype); - if(!bpenable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint)) + BpSetTitanType(found.addr, BPHARDWARE, found.titantype); + if(!BpEnable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint)) { dprintf("Could not enable hardware breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -1251,12 +1251,12 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all hardware breakpoints { - if(!bpgetcount(BPHARDWARE)) + if(!BpGetCount(BPHARDWARE)) { dputs("No hardware breakpoints to disable!"); return STATUS_CONTINUE; } - if(!bpenumall(cbDisableAllHardwareBreakpoints)) //at least one deletion failed + if(!BpEnumAll(cbDisableAllHardwareBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All hardware breakpoints disabled!"); GuiUpdateAllViews(); @@ -1264,7 +1264,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint { dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1274,7 +1274,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) dputs("Hardware breakpoint already disabled!"); return STATUS_CONTINUE; } - if(!bpenable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) + if(!BpEnable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { dprintf("Could not disable hardware breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -1295,12 +1295,12 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) } if(!argget(*argv, arg1, 0, true)) //enable all memory breakpoints { - if(!bpgetcount(BPMEMORY)) + if(!BpGetCount(BPMEMORY)) { dputs("No hardware breakpoints to enable!"); return STATUS_CONTINUE; } - if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed + if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed return STATUS_ERROR; dputs("All memory breakpoints enabled!"); GuiUpdateAllViews(); @@ -1308,7 +1308,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint { dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1321,7 +1321,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) } uint size = 0; memfindbaseaddr(found.addr, &size); - if(!bpenable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint)) + if(!BpEnable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint)) { dprintf("Could not enable memory breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -1336,12 +1336,12 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all memory breakpoints { - if(!bpgetcount(BPMEMORY)) + if(!BpGetCount(BPMEMORY)) { dputs("No memory breakpoints to disable!"); return STATUS_CONTINUE; } - if(!bpenumall(cbDisableAllMemoryBreakpoints)) //at least one deletion failed + if(!BpEnumAll(cbDisableAllMemoryBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All memory breakpoints disabled!"); GuiUpdateAllViews(); @@ -1349,7 +1349,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint + if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint { dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1361,7 +1361,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) } uint size = 0; memfindbaseaddr(found.addr, &size); - if(!bpenable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size)) + if(!BpEnable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Could not disable memory breakpoint "fhex"\n", found.addr); return STATUS_ERROR; diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 69f5640d..a8b29c88 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -17,9 +17,7 @@ bool ModLoad(uint base, uint size, const char* fullpath) MODINFO info; - // // Break the module path into a directory and file name - // char dir[deflen]; char* file; @@ -42,16 +40,12 @@ bool ModLoad(uint base, uint size, const char* fullpath) // Copy the name to the module struct strcpy_s(info.name, file); - // // Module base address/size/hash index - // info.hash = ModHashFromName(info.name); info.base = base; info.size = size; - // // Process module sections - // info.sections.clear(); WString wszFullPath = StringUtils::Utf8ToUtf16(fullpath); From efa87720f6d38ea0af468782187fe2e5de297940 Mon Sep 17 00:00:00 2001 From: Nukem Date: Tue, 17 Mar 2015 21:37:14 -0400 Subject: [PATCH 049/106] EnumModules() inline lambda --- x64_dbg_dbg/symbolinfo.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 6de22eea..750076e3 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -46,20 +46,6 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO SymInfo, ULONG SymbolSize, PVOID U return TRUE; } -#ifdef _WIN64 -static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) -#else -static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID UserContext) -#endif //_WIN64 -{ - SYMBOLMODULEINFO curModule; - curModule.base = BaseOfDll; - ModNameFromAddr(BaseOfDll, curModule.name, true); - - ((std::vector*)UserContext)->push_back(curModule); - return TRUE; -} - void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData) { SYMBOLCBDATA symbolCbData; @@ -76,7 +62,21 @@ void SymUpdateModuleList() // Build the vector of modules std::vector modList; - if(!SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList)) + // + // Inline lambda enum + // + auto EnumModules = [](LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) -> BOOL + { + SYMBOLMODULEINFO curModule; + curModule.base = BaseOfDll; + ModNameFromAddr(BaseOfDll, curModule.name, true); + + ((std::vector*)UserContext)->push_back(curModule); + return TRUE; + }; + + // Execute the symbol enumerator (Force cast to STDCALL) + if(!SymEnumerateModules64(fdProcessInfo->hProcess, EnumModules, &modList)) dputs("SymEnumerateModules failed!"); // Send the module data to the GUI for updating From 4e19f58bbeb85e448b668ab6604c37ae360c93aa Mon Sep 17 00:00:00 2001 From: Nukem Date: Tue, 17 Mar 2015 21:42:20 -0400 Subject: [PATCH 050/106] Create SymGetModuleList() --- x64_dbg_dbg/symbolinfo.cpp | 34 ++++++++++++++++++++++++---------- x64_dbg_dbg/symbolinfo.h | 1 + 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 750076e3..980b2d34 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -57,11 +57,8 @@ void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData) dputs("SymEnumSymbols failed!"); } -void SymUpdateModuleList() +bool SymGetModuleList(std::vector* List) { - // Build the vector of modules - std::vector modList; - // // Inline lambda enum // @@ -69,15 +66,32 @@ void SymUpdateModuleList() { SYMBOLMODULEINFO curModule; curModule.base = BaseOfDll; - ModNameFromAddr(BaseOfDll, curModule.name, true); + + // Zero module name if one isn't found + if(!ModNameFromAddr(BaseOfDll, curModule.name, true)) + memset(curModule.name, 0, MAX_MODULE_SIZE); ((std::vector*)UserContext)->push_back(curModule); return TRUE; }; // Execute the symbol enumerator (Force cast to STDCALL) - if(!SymEnumerateModules64(fdProcessInfo->hProcess, EnumModules, &modList)) - dputs("SymEnumerateModules failed!"); + if(!SymEnumerateModules64(fdProcessInfo->hProcess, EnumModules, List)) + { + dputs("SymEnumerateModules64 failed!"); + return false; + } + + return true; +} + +void SymUpdateModuleList() +{ + // Build the vector of modules + std::vector modList; + + if(!SymGetModuleList(&modList)) + return; // Send the module data to the GUI for updating GuiSymbolUpdateModuleList((int)modList.size(), modList.data()); @@ -92,8 +106,8 @@ void SymDownloadAllSymbols(const char* SymbolStore) // Build the vector of modules std::vector modList; - if(!SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList)) - dputs("SymEnumerateModules failed!"); + if(!SymGetModuleList(&modList)) + return; // Skip loading if there aren't any found modules if(modList.size() <= 0) @@ -118,7 +132,7 @@ void SymDownloadAllSymbols(const char* SymbolStore) return; } - // Reload all modules + // Reload for(auto & module : modList) { dprintf("Downloading symbols for %s...\n", module.name); diff --git a/x64_dbg_dbg/symbolinfo.h b/x64_dbg_dbg/symbolinfo.h index 873b917b..2bb57f6b 100644 --- a/x64_dbg_dbg/symbolinfo.h +++ b/x64_dbg_dbg/symbolinfo.h @@ -3,6 +3,7 @@ #include "_global.h" void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData); +bool SymGetModuleList(std::vector* List); void SymUpdateModuleList(); void SymDownloadAllSymbols(const char* SymbolStore); bool SymAddrFromName(const char* Name, uint* Address); From 66c290c33175b3d21f06772b1993a3486278cf37 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 16:35:42 -0400 Subject: [PATCH 051/106] Small compile-time optimization for locks --- x64_dbg_dbg/bookmark.cpp | 28 +++++++++++-------- x64_dbg_dbg/bookmark.h | 2 +- x64_dbg_dbg/loop.cpp | 2 +- x64_dbg_dbg/symbolinfo.cpp | 4 +-- x64_dbg_dbg/threading.cpp | 57 +++++++++++++++++++++++++------------- x64_dbg_dbg/threading.h | 37 +++++++++++++++---------- 6 files changed, 79 insertions(+), 51 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index fae3011a..03240d0b 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -32,30 +32,34 @@ bool bookmarkset(uint addr, bool manual) return true; } -bool bookmarkget(uint addr) +bool bookmarkget(uint Address) { + // CHECK: Export call + if(!DbgIsDebugging()) + return false; + SHARED_ACQUIRE(LockBookmarks); - return (bookmarks.count(ModHashFromAddr(addr)) > 0); + return (bookmarks.count(ModHashFromAddr(Address)) > 0); } -bool bookmarkdel(uint addr) +bool bookmarkdel(uint Address) { // CHECK: Export call if(!DbgIsDebugging()) return false; EXCLUSIVE_ACQUIRE(LockBookmarks); - return (bookmarks.erase(ModHashFromAddr(addr)) > 0); + return (bookmarks.erase(ModHashFromAddr(Address)) > 0); } -void bookmarkdelrange(uint start, uint end) +void bookmarkdelrange(uint Start, uint End) { // CHECK: Export call if(!DbgIsDebugging()) return; // Are all bookmarks going to be deleted? - if(start == 0x00000000 && end == 0xFFFFFFFF) + if(Start == 0x00000000 && End == 0xFFFFFFFF) { EXCLUSIVE_ACQUIRE(LockBookmarks); bookmarks.clear(); @@ -63,13 +67,13 @@ void bookmarkdelrange(uint start, uint end) else { // Make sure 'start' and 'end' reference the same module - uint modbase = ModBaseFromAddr(start); + uint modbase = ModBaseFromAddr(Start); - if(modbase != ModBaseFromAddr(end)) + if(modbase != ModBaseFromAddr(End)) return; - start -= modbase; - end -= modbase; + Start -= modbase; + End -= modbase; EXCLUSIVE_ACQUIRE(LockBookmarks); for(auto itr = bookmarks.begin(); itr != bookmarks.end();) @@ -81,7 +85,7 @@ void bookmarkdelrange(uint start, uint end) continue; } - if(itr->second.addr >= start && itr->second.addr < end) + if(itr->second.addr >= Start && itr->second.addr < End) bookmarks.erase(itr); itr++; @@ -192,6 +196,6 @@ bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) void bookmarkclear() { EXCLUSIVE_ACQUIRE(LockBookmarks); - bookmarks.clear(); + EXCLUSIVE_RELEASE(); } \ No newline at end of file diff --git a/x64_dbg_dbg/bookmark.h b/x64_dbg_dbg/bookmark.h index 1ee9ee82..b3b4aeed 100644 --- a/x64_dbg_dbg/bookmark.h +++ b/x64_dbg_dbg/bookmark.h @@ -11,7 +11,7 @@ struct BOOKMARKSINFO }; bool bookmarkset(uint addr, bool manual); -bool bookmarkget(uint addr); +bool bookmarkget(uint Address); bool bookmarkdel(uint addr); void bookmarkdelrange(uint start, uint end); void bookmarkcachesave(JSON root); diff --git a/x64_dbg_dbg/loop.cpp b/x64_dbg_dbg/loop.cpp index 584c3403..6664ae25 100644 --- a/x64_dbg_dbg/loop.cpp +++ b/x64_dbg_dbg/loop.cpp @@ -208,6 +208,6 @@ bool loopenum(LOOPSINFO* looplist, size_t* cbsize) void loopclear() { EXCLUSIVE_ACQUIRE(LockLoops); - loops.clear(); + EXCLUSIVE_RELEASE(); } \ No newline at end of file diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 980b2d34..764ac7c1 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -67,9 +67,9 @@ bool SymGetModuleList(std::vector* List) SYMBOLMODULEINFO curModule; curModule.base = BaseOfDll; - // Zero module name if one isn't found + // Terminate module name if one isn't found if(!ModNameFromAddr(BaseOfDll, curModule.name, true)) - memset(curModule.name, 0, MAX_MODULE_SIZE); + curModule.name[0] = '\0'; ((std::vector*)UserContext)->push_back(curModule); return TRUE; diff --git a/x64_dbg_dbg/threading.cpp b/x64_dbg_dbg/threading.cpp index fbe0cfa9..770108d9 100644 --- a/x64_dbg_dbg/threading.cpp +++ b/x64_dbg_dbg/threading.cpp @@ -28,10 +28,10 @@ bool waitislocked(WAIT_ID id) return waitarray[id]; } -bool CriticalSectionLocker::m_Initialized = false; -SRWLOCK CriticalSectionLocker::m_Locks[LockLast]; +bool ExclusiveSectionLocker::m_Initialized = false; +SRWLOCK ExclusiveSectionLocker::m_Locks[SectionLock::LockLast]; -void CriticalSectionLocker::Initialize() +void ExclusiveSectionLocker::Initialize() { if(m_Initialized) return; @@ -39,18 +39,18 @@ void CriticalSectionLocker::Initialize() // Destroy previous data if any existed memset(m_Locks, 0, sizeof(m_Locks)); - for(int i = 0; i < LockLast; i++) + for(int i = 0; i < ARRAYSIZE(m_Locks); i++) InitializeSRWLock(&m_Locks[i]); m_Initialized = true; } -void CriticalSectionLocker::Deinitialize() +void ExclusiveSectionLocker::Deinitialize() { if(!m_Initialized) return; - for(int i = 0; i < LockLast; i++) + for(int i = 0; i < ARRAYSIZE(m_Locks); i++) { // Wait for the lock's ownership to be released AcquireSRWLockExclusive(&m_Locks[i]); @@ -63,39 +63,56 @@ void CriticalSectionLocker::Deinitialize() m_Initialized = false; } -CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock LockIndex, bool Shared) +ExclusiveSectionLocker::ExclusiveSectionLocker(SectionLock LockIndex) { m_Lock = &m_Locks[LockIndex]; m_LockCount = 0; - Lock(Shared); + Lock(); } -CriticalSectionLocker::~CriticalSectionLocker() +ExclusiveSectionLocker::~ExclusiveSectionLocker() { if(m_LockCount > 0) Unlock(); // TODO: Assert that the lock count is zero on destructor +#ifdef _DEBUG + if(m_LockCount > 0) + __debugbreak(); +#endif } -void CriticalSectionLocker::Unlock() +void ExclusiveSectionLocker::Lock() +{ + AcquireSRWLockExclusive(m_Lock); + + m_LockCount++; +} + +void ExclusiveSectionLocker::Unlock() { m_LockCount--; - if(m_Shared) - ReleaseSRWLockShared(m_Lock); - else - ReleaseSRWLockExclusive(m_Lock); + ReleaseSRWLockExclusive(m_Lock); } -void CriticalSectionLocker::Lock(bool Shared) +SharedSectionLocker::SharedSectionLocker(SectionLock LockIndex) + : ExclusiveSectionLocker(LockIndex) { - if(Shared) - AcquireSRWLockShared(m_Lock); - else - AcquireSRWLockExclusive(m_Lock); + // Nothing to do here; parent class constructor is called +} + +void SharedSectionLocker::Lock() +{ + AcquireSRWLockShared(m_Lock); - m_Shared = Shared; m_LockCount++; +} + +void SharedSectionLocker::Unlock() +{ + m_LockCount--; + + ReleaseSRWLockShared(m_Lock); } \ No newline at end of file diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index ce534ed5..2bef15a8 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -1,5 +1,4 @@ -#ifndef _THREADING_H -#define _THREADING_H +#pragma once #include "_global.h" @@ -24,13 +23,13 @@ bool waitislocked(WAIT_ID id); // Better, but requires VISTA+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa904937%28v=vs.85%29.aspx // -#define EXCLUSIVE_ACQUIRE(Index) CriticalSectionLocker __ThreadLock(Index, false); +#define EXCLUSIVE_ACQUIRE(Index) ExclusiveSectionLocker __ThreadLock(SectionLock::##Index); #define EXCLUSIVE_RELEASE() __ThreadLock.Unlock(); -#define SHARED_ACQUIRE(Index) CriticalSectionLocker __SThreadLock(Index, true); +#define SHARED_ACQUIRE(Index) SharedSectionLocker __SThreadLock(SectionLock::##Index); #define SHARED_RELEASE() __SThreadLock.Unlock(); -enum CriticalSectionLock +enum SectionLock { LockMemoryPages, LockVariables, @@ -54,25 +53,33 @@ enum CriticalSectionLock LockLast }; -class CriticalSectionLocker +class ExclusiveSectionLocker { public: static void Initialize(); static void Deinitialize(); - CriticalSectionLocker(CriticalSectionLock LockIndex, bool Shared); - ~CriticalSectionLocker(); + ExclusiveSectionLocker(SectionLock LockIndex); + ~ExclusiveSectionLocker(); + void Lock(); void Unlock(); - void Lock(bool Shared); private: - static bool m_Initialized; - static SRWLOCK m_Locks[LockLast]; + static bool m_Initialized; + static SRWLOCK m_Locks[SectionLock::LockLast]; - SRWLOCK* m_Lock; - bool m_Shared; - BYTE m_LockCount; +protected: + SRWLOCK* m_Lock; + BYTE m_LockCount; }; -#endif // _THREADING_H +class SharedSectionLocker : public ExclusiveSectionLocker +{ +public: + SharedSectionLocker(SectionLock LockIndex); + ~SharedSectionLocker(); + + void Lock(); + void Unlock(); +}; \ No newline at end of file From 31f816afd1e1ba9124478291f72c7a2c02b3d279 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 16:45:40 -0400 Subject: [PATCH 052/106] Change 'bookmark' function names (capitalization) --- x64_dbg_dbg/bookmark.cpp | 83 ++++++++++++++++++++-------------------- x64_dbg_dbg/bookmark.h | 21 +++++----- x64_dbg_dbg/threading.h | 1 - 3 files changed, 51 insertions(+), 54 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 03240d0b..7d14af20 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -8,31 +8,31 @@ typedef std::map BookmarksInfo; static BookmarksInfo bookmarks; -bool bookmarkset(uint addr, bool manual) +bool BookmarkSet(uint Address, bool Manual) { // CHECK: Export call if(!DbgIsDebugging()) return false; // Validate the incoming address - if(!memisvalidreadptr(fdProcessInfo->hProcess, addr)) + if(!memisvalidreadptr(fdProcessInfo->hProcess, Address)) return false; BOOKMARKSINFO bookmark; - ModNameFromAddr(addr, bookmark.mod, true); - bookmark.addr = addr - ModBaseFromAddr(addr); - bookmark.manual = manual; + ModNameFromAddr(Address, bookmark.mod, true); + bookmark.addr = Address - ModBaseFromAddr(Address); + bookmark.manual = Manual; // Exclusive lock to insert new data EXCLUSIVE_ACQUIRE(LockBookmarks); - if(!bookmarks.insert(std::make_pair(ModHashFromAddr(addr), bookmark)).second) - return bookmarkdel(addr); + if(!bookmarks.insert(std::make_pair(ModHashFromAddr(Address), bookmark)).second) + return BookmarkDel(Address); return true; } -bool bookmarkget(uint Address) +bool BookmarkGet(uint Address) { // CHECK: Export call if(!DbgIsDebugging()) @@ -42,7 +42,7 @@ bool bookmarkget(uint Address) return (bookmarks.count(ModHashFromAddr(Address)) > 0); } -bool bookmarkdel(uint Address) +bool BookmarkDel(uint Address) { // CHECK: Export call if(!DbgIsDebugging()) @@ -52,7 +52,7 @@ bool bookmarkdel(uint Address) return (bookmarks.erase(ModHashFromAddr(Address)) > 0); } -void bookmarkdelrange(uint Start, uint End) +void BookmarkDelRange(uint Start, uint End) { // CHECK: Export call if(!DbgIsDebugging()) @@ -93,41 +93,42 @@ void bookmarkdelrange(uint Start, uint End) } } -void bookmarkcachesave(JSON root) +void BookmarkCacheSave(JSON Root) { EXCLUSIVE_ACQUIRE(LockBookmarks); - const JSON jsonbookmarks = json_array(); - const JSON jsonautobookmarks = json_array(); + const JSON jsonBookmarks = json_array(); + const JSON jsonAutoBookmarks = json_array(); // Save to the JSON root - for(auto itr = bookmarks.begin(); itr != bookmarks.end(); itr++) + for(auto & itr : bookmarks) { JSON curjsonbookmark = json_object(); - json_object_set_new(curjsonbookmark, "module", json_string(itr->second.mod)); - json_object_set_new(curjsonbookmark, "address", json_hex(itr->second.addr)); + json_object_set_new(curjsonbookmark, "module", json_string(itr.second.mod)); + json_object_set_new(curjsonbookmark, "address", json_hex(itr.second.addr)); - if(itr->second.manual) - json_array_append_new(jsonbookmarks, curjsonbookmark); + if(itr.second.manual) + json_array_append_new(jsonBookmarks, curjsonbookmark); else - json_array_append_new(jsonautobookmarks, curjsonbookmark); + json_array_append_new(jsonAutoBookmarks, curjsonbookmark); } - if(json_array_size(jsonbookmarks)) - json_object_set(root, "bookmarks", jsonbookmarks); + if(json_array_size(jsonBookmarks)) + json_object_set(Root, "bookmarks", jsonBookmarks); - if(json_array_size(jsonautobookmarks)) - json_object_set(root, "autobookmarks", jsonautobookmarks); + if(json_array_size(jsonAutoBookmarks)) + json_object_set(Root, "autobookmarks", jsonAutoBookmarks); - json_decref(jsonbookmarks); - json_decref(jsonautobookmarks); + json_decref(jsonBookmarks); + json_decref(jsonAutoBookmarks); } -void bookmarkcacheload(JSON root) +void BookmarkCacheLoad(JSON Root) { EXCLUSIVE_ACQUIRE(LockBookmarks); + // Inline lambda to parse each JSON entry auto AddBookmarks = [](const JSON Object, bool Manual) { size_t i; @@ -156,44 +157,44 @@ void bookmarkcacheload(JSON root) // Remove existing entries bookmarks.clear(); - const JSON jsonbookmarks = json_object_get(root, "bookmarks"); - const JSON jsonautobookmarks = json_object_get(root, "autobookmarks"); + const JSON jsonBookmarks = json_object_get(Root, "bookmarks"); + const JSON jsonAutoBookmarks = json_object_get(Root, "autobookmarks"); // Load user-set bookmarks - if(jsonbookmarks) - AddBookmarks(jsonbookmarks, true); + if(jsonBookmarks) + AddBookmarks(jsonBookmarks, true); // Load auto-set bookmarks - if(jsonautobookmarks) - AddBookmarks(jsonbookmarks, false); + if(jsonAutoBookmarks) + AddBookmarks(jsonAutoBookmarks, false); } -bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) +bool BookmarkEnum(BOOKMARKSINFO* List, size_t* Size) { // The array container must be set, or the size must be set, or both - if(!bookmarklist && !cbsize) + if(!List && !Size) return false; SHARED_ACQUIRE(LockBookmarks); // Return the size if set - if(cbsize) + if(Size) { - *cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO); + *Size = bookmarks.size() * sizeof(BOOKMARKSINFO); return true; } - // TODO: only ModBaseFromName seems wrong - for(auto itr = bookmarks.begin(); itr != bookmarks.end(); itr++, bookmarklist++) + // Copy struct and adjust the relative offset to a virtual address + for(auto & itr : bookmarks) { - *bookmarklist = itr->second; - bookmarklist->addr += ModBaseFromName(bookmarklist->mod); + *List = itr.second; + List->addr += ModBaseFromName(List->mod); } return true; } -void bookmarkclear() +void BookmarkClear() { EXCLUSIVE_ACQUIRE(LockBookmarks); bookmarks.clear(); diff --git a/x64_dbg_dbg/bookmark.h b/x64_dbg_dbg/bookmark.h index b3b4aeed..4bb9f304 100644 --- a/x64_dbg_dbg/bookmark.h +++ b/x64_dbg_dbg/bookmark.h @@ -1,5 +1,4 @@ -#ifndef _BOOKMARK_H -#define _BOOKMARK_H +#pragma once #include "_global.h" @@ -10,13 +9,11 @@ struct BOOKMARKSINFO bool manual; }; -bool bookmarkset(uint addr, bool manual); -bool bookmarkget(uint Address); -bool bookmarkdel(uint addr); -void bookmarkdelrange(uint start, uint end); -void bookmarkcachesave(JSON root); -void bookmarkcacheload(JSON root); -bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize); -void bookmarkclear(); - -#endif //_BOOKMARK_H \ No newline at end of file +bool BookmarkSet(uint Address, bool Manual); +bool BookmarkGet(uint Address); +bool BookmarkDel(uint Address); +void BookmarkDelRange(uint Start, uint End); +void BookmarkCacheSave(JSON Root); +void BookmarkCacheLoad(JSON Root); +bool BookmarkEnum(BOOKMARKSINFO* List, size_t* Size); +void BookmarkClear(); \ No newline at end of file diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 2bef15a8..eb029d9b 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -78,7 +78,6 @@ class SharedSectionLocker : public ExclusiveSectionLocker { public: SharedSectionLocker(SectionLock LockIndex); - ~SharedSectionLocker(); void Lock(); void Unlock(); From 9d03839918ee274f5fd09fd619ccc8d6db210b57 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 16:51:36 -0400 Subject: [PATCH 053/106] Small cleanup --- x64_dbg_dbg/bookmark.cpp | 5 ++--- x64_dbg_dbg/bookmark.h | 2 +- x64_dbg_dbg/breakpoint.cpp | 1 - x64_dbg_dbg/module.cpp | 2 ++ 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 7d14af20..01bb91ff 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -27,7 +27,7 @@ bool BookmarkSet(uint Address, bool Manual) EXCLUSIVE_ACQUIRE(LockBookmarks); if(!bookmarks.insert(std::make_pair(ModHashFromAddr(Address), bookmark)).second) - return BookmarkDel(Address); + return BookmarkDelete(Address); return true; } @@ -42,7 +42,7 @@ bool BookmarkGet(uint Address) return (bookmarks.count(ModHashFromAddr(Address)) > 0); } -bool BookmarkDel(uint Address) +bool BookmarkDelete(uint Address) { // CHECK: Export call if(!DbgIsDebugging()) @@ -198,5 +198,4 @@ void BookmarkClear() { EXCLUSIVE_ACQUIRE(LockBookmarks); bookmarks.clear(); - EXCLUSIVE_RELEASE(); } \ No newline at end of file diff --git a/x64_dbg_dbg/bookmark.h b/x64_dbg_dbg/bookmark.h index 4bb9f304..a6898ddc 100644 --- a/x64_dbg_dbg/bookmark.h +++ b/x64_dbg_dbg/bookmark.h @@ -11,7 +11,7 @@ struct BOOKMARKSINFO bool BookmarkSet(uint Address, bool Manual); bool BookmarkGet(uint Address); -bool BookmarkDel(uint Address); +bool BookmarkDelete(uint Address); void BookmarkDelRange(uint Start, uint End); void BookmarkCacheSave(JSON Root); void BookmarkCacheLoad(JSON Root); diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index 9b4b24d8..d1f69df4 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -392,5 +392,4 @@ void BpClear() { EXCLUSIVE_ACQUIRE(LockBreakpoints); breakpoints.clear(); - EXCLUSIVE_RELEASE(); } \ No newline at end of file diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index a8b29c88..4adc07e3 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -54,7 +54,9 @@ bool ModLoad(uint base, uint size, const char* fullpath) // Get the entry point info.entry = GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_OEP) + info.base; + // Enumerate all PE sections int sectionCount = (int)GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_SECTIONNUMBER); + for(int i = 0; i < sectionCount; i++) { MODSECTIONINFO curSection; From 94ec4a822f8fa53aad27f6e34c818fe51684949a Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 16:56:45 -0400 Subject: [PATCH 054/106] Fix possible for loop iterator bug --- x64_dbg_dbg/bookmark.cpp | 14 +++++++------- x64_dbg_dbg/breakpoint.cpp | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 01bb91ff..28628dc0 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -67,13 +67,13 @@ void BookmarkDelRange(uint Start, uint End) else { // Make sure 'start' and 'end' reference the same module - uint modbase = ModBaseFromAddr(Start); + uint moduleBase = ModBaseFromAddr(Start); - if(modbase != ModBaseFromAddr(End)) + if(moduleBase != ModBaseFromAddr(End)) return; - Start -= modbase; - End -= modbase; + Start -= moduleBase; + End -= moduleBase; EXCLUSIVE_ACQUIRE(LockBookmarks); for(auto itr = bookmarks.begin(); itr != bookmarks.end();) @@ -86,9 +86,9 @@ void BookmarkDelRange(uint Start, uint End) } if(itr->second.addr >= Start && itr->second.addr < End) - bookmarks.erase(itr); - - itr++; + itr = bookmarks.erase(itr); + else + itr++; } } } diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index d1f69df4..249bf787 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -309,7 +309,7 @@ void BpCacheSave(JSON Root) EXCLUSIVE_ACQUIRE(LockBreakpoints); // Create a JSON array to store each sub-object with a breakpoint - const JSON jsonbreakpoints = json_array(); + const JSON jsonBreakpoints = json_array(); // Loop all breakpoints for(auto & i : breakpoints) @@ -332,14 +332,14 @@ void BpCacheSave(JSON Root) json_object_set_new(jsonObj, "titantype", json_hex(breakpoint.titantype)); json_object_set_new(jsonObj, "name", json_string(breakpoint.name)); json_object_set_new(jsonObj, "module", json_string(breakpoint.mod)); - json_array_append_new(jsonbreakpoints, jsonObj); + json_array_append_new(jsonBreakpoints, jsonObj); } - if(json_array_size(jsonbreakpoints)) - json_object_set(Root, "breakpoints", jsonbreakpoints); + if(json_array_size(jsonBreakpoints)) + json_object_set(Root, "breakpoints", jsonBreakpoints); // Notify garbage collector - json_decref(jsonbreakpoints); + json_decref(jsonBreakpoints); } void BpCacheLoad(JSON Root) @@ -350,15 +350,15 @@ void BpCacheLoad(JSON Root) breakpoints.clear(); // Get a handle to the root object -> breakpoints subtree - const JSON jsonbreakpoints = json_object_get(Root, "breakpoints"); + const JSON jsonBreakpoints = json_object_get(Root, "breakpoints"); // Return if there was nothing to load - if(!jsonbreakpoints) + if(!jsonBreakpoints) return; size_t i; JSON value; - json_array_foreach(jsonbreakpoints, i, value) + json_array_foreach(jsonBreakpoints, i, value) { BREAKPOINT breakpoint; memset(&breakpoint, 0, sizeof(BREAKPOINT)); From 003babb4bb8f1d5889bea7d100ce9fd8dd351f6b Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 17:00:30 -0400 Subject: [PATCH 055/106] Small BpEnumAll optimization --- x64_dbg_dbg/bookmark.cpp | 11 ++++++----- x64_dbg_dbg/breakpoint.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 28628dc0..5ea6268f 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -85,6 +85,7 @@ void BookmarkDelRange(uint Start, uint End) continue; } + // [Start, End) if(itr->second.addr >= Start && itr->second.addr < End) itr = bookmarks.erase(itr); else @@ -103,15 +104,15 @@ void BookmarkCacheSave(JSON Root) // Save to the JSON root for(auto & itr : bookmarks) { - JSON curjsonbookmark = json_object(); + JSON currentBookmark = json_object(); - json_object_set_new(curjsonbookmark, "module", json_string(itr.second.mod)); - json_object_set_new(curjsonbookmark, "address", json_hex(itr.second.addr)); + json_object_set_new(currentBookmark, "module", json_string(itr.second.mod)); + json_object_set_new(currentBookmark, "address", json_hex(itr.second.addr)); if(itr.second.manual) - json_array_append_new(jsonBookmarks, curjsonbookmark); + json_array_append_new(jsonBookmarks, currentBookmark); else - json_array_append_new(jsonAutoBookmarks, curjsonbookmark); + json_array_append_new(jsonAutoBookmarks, currentBookmark); } if(json_array_size(jsonBookmarks)) diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index 249bf787..d7dace60 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -101,7 +101,7 @@ bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp) // Name is optional if(!Name || Name[0] == '\0') { - // Perform a lookup by an address only + // Perform a lookup by address only BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); if(!bpInfo) @@ -221,17 +221,17 @@ bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module) for(auto & i : breakpoints) { - BREAKPOINT bpInfo = i.second; - bpInfo.addr += ModBaseFromName(bpInfo.mod); - bpInfo.active = memisvalidreadptr(fdProcessInfo->hProcess, bpInfo.addr); - // If a module name was sent, check it if(Module && Module[0] != '\0') { - if(strcmp(bpInfo.mod, Module) != 0) + if(strcmp(i.second.mod, Module) != 0) continue; } + BREAKPOINT bpInfo = i.second; + bpInfo.addr += ModBaseFromName(bpInfo.mod); + bpInfo.active = memisvalidreadptr(fdProcessInfo->hProcess, bpInfo.addr); + // Execute the callback if(!EnumCallback(&bpInfo)) callbackStatus = false; From 0abe4fc1bd2955c878c991502bffb5f5dfa00a3d Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 19:03:18 -0400 Subject: [PATCH 056/106] Refactor function.cpp/.h --- x64_dbg_dbg/_exports.cpp | 26 +-- x64_dbg_dbg/addrinfo.cpp | 12 +- x64_dbg_dbg/bookmark.cpp | 3 +- x64_dbg_dbg/debugger_commands.cpp | 4 +- x64_dbg_dbg/function.cpp | 315 ++++++++++++++++++------------ x64_dbg_dbg/function.h | 23 +-- x64_dbg_dbg/instruction.cpp | 16 +- x64_dbg_dbg/module.cpp | 9 +- 8 files changed, 236 insertions(+), 172 deletions(-) diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index f150d3e5..f7c9a109 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -138,12 +138,12 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR } if(addrinfo->flags & flagbookmark) { - addrinfo->isbookmark = bookmarkget(addr); + addrinfo->isbookmark = BookmarkGet(addr); retval = true; } if(addrinfo->flags & flagfunction) { - if(functionget(addr, &addrinfo->function.start, &addrinfo->function.end)) + if(FunctionGet(addr, &addrinfo->function.start, &addrinfo->function.end)) retval = true; } if(addrinfo->flags & flagloop) @@ -306,9 +306,9 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo) if(addrinfo->flags & flagbookmark) //set bookmark { if(addrinfo->isbookmark) - retval = bookmarkset(addr, true); + retval = BookmarkSet(addr, true); else - retval = bookmarkdel(addr); + retval = BookmarkDelete(addr); } return retval; } @@ -614,7 +614,7 @@ extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr) extern "C" DLL_EXPORT bool _dbg_functionoverlaps(uint start, uint end) { - return functionoverlaps(start, end); + return FunctionOverlaps(start, end); } extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* param2) @@ -805,28 +805,28 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_FUNCTION_GET: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)functionget(info->addr, &info->start, &info->end); + return (uint)FunctionGet(info->addr, &info->start, &info->end); } break; case DBG_FUNCTION_OVERLAPS: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)functionoverlaps(info->start, info->end); + return (uint)FunctionOverlaps(info->start, info->end); } break; case DBG_FUNCTION_ADD: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)functionadd(info->start, info->end, info->manual); + return (uint)FunctionAdd(info->start, info->end, info->manual); } break; case DBG_FUNCTION_DEL: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)functiondel(info->addr); + return (uint)FunctionDelete(info->addr); } break; @@ -899,25 +899,25 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_SET_AUTO_BOOKMARK_AT: { - return (uint)bookmarkset((uint)param1, false); + return (uint)BookmarkSet((uint)param1, false); } break; case DBG_DELETE_AUTO_BOOKMARK_RANGE: { - bookmarkdelrange((uint)param1, (uint)param2); + BookmarkDelRange((uint)param1, (uint)param2); } break; case DBG_SET_AUTO_FUNCTION_AT: { - return (uint)functionadd((uint)param1, (uint)param2, false); + return (uint)FunctionAdd((uint)param1, (uint)param2, false); } break; case DBG_DELETE_AUTO_FUNCTION_RANGE: { - functiondelrange((uint)param1, (uint)param2); + FunctionDelRange((uint)param1, (uint)param2); } break; diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index ed4bb65c..52a51d9a 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -23,8 +23,8 @@ void dbsave() JSON root = json_object(); commentcachesave(root); labelcachesave(root); - bookmarkcachesave(root); - functioncachesave(root); + BookmarkCacheSave(root); + FunctionCacheSave(root); loopcachesave(root); BpCacheSave(root); WString wdbpath = StringUtils::Utf8ToUtf16(dbpath); @@ -84,8 +84,8 @@ void dbload() } commentcacheload(root); labelcacheload(root); - bookmarkcacheload(root); - functioncacheload(root); + BookmarkCacheLoad(root); + FunctionCacheLoad(root); loopcacheload(root); BpCacheLoad(root); json_decref(root); //free root @@ -97,8 +97,8 @@ void dbclose() dbsave(); commentclear(); labelclear(); - bookmarkclear(); - functionclear(); + BookmarkClear(); + FunctionClear(); loopclear(); BpClear(); patchclear(); diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 5ea6268f..6db5e1a9 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -66,12 +66,13 @@ void BookmarkDelRange(uint Start, uint End) } else { - // Make sure 'start' and 'end' reference the same module + // Make sure 'Start' and 'End' reference the same module uint moduleBase = ModBaseFromAddr(Start); if(moduleBase != ModBaseFromAddr(End)) return; + // Virtual -> relative offset Start -= moduleBase; End -= moduleBase; diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 2e93d8b7..c3d23861 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -813,8 +813,8 @@ CMDRESULT cbDebugBenchmark(int argc, char* argv[]) { commentset(i, "test", false); labelset(i, "test", false); - bookmarkset(i, false); - functionadd(i, i, false); + BookmarkSet(i, false); + FunctionAdd(i, i, false); } dprintf("%ums\n", GetTickCount() - ticks); return STATUS_CONTINUE; diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp index e24c01e5..090b3c58 100644 --- a/x64_dbg_dbg/function.cpp +++ b/x64_dbg_dbg/function.cpp @@ -8,185 +8,256 @@ typedef std::map FunctionsInfo; static FunctionsInfo functions; -bool functionadd(uint start, uint end, bool manual) +bool FunctionAdd(uint Start, uint End, bool Manual) { - if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) + // CHECK: Export/Command function + if(!DbgIsDebugging()) return false; - const uint modbase = ModBaseFromAddr(start); - if(modbase != ModBaseFromAddr(end)) //the function boundaries are not in the same module + + // Make sure memory is readable + if(!memisvalidreadptr(fdProcessInfo->hProcess, Start)) return false; - if(functionoverlaps(start, end)) + + // Fail if boundary exceeds module size + const uint moduleBase = ModBaseFromAddr(Start); + + if(moduleBase != ModBaseFromAddr(End)) return false; + + // Fail if 'Start' and 'End' are incompatible + if(Start > End || FunctionOverlaps(Start, End)) + return false; + FUNCTIONSINFO function; - ModNameFromAddr(start, function.mod, true); - function.start = start - modbase; - function.end = end - modbase; - function.manual = manual; - CriticalSectionLocker locker(LockFunctions); - functions.insert(std::make_pair(ModuleRange(ModHashFromAddr(modbase), Range(function.start, function.end)), function)); + ModNameFromAddr(Start, function.mod, true); + function.start = Start - moduleBase; + function.end = End - moduleBase; + function.manual = Manual; + + // Insert to global table + EXCLUSIVE_ACQUIRE(LockFunctions); + + functions.insert(std::make_pair(ModuleRange(ModHashFromAddr(moduleBase), Range(function.start, function.end)), function)); return true; } -bool functionget(uint addr, uint* start, uint* end) +bool FunctionGet(uint Address, uint* Start, uint* End) { + // CHECK: Exported function if(!DbgIsDebugging()) return false; - uint modbase = ModBaseFromAddr(addr); - CriticalSectionLocker locker(LockFunctions); - const FunctionsInfo::iterator found = functions.find(ModuleRange(ModHashFromAddr(modbase), Range(addr - modbase, addr - modbase))); - if(found == functions.end()) //not found + + const uint modbase = ModBaseFromAddr(Address); + + // Lookup by module hash, then function range + SHARED_ACQUIRE(LockFunctions); + + auto found = functions.find(ModuleRange(ModHashFromAddr(modbase), Range(Address - modbase, Address - modbase))); + + // Was this range found? + if(found == functions.end()) return false; - if(start) - *start = found->second.start + modbase; - if(end) - *end = found->second.end + modbase; + + if(Start) + *Start = found->second.start + modbase; + + if(End) + *End = found->second.end + modbase; + return true; } -bool functionoverlaps(uint start, uint end) -{ - if(!DbgIsDebugging() or end < start) - return false; - const uint modbase = ModBaseFromAddr(start); - CriticalSectionLocker locker(LockFunctions); - return (functions.count(ModuleRange(ModHashFromAddr(modbase), Range(start - modbase, end - modbase))) > 0); -} - -bool functiondel(uint addr) +bool FunctionOverlaps(uint Start, uint End) { + // CHECK: Exported function if(!DbgIsDebugging()) return false; - const uint modbase = ModBaseFromAddr(addr); - CriticalSectionLocker locker(LockFunctions); - return (functions.erase(ModuleRange(ModHashFromAddr(modbase), Range(addr - modbase, addr - modbase))) > 0); + + // A function can't end before it begins + if(Start > End) + return false; + + const uint moduleBase = ModBaseFromAddr(Start); + + SHARED_ACQUIRE(LockFunctions); + return (functions.count(ModuleRange(ModHashFromAddr(moduleBase), Range(Start - moduleBase, End - moduleBase))) > 0); } -void functiondelrange(uint start, uint end) +bool FunctionDelete(uint Address) { + // CHECK: Exported function + if(!DbgIsDebugging()) + return false; + + const uint moduleBase = ModBaseFromAddr(Address); + + EXCLUSIVE_ACQUIRE(LockFunctions); + return (functions.erase(ModuleRange(ModHashFromAddr(moduleBase), Range(Address - moduleBase, Address - moduleBase))) > 0); +} + +void FunctionDelRange(uint Start, uint End) +{ + // CHECK: Exported function if(!DbgIsDebugging()) return; - bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = ModBaseFromAddr(start); - if(modbase != ModBaseFromAddr(end)) - return; - start -= modbase; - end -= modbase; - CriticalSectionLocker locker(LockFunctions); - FunctionsInfo::iterator i = functions.begin(); - while(i != functions.end()) + + // Should all functions be deleted? + if(Start == 0x00000000 && End == 0xFFFFFFFF) { - if(i->second.manual) //ignore manual + EXCLUSIVE_ACQUIRE(LockFunctions); + functions.clear(); + } + else + { + uint moduleBase = ModBaseFromAddr(Start); + + // The start and end address must be in the same module + if(moduleBase != ModBaseFromAddr(End)) + return; + + // Convert these to a relative offset + Start -= moduleBase; + End -= moduleBase; + + EXCLUSIVE_ACQUIRE(LockFunctions); + for(auto itr = functions.begin(); itr != functions.end();) { - i++; - continue; + // Ignore manually set entries + if(itr->second.manual) + { + itr++; + continue; + } + + // [Start, End] + if(itr->second.end >= Start && itr->second.start <= End) + itr = functions.erase(itr); + else + itr++; } - if(bDelAll or !(i->second.start <= end and i->second.end >= start)) - functions.erase(i++); - else - i++; } } -void functioncachesave(JSON root) +void FunctionCacheSave(JSON Root) { - CriticalSectionLocker locker(LockFunctions); - const JSON jsonfunctions = json_array(); - const JSON jsonautofunctions = json_array(); - for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i) + EXCLUSIVE_ACQUIRE(LockFunctions); + + // Allocate JSON object array + const JSON jsonFunctions = json_array(); + const JSON jsonAutoFunctions = json_array(); + + for(auto & i : functions) { - const FUNCTIONSINFO curFunction = i->second; - JSON curjsonfunction = json_object(); - json_object_set_new(curjsonfunction, "module", json_string(curFunction.mod)); - json_object_set_new(curjsonfunction, "start", json_hex(curFunction.start)); - json_object_set_new(curjsonfunction, "end", json_hex(curFunction.end)); - if(curFunction.manual) - json_array_append_new(jsonfunctions, curjsonfunction); + JSON currentFunction = json_object(); + + json_object_set_new(currentFunction, "module", json_string(i.second.mod)); + json_object_set_new(currentFunction, "start", json_hex(i.second.start)); + json_object_set_new(currentFunction, "end", json_hex(i.second.end)); + + if(i.second.manual) + json_array_append_new(jsonFunctions, currentFunction); else - json_array_append_new(jsonautofunctions, curjsonfunction); + json_array_append_new(jsonAutoFunctions, currentFunction); } - if(json_array_size(jsonfunctions)) - json_object_set(root, "functions", jsonfunctions); - json_decref(jsonfunctions); - if(json_array_size(jsonautofunctions)) - json_object_set(root, "autofunctions", jsonautofunctions); - json_decref(jsonautofunctions); + + if(json_array_size(jsonFunctions)) + json_object_set(Root, "functions", jsonFunctions); + + if(json_array_size(jsonAutoFunctions)) + json_object_set(Root, "autofunctions", jsonAutoFunctions); + + // Decrease reference count to avoid leaking memory + json_decref(jsonFunctions); + json_decref(jsonAutoFunctions); } -void functioncacheload(JSON root) +void FunctionCacheLoad(JSON Root) { - CriticalSectionLocker locker(LockFunctions); + EXCLUSIVE_ACQUIRE(LockFunctions); + + // Delete existing entries functions.clear(); - const JSON jsonfunctions = json_object_get(root, "functions"); - if(jsonfunctions) + + // Inline lambda to enumerate all JSON array indices + auto InsertFunctions = [](const JSON Object, bool Manual) { size_t i; JSON value; - json_array_foreach(jsonfunctions, i, value) + json_array_foreach(Object, i, value) { - FUNCTIONSINFO curFunction; + FUNCTIONSINFO function; + + // Copy module name const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(curFunction.mod, mod); + strcpy_s(function.mod, mod); else - *curFunction.mod = '\0'; - curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); - curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); - if(curFunction.end < curFunction.start) - continue; //invalid function - curFunction.manual = true; - const uint key = ModHashFromName(curFunction.mod); - functions.insert(std::make_pair(ModuleRange(ModHashFromName(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); + function.mod[0] = '\0'; + + // Function address + function.start = (uint)json_hex_value(json_object_get(value, "start")); + function.end = (uint)json_hex_value(json_object_get(value, "end")); + function.manual = Manual; + + // Sanity check + if(function.end < function.start) + continue; + + const uint key = ModHashFromName(function.mod); + functions.insert(std::make_pair(ModuleRange(ModHashFromName(function.mod), Range(function.start, function.end)), function)); } - } - JSON jsonautofunctions = json_object_get(root, "autofunctions"); - if(jsonautofunctions) - { - size_t i; - JSON value; - json_array_foreach(jsonautofunctions, i, value) - { - FUNCTIONSINFO curFunction; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(curFunction.mod, mod); - else - *curFunction.mod = '\0'; - curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); - curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); - if(curFunction.end < curFunction.start) - continue; //invalid function - curFunction.manual = true; - const uint key = ModHashFromName(curFunction.mod); - functions.insert(std::make_pair(ModuleRange(ModHashFromName(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); - } - } + }; + + const JSON jsonFunctions = json_object_get(Root, "functions"); + const JSON jsonAutoFunctions = json_object_get(Root, "autofunctions"); + + if(jsonFunctions) + InsertFunctions(jsonFunctions, true); + + if(jsonAutoFunctions) + InsertFunctions(jsonAutoFunctions, false); } -bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize) +bool FunctionEnum(FUNCTIONSINFO* List, size_t* Size) { + // CHECK: Exported function if(!DbgIsDebugging()) return false; - if(!functionlist && !cbsize) + + // If a list isn't passed and the size not requested, fail + if(!List && !Size) return false; - CriticalSectionLocker locker(LockFunctions); - if(!functionlist && cbsize) + + SHARED_ACQUIRE(LockFunctions); + + // Did the caller request the buffer size needed? + if(Size) { - *cbsize = functions.size() * sizeof(FUNCTIONSINFO); - return true; + *Size = functions.size() * sizeof(FUNCTIONSINFO); + + if(!List) + return true; } - int j = 0; - for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i, j++) + + // Fill out the buffer + for(auto & itr : functions) { - functionlist[j] = i->second; - uint modbase = ModBaseFromName(functionlist[j].mod); - functionlist[j].start += modbase; - functionlist[j].end += modbase; + // Adjust for relative to virtual addresses + uint moduleBase = ModBaseFromName(itr.second.mod); + + *List = itr.second; + List->start += moduleBase; + List->end += moduleBase; + + List++; } + return true; } -void functionclear() +void FunctionClear() { - CriticalSectionLocker locker(LockFunctions); - FunctionsInfo().swap(functions); + EXCLUSIVE_ACQUIRE(LockFunctions); + functions.clear(); } \ No newline at end of file diff --git a/x64_dbg_dbg/function.h b/x64_dbg_dbg/function.h index 53f4adda..41afb223 100644 --- a/x64_dbg_dbg/function.h +++ b/x64_dbg_dbg/function.h @@ -1,5 +1,4 @@ -#ifndef _FUNCTION_H -#define _FUNCTION_H +#pragma once #include "addrinfo.h" @@ -11,14 +10,12 @@ struct FUNCTIONSINFO bool manual; }; -bool functionadd(uint start, uint end, bool manual); -bool functionget(uint addr, uint* start, uint* end); -bool functionoverlaps(uint start, uint end); -bool functiondel(uint addr); -void functiondelrange(uint start, uint end); -void functioncachesave(JSON root); -void functioncacheload(JSON root); -bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize); -void functionclear(); - -#endif //_FUNCTION_H \ No newline at end of file +bool FunctionAdd(uint Start, uint End, bool Manual); +bool FunctionGet(uint Address, uint* Start, uint* End); +bool FunctionOverlaps(uint Start, uint End); +bool FunctionDelete(uint Address); +void FunctionDelRange(uint Start, uint End); +void FunctionCacheSave(JSON Root); +void FunctionCacheLoad(JSON Root); +bool FunctionEnum(FUNCTIONSINFO* List, size_t* Size); +void FunctionClear(); \ No newline at end of file diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index f9cba729..a48047b5 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -368,7 +368,7 @@ CMDRESULT cbInstrBookmarkSet(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!bookmarkset(addr, true)) + if(!BookmarkSet(addr, true)) { dputs("failed to set bookmark!"); return STATUS_ERROR; @@ -387,7 +387,7 @@ CMDRESULT cbInstrBookmarkDel(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!bookmarkdel(addr)) + if(!BookmarkDelete(addr)) { dputs("failed to delete bookmark!"); return STATUS_ERROR; @@ -454,7 +454,7 @@ CMDRESULT cbFunctionAdd(int argc, char* argv[]) uint end = 0; if(!valfromstring(argv[1], &start, false) or !valfromstring(argv[2], &end, false)) return STATUS_ERROR; - if(!functionadd(start, end, true)) + if(!FunctionAdd(start, end, true)) { dputs("failed to add function"); return STATUS_ERROR; @@ -474,7 +474,7 @@ CMDRESULT cbFunctionDel(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!functiondel(addr)) + if(!FunctionDelete(addr)) { dputs("failed to delete function"); return STATUS_ERROR; @@ -1339,14 +1339,14 @@ CMDRESULT cbInstrBookmarkList(int argc, char* argv[]) GuiReferenceAddColumn(0, "Disassembly"); GuiReferenceReloadData(); size_t cbsize; - bookmarkenum(0, &cbsize); + BookmarkEnum(0, &cbsize); if(!cbsize) { dputs("no bookmarks"); return STATUS_CONTINUE; } Memory bookmarks(cbsize, "cbInstrBookmarkList:bookmarks"); - bookmarkenum(bookmarks, 0); + BookmarkEnum(bookmarks, 0); int count = (int)(cbsize / sizeof(BOOKMARKSINFO)); for(int i = 0; i < count; i++) { @@ -1374,14 +1374,14 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[]) GuiReferenceAddColumn(0, "Label/Comment"); GuiReferenceReloadData(); size_t cbsize; - functionenum(0, &cbsize); + FunctionEnum(0, &cbsize); if(!cbsize) { dputs("no functions"); return STATUS_CONTINUE; } Memory functions(cbsize, "cbInstrFunctionList:functions"); - functionenum(functions, 0); + FunctionEnum(functions, 0); int count = (int)(cbsize / sizeof(FUNCTIONSINFO)); for(int i = 0; i < count; i++) { diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 4adc07e3..f3186c0b 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -105,7 +105,6 @@ bool ModUnload(uint base) void ModClear() { - // Remove all modules in the list EXCLUSIVE_ACQUIRE(LockModules); modinfo.clear(); EXCLUSIVE_RELEASE(); @@ -141,13 +140,9 @@ bool ModNameFromAddr(uint addr, char* modname, bool extension) if(!module) return false; - // Zero buffer first - memset(modname, 0, MAX_MODULE_SIZE); + // Copy initial module name + strcpy_s(modname, MAX_MODULE_SIZE, module->name); - // Append the module path/name - strcat_s(modname, MAX_MODULE_SIZE, module->name); - - // Append the extension if(extension) strcat_s(modname, MAX_MODULE_SIZE, module->extension); From 179c5ea5ddd0be0940d7882705f65910817c9df7 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 19:04:00 -0400 Subject: [PATCH 057/106] Missing SHARED_ACQUIRE --- x64_dbg_dbg/module.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index f3186c0b..c1e29939 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -247,6 +247,8 @@ uint ModEntryFromAddr(uint addr) int ModPathFromAddr(duint addr, char* path, int size) { + SHARED_ACQUIRE(LockModules); + auto module = ModInfoFromAddr(addr); if(!module) From e6b9a681b069b3de20e1bb21f78ed3a0e8ec9b16 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 19:08:46 -0400 Subject: [PATCH 058/106] Change module function parameter names --- x64_dbg_dbg/module.cpp | 85 +++++++++++++++++++++--------------------- x64_dbg_dbg/module.h | 26 ++++++------- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index c1e29939..73593658 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -6,13 +6,13 @@ static ModulesInfo modinfo; -bool ModLoad(uint base, uint size, const char* fullpath) +bool ModLoad(uint Base, uint Size, const char* FullPath) { // // Handle a new module being loaded // // TODO: Do loaded modules always require a path? - if(!base or !size or !fullpath) + if(!Base || !Size || !FullPath) return false; MODINFO info; @@ -21,7 +21,8 @@ bool ModLoad(uint base, uint size, const char* fullpath) char dir[deflen]; char* file; - GetFullPathNameA(fullpath, deflen, dir, &file); + if(GetFullPathNameA(FullPath, ARRAYSIZE(dir), dir, &file) == 0) + return false; // Make everything lowercase _strlwr(dir); @@ -42,13 +43,13 @@ bool ModLoad(uint base, uint size, const char* fullpath) // Module base address/size/hash index info.hash = ModHashFromName(info.name); - info.base = base; - info.size = size; + info.base = Base; + info.size = Size; // Process module sections info.sections.clear(); - WString wszFullPath = StringUtils::Utf8ToUtf16(fullpath); + WString wszFullPath = StringUtils::Utf8ToUtf16(FullPath); if(StaticFileLoadW(wszFullPath.c_str(), UE_ACCESS_READ, false, &info.Handle, &info.FileMapSize, &info.MapHandle, &info.FileMapVA)) { // Get the entry point @@ -75,19 +76,19 @@ bool ModLoad(uint base, uint size, const char* fullpath) // Add module to list EXCLUSIVE_ACQUIRE(LockModules); - modinfo.insert(std::make_pair(Range(base, base + size - 1), info)); + modinfo.insert(std::make_pair(Range(Base, Base + Size - 1), info)); EXCLUSIVE_RELEASE(); SymUpdateModuleList(); return true; } -bool ModUnload(uint base) +bool ModUnload(uint Base) { EXCLUSIVE_ACQUIRE(LockModules); // Find the iterator index - const auto found = modinfo.find(Range(base, base)); + const auto found = modinfo.find(Range(Base, Base)); if(found == modinfo.end()) return false; @@ -113,12 +114,12 @@ void ModClear() SymUpdateModuleList(); } -MODINFO* ModInfoFromAddr(uint addr) +MODINFO* ModInfoFromAddr(uint Address) { // // NOTE: THIS DOES _NOT_ USE LOCKS // - auto found = modinfo.find(Range(addr, addr)); + auto found = modinfo.find(Range(Address, Address)); // Was the module found with this address? if(found == modinfo.end()) @@ -127,33 +128,33 @@ MODINFO* ModInfoFromAddr(uint addr) return &found->second; } -bool ModNameFromAddr(uint addr, char* modname, bool extension) +bool ModNameFromAddr(uint Address, char* Name, bool Extension) { - if(!modname) + if(!Name) return false; SHARED_ACQUIRE(LockModules); // Get a pointer to module information - auto module = ModInfoFromAddr(addr); + auto module = ModInfoFromAddr(Address); if(!module) return false; // Copy initial module name - strcpy_s(modname, MAX_MODULE_SIZE, module->name); + strcpy_s(Name, MAX_MODULE_SIZE, module->name); - if(extension) - strcat_s(modname, MAX_MODULE_SIZE, module->extension); + if(Extension) + strcat_s(Name, MAX_MODULE_SIZE, module->extension); return true; } -uint ModBaseFromAddr(uint addr) +uint ModBaseFromAddr(uint Address) { SHARED_ACQUIRE(LockModules); - auto module = ModInfoFromAddr(addr); + auto module = ModInfoFromAddr(Address); if(!module) return 0; @@ -161,35 +162,35 @@ uint ModBaseFromAddr(uint addr) return module->base; } -uint ModHashFromAddr(uint addr) +uint ModHashFromAddr(uint Address) { // // Returns a unique hash from a virtual address // SHARED_ACQUIRE(LockModules); - auto module = ModInfoFromAddr(addr); + auto module = ModInfoFromAddr(Address); if(!module) - return addr; + return Address; - return module->hash + (addr - module->base); + return module->hash + (Address - module->base); } -uint ModHashFromName(const char* mod) +uint ModHashFromName(const char* Module) { // // return MODINFO.hash (based on the name) // - if(!mod || !mod[0]) + if(!Module || Module[0] == '\0') return 0; - return murmurhash(mod, (int)strlen(mod)); + return murmurhash(Module, (int)strlen(Module)); } -uint ModBaseFromName(const char* modname) +uint ModBaseFromName(const char* Module) { - if(!modname || strlen(modname) >= MAX_MODULE_SIZE) + if(!Module || strlen(Module) >= MAX_MODULE_SIZE) return 0; SHARED_ACQUIRE(LockModules); @@ -200,18 +201,18 @@ uint ModBaseFromName(const char* modname) sprintf(curmodname, "%s%s", itr->second.name, itr->second.extension); // Test with and without extension - if(!_stricmp(curmodname, modname) || !_stricmp(itr->second.name, modname)) + if(!_stricmp(curmodname, Module) || !_stricmp(itr->second.name, Module)) return itr->second.base; } return 0; } -uint ModSizeFromAddr(uint addr) +uint ModSizeFromAddr(uint Address) { SHARED_ACQUIRE(LockModules); - auto module = ModInfoFromAddr(addr); + auto module = ModInfoFromAddr(Address); if(!module) return 0; @@ -219,25 +220,25 @@ uint ModSizeFromAddr(uint addr) return module->size; } -bool ModSectionsFromAddr(uint addr, std::vector* sections) +bool ModSectionsFromAddr(uint Address, std::vector* Sections) { SHARED_ACQUIRE(LockModules); - auto module = ModInfoFromAddr(addr); + auto module = ModInfoFromAddr(Address); if(!module) return false; // Copy vector <-> vector - *sections = module->sections; + *Sections = module->sections; return true; } -uint ModEntryFromAddr(uint addr) +uint ModEntryFromAddr(uint Address) { SHARED_ACQUIRE(LockModules); - auto module = ModInfoFromAddr(addr); + auto module = ModInfoFromAddr(Address); if(!module) return 0; @@ -245,20 +246,20 @@ uint ModEntryFromAddr(uint addr) return module->entry; } -int ModPathFromAddr(duint addr, char* path, int size) +int ModPathFromAddr(duint Address, char* Path, int Size) { SHARED_ACQUIRE(LockModules); - auto module = ModInfoFromAddr(addr); + auto module = ModInfoFromAddr(Address); if(!module) return 0; - strcpy_s(path, size, module->path); - return (int)strlen(path); + strcpy_s(Path, Size, module->path); + return (int)strlen(Path); } -int ModPathFromName(const char* modname, char* path, int size) +int ModPathFromName(const char* Module, char* Path, int Size) { - return ModPathFromAddr(ModBaseFromName(modname), path, size); + return ModPathFromAddr(ModBaseFromName(Module), Path, Size); } \ No newline at end of file diff --git a/x64_dbg_dbg/module.h b/x64_dbg_dbg/module.h index c59cb97c..656cc310 100644 --- a/x64_dbg_dbg/module.h +++ b/x64_dbg_dbg/module.h @@ -31,17 +31,17 @@ struct MODINFO typedef std::map ModulesInfo; -bool ModLoad(uint base, uint size, const char* fullpath); -bool ModUnload(uint base); +bool ModLoad(uint Base, uint Size, const char* FullPath); +bool ModUnload(uint Base); void ModClear(); -MODINFO* ModInfoFromAddr(uint addr); -bool ModNameFromAddr(uint addr, char* modname, bool extension); -uint ModBaseFromAddr(uint addr); -uint ModHashFromAddr(uint addr); -uint ModHashFromName(const char* mod); -uint ModBaseFromName(const char* modname); -uint ModSizeFromAddr(uint addr); -bool ModSectionsFromAddr(uint addr, std::vector* sections); -uint ModEntryFromAddr(uint addr); -int ModPathFromAddr(duint addr, char* path, int size); -int ModPathFromName(const char* modname, char* path, int size); \ No newline at end of file +MODINFO* ModInfoFromAddr(uint Address); +bool ModNameFromAddr(uint Address, char* Name, bool Extension); +uint ModBaseFromAddr(uint Address); +uint ModHashFromAddr(uint Address); +uint ModHashFromName(const char* Module); +uint ModBaseFromName(const char* Module); +uint ModSizeFromAddr(uint Address); +bool ModSectionsFromAddr(uint Address, std::vector* Sections); +uint ModEntryFromAddr(uint Address); +int ModPathFromAddr(duint Address, char* Path, int Size); +int ModPathFromName(const char* Module, char* Path, int Size); \ No newline at end of file From a80f6f0bf9b51f49a365ed937cdaefb060cdeba5 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 19:12:34 -0400 Subject: [PATCH 059/106] Use a local buffer in dprintf --- x64_dbg_dbg/console.cpp | 19 ++++++++++--------- x64_dbg_dbg/console.h | 10 +++------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/x64_dbg_dbg/console.cpp b/x64_dbg_dbg/console.cpp index 15895114..30a31e92 100644 --- a/x64_dbg_dbg/console.cpp +++ b/x64_dbg_dbg/console.cpp @@ -1,18 +1,19 @@ #include "console.h" #include "threading.h" -static char msg[66000] = ""; - -void dputs(const char* text) +void dputs(const char* Text) { - dprintf("%s\n", text); + dprintf("%s\n", Text); } -void dprintf(const char* format, ...) +void dprintf(const char* Format, ...) { - CriticalSectionLocker locker(LockDprintf); va_list args; - va_start(args, format); - vsnprintf(msg, sizeof(msg), format, args); - GuiAddLogMessage(msg); + char buffer[16384]; + + va_start(args, Format); + vsnprintf_s(buffer, _TRUNCATE, Format, args); + va_end(args); + + GuiAddLogMessage(buffer); } diff --git a/x64_dbg_dbg/console.h b/x64_dbg_dbg/console.h index 1407ed0d..52e4e488 100644 --- a/x64_dbg_dbg/console.h +++ b/x64_dbg_dbg/console.h @@ -1,10 +1,6 @@ -#ifndef _CONSOLE_H -#define _CONSOLE_H +#pragma once #include "_global.h" -//functions -void dputs(const char* text); -void dprintf(const char* format, ...); - -#endif // _CONSOLE_H +void dputs(const char* Text); +void dprintf(const char* Format, ...); \ No newline at end of file From f161227174d91e661fe093fc6db752ac396bfff1 Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 18 Mar 2015 19:25:18 -0400 Subject: [PATCH 060/106] Fix BpGetCount and some warnings --- x64_dbg_dbg/breakpoint.h | 2 +- x64_dbg_dbg/function.cpp | 2 +- x64_dbg_dbg/symbolinfo.cpp | 4 ++-- x64_dbg_dbg/threading.cpp | 4 ---- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/x64_dbg_dbg/breakpoint.h b/x64_dbg_dbg/breakpoint.h index e30bb70f..d9806102 100644 --- a/x64_dbg_dbg/breakpoint.h +++ b/x64_dbg_dbg/breakpoint.h @@ -43,7 +43,7 @@ bool BpSetName(uint Address, BP_TYPE Type, const char* Name); bool BpSetTitanType(uint Address, BP_TYPE Type, int TitanType); bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module); bool BpEnumAll(BPENUMCALLBACK EnumCallback); -int BpGetCount(BP_TYPE Type, bool EnabledOnly); +int BpGetCount(BP_TYPE Type, bool EnabledOnly = false); void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp); void BpCacheSave(JSON Root); void BpCacheLoad(JSON Root); diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp index 090b3c58..87552a96 100644 --- a/x64_dbg_dbg/function.cpp +++ b/x64_dbg_dbg/function.cpp @@ -109,9 +109,9 @@ void FunctionDelRange(uint Start, uint End) } else { + // The start and end address must be in the same module uint moduleBase = ModBaseFromAddr(Start); - // The start and end address must be in the same module if(moduleBase != ModBaseFromAddr(End)) return; diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 764ac7c1..b44d1133 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -65,10 +65,10 @@ bool SymGetModuleList(std::vector* List) auto EnumModules = [](LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) -> BOOL { SYMBOLMODULEINFO curModule; - curModule.base = BaseOfDll; + curModule.base = (duint)BaseOfDll; // Terminate module name if one isn't found - if(!ModNameFromAddr(BaseOfDll, curModule.name, true)) + if(!ModNameFromAddr(curModule.base, curModule.name, true)) curModule.name[0] = '\0'; ((std::vector*)UserContext)->push_back(curModule); diff --git a/x64_dbg_dbg/threading.cpp b/x64_dbg_dbg/threading.cpp index 770108d9..3475196e 100644 --- a/x64_dbg_dbg/threading.cpp +++ b/x64_dbg_dbg/threading.cpp @@ -86,14 +86,12 @@ ExclusiveSectionLocker::~ExclusiveSectionLocker() void ExclusiveSectionLocker::Lock() { AcquireSRWLockExclusive(m_Lock); - m_LockCount++; } void ExclusiveSectionLocker::Unlock() { m_LockCount--; - ReleaseSRWLockExclusive(m_Lock); } @@ -106,13 +104,11 @@ SharedSectionLocker::SharedSectionLocker(SectionLock LockIndex) void SharedSectionLocker::Lock() { AcquireSRWLockShared(m_Lock); - m_LockCount++; } void SharedSectionLocker::Unlock() { m_LockCount--; - ReleaseSRWLockShared(m_Lock); } \ No newline at end of file From 0fb5f7590b0a5baa3934f261825cf4426915b5e7 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 22 Mar 2015 14:09:43 +0100 Subject: [PATCH 061/106] GUI: some fixes with importing patches --- x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp b/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp index a4fe10b9..e9a3dec9 100644 --- a/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp @@ -507,8 +507,8 @@ void PatchDialog::on_btnImport_clicked() typedef struct _IMPORTSTATUS { - bool nomatchoriginal; - bool matchold; + bool badoriginal; + bool alreadypatched; } IMPORTSTATUS; QList> patchList; DBGPATCHINFO curPatch; @@ -545,13 +545,13 @@ void PatchDialog::on_btnImport_clicked() continue; unsigned char checkbyte = 0; DbgMemRead(curPatch.addr, &checkbyte, sizeof(checkbyte)); - if(checkbyte == newbyte) + IMPORTSTATUS status; + if(status.alreadypatched = checkbyte == newbyte) bAlreadyDone = true; - else if(checkbyte != oldbyte) + else if(status.badoriginal = checkbyte != oldbyte) bBadOriginal = true; curPatch.oldbyte = oldbyte; curPatch.newbyte = newbyte; - IMPORTSTATUS status = {checkbyte != oldbyte && !checkbyte == newbyte, checkbyte == newbyte}; patchList.push_back(QPair(curPatch, status)); } @@ -590,12 +590,11 @@ void PatchDialog::on_btnImport_clicked() int patched = 0; for(int i = 0; i < patchList.size(); i++) { - if(!bPatchBadOriginals && patchList.at(i).second.nomatchoriginal) + if(!bPatchBadOriginals && patchList.at(i).second.badoriginal) continue; curPatch = patchList.at(i).first; - if(bUndoPatched && patchList.at(i).second.matchold) + if(bUndoPatched && patchList.at(i).second.alreadypatched) { - GuiAddStatusBarMessage("undo!"); if(DbgFunctions()->MemPatch(curPatch.addr, &curPatch.oldbyte, 1)) patched++; } From b42bb8a19e4eb53e9e570c22fe4b7296c14d36eb Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 22 Mar 2015 19:03:04 -0400 Subject: [PATCH 062/106] Refactor comment.cpp/.h --- x64_dbg_dbg/_exports.cpp | 8 +- x64_dbg_dbg/addrinfo.cpp | 6 +- x64_dbg_dbg/bookmark.cpp | 4 +- x64_dbg_dbg/comment.cpp | 305 ++++++++++++++++++------------ x64_dbg_dbg/comment.h | 21 +- x64_dbg_dbg/debugger_commands.cpp | 2 +- x64_dbg_dbg/instruction.cpp | 12 +- 7 files changed, 213 insertions(+), 145 deletions(-) diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index f7c9a109..621d8996 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -154,7 +154,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR if(addrinfo->flags & flagcomment) { *addrinfo->comment = 0; - if(commentget(addr, addrinfo->comment)) + if(CommentGet(addr, addrinfo->comment)) retval = true; else { @@ -300,7 +300,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo) } if(addrinfo->flags & flagcomment) //set comment { - if(commentset(addr, addrinfo->comment, true)) + if(CommentSet(addr, addrinfo->comment, true)) retval = true; } if(addrinfo->flags & flagbookmark) //set bookmark @@ -875,13 +875,13 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_SET_AUTO_COMMENT_AT: { - return (uint)commentset((uint)param1, (const char*)param2, false); + return (uint)CommentSet((uint)param1, (const char*)param2, false); } break; case DBG_DELETE_AUTO_COMMENT_RANGE: { - commentdelrange((uint)param1, (uint)param2); + CommentDelRange((uint)param1, (uint)param2); } break; diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index 52a51d9a..2475333c 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -21,7 +21,7 @@ void dbsave() dprintf("saving database..."); DWORD ticks = GetTickCount(); JSON root = json_object(); - commentcachesave(root); + CommentCacheSave(root); labelcachesave(root); BookmarkCacheSave(root); FunctionCacheSave(root); @@ -82,7 +82,7 @@ void dbload() dputs("\ninvalid database file (JSON)!"); return; } - commentcacheload(root); + CommentCacheLoad(root); labelcacheload(root); BookmarkCacheLoad(root); FunctionCacheLoad(root); @@ -95,7 +95,7 @@ void dbload() void dbclose() { dbsave(); - commentclear(); + CommentClear(); labelclear(); BookmarkClear(); FunctionClear(); diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 6db5e1a9..7e9f42ae 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -183,7 +183,9 @@ bool BookmarkEnum(BOOKMARKSINFO* List, size_t* Size) if(Size) { *Size = bookmarks.size() * sizeof(BOOKMARKSINFO); - return true; + + if(!List) + return true; } // Copy struct and adjust the relative offset to a virtual address diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index a42b5940..122219b8 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -8,175 +8,244 @@ typedef std::map CommentsInfo; static CommentsInfo comments; -bool commentset(uint addr, const char* text, bool manual) +bool CommentSet(uint Address, const char* Text, bool Manual) { - if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or text[0] == '\1' or strlen(text) >= MAX_COMMENT_SIZE - 1) + // CHECK: Exported/Command function + if(!DbgIsDebugging()) return false; - if(!*text) //NOTE: delete when there is no text + + // A valid memory address must be supplied + if(!memisvalidreadptr(fdProcessInfo->hProcess, Address)) + return false; + + // Make sure the string is supplied, within bounds, and not a special delimiter + if(!Text || Text[0] == '\1' || strlen(Text) >= MAX_COMMENT_SIZE - 1) + return false; + + // Delete the comment if no text was supplied + if(!*Text) { - commentdel(addr); + CommentDelete(Address); return true; } + + // Fill out the structure COMMENTSINFO comment; - comment.manual = manual; - strcpy_s(comment.text, text); - ModNameFromAddr(addr, comment.mod, true); - comment.addr = addr - ModBaseFromAddr(addr); - const uint key = ModHashFromAddr(addr); - CriticalSectionLocker locker(LockComments); - if(!comments.insert(std::make_pair(key, comment)).second) //key already present + strcpy_s(comment.text, Text); + ModNameFromAddr(Address, comment.mod, true); + + comment.manual = Manual; + comment.addr = Address - ModBaseFromAddr(Address); + + // Insert into list + const uint key = ModHashFromAddr(Address); + + EXCLUSIVE_ACQUIRE(LockComments); + + // Only add if the key wasn't present + if(!comments.insert(std::make_pair(key, comment)).second) comments[key] = comment; + return true; } -bool commentget(uint addr, char* text) +bool CommentGet(uint Address, char* Text) { + // CHECK: Exported/Command function if(!DbgIsDebugging()) return false; - CriticalSectionLocker locker(LockComments); - const CommentsInfo::iterator found = comments.find(ModHashFromAddr(addr)); - if(found == comments.end()) //not found + + SHARED_ACQUIRE(LockComments); + + // Get an existing comment and copy the string buffer + auto found = comments.find(ModHashFromAddr(Address)); + + // Was it found? + if(found == comments.end()) return false; - strcpy_s(text, MAX_COMMENT_SIZE, found->second.text); + + strcpy_s(Text, MAX_COMMENT_SIZE, found->second.text); return true; } -bool commentdel(uint addr) +bool CommentDelete(uint Address) { + // CHECK: Command/Sub function if(!DbgIsDebugging()) return false; - CriticalSectionLocker locker(LockComments); - return (comments.erase(ModHashFromAddr(addr)) == 1); + + EXCLUSIVE_ACQUIRE(LockComments); + return (comments.erase(ModHashFromAddr(Address)) > 0); } -void commentdelrange(uint start, uint end) +void CommentDelRange(uint Start, uint End) { + // CHECK: Export function if(!DbgIsDebugging()) return; - bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = ModBaseFromAddr(start); - if(modbase != ModBaseFromAddr(end)) - return; - start -= modbase; - end -= modbase; - CriticalSectionLocker locker(LockComments); - CommentsInfo::iterator i = comments.begin(); - while(i != comments.end()) + + // Are all comments going to be deleted? + if(Start == 0x00000000 && End == 0xFFFFFFFF) { - if(i->second.manual) //ignore manual + EXCLUSIVE_ACQUIRE(LockComments); + comments.clear(); + } + else + { + // Make sure 'Start' and 'End' reference the same module + uint moduleBase = ModBaseFromAddr(Start); + + if(moduleBase != ModBaseFromAddr(End)) + return; + + // Virtual -> relative offset + Start -= moduleBase; + End -= moduleBase; + + EXCLUSIVE_ACQUIRE(LockComments); + for(auto itr = comments.begin(); itr != comments.end();) { - i++; - continue; + // Ignore manually set entries + if(itr->second.manual) + { + itr++; + continue; + } + + // [Start, End) + if(itr->second.addr >= Start && itr->second.addr < End) + itr = comments.erase(itr); + else + itr++; } - if(bDelAll || (i->second.addr >= start && i->second.addr < end)) - comments.erase(i++); - else - i++; } } -void commentcachesave(JSON root) +void CommentCacheSave(JSON Root) { - CriticalSectionLocker locker(LockComments); - const JSON jsoncomments = json_array(); - const JSON jsonautocomments = json_array(); - for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i) + EXCLUSIVE_ACQUIRE(LockComments); + + const JSON jsonComments = json_array(); + const JSON jsonAutoComments = json_array(); + + // Build the JSON array + for(auto & itr : comments) { - const COMMENTSINFO curComment = i->second; - JSON curjsoncomment = json_object(); - json_object_set_new(curjsoncomment, "module", json_string(curComment.mod)); - json_object_set_new(curjsoncomment, "address", json_hex(curComment.addr)); - json_object_set_new(curjsoncomment, "text", json_string(curComment.text)); - if(curComment.manual) - json_array_append_new(jsoncomments, curjsoncomment); + JSON currentComment = json_object(); + + json_object_set_new(currentComment, "module", json_string(itr.second.mod)); + json_object_set_new(currentComment, "address", json_hex(itr.second.addr)); + json_object_set_new(currentComment, "text", json_string(itr.second.text)); + + if(itr.second.manual) + json_array_append_new(jsonComments, currentComment); else - json_array_append_new(jsonautocomments, curjsoncomment); + json_array_append_new(jsonAutoComments, currentComment); } - if(json_array_size(jsoncomments)) - json_object_set(root, "comments", jsoncomments); - json_decref(jsoncomments); - if(json_array_size(jsonautocomments)) - json_object_set(root, "autocomments", jsonautocomments); - json_decref(jsonautocomments); + + // Save to the JSON root + if(json_array_size(jsonComments)) + json_object_set(Root, "comments", jsonComments); + + if(json_array_size(jsonAutoComments)) + json_object_set(Root, "autocomments", jsonAutoComments); + + json_decref(jsonComments); + json_decref(jsonAutoComments); } -void commentcacheload(JSON root) +void CommentCacheLoad(JSON Root) { - CriticalSectionLocker locker(LockComments); + EXCLUSIVE_ACQUIRE(LockBookmarks); + + // Inline lambda to parse each JSON entry + auto AddBookmarks = [](const JSON Object, bool Manual) + { + size_t i; + JSON value; + + json_array_foreach(Object, i, value) + { + COMMENTSINFO commentInfo; + + // Module + const char* mod = json_string_value(json_object_get(value, "module")); + + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy_s(commentInfo.mod, mod); + else + commentInfo.mod[0] = '\0'; + + // Address/Manual + commentInfo.addr = (uint)json_hex_value(json_object_get(value, "address")); + commentInfo.manual = Manual; + + // String value + const char* text = json_string_value(json_object_get(value, "text")); + + if(text) + strcpy_s(commentInfo.text, text); + else + { + // Skip blank comments + continue; + } + + const uint key = ModHashFromName(commentInfo.mod) + commentInfo.addr; + comments.insert(std::make_pair(key, commentInfo)); + } + }; + + // Remove existing entries comments.clear(); - const JSON jsoncomments = json_object_get(root, "comments"); - if(jsoncomments) - { - size_t i; - JSON value; - json_array_foreach(jsoncomments, i, value) - { - COMMENTSINFO curComment; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(curComment.mod, mod); - else - *curComment.mod = '\0'; - curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); - curComment.manual = true; - const char* text = json_string_value(json_object_get(value, "text")); - if(text) - strcpy_s(curComment.text, text); - else - continue; //skip - const uint key = ModHashFromName(curComment.mod) + curComment.addr; - comments.insert(std::make_pair(key, curComment)); - } - } - JSON jsonautocomments = json_object_get(root, "autocomments"); - if(jsonautocomments) - { - size_t i; - JSON value; - json_array_foreach(jsonautocomments, i, value) - { - COMMENTSINFO curComment; - const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(curComment.mod, mod); - else - *curComment.mod = '\0'; - curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); - curComment.manual = false; - const char* text = json_string_value(json_object_get(value, "text")); - if(text) - strcpy_s(curComment.text, text); - else - continue; //skip - const uint key = ModHashFromName(curComment.mod) + curComment.addr; - comments.insert(std::make_pair(key, curComment)); - } - } + + const JSON jsonComments = json_object_get(Root, "comments"); + const JSON jsonAutoComments = json_object_get(Root, "autocomments"); + + // Load user-set comments + if(jsonComments) + AddBookmarks(jsonComments, true); + + // Load auto-set comments + if(jsonAutoComments) + AddBookmarks(jsonAutoComments, false); } -bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize) +bool CommentEnum(COMMENTSINFO* List, size_t* Size) { + // CHECK: Command function if(!DbgIsDebugging()) return false; - if(!commentlist && !cbsize) + + // At least 1 parameter must be supplied + if(!List && !Size) return false; - CriticalSectionLocker locker(LockComments); - if(!commentlist && cbsize) + + SHARED_ACQUIRE(LockComments); + + // Check if the user requested size only + if(Size) { - *cbsize = comments.size() * sizeof(COMMENTSINFO); - return true; + *Size = comments.size() * sizeof(COMMENTSINFO); + + if(!List) + return true; } - int j = 0; - for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i, j++) + + // Populate the returned array + for(auto & itr : comments) { - commentlist[j] = i->second; - commentlist[j].addr += ModBaseFromName(commentlist[j].mod); + *List = itr.second; + List->addr += ModBaseFromName(List->mod); + + List++; } + return true; } -void commentclear() +void CommentClear() { - CriticalSectionLocker locker(LockComments); - CommentsInfo().swap(comments); + EXCLUSIVE_ACQUIRE(LockComments); + comments.clear(); } \ No newline at end of file diff --git a/x64_dbg_dbg/comment.h b/x64_dbg_dbg/comment.h index 3f25f6ef..993a63fa 100644 --- a/x64_dbg_dbg/comment.h +++ b/x64_dbg_dbg/comment.h @@ -1,5 +1,4 @@ -#ifndef _COMMENT_H -#define _COMMENT_H +#pragma once #include "_global.h" @@ -11,13 +10,11 @@ struct COMMENTSINFO bool manual; }; -bool commentset(uint addr, const char* text, bool manual); -bool commentget(uint addr, char* text); -bool commentdel(uint addr); -void commentdelrange(uint start, uint end); -void commentcachesave(JSON root); -void commentcacheload(JSON root); -bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize); -void commentclear(); - -#endif //_COMMENT_H \ No newline at end of file +bool CommentSet(uint Address, const char* Text, bool Manual); +bool CommentGet(uint Address, char* Text); +bool CommentDelete(uint Address); +void CommentDelRange(uint Start, uint End); +void CommentCacheSave(JSON Root); +void CommentCacheLoad(JSON Root); +bool CommentEnum(COMMENTSINFO* List, size_t* Size); +void CommentClear(); \ No newline at end of file diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index c3d23861..e300c590 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -811,7 +811,7 @@ CMDRESULT cbDebugBenchmark(int argc, char* argv[]) char comment[MAX_COMMENT_SIZE] = ""; for(uint i = addr; i < addr + 100000; i++) { - commentset(i, "test", false); + CommentSet(i, "test", false); labelset(i, "test", false); BookmarkSet(i, false); FunctionAdd(i, i, false); diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index a48047b5..d29154c5 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -294,7 +294,7 @@ CMDRESULT cbInstrCmt(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!commentset(addr, argv[2], true)) + if(!CommentSet(addr, argv[2], true)) { dputs("error setting comment"); return STATUS_ERROR; @@ -312,7 +312,7 @@ CMDRESULT cbInstrCmtdel(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!commentdel(addr)) + if(!CommentDelete(addr)) { dputs("error deleting comment"); return STATUS_ERROR; @@ -1270,14 +1270,14 @@ CMDRESULT cbInstrCommentList(int argc, char* argv[]) GuiReferenceAddColumn(0, "Comment"); GuiReferenceReloadData(); size_t cbsize; - commentenum(0, &cbsize); + CommentEnum(0, &cbsize); if(!cbsize) { dputs("no comments"); return STATUS_CONTINUE; } Memory comments(cbsize, "cbInstrCommentList:comments"); - commentenum(comments, 0); + CommentEnum(comments, 0); int count = (int)(cbsize / sizeof(COMMENTSINFO)); for(int i = 0; i < count; i++) { @@ -1400,7 +1400,7 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[]) else { char comment[MAX_COMMENT_SIZE] = ""; - if(commentget(functions[i].start, comment)) + if(CommentGet(functions[i].start, comment)) GuiReferenceSetCellContent(i, 3, comment); } } @@ -1446,7 +1446,7 @@ CMDRESULT cbInstrLoopList(int argc, char* argv[]) else { char comment[MAX_COMMENT_SIZE] = ""; - if(commentget(loops[i].start, comment)) + if(CommentGet(loops[i].start, comment)) GuiReferenceSetCellContent(i, 3, comment); } } From 4c115e5e7e865d39efa515e980ab7c4f98039868 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 22 Mar 2015 21:14:18 -0400 Subject: [PATCH 063/106] Fix recursive deadlocks / some small bugs --- x64_dbg_dbg/addrinfo.cpp | 2 +- x64_dbg_dbg/module.cpp | 3 +- x64_dbg_dbg/threading.cpp | 44 +++++---------------------- x64_dbg_dbg/threading.h | 64 +++++++++++++++++++++++++++------------ x64_dbg_dbg/variable.cpp | 32 +++++++++++++++++--- x64_dbg_dbg/x64_dbg.cpp | 4 ++- 6 files changed, 85 insertions(+), 64 deletions(-) diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index 2475333c..30198904 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -68,7 +68,7 @@ void dbload() return; } FILE* jsonFile = 0; - if(_wfopen_s(&jsonFile, wdbpath.c_str(), L"rb")) + if(_wfopen_s(&jsonFile, wdbpath.c_str(), L"rb") != 0) { dputs("\nfailed to open database file!"); return; diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 73593658..bb7eeac4 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -33,8 +33,8 @@ bool ModLoad(uint Base, uint Size, const char* FullPath) if(extensionPos) { + strcpy_s(info.extension, extensionPos); extensionPos[0] = '\0'; - strcpy_s(info.extension, extensionPos + 1); } } @@ -98,6 +98,7 @@ bool ModUnload(uint Base) // Unload everything from TitanEngine StaticFileUnloadW(nullptr, false, found->second.Handle, found->second.FileMapSize, found->second.MapHandle, found->second.FileMapVA); + EXCLUSIVE_RELEASE(); // Update symbols SymUpdateModuleList(); diff --git a/x64_dbg_dbg/threading.cpp b/x64_dbg_dbg/threading.cpp index 3475196e..2f421b3e 100644 --- a/x64_dbg_dbg/threading.cpp +++ b/x64_dbg_dbg/threading.cpp @@ -28,10 +28,10 @@ bool waitislocked(WAIT_ID id) return waitarray[id]; } -bool ExclusiveSectionLocker::m_Initialized = false; -SRWLOCK ExclusiveSectionLocker::m_Locks[SectionLock::LockLast]; +bool SectionLockerGlobal::m_Initialized = false; +SRWLOCK SectionLockerGlobal::m_Locks[SectionLock::LockLast]; -void ExclusiveSectionLocker::Initialize() +void SectionLockerGlobal::Initialize() { if(m_Initialized) return; @@ -45,7 +45,7 @@ void ExclusiveSectionLocker::Initialize() m_Initialized = true; } -void ExclusiveSectionLocker::Deinitialize() +void SectionLockerGlobal::Deinitialize() { if(!m_Initialized) return; @@ -63,38 +63,7 @@ void ExclusiveSectionLocker::Deinitialize() m_Initialized = false; } -ExclusiveSectionLocker::ExclusiveSectionLocker(SectionLock LockIndex) -{ - m_Lock = &m_Locks[LockIndex]; - m_LockCount = 0; - - Lock(); -} - -ExclusiveSectionLocker::~ExclusiveSectionLocker() -{ - if(m_LockCount > 0) - Unlock(); - - // TODO: Assert that the lock count is zero on destructor -#ifdef _DEBUG - if(m_LockCount > 0) - __debugbreak(); -#endif -} - -void ExclusiveSectionLocker::Lock() -{ - AcquireSRWLockExclusive(m_Lock); - m_LockCount++; -} - -void ExclusiveSectionLocker::Unlock() -{ - m_LockCount--; - ReleaseSRWLockExclusive(m_Lock); -} - +/* SharedSectionLocker::SharedSectionLocker(SectionLock LockIndex) : ExclusiveSectionLocker(LockIndex) { @@ -111,4 +80,5 @@ void SharedSectionLocker::Unlock() { m_LockCount--; ReleaseSRWLockShared(m_Lock); -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index eb029d9b..3e758d3b 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -2,7 +2,6 @@ #include "_global.h" -//enums enum WAIT_ID { WAITID_RUN, @@ -23,10 +22,13 @@ bool waitislocked(WAIT_ID id); // Better, but requires VISTA+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa904937%28v=vs.85%29.aspx // -#define EXCLUSIVE_ACQUIRE(Index) ExclusiveSectionLocker __ThreadLock(SectionLock::##Index); +#define CriticalSectionLocker +#define locker(x) EXCLUSIVE_ACQUIRE(x) + +#define EXCLUSIVE_ACQUIRE(Index) SectionLocker __ThreadLock(SectionLock::##Index); #define EXCLUSIVE_RELEASE() __ThreadLock.Unlock(); -#define SHARED_ACQUIRE(Index) SharedSectionLocker __SThreadLock(SectionLock::##Index); +#define SHARED_ACQUIRE(Index) SectionLocker __SThreadLock(SectionLock::##Index); #define SHARED_RELEASE() __SThreadLock.Unlock(); enum SectionLock @@ -53,32 +55,56 @@ enum SectionLock LockLast }; -class ExclusiveSectionLocker +class SectionLockerGlobal { + template friend class SectionLocker; + public: static void Initialize(); static void Deinitialize(); - ExclusiveSectionLocker(SectionLock LockIndex); - ~ExclusiveSectionLocker(); - - void Lock(); - void Unlock(); - -private: +protected: static bool m_Initialized; static SRWLOCK m_Locks[SectionLock::LockLast]; - -protected: - SRWLOCK* m_Lock; - BYTE m_LockCount; }; -class SharedSectionLocker : public ExclusiveSectionLocker +template +class SectionLocker { public: - SharedSectionLocker(SectionLock LockIndex); + SectionLocker(SectionLock LockIndex) + { + m_Lock = &SectionLockerGlobal::m_Locks[LockIndex]; + m_LockCount = 0; - void Lock(); - void Unlock(); + Lock(); + } + + ~SectionLocker() + { + if(m_LockCount > 0) + Unlock(); + + // TODO: Assert that the lock count is zero on destructor +#ifdef _DEBUG + if(m_LockCount > 0) + __debugbreak(); +#endif + } + + inline void Lock() + { + AcquireSRWLockExclusive(m_Lock); + m_LockCount++; + } + + inline void Unlock() + { + m_LockCount--; + ReleaseSRWLockExclusive(m_Lock); + } + +protected: + PSRWLOCK m_Lock; + BYTE m_LockCount; }; \ No newline at end of file diff --git a/x64_dbg_dbg/variable.cpp b/x64_dbg_dbg/variable.cpp index f71905a0..fe4765c8 100644 --- a/x64_dbg_dbg/variable.cpp +++ b/x64_dbg_dbg/variable.cpp @@ -20,16 +20,23 @@ static void varsetvalue(VAR* var, VAR_VALUE* value) static bool varset(const char* name, VAR_VALUE* value, bool setreadonly) { - CriticalSectionLocker locker(LockVariables); + EXCLUSIVE_ACQUIRE(LockVariables); + String name_; if(*name != '$') name_ = "$"; name_ += name; VariableMap::iterator found = variables.find(name_); - if(found == variables.end()) //not found + if(found == variables.end()) //not found return false; if(found->second.alias.length()) + { + // Release the lock (potential deadlock here) + EXCLUSIVE_RELEASE(); + return varset(found->second.alias.c_str(), value, setreadonly); + } + if(!setreadonly && (found->second.type == VAR_READONLY || found->second.type == VAR_HIDDEN)) return false; varsetvalue(&found->second, value); @@ -69,9 +76,11 @@ VAR* vargetptr() bool varnew(const char* name, uint value, VAR_TYPE type) { - CriticalSectionLocker locker(LockVariables); if(!name) return false; + + CriticalSectionLocker locker(LockVariables); + std::vector names = StringUtils::Split(name, '\1'); String firstName; for(int i = 0; i < (int)names.size(); i++) @@ -100,7 +109,8 @@ bool varnew(const char* name, uint value, VAR_TYPE type) static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type) { - CriticalSectionLocker locker(LockVariables); + EXCLUSIVE_ACQUIRE(LockVariables); + String name_; if(*name != '$') name_ = "$"; @@ -109,7 +119,12 @@ static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type if(found == variables.end()) //not found return false; if(found->second.alias.length()) + { + // Release the lock (potential deadlock here) + EXCLUSIVE_RELEASE(); + return varget(found->second.alias.c_str(), value, size, type); + } if(type) *type = found->second.type; if(size) @@ -184,7 +199,8 @@ bool varset(const char* name, const char* string, bool setreadonly) bool vardel(const char* name, bool delsystem) { - CriticalSectionLocker locker(LockVariables); + EXCLUSIVE_ACQUIRE(LockVariables); + String name_; if(*name != '$') name_ = "$"; @@ -193,7 +209,13 @@ bool vardel(const char* name, bool delsystem) if(found == variables.end()) //not found return false; if(found->second.alias.length()) + { + // Release the lock (potential deadlock here) + EXCLUSIVE_RELEASE(); + return vardel(found->second.alias.c_str(), delsystem); + } + if(!delsystem && found->second.type != VAR_USER) return false; found = variables.begin(); diff --git a/x64_dbg_dbg/x64_dbg.cpp b/x64_dbg_dbg/x64_dbg.cpp index ff2b7dba..eea09dde 100644 --- a/x64_dbg_dbg/x64_dbg.cpp +++ b/x64_dbg_dbg/x64_dbg.cpp @@ -236,6 +236,7 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit() return "Invalid TITAN_ENGINE_CONTEXT_t alignment!"; if(sizeof(TITAN_ENGINE_CONTEXT_t) != sizeof(REGISTERCONTEXT)) return "Invalid REGISTERCONTEXT alignment!"; + SectionLockerGlobal::Initialize(); dbginit(); dbgfunctionsinit(); json_set_alloc_funcs(emalloc_json, efree_json); @@ -314,7 +315,8 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal() } else DeleteFileA(alloctrace); - CriticalSectionLocker::Deinitialize(); + + SectionLockerGlobal::Deinitialize(); } extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd) From 7cd657abe692ef23c1dbc46744fb2422984a9da5 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 22 Mar 2015 21:16:08 -0400 Subject: [PATCH 064/106] Multiprocessor compilation --- x64_dbg_dbg/x64_dbg_dbg.vcxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 92324802..06e5c3b5 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -156,6 +156,7 @@ MultiThreadedDLL Level3 ProgramDatabase + true MachineX86 @@ -172,6 +173,7 @@ MultiThreadedDLL Level3 ProgramDatabase + true true From 5b948d974f7b650ce81bcf071812cad86e8a7712 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 22 Mar 2015 21:19:28 -0400 Subject: [PATCH 065/106] Better shared SRWLock code (Template class) --- x64_dbg_dbg/threading.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 3e758d3b..dfaf0aef 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -94,14 +94,22 @@ public: inline void Lock() { - AcquireSRWLockExclusive(m_Lock); + if(Shared) + AcquireSRWLockShared(m_Lock); + else + AcquireSRWLockExclusive(m_Lock); + m_LockCount++; } inline void Unlock() { m_LockCount--; - ReleaseSRWLockExclusive(m_Lock); + + if(Shared) + ReleaseSRWLockShared(m_Lock); + else + ReleaseSRWLockExclusive(m_Lock); } protected: From 5bd3a0b5a739d4d8fe0c44b6253d7de2cebe6aa0 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sun, 22 Mar 2015 21:56:25 -0400 Subject: [PATCH 066/106] Optimize SectionLocker to use fewer runtime variables --- x64_dbg_dbg/threading.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index dfaf0aef..b24f8546 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -25,10 +25,10 @@ bool waitislocked(WAIT_ID id); #define CriticalSectionLocker #define locker(x) EXCLUSIVE_ACQUIRE(x) -#define EXCLUSIVE_ACQUIRE(Index) SectionLocker __ThreadLock(SectionLock::##Index); +#define EXCLUSIVE_ACQUIRE(Index) SectionLocker __ThreadLock; #define EXCLUSIVE_RELEASE() __ThreadLock.Unlock(); -#define SHARED_ACQUIRE(Index) SectionLocker __SThreadLock(SectionLock::##Index); +#define SHARED_ACQUIRE(Index) SectionLocker __SThreadLock; #define SHARED_RELEASE() __SThreadLock.Unlock(); enum SectionLock @@ -57,26 +57,24 @@ enum SectionLock class SectionLockerGlobal { - template friend class SectionLocker; + template friend class SectionLocker; public: static void Initialize(); static void Deinitialize(); -protected: +private: static bool m_Initialized; static SRWLOCK m_Locks[SectionLock::LockLast]; }; -template +template class SectionLocker { public: - SectionLocker(SectionLock LockIndex) + SectionLocker() { - m_Lock = &SectionLockerGlobal::m_Locks[LockIndex]; m_LockCount = 0; - Lock(); } @@ -95,9 +93,9 @@ public: inline void Lock() { if(Shared) - AcquireSRWLockShared(m_Lock); + AcquireSRWLockShared(&Internal::m_Locks[LockIndex]); else - AcquireSRWLockExclusive(m_Lock); + AcquireSRWLockExclusive(&Internal::m_Locks[LockIndex]); m_LockCount++; } @@ -107,12 +105,14 @@ public: m_LockCount--; if(Shared) - ReleaseSRWLockShared(m_Lock); + ReleaseSRWLockShared(&Internal::m_Locks[LockIndex]); else - ReleaseSRWLockExclusive(m_Lock); + ReleaseSRWLockExclusive(&Internal::m_Locks[LockIndex]); } +private: + using Internal = SectionLockerGlobal; + protected: - PSRWLOCK m_Lock; - BYTE m_LockCount; + BYTE m_LockCount; }; \ No newline at end of file From 78d4efc31224b0676ecdfee78769a927cae3fd3c Mon Sep 17 00:00:00 2001 From: Nukem Date: Wed, 25 Mar 2015 22:17:52 -0400 Subject: [PATCH 067/106] Partially refactor memory.cpp/.h --- x64_dbg_dbg/_dbgfunctions.cpp | 4 +- x64_dbg_dbg/_exports.cpp | 14 +-- x64_dbg_dbg/addrinfo.cpp | 16 ++-- x64_dbg_dbg/assemble.cpp | 4 +- x64_dbg_dbg/bookmark.cpp | 2 +- x64_dbg_dbg/breakpoint.cpp | 10 +- x64_dbg_dbg/comment.cpp | 2 +- x64_dbg_dbg/debugger.cpp | 48 +++++----- x64_dbg_dbg/debugger_commands.cpp | 32 +++---- x64_dbg_dbg/disasm_fast.cpp | 2 +- x64_dbg_dbg/disasm_helper.cpp | 10 +- x64_dbg_dbg/function.cpp | 2 +- x64_dbg_dbg/instruction.cpp | 16 ++-- x64_dbg_dbg/label.cpp | 2 +- x64_dbg_dbg/loop.cpp | 2 +- x64_dbg_dbg/memory.cpp | 149 +++++++++++++++++++----------- x64_dbg_dbg/memory.h | 21 ++--- x64_dbg_dbg/patches.cpp | 6 +- x64_dbg_dbg/plugin_loader.cpp | 2 +- x64_dbg_dbg/reference.cpp | 4 +- x64_dbg_dbg/stackinfo.cpp | 20 ++-- x64_dbg_dbg/thread.cpp | 3 +- x64_dbg_dbg/threading.cpp | 22 +---- x64_dbg_dbg/value.cpp | 4 +- x64_dbg_dbg/variable.cpp | 72 +++++++++------ 25 files changed, 249 insertions(+), 220 deletions(-) diff --git a/x64_dbg_dbg/_dbgfunctions.cpp b/x64_dbg_dbg/_dbgfunctions.cpp index 79fbdd6f..6accb9cd 100644 --- a/x64_dbg_dbg/_dbgfunctions.cpp +++ b/x64_dbg_dbg/_dbgfunctions.cpp @@ -72,7 +72,7 @@ static bool _patchinrange(duint start, duint end) static bool _mempatch(duint va, const unsigned char* src, duint size) { - return mempatch(fdProcessInfo->hProcess, (void*)va, src, size, 0); + return MemPatch((void*)va, (void*)src, size, 0); } static void _patchrestorerange(duint start, duint end) @@ -162,7 +162,7 @@ bool _getprocesslist(DBGPROCESSINFO** entries, int* count) static void _memupdatemap() { - memupdatemap(fdProcessInfo->hProcess); + MemUpdateMap(fdProcessInfo->hProcess); } void dbgfunctionsinit() diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index 621d8996..5733137c 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -26,17 +26,17 @@ static bool bOnlyCipAutoComments = false; extern "C" DLL_EXPORT duint _dbg_memfindbaseaddr(duint addr, duint* size) { - return memfindbaseaddr(addr, size); + return MemFindBaseAddr(addr, size); } extern "C" DLL_EXPORT bool _dbg_memread(duint addr, unsigned char* dest, duint size, duint* read) { - return memread(fdProcessInfo->hProcess, (void*)addr, dest, size, read); + return MemRead((void*)addr, dest, size, read); } extern "C" DLL_EXPORT bool _dbg_memwrite(duint addr, const unsigned char* src, duint size, duint* written) { - return memwrite(fdProcessInfo->hProcess, (void*)addr, src, size, written); + return MemWrite((void*)addr, (void*)src, size, written); } extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap) @@ -57,7 +57,7 @@ extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap) extern "C" DLL_EXPORT bool _dbg_memisvalidreadptr(duint addr) { - return memisvalidreadptr(fdProcessInfo->hProcess, addr); + return MemIsValidReadPtr(addr); } extern "C" DLL_EXPORT bool _dbg_valfromstring(const char* string, duint* value) @@ -122,7 +122,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR if(disasmfast(addr, &basicinfo) && basicinfo.branch && !basicinfo.call && basicinfo.memory.value) //thing is a JMP { uint val = 0; - if(memread(fdProcessInfo->hProcess, (const void*)basicinfo.memory.value, &val, sizeof(val), 0)) + if(MemRead((void*)basicinfo.memory.value, &val, sizeof(val), 0)) { if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement) { @@ -567,7 +567,7 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap) curBp.addr = list[i].addr; curBp.enabled = list[i].enabled; //TODO: fix this - if(memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr)) + if(MemIsValidReadPtr(curBp.addr)) curBp.active = true; strcpy_s(curBp.mod, list[i].mod); strcpy_s(curBp.name, list[i].name); @@ -776,7 +776,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par if(!param1 or !param2) return 0; unsigned char data[16]; - if(!memread(fdProcessInfo->hProcess, param1, data, sizeof(data), 0)) + if(!MemRead(param1, data, sizeof(data), 0)) return 0; DISASM disasm; memset(&disasm, 0, sizeof(disasm)); diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index 30198904..f8fba9e9 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -111,14 +111,14 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum) VirtualQueryEx(fdProcessInfo->hProcess, (const void*)base, &mbi, sizeof(mbi)); uint size = mbi.RegionSize; Memory buffer(size, "apienumexports:buffer"); - if(!memread(fdProcessInfo->hProcess, (const void*)base, buffer, size, 0)) + if(!MemRead((void*)base, buffer, size, 0)) return false; IMAGE_NT_HEADERS* pnth = (IMAGE_NT_HEADERS*)((uint)buffer + GetPE32DataFromMappedFile((ULONG_PTR)buffer, 0, UE_PE_OFFSET)); uint export_dir_rva = pnth->OptionalHeader.DataDirectory[0].VirtualAddress; uint export_dir_size = pnth->OptionalHeader.DataDirectory[0].Size; IMAGE_EXPORT_DIRECTORY export_dir; memset(&export_dir, 0, sizeof(export_dir)); - memread(fdProcessInfo->hProcess, (const void*)(export_dir_rva + base), &export_dir, sizeof(export_dir), 0); + MemRead((void*)(export_dir_rva + base), &export_dir, sizeof(export_dir), 0); unsigned int NumberOfNames = export_dir.NumberOfNames; if(!export_dir.NumberOfFunctions or !NumberOfNames) //no named exports return false; @@ -127,28 +127,28 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum) uint original_name_va = export_dir.Name + base; char original_name[deflen] = ""; memset(original_name, 0, sizeof(original_name)); - memread(fdProcessInfo->hProcess, (const void*)original_name_va, original_name, deflen, 0); + MemRead((void*)original_name_va, original_name, deflen, 0); char* AddrOfFunctions_va = (char*)(export_dir.AddressOfFunctions + base); char* AddrOfNames_va = (char*)(export_dir.AddressOfNames + base); char* AddrOfNameOrdinals_va = (char*)(export_dir.AddressOfNameOrdinals + base); for(DWORD i = 0; i < NumberOfNames; i++) { DWORD curAddrOfName = 0; - memread(fdProcessInfo->hProcess, AddrOfNames_va + sizeof(DWORD)*i, &curAddrOfName, sizeof(DWORD), 0); + MemRead(AddrOfNames_va + sizeof(DWORD)*i, &curAddrOfName, sizeof(DWORD), 0); char* cur_name_va = (char*)(curAddrOfName + base); char cur_name[deflen] = ""; memset(cur_name, 0, deflen); - memread(fdProcessInfo->hProcess, cur_name_va, cur_name, deflen, 0); + MemRead(cur_name_va, cur_name, deflen, 0); WORD curAddrOfNameOrdinals = 0; - memread(fdProcessInfo->hProcess, AddrOfNameOrdinals_va + sizeof(WORD)*i, &curAddrOfNameOrdinals, sizeof(WORD), 0); + MemRead(AddrOfNameOrdinals_va + sizeof(WORD)*i, &curAddrOfNameOrdinals, sizeof(WORD), 0); DWORD curFunctionRva = 0; - memread(fdProcessInfo->hProcess, AddrOfFunctions_va + sizeof(DWORD)*curAddrOfNameOrdinals, &curFunctionRva, sizeof(DWORD), 0); + MemRead(AddrOfFunctions_va + sizeof(DWORD)*curAddrOfNameOrdinals, &curFunctionRva, sizeof(DWORD), 0); if(curFunctionRva >= export_dir_rva and curFunctionRva < export_dir_rva + export_dir_size) { char forwarded_api[deflen] = ""; memset(forwarded_api, 0, deflen); - memread(fdProcessInfo->hProcess, (void*)(curFunctionRva + base), forwarded_api, deflen, 0); + MemRead((void*)(curFunctionRva + base), forwarded_api, deflen, 0); int len = (int)strlen(forwarded_api); int j = 0; while(forwarded_api[j] != '.' and j < len) diff --git a/x64_dbg_dbg/assemble.cpp b/x64_dbg_dbg/assemble.cpp index 6c6f1f11..a8389045 100644 --- a/x64_dbg_dbg/assemble.cpp +++ b/x64_dbg_dbg/assemble.cpp @@ -67,12 +67,12 @@ bool assembleat(uint addr, const char* instruction, int* size, char* error, bool if(size) *size = destSize; - bool ret = mempatch(fdProcessInfo->hProcess, (void*)addr, dest, destSize, 0); + bool ret = MemPatch((void*)addr, dest, destSize, 0); if(ret && fillnop && nopsize) { if(size) *size += nopsize; - if(!mempatch(fdProcessInfo->hProcess, (void*)(addr + destSize), nops, nopsize, 0)) + if(!MemPatch((void*)(addr + destSize), nops, nopsize, 0)) ret = false; } GuiUpdatePatches(); diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 7e9f42ae..954306d2 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -15,7 +15,7 @@ bool BookmarkSet(uint Address, bool Manual) return false; // Validate the incoming address - if(!memisvalidreadptr(fdProcessInfo->hProcess, Address)) + if(!MemIsValidReadPtr(Address)) return false; BOOKMARKSINFO bookmark; diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index d7dace60..efa4ae2e 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -42,7 +42,7 @@ int BpGetList(std::vector* List) { BREAKPOINT currentBp = i.second; currentBp.addr += ModBaseFromName(currentBp.mod); - currentBp.active = memisvalidreadptr(fdProcessInfo->hProcess, currentBp.addr); + currentBp.active = MemIsValidReadPtr(currentBp.addr); List->push_back(currentBp); } @@ -58,7 +58,7 @@ bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE T return false; // Fail if the address is a bad memory region - if(!memisvalidreadptr(fdProcessInfo->hProcess, Address)) + if(!MemIsValidReadPtr(Address)) return false; // Fail if the breakpoint already exists @@ -113,7 +113,7 @@ bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp) *Bp = *bpInfo; Bp->addr += ModBaseFromAddr(Address); - Bp->active = memisvalidreadptr(fdProcessInfo->hProcess, Bp->addr); + Bp->active = MemIsValidReadPtr(Bp->addr); return true; } @@ -129,7 +129,7 @@ bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp) { *Bp = i.second; Bp->addr += ModBaseFromAddr(Address); - Bp->active = memisvalidreadptr(fdProcessInfo->hProcess, Bp->addr); + Bp->active = MemIsValidReadPtr(Bp->addr); } // Return true if the name was found at all @@ -230,7 +230,7 @@ bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module) BREAKPOINT bpInfo = i.second; bpInfo.addr += ModBaseFromName(bpInfo.mod); - bpInfo.active = memisvalidreadptr(fdProcessInfo->hProcess, bpInfo.addr); + bpInfo.active = MemIsValidReadPtr(bpInfo.addr); // Execute the callback if(!EnumCallback(&bpInfo)) diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index 122219b8..4c93087c 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -15,7 +15,7 @@ bool CommentSet(uint Address, const char* Text, bool Manual) return false; // A valid memory address must be supplied - if(!memisvalidreadptr(fdProcessInfo->hProcess, Address)) + if(!MemIsValidReadPtr(Address)) return false; // Make sure the string is supplied, within bounds, and not a special delimiter diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 83572402..6a01cf3f 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -49,7 +49,7 @@ static DWORD WINAPI memMapThread(void* ptr) if(cachePrivateUsage != PrivateUsage && !dbgisrunning()) //update the memory map when { cachePrivateUsage = PrivateUsage; - memupdatemap(fdProcessInfo->hProcess); + MemUpdateMap(fdProcessInfo->hProcess); } Sleep(1000); } @@ -185,7 +185,7 @@ DWORD WINAPI updateCallStackThread(void* ptr) void DebugUpdateGui(uint disasm_addr, bool stack) { uint cip = GetContextDataEx(hActiveThread, UE_CIP); - if(memisvalidreadptr(fdProcessInfo->hProcess, disasm_addr)) + if(MemIsValidReadPtr(disasm_addr)) GuiDisasmAt(disasm_addr, cip); uint csp = GetContextDataEx(hActiveThread, UE_CSP); if(stack) @@ -338,7 +338,7 @@ void cbMemoryBreakpoint(void* ExceptionAddress) hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); uint cip = GetContextDataEx(hActiveThread, UE_CIP); uint size; - uint base = memfindbaseaddr((uint)ExceptionAddress, &size, true); + uint base = MemFindBaseAddr((uint)ExceptionAddress, &size, true); BREAKPOINT bp; BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; @@ -487,7 +487,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp) case BPMEMORY: { uint size = 0; - memfindbaseaddr(bp->addr, &size); + MemFindBaseAddr(bp->addr, &size); if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) dprintf("Could not set memory breakpoint "fhex"!\n", bp->addr); } @@ -576,7 +576,7 @@ static unsigned char getCIPch() { unsigned char ch = 0x90; uint cip = GetContextDataEx(hActiveThread, UE_CIP); - memread(fdProcessInfo->hProcess, (void*)cip, &ch, 1, 0); + MemRead((void*)cip, &ch, 1, 0); return ch; } @@ -604,8 +604,8 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) } dprintf("Process Started: "fhex" %s\n", base, DebugFileName); - memupdatemap(fdProcessInfo->hProcess); - GuiDumpAt(memfindbaseaddr(GetContextData(UE_CIP), 0) + PAGE_SIZE); //dump somewhere + MemUpdateMap(fdProcessInfo->hProcess); + GuiDumpAt(MemFindBaseAddr(GetContextData(UE_CIP), 0) + PAGE_SIZE); //dump somewhere //init program database int len = (int)strlen(szFileName); @@ -635,7 +635,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); - memupdatemap(fdProcessInfo->hProcess); //update memory map + MemUpdateMap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; if(ModNameFromAddr((uint)base, modname, true)) BpEnumAll(cbSetModuleBreakpoints, modname); @@ -723,7 +723,7 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) if(settingboolget("Events", "ThreadStart")) { dbggetprivateusage(fdProcessInfo->hProcess, true); - memupdatemap(fdProcessInfo->hProcess); //update memory map + MemUpdateMap(fdProcessInfo->hProcess); //update memory map //update GUI GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); @@ -773,7 +773,7 @@ static void cbSystemBreakpoint(void* ExceptionData) dputs("System breakpoint reached!"); bSkipExceptions = false; //we are not skipping first-chance exceptions uint cip = GetContextDataEx(hActiveThread, UE_CIP); - GuiDumpAt(memfindbaseaddr(cip, 0, true)); //dump somewhere + GuiDumpAt(MemFindBaseAddr(cip, 0, true)); //dump somewhere //plugin callbacks PLUG_CB_SYSTEMBREAKPOINT callbackInfo; @@ -815,7 +815,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); - memupdatemap(fdProcessInfo->hProcess); //update memory map + MemUpdateMap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; if(ModNameFromAddr((uint)base, modname, true)) BpEnumAll(cbSetModuleBreakpoints, modname); @@ -942,7 +942,7 @@ static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) if(!DebugString->fUnicode) //ASCII { Memory DebugText(DebugString->nDebugStringLength + 1, "cbOutputDebugString:DebugText"); - if(memread(fdProcessInfo->hProcess, DebugString->lpDebugStringData, DebugText, DebugString->nDebugStringLength, 0)) + if(MemRead(DebugString->lpDebugStringData, DebugText, DebugString->nDebugStringLength, 0)) { String str = String(DebugText); if(str != lastDebugText) //fix for every string being printed twice @@ -1022,7 +1022,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) if(nameInfo.dwType == 0x1000 and nameInfo.dwFlags == 0 and ThreadIsValid(nameInfo.dwThreadID)) //passed basic checks { Memory ThreadName(MAX_THREAD_NAME_SIZE, "cbException:ThreadName"); - if(memread(fdProcessInfo->hProcess, nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0)) + if(MemRead((void*)nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0)) { String ThreadNameEscaped = StringUtils::Escape(ThreadName); dprintf("SetThreadName(%X, \"%s\")\n", nameInfo.dwThreadID, ThreadNameEscaped.c_str()); @@ -1234,7 +1234,7 @@ bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp) if(bp->type != BPMEMORY or bp->enabled) return true; uint size = 0; - memfindbaseaddr(bp->addr, &size); + MemFindBaseAddr(bp->addr, &size); if(!BpEnable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) { dprintf("Could not enable memory breakpoint "fhex"\n", bp->addr); @@ -1282,7 +1282,7 @@ bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp) if(!bp->enabled) return true; uint size; - memfindbaseaddr(bp->addr, &size); + MemFindBaseAddr(bp->addr, &size); if(!BpDelete(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", bp->addr); @@ -1743,7 +1743,7 @@ static bool getcommandlineaddr(uint* addr, cmdline_error_t* cmd_line_error) //cast-trick to calculate the address of the remote peb field ProcessParameters cmd_line_error->addr = (uint) & (((PPEB) cmd_line_error->addr)->ProcessParameters); - if(!memread(fdProcessInfo->hProcess, (const void*)cmd_line_error->addr, &pprocess_parameters, sizeof(pprocess_parameters), &size)) + if(!MemRead((void*)cmd_line_error->addr, &pprocess_parameters, sizeof(pprocess_parameters), &size)) { cmd_line_error->type = CMDL_ERR_READ_PEBBASE; return false; @@ -1762,7 +1762,7 @@ static bool patchcmdline(uint getcommandline, uint new_command_line, cmdline_err unsigned char data[100]; cmd_line_error->addr = getcommandline; - if(!memread(fdProcessInfo->hProcess, (const void*) cmd_line_error->addr, & data, sizeof(data), & size)) + if(!MemRead((void*) cmd_line_error->addr, & data, sizeof(data), & size)) { cmd_line_error->type = CMDL_ERR_READ_GETCOMMANDLINEBASE; return false; @@ -1796,7 +1796,7 @@ static bool patchcmdline(uint getcommandline, uint new_command_line, cmdline_err #endif //update the pointer in the debuggee - if(!memwrite(fdProcessInfo->hProcess, (void*)command_line_stored, &new_command_line, sizeof(new_command_line), &size)) + if(!MemWrite((void*)command_line_stored, &new_command_line, sizeof(new_command_line), &size)) { cmd_line_error->addr = command_line_stored; cmd_line_error->type = CMDL_ERR_WRITE_GETCOMMANDLINESTORED; @@ -1865,21 +1865,21 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error) new_command_line.Buffer = command_linewstr; - uint mem = (uint)memalloc(fdProcessInfo->hProcess, 0, new_command_line.Length * 2, PAGE_READWRITE); + uint mem = (uint)MemAllocRemote(0, new_command_line.Length * 2, PAGE_READWRITE); if(!mem) { cmd_line_error->type = CMDL_ERR_ALLOC_UNICODEANSI_COMMANDLINE; return false; } - if(!memwrite(fdProcessInfo->hProcess, (void*)mem, new_command_line.Buffer, new_command_line.Length, &size)) + if(!MemWrite((void*)mem, new_command_line.Buffer, new_command_line.Length, &size)) { cmd_line_error->addr = mem; cmd_line_error->type = CMDL_ERR_WRITE_UNICODE_COMMANDLINE; return false; } - if(!memwrite(fdProcessInfo->hProcess, (void*)(mem + new_command_line.Length), cmd_line, strlen(cmd_line) + 1, &size)) + if(!MemWrite((void*)(mem + new_command_line.Length), (void*)cmd_line, strlen(cmd_line) + 1, &size)) { cmd_line_error->addr = mem + new_command_line.Length; cmd_line_error->type = CMDL_ERR_WRITE_ANSI_COMMANDLINE; @@ -1890,7 +1890,7 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error) return false; new_command_line.Buffer = (PWSTR) mem; - if(!memwrite(fdProcessInfo->hProcess, (void*)command_line_addr, &new_command_line, sizeof(new_command_line), &size)) + if(!MemWrite((void*)command_line_addr, &new_command_line, sizeof(new_command_line), &size)) { cmd_line_error->addr = command_line_addr; cmd_line_error->type = CMDL_ERR_WRITE_PEBUNICODE_COMMANDLINE; @@ -1912,7 +1912,7 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error) if(!getcommandlineaddr(&cmd_line_error->addr, cmd_line_error)) return false; - if(!memread(fdProcessInfo->hProcess, (const void*)cmd_line_error->addr, &CommandLine, sizeof(CommandLine), &size)) + if(!MemRead((void*)cmd_line_error->addr, &CommandLine, sizeof(CommandLine), &size)) { cmd_line_error->type = CMDL_ERR_READ_PROCPARM_PTR; return false; @@ -1921,7 +1921,7 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error) Memory wstr_cmd(CommandLine.Length + sizeof(wchar_t)); cmd_line_error->addr = (uint) CommandLine.Buffer; - if(!memread(fdProcessInfo->hProcess, (const void*)cmd_line_error->addr, wstr_cmd, CommandLine.Length, &size)) + if(!MemRead((void*)cmd_line_error->addr, wstr_cmd, CommandLine.Length, &size)) { cmd_line_error->type = CMDL_ERR_READ_PROCPARM_CMDLINE; return false; diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index e300c590..8ed1b7d2 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -219,7 +219,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] dprintf("Error setting breakpoint at "fhex"! (IsBPXEnabled)\n", addr); return STATUS_ERROR; } - else if(!memread(fdProcessInfo->hProcess, (void*)addr, &oldbytes, sizeof(short), 0)) + else if(!MemRead((void*)addr, &oldbytes, sizeof(short), 0)) { dprintf("Error setting breakpoint at "fhex"! (memread)\n", addr); return STATUS_ERROR; @@ -458,7 +458,7 @@ CMDRESULT cbDebugDisasm(int argc, char* argv[]) if(argget(*argv, arg1, 0, true)) if(!valfromstring(arg1, &addr)) addr = GetContextDataEx(hActiveThread, UE_CIP); - if(!memisvalidreadptr(fdProcessInfo->hProcess, addr)) + if(!MemIsValidReadPtr(addr)) return STATUS_CONTINUE; DebugUpdateGui(addr, false); return STATUS_CONTINUE; @@ -505,7 +505,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]) } } uint size = 0; - uint base = memfindbaseaddr(addr, &size, true); + uint base = MemFindBaseAddr(addr, &size, true); bool singleshoot = false; if(!restore) singleshoot = true; @@ -544,7 +544,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) if(BpGet(0, BPMEMORY, arg1, &found)) //found a breakpoint with name { uint size; - memfindbaseaddr(found.addr, &size); + MemFindBaseAddr(found.addr, &size); if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); @@ -559,7 +559,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) return STATUS_ERROR; } uint size; - memfindbaseaddr(found.addr, &size); + MemFindBaseAddr(found.addr, &size); if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); @@ -724,7 +724,7 @@ CMDRESULT cbDebugAlloc(int argc, char* argv[]) if(argget(*argv, arg1, 0, true)) if(!valfromstring(arg1, &size, false)) return STATUS_ERROR; - uint mem = (uint)memalloc(fdProcessInfo->hProcess, 0, size, PAGE_EXECUTE_READWRITE); + uint mem = (uint)MemAllocRemote(0, size, PAGE_EXECUTE_READWRITE); if(!mem) dputs("VirtualAllocEx failed"); else @@ -732,7 +732,7 @@ CMDRESULT cbDebugAlloc(int argc, char* argv[]) if(mem) varset("$lastalloc", mem, true); dbggetprivateusage(fdProcessInfo->hProcess, true); - memupdatemap(fdProcessInfo->hProcess); + MemUpdateMap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); varset("$res", mem, false); return STATUS_CONTINUE; @@ -760,7 +760,7 @@ CMDRESULT cbDebugFree(int argc, char* argv[]) if(!ok) dputs("VirtualFreeEx failed"); dbggetprivateusage(fdProcessInfo->hProcess, true); - memupdatemap(fdProcessInfo->hProcess); + MemUpdateMap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); varset("$res", ok, false); return STATUS_CONTINUE; @@ -786,7 +786,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[]) } else { - uint base = memfindbaseaddr(addr, &size, true); + uint base = MemFindBaseAddr(addr, &size, true); if(!base) { dputs("invalid address specified"); @@ -806,7 +806,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[]) CMDRESULT cbDebugBenchmark(int argc, char* argv[]) { - uint addr = memfindbaseaddr(GetContextDataEx(hActiveThread, UE_CIP), 0); + uint addr = MemFindBaseAddr(GetContextDataEx(hActiveThread, UE_CIP), 0); DWORD ticks = GetTickCount(); char comment[MAX_COMMENT_SIZE] = ""; for(uint i = addr; i < addr + 100000; i++) @@ -962,7 +962,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[]) } duint csp = GetContextDataEx(hActiveThread, UE_CSP); duint size = 0; - duint base = memfindbaseaddr(csp, &size); + duint base = MemFindBaseAddr(csp, &size); if(base && addr >= base && addr < (base + size)) GuiStackDumpAt(addr, csp); else @@ -1320,7 +1320,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint size = 0; - memfindbaseaddr(found.addr, &size); + MemFindBaseAddr(found.addr, &size); if(!BpEnable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint)) { dprintf("Could not enable memory breakpoint "fhex"\n", found.addr); @@ -1360,7 +1360,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint size = 0; - memfindbaseaddr(found.addr, &size); + MemFindBaseAddr(found.addr, &size); if(!BpEnable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Could not disable memory breakpoint "fhex"\n", found.addr); @@ -1798,7 +1798,7 @@ CMDRESULT cbDebugSetPageRights(int argc, char* argv[]) //update the memory map dbggetprivateusage(fdProcessInfo->hProcess, true); - memupdatemap(fdProcessInfo->hProcess); + MemUpdateMap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); dprintf("New rights of "fhex": %s\n", addr, rights); @@ -1826,7 +1826,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) return STATUS_ERROR; } - if(!memwrite(fdProcessInfo->hProcess, DLLNameMem, argv[1], strlen(argv[1]), NULL)) + if(!MemWrite(DLLNameMem, argv[1], strlen(argv[1]), NULL)) { dprintf("Error: couldn't write process memory"); return STATUS_ERROR; @@ -2000,7 +2000,7 @@ CMDRESULT cbDebugSetCmdline(int argc, char* argv[]) //update the memory map dbggetprivateusage(fdProcessInfo->hProcess, true); - memupdatemap(fdProcessInfo->hProcess); + MemUpdateMap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); dprintf("New command line: %s\n", argv[1]); diff --git a/x64_dbg_dbg/disasm_fast.cpp b/x64_dbg_dbg/disasm_fast.cpp index c68e5052..137f30fa 100644 --- a/x64_dbg_dbg/disasm_fast.cpp +++ b/x64_dbg_dbg/disasm_fast.cpp @@ -117,7 +117,7 @@ bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinf bool disasmfast(uint addr, BASIC_INSTRUCTION_INFO* basicinfo) { unsigned int data[16]; - if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data), 0)) + if(!MemRead((void*)addr, data, sizeof(data), 0)) return false; return disasmfast((unsigned char*)data, addr, basicinfo); } \ No newline at end of file diff --git a/x64_dbg_dbg/disasm_helper.cpp b/x64_dbg_dbg/disasm_helper.cpp index cdee9c63..ca179165 100644 --- a/x64_dbg_dbg/disasm_helper.cpp +++ b/x64_dbg_dbg/disasm_helper.cpp @@ -321,11 +321,11 @@ bool disasmispossiblestring(uint addr) { unsigned char data[11]; memset(data, 0, sizeof(data)); - if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data) - 3, 0)) + if(!MemRead((void*)addr, data, sizeof(data) - 3, 0)) return false; uint test = 0; memcpy(&test, data, sizeof(uint)); - if(memisvalidreadptr(fdProcessInfo->hProcess, test)) //imports/pointers + if(MemIsValidReadPtr(test)) //imports/pointers return false; if(isasciistring(data, sizeof(data)) or isunicodestring(data, _countof(data))) return true; @@ -340,11 +340,11 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, return false; Memory data((maxlen + 1) * 2, "disasmgetstringat:data"); memset(data, 0, (maxlen + 1) * 2); - if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, (maxlen + 1) * 2, 0)) + if(!MemRead((void*)addr, data, (maxlen + 1) * 2, 0)) return false; uint test = 0; memcpy(&test, data, sizeof(uint)); - if(memisvalidreadptr(fdProcessInfo->hProcess, test)) + if(MemIsValidReadPtr(test)) return false; if(isasciistring(data, maxlen)) { @@ -442,7 +442,7 @@ int disasmgetsize(uint addr, unsigned char* data) int disasmgetsize(uint addr) { char data[16]; - if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data), 0)) + if(!MemRead((void*)addr, data, sizeof(data), 0)) return 1; return disasmgetsize(addr, (unsigned char*)data); } \ No newline at end of file diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp index 87552a96..f9d02d19 100644 --- a/x64_dbg_dbg/function.cpp +++ b/x64_dbg_dbg/function.cpp @@ -15,7 +15,7 @@ bool FunctionAdd(uint Start, uint End, bool Manual) return false; // Make sure memory is readable - if(!memisvalidreadptr(fdProcessInfo->hProcess, Start)) + if(!MemIsValidReadPtr(Start)) return false; // Fail if boundary exceeds module size diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index d29154c5..6e0ee4ec 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -158,7 +158,7 @@ CMDRESULT cbInstrMov(int argc, char* argv[]) } //Check the destination uint dest; - if(!valfromstring(argv[1], &dest) || !memisvalidreadptr(fdProcessInfo->hProcess, dest)) + if(!valfromstring(argv[1], &dest) || !MemIsValidReadPtr(dest)) { dprintf("invalid destination \"%s\"\n", argv[1]); return STATUS_ERROR; @@ -175,7 +175,7 @@ CMDRESULT cbInstrMov(int argc, char* argv[]) data[j] = res; } //Move data to destination - if(!memwrite(fdProcessInfo->hProcess, (void*)dest, data, data.size(), 0)) + if(!MemWrite((void*)dest, data, data.size(), 0)) { dprintf("failed to write to "fhex"\n", dest); return STATUS_ERROR; @@ -1053,7 +1053,7 @@ CMDRESULT cbInstrCopystr(int argc, char* argv[]) dprintf("invalid address \"%s\"!\n", argv[1]); return STATUS_ERROR; } - if(!mempatch(fdProcessInfo->hProcess, (void*)addr, string, strlen(string), 0)) + if(!MemPatch((void*)addr, string, strlen(string), 0)) { dputs("memwrite failed!"); return STATUS_ERROR; @@ -1084,14 +1084,14 @@ CMDRESULT cbInstrFind(int argc, char* argv[]) if(pattern[len - 1] == '#') pattern[len - 1] = '\0'; uint size = 0; - uint base = memfindbaseaddr(addr, &size, true); + uint base = MemFindBaseAddr(addr, &size, true); if(!base) { dprintf("invalid memory address "fhex"!\n", addr); return STATUS_ERROR; } Memory data(size, "cbInstrFind:data"); - if(!memread(fdProcessInfo->hProcess, (const void*)base, data, size, 0)) + if(!MemRead((void*)base, data, size, 0)) { dputs("failed to read memory!"); return STATUS_ERROR; @@ -1136,14 +1136,14 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[]) if(pattern[len - 1] == '#') pattern[len - 1] = '\0'; uint size = 0; - uint base = memfindbaseaddr(addr, &size, true); + uint base = MemFindBaseAddr(addr, &size, true); if(!base) { dprintf("invalid memory address "fhex"!\n", addr); return STATUS_ERROR; } Memory data(size, "cbInstrFindAll:data"); - if(!memread(fdProcessInfo->hProcess, (const void*)base, data, size, 0)) + if(!MemRead((void*)base, data, size, 0)) { dputs("failed to read memory!"); return STATUS_ERROR; @@ -1192,7 +1192,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[]) if(findData) { Memory printData(patternsize, "cbInstrFindAll:printData"); - memread(fdProcessInfo->hProcess, (const void*)result, printData, patternsize, 0); + MemRead((void*)result, printData, patternsize, 0); for(int j = 0, k = 0; j < patternsize; j++) { if(j) diff --git a/x64_dbg_dbg/label.cpp b/x64_dbg_dbg/label.cpp index 7f6ad248..e336b4b6 100644 --- a/x64_dbg_dbg/label.cpp +++ b/x64_dbg_dbg/label.cpp @@ -10,7 +10,7 @@ static LabelsInfo labels; bool labelset(uint addr, const char* text, bool manual) { - if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text) >= MAX_LABEL_SIZE - 1 or strstr(text, "&")) + if(!DbgIsDebugging() or !MemIsValidReadPtr(addr) or !text or strlen(text) >= MAX_LABEL_SIZE - 1 or strstr(text, "&")) return false; if(!*text) //NOTE: delete when there is no text { diff --git a/x64_dbg_dbg/loop.cpp b/x64_dbg_dbg/loop.cpp index 6664ae25..247267d7 100644 --- a/x64_dbg_dbg/loop.cpp +++ b/x64_dbg_dbg/loop.cpp @@ -10,7 +10,7 @@ static LoopsInfo loops; bool loopadd(uint start, uint end, bool manual) { - if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) + if(!DbgIsDebugging() or end < start or !MemIsValidReadPtr(start)) return false; const uint modbase = ModBaseFromAddr(start); if(modbase != ModBaseFromAddr(end)) //the function boundaries are not in the same mem page diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 5bdde6c7..e5ef2a1e 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -8,7 +8,7 @@ MemoryMap memoryPages; bool bListAllPages = false; -void memupdatemap(HANDLE hProcess) +void MemUpdateMap(HANDLE hProcess) { CriticalSectionLocker locker(LockMemoryPages); MEMORY_BASIC_INFORMATION mbi; @@ -123,102 +123,139 @@ void memupdatemap(HANDLE hProcess) } } -uint memfindbaseaddr(uint addr, uint* size, bool refresh) +uint MemFindBaseAddr(uint addr, uint* Size, bool refresh) { + // Update the memory map if needed if(refresh) - memupdatemap(fdProcessInfo->hProcess); //update memory map - CriticalSectionLocker locker(LockMemoryPages); - MemoryMap::iterator found = memoryPages.find(std::make_pair(addr, addr)); + MemUpdateMap(fdProcessInfo->hProcess); + + SHARED_ACQUIRE(LockMemoryPages); + + // Search for the memory page address + auto found = memoryPages.find(std::make_pair(addr, addr)); + if(found == memoryPages.end()) return 0; - if(size) - *size = found->second.mbi.RegionSize; + + // Return the allocation region size when requested + if(Size) + *Size = found->second.mbi.RegionSize; + return found->first.first; } -bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead) +bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesRead) { - if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures + // Buffer must be supplied and size must be greater than 0 + if(!Buffer || Size <= 0) return false; - SIZE_T read = 0; - DWORD oldprotect = 0; - bool ret = MemoryReadSafe(hProcess, (void*)lpBaseAddress, lpBuffer, nSize, &read); //try 'normal' RPM - if(ret and read == nSize) //'normal' RPM worked! - { - if(lpNumberOfBytesRead) - *lpNumberOfBytesRead = read; + + // If the 'bytes read' parameter is null, use a temp + SIZE_T bytesReadTemp = 0; + + if(!NumberOfBytesRead) + NumberOfBytesRead = &bytesReadTemp; + + // Normal single-call read + bool ret = MemoryReadSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesRead); + + // Did the normal memory read work? + if(ret && *NumberOfBytesRead == Size) return true; - } - for(uint i = 0; i < nSize; i++) //read byte-per-byte + + // Read byte-by-byte + // TODO: Replace this with a better method (PAGE_SIZE) + for(uint i = 0; i < Size; i++) { - unsigned char* curaddr = (unsigned char*)lpBaseAddress + i; - unsigned char* curbuf = (unsigned char*)lpBuffer + i; - ret = MemoryReadSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' RPM - if(!ret) //we failed + unsigned char* curaddr = (unsigned char*)BaseAddress + i; + unsigned char* curbuf = (unsigned char*)Buffer + i; + + ret = MemoryReadSafe(fdProcessInfo->hProcess, curaddr, curbuf, 1, nullptr); + + if(!ret) { - if(lpNumberOfBytesRead) - *lpNumberOfBytesRead = i; + *NumberOfBytesRead = i; + SetLastError(ERROR_PARTIAL_COPY); return false; } } + return true; } -bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten) +bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) { - if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures + // Buffer must be supplied and size must be greater than 0 + if(!Buffer || Size <= 0) return false; - SIZE_T written = 0; - DWORD oldprotect = 0; - bool ret = MemoryWriteSafe(hProcess, lpBaseAddress, lpBuffer, nSize, &written); - if(ret and written == nSize) //'normal' WPM worked! - { - if(lpNumberOfBytesWritten) - *lpNumberOfBytesWritten = written; + + // If the 'bytes written' parameter is null, use a temp + SIZE_T bytesWrittenTemp = 0; + + if(!NumberOfBytesWritten) + NumberOfBytesWritten = &bytesWrittenTemp; + + // Try a regular WriteProcessMemory call + bool ret = MemoryWriteSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesWritten); + + if(ret and * NumberOfBytesWritten == Size) return true; - } - for(uint i = 0; i < nSize; i++) //write byte-per-byte + + // Fallback: Write byte-by-byte + for(SIZE_T i = 0; i < Size; i++) { - unsigned char* curaddr = (unsigned char*)lpBaseAddress + i; - unsigned char* curbuf = (unsigned char*)lpBuffer + i; - ret = MemoryWriteSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' WPM - if(!ret) //we failed + unsigned char* curaddr = (unsigned char*)BaseAddress + i; + unsigned char* curbuf = (unsigned char*)Buffer + i; + + ret = MemoryWriteSafe(fdProcessInfo->hProcess, curaddr, curbuf, 1, nullptr); + + if(!ret) { - if(lpNumberOfBytesWritten) - *lpNumberOfBytesWritten = i; + *NumberOfBytesWritten = i; + SetLastError(ERROR_PARTIAL_COPY); return false; } } + return true; } -bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten) +bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) { - if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures + // Buffer and size must be valid + if(!Buffer || Size <= 0) return false; - Memory olddata(nSize, "mempatch:olddata"); - if(!memread(hProcess, lpBaseAddress, olddata, nSize, 0)) - return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten); - unsigned char* newdata = (unsigned char*)lpBuffer; - for(uint i = 0; i < nSize; i++) - patchset((uint)lpBaseAddress + i, olddata[i], newdata[i]); - return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten); + + // Allocate the memory + Memory olddata(Size, "mempatch:olddata"); + + if(!MemRead(BaseAddress, olddata, Size, nullptr)) + { + // If no memory can be read, no memory can be written. Fail out + // of this function. + return false; + } + + for(SIZE_T i = 0; i < Size; i++) + patchset((uint)BaseAddress + i, olddata[i], ((unsigned char*)Buffer)[i]); + + return MemWrite(BaseAddress, Buffer, Size, NumberOfBytesWritten); } -bool memisvalidreadptr(HANDLE hProcess, uint addr) +bool MemIsValidReadPtr(uint Address) { unsigned char a = 0; - return memread(hProcess, (void*)addr, &a, 1, 0); + return MemRead((void*)Address, &a, 1, nullptr); } -void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect) +void* MemAllocRemote(uint Address, SIZE_T Size, DWORD Protect) { - return VirtualAllocEx(hProcess, (void*)addr, size, MEM_RESERVE | MEM_COMMIT, fdProtect); + return VirtualAllocEx(fdProcessInfo->hProcess, (void*)Address, Size, MEM_RESERVE | MEM_COMMIT, Protect); } -void memfree(HANDLE hProcess, uint addr) +void MemFreeRemote(uint Address) { - VirtualFreeEx(hProcess, (void*)addr, 0, MEM_RELEASE); + VirtualFreeEx(fdProcessInfo->hProcess, (void*)Address, 0, MEM_RELEASE); } \ No newline at end of file diff --git a/x64_dbg_dbg/memory.h b/x64_dbg_dbg/memory.h index c17c6f18..611f7ca8 100644 --- a/x64_dbg_dbg/memory.h +++ b/x64_dbg_dbg/memory.h @@ -1,6 +1,3 @@ -#ifndef _MEMORY_H -#define _MEMORY_H - #include "_global.h" #include "addrinfo.h" @@ -9,13 +6,11 @@ typedef std::map MemoryMap; extern MemoryMap memoryPages; extern bool bListAllPages; -void memupdatemap(HANDLE hProcess); -uint memfindbaseaddr(uint addr, uint* size, bool refresh = false); -bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead); -bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten); -bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten); -bool memisvalidreadptr(HANDLE hProcess, uint addr); -void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect); -void memfree(HANDLE hProcess, uint addr); - -#endif // _MEMORY_H +void MemUpdateMap(HANDLE hProcess); +uint MemFindBaseAddr(uint addr, uint* Size, bool refresh = false); +bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesRead); +bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); +bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); +bool MemIsValidReadPtr(uint Address); +void* MemAllocRemote(uint Address, SIZE_T Size, DWORD Protect); +void MemFreeRemote(uint Address); \ No newline at end of file diff --git a/x64_dbg_dbg/patches.cpp b/x64_dbg_dbg/patches.cpp index 2b9f6ef5..a15a29b6 100644 --- a/x64_dbg_dbg/patches.cpp +++ b/x64_dbg_dbg/patches.cpp @@ -10,7 +10,7 @@ static PatchesInfo patches; bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte) { - if(!DbgIsDebugging() || !memisvalidreadptr(fdProcessInfo->hProcess, addr)) + if(!DbgIsDebugging() || !MemIsValidReadPtr(addr)) return false; if(oldbyte == newbyte) return true; //no need to make a patch for a byte that is equal to itself @@ -66,7 +66,7 @@ bool patchdel(uint addr, bool restore) if(found == patches.end()) //not found return false; if(restore) - memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr + ModBaseFromAddr(addr)), &found->second.oldbyte, sizeof(char), 0); + MemWrite((void*)(found->second.addr + ModBaseFromAddr(addr)), &found->second.oldbyte, sizeof(char), 0); patches.erase(found); return true; } @@ -88,7 +88,7 @@ void patchdelrange(uint start, uint end, bool restore) if(bDelAll || (i->second.addr >= start && i->second.addr < end)) { if(restore) - memwrite(fdProcessInfo->hProcess, (void*)(i->second.addr + modbase), &i->second.oldbyte, sizeof(char), 0); + MemWrite((void*)(i->second.addr + modbase), &i->second.oldbyte, sizeof(char), 0); patches.erase(i++); } else diff --git a/x64_dbg_dbg/plugin_loader.cpp b/x64_dbg_dbg/plugin_loader.cpp index 1e8fc555..43bf1653 100644 --- a/x64_dbg_dbg/plugin_loader.cpp +++ b/x64_dbg_dbg/plugin_loader.cpp @@ -303,7 +303,7 @@ void plugincbcall(CBTYPE cbType, void* callbackInfo) if(pluginCallbackList.at(i).cbType == cbType) { CBPLUGIN cbPlugin = pluginCallbackList.at(i).cbPlugin; - if(memisvalidreadptr(GetCurrentProcess(), (uint)cbPlugin)) + if(!IsBadReadPtr((const void*)cbPlugin, sizeof(uint))) cbPlugin(cbType, callbackInfo); } } diff --git a/x64_dbg_dbg/reference.cpp b/x64_dbg_dbg/reference.cpp index 03254508..5bd33a2f 100644 --- a/x64_dbg_dbg/reference.cpp +++ b/x64_dbg_dbg/reference.cpp @@ -10,7 +10,7 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent, cons uint start_size; uint base; uint base_size; - base = memfindbaseaddr(addr, &base_size, true); + base = MemFindBaseAddr(addr, &base_size, true); if(!base or !base_size) { if(!silent) @@ -33,7 +33,7 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent, cons start_size = maxsize; } Memory data(start_size, "reffind:data"); - if(!memread(fdProcessInfo->hProcess, (const void*)start_addr, data, start_size, 0)) + if(!MemRead((void*)start_addr, data, start_size, 0)) { if(!silent) dputs("error reading memory"); diff --git a/x64_dbg_dbg/stackinfo.cpp b/x64_dbg_dbg/stackinfo.cpp index 9b92c83f..1b484e1b 100644 --- a/x64_dbg_dbg/stackinfo.cpp +++ b/x64_dbg_dbg/stackinfo.cpp @@ -12,17 +12,17 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) { uint data = 0; memset(comment, 0, sizeof(STACK_COMMENT)); - memread(fdProcessInfo->hProcess, (const void*)addr, &data, sizeof(uint), 0); - if(!memisvalidreadptr(fdProcessInfo->hProcess, data)) //the stack value is no pointer + MemRead((void*)addr, &data, sizeof(uint), 0); + if(!MemIsValidReadPtr(data)) //the stack value is no pointer return false; uint size = 0; - uint base = memfindbaseaddr(data, &size); + uint base = MemFindBaseAddr(data, &size); uint readStart = data - 16 * 4; if(readStart < base) readStart = base; unsigned char disasmData[256]; - memread(fdProcessInfo->hProcess, (const void*)readStart, disasmData, sizeof(disasmData), 0); + MemRead((void*)readStart, disasmData, sizeof(disasmData), 0); uint prev = disasmback(disasmData, 0, sizeof(disasmData), data - readStart, 1); uint previousInstr = readStart + prev; @@ -118,12 +118,12 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) callstack->total = 0; if(!DbgIsDebugging() or csp % sizeof(uint)) //alignment problem return; - if(!memisvalidreadptr(fdProcessInfo->hProcess, csp)) + if(!MemIsValidReadPtr(csp)) return; std::vector callstackVector; DWORD ticks = GetTickCount(); uint stacksize = 0; - uint stackbase = memfindbaseaddr(csp, &stacksize, false); + uint stackbase = MemFindBaseAddr(csp, &stacksize, false); if(!stackbase) //super-fail (invalid stack address) return; //walk up the stack @@ -131,16 +131,16 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) while(i != stackbase + stacksize) { uint data = 0; - memread(fdProcessInfo->hProcess, (const void*)i, &data, sizeof(uint), 0); - if(memisvalidreadptr(fdProcessInfo->hProcess, data)) //the stack value is a pointer + MemRead((void*)i, &data, sizeof(uint), 0); + if(MemIsValidReadPtr(data)) //the stack value is a pointer { uint size = 0; - uint base = memfindbaseaddr(data, &size); + uint base = MemFindBaseAddr(data, &size); uint readStart = data - 16 * 4; if(readStart < base) readStart = base; unsigned char disasmData[256]; - memread(fdProcessInfo->hProcess, (const void*)readStart, disasmData, sizeof(disasmData), 0); + MemRead((void*)readStart, disasmData, sizeof(disasmData), 0); uint prev = disasmback(disasmData, 0, sizeof(disasmData), data - readStart, 1); uint previousInstr = readStart + prev; BASIC_INSTRUCTION_INFO basicinfo; diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index 67be502a..064263ea 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -34,6 +34,7 @@ void ThreadExit(DWORD dwThreadId) { EXCLUSIVE_ACQUIRE(LockThreads); + // Don't use a foreach loop here because of the erase() call for(auto itr = threadList.begin(); itr != threadList.end(); itr++) { if(itr->ThreadId == dwThreadId) @@ -119,7 +120,7 @@ bool ThreadGetTeb(uint TEBAddress, TEB* Teb) // memset(Teb, 0, sizeof(TEB)); - return memread(fdProcessInfo->hProcess, (void*)TEBAddress, Teb, sizeof(TEB), nullptr); + return MemRead((void*)TEBAddress, Teb, sizeof(TEB), nullptr); } int ThreadGetSuspendCount(HANDLE Thread) diff --git a/x64_dbg_dbg/threading.cpp b/x64_dbg_dbg/threading.cpp index 2f421b3e..dfeb9089 100644 --- a/x64_dbg_dbg/threading.cpp +++ b/x64_dbg_dbg/threading.cpp @@ -61,24 +61,4 @@ void SectionLockerGlobal::Deinitialize() } m_Initialized = false; -} - -/* -SharedSectionLocker::SharedSectionLocker(SectionLock LockIndex) - : ExclusiveSectionLocker(LockIndex) -{ - // Nothing to do here; parent class constructor is called -} - -void SharedSectionLocker::Lock() -{ - AcquireSRWLockShared(m_Lock); - m_LockCount++; -} - -void SharedSectionLocker::Unlock() -{ - m_LockCount--; - ReleaseSRWLockShared(m_Lock); -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/x64_dbg_dbg/value.cpp b/x64_dbg_dbg/value.cpp index a9ab2ff2..f440f6e9 100644 --- a/x64_dbg_dbg/value.cpp +++ b/x64_dbg_dbg/value.cpp @@ -1477,7 +1477,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, return false; uint addr = *value; *value = 0; - if(!memread(fdProcessInfo->hProcess, (void*)addr, value, read_size, 0)) + if(!MemRead((void*)addr, value, read_size, 0)) { if(!silent) dputs("failed to read memory"); @@ -2025,7 +2025,7 @@ bool valtostring(const char* string, uint* value, bool silent) { return false; } - if(!mempatch(fdProcessInfo->hProcess, (void*)temp, value, read_size, 0)) + if(!MemPatch((void*)temp, value, read_size, 0)) { if(!silent) dputs("failed to write memory"); diff --git a/x64_dbg_dbg/variable.cpp b/x64_dbg_dbg/variable.cpp index fe4765c8..82d9401d 100644 --- a/x64_dbg_dbg/variable.cpp +++ b/x64_dbg_dbg/variable.cpp @@ -6,15 +6,14 @@ static VAR* vars; static void varsetvalue(VAR* var, VAR_VALUE* value) { - switch(var->value.type) + // VAR_STRING needs to be freed before destroying it + if(var->value.type == VAR_STRING) { - case VAR_STRING: var->value.u.data->clear(); delete var->value.u.data; - break; - default: - break; } + + // Replace all information in the struct memcpy(&var->value, value, sizeof(VAR_VALUE)); } @@ -46,32 +45,37 @@ static bool varset(const char* name, VAR_VALUE* value, bool setreadonly) void varinit() { varfree(); - //General variables + + // General variables varnew("$result\1$res", 0, VAR_SYSTEM); varnew("$result1\1$res1", 0, VAR_SYSTEM); varnew("$result2\1$res2", 0, VAR_SYSTEM); varnew("$result3\1$res3", 0, VAR_SYSTEM); varnew("$result4\1$res4", 0, VAR_SYSTEM); - //InitDebug variables - varnew("$hProcess\1$hp", 0, VAR_READONLY); - varnew("$pid", 0, VAR_READONLY); - //hidden variables + + // InitDebug variables + varnew("$hProcess\1$hp", 0, VAR_READONLY); // Process handle + varnew("$pid", 0, VAR_READONLY); // Process ID + + // Hidden variables varnew("$ans\1$an", 0, VAR_HIDDEN); - //read-only variables - varnew("$lastalloc", 0, VAR_READONLY); - varnew("$_EZ_FLAG", 0, VAR_READONLY); //equal/zero flag for internal use (1=equal, 0=unequal) - varnew("$_BS_FLAG", 0, VAR_READONLY); //bigger/smaller flag for internal use (1=bigger, 0=smaller) + + // Read-only variables + varnew("$lastalloc", 0, VAR_READONLY); // Last memory allocation + varnew("$_EZ_FLAG", 0, VAR_READONLY); // Equal/zero flag for internal use (1=equal, 0=unequal) + varnew("$_BS_FLAG", 0, VAR_READONLY); // Bigger/smaller flag for internal use (1=bigger, 0=smaller) } void varfree() { - CriticalSectionLocker locker(LockVariables); + EXCLUSIVE_ACQUIRE(LockVariables); variables.clear(); } VAR* vargetptr() { - return 0; + // TODO: Implement this? Or remove it. + return nullptr; } bool varnew(const char* name, uint value, VAR_TYPE type) @@ -109,7 +113,7 @@ bool varnew(const char* name, uint value, VAR_TYPE type) static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type) { - EXCLUSIVE_ACQUIRE(LockVariables); + SHARED_ACQUIRE(LockVariables); String name_; if(*name != '$') @@ -121,7 +125,7 @@ static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type if(found->second.alias.length()) { // Release the lock (potential deadlock here) - EXCLUSIVE_RELEASE(); + SHARED_RELEASE(); return varget(found->second.alias.c_str(), value, size, type); } @@ -231,7 +235,8 @@ bool vardel(const char* name, bool delsystem) bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype) { - CriticalSectionLocker locker(LockVariables); + SHARED_ACQUIRE(LockVariables); + String name_; if(*name != '$') name_ = "$"; @@ -248,18 +253,29 @@ bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype) return true; } -bool varenum(VAR* entries, size_t* cbsize) +bool varenum(VAR* List, size_t* Size) { - CriticalSectionLocker locker(LockVariables); - if(!entries && !cbsize || !variables.size()) + // A list or size must be requested + if(!List && !Size) return false; - if(!entries && cbsize) + + SHARED_ACQUIRE(LockVariables); + + if(Size) { - *cbsize = variables.size() * sizeof(VAR); - return true; + // Size requested, so return it + *Size = variables.size() * sizeof(VAR); + + if(!List) + return true; } - int j = 0; - for(VariableMap::iterator i = variables.begin(); i != variables.end(); ++i, j++) - entries[j] = i->second; + + // Fill out all list entries + for(auto & itr : variables) + { + *List = itr.second; + List++; + } + return true; } \ No newline at end of file From 4cb93d72e8c6f354650a4b23554d0f0a02607c54 Mon Sep 17 00:00:00 2001 From: Nukem Date: Thu, 26 Mar 2015 18:40:15 -0400 Subject: [PATCH 068/106] Replace std::map with std::unordered_map --- x64_dbg_dbg/debugger.cpp | 6 +++--- x64_dbg_dbg/error.cpp | 8 ++++---- x64_dbg_dbg/error.h | 9 +++------ x64_dbg_dbg/exception.cpp | 8 ++++---- x64_dbg_dbg/exception.h | 9 +++------ 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 6a01cf3f..89743ca6 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -58,8 +58,8 @@ static DWORD WINAPI memMapThread(void* ptr) void dbginit() { - exceptioninit(); - errorinit(); + ExceptionCodeInit(); + ErrorCodeInit(); CloseHandle(CreateThread(0, 0, memMapThread, 0, 0, 0)); } @@ -1030,7 +1030,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) } } } - const char* exceptionName = exceptionnamefromcode(ExceptionCode); + const char* exceptionName = ExceptionCodeToName(ExceptionCode); if(ExceptionData->dwFirstChance) //first chance exception { if(exceptionName) diff --git a/x64_dbg_dbg/error.cpp b/x64_dbg_dbg/error.cpp index a23875eb..ba4faafb 100644 --- a/x64_dbg_dbg/error.cpp +++ b/x64_dbg_dbg/error.cpp @@ -1,9 +1,9 @@ #include "error.h" -#include +#include -static std::map errorNames; +std::unordered_map errorNames; -void errorinit() +void ErrorCodeInit() { errorNames.insert(std::make_pair(0, "ERROR_SUCCESS")); errorNames.insert(std::make_pair(1, "ERROR_INVALID_FUNCTION")); @@ -2194,7 +2194,7 @@ void errorinit() errorNames.insert(std::make_pair(15301, "ERROR_HASH_NOT_PRESENT")); } -const char* errornamefromcode(unsigned int ErrorCode) +const char* ErrorCodeToName(unsigned int ErrorCode) { if(!errorNames.count(ErrorCode)) return nullptr; diff --git a/x64_dbg_dbg/error.h b/x64_dbg_dbg/error.h index 7b4eeac1..65985171 100644 --- a/x64_dbg_dbg/error.h +++ b/x64_dbg_dbg/error.h @@ -1,7 +1,4 @@ -#ifndef _ERROR_H -#define _ERROR_H +#pragma once -void errorinit(); -const char* errornamefromcode(unsigned int ErrorCode); - -#endif //_ERROR_H \ No newline at end of file +void ErrorCodeInit(); +const char* ErrorCodeToName(unsigned int ErrorCode); \ No newline at end of file diff --git a/x64_dbg_dbg/exception.cpp b/x64_dbg_dbg/exception.cpp index fd10b4fa..c44611cc 100644 --- a/x64_dbg_dbg/exception.cpp +++ b/x64_dbg_dbg/exception.cpp @@ -1,9 +1,9 @@ #include "exception.h" -#include +#include -static std::map exceptionNames; +std::unordered_map exceptionNames; -void exceptioninit() +void ExceptionCodeInit() { exceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); exceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); @@ -69,7 +69,7 @@ void exceptioninit() exceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); } -const char* exceptionnamefromcode(unsigned int ExceptionCode) +const char* ExceptionCodeToName(unsigned int ExceptionCode) { if(!exceptionNames.count(ExceptionCode)) return nullptr; diff --git a/x64_dbg_dbg/exception.h b/x64_dbg_dbg/exception.h index df0ea2a3..39043631 100644 --- a/x64_dbg_dbg/exception.h +++ b/x64_dbg_dbg/exception.h @@ -1,7 +1,4 @@ -#ifndef _EXCEPTION_H -#define _EXCEPTION_H +#pragma once -void exceptioninit(); -const char* exceptionnamefromcode(unsigned int ExceptionCode); - -#endif //_EXCEPTIONS_H \ No newline at end of file +void ExceptionCodeInit(); +const char* ExceptionCodeToName(unsigned int ExceptionCode); \ No newline at end of file From 753418a80d099e81bb732f27b0624322ad8283cd Mon Sep 17 00:00:00 2001 From: Nukem Date: Thu, 26 Mar 2015 18:46:55 -0400 Subject: [PATCH 069/106] Capitalize global variable name --- x64_dbg_dbg/error.cpp | 4380 ++++++++++++++++++------------------- x64_dbg_dbg/exception.cpp | 130 +- 2 files changed, 2255 insertions(+), 2255 deletions(-) diff --git a/x64_dbg_dbg/error.cpp b/x64_dbg_dbg/error.cpp index ba4faafb..8199ecc7 100644 --- a/x64_dbg_dbg/error.cpp +++ b/x64_dbg_dbg/error.cpp @@ -1,2203 +1,2203 @@ #include "error.h" #include -std::unordered_map errorNames; +std::unordered_map ErrorNames; void ErrorCodeInit() { - errorNames.insert(std::make_pair(0, "ERROR_SUCCESS")); - errorNames.insert(std::make_pair(1, "ERROR_INVALID_FUNCTION")); - errorNames.insert(std::make_pair(2, "ERROR_FILE_NOT_FOUND")); - errorNames.insert(std::make_pair(3, "ERROR_PATH_NOT_FOUND")); - errorNames.insert(std::make_pair(4, "ERROR_TOO_MANY_OPEN_FILES")); - errorNames.insert(std::make_pair(5, "ERROR_ACCESS_DENIED")); - errorNames.insert(std::make_pair(6, "ERROR_INVALID_HANDLE")); - errorNames.insert(std::make_pair(7, "ERROR_ARENA_TRASHED")); - errorNames.insert(std::make_pair(8, "ERROR_NOT_ENOUGH_MEMORY")); - errorNames.insert(std::make_pair(9, "ERROR_INVALID_BLOCK")); - errorNames.insert(std::make_pair(10, "ERROR_BAD_ENVIRONMENT")); - errorNames.insert(std::make_pair(11, "ERROR_BAD_FORMAT")); - errorNames.insert(std::make_pair(12, "ERROR_INVALID_ACCESS")); - errorNames.insert(std::make_pair(13, "ERROR_INVALID_DATA")); - errorNames.insert(std::make_pair(14, "ERROR_OUTOFMEMORY")); - errorNames.insert(std::make_pair(15, "ERROR_INVALID_DRIVE")); - errorNames.insert(std::make_pair(16, "ERROR_CURRENT_DIRECTORY")); - errorNames.insert(std::make_pair(17, "ERROR_NOT_SAME_DEVICE")); - errorNames.insert(std::make_pair(18, "ERROR_NO_MORE_FILES")); - errorNames.insert(std::make_pair(19, "ERROR_WRITE_PROTECT")); - errorNames.insert(std::make_pair(20, "ERROR_BAD_UNIT")); - errorNames.insert(std::make_pair(21, "ERROR_NOT_READY")); - errorNames.insert(std::make_pair(22, "ERROR_BAD_COMMAND")); - errorNames.insert(std::make_pair(23, "ERROR_CRC")); - errorNames.insert(std::make_pair(24, "ERROR_BAD_LENGTH")); - errorNames.insert(std::make_pair(25, "ERROR_SEEK")); - errorNames.insert(std::make_pair(26, "ERROR_NOT_DOS_DISK")); - errorNames.insert(std::make_pair(27, "ERROR_SECTOR_NOT_FOUND")); - errorNames.insert(std::make_pair(28, "ERROR_OUT_OF_PAPER")); - errorNames.insert(std::make_pair(29, "ERROR_WRITE_FAULT")); - errorNames.insert(std::make_pair(30, "ERROR_READ_FAULT")); - errorNames.insert(std::make_pair(31, "ERROR_GEN_FAILURE")); - errorNames.insert(std::make_pair(32, "ERROR_SHARING_VIOLATION")); - errorNames.insert(std::make_pair(33, "ERROR_LOCK_VIOLATION")); - errorNames.insert(std::make_pair(34, "ERROR_WRONG_DISK")); - errorNames.insert(std::make_pair(36, "ERROR_SHARING_BUFFER_EXCEEDED")); - errorNames.insert(std::make_pair(38, "ERROR_HANDLE_EOF")); - errorNames.insert(std::make_pair(39, "ERROR_HANDLE_DISK_FULL")); - errorNames.insert(std::make_pair(50, "ERROR_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(51, "ERROR_REM_NOT_LIST")); - errorNames.insert(std::make_pair(52, "ERROR_DUP_NAME")); - errorNames.insert(std::make_pair(53, "ERROR_BAD_NETPATH")); - errorNames.insert(std::make_pair(54, "ERROR_NETWORK_BUSY")); - errorNames.insert(std::make_pair(55, "ERROR_DEV_NOT_EXIST")); - errorNames.insert(std::make_pair(56, "ERROR_TOO_MANY_CMDS")); - errorNames.insert(std::make_pair(57, "ERROR_ADAP_HDW_ERR")); - errorNames.insert(std::make_pair(58, "ERROR_BAD_NET_RESP")); - errorNames.insert(std::make_pair(59, "ERROR_UNEXP_NET_ERR")); - errorNames.insert(std::make_pair(60, "ERROR_BAD_REM_ADAP")); - errorNames.insert(std::make_pair(61, "ERROR_PRINTQ_FULL")); - errorNames.insert(std::make_pair(62, "ERROR_NO_SPOOL_SPACE")); - errorNames.insert(std::make_pair(63, "ERROR_PRINT_CANCELLED")); - errorNames.insert(std::make_pair(64, "ERROR_NETNAME_DELETED")); - errorNames.insert(std::make_pair(65, "ERROR_NETWORK_ACCESS_DENIED")); - errorNames.insert(std::make_pair(66, "ERROR_BAD_DEV_TYPE")); - errorNames.insert(std::make_pair(67, "ERROR_BAD_NET_NAME")); - errorNames.insert(std::make_pair(68, "ERROR_TOO_MANY_NAMES")); - errorNames.insert(std::make_pair(69, "ERROR_TOO_MANY_SESS")); - errorNames.insert(std::make_pair(70, "ERROR_SHARING_PAUSED")); - errorNames.insert(std::make_pair(71, "ERROR_REQ_NOT_ACCEP")); - errorNames.insert(std::make_pair(72, "ERROR_REDIR_PAUSED")); - errorNames.insert(std::make_pair(80, "ERROR_FILE_EXISTS")); - errorNames.insert(std::make_pair(82, "ERROR_CANNOT_MAKE")); - errorNames.insert(std::make_pair(83, "ERROR_FAIL_I24")); - errorNames.insert(std::make_pair(84, "ERROR_OUT_OF_STRUCTURES")); - errorNames.insert(std::make_pair(85, "ERROR_ALREADY_ASSIGNED")); - errorNames.insert(std::make_pair(86, "ERROR_INVALID_PASSWORD")); - errorNames.insert(std::make_pair(87, "ERROR_INVALID_PARAMETER")); - errorNames.insert(std::make_pair(88, "ERROR_NET_WRITE_FAULT")); - errorNames.insert(std::make_pair(89, "ERROR_NO_PROC_SLOTS")); - errorNames.insert(std::make_pair(100, "ERROR_TOO_MANY_SEMAPHORES")); - errorNames.insert(std::make_pair(101, "ERROR_EXCL_SEM_ALREADY_OWNED")); - errorNames.insert(std::make_pair(102, "ERROR_SEM_IS_SET")); - errorNames.insert(std::make_pair(103, "ERROR_TOO_MANY_SEM_REQUESTS")); - errorNames.insert(std::make_pair(104, "ERROR_INVALID_AT_INTERRUPT_TIME")); - errorNames.insert(std::make_pair(105, "ERROR_SEM_OWNER_DIED")); - errorNames.insert(std::make_pair(106, "ERROR_SEM_USER_LIMIT")); - errorNames.insert(std::make_pair(107, "ERROR_DISK_CHANGE")); - errorNames.insert(std::make_pair(108, "ERROR_DRIVE_LOCKED")); - errorNames.insert(std::make_pair(109, "ERROR_BROKEN_PIPE")); - errorNames.insert(std::make_pair(110, "ERROR_OPEN_FAILED")); - errorNames.insert(std::make_pair(111, "ERROR_BUFFER_OVERFLOW")); - errorNames.insert(std::make_pair(112, "ERROR_DISK_FULL")); - errorNames.insert(std::make_pair(113, "ERROR_NO_MORE_SEARCH_HANDLES")); - errorNames.insert(std::make_pair(114, "ERROR_INVALID_TARGET_HANDLE")); - errorNames.insert(std::make_pair(117, "ERROR_INVALID_CATEGORY")); - errorNames.insert(std::make_pair(118, "ERROR_INVALID_VERIFY_SWITCH")); - errorNames.insert(std::make_pair(119, "ERROR_BAD_DRIVER_LEVEL")); - errorNames.insert(std::make_pair(120, "ERROR_CALL_NOT_IMPLEMENTED")); - errorNames.insert(std::make_pair(121, "ERROR_SEM_TIMEOUT")); - errorNames.insert(std::make_pair(122, "ERROR_INSUFFICIENT_BUFFER")); - errorNames.insert(std::make_pair(123, "ERROR_INVALID_NAME")); - errorNames.insert(std::make_pair(124, "ERROR_INVALID_LEVEL")); - errorNames.insert(std::make_pair(125, "ERROR_NO_VOLUME_LABEL")); - errorNames.insert(std::make_pair(126, "ERROR_MOD_NOT_FOUND")); - errorNames.insert(std::make_pair(127, "ERROR_PROC_NOT_FOUND")); - errorNames.insert(std::make_pair(128, "ERROR_WAIT_NO_CHILDREN")); - errorNames.insert(std::make_pair(129, "ERROR_CHILD_NOT_COMPLETE")); - errorNames.insert(std::make_pair(130, "ERROR_DIRECT_ACCESS_HANDLE")); - errorNames.insert(std::make_pair(131, "ERROR_NEGATIVE_SEEK")); - errorNames.insert(std::make_pair(132, "ERROR_SEEK_ON_DEVICE")); - errorNames.insert(std::make_pair(133, "ERROR_IS_JOIN_TARGET")); - errorNames.insert(std::make_pair(134, "ERROR_IS_JOINED")); - errorNames.insert(std::make_pair(135, "ERROR_IS_SUBSTED")); - errorNames.insert(std::make_pair(136, "ERROR_NOT_JOINED")); - errorNames.insert(std::make_pair(137, "ERROR_NOT_SUBSTED")); - errorNames.insert(std::make_pair(138, "ERROR_JOIN_TO_JOIN")); - errorNames.insert(std::make_pair(139, "ERROR_SUBST_TO_SUBST")); - errorNames.insert(std::make_pair(140, "ERROR_JOIN_TO_SUBST")); - errorNames.insert(std::make_pair(141, "ERROR_SUBST_TO_JOIN")); - errorNames.insert(std::make_pair(142, "ERROR_BUSY_DRIVE")); - errorNames.insert(std::make_pair(143, "ERROR_SAME_DRIVE")); - errorNames.insert(std::make_pair(144, "ERROR_DIR_NOT_ROOT")); - errorNames.insert(std::make_pair(145, "ERROR_DIR_NOT_EMPTY")); - errorNames.insert(std::make_pair(146, "ERROR_IS_SUBST_PATH")); - errorNames.insert(std::make_pair(147, "ERROR_IS_JOIN_PATH")); - errorNames.insert(std::make_pair(148, "ERROR_PATH_BUSY")); - errorNames.insert(std::make_pair(149, "ERROR_IS_SUBST_TARGET")); - errorNames.insert(std::make_pair(150, "ERROR_SYSTEM_TRACE")); - errorNames.insert(std::make_pair(151, "ERROR_INVALID_EVENT_COUNT")); - errorNames.insert(std::make_pair(152, "ERROR_TOO_MANY_MUXWAITERS")); - errorNames.insert(std::make_pair(153, "ERROR_INVALID_LIST_FORMAT")); - errorNames.insert(std::make_pair(154, "ERROR_LABEL_TOO_LONG")); - errorNames.insert(std::make_pair(155, "ERROR_TOO_MANY_TCBS")); - errorNames.insert(std::make_pair(156, "ERROR_SIGNAL_REFUSED")); - errorNames.insert(std::make_pair(157, "ERROR_DISCARDED")); - errorNames.insert(std::make_pair(158, "ERROR_NOT_LOCKED")); - errorNames.insert(std::make_pair(159, "ERROR_BAD_THREADID_ADDR")); - errorNames.insert(std::make_pair(160, "ERROR_BAD_ARGUMENTS")); - errorNames.insert(std::make_pair(161, "ERROR_BAD_PATHNAME")); - errorNames.insert(std::make_pair(162, "ERROR_SIGNAL_PENDING")); - errorNames.insert(std::make_pair(164, "ERROR_MAX_THRDS_REACHED")); - errorNames.insert(std::make_pair(167, "ERROR_LOCK_FAILED")); - errorNames.insert(std::make_pair(170, "ERROR_BUSY")); - errorNames.insert(std::make_pair(173, "ERROR_CANCEL_VIOLATION")); - errorNames.insert(std::make_pair(174, "ERROR_ATOMIC_LOCKS_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(180, "ERROR_INVALID_SEGMENT_NUMBER")); - errorNames.insert(std::make_pair(182, "ERROR_INVALID_ORDINAL")); - errorNames.insert(std::make_pair(183, "ERROR_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(186, "ERROR_INVALID_FLAG_NUMBER")); - errorNames.insert(std::make_pair(187, "ERROR_SEM_NOT_FOUND")); - errorNames.insert(std::make_pair(188, "ERROR_INVALID_STARTING_CODESEG")); - errorNames.insert(std::make_pair(189, "ERROR_INVALID_STACKSEG")); - errorNames.insert(std::make_pair(190, "ERROR_INVALID_MODULETYPE")); - errorNames.insert(std::make_pair(191, "ERROR_INVALID_EXE_SIGNATURE")); - errorNames.insert(std::make_pair(192, "ERROR_EXE_MARKED_INVALID")); - errorNames.insert(std::make_pair(193, "ERROR_BAD_EXE_FORMAT")); - errorNames.insert(std::make_pair(194, "ERROR_ITERATED_DATA_EXCEEDS_64k")); - errorNames.insert(std::make_pair(195, "ERROR_INVALID_MINALLOCSIZE")); - errorNames.insert(std::make_pair(196, "ERROR_DYNLINK_FROM_INVALID_RING")); - errorNames.insert(std::make_pair(197, "ERROR_IOPL_NOT_ENABLED")); - errorNames.insert(std::make_pair(198, "ERROR_INVALID_SEGDPL")); - errorNames.insert(std::make_pair(199, "ERROR_AUTODATASEG_EXCEEDS_64k")); - errorNames.insert(std::make_pair(200, "ERROR_RING2SEG_MUST_BE_MOVABLE")); - errorNames.insert(std::make_pair(201, "ERROR_RELOC_CHAIN_XEEDS_SEGLIM")); - errorNames.insert(std::make_pair(202, "ERROR_INFLOOP_IN_RELOC_CHAIN")); - errorNames.insert(std::make_pair(203, "ERROR_ENVVAR_NOT_FOUND")); - errorNames.insert(std::make_pair(205, "ERROR_NO_SIGNAL_SENT")); - errorNames.insert(std::make_pair(206, "ERROR_FILENAME_EXCED_RANGE")); - errorNames.insert(std::make_pair(207, "ERROR_RING2_STACK_IN_USE")); - errorNames.insert(std::make_pair(208, "ERROR_META_EXPANSION_TOO_LONG")); - errorNames.insert(std::make_pair(209, "ERROR_INVALID_SIGNAL_NUMBER")); - errorNames.insert(std::make_pair(210, "ERROR_THREAD_1_INACTIVE")); - errorNames.insert(std::make_pair(212, "ERROR_LOCKED")); - errorNames.insert(std::make_pair(214, "ERROR_TOO_MANY_MODULES")); - errorNames.insert(std::make_pair(215, "ERROR_NESTING_NOT_ALLOWED")); - errorNames.insert(std::make_pair(216, "ERROR_EXE_MACHINE_TYPE_MISMATCH")); - errorNames.insert(std::make_pair(217, "ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY")); - errorNames.insert(std::make_pair(218, "ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY")); - errorNames.insert(std::make_pair(220, "ERROR_FILE_CHECKED_OUT")); - errorNames.insert(std::make_pair(221, "ERROR_CHECKOUT_REQUIRED")); - errorNames.insert(std::make_pair(222, "ERROR_BAD_FILE_TYPE")); - errorNames.insert(std::make_pair(223, "ERROR_FILE_TOO_LARGE")); - errorNames.insert(std::make_pair(224, "ERROR_FORMS_AUTH_REQUIRED")); - errorNames.insert(std::make_pair(225, "ERROR_VIRUS_INFECTED")); - errorNames.insert(std::make_pair(226, "ERROR_VIRUS_DELETED")); - errorNames.insert(std::make_pair(229, "ERROR_PIPE_LOCAL")); - errorNames.insert(std::make_pair(230, "ERROR_BAD_PIPE")); - errorNames.insert(std::make_pair(231, "ERROR_PIPE_BUSY")); - errorNames.insert(std::make_pair(232, "ERROR_NO_DATA")); - errorNames.insert(std::make_pair(233, "ERROR_PIPE_NOT_CONNECTED")); - errorNames.insert(std::make_pair(234, "ERROR_MORE_DATA")); - errorNames.insert(std::make_pair(240, "ERROR_VC_DISCONNECTED")); - errorNames.insert(std::make_pair(254, "ERROR_INVALID_EA_NAME")); - errorNames.insert(std::make_pair(255, "ERROR_EA_LIST_INCONSISTENT")); - errorNames.insert(std::make_pair(259, "ERROR_NO_MORE_ITEMS")); - errorNames.insert(std::make_pair(266, "ERROR_CANNOT_COPY")); - errorNames.insert(std::make_pair(267, "ERROR_DIRECTORY")); - errorNames.insert(std::make_pair(275, "ERROR_EAS_DIDNT_FIT")); - errorNames.insert(std::make_pair(276, "ERROR_EA_FILE_CORRUPT")); - errorNames.insert(std::make_pair(277, "ERROR_EA_TABLE_FULL")); - errorNames.insert(std::make_pair(278, "ERROR_INVALID_EA_HANDLE")); - errorNames.insert(std::make_pair(282, "ERROR_EAS_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(288, "ERROR_NOT_OWNER")); - errorNames.insert(std::make_pair(298, "ERROR_TOO_MANY_POSTS")); - errorNames.insert(std::make_pair(299, "ERROR_PARTIAL_COPY")); - errorNames.insert(std::make_pair(300, "ERROR_OPLOCK_NOT_GRANTED")); - errorNames.insert(std::make_pair(301, "ERROR_INVALID_OPLOCK_PROTOCOL")); - errorNames.insert(std::make_pair(302, "ERROR_DISK_TOO_FRAGMENTED")); - errorNames.insert(std::make_pair(303, "ERROR_DELETE_PENDING")); - errorNames.insert(std::make_pair(304, "ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING")); - errorNames.insert(std::make_pair(305, "ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME")); - errorNames.insert(std::make_pair(306, "ERROR_SECURITY_STREAM_IS_INCONSISTENT")); - errorNames.insert(std::make_pair(307, "ERROR_INVALID_LOCK_RANGE")); - errorNames.insert(std::make_pair(308, "ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT")); - errorNames.insert(std::make_pair(309, "ERROR_NOTIFICATION_GUID_ALREADY_DEFINED")); - errorNames.insert(std::make_pair(317, "ERROR_MR_MID_NOT_FOUND")); - errorNames.insert(std::make_pair(318, "ERROR_SCOPE_NOT_FOUND")); - errorNames.insert(std::make_pair(350, "ERROR_FAIL_NOACTION_REBOOT")); - errorNames.insert(std::make_pair(351, "ERROR_FAIL_SHUTDOWN")); - errorNames.insert(std::make_pair(352, "ERROR_FAIL_RESTART")); - errorNames.insert(std::make_pair(353, "ERROR_MAX_SESSIONS_REACHED")); - errorNames.insert(std::make_pair(400, "ERROR_THREAD_MODE_ALREADY_BACKGROUND")); - errorNames.insert(std::make_pair(401, "ERROR_THREAD_MODE_NOT_BACKGROUND")); - errorNames.insert(std::make_pair(402, "ERROR_PROCESS_MODE_ALREADY_BACKGROUND")); - errorNames.insert(std::make_pair(403, "ERROR_PROCESS_MODE_NOT_BACKGROUND")); - errorNames.insert(std::make_pair(487, "ERROR_INVALID_ADDRESS")); - errorNames.insert(std::make_pair(500, "ERROR_USER_PROFILE_LOAD")); - errorNames.insert(std::make_pair(534, "ERROR_ARITHMETIC_OVERFLOW")); - errorNames.insert(std::make_pair(535, "ERROR_PIPE_CONNECTED")); - errorNames.insert(std::make_pair(536, "ERROR_PIPE_LISTENING")); - errorNames.insert(std::make_pair(537, "ERROR_VERIFIER_STOP")); - errorNames.insert(std::make_pair(538, "ERROR_ABIOS_ERROR")); - errorNames.insert(std::make_pair(539, "ERROR_WX86_WARNING")); - errorNames.insert(std::make_pair(540, "ERROR_WX86_ERROR")); - errorNames.insert(std::make_pair(541, "ERROR_TIMER_NOT_CANCELED")); - errorNames.insert(std::make_pair(542, "ERROR_UNWIND")); - errorNames.insert(std::make_pair(543, "ERROR_BAD_STACK")); - errorNames.insert(std::make_pair(544, "ERROR_INVALID_UNWIND_TARGET")); - errorNames.insert(std::make_pair(545, "ERROR_INVALID_PORT_ATTRIBUTES")); - errorNames.insert(std::make_pair(546, "ERROR_PORT_MESSAGE_TOO_LONG")); - errorNames.insert(std::make_pair(547, "ERROR_INVALID_QUOTA_LOWER")); - errorNames.insert(std::make_pair(548, "ERROR_DEVICE_ALREADY_ATTACHED")); - errorNames.insert(std::make_pair(549, "ERROR_INSTRUCTION_MISALIGNMENT")); - errorNames.insert(std::make_pair(550, "ERROR_PROFILING_NOT_STARTED")); - errorNames.insert(std::make_pair(551, "ERROR_PROFILING_NOT_STOPPED")); - errorNames.insert(std::make_pair(552, "ERROR_COULD_NOT_INTERPRET")); - errorNames.insert(std::make_pair(553, "ERROR_PROFILING_AT_LIMIT")); - errorNames.insert(std::make_pair(554, "ERROR_CANT_WAIT")); - errorNames.insert(std::make_pair(555, "ERROR_CANT_TERMINATE_SELF")); - errorNames.insert(std::make_pair(556, "ERROR_UNEXPECTED_MM_CREATE_ERR")); - errorNames.insert(std::make_pair(557, "ERROR_UNEXPECTED_MM_MAP_ERROR")); - errorNames.insert(std::make_pair(558, "ERROR_UNEXPECTED_MM_EXTEND_ERR")); - errorNames.insert(std::make_pair(559, "ERROR_BAD_FUNCTION_TABLE")); - errorNames.insert(std::make_pair(560, "ERROR_NO_GUID_TRANSLATION")); - errorNames.insert(std::make_pair(561, "ERROR_INVALID_LDT_SIZE")); - errorNames.insert(std::make_pair(563, "ERROR_INVALID_LDT_OFFSET")); - errorNames.insert(std::make_pair(564, "ERROR_INVALID_LDT_DESCRIPTOR")); - errorNames.insert(std::make_pair(565, "ERROR_TOO_MANY_THREADS")); - errorNames.insert(std::make_pair(566, "ERROR_THREAD_NOT_IN_PROCESS")); - errorNames.insert(std::make_pair(567, "ERROR_PAGEFILE_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(568, "ERROR_LOGON_SERVER_CONFLICT")); - errorNames.insert(std::make_pair(569, "ERROR_SYNCHRONIZATION_REQUIRED")); - errorNames.insert(std::make_pair(570, "ERROR_NET_OPEN_FAILED")); - errorNames.insert(std::make_pair(571, "ERROR_IO_PRIVILEGE_FAILED")); - errorNames.insert(std::make_pair(572, "ERROR_CONTROL_C_EXIT")); - errorNames.insert(std::make_pair(573, "ERROR_MISSING_SYSTEMFILE")); - errorNames.insert(std::make_pair(574, "ERROR_UNHANDLED_EXCEPTION")); - errorNames.insert(std::make_pair(575, "ERROR_APP_INIT_FAILURE")); - errorNames.insert(std::make_pair(576, "ERROR_PAGEFILE_CREATE_FAILED")); - errorNames.insert(std::make_pair(577, "ERROR_INVALID_IMAGE_HASH")); - errorNames.insert(std::make_pair(578, "ERROR_NO_PAGEFILE")); - errorNames.insert(std::make_pair(579, "ERROR_ILLEGAL_FLOAT_CONTEXT")); - errorNames.insert(std::make_pair(580, "ERROR_NO_EVENT_PAIR")); - errorNames.insert(std::make_pair(581, "ERROR_DOMAIN_CTRLR_CONFIG_ERROR")); - errorNames.insert(std::make_pair(582, "ERROR_ILLEGAL_CHARACTER")); - errorNames.insert(std::make_pair(583, "ERROR_UNDEFINED_CHARACTER")); - errorNames.insert(std::make_pair(584, "ERROR_FLOPPY_VOLUME")); - errorNames.insert(std::make_pair(585, "ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT")); - errorNames.insert(std::make_pair(586, "ERROR_BACKUP_CONTROLLER")); - errorNames.insert(std::make_pair(587, "ERROR_MUTANT_LIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(588, "ERROR_FS_DRIVER_REQUIRED")); - errorNames.insert(std::make_pair(589, "ERROR_CANNOT_LOAD_REGISTRY_FILE")); - errorNames.insert(std::make_pair(590, "ERROR_DEBUG_ATTACH_FAILED")); - errorNames.insert(std::make_pair(591, "ERROR_SYSTEM_PROCESS_TERMINATED")); - errorNames.insert(std::make_pair(592, "ERROR_DATA_NOT_ACCEPTED")); - errorNames.insert(std::make_pair(593, "ERROR_VDM_HARD_ERROR")); - errorNames.insert(std::make_pair(594, "ERROR_DRIVER_CANCEL_TIMEOUT")); - errorNames.insert(std::make_pair(595, "ERROR_REPLY_MESSAGE_MISMATCH")); - errorNames.insert(std::make_pair(596, "ERROR_LOST_WRITEBEHIND_DATA")); - errorNames.insert(std::make_pair(597, "ERROR_CLIENT_SERVER_PARAMETERS_INVALID")); - errorNames.insert(std::make_pair(598, "ERROR_NOT_TINY_STREAM")); - errorNames.insert(std::make_pair(599, "ERROR_STACK_OVERFLOW_READ")); - errorNames.insert(std::make_pair(600, "ERROR_CONVERT_TO_LARGE")); - errorNames.insert(std::make_pair(601, "ERROR_FOUND_OUT_OF_SCOPE")); - errorNames.insert(std::make_pair(602, "ERROR_ALLOCATE_BUCKET")); - errorNames.insert(std::make_pair(603, "ERROR_MARSHALL_OVERFLOW")); - errorNames.insert(std::make_pair(604, "ERROR_INVALID_VARIANT")); - errorNames.insert(std::make_pair(605, "ERROR_BAD_COMPRESSION_BUFFER")); - errorNames.insert(std::make_pair(606, "ERROR_AUDIT_FAILED")); - errorNames.insert(std::make_pair(607, "ERROR_TIMER_RESOLUTION_NOT_SET")); - errorNames.insert(std::make_pair(608, "ERROR_INSUFFICIENT_LOGON_INFO")); - errorNames.insert(std::make_pair(609, "ERROR_BAD_DLL_ENTRYPOINT")); - errorNames.insert(std::make_pair(610, "ERROR_BAD_SERVICE_ENTRYPOINT")); - errorNames.insert(std::make_pair(611, "ERROR_IP_ADDRESS_CONFLICT1")); - errorNames.insert(std::make_pair(612, "ERROR_IP_ADDRESS_CONFLICT2")); - errorNames.insert(std::make_pair(613, "ERROR_REGISTRY_QUOTA_LIMIT")); - errorNames.insert(std::make_pair(614, "ERROR_NO_CALLBACK_ACTIVE")); - errorNames.insert(std::make_pair(615, "ERROR_PWD_TOO_SHORT")); - errorNames.insert(std::make_pair(616, "ERROR_PWD_TOO_RECENT")); - errorNames.insert(std::make_pair(617, "ERROR_PWD_HISTORY_CONFLICT")); - errorNames.insert(std::make_pair(618, "ERROR_UNSUPPORTED_COMPRESSION")); - errorNames.insert(std::make_pair(619, "ERROR_INVALID_HW_PROFILE")); - errorNames.insert(std::make_pair(620, "ERROR_INVALID_PLUGPLAY_DEVICE_PATH")); - errorNames.insert(std::make_pair(621, "ERROR_QUOTA_LIST_INCONSISTENT")); - errorNames.insert(std::make_pair(622, "ERROR_EVALUATION_EXPIRATION")); - errorNames.insert(std::make_pair(623, "ERROR_ILLEGAL_DLL_RELOCATION")); - errorNames.insert(std::make_pair(624, "ERROR_DLL_INIT_FAILED_LOGOFF")); - errorNames.insert(std::make_pair(625, "ERROR_VALIDATE_CONTINUE")); - errorNames.insert(std::make_pair(626, "ERROR_NO_MORE_MATCHES")); - errorNames.insert(std::make_pair(627, "ERROR_RANGE_LIST_CONFLICT")); - errorNames.insert(std::make_pair(628, "ERROR_SERVER_SID_MISMATCH")); - errorNames.insert(std::make_pair(629, "ERROR_CANT_ENABLE_DENY_ONLY")); - errorNames.insert(std::make_pair(630, "ERROR_FLOAT_MULTIPLE_FAULTS")); - errorNames.insert(std::make_pair(631, "ERROR_FLOAT_MULTIPLE_TRAPS")); - errorNames.insert(std::make_pair(632, "ERROR_NOINTERFACE")); - errorNames.insert(std::make_pair(633, "ERROR_DRIVER_FAILED_SLEEP")); - errorNames.insert(std::make_pair(634, "ERROR_CORRUPT_SYSTEM_FILE")); - errorNames.insert(std::make_pair(635, "ERROR_COMMITMENT_MINIMUM")); - errorNames.insert(std::make_pair(636, "ERROR_PNP_RESTART_ENUMERATION")); - errorNames.insert(std::make_pair(637, "ERROR_SYSTEM_IMAGE_BAD_SIGNATURE")); - errorNames.insert(std::make_pair(638, "ERROR_PNP_REBOOT_REQUIRED")); - errorNames.insert(std::make_pair(639, "ERROR_INSUFFICIENT_POWER")); - errorNames.insert(std::make_pair(640, "ERROR_MULTIPLE_FAULT_VIOLATION")); - errorNames.insert(std::make_pair(641, "ERROR_SYSTEM_SHUTDOWN")); - errorNames.insert(std::make_pair(642, "ERROR_PORT_NOT_SET")); - errorNames.insert(std::make_pair(643, "ERROR_DS_VERSION_CHECK_FAILURE")); - errorNames.insert(std::make_pair(644, "ERROR_RANGE_NOT_FOUND")); - errorNames.insert(std::make_pair(646, "ERROR_NOT_SAFE_MODE_DRIVER")); - errorNames.insert(std::make_pair(647, "ERROR_FAILED_DRIVER_ENTRY")); - errorNames.insert(std::make_pair(648, "ERROR_DEVICE_ENUMERATION_ERROR")); - errorNames.insert(std::make_pair(649, "ERROR_MOUNT_POINT_NOT_RESOLVED")); - errorNames.insert(std::make_pair(650, "ERROR_INVALID_DEVICE_OBJECT_PARAMETER")); - errorNames.insert(std::make_pair(651, "ERROR_MCA_OCCURED")); - errorNames.insert(std::make_pair(652, "ERROR_DRIVER_DATABASE_ERROR")); - errorNames.insert(std::make_pair(653, "ERROR_SYSTEM_HIVE_TOO_LARGE")); - errorNames.insert(std::make_pair(654, "ERROR_DRIVER_FAILED_PRIOR_UNLOAD")); - errorNames.insert(std::make_pair(655, "ERROR_VOLSNAP_PREPARE_HIBERNATE")); - errorNames.insert(std::make_pair(656, "ERROR_HIBERNATION_FAILURE")); - errorNames.insert(std::make_pair(665, "ERROR_FILE_SYSTEM_LIMITATION")); - errorNames.insert(std::make_pair(668, "ERROR_ASSERTION_FAILURE")); - errorNames.insert(std::make_pair(669, "ERROR_ACPI_ERROR")); - errorNames.insert(std::make_pair(670, "ERROR_WOW_ASSERTION")); - errorNames.insert(std::make_pair(671, "ERROR_PNP_BAD_MPS_TABLE")); - errorNames.insert(std::make_pair(672, "ERROR_PNP_TRANSLATION_FAILED")); - errorNames.insert(std::make_pair(673, "ERROR_PNP_IRQ_TRANSLATION_FAILED")); - errorNames.insert(std::make_pair(674, "ERROR_PNP_INVALID_ID")); - errorNames.insert(std::make_pair(675, "ERROR_WAKE_SYSTEM_DEBUGGER")); - errorNames.insert(std::make_pair(676, "ERROR_HANDLES_CLOSED")); - errorNames.insert(std::make_pair(677, "ERROR_EXTRANEOUS_INFORMATION")); - errorNames.insert(std::make_pair(678, "ERROR_RXACT_COMMIT_NECESSARY")); - errorNames.insert(std::make_pair(679, "ERROR_MEDIA_CHECK")); - errorNames.insert(std::make_pair(680, "ERROR_GUID_SUBSTITUTION_MADE")); - errorNames.insert(std::make_pair(681, "ERROR_STOPPED_ON_SYMLINK")); - errorNames.insert(std::make_pair(682, "ERROR_LONGJUMP")); - errorNames.insert(std::make_pair(683, "ERROR_PLUGPLAY_QUERY_VETOED")); - errorNames.insert(std::make_pair(684, "ERROR_UNWIND_CONSOLIDATE")); - errorNames.insert(std::make_pair(685, "ERROR_REGISTRY_HIVE_RECOVERED")); - errorNames.insert(std::make_pair(686, "ERROR_DLL_MIGHT_BE_INSECURE")); - errorNames.insert(std::make_pair(687, "ERROR_DLL_MIGHT_BE_INCOMPATIBLE")); - errorNames.insert(std::make_pair(688, "ERROR_DBG_EXCEPTION_NOT_HANDLED")); - errorNames.insert(std::make_pair(689, "ERROR_DBG_REPLY_LATER")); - errorNames.insert(std::make_pair(690, "ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE")); - errorNames.insert(std::make_pair(691, "ERROR_DBG_TERMINATE_THREAD")); - errorNames.insert(std::make_pair(692, "ERROR_DBG_TERMINATE_PROCESS")); - errorNames.insert(std::make_pair(693, "ERROR_DBG_CONTROL_C")); - errorNames.insert(std::make_pair(694, "ERROR_DBG_PRINTEXCEPTION_C")); - errorNames.insert(std::make_pair(695, "ERROR_DBG_RIPEXCEPTION")); - errorNames.insert(std::make_pair(696, "ERROR_DBG_CONTROL_BREAK")); - errorNames.insert(std::make_pair(697, "ERROR_DBG_COMMAND_EXCEPTION")); - errorNames.insert(std::make_pair(698, "ERROR_OBJECT_NAME_EXISTS")); - errorNames.insert(std::make_pair(699, "ERROR_THREAD_WAS_SUSPENDED")); - errorNames.insert(std::make_pair(700, "ERROR_IMAGE_NOT_AT_BASE")); - errorNames.insert(std::make_pair(701, "ERROR_RXACT_STATE_CREATED")); - errorNames.insert(std::make_pair(702, "ERROR_SEGMENT_NOTIFICATION")); - errorNames.insert(std::make_pair(703, "ERROR_BAD_CURRENT_DIRECTORY")); - errorNames.insert(std::make_pair(704, "ERROR_FT_READ_RECOVERY_FROM_BACKUP")); - errorNames.insert(std::make_pair(705, "ERROR_FT_WRITE_RECOVERY")); - errorNames.insert(std::make_pair(706, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH")); - errorNames.insert(std::make_pair(707, "ERROR_RECEIVE_PARTIAL")); - errorNames.insert(std::make_pair(708, "ERROR_RECEIVE_EXPEDITED")); - errorNames.insert(std::make_pair(709, "ERROR_RECEIVE_PARTIAL_EXPEDITED")); - errorNames.insert(std::make_pair(710, "ERROR_EVENT_DONE")); - errorNames.insert(std::make_pair(711, "ERROR_EVENT_PENDING")); - errorNames.insert(std::make_pair(712, "ERROR_CHECKING_FILE_SYSTEM")); - errorNames.insert(std::make_pair(713, "ERROR_FATAL_APP_EXIT")); - errorNames.insert(std::make_pair(714, "ERROR_PREDEFINED_HANDLE")); - errorNames.insert(std::make_pair(715, "ERROR_WAS_UNLOCKED")); - errorNames.insert(std::make_pair(716, "ERROR_SERVICE_NOTIFICATION")); - errorNames.insert(std::make_pair(717, "ERROR_WAS_LOCKED")); - errorNames.insert(std::make_pair(718, "ERROR_LOG_HARD_ERROR")); - errorNames.insert(std::make_pair(719, "ERROR_ALREADY_WIN32")); - errorNames.insert(std::make_pair(720, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE")); - errorNames.insert(std::make_pair(721, "ERROR_NO_YIELD_PERFORMED")); - errorNames.insert(std::make_pair(722, "ERROR_TIMER_RESUME_IGNORED")); - errorNames.insert(std::make_pair(723, "ERROR_ARBITRATION_UNHANDLED")); - errorNames.insert(std::make_pair(724, "ERROR_CARDBUS_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(725, "ERROR_MP_PROCESSOR_MISMATCH")); - errorNames.insert(std::make_pair(726, "ERROR_HIBERNATED")); - errorNames.insert(std::make_pair(727, "ERROR_RESUME_HIBERNATION")); - errorNames.insert(std::make_pair(728, "ERROR_FIRMWARE_UPDATED")); - errorNames.insert(std::make_pair(729, "ERROR_DRIVERS_LEAKING_LOCKED_PAGES")); - errorNames.insert(std::make_pair(730, "ERROR_WAKE_SYSTEM")); - errorNames.insert(std::make_pair(731, "ERROR_WAIT_1")); - errorNames.insert(std::make_pair(732, "ERROR_WAIT_2")); - errorNames.insert(std::make_pair(733, "ERROR_WAIT_3")); - errorNames.insert(std::make_pair(734, "ERROR_WAIT_63")); - errorNames.insert(std::make_pair(735, "ERROR_ABANDONED_WAIT_0")); - errorNames.insert(std::make_pair(736, "ERROR_ABANDONED_WAIT_63")); - errorNames.insert(std::make_pair(737, "ERROR_USER_APC")); - errorNames.insert(std::make_pair(738, "ERROR_KERNEL_APC")); - errorNames.insert(std::make_pair(739, "ERROR_ALERTED")); - errorNames.insert(std::make_pair(740, "ERROR_ELEVATION_REQUIRED")); - errorNames.insert(std::make_pair(741, "ERROR_REPARSE")); - errorNames.insert(std::make_pair(742, "ERROR_OPLOCK_BREAK_IN_PROGRESS")); - errorNames.insert(std::make_pair(743, "ERROR_VOLUME_MOUNTED")); - errorNames.insert(std::make_pair(744, "ERROR_RXACT_COMMITTED")); - errorNames.insert(std::make_pair(745, "ERROR_NOTIFY_CLEANUP")); - errorNames.insert(std::make_pair(746, "ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED")); - errorNames.insert(std::make_pair(747, "ERROR_PAGE_FAULT_TRANSITION")); - errorNames.insert(std::make_pair(748, "ERROR_PAGE_FAULT_DEMAND_ZERO")); - errorNames.insert(std::make_pair(749, "ERROR_PAGE_FAULT_COPY_ON_WRITE")); - errorNames.insert(std::make_pair(750, "ERROR_PAGE_FAULT_GUARD_PAGE")); - errorNames.insert(std::make_pair(751, "ERROR_PAGE_FAULT_PAGING_FILE")); - errorNames.insert(std::make_pair(752, "ERROR_CACHE_PAGE_LOCKED")); - errorNames.insert(std::make_pair(753, "ERROR_CRASH_DUMP")); - errorNames.insert(std::make_pair(754, "ERROR_BUFFER_ALL_ZEROS")); - errorNames.insert(std::make_pair(755, "ERROR_REPARSE_OBJECT")); - errorNames.insert(std::make_pair(756, "ERROR_RESOURCE_REQUIREMENTS_CHANGED")); - errorNames.insert(std::make_pair(757, "ERROR_TRANSLATION_COMPLETE")); - errorNames.insert(std::make_pair(758, "ERROR_NOTHING_TO_TERMINATE")); - errorNames.insert(std::make_pair(759, "ERROR_PROCESS_NOT_IN_JOB")); - errorNames.insert(std::make_pair(760, "ERROR_PROCESS_IN_JOB")); - errorNames.insert(std::make_pair(761, "ERROR_VOLSNAP_HIBERNATE_READY")); - errorNames.insert(std::make_pair(762, "ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY")); - errorNames.insert(std::make_pair(763, "ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED")); - errorNames.insert(std::make_pair(764, "ERROR_INTERRUPT_STILL_CONNECTED")); - errorNames.insert(std::make_pair(765, "ERROR_WAIT_FOR_OPLOCK")); - errorNames.insert(std::make_pair(766, "ERROR_DBG_EXCEPTION_HANDLED")); - errorNames.insert(std::make_pair(767, "ERROR_DBG_CONTINUE")); - errorNames.insert(std::make_pair(768, "ERROR_CALLBACK_POP_STACK")); - errorNames.insert(std::make_pair(769, "ERROR_COMPRESSION_DISABLED")); - errorNames.insert(std::make_pair(770, "ERROR_CANTFETCHBACKWARDS")); - errorNames.insert(std::make_pair(771, "ERROR_CANTSCROLLBACKWARDS")); - errorNames.insert(std::make_pair(772, "ERROR_ROWSNOTRELEASED")); - errorNames.insert(std::make_pair(773, "ERROR_BAD_ACCESSOR_FLAGS")); - errorNames.insert(std::make_pair(774, "ERROR_ERRORS_ENCOUNTERED")); - errorNames.insert(std::make_pair(775, "ERROR_NOT_CAPABLE")); - errorNames.insert(std::make_pair(776, "ERROR_REQUEST_OUT_OF_SEQUENCE")); - errorNames.insert(std::make_pair(777, "ERROR_VERSION_PARSE_ERROR")); - errorNames.insert(std::make_pair(778, "ERROR_BADSTARTPOSITION")); - errorNames.insert(std::make_pair(779, "ERROR_MEMORY_HARDWARE")); - errorNames.insert(std::make_pair(780, "ERROR_DISK_REPAIR_DISABLED")); - errorNames.insert(std::make_pair(781, "ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE")); - errorNames.insert(std::make_pair(782, "ERROR_SYSTEM_POWERSTATE_TRANSITION")); - errorNames.insert(std::make_pair(783, "ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION")); - errorNames.insert(std::make_pair(784, "ERROR_MCA_EXCEPTION")); - errorNames.insert(std::make_pair(785, "ERROR_ACCESS_AUDIT_BY_POLICY")); - errorNames.insert(std::make_pair(786, "ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY")); - errorNames.insert(std::make_pair(787, "ERROR_ABANDON_HIBERFILE")); - errorNames.insert(std::make_pair(788, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED")); - errorNames.insert(std::make_pair(789, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR")); - errorNames.insert(std::make_pair(790, "ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR")); - errorNames.insert(std::make_pair(791, "ERROR_BAD_MCFG_TABLE")); - errorNames.insert(std::make_pair(800, "ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE")); - errorNames.insert(std::make_pair(801, "ERROR_CANNOT_GRANT_REQUESTED_OPLOCK")); - errorNames.insert(std::make_pair(802, "ERROR_CANNOT_BREAK_OPLOCK")); - errorNames.insert(std::make_pair(803, "ERROR_OPLOCK_HANDLE_CLOSED")); - errorNames.insert(std::make_pair(804, "ERROR_NO_ACE_CONDITION")); - errorNames.insert(std::make_pair(805, "ERROR_INVALID_ACE_CONDITION")); - errorNames.insert(std::make_pair(994, "ERROR_EA_ACCESS_DENIED")); - errorNames.insert(std::make_pair(995, "ERROR_OPERATION_ABORTED")); - errorNames.insert(std::make_pair(996, "ERROR_IO_INCOMPLETE")); - errorNames.insert(std::make_pair(997, "ERROR_IO_PENDING")); - errorNames.insert(std::make_pair(998, "ERROR_NOACCESS")); - errorNames.insert(std::make_pair(999, "ERROR_SWAPERROR")); - errorNames.insert(std::make_pair(1001, "ERROR_STACK_OVERFLOW")); - errorNames.insert(std::make_pair(1002, "ERROR_INVALID_MESSAGE")); - errorNames.insert(std::make_pair(1003, "ERROR_CAN_NOT_COMPLETE")); - errorNames.insert(std::make_pair(1004, "ERROR_INVALID_FLAGS")); - errorNames.insert(std::make_pair(1005, "ERROR_UNRECOGNIZED_VOLUME")); - errorNames.insert(std::make_pair(1006, "ERROR_FILE_INVALID")); - errorNames.insert(std::make_pair(1007, "ERROR_FULLSCREEN_MODE")); - errorNames.insert(std::make_pair(1008, "ERROR_NO_TOKEN")); - errorNames.insert(std::make_pair(1009, "ERROR_BADDB")); - errorNames.insert(std::make_pair(1010, "ERROR_BADKEY")); - errorNames.insert(std::make_pair(1011, "ERROR_CANTOPEN")); - errorNames.insert(std::make_pair(1012, "ERROR_CANTREAD")); - errorNames.insert(std::make_pair(1013, "ERROR_CANTWRITE")); - errorNames.insert(std::make_pair(1014, "ERROR_REGISTRY_RECOVERED")); - errorNames.insert(std::make_pair(1015, "ERROR_REGISTRY_CORRUPT")); - errorNames.insert(std::make_pair(1016, "ERROR_REGISTRY_IO_FAILED")); - errorNames.insert(std::make_pair(1017, "ERROR_NOT_REGISTRY_FILE")); - errorNames.insert(std::make_pair(1018, "ERROR_KEY_DELETED")); - errorNames.insert(std::make_pair(1019, "ERROR_NO_LOG_SPACE")); - errorNames.insert(std::make_pair(1020, "ERROR_KEY_HAS_CHILDREN")); - errorNames.insert(std::make_pair(1021, "ERROR_CHILD_MUST_BE_VOLATILE")); - errorNames.insert(std::make_pair(1022, "ERROR_NOTIFY_ENUM_DIR")); - errorNames.insert(std::make_pair(1051, "ERROR_DEPENDENT_SERVICES_RUNNING")); - errorNames.insert(std::make_pair(1052, "ERROR_INVALID_SERVICE_CONTROL")); - errorNames.insert(std::make_pair(1053, "ERROR_SERVICE_REQUEST_TIMEOUT")); - errorNames.insert(std::make_pair(1054, "ERROR_SERVICE_NO_THREAD")); - errorNames.insert(std::make_pair(1055, "ERROR_SERVICE_DATABASE_LOCKED")); - errorNames.insert(std::make_pair(1056, "ERROR_SERVICE_ALREADY_RUNNING")); - errorNames.insert(std::make_pair(1057, "ERROR_INVALID_SERVICE_ACCOUNT")); - errorNames.insert(std::make_pair(1058, "ERROR_SERVICE_DISABLED")); - errorNames.insert(std::make_pair(1059, "ERROR_CIRCULAR_DEPENDENCY")); - errorNames.insert(std::make_pair(1060, "ERROR_SERVICE_DOES_NOT_EXIST")); - errorNames.insert(std::make_pair(1061, "ERROR_SERVICE_CANNOT_ACCEPT_CTRL")); - errorNames.insert(std::make_pair(1062, "ERROR_SERVICE_NOT_ACTIVE")); - errorNames.insert(std::make_pair(1063, "ERROR_FAILED_SERVICE_CONTROLLER_CONNECT")); - errorNames.insert(std::make_pair(1064, "ERROR_EXCEPTION_IN_SERVICE")); - errorNames.insert(std::make_pair(1065, "ERROR_DATABASE_DOES_NOT_EXIST")); - errorNames.insert(std::make_pair(1066, "ERROR_SERVICE_SPECIFIC_ERROR")); - errorNames.insert(std::make_pair(1067, "ERROR_PROCESS_ABORTED")); - errorNames.insert(std::make_pair(1068, "ERROR_SERVICE_DEPENDENCY_FAIL")); - errorNames.insert(std::make_pair(1069, "ERROR_SERVICE_LOGON_FAILED")); - errorNames.insert(std::make_pair(1070, "ERROR_SERVICE_START_HANG")); - errorNames.insert(std::make_pair(1071, "ERROR_INVALID_SERVICE_LOCK")); - errorNames.insert(std::make_pair(1072, "ERROR_SERVICE_MARKED_FOR_DELETE")); - errorNames.insert(std::make_pair(1073, "ERROR_SERVICE_EXISTS")); - errorNames.insert(std::make_pair(1074, "ERROR_ALREADY_RUNNING_LKG")); - errorNames.insert(std::make_pair(1075, "ERROR_SERVICE_DEPENDENCY_DELETED")); - errorNames.insert(std::make_pair(1076, "ERROR_BOOT_ALREADY_ACCEPTED")); - errorNames.insert(std::make_pair(1077, "ERROR_SERVICE_NEVER_STARTED")); - errorNames.insert(std::make_pair(1078, "ERROR_DUPLICATE_SERVICE_NAME")); - errorNames.insert(std::make_pair(1079, "ERROR_DIFFERENT_SERVICE_ACCOUNT")); - errorNames.insert(std::make_pair(1080, "ERROR_CANNOT_DETECT_DRIVER_FAILURE")); - errorNames.insert(std::make_pair(1081, "ERROR_CANNOT_DETECT_PROCESS_ABORT")); - errorNames.insert(std::make_pair(1082, "ERROR_NO_RECOVERY_PROGRAM")); - errorNames.insert(std::make_pair(1083, "ERROR_SERVICE_NOT_IN_EXE")); - errorNames.insert(std::make_pair(1084, "ERROR_NOT_SAFEBOOT_SERVICE")); - errorNames.insert(std::make_pair(1100, "ERROR_END_OF_MEDIA")); - errorNames.insert(std::make_pair(1101, "ERROR_FILEMARK_DETECTED")); - errorNames.insert(std::make_pair(1102, "ERROR_BEGINNING_OF_MEDIA")); - errorNames.insert(std::make_pair(1103, "ERROR_SETMARK_DETECTED")); - errorNames.insert(std::make_pair(1104, "ERROR_NO_DATA_DETECTED")); - errorNames.insert(std::make_pair(1105, "ERROR_PARTITION_FAILURE")); - errorNames.insert(std::make_pair(1106, "ERROR_INVALID_BLOCK_LENGTH")); - errorNames.insert(std::make_pair(1107, "ERROR_DEVICE_NOT_PARTITIONED")); - errorNames.insert(std::make_pair(1108, "ERROR_UNABLE_TO_LOCK_MEDIA")); - errorNames.insert(std::make_pair(1109, "ERROR_UNABLE_TO_UNLOAD_MEDIA")); - errorNames.insert(std::make_pair(1110, "ERROR_MEDIA_CHANGED")); - errorNames.insert(std::make_pair(1111, "ERROR_BUS_RESET")); - errorNames.insert(std::make_pair(1112, "ERROR_NO_MEDIA_IN_DRIVE")); - errorNames.insert(std::make_pair(1113, "ERROR_NO_UNICODE_TRANSLATION")); - errorNames.insert(std::make_pair(1114, "ERROR_DLL_INIT_FAILED")); - errorNames.insert(std::make_pair(1115, "ERROR_SHUTDOWN_IN_PROGRESS")); - errorNames.insert(std::make_pair(1116, "ERROR_NO_SHUTDOWN_IN_PROGRESS")); - errorNames.insert(std::make_pair(1117, "ERROR_IO_DEVICE")); - errorNames.insert(std::make_pair(1118, "ERROR_SERIAL_NO_DEVICE")); - errorNames.insert(std::make_pair(1119, "ERROR_IRQ_BUSY")); - errorNames.insert(std::make_pair(1120, "ERROR_MORE_WRITES")); - errorNames.insert(std::make_pair(1121, "ERROR_COUNTER_TIMEOUT")); - errorNames.insert(std::make_pair(1122, "ERROR_FLOPPY_ID_MARK_NOT_FOUND")); - errorNames.insert(std::make_pair(1123, "ERROR_FLOPPY_WRONG_CYLINDER")); - errorNames.insert(std::make_pair(1124, "ERROR_FLOPPY_UNKNOWN_ERROR")); - errorNames.insert(std::make_pair(1125, "ERROR_FLOPPY_BAD_REGISTERS")); - errorNames.insert(std::make_pair(1126, "ERROR_DISK_RECALIBRATE_FAILED")); - errorNames.insert(std::make_pair(1127, "ERROR_DISK_OPERATION_FAILED")); - errorNames.insert(std::make_pair(1128, "ERROR_DISK_RESET_FAILED")); - errorNames.insert(std::make_pair(1129, "ERROR_EOM_OVERFLOW")); - errorNames.insert(std::make_pair(1130, "ERROR_NOT_ENOUGH_SERVER_MEMORY")); - errorNames.insert(std::make_pair(1131, "ERROR_POSSIBLE_DEADLOCK")); - errorNames.insert(std::make_pair(1132, "ERROR_MAPPED_ALIGNMENT")); - errorNames.insert(std::make_pair(1140, "ERROR_SET_POWER_STATE_VETOED")); - errorNames.insert(std::make_pair(1141, "ERROR_SET_POWER_STATE_FAILED")); - errorNames.insert(std::make_pair(1142, "ERROR_TOO_MANY_LINKS")); - errorNames.insert(std::make_pair(1150, "ERROR_OLD_WIN_VERSION")); - errorNames.insert(std::make_pair(1151, "ERROR_APP_WRONG_OS")); - errorNames.insert(std::make_pair(1152, "ERROR_SINGLE_INSTANCE_APP")); - errorNames.insert(std::make_pair(1153, "ERROR_RMODE_APP")); - errorNames.insert(std::make_pair(1154, "ERROR_INVALID_DLL")); - errorNames.insert(std::make_pair(1155, "ERROR_NO_ASSOCIATION")); - errorNames.insert(std::make_pair(1156, "ERROR_DDE_FAIL")); - errorNames.insert(std::make_pair(1157, "ERROR_DLL_NOT_FOUND")); - errorNames.insert(std::make_pair(1158, "ERROR_NO_MORE_USER_HANDLES")); - errorNames.insert(std::make_pair(1159, "ERROR_MESSAGE_SYNC_ONLY")); - errorNames.insert(std::make_pair(1160, "ERROR_SOURCE_ELEMENT_EMPTY")); - errorNames.insert(std::make_pair(1161, "ERROR_DESTINATION_ELEMENT_FULL")); - errorNames.insert(std::make_pair(1162, "ERROR_ILLEGAL_ELEMENT_ADDRESS")); - errorNames.insert(std::make_pair(1163, "ERROR_MAGAZINE_NOT_PRESENT")); - errorNames.insert(std::make_pair(1164, "ERROR_DEVICE_REINITIALIZATION_NEEDED")); - errorNames.insert(std::make_pair(1165, "ERROR_DEVICE_REQUIRES_CLEANING")); - errorNames.insert(std::make_pair(1166, "ERROR_DEVICE_DOOR_OPEN")); - errorNames.insert(std::make_pair(1167, "ERROR_DEVICE_NOT_CONNECTED")); - errorNames.insert(std::make_pair(1168, "ERROR_NOT_FOUND")); - errorNames.insert(std::make_pair(1169, "ERROR_NO_MATCH")); - errorNames.insert(std::make_pair(1170, "ERROR_SET_NOT_FOUND")); - errorNames.insert(std::make_pair(1171, "ERROR_POINT_NOT_FOUND")); - errorNames.insert(std::make_pair(1172, "ERROR_NO_TRACKING_SERVICE")); - errorNames.insert(std::make_pair(1173, "ERROR_NO_VOLUME_ID")); - errorNames.insert(std::make_pair(1175, "ERROR_UNABLE_TO_REMOVE_REPLACED")); - errorNames.insert(std::make_pair(1176, "ERROR_UNABLE_TO_MOVE_REPLACEMENT")); - errorNames.insert(std::make_pair(1177, "ERROR_UNABLE_TO_MOVE_REPLACEMENT_2")); - errorNames.insert(std::make_pair(1178, "ERROR_JOURNAL_DELETE_IN_PROGRESS")); - errorNames.insert(std::make_pair(1179, "ERROR_JOURNAL_NOT_ACTIVE")); - errorNames.insert(std::make_pair(1180, "ERROR_POTENTIAL_FILE_FOUND")); - errorNames.insert(std::make_pair(1181, "ERROR_JOURNAL_ENTRY_DELETED")); - errorNames.insert(std::make_pair(1190, "ERROR_SHUTDOWN_IS_SCHEDULED")); - errorNames.insert(std::make_pair(1191, "ERROR_SHUTDOWN_USERS_LOGGED_ON")); - errorNames.insert(std::make_pair(1200, "ERROR_BAD_DEVICE")); - errorNames.insert(std::make_pair(1201, "ERROR_CONNECTION_UNAVAIL")); - errorNames.insert(std::make_pair(1202, "ERROR_DEVICE_ALREADY_REMEMBERED")); - errorNames.insert(std::make_pair(1203, "ERROR_NO_NET_OR_BAD_PATH")); - errorNames.insert(std::make_pair(1204, "ERROR_BAD_PROVIDER")); - errorNames.insert(std::make_pair(1205, "ERROR_CANNOT_OPEN_PROFILE")); - errorNames.insert(std::make_pair(1206, "ERROR_BAD_PROFILE")); - errorNames.insert(std::make_pair(1207, "ERROR_NOT_CONTAINER")); - errorNames.insert(std::make_pair(1208, "ERROR_EXTENDED_ERROR")); - errorNames.insert(std::make_pair(1209, "ERROR_INVALID_GROUPNAME")); - errorNames.insert(std::make_pair(1210, "ERROR_INVALID_COMPUTERNAME")); - errorNames.insert(std::make_pair(1211, "ERROR_INVALID_EVENTNAME")); - errorNames.insert(std::make_pair(1212, "ERROR_INVALID_DOMAINNAME")); - errorNames.insert(std::make_pair(1213, "ERROR_INVALID_SERVICENAME")); - errorNames.insert(std::make_pair(1214, "ERROR_INVALID_NETNAME")); - errorNames.insert(std::make_pair(1215, "ERROR_INVALID_SHARENAME")); - errorNames.insert(std::make_pair(1216, "ERROR_INVALID_PASSWORDNAME")); - errorNames.insert(std::make_pair(1217, "ERROR_INVALID_MESSAGENAME")); - errorNames.insert(std::make_pair(1218, "ERROR_INVALID_MESSAGEDEST")); - errorNames.insert(std::make_pair(1219, "ERROR_SESSION_CREDENTIAL_CONFLICT")); - errorNames.insert(std::make_pair(1220, "ERROR_REMOTE_SESSION_LIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(1221, "ERROR_DUP_DOMAINNAME")); - errorNames.insert(std::make_pair(1222, "ERROR_NO_NETWORK")); - errorNames.insert(std::make_pair(1223, "ERROR_CANCELLED")); - errorNames.insert(std::make_pair(1224, "ERROR_USER_MAPPED_FILE")); - errorNames.insert(std::make_pair(1225, "ERROR_CONNECTION_REFUSED")); - errorNames.insert(std::make_pair(1226, "ERROR_GRACEFUL_DISCONNECT")); - errorNames.insert(std::make_pair(1227, "ERROR_ADDRESS_ALREADY_ASSOCIATED")); - errorNames.insert(std::make_pair(1228, "ERROR_ADDRESS_NOT_ASSOCIATED")); - errorNames.insert(std::make_pair(1229, "ERROR_CONNECTION_INVALID")); - errorNames.insert(std::make_pair(1230, "ERROR_CONNECTION_ACTIVE")); - errorNames.insert(std::make_pair(1231, "ERROR_NETWORK_UNREACHABLE")); - errorNames.insert(std::make_pair(1232, "ERROR_HOST_UNREACHABLE")); - errorNames.insert(std::make_pair(1233, "ERROR_PROTOCOL_UNREACHABLE")); - errorNames.insert(std::make_pair(1234, "ERROR_PORT_UNREACHABLE")); - errorNames.insert(std::make_pair(1235, "ERROR_REQUEST_ABORTED")); - errorNames.insert(std::make_pair(1236, "ERROR_CONNECTION_ABORTED")); - errorNames.insert(std::make_pair(1237, "ERROR_RETRY")); - errorNames.insert(std::make_pair(1238, "ERROR_CONNECTION_COUNT_LIMIT")); - errorNames.insert(std::make_pair(1239, "ERROR_LOGIN_TIME_RESTRICTION")); - errorNames.insert(std::make_pair(1240, "ERROR_LOGIN_WKSTA_RESTRICTION")); - errorNames.insert(std::make_pair(1241, "ERROR_INCORRECT_ADDRESS")); - errorNames.insert(std::make_pair(1242, "ERROR_ALREADY_REGISTERED")); - errorNames.insert(std::make_pair(1243, "ERROR_SERVICE_NOT_FOUND")); - errorNames.insert(std::make_pair(1244, "ERROR_NOT_AUTHENTICATED")); - errorNames.insert(std::make_pair(1245, "ERROR_NOT_LOGGED_ON")); - errorNames.insert(std::make_pair(1246, "ERROR_CONTINUE")); - errorNames.insert(std::make_pair(1247, "ERROR_ALREADY_INITIALIZED")); - errorNames.insert(std::make_pair(1248, "ERROR_NO_MORE_DEVICES")); - errorNames.insert(std::make_pair(1249, "ERROR_NO_SUCH_SITE")); - errorNames.insert(std::make_pair(1250, "ERROR_DOMAIN_CONTROLLER_EXISTS")); - errorNames.insert(std::make_pair(1251, "ERROR_ONLY_IF_CONNECTED")); - errorNames.insert(std::make_pair(1252, "ERROR_OVERRIDE_NOCHANGES")); - errorNames.insert(std::make_pair(1253, "ERROR_BAD_USER_PROFILE")); - errorNames.insert(std::make_pair(1254, "ERROR_NOT_SUPPORTED_ON_SBS")); - errorNames.insert(std::make_pair(1255, "ERROR_SERVER_SHUTDOWN_IN_PROGRESS")); - errorNames.insert(std::make_pair(1256, "ERROR_HOST_DOWN")); - errorNames.insert(std::make_pair(1257, "ERROR_NON_ACCOUNT_SID")); - errorNames.insert(std::make_pair(1258, "ERROR_NON_DOMAIN_SID")); - errorNames.insert(std::make_pair(1259, "ERROR_APPHELP_BLOCK")); - errorNames.insert(std::make_pair(1260, "ERROR_ACCESS_DISABLED_BY_POLICY")); - errorNames.insert(std::make_pair(1261, "ERROR_REG_NAT_CONSUMPTION")); - errorNames.insert(std::make_pair(1262, "ERROR_CSCSHARE_OFFLINE")); - errorNames.insert(std::make_pair(1263, "ERROR_PKINIT_FAILURE")); - errorNames.insert(std::make_pair(1264, "ERROR_SMARTCARD_SUBSYSTEM_FAILURE")); - errorNames.insert(std::make_pair(1265, "ERROR_DOWNGRADE_DETECTED")); - errorNames.insert(std::make_pair(1271, "ERROR_MACHINE_LOCKED")); - errorNames.insert(std::make_pair(1273, "ERROR_CALLBACK_SUPPLIED_INVALID_DATA")); - errorNames.insert(std::make_pair(1274, "ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED")); - errorNames.insert(std::make_pair(1275, "ERROR_DRIVER_BLOCKED")); - errorNames.insert(std::make_pair(1276, "ERROR_INVALID_IMPORT_OF_NON_DLL")); - errorNames.insert(std::make_pair(1277, "ERROR_ACCESS_DISABLED_WEBBLADE")); - errorNames.insert(std::make_pair(1278, "ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER")); - errorNames.insert(std::make_pair(1279, "ERROR_RECOVERY_FAILURE")); - errorNames.insert(std::make_pair(1280, "ERROR_ALREADY_FIBER")); - errorNames.insert(std::make_pair(1281, "ERROR_ALREADY_THREAD")); - errorNames.insert(std::make_pair(1282, "ERROR_STACK_BUFFER_OVERRUN")); - errorNames.insert(std::make_pair(1283, "ERROR_PARAMETER_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(1284, "ERROR_DEBUGGER_INACTIVE")); - errorNames.insert(std::make_pair(1285, "ERROR_DELAY_LOAD_FAILED")); - errorNames.insert(std::make_pair(1286, "ERROR_VDM_DISALLOWED")); - errorNames.insert(std::make_pair(1287, "ERROR_UNIDENTIFIED_ERROR")); - errorNames.insert(std::make_pair(1288, "ERROR_INVALID_CRUNTIME_PARAMETER")); - errorNames.insert(std::make_pair(1289, "ERROR_BEYOND_VDL")); - errorNames.insert(std::make_pair(1290, "ERROR_INCOMPATIBLE_SERVICE_SID_TYPE")); - errorNames.insert(std::make_pair(1291, "ERROR_DRIVER_PROCESS_TERMINATED")); - errorNames.insert(std::make_pair(1292, "ERROR_IMPLEMENTATION_LIMIT")); - errorNames.insert(std::make_pair(1293, "ERROR_PROCESS_IS_PROTECTED")); - errorNames.insert(std::make_pair(1294, "ERROR_SERVICE_NOTIFY_CLIENT_LAGGING")); - errorNames.insert(std::make_pair(1295, "ERROR_DISK_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(1296, "ERROR_CONTENT_BLOCKED")); - errorNames.insert(std::make_pair(1297, "ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE")); - errorNames.insert(std::make_pair(1298, "ERROR_APP_HANG")); - errorNames.insert(std::make_pair(1299, "ERROR_INVALID_LABEL")); - errorNames.insert(std::make_pair(1300, "ERROR_NOT_ALL_ASSIGNED")); - errorNames.insert(std::make_pair(1301, "ERROR_SOME_NOT_MAPPED")); - errorNames.insert(std::make_pair(1302, "ERROR_NO_QUOTAS_FOR_ACCOUNT")); - errorNames.insert(std::make_pair(1303, "ERROR_LOCAL_USER_SESSION_KEY")); - errorNames.insert(std::make_pair(1304, "ERROR_NULL_LM_PASSWORD")); - errorNames.insert(std::make_pair(1305, "ERROR_UNKNOWN_REVISION")); - errorNames.insert(std::make_pair(1306, "ERROR_REVISION_MISMATCH")); - errorNames.insert(std::make_pair(1307, "ERROR_INVALID_OWNER")); - errorNames.insert(std::make_pair(1308, "ERROR_INVALID_PRIMARY_GROUP")); - errorNames.insert(std::make_pair(1309, "ERROR_NO_IMPERSONATION_TOKEN")); - errorNames.insert(std::make_pair(1310, "ERROR_CANT_DISABLE_MANDATORY")); - errorNames.insert(std::make_pair(1311, "ERROR_NO_LOGON_SERVERS")); - errorNames.insert(std::make_pair(1312, "ERROR_NO_SUCH_LOGON_SESSION")); - errorNames.insert(std::make_pair(1313, "ERROR_NO_SUCH_PRIVILEGE")); - errorNames.insert(std::make_pair(1314, "ERROR_PRIVILEGE_NOT_HELD")); - errorNames.insert(std::make_pair(1315, "ERROR_INVALID_ACCOUNT_NAME")); - errorNames.insert(std::make_pair(1316, "ERROR_USER_EXISTS")); - errorNames.insert(std::make_pair(1317, "ERROR_NO_SUCH_USER")); - errorNames.insert(std::make_pair(1318, "ERROR_GROUP_EXISTS")); - errorNames.insert(std::make_pair(1319, "ERROR_NO_SUCH_GROUP")); - errorNames.insert(std::make_pair(1320, "ERROR_MEMBER_IN_GROUP")); - errorNames.insert(std::make_pair(1321, "ERROR_MEMBER_NOT_IN_GROUP")); - errorNames.insert(std::make_pair(1322, "ERROR_LAST_ADMIN")); - errorNames.insert(std::make_pair(1323, "ERROR_WRONG_PASSWORD")); - errorNames.insert(std::make_pair(1324, "ERROR_ILL_FORMED_PASSWORD")); - errorNames.insert(std::make_pair(1325, "ERROR_PASSWORD_RESTRICTION")); - errorNames.insert(std::make_pair(1326, "ERROR_LOGON_FAILURE")); - errorNames.insert(std::make_pair(1327, "ERROR_ACCOUNT_RESTRICTION")); - errorNames.insert(std::make_pair(1328, "ERROR_INVALID_LOGON_HOURS")); - errorNames.insert(std::make_pair(1329, "ERROR_INVALID_WORKSTATION")); - errorNames.insert(std::make_pair(1330, "ERROR_PASSWORD_EXPIRED")); - errorNames.insert(std::make_pair(1331, "ERROR_ACCOUNT_DISABLED")); - errorNames.insert(std::make_pair(1332, "ERROR_NONE_MAPPED")); - errorNames.insert(std::make_pair(1333, "ERROR_TOO_MANY_LUIDS_REQUESTED")); - errorNames.insert(std::make_pair(1334, "ERROR_LUIDS_EXHAUSTED")); - errorNames.insert(std::make_pair(1335, "ERROR_INVALID_SUB_AUTHORITY")); - errorNames.insert(std::make_pair(1336, "ERROR_INVALID_ACL")); - errorNames.insert(std::make_pair(1337, "ERROR_INVALID_SID")); - errorNames.insert(std::make_pair(1338, "ERROR_INVALID_SECURITY_DESCR")); - errorNames.insert(std::make_pair(1340, "ERROR_BAD_INHERITANCE_ACL")); - errorNames.insert(std::make_pair(1341, "ERROR_SERVER_DISABLED")); - errorNames.insert(std::make_pair(1342, "ERROR_SERVER_NOT_DISABLED")); - errorNames.insert(std::make_pair(1343, "ERROR_INVALID_ID_AUTHORITY")); - errorNames.insert(std::make_pair(1344, "ERROR_ALLOTTED_SPACE_EXCEEDED")); - errorNames.insert(std::make_pair(1345, "ERROR_INVALID_GROUP_ATTRIBUTES")); - errorNames.insert(std::make_pair(1346, "ERROR_BAD_IMPERSONATION_LEVEL")); - errorNames.insert(std::make_pair(1347, "ERROR_CANT_OPEN_ANONYMOUS")); - errorNames.insert(std::make_pair(1348, "ERROR_BAD_VALIDATION_CLASS")); - errorNames.insert(std::make_pair(1349, "ERROR_BAD_TOKEN_TYPE")); - errorNames.insert(std::make_pair(1350, "ERROR_NO_SECURITY_ON_OBJECT")); - errorNames.insert(std::make_pair(1351, "ERROR_CANT_ACCESS_DOMAIN_INFO")); - errorNames.insert(std::make_pair(1352, "ERROR_INVALID_SERVER_STATE")); - errorNames.insert(std::make_pair(1353, "ERROR_INVALID_DOMAIN_STATE")); - errorNames.insert(std::make_pair(1354, "ERROR_INVALID_DOMAIN_ROLE")); - errorNames.insert(std::make_pair(1355, "ERROR_NO_SUCH_DOMAIN")); - errorNames.insert(std::make_pair(1356, "ERROR_DOMAIN_EXISTS")); - errorNames.insert(std::make_pair(1357, "ERROR_DOMAIN_LIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(1358, "ERROR_INTERNAL_DB_CORRUPTION")); - errorNames.insert(std::make_pair(1359, "ERROR_INTERNAL_ERROR")); - errorNames.insert(std::make_pair(1360, "ERROR_GENERIC_NOT_MAPPED")); - errorNames.insert(std::make_pair(1361, "ERROR_BAD_DESCRIPTOR_FORMAT")); - errorNames.insert(std::make_pair(1362, "ERROR_NOT_LOGON_PROCESS")); - errorNames.insert(std::make_pair(1363, "ERROR_LOGON_SESSION_EXISTS")); - errorNames.insert(std::make_pair(1364, "ERROR_NO_SUCH_PACKAGE")); - errorNames.insert(std::make_pair(1365, "ERROR_BAD_LOGON_SESSION_STATE")); - errorNames.insert(std::make_pair(1366, "ERROR_LOGON_SESSION_COLLISION")); - errorNames.insert(std::make_pair(1367, "ERROR_INVALID_LOGON_TYPE")); - errorNames.insert(std::make_pair(1368, "ERROR_CANNOT_IMPERSONATE")); - errorNames.insert(std::make_pair(1369, "ERROR_RXACT_INVALID_STATE")); - errorNames.insert(std::make_pair(1370, "ERROR_RXACT_COMMIT_FAILURE")); - errorNames.insert(std::make_pair(1371, "ERROR_SPECIAL_ACCOUNT")); - errorNames.insert(std::make_pair(1372, "ERROR_SPECIAL_GROUP")); - errorNames.insert(std::make_pair(1373, "ERROR_SPECIAL_USER")); - errorNames.insert(std::make_pair(1374, "ERROR_MEMBERS_PRIMARY_GROUP")); - errorNames.insert(std::make_pair(1375, "ERROR_TOKEN_ALREADY_IN_USE")); - errorNames.insert(std::make_pair(1376, "ERROR_NO_SUCH_ALIAS")); - errorNames.insert(std::make_pair(1377, "ERROR_MEMBER_NOT_IN_ALIAS")); - errorNames.insert(std::make_pair(1378, "ERROR_MEMBER_IN_ALIAS")); - errorNames.insert(std::make_pair(1379, "ERROR_ALIAS_EXISTS")); - errorNames.insert(std::make_pair(1380, "ERROR_LOGON_NOT_GRANTED")); - errorNames.insert(std::make_pair(1381, "ERROR_TOO_MANY_SECRETS")); - errorNames.insert(std::make_pair(1382, "ERROR_SECRET_TOO_LONG")); - errorNames.insert(std::make_pair(1383, "ERROR_INTERNAL_DB_ERROR")); - errorNames.insert(std::make_pair(1384, "ERROR_TOO_MANY_CONTEXT_IDS")); - errorNames.insert(std::make_pair(1385, "ERROR_LOGON_TYPE_NOT_GRANTED")); - errorNames.insert(std::make_pair(1386, "ERROR_NT_CROSS_ENCRYPTION_REQUIRED")); - errorNames.insert(std::make_pair(1387, "ERROR_NO_SUCH_MEMBER")); - errorNames.insert(std::make_pair(1388, "ERROR_INVALID_MEMBER")); - errorNames.insert(std::make_pair(1389, "ERROR_TOO_MANY_SIDS")); - errorNames.insert(std::make_pair(1390, "ERROR_LM_CROSS_ENCRYPTION_REQUIRED")); - errorNames.insert(std::make_pair(1391, "ERROR_NO_INHERITANCE")); - errorNames.insert(std::make_pair(1392, "ERROR_FILE_CORRUPT")); - errorNames.insert(std::make_pair(1393, "ERROR_DISK_CORRUPT")); - errorNames.insert(std::make_pair(1394, "ERROR_NO_USER_SESSION_KEY")); - errorNames.insert(std::make_pair(1395, "ERROR_LICENSE_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(1396, "ERROR_WRONG_TARGET_NAME")); - errorNames.insert(std::make_pair(1397, "ERROR_MUTUAL_AUTH_FAILED")); - errorNames.insert(std::make_pair(1398, "ERROR_TIME_SKEW")); - errorNames.insert(std::make_pair(1399, "ERROR_CURRENT_DOMAIN_NOT_ALLOWED")); - errorNames.insert(std::make_pair(1400, "ERROR_INVALID_WINDOW_HANDLE")); - errorNames.insert(std::make_pair(1401, "ERROR_INVALID_MENU_HANDLE")); - errorNames.insert(std::make_pair(1402, "ERROR_INVALID_CURSOR_HANDLE")); - errorNames.insert(std::make_pair(1403, "ERROR_INVALID_ACCEL_HANDLE")); - errorNames.insert(std::make_pair(1404, "ERROR_INVALID_HOOK_HANDLE")); - errorNames.insert(std::make_pair(1405, "ERROR_INVALID_DWP_HANDLE")); - errorNames.insert(std::make_pair(1406, "ERROR_TLW_WITH_WSCHILD")); - errorNames.insert(std::make_pair(1407, "ERROR_CANNOT_FIND_WND_CLASS")); - errorNames.insert(std::make_pair(1408, "ERROR_WINDOW_OF_OTHER_THREAD")); - errorNames.insert(std::make_pair(1409, "ERROR_HOTKEY_ALREADY_REGISTERED")); - errorNames.insert(std::make_pair(1410, "ERROR_CLASS_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(1411, "ERROR_CLASS_DOES_NOT_EXIST")); - errorNames.insert(std::make_pair(1412, "ERROR_CLASS_HAS_WINDOWS")); - errorNames.insert(std::make_pair(1413, "ERROR_INVALID_INDEX")); - errorNames.insert(std::make_pair(1414, "ERROR_INVALID_ICON_HANDLE")); - errorNames.insert(std::make_pair(1415, "ERROR_PRIVATE_DIALOG_INDEX")); - errorNames.insert(std::make_pair(1416, "ERROR_LISTBOX_ID_NOT_FOUND")); - errorNames.insert(std::make_pair(1417, "ERROR_NO_WILDCARD_CHARACTERS")); - errorNames.insert(std::make_pair(1418, "ERROR_CLIPBOARD_NOT_OPEN")); - errorNames.insert(std::make_pair(1419, "ERROR_HOTKEY_NOT_REGISTERED")); - errorNames.insert(std::make_pair(1420, "ERROR_WINDOW_NOT_DIALOG")); - errorNames.insert(std::make_pair(1421, "ERROR_CONTROL_ID_NOT_FOUND")); - errorNames.insert(std::make_pair(1422, "ERROR_INVALID_COMBOBOX_MESSAGE")); - errorNames.insert(std::make_pair(1423, "ERROR_WINDOW_NOT_COMBOBOX")); - errorNames.insert(std::make_pair(1424, "ERROR_INVALID_EDIT_HEIGHT")); - errorNames.insert(std::make_pair(1425, "ERROR_DC_NOT_FOUND")); - errorNames.insert(std::make_pair(1426, "ERROR_INVALID_HOOK_FILTER")); - errorNames.insert(std::make_pair(1427, "ERROR_INVALID_FILTER_PROC")); - errorNames.insert(std::make_pair(1428, "ERROR_HOOK_NEEDS_HMOD")); - errorNames.insert(std::make_pair(1429, "ERROR_GLOBAL_ONLY_HOOK")); - errorNames.insert(std::make_pair(1430, "ERROR_JOURNAL_HOOK_SET")); - errorNames.insert(std::make_pair(1431, "ERROR_HOOK_NOT_INSTALLED")); - errorNames.insert(std::make_pair(1432, "ERROR_INVALID_LB_MESSAGE")); - errorNames.insert(std::make_pair(1433, "ERROR_SETCOUNT_ON_BAD_LB")); - errorNames.insert(std::make_pair(1434, "ERROR_LB_WITHOUT_TABSTOPS")); - errorNames.insert(std::make_pair(1435, "ERROR_DESTROY_OBJECT_OF_OTHER_THREAD")); - errorNames.insert(std::make_pair(1436, "ERROR_CHILD_WINDOW_MENU")); - errorNames.insert(std::make_pair(1437, "ERROR_NO_SYSTEM_MENU")); - errorNames.insert(std::make_pair(1438, "ERROR_INVALID_MSGBOX_STYLE")); - errorNames.insert(std::make_pair(1439, "ERROR_INVALID_SPI_VALUE")); - errorNames.insert(std::make_pair(1440, "ERROR_SCREEN_ALREADY_LOCKED")); - errorNames.insert(std::make_pair(1441, "ERROR_HWNDS_HAVE_DIFF_PARENT")); - errorNames.insert(std::make_pair(1442, "ERROR_NOT_CHILD_WINDOW")); - errorNames.insert(std::make_pair(1443, "ERROR_INVALID_GW_COMMAND")); - errorNames.insert(std::make_pair(1444, "ERROR_INVALID_THREAD_ID")); - errorNames.insert(std::make_pair(1445, "ERROR_NON_MDICHILD_WINDOW")); - errorNames.insert(std::make_pair(1446, "ERROR_POPUP_ALREADY_ACTIVE")); - errorNames.insert(std::make_pair(1447, "ERROR_NO_SCROLLBARS")); - errorNames.insert(std::make_pair(1448, "ERROR_INVALID_SCROLLBAR_RANGE")); - errorNames.insert(std::make_pair(1449, "ERROR_INVALID_SHOWWIN_COMMAND")); - errorNames.insert(std::make_pair(1450, "ERROR_NO_SYSTEM_RESOURCES")); - errorNames.insert(std::make_pair(1451, "ERROR_NONPAGED_SYSTEM_RESOURCES")); - errorNames.insert(std::make_pair(1452, "ERROR_PAGED_SYSTEM_RESOURCES")); - errorNames.insert(std::make_pair(1453, "ERROR_WORKING_SET_QUOTA")); - errorNames.insert(std::make_pair(1454, "ERROR_PAGEFILE_QUOTA")); - errorNames.insert(std::make_pair(1455, "ERROR_COMMITMENT_LIMIT")); - errorNames.insert(std::make_pair(1456, "ERROR_MENU_ITEM_NOT_FOUND")); - errorNames.insert(std::make_pair(1457, "ERROR_INVALID_KEYBOARD_HANDLE")); - errorNames.insert(std::make_pair(1458, "ERROR_HOOK_TYPE_NOT_ALLOWED")); - errorNames.insert(std::make_pair(1459, "ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION")); - errorNames.insert(std::make_pair(1460, "ERROR_TIMEOUT")); - errorNames.insert(std::make_pair(1461, "ERROR_INVALID_MONITOR_HANDLE")); - errorNames.insert(std::make_pair(1462, "ERROR_INCORRECT_SIZE")); - errorNames.insert(std::make_pair(1463, "ERROR_SYMLINK_CLASS_DISABLED")); - errorNames.insert(std::make_pair(1464, "ERROR_SYMLINK_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(1465, "ERROR_XML_PARSE_ERROR")); - errorNames.insert(std::make_pair(1466, "ERROR_XMLDSIG_ERROR")); - errorNames.insert(std::make_pair(1467, "ERROR_RESTART_APPLICATION")); - errorNames.insert(std::make_pair(1468, "ERROR_WRONG_COMPARTMENT")); - errorNames.insert(std::make_pair(1469, "ERROR_AUTHIP_FAILURE")); - errorNames.insert(std::make_pair(1470, "ERROR_NO_NVRAM_RESOURCES")); - errorNames.insert(std::make_pair(1500, "ERROR_EVENTLOG_FILE_CORRUPT")); - errorNames.insert(std::make_pair(1501, "ERROR_EVENTLOG_CANT_START")); - errorNames.insert(std::make_pair(1502, "ERROR_LOG_FILE_FULL")); - errorNames.insert(std::make_pair(1503, "ERROR_EVENTLOG_FILE_CHANGED")); - errorNames.insert(std::make_pair(1550, "ERROR_INVALID_TASK_NAME")); - errorNames.insert(std::make_pair(1551, "ERROR_INVALID_TASK_INDEX")); - errorNames.insert(std::make_pair(1552, "ERROR_THREAD_ALREADY_IN_TASK")); - errorNames.insert(std::make_pair(1601, "ERROR_INSTALL_SERVICE_FAILURE")); - errorNames.insert(std::make_pair(1602, "ERROR_INSTALL_USEREXIT")); - errorNames.insert(std::make_pair(1603, "ERROR_INSTALL_FAILURE")); - errorNames.insert(std::make_pair(1604, "ERROR_INSTALL_SUSPEND")); - errorNames.insert(std::make_pair(1605, "ERROR_UNKNOWN_PRODUCT")); - errorNames.insert(std::make_pair(1606, "ERROR_UNKNOWN_FEATURE")); - errorNames.insert(std::make_pair(1607, "ERROR_UNKNOWN_COMPONENT")); - errorNames.insert(std::make_pair(1608, "ERROR_UNKNOWN_PROPERTY")); - errorNames.insert(std::make_pair(1609, "ERROR_INVALID_HANDLE_STATE")); - errorNames.insert(std::make_pair(1610, "ERROR_BAD_CONFIGURATION")); - errorNames.insert(std::make_pair(1611, "ERROR_INDEX_ABSENT")); - errorNames.insert(std::make_pair(1612, "ERROR_INSTALL_SOURCE_ABSENT")); - errorNames.insert(std::make_pair(1613, "ERROR_INSTALL_PACKAGE_VERSION")); - errorNames.insert(std::make_pair(1614, "ERROR_PRODUCT_UNINSTALLED")); - errorNames.insert(std::make_pair(1615, "ERROR_BAD_QUERY_SYNTAX")); - errorNames.insert(std::make_pair(1616, "ERROR_INVALID_FIELD")); - errorNames.insert(std::make_pair(1617, "ERROR_DEVICE_REMOVED")); - errorNames.insert(std::make_pair(1618, "ERROR_INSTALL_ALREADY_RUNNING")); - errorNames.insert(std::make_pair(1619, "ERROR_INSTALL_PACKAGE_OPEN_FAILED")); - errorNames.insert(std::make_pair(1620, "ERROR_INSTALL_PACKAGE_INVALID")); - errorNames.insert(std::make_pair(1621, "ERROR_INSTALL_UI_FAILURE")); - errorNames.insert(std::make_pair(1622, "ERROR_INSTALL_LOG_FAILURE")); - errorNames.insert(std::make_pair(1623, "ERROR_INSTALL_LANGUAGE_UNSUPPORTED")); - errorNames.insert(std::make_pair(1624, "ERROR_INSTALL_TRANSFORM_FAILURE")); - errorNames.insert(std::make_pair(1625, "ERROR_INSTALL_PACKAGE_REJECTED")); - errorNames.insert(std::make_pair(1626, "ERROR_FUNCTION_NOT_CALLED")); - errorNames.insert(std::make_pair(1627, "ERROR_FUNCTION_FAILED")); - errorNames.insert(std::make_pair(1628, "ERROR_INVALID_TABLE")); - errorNames.insert(std::make_pair(1629, "ERROR_DATATYPE_MISMATCH")); - errorNames.insert(std::make_pair(1630, "ERROR_UNSUPPORTED_TYPE")); - errorNames.insert(std::make_pair(1631, "ERROR_CREATE_FAILED")); - errorNames.insert(std::make_pair(1632, "ERROR_INSTALL_TEMP_UNWRITABLE")); - errorNames.insert(std::make_pair(1633, "ERROR_INSTALL_PLATFORM_UNSUPPORTED")); - errorNames.insert(std::make_pair(1634, "ERROR_INSTALL_NOTUSED")); - errorNames.insert(std::make_pair(1635, "ERROR_PATCH_PACKAGE_OPEN_FAILED")); - errorNames.insert(std::make_pair(1636, "ERROR_PATCH_PACKAGE_INVALID")); - errorNames.insert(std::make_pair(1637, "ERROR_PATCH_PACKAGE_UNSUPPORTED")); - errorNames.insert(std::make_pair(1638, "ERROR_PRODUCT_VERSION")); - errorNames.insert(std::make_pair(1639, "ERROR_INVALID_COMMAND_LINE")); - errorNames.insert(std::make_pair(1640, "ERROR_INSTALL_REMOTE_DISALLOWED")); - errorNames.insert(std::make_pair(1641, "ERROR_SUCCESS_REBOOT_INITIATED")); - errorNames.insert(std::make_pair(1642, "ERROR_PATCH_TARGET_NOT_FOUND")); - errorNames.insert(std::make_pair(1643, "ERROR_PATCH_PACKAGE_REJECTED")); - errorNames.insert(std::make_pair(1644, "ERROR_INSTALL_TRANSFORM_REJECTED")); - errorNames.insert(std::make_pair(1645, "ERROR_INSTALL_REMOTE_PROHIBITED")); - errorNames.insert(std::make_pair(1646, "ERROR_PATCH_REMOVAL_UNSUPPORTED")); - errorNames.insert(std::make_pair(1647, "ERROR_UNKNOWN_PATCH")); - errorNames.insert(std::make_pair(1648, "ERROR_PATCH_NO_SEQUENCE")); - errorNames.insert(std::make_pair(1649, "ERROR_PATCH_REMOVAL_DISALLOWED")); - errorNames.insert(std::make_pair(1650, "ERROR_INVALID_PATCH_XML")); - errorNames.insert(std::make_pair(1651, "ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT")); - errorNames.insert(std::make_pair(1652, "ERROR_INSTALL_SERVICE_SAFEBOOT")); - errorNames.insert(std::make_pair(1653, "ERROR_FAIL_FAST_EXCEPTION")); - errorNames.insert(std::make_pair(1784, "ERROR_INVALID_USER_BUFFER")); - errorNames.insert(std::make_pair(1785, "ERROR_UNRECOGNIZED_MEDIA")); - errorNames.insert(std::make_pair(1786, "ERROR_NO_TRUST_LSA_SECRET")); - errorNames.insert(std::make_pair(1787, "ERROR_NO_TRUST_SAM_ACCOUNT")); - errorNames.insert(std::make_pair(1788, "ERROR_TRUSTED_DOMAIN_FAILURE")); - errorNames.insert(std::make_pair(1789, "ERROR_TRUSTED_RELATIONSHIP_FAILURE")); - errorNames.insert(std::make_pair(1790, "ERROR_TRUST_FAILURE")); - errorNames.insert(std::make_pair(1792, "ERROR_NETLOGON_NOT_STARTED")); - errorNames.insert(std::make_pair(1793, "ERROR_ACCOUNT_EXPIRED")); - errorNames.insert(std::make_pair(1794, "ERROR_REDIRECTOR_HAS_OPEN_HANDLES")); - errorNames.insert(std::make_pair(1795, "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED")); - errorNames.insert(std::make_pair(1796, "ERROR_UNKNOWN_PORT")); - errorNames.insert(std::make_pair(1797, "ERROR_UNKNOWN_PRINTER_DRIVER")); - errorNames.insert(std::make_pair(1798, "ERROR_UNKNOWN_PRINTPROCESSOR")); - errorNames.insert(std::make_pair(1799, "ERROR_INVALID_SEPARATOR_FILE")); - errorNames.insert(std::make_pair(1800, "ERROR_INVALID_PRIORITY")); - errorNames.insert(std::make_pair(1801, "ERROR_INVALID_PRINTER_NAME")); - errorNames.insert(std::make_pair(1802, "ERROR_PRINTER_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(1803, "ERROR_INVALID_PRINTER_COMMAND")); - errorNames.insert(std::make_pair(1804, "ERROR_INVALID_DATATYPE")); - errorNames.insert(std::make_pair(1805, "ERROR_INVALID_ENVIRONMENT")); - errorNames.insert(std::make_pair(1807, "ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT")); - errorNames.insert(std::make_pair(1808, "ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT")); - errorNames.insert(std::make_pair(1809, "ERROR_NOLOGON_SERVER_TRUST_ACCOUNT")); - errorNames.insert(std::make_pair(1810, "ERROR_DOMAIN_TRUST_INCONSISTENT")); - errorNames.insert(std::make_pair(1811, "ERROR_SERVER_HAS_OPEN_HANDLES")); - errorNames.insert(std::make_pair(1812, "ERROR_RESOURCE_DATA_NOT_FOUND")); - errorNames.insert(std::make_pair(1813, "ERROR_RESOURCE_TYPE_NOT_FOUND")); - errorNames.insert(std::make_pair(1814, "ERROR_RESOURCE_NAME_NOT_FOUND")); - errorNames.insert(std::make_pair(1815, "ERROR_RESOURCE_LANG_NOT_FOUND")); - errorNames.insert(std::make_pair(1816, "ERROR_NOT_ENOUGH_QUOTA")); - errorNames.insert(std::make_pair(1901, "ERROR_INVALID_TIME")); - errorNames.insert(std::make_pair(1902, "ERROR_INVALID_FORM_NAME")); - errorNames.insert(std::make_pair(1903, "ERROR_INVALID_FORM_SIZE")); - errorNames.insert(std::make_pair(1904, "ERROR_ALREADY_WAITING")); - errorNames.insert(std::make_pair(1905, "ERROR_PRINTER_DELETED")); - errorNames.insert(std::make_pair(1906, "ERROR_INVALID_PRINTER_STATE")); - errorNames.insert(std::make_pair(1907, "ERROR_PASSWORD_MUST_CHANGE")); - errorNames.insert(std::make_pair(1908, "ERROR_DOMAIN_CONTROLLER_NOT_FOUND")); - errorNames.insert(std::make_pair(1909, "ERROR_ACCOUNT_LOCKED_OUT")); - errorNames.insert(std::make_pair(1919, "ERROR_NO_SITENAME")); - errorNames.insert(std::make_pair(1920, "ERROR_CANT_ACCESS_FILE")); - errorNames.insert(std::make_pair(1921, "ERROR_CANT_RESOLVE_FILENAME")); - errorNames.insert(std::make_pair(1930, "ERROR_KM_DRIVER_BLOCKED")); - errorNames.insert(std::make_pair(1931, "ERROR_CONTEXT_EXPIRED")); - errorNames.insert(std::make_pair(1932, "ERROR_PER_USER_TRUST_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(1933, "ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(1934, "ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(1935, "ERROR_AUTHENTICATION_FIREWALL_FAILED")); - errorNames.insert(std::make_pair(1936, "ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED")); - errorNames.insert(std::make_pair(1937, "ERROR_NTLM_BLOCKED")); - errorNames.insert(std::make_pair(2000, "ERROR_INVALID_PIXEL_FORMAT")); - errorNames.insert(std::make_pair(2001, "ERROR_BAD_DRIVER")); - errorNames.insert(std::make_pair(2002, "ERROR_INVALID_WINDOW_STYLE")); - errorNames.insert(std::make_pair(2003, "ERROR_METAFILE_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(2004, "ERROR_TRANSFORM_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(2005, "ERROR_CLIPPING_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(2010, "ERROR_INVALID_CMM")); - errorNames.insert(std::make_pair(2011, "ERROR_INVALID_PROFILE")); - errorNames.insert(std::make_pair(2012, "ERROR_TAG_NOT_FOUND")); - errorNames.insert(std::make_pair(2013, "ERROR_TAG_NOT_PRESENT")); - errorNames.insert(std::make_pair(2014, "ERROR_DUPLICATE_TAG")); - errorNames.insert(std::make_pair(2015, "ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE")); - errorNames.insert(std::make_pair(2016, "ERROR_PROFILE_NOT_FOUND")); - errorNames.insert(std::make_pair(2017, "ERROR_INVALID_COLORSPACE")); - errorNames.insert(std::make_pair(2018, "ERROR_ICM_NOT_ENABLED")); - errorNames.insert(std::make_pair(2019, "ERROR_DELETING_ICM_XFORM")); - errorNames.insert(std::make_pair(2020, "ERROR_INVALID_TRANSFORM")); - errorNames.insert(std::make_pair(2021, "ERROR_COLORSPACE_MISMATCH")); - errorNames.insert(std::make_pair(2022, "ERROR_INVALID_COLORINDEX")); - errorNames.insert(std::make_pair(2023, "ERROR_PROFILE_DOES_NOT_MATCH_DEVICE")); - errorNames.insert(std::make_pair(2108, "ERROR_CONNECTED_OTHER_PASSWORD")); - errorNames.insert(std::make_pair(2109, "ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT")); - errorNames.insert(std::make_pair(2202, "ERROR_BAD_USERNAME")); - errorNames.insert(std::make_pair(2250, "ERROR_NOT_CONNECTED")); - errorNames.insert(std::make_pair(2401, "ERROR_OPEN_FILES")); - errorNames.insert(std::make_pair(2402, "ERROR_ACTIVE_CONNECTIONS")); - errorNames.insert(std::make_pair(2404, "ERROR_DEVICE_IN_USE")); - errorNames.insert(std::make_pair(3000, "ERROR_UNKNOWN_PRINT_MONITOR")); - errorNames.insert(std::make_pair(3001, "ERROR_PRINTER_DRIVER_IN_USE")); - errorNames.insert(std::make_pair(3002, "ERROR_SPOOL_FILE_NOT_FOUND")); - errorNames.insert(std::make_pair(3003, "ERROR_SPL_NO_STARTDOC")); - errorNames.insert(std::make_pair(3004, "ERROR_SPL_NO_ADDJOB")); - errorNames.insert(std::make_pair(3005, "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED")); - errorNames.insert(std::make_pair(3006, "ERROR_PRINT_MONITOR_ALREADY_INSTALLED")); - errorNames.insert(std::make_pair(3007, "ERROR_INVALID_PRINT_MONITOR")); - errorNames.insert(std::make_pair(3008, "ERROR_PRINT_MONITOR_IN_USE")); - errorNames.insert(std::make_pair(3009, "ERROR_PRINTER_HAS_JOBS_QUEUED")); - errorNames.insert(std::make_pair(3010, "ERROR_SUCCESS_REBOOT_REQUIRED")); - errorNames.insert(std::make_pair(3011, "ERROR_SUCCESS_RESTART_REQUIRED")); - errorNames.insert(std::make_pair(3012, "ERROR_PRINTER_NOT_FOUND")); - errorNames.insert(std::make_pair(3013, "ERROR_PRINTER_DRIVER_WARNED")); - errorNames.insert(std::make_pair(3014, "ERROR_PRINTER_DRIVER_BLOCKED")); - errorNames.insert(std::make_pair(3015, "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE")); - errorNames.insert(std::make_pair(3016, "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND")); - errorNames.insert(std::make_pair(3017, "ERROR_FAIL_REBOOT_REQUIRED")); - errorNames.insert(std::make_pair(3018, "ERROR_FAIL_REBOOT_INITIATED")); - errorNames.insert(std::make_pair(3019, "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED")); - errorNames.insert(std::make_pair(3020, "ERROR_PRINT_JOB_RESTART_REQUIRED")); - errorNames.insert(std::make_pair(3950, "ERROR_IO_REISSUE_AS_CACHED")); - errorNames.insert(std::make_pair(4000, "ERROR_WINS_INTERNAL")); - errorNames.insert(std::make_pair(4001, "ERROR_CAN_NOT_DEL_LOCAL_WINS")); - errorNames.insert(std::make_pair(4002, "ERROR_STATIC_INIT")); - errorNames.insert(std::make_pair(4003, "ERROR_INC_BACKUP")); - errorNames.insert(std::make_pair(4004, "ERROR_FULL_BACKUP")); - errorNames.insert(std::make_pair(4005, "ERROR_REC_NON_EXISTENT")); - errorNames.insert(std::make_pair(4006, "ERROR_RPL_NOT_ALLOWED")); - errorNames.insert(std::make_pair(4100, "ERROR_DHCP_ADDRESS_CONFLICT")); - errorNames.insert(std::make_pair(4200, "ERROR_WMI_GUID_NOT_FOUND")); - errorNames.insert(std::make_pair(4201, "ERROR_WMI_INSTANCE_NOT_FOUND")); - errorNames.insert(std::make_pair(4202, "ERROR_WMI_ITEMID_NOT_FOUND")); - errorNames.insert(std::make_pair(4203, "ERROR_WMI_TRY_AGAIN")); - errorNames.insert(std::make_pair(4204, "ERROR_WMI_DP_NOT_FOUND")); - errorNames.insert(std::make_pair(4205, "ERROR_WMI_UNRESOLVED_INSTANCE_REF")); - errorNames.insert(std::make_pair(4206, "ERROR_WMI_ALREADY_ENABLED")); - errorNames.insert(std::make_pair(4207, "ERROR_WMI_GUID_DISCONNECTED")); - errorNames.insert(std::make_pair(4208, "ERROR_WMI_SERVER_UNAVAILABLE")); - errorNames.insert(std::make_pair(4209, "ERROR_WMI_DP_FAILED")); - errorNames.insert(std::make_pair(4210, "ERROR_WMI_INVALID_MOF")); - errorNames.insert(std::make_pair(4211, "ERROR_WMI_INVALID_REGINFO")); - errorNames.insert(std::make_pair(4212, "ERROR_WMI_ALREADY_DISABLED")); - errorNames.insert(std::make_pair(4213, "ERROR_WMI_READ_ONLY")); - errorNames.insert(std::make_pair(4214, "ERROR_WMI_SET_FAILURE")); - errorNames.insert(std::make_pair(4300, "ERROR_INVALID_MEDIA")); - errorNames.insert(std::make_pair(4301, "ERROR_INVALID_LIBRARY")); - errorNames.insert(std::make_pair(4302, "ERROR_INVALID_MEDIA_POOL")); - errorNames.insert(std::make_pair(4303, "ERROR_DRIVE_MEDIA_MISMATCH")); - errorNames.insert(std::make_pair(4304, "ERROR_MEDIA_OFFLINE")); - errorNames.insert(std::make_pair(4305, "ERROR_LIBRARY_OFFLINE")); - errorNames.insert(std::make_pair(4306, "ERROR_EMPTY")); - errorNames.insert(std::make_pair(4307, "ERROR_NOT_EMPTY")); - errorNames.insert(std::make_pair(4308, "ERROR_MEDIA_UNAVAILABLE")); - errorNames.insert(std::make_pair(4309, "ERROR_RESOURCE_DISABLED")); - errorNames.insert(std::make_pair(4310, "ERROR_INVALID_CLEANER")); - errorNames.insert(std::make_pair(4311, "ERROR_UNABLE_TO_CLEAN")); - errorNames.insert(std::make_pair(4312, "ERROR_OBJECT_NOT_FOUND")); - errorNames.insert(std::make_pair(4313, "ERROR_DATABASE_FAILURE")); - errorNames.insert(std::make_pair(4314, "ERROR_DATABASE_FULL")); - errorNames.insert(std::make_pair(4315, "ERROR_MEDIA_INCOMPATIBLE")); - errorNames.insert(std::make_pair(4316, "ERROR_RESOURCE_NOT_PRESENT")); - errorNames.insert(std::make_pair(4317, "ERROR_INVALID_OPERATION")); - errorNames.insert(std::make_pair(4318, "ERROR_MEDIA_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(4319, "ERROR_DEVICE_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(4320, "ERROR_REQUEST_REFUSED")); - errorNames.insert(std::make_pair(4321, "ERROR_INVALID_DRIVE_OBJECT")); - errorNames.insert(std::make_pair(4322, "ERROR_LIBRARY_FULL")); - errorNames.insert(std::make_pair(4323, "ERROR_MEDIUM_NOT_ACCESSIBLE")); - errorNames.insert(std::make_pair(4324, "ERROR_UNABLE_TO_LOAD_MEDIUM")); - errorNames.insert(std::make_pair(4325, "ERROR_UNABLE_TO_INVENTORY_DRIVE")); - errorNames.insert(std::make_pair(4326, "ERROR_UNABLE_TO_INVENTORY_SLOT")); - errorNames.insert(std::make_pair(4327, "ERROR_UNABLE_TO_INVENTORY_TRANSPORT")); - errorNames.insert(std::make_pair(4328, "ERROR_TRANSPORT_FULL")); - errorNames.insert(std::make_pair(4329, "ERROR_CONTROLLING_IEPORT")); - errorNames.insert(std::make_pair(4330, "ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA")); - errorNames.insert(std::make_pair(4331, "ERROR_CLEANER_SLOT_SET")); - errorNames.insert(std::make_pair(4332, "ERROR_CLEANER_SLOT_NOT_SET")); - errorNames.insert(std::make_pair(4333, "ERROR_CLEANER_CARTRIDGE_SPENT")); - errorNames.insert(std::make_pair(4334, "ERROR_UNEXPECTED_OMID")); - errorNames.insert(std::make_pair(4335, "ERROR_CANT_DELETE_LAST_ITEM")); - errorNames.insert(std::make_pair(4336, "ERROR_MESSAGE_EXCEEDS_MAX_SIZE")); - errorNames.insert(std::make_pair(4337, "ERROR_VOLUME_CONTAINS_SYS_FILES")); - errorNames.insert(std::make_pair(4338, "ERROR_INDIGENOUS_TYPE")); - errorNames.insert(std::make_pair(4339, "ERROR_NO_SUPPORTING_DRIVES")); - errorNames.insert(std::make_pair(4340, "ERROR_CLEANER_CARTRIDGE_INSTALLED")); - errorNames.insert(std::make_pair(4341, "ERROR_IEPORT_FULL")); - errorNames.insert(std::make_pair(4350, "ERROR_FILE_OFFLINE")); - errorNames.insert(std::make_pair(4351, "ERROR_REMOTE_STORAGE_NOT_ACTIVE")); - errorNames.insert(std::make_pair(4352, "ERROR_REMOTE_STORAGE_MEDIA_ERROR")); - errorNames.insert(std::make_pair(4390, "ERROR_NOT_A_REPARSE_POINT")); - errorNames.insert(std::make_pair(4391, "ERROR_REPARSE_ATTRIBUTE_CONFLICT")); - errorNames.insert(std::make_pair(4392, "ERROR_INVALID_REPARSE_DATA")); - errorNames.insert(std::make_pair(4393, "ERROR_REPARSE_TAG_INVALID")); - errorNames.insert(std::make_pair(4394, "ERROR_REPARSE_TAG_MISMATCH")); - errorNames.insert(std::make_pair(4500, "ERROR_VOLUME_NOT_SIS_ENABLED")); - errorNames.insert(std::make_pair(5001, "ERROR_DEPENDENT_RESOURCE_EXISTS")); - errorNames.insert(std::make_pair(5002, "ERROR_DEPENDENCY_NOT_FOUND")); - errorNames.insert(std::make_pair(5003, "ERROR_DEPENDENCY_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(5004, "ERROR_RESOURCE_NOT_ONLINE")); - errorNames.insert(std::make_pair(5005, "ERROR_HOST_NODE_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(5006, "ERROR_RESOURCE_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(5007, "ERROR_RESOURCE_NOT_FOUND")); - errorNames.insert(std::make_pair(5008, "ERROR_SHUTDOWN_CLUSTER")); - errorNames.insert(std::make_pair(5009, "ERROR_CANT_EVICT_ACTIVE_NODE")); - errorNames.insert(std::make_pair(5010, "ERROR_OBJECT_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(5011, "ERROR_OBJECT_IN_LIST")); - errorNames.insert(std::make_pair(5012, "ERROR_GROUP_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(5013, "ERROR_GROUP_NOT_FOUND")); - errorNames.insert(std::make_pair(5014, "ERROR_GROUP_NOT_ONLINE")); - errorNames.insert(std::make_pair(5015, "ERROR_HOST_NODE_NOT_RESOURCE_OWNER")); - errorNames.insert(std::make_pair(5016, "ERROR_HOST_NODE_NOT_GROUP_OWNER")); - errorNames.insert(std::make_pair(5017, "ERROR_RESMON_CREATE_FAILED")); - errorNames.insert(std::make_pair(5018, "ERROR_RESMON_ONLINE_FAILED")); - errorNames.insert(std::make_pair(5019, "ERROR_RESOURCE_ONLINE")); - errorNames.insert(std::make_pair(5020, "ERROR_QUORUM_RESOURCE")); - errorNames.insert(std::make_pair(5021, "ERROR_NOT_QUORUM_CAPABLE")); - errorNames.insert(std::make_pair(5022, "ERROR_CLUSTER_SHUTTING_DOWN")); - errorNames.insert(std::make_pair(5023, "ERROR_INVALID_STATE")); - errorNames.insert(std::make_pair(5024, "ERROR_RESOURCE_PROPERTIES_STORED")); - errorNames.insert(std::make_pair(5025, "ERROR_NOT_QUORUM_CLASS")); - errorNames.insert(std::make_pair(5026, "ERROR_CORE_RESOURCE")); - errorNames.insert(std::make_pair(5027, "ERROR_QUORUM_RESOURCE_ONLINE_FAILED")); - errorNames.insert(std::make_pair(5028, "ERROR_QUORUMLOG_OPEN_FAILED")); - errorNames.insert(std::make_pair(5029, "ERROR_CLUSTERLOG_CORRUPT")); - errorNames.insert(std::make_pair(5030, "ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE")); - errorNames.insert(std::make_pair(5031, "ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE")); - errorNames.insert(std::make_pair(5032, "ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND")); - errorNames.insert(std::make_pair(5033, "ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE")); - errorNames.insert(std::make_pair(5034, "ERROR_QUORUM_OWNER_ALIVE")); - errorNames.insert(std::make_pair(5035, "ERROR_NETWORK_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(5036, "ERROR_NODE_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(5037, "ERROR_ALL_NODES_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(5038, "ERROR_RESOURCE_FAILED")); - errorNames.insert(std::make_pair(5039, "ERROR_CLUSTER_INVALID_NODE")); - errorNames.insert(std::make_pair(5040, "ERROR_CLUSTER_NODE_EXISTS")); - errorNames.insert(std::make_pair(5041, "ERROR_CLUSTER_JOIN_IN_PROGRESS")); - errorNames.insert(std::make_pair(5042, "ERROR_CLUSTER_NODE_NOT_FOUND")); - errorNames.insert(std::make_pair(5043, "ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND")); - errorNames.insert(std::make_pair(5044, "ERROR_CLUSTER_NETWORK_EXISTS")); - errorNames.insert(std::make_pair(5045, "ERROR_CLUSTER_NETWORK_NOT_FOUND")); - errorNames.insert(std::make_pair(5046, "ERROR_CLUSTER_NETINTERFACE_EXISTS")); - errorNames.insert(std::make_pair(5047, "ERROR_CLUSTER_NETINTERFACE_NOT_FOUND")); - errorNames.insert(std::make_pair(5048, "ERROR_CLUSTER_INVALID_REQUEST")); - errorNames.insert(std::make_pair(5049, "ERROR_CLUSTER_INVALID_NETWORK_PROVIDER")); - errorNames.insert(std::make_pair(5050, "ERROR_CLUSTER_NODE_DOWN")); - errorNames.insert(std::make_pair(5051, "ERROR_CLUSTER_NODE_UNREACHABLE")); - errorNames.insert(std::make_pair(5052, "ERROR_CLUSTER_NODE_NOT_MEMBER")); - errorNames.insert(std::make_pair(5053, "ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS")); - errorNames.insert(std::make_pair(5054, "ERROR_CLUSTER_INVALID_NETWORK")); - errorNames.insert(std::make_pair(5056, "ERROR_CLUSTER_NODE_UP")); - errorNames.insert(std::make_pair(5057, "ERROR_CLUSTER_IPADDR_IN_USE")); - errorNames.insert(std::make_pair(5058, "ERROR_CLUSTER_NODE_NOT_PAUSED")); - errorNames.insert(std::make_pair(5059, "ERROR_CLUSTER_NO_SECURITY_CONTEXT")); - errorNames.insert(std::make_pair(5060, "ERROR_CLUSTER_NETWORK_NOT_INTERNAL")); - errorNames.insert(std::make_pair(5061, "ERROR_CLUSTER_NODE_ALREADY_UP")); - errorNames.insert(std::make_pair(5062, "ERROR_CLUSTER_NODE_ALREADY_DOWN")); - errorNames.insert(std::make_pair(5063, "ERROR_CLUSTER_NETWORK_ALREADY_ONLINE")); - errorNames.insert(std::make_pair(5064, "ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE")); - errorNames.insert(std::make_pair(5065, "ERROR_CLUSTER_NODE_ALREADY_MEMBER")); - errorNames.insert(std::make_pair(5066, "ERROR_CLUSTER_LAST_INTERNAL_NETWORK")); - errorNames.insert(std::make_pair(5067, "ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS")); - errorNames.insert(std::make_pair(5068, "ERROR_INVALID_OPERATION_ON_QUORUM")); - errorNames.insert(std::make_pair(5069, "ERROR_DEPENDENCY_NOT_ALLOWED")); - errorNames.insert(std::make_pair(5070, "ERROR_CLUSTER_NODE_PAUSED")); - errorNames.insert(std::make_pair(5071, "ERROR_NODE_CANT_HOST_RESOURCE")); - errorNames.insert(std::make_pair(5072, "ERROR_CLUSTER_NODE_NOT_READY")); - errorNames.insert(std::make_pair(5073, "ERROR_CLUSTER_NODE_SHUTTING_DOWN")); - errorNames.insert(std::make_pair(5074, "ERROR_CLUSTER_JOIN_ABORTED")); - errorNames.insert(std::make_pair(5075, "ERROR_CLUSTER_INCOMPATIBLE_VERSIONS")); - errorNames.insert(std::make_pair(5076, "ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED")); - errorNames.insert(std::make_pair(5077, "ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED")); - errorNames.insert(std::make_pair(5078, "ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND")); - errorNames.insert(std::make_pair(5079, "ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(5080, "ERROR_CLUSTER_RESNAME_NOT_FOUND")); - errorNames.insert(std::make_pair(5081, "ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED")); - errorNames.insert(std::make_pair(5082, "ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST")); - errorNames.insert(std::make_pair(5083, "ERROR_CLUSTER_DATABASE_SEQMISMATCH")); - errorNames.insert(std::make_pair(5084, "ERROR_RESMON_INVALID_STATE")); - errorNames.insert(std::make_pair(5085, "ERROR_CLUSTER_GUM_NOT_LOCKER")); - errorNames.insert(std::make_pair(5086, "ERROR_QUORUM_DISK_NOT_FOUND")); - errorNames.insert(std::make_pair(5087, "ERROR_DATABASE_BACKUP_CORRUPT")); - errorNames.insert(std::make_pair(5088, "ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT")); - errorNames.insert(std::make_pair(5089, "ERROR_RESOURCE_PROPERTY_UNCHANGEABLE")); - errorNames.insert(std::make_pair(5890, "ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE")); - errorNames.insert(std::make_pair(5891, "ERROR_CLUSTER_QUORUMLOG_NOT_FOUND")); - errorNames.insert(std::make_pair(5892, "ERROR_CLUSTER_MEMBERSHIP_HALT")); - errorNames.insert(std::make_pair(5893, "ERROR_CLUSTER_INSTANCE_ID_MISMATCH")); - errorNames.insert(std::make_pair(5894, "ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP")); - errorNames.insert(std::make_pair(5895, "ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH")); - errorNames.insert(std::make_pair(5896, "ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP")); - errorNames.insert(std::make_pair(5897, "ERROR_CLUSTER_PARAMETER_MISMATCH")); - errorNames.insert(std::make_pair(5898, "ERROR_NODE_CANNOT_BE_CLUSTERED")); - errorNames.insert(std::make_pair(5899, "ERROR_CLUSTER_WRONG_OS_VERSION")); - errorNames.insert(std::make_pair(5900, "ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME")); - errorNames.insert(std::make_pair(5901, "ERROR_CLUSCFG_ALREADY_COMMITTED")); - errorNames.insert(std::make_pair(5902, "ERROR_CLUSCFG_ROLLBACK_FAILED")); - errorNames.insert(std::make_pair(5903, "ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT")); - errorNames.insert(std::make_pair(5904, "ERROR_CLUSTER_OLD_VERSION")); - errorNames.insert(std::make_pair(5905, "ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME")); - errorNames.insert(std::make_pair(5906, "ERROR_CLUSTER_NO_NET_ADAPTERS")); - errorNames.insert(std::make_pair(5907, "ERROR_CLUSTER_POISONED")); - errorNames.insert(std::make_pair(5908, "ERROR_CLUSTER_GROUP_MOVING")); - errorNames.insert(std::make_pair(5909, "ERROR_CLUSTER_RESOURCE_TYPE_BUSY")); - errorNames.insert(std::make_pair(5910, "ERROR_RESOURCE_CALL_TIMED_OUT")); - errorNames.insert(std::make_pair(5911, "ERROR_INVALID_CLUSTER_IPV6_ADDRESS")); - errorNames.insert(std::make_pair(5912, "ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION")); - errorNames.insert(std::make_pair(5913, "ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS")); - errorNames.insert(std::make_pair(5914, "ERROR_CLUSTER_PARTIAL_SEND")); - errorNames.insert(std::make_pair(5915, "ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION")); - errorNames.insert(std::make_pair(5916, "ERROR_CLUSTER_INVALID_STRING_TERMINATION")); - errorNames.insert(std::make_pair(5917, "ERROR_CLUSTER_INVALID_STRING_FORMAT")); - errorNames.insert(std::make_pair(5918, "ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS")); - errorNames.insert(std::make_pair(5919, "ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS")); - errorNames.insert(std::make_pair(5920, "ERROR_CLUSTER_NULL_DATA")); - errorNames.insert(std::make_pair(5921, "ERROR_CLUSTER_PARTIAL_READ")); - errorNames.insert(std::make_pair(5922, "ERROR_CLUSTER_PARTIAL_WRITE")); - errorNames.insert(std::make_pair(5923, "ERROR_CLUSTER_CANT_DESERIALIZE_DATA")); - errorNames.insert(std::make_pair(5924, "ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT")); - errorNames.insert(std::make_pair(5925, "ERROR_CLUSTER_NO_QUORUM")); - errorNames.insert(std::make_pair(5926, "ERROR_CLUSTER_INVALID_IPV6_NETWORK")); - errorNames.insert(std::make_pair(5927, "ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK")); - errorNames.insert(std::make_pair(5928, "ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP")); - errorNames.insert(std::make_pair(5929, "ERROR_DEPENDENCY_TREE_TOO_COMPLEX")); - errorNames.insert(std::make_pair(5930, "ERROR_EXCEPTION_IN_RESOURCE_CALL")); - errorNames.insert(std::make_pair(5931, "ERROR_CLUSTER_RHS_FAILED_INITIALIZATION")); - errorNames.insert(std::make_pair(5932, "ERROR_CLUSTER_NOT_INSTALLED")); - errorNames.insert(std::make_pair(5933, "ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE")); - errorNames.insert(std::make_pair(5934, "ERROR_CLUSTER_MAX_NODES_IN_CLUSTER")); - errorNames.insert(std::make_pair(5935, "ERROR_CLUSTER_TOO_MANY_NODES")); - errorNames.insert(std::make_pair(5936, "ERROR_CLUSTER_OBJECT_ALREADY_USED")); - errorNames.insert(std::make_pair(5937, "ERROR_NONCORE_GROUPS_FOUND")); - errorNames.insert(std::make_pair(5938, "ERROR_FILE_SHARE_RESOURCE_CONFLICT")); - errorNames.insert(std::make_pair(5939, "ERROR_CLUSTER_EVICT_INVALID_REQUEST")); - errorNames.insert(std::make_pair(5940, "ERROR_CLUSTER_SINGLETON_RESOURCE")); - errorNames.insert(std::make_pair(5941, "ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE")); - errorNames.insert(std::make_pair(5942, "ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED")); - errorNames.insert(std::make_pair(5943, "ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR")); - errorNames.insert(std::make_pair(5944, "ERROR_CLUSTER_GROUP_BUSY")); - errorNames.insert(std::make_pair(5945, "ERROR_CLUSTER_NOT_SHARED_VOLUME")); - errorNames.insert(std::make_pair(5946, "ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR")); - errorNames.insert(std::make_pair(5947, "ERROR_CLUSTER_SHARED_VOLUMES_IN_USE")); - errorNames.insert(std::make_pair(5948, "ERROR_CLUSTER_USE_SHARED_VOLUMES_API")); - errorNames.insert(std::make_pair(5949, "ERROR_CLUSTER_BACKUP_IN_PROGRESS")); - errorNames.insert(std::make_pair(5950, "ERROR_NON_CSV_PATH")); - errorNames.insert(std::make_pair(5951, "ERROR_CSV_VOLUME_NOT_LOCAL")); - errorNames.insert(std::make_pair(5952, "ERROR_CLUSTER_WATCHDOG_TERMINATING")); - errorNames.insert(std::make_pair(6000, "ERROR_ENCRYPTION_FAILED")); - errorNames.insert(std::make_pair(6001, "ERROR_DECRYPTION_FAILED")); - errorNames.insert(std::make_pair(6002, "ERROR_FILE_ENCRYPTED")); - errorNames.insert(std::make_pair(6003, "ERROR_NO_RECOVERY_POLICY")); - errorNames.insert(std::make_pair(6004, "ERROR_NO_EFS")); - errorNames.insert(std::make_pair(6005, "ERROR_WRONG_EFS")); - errorNames.insert(std::make_pair(6006, "ERROR_NO_USER_KEYS")); - errorNames.insert(std::make_pair(6007, "ERROR_FILE_NOT_ENCRYPTED")); - errorNames.insert(std::make_pair(6008, "ERROR_NOT_EXPORT_FORMAT")); - errorNames.insert(std::make_pair(6009, "ERROR_FILE_READ_ONLY")); - errorNames.insert(std::make_pair(6010, "ERROR_DIR_EFS_DISALLOWED")); - errorNames.insert(std::make_pair(6011, "ERROR_EFS_SERVER_NOT_TRUSTED")); - errorNames.insert(std::make_pair(6012, "ERROR_BAD_RECOVERY_POLICY")); - errorNames.insert(std::make_pair(6013, "ERROR_EFS_ALG_BLOB_TOO_BIG")); - errorNames.insert(std::make_pair(6014, "ERROR_VOLUME_NOT_SUPPORT_EFS")); - errorNames.insert(std::make_pair(6015, "ERROR_EFS_DISABLED")); - errorNames.insert(std::make_pair(6016, "ERROR_EFS_VERSION_NOT_SUPPORT")); - errorNames.insert(std::make_pair(6017, "ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE")); - errorNames.insert(std::make_pair(6018, "ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER")); - errorNames.insert(std::make_pair(6019, "ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE")); - errorNames.insert(std::make_pair(6020, "ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE")); - errorNames.insert(std::make_pair(6021, "ERROR_CS_ENCRYPTION_FILE_NOT_CSE")); - errorNames.insert(std::make_pair(6022, "ERROR_ENCRYPTION_POLICY_DENIES_OPERATION")); - errorNames.insert(std::make_pair(6118, "ERROR_NO_BROWSER_SERVERS_FOUND")); - errorNames.insert(std::make_pair(6600, "ERROR_LOG_SECTOR_INVALID")); - errorNames.insert(std::make_pair(6601, "ERROR_LOG_SECTOR_PARITY_INVALID")); - errorNames.insert(std::make_pair(6602, "ERROR_LOG_SECTOR_REMAPPED")); - errorNames.insert(std::make_pair(6603, "ERROR_LOG_BLOCK_INCOMPLETE")); - errorNames.insert(std::make_pair(6604, "ERROR_LOG_INVALID_RANGE")); - errorNames.insert(std::make_pair(6605, "ERROR_LOG_BLOCKS_EXHAUSTED")); - errorNames.insert(std::make_pair(6606, "ERROR_LOG_READ_CONTEXT_INVALID")); - errorNames.insert(std::make_pair(6607, "ERROR_LOG_RESTART_INVALID")); - errorNames.insert(std::make_pair(6608, "ERROR_LOG_BLOCK_VERSION")); - errorNames.insert(std::make_pair(6609, "ERROR_LOG_BLOCK_INVALID")); - errorNames.insert(std::make_pair(6610, "ERROR_LOG_READ_MODE_INVALID")); - errorNames.insert(std::make_pair(6611, "ERROR_LOG_NO_RESTART")); - errorNames.insert(std::make_pair(6612, "ERROR_LOG_METADATA_CORRUPT")); - errorNames.insert(std::make_pair(6613, "ERROR_LOG_METADATA_INVALID")); - errorNames.insert(std::make_pair(6614, "ERROR_LOG_METADATA_INCONSISTENT")); - errorNames.insert(std::make_pair(6615, "ERROR_LOG_RESERVATION_INVALID")); - errorNames.insert(std::make_pair(6616, "ERROR_LOG_CANT_DELETE")); - errorNames.insert(std::make_pair(6617, "ERROR_LOG_CONTAINER_LIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(6618, "ERROR_LOG_START_OF_LOG")); - errorNames.insert(std::make_pair(6619, "ERROR_LOG_POLICY_ALREADY_INSTALLED")); - errorNames.insert(std::make_pair(6620, "ERROR_LOG_POLICY_NOT_INSTALLED")); - errorNames.insert(std::make_pair(6621, "ERROR_LOG_POLICY_INVALID")); - errorNames.insert(std::make_pair(6622, "ERROR_LOG_POLICY_CONFLICT")); - errorNames.insert(std::make_pair(6623, "ERROR_LOG_PINNED_ARCHIVE_TAIL")); - errorNames.insert(std::make_pair(6624, "ERROR_LOG_RECORD_NONEXISTENT")); - errorNames.insert(std::make_pair(6625, "ERROR_LOG_RECORDS_RESERVED_INVALID")); - errorNames.insert(std::make_pair(6626, "ERROR_LOG_SPACE_RESERVED_INVALID")); - errorNames.insert(std::make_pair(6627, "ERROR_LOG_TAIL_INVALID")); - errorNames.insert(std::make_pair(6628, "ERROR_LOG_FULL")); - errorNames.insert(std::make_pair(6629, "ERROR_COULD_NOT_RESIZE_LOG")); - errorNames.insert(std::make_pair(6630, "ERROR_LOG_MULTIPLEXED")); - errorNames.insert(std::make_pair(6631, "ERROR_LOG_DEDICATED")); - errorNames.insert(std::make_pair(6632, "ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS")); - errorNames.insert(std::make_pair(6633, "ERROR_LOG_ARCHIVE_IN_PROGRESS")); - errorNames.insert(std::make_pair(6634, "ERROR_LOG_EPHEMERAL")); - errorNames.insert(std::make_pair(6635, "ERROR_LOG_NOT_ENOUGH_CONTAINERS")); - errorNames.insert(std::make_pair(6636, "ERROR_LOG_CLIENT_ALREADY_REGISTERED")); - errorNames.insert(std::make_pair(6637, "ERROR_LOG_CLIENT_NOT_REGISTERED")); - errorNames.insert(std::make_pair(6638, "ERROR_LOG_FULL_HANDLER_IN_PROGRESS")); - errorNames.insert(std::make_pair(6639, "ERROR_LOG_CONTAINER_READ_FAILED")); - errorNames.insert(std::make_pair(6640, "ERROR_LOG_CONTAINER_WRITE_FAILED")); - errorNames.insert(std::make_pair(6641, "ERROR_LOG_CONTAINER_OPEN_FAILED")); - errorNames.insert(std::make_pair(6642, "ERROR_LOG_CONTAINER_STATE_INVALID")); - errorNames.insert(std::make_pair(6643, "ERROR_LOG_STATE_INVALID")); - errorNames.insert(std::make_pair(6644, "ERROR_LOG_PINNED")); - errorNames.insert(std::make_pair(6645, "ERROR_LOG_METADATA_FLUSH_FAILED")); - errorNames.insert(std::make_pair(6646, "ERROR_LOG_INCONSISTENT_SECURITY")); - errorNames.insert(std::make_pair(6647, "ERROR_LOG_APPENDED_FLUSH_FAILED")); - errorNames.insert(std::make_pair(6648, "ERROR_LOG_PINNED_RESERVATION")); - errorNames.insert(std::make_pair(6700, "ERROR_INVALID_TRANSACTION")); - errorNames.insert(std::make_pair(6701, "ERROR_TRANSACTION_NOT_ACTIVE")); - errorNames.insert(std::make_pair(6702, "ERROR_TRANSACTION_REQUEST_NOT_VALID")); - errorNames.insert(std::make_pair(6703, "ERROR_TRANSACTION_NOT_REQUESTED")); - errorNames.insert(std::make_pair(6704, "ERROR_TRANSACTION_ALREADY_ABORTED")); - errorNames.insert(std::make_pair(6705, "ERROR_TRANSACTION_ALREADY_COMMITTED")); - errorNames.insert(std::make_pair(6706, "ERROR_TM_INITIALIZATION_FAILED")); - errorNames.insert(std::make_pair(6707, "ERROR_RESOURCEMANAGER_READ_ONLY")); - errorNames.insert(std::make_pair(6708, "ERROR_TRANSACTION_NOT_JOINED")); - errorNames.insert(std::make_pair(6709, "ERROR_TRANSACTION_SUPERIOR_EXISTS")); - errorNames.insert(std::make_pair(6710, "ERROR_CRM_PROTOCOL_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(6711, "ERROR_TRANSACTION_PROPAGATION_FAILED")); - errorNames.insert(std::make_pair(6712, "ERROR_CRM_PROTOCOL_NOT_FOUND")); - errorNames.insert(std::make_pair(6713, "ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER")); - errorNames.insert(std::make_pair(6714, "ERROR_CURRENT_TRANSACTION_NOT_VALID")); - errorNames.insert(std::make_pair(6715, "ERROR_TRANSACTION_NOT_FOUND")); - errorNames.insert(std::make_pair(6716, "ERROR_RESOURCEMANAGER_NOT_FOUND")); - errorNames.insert(std::make_pair(6717, "ERROR_ENLISTMENT_NOT_FOUND")); - errorNames.insert(std::make_pair(6718, "ERROR_TRANSACTIONMANAGER_NOT_FOUND")); - errorNames.insert(std::make_pair(6719, "ERROR_TRANSACTIONMANAGER_NOT_ONLINE")); - errorNames.insert(std::make_pair(6720, "ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION")); - errorNames.insert(std::make_pair(6721, "ERROR_TRANSACTION_NOT_ROOT")); - errorNames.insert(std::make_pair(6722, "ERROR_TRANSACTION_OBJECT_EXPIRED")); - errorNames.insert(std::make_pair(6723, "ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED")); - errorNames.insert(std::make_pair(6724, "ERROR_TRANSACTION_RECORD_TOO_LONG")); - errorNames.insert(std::make_pair(6725, "ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(6726, "ERROR_TRANSACTION_INTEGRITY_VIOLATED")); - errorNames.insert(std::make_pair(6727, "ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH")); - errorNames.insert(std::make_pair(6728, "ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT")); - errorNames.insert(std::make_pair(6729, "ERROR_TRANSACTION_MUST_WRITETHROUGH")); - errorNames.insert(std::make_pair(6730, "ERROR_TRANSACTION_NO_SUPERIOR")); - errorNames.insert(std::make_pair(6731, "ERROR_HEURISTIC_DAMAGE_POSSIBLE")); - errorNames.insert(std::make_pair(6800, "ERROR_TRANSACTIONAL_CONFLICT")); - errorNames.insert(std::make_pair(6801, "ERROR_RM_NOT_ACTIVE")); - errorNames.insert(std::make_pair(6802, "ERROR_RM_METADATA_CORRUPT")); - errorNames.insert(std::make_pair(6803, "ERROR_DIRECTORY_NOT_RM")); - errorNames.insert(std::make_pair(6805, "ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE")); - errorNames.insert(std::make_pair(6806, "ERROR_LOG_RESIZE_INVALID_SIZE")); - errorNames.insert(std::make_pair(6807, "ERROR_OBJECT_NO_LONGER_EXISTS")); - errorNames.insert(std::make_pair(6808, "ERROR_STREAM_MINIVERSION_NOT_FOUND")); - errorNames.insert(std::make_pair(6809, "ERROR_STREAM_MINIVERSION_NOT_VALID")); - errorNames.insert(std::make_pair(6810, "ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION")); - errorNames.insert(std::make_pair(6811, "ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT")); - errorNames.insert(std::make_pair(6812, "ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS")); - errorNames.insert(std::make_pair(6814, "ERROR_REMOTE_FILE_VERSION_MISMATCH")); - errorNames.insert(std::make_pair(6815, "ERROR_HANDLE_NO_LONGER_VALID")); - errorNames.insert(std::make_pair(6816, "ERROR_NO_TXF_METADATA")); - errorNames.insert(std::make_pair(6817, "ERROR_LOG_CORRUPTION_DETECTED")); - errorNames.insert(std::make_pair(6818, "ERROR_CANT_RECOVER_WITH_HANDLE_OPEN")); - errorNames.insert(std::make_pair(6819, "ERROR_RM_DISCONNECTED")); - errorNames.insert(std::make_pair(6820, "ERROR_ENLISTMENT_NOT_SUPERIOR")); - errorNames.insert(std::make_pair(6821, "ERROR_RECOVERY_NOT_NEEDED")); - errorNames.insert(std::make_pair(6822, "ERROR_RM_ALREADY_STARTED")); - errorNames.insert(std::make_pair(6823, "ERROR_FILE_IDENTITY_NOT_PERSISTENT")); - errorNames.insert(std::make_pair(6824, "ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY")); - errorNames.insert(std::make_pair(6825, "ERROR_CANT_CROSS_RM_BOUNDARY")); - errorNames.insert(std::make_pair(6826, "ERROR_TXF_DIR_NOT_EMPTY")); - errorNames.insert(std::make_pair(6827, "ERROR_INDOUBT_TRANSACTIONS_EXIST")); - errorNames.insert(std::make_pair(6828, "ERROR_TM_VOLATILE")); - errorNames.insert(std::make_pair(6829, "ERROR_ROLLBACK_TIMER_EXPIRED")); - errorNames.insert(std::make_pair(6830, "ERROR_TXF_ATTRIBUTE_CORRUPT")); - errorNames.insert(std::make_pair(6831, "ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION")); - errorNames.insert(std::make_pair(6832, "ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED")); - errorNames.insert(std::make_pair(6833, "ERROR_LOG_GROWTH_FAILED")); - errorNames.insert(std::make_pair(6834, "ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE")); - errorNames.insert(std::make_pair(6835, "ERROR_TXF_METADATA_ALREADY_PRESENT")); - errorNames.insert(std::make_pair(6836, "ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET")); - errorNames.insert(std::make_pair(6837, "ERROR_TRANSACTION_REQUIRED_PROMOTION")); - errorNames.insert(std::make_pair(6838, "ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION")); - errorNames.insert(std::make_pair(6839, "ERROR_TRANSACTIONS_NOT_FROZEN")); - errorNames.insert(std::make_pair(6840, "ERROR_TRANSACTION_FREEZE_IN_PROGRESS")); - errorNames.insert(std::make_pair(6841, "ERROR_NOT_SNAPSHOT_VOLUME")); - errorNames.insert(std::make_pair(6842, "ERROR_NO_SAVEPOINT_WITH_OPEN_FILES")); - errorNames.insert(std::make_pair(6843, "ERROR_DATA_LOST_REPAIR")); - errorNames.insert(std::make_pair(6844, "ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION")); - errorNames.insert(std::make_pair(6845, "ERROR_TM_IDENTITY_MISMATCH")); - errorNames.insert(std::make_pair(6846, "ERROR_FLOATED_SECTION")); - errorNames.insert(std::make_pair(6847, "ERROR_CANNOT_ACCEPT_TRANSACTED_WORK")); - errorNames.insert(std::make_pair(6848, "ERROR_CANNOT_ABORT_TRANSACTIONS")); - errorNames.insert(std::make_pair(6849, "ERROR_BAD_CLUSTERS")); - errorNames.insert(std::make_pair(6850, "ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION")); - errorNames.insert(std::make_pair(6851, "ERROR_VOLUME_DIRTY")); - errorNames.insert(std::make_pair(6852, "ERROR_NO_LINK_TRACKING_IN_TRANSACTION")); - errorNames.insert(std::make_pair(6853, "ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION")); - errorNames.insert(std::make_pair(6854, "ERROR_EXPIRED_HANDLE")); - errorNames.insert(std::make_pair(6855, "ERROR_TRANSACTION_NOT_ENLISTED")); - errorNames.insert(std::make_pair(7001, "ERROR_CTX_WINSTATION_NAME_INVALID")); - errorNames.insert(std::make_pair(7002, "ERROR_CTX_INVALID_PD")); - errorNames.insert(std::make_pair(7003, "ERROR_CTX_PD_NOT_FOUND")); - errorNames.insert(std::make_pair(7004, "ERROR_CTX_WD_NOT_FOUND")); - errorNames.insert(std::make_pair(7005, "ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY")); - errorNames.insert(std::make_pair(7006, "ERROR_CTX_SERVICE_NAME_COLLISION")); - errorNames.insert(std::make_pair(7007, "ERROR_CTX_CLOSE_PENDING")); - errorNames.insert(std::make_pair(7008, "ERROR_CTX_NO_OUTBUF")); - errorNames.insert(std::make_pair(7009, "ERROR_CTX_MODEM_INF_NOT_FOUND")); - errorNames.insert(std::make_pair(7010, "ERROR_CTX_INVALID_MODEMNAME")); - errorNames.insert(std::make_pair(7011, "ERROR_CTX_MODEM_RESPONSE_ERROR")); - errorNames.insert(std::make_pair(7012, "ERROR_CTX_MODEM_RESPONSE_TIMEOUT")); - errorNames.insert(std::make_pair(7013, "ERROR_CTX_MODEM_RESPONSE_NO_CARRIER")); - errorNames.insert(std::make_pair(7014, "ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE")); - errorNames.insert(std::make_pair(7015, "ERROR_CTX_MODEM_RESPONSE_BUSY")); - errorNames.insert(std::make_pair(7016, "ERROR_CTX_MODEM_RESPONSE_VOICE")); - errorNames.insert(std::make_pair(7017, "ERROR_CTX_TD_ERROR")); - errorNames.insert(std::make_pair(7022, "ERROR_CTX_WINSTATION_NOT_FOUND")); - errorNames.insert(std::make_pair(7023, "ERROR_CTX_WINSTATION_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(7024, "ERROR_CTX_WINSTATION_BUSY")); - errorNames.insert(std::make_pair(7025, "ERROR_CTX_BAD_VIDEO_MODE")); - errorNames.insert(std::make_pair(7035, "ERROR_CTX_GRAPHICS_INVALID")); - errorNames.insert(std::make_pair(7037, "ERROR_CTX_LOGON_DISABLED")); - errorNames.insert(std::make_pair(7038, "ERROR_CTX_NOT_CONSOLE")); - errorNames.insert(std::make_pair(7040, "ERROR_CTX_CLIENT_QUERY_TIMEOUT")); - errorNames.insert(std::make_pair(7041, "ERROR_CTX_CONSOLE_DISCONNECT")); - errorNames.insert(std::make_pair(7042, "ERROR_CTX_CONSOLE_CONNECT")); - errorNames.insert(std::make_pair(7044, "ERROR_CTX_SHADOW_DENIED")); - errorNames.insert(std::make_pair(7045, "ERROR_CTX_WINSTATION_ACCESS_DENIED")); - errorNames.insert(std::make_pair(7049, "ERROR_CTX_INVALID_WD")); - errorNames.insert(std::make_pair(7050, "ERROR_CTX_SHADOW_INVALID")); - errorNames.insert(std::make_pair(7051, "ERROR_CTX_SHADOW_DISABLED")); - errorNames.insert(std::make_pair(7052, "ERROR_CTX_CLIENT_LICENSE_IN_USE")); - errorNames.insert(std::make_pair(7053, "ERROR_CTX_CLIENT_LICENSE_NOT_SET")); - errorNames.insert(std::make_pair(7054, "ERROR_CTX_LICENSE_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(7055, "ERROR_CTX_LICENSE_CLIENT_INVALID")); - errorNames.insert(std::make_pair(7056, "ERROR_CTX_LICENSE_EXPIRED")); - errorNames.insert(std::make_pair(7057, "ERROR_CTX_SHADOW_NOT_RUNNING")); - errorNames.insert(std::make_pair(7058, "ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE")); - errorNames.insert(std::make_pair(7059, "ERROR_ACTIVATION_COUNT_EXCEEDED")); - errorNames.insert(std::make_pair(7060, "ERROR_CTX_WINSTATIONS_DISABLED")); - errorNames.insert(std::make_pair(7061, "ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED")); - errorNames.insert(std::make_pair(7062, "ERROR_CTX_SESSION_IN_USE")); - errorNames.insert(std::make_pair(7063, "ERROR_CTX_NO_FORCE_LOGOFF")); - errorNames.insert(std::make_pair(7064, "ERROR_CTX_ACCOUNT_RESTRICTION")); - errorNames.insert(std::make_pair(7065, "ERROR_RDP_PROTOCOL_ERROR")); - errorNames.insert(std::make_pair(7066, "ERROR_CTX_CDM_CONNECT")); - errorNames.insert(std::make_pair(7067, "ERROR_CTX_CDM_DISCONNECT")); - errorNames.insert(std::make_pair(7068, "ERROR_CTX_SECURITY_LAYER_ERROR")); - errorNames.insert(std::make_pair(7069, "ERROR_TS_INCOMPATIBLE_SESSIONS")); - errorNames.insert(std::make_pair(7070, "ERROR_TS_VIDEO_SUBSYSTEM_ERROR")); - errorNames.insert(std::make_pair(8200, "ERROR_DS_NOT_INSTALLED")); - errorNames.insert(std::make_pair(8201, "ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY")); - errorNames.insert(std::make_pair(8202, "ERROR_DS_NO_ATTRIBUTE_OR_VALUE")); - errorNames.insert(std::make_pair(8203, "ERROR_DS_INVALID_ATTRIBUTE_SYNTAX")); - errorNames.insert(std::make_pair(8204, "ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED")); - errorNames.insert(std::make_pair(8205, "ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS")); - errorNames.insert(std::make_pair(8206, "ERROR_DS_BUSY")); - errorNames.insert(std::make_pair(8207, "ERROR_DS_UNAVAILABLE")); - errorNames.insert(std::make_pair(8208, "ERROR_DS_NO_RIDS_ALLOCATED")); - errorNames.insert(std::make_pair(8209, "ERROR_DS_NO_MORE_RIDS")); - errorNames.insert(std::make_pair(8210, "ERROR_DS_INCORRECT_ROLE_OWNER")); - errorNames.insert(std::make_pair(8211, "ERROR_DS_RIDMGR_INIT_ERROR")); - errorNames.insert(std::make_pair(8212, "ERROR_DS_OBJ_CLASS_VIOLATION")); - errorNames.insert(std::make_pair(8213, "ERROR_DS_CANT_ON_NON_LEAF")); - errorNames.insert(std::make_pair(8214, "ERROR_DS_CANT_ON_RDN")); - errorNames.insert(std::make_pair(8215, "ERROR_DS_CANT_MOD_OBJ_CLASS")); - errorNames.insert(std::make_pair(8216, "ERROR_DS_CROSS_DOM_MOVE_ERROR")); - errorNames.insert(std::make_pair(8217, "ERROR_DS_GC_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(8218, "ERROR_SHARED_POLICY")); - errorNames.insert(std::make_pair(8219, "ERROR_POLICY_OBJECT_NOT_FOUND")); - errorNames.insert(std::make_pair(8220, "ERROR_POLICY_ONLY_IN_DS")); - errorNames.insert(std::make_pair(8221, "ERROR_PROMOTION_ACTIVE")); - errorNames.insert(std::make_pair(8222, "ERROR_NO_PROMOTION_ACTIVE")); - errorNames.insert(std::make_pair(8224, "ERROR_DS_OPERATIONS_ERROR")); - errorNames.insert(std::make_pair(8225, "ERROR_DS_PROTOCOL_ERROR")); - errorNames.insert(std::make_pair(8226, "ERROR_DS_TIMELIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(8227, "ERROR_DS_SIZELIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(8228, "ERROR_DS_ADMIN_LIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(8229, "ERROR_DS_COMPARE_FALSE")); - errorNames.insert(std::make_pair(8230, "ERROR_DS_COMPARE_TRUE")); - errorNames.insert(std::make_pair(8231, "ERROR_DS_AUTH_METHOD_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(8232, "ERROR_DS_STRONG_AUTH_REQUIRED")); - errorNames.insert(std::make_pair(8233, "ERROR_DS_INAPPROPRIATE_AUTH")); - errorNames.insert(std::make_pair(8234, "ERROR_DS_AUTH_UNKNOWN")); - errorNames.insert(std::make_pair(8235, "ERROR_DS_REFERRAL")); - errorNames.insert(std::make_pair(8236, "ERROR_DS_UNAVAILABLE_CRIT_EXTENSION")); - errorNames.insert(std::make_pair(8237, "ERROR_DS_CONFIDENTIALITY_REQUIRED")); - errorNames.insert(std::make_pair(8238, "ERROR_DS_INAPPROPRIATE_MATCHING")); - errorNames.insert(std::make_pair(8239, "ERROR_DS_CONSTRAINT_VIOLATION")); - errorNames.insert(std::make_pair(8240, "ERROR_DS_NO_SUCH_OBJECT")); - errorNames.insert(std::make_pair(8241, "ERROR_DS_ALIAS_PROBLEM")); - errorNames.insert(std::make_pair(8242, "ERROR_DS_INVALID_DN_SYNTAX")); - errorNames.insert(std::make_pair(8243, "ERROR_DS_IS_LEAF")); - errorNames.insert(std::make_pair(8244, "ERROR_DS_ALIAS_DEREF_PROBLEM")); - errorNames.insert(std::make_pair(8245, "ERROR_DS_UNWILLING_TO_PERFORM")); - errorNames.insert(std::make_pair(8246, "ERROR_DS_LOOP_DETECT")); - errorNames.insert(std::make_pair(8247, "ERROR_DS_NAMING_VIOLATION")); - errorNames.insert(std::make_pair(8248, "ERROR_DS_OBJECT_RESULTS_TOO_LARGE")); - errorNames.insert(std::make_pair(8249, "ERROR_DS_AFFECTS_MULTIPLE_DSAS")); - errorNames.insert(std::make_pair(8250, "ERROR_DS_SERVER_DOWN")); - errorNames.insert(std::make_pair(8251, "ERROR_DS_LOCAL_ERROR")); - errorNames.insert(std::make_pair(8252, "ERROR_DS_ENCODING_ERROR")); - errorNames.insert(std::make_pair(8253, "ERROR_DS_DECODING_ERROR")); - errorNames.insert(std::make_pair(8254, "ERROR_DS_FILTER_UNKNOWN")); - errorNames.insert(std::make_pair(8255, "ERROR_DS_PARAM_ERROR")); - errorNames.insert(std::make_pair(8256, "ERROR_DS_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(8257, "ERROR_DS_NO_RESULTS_RETURNED")); - errorNames.insert(std::make_pair(8258, "ERROR_DS_CONTROL_NOT_FOUND")); - errorNames.insert(std::make_pair(8259, "ERROR_DS_CLIENT_LOOP")); - errorNames.insert(std::make_pair(8260, "ERROR_DS_REFERRAL_LIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(8261, "ERROR_DS_SORT_CONTROL_MISSING")); - errorNames.insert(std::make_pair(8262, "ERROR_DS_OFFSET_RANGE_ERROR")); - errorNames.insert(std::make_pair(8301, "ERROR_DS_ROOT_MUST_BE_NC")); - errorNames.insert(std::make_pair(8302, "ERROR_DS_ADD_REPLICA_INHIBITED")); - errorNames.insert(std::make_pair(8303, "ERROR_DS_ATT_NOT_DEF_IN_SCHEMA")); - errorNames.insert(std::make_pair(8304, "ERROR_DS_MAX_OBJ_SIZE_EXCEEDED")); - errorNames.insert(std::make_pair(8305, "ERROR_DS_OBJ_STRING_NAME_EXISTS")); - errorNames.insert(std::make_pair(8306, "ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA")); - errorNames.insert(std::make_pair(8307, "ERROR_DS_RDN_DOESNT_MATCH_SCHEMA")); - errorNames.insert(std::make_pair(8308, "ERROR_DS_NO_REQUESTED_ATTS_FOUND")); - errorNames.insert(std::make_pair(8309, "ERROR_DS_USER_BUFFER_TO_SMALL")); - errorNames.insert(std::make_pair(8310, "ERROR_DS_ATT_IS_NOT_ON_OBJ")); - errorNames.insert(std::make_pair(8311, "ERROR_DS_ILLEGAL_MOD_OPERATION")); - errorNames.insert(std::make_pair(8312, "ERROR_DS_OBJ_TOO_LARGE")); - errorNames.insert(std::make_pair(8313, "ERROR_DS_BAD_INSTANCE_TYPE")); - errorNames.insert(std::make_pair(8314, "ERROR_DS_MASTERDSA_REQUIRED")); - errorNames.insert(std::make_pair(8315, "ERROR_DS_OBJECT_CLASS_REQUIRED")); - errorNames.insert(std::make_pair(8316, "ERROR_DS_MISSING_REQUIRED_ATT")); - errorNames.insert(std::make_pair(8317, "ERROR_DS_ATT_NOT_DEF_FOR_CLASS")); - errorNames.insert(std::make_pair(8318, "ERROR_DS_ATT_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(8320, "ERROR_DS_CANT_ADD_ATT_VALUES")); - errorNames.insert(std::make_pair(8321, "ERROR_DS_SINGLE_VALUE_CONSTRAINT")); - errorNames.insert(std::make_pair(8322, "ERROR_DS_RANGE_CONSTRAINT")); - errorNames.insert(std::make_pair(8323, "ERROR_DS_ATT_VAL_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(8324, "ERROR_DS_CANT_REM_MISSING_ATT")); - errorNames.insert(std::make_pair(8325, "ERROR_DS_CANT_REM_MISSING_ATT_VAL")); - errorNames.insert(std::make_pair(8326, "ERROR_DS_ROOT_CANT_BE_SUBREF")); - errorNames.insert(std::make_pair(8327, "ERROR_DS_NO_CHAINING")); - errorNames.insert(std::make_pair(8328, "ERROR_DS_NO_CHAINED_EVAL")); - errorNames.insert(std::make_pair(8329, "ERROR_DS_NO_PARENT_OBJECT")); - errorNames.insert(std::make_pair(8330, "ERROR_DS_PARENT_IS_AN_ALIAS")); - errorNames.insert(std::make_pair(8331, "ERROR_DS_CANT_MIX_MASTER_AND_REPS")); - errorNames.insert(std::make_pair(8332, "ERROR_DS_CHILDREN_EXIST")); - errorNames.insert(std::make_pair(8333, "ERROR_DS_OBJ_NOT_FOUND")); - errorNames.insert(std::make_pair(8334, "ERROR_DS_ALIASED_OBJ_MISSING")); - errorNames.insert(std::make_pair(8335, "ERROR_DS_BAD_NAME_SYNTAX")); - errorNames.insert(std::make_pair(8336, "ERROR_DS_ALIAS_POINTS_TO_ALIAS")); - errorNames.insert(std::make_pair(8337, "ERROR_DS_CANT_DEREF_ALIAS")); - errorNames.insert(std::make_pair(8338, "ERROR_DS_OUT_OF_SCOPE")); - errorNames.insert(std::make_pair(8339, "ERROR_DS_OBJECT_BEING_REMOVED")); - errorNames.insert(std::make_pair(8340, "ERROR_DS_CANT_DELETE_DSA_OBJ")); - errorNames.insert(std::make_pair(8341, "ERROR_DS_GENERIC_ERROR")); - errorNames.insert(std::make_pair(8342, "ERROR_DS_DSA_MUST_BE_INT_MASTER")); - errorNames.insert(std::make_pair(8343, "ERROR_DS_CLASS_NOT_DSA")); - errorNames.insert(std::make_pair(8344, "ERROR_DS_INSUFF_ACCESS_RIGHTS")); - errorNames.insert(std::make_pair(8345, "ERROR_DS_ILLEGAL_SUPERIOR")); - errorNames.insert(std::make_pair(8346, "ERROR_DS_ATTRIBUTE_OWNED_BY_SAM")); - errorNames.insert(std::make_pair(8347, "ERROR_DS_NAME_TOO_MANY_PARTS")); - errorNames.insert(std::make_pair(8348, "ERROR_DS_NAME_TOO_LONG")); - errorNames.insert(std::make_pair(8349, "ERROR_DS_NAME_VALUE_TOO_LONG")); - errorNames.insert(std::make_pair(8350, "ERROR_DS_NAME_UNPARSEABLE")); - errorNames.insert(std::make_pair(8351, "ERROR_DS_NAME_TYPE_UNKNOWN")); - errorNames.insert(std::make_pair(8352, "ERROR_DS_NOT_AN_OBJECT")); - errorNames.insert(std::make_pair(8353, "ERROR_DS_SEC_DESC_TOO_SHORT")); - errorNames.insert(std::make_pair(8354, "ERROR_DS_SEC_DESC_INVALID")); - errorNames.insert(std::make_pair(8355, "ERROR_DS_NO_DELETED_NAME")); - errorNames.insert(std::make_pair(8356, "ERROR_DS_SUBREF_MUST_HAVE_PARENT")); - errorNames.insert(std::make_pair(8357, "ERROR_DS_NCNAME_MUST_BE_NC")); - errorNames.insert(std::make_pair(8358, "ERROR_DS_CANT_ADD_SYSTEM_ONLY")); - errorNames.insert(std::make_pair(8359, "ERROR_DS_CLASS_MUST_BE_CONCRETE")); - errorNames.insert(std::make_pair(8360, "ERROR_DS_INVALID_DMD")); - errorNames.insert(std::make_pair(8361, "ERROR_DS_OBJ_GUID_EXISTS")); - errorNames.insert(std::make_pair(8362, "ERROR_DS_NOT_ON_BACKLINK")); - errorNames.insert(std::make_pair(8363, "ERROR_DS_NO_CROSSREF_FOR_NC")); - errorNames.insert(std::make_pair(8364, "ERROR_DS_SHUTTING_DOWN")); - errorNames.insert(std::make_pair(8365, "ERROR_DS_UNKNOWN_OPERATION")); - errorNames.insert(std::make_pair(8366, "ERROR_DS_INVALID_ROLE_OWNER")); - errorNames.insert(std::make_pair(8367, "ERROR_DS_COULDNT_CONTACT_FSMO")); - errorNames.insert(std::make_pair(8368, "ERROR_DS_CROSS_NC_DN_RENAME")); - errorNames.insert(std::make_pair(8369, "ERROR_DS_CANT_MOD_SYSTEM_ONLY")); - errorNames.insert(std::make_pair(8370, "ERROR_DS_REPLICATOR_ONLY")); - errorNames.insert(std::make_pair(8371, "ERROR_DS_OBJ_CLASS_NOT_DEFINED")); - errorNames.insert(std::make_pair(8372, "ERROR_DS_OBJ_CLASS_NOT_SUBCLASS")); - errorNames.insert(std::make_pair(8373, "ERROR_DS_NAME_REFERENCE_INVALID")); - errorNames.insert(std::make_pair(8374, "ERROR_DS_CROSS_REF_EXISTS")); - errorNames.insert(std::make_pair(8375, "ERROR_DS_CANT_DEL_MASTER_CROSSREF")); - errorNames.insert(std::make_pair(8376, "ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD")); - errorNames.insert(std::make_pair(8377, "ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX")); - errorNames.insert(std::make_pair(8378, "ERROR_DS_DUP_RDN")); - errorNames.insert(std::make_pair(8379, "ERROR_DS_DUP_OID")); - errorNames.insert(std::make_pair(8380, "ERROR_DS_DUP_MAPI_ID")); - errorNames.insert(std::make_pair(8381, "ERROR_DS_DUP_SCHEMA_ID_GUID")); - errorNames.insert(std::make_pair(8382, "ERROR_DS_DUP_LDAP_DISPLAY_NAME")); - errorNames.insert(std::make_pair(8383, "ERROR_DS_SEMANTIC_ATT_TEST")); - errorNames.insert(std::make_pair(8384, "ERROR_DS_SYNTAX_MISMATCH")); - errorNames.insert(std::make_pair(8385, "ERROR_DS_EXISTS_IN_MUST_HAVE")); - errorNames.insert(std::make_pair(8386, "ERROR_DS_EXISTS_IN_MAY_HAVE")); - errorNames.insert(std::make_pair(8387, "ERROR_DS_NONEXISTENT_MAY_HAVE")); - errorNames.insert(std::make_pair(8388, "ERROR_DS_NONEXISTENT_MUST_HAVE")); - errorNames.insert(std::make_pair(8389, "ERROR_DS_AUX_CLS_TEST_FAIL")); - errorNames.insert(std::make_pair(8390, "ERROR_DS_NONEXISTENT_POSS_SUP")); - errorNames.insert(std::make_pair(8391, "ERROR_DS_SUB_CLS_TEST_FAIL")); - errorNames.insert(std::make_pair(8392, "ERROR_DS_BAD_RDN_ATT_ID_SYNTAX")); - errorNames.insert(std::make_pair(8393, "ERROR_DS_EXISTS_IN_AUX_CLS")); - errorNames.insert(std::make_pair(8394, "ERROR_DS_EXISTS_IN_SUB_CLS")); - errorNames.insert(std::make_pair(8395, "ERROR_DS_EXISTS_IN_POSS_SUP")); - errorNames.insert(std::make_pair(8396, "ERROR_DS_RECALCSCHEMA_FAILED")); - errorNames.insert(std::make_pair(8397, "ERROR_DS_TREE_DELETE_NOT_FINISHED")); - errorNames.insert(std::make_pair(8398, "ERROR_DS_CANT_DELETE")); - errorNames.insert(std::make_pair(8399, "ERROR_DS_ATT_SCHEMA_REQ_ID")); - errorNames.insert(std::make_pair(8400, "ERROR_DS_BAD_ATT_SCHEMA_SYNTAX")); - errorNames.insert(std::make_pair(8401, "ERROR_DS_CANT_CACHE_ATT")); - errorNames.insert(std::make_pair(8402, "ERROR_DS_CANT_CACHE_CLASS")); - errorNames.insert(std::make_pair(8403, "ERROR_DS_CANT_REMOVE_ATT_CACHE")); - errorNames.insert(std::make_pair(8404, "ERROR_DS_CANT_REMOVE_CLASS_CACHE")); - errorNames.insert(std::make_pair(8405, "ERROR_DS_CANT_RETRIEVE_DN")); - errorNames.insert(std::make_pair(8406, "ERROR_DS_MISSING_SUPREF")); - errorNames.insert(std::make_pair(8407, "ERROR_DS_CANT_RETRIEVE_INSTANCE")); - errorNames.insert(std::make_pair(8408, "ERROR_DS_CODE_INCONSISTENCY")); - errorNames.insert(std::make_pair(8409, "ERROR_DS_DATABASE_ERROR")); - errorNames.insert(std::make_pair(8410, "ERROR_DS_GOVERNSID_MISSING")); - errorNames.insert(std::make_pair(8411, "ERROR_DS_MISSING_EXPECTED_ATT")); - errorNames.insert(std::make_pair(8412, "ERROR_DS_NCNAME_MISSING_CR_REF")); - errorNames.insert(std::make_pair(8413, "ERROR_DS_SECURITY_CHECKING_ERROR")); - errorNames.insert(std::make_pair(8414, "ERROR_DS_SCHEMA_NOT_LOADED")); - errorNames.insert(std::make_pair(8415, "ERROR_DS_SCHEMA_ALLOC_FAILED")); - errorNames.insert(std::make_pair(8416, "ERROR_DS_ATT_SCHEMA_REQ_SYNTAX")); - errorNames.insert(std::make_pair(8417, "ERROR_DS_GCVERIFY_ERROR")); - errorNames.insert(std::make_pair(8418, "ERROR_DS_DRA_SCHEMA_MISMATCH")); - errorNames.insert(std::make_pair(8419, "ERROR_DS_CANT_FIND_DSA_OBJ")); - errorNames.insert(std::make_pair(8420, "ERROR_DS_CANT_FIND_EXPECTED_NC")); - errorNames.insert(std::make_pair(8421, "ERROR_DS_CANT_FIND_NC_IN_CACHE")); - errorNames.insert(std::make_pair(8422, "ERROR_DS_CANT_RETRIEVE_CHILD")); - errorNames.insert(std::make_pair(8423, "ERROR_DS_SECURITY_ILLEGAL_MODIFY")); - errorNames.insert(std::make_pair(8424, "ERROR_DS_CANT_REPLACE_HIDDEN_REC")); - errorNames.insert(std::make_pair(8425, "ERROR_DS_BAD_HIERARCHY_FILE")); - errorNames.insert(std::make_pair(8426, "ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED")); - errorNames.insert(std::make_pair(8427, "ERROR_DS_CONFIG_PARAM_MISSING")); - errorNames.insert(std::make_pair(8428, "ERROR_DS_COUNTING_AB_INDICES_FAILED")); - errorNames.insert(std::make_pair(8429, "ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED")); - errorNames.insert(std::make_pair(8430, "ERROR_DS_INTERNAL_FAILURE")); - errorNames.insert(std::make_pair(8431, "ERROR_DS_UNKNOWN_ERROR")); - errorNames.insert(std::make_pair(8432, "ERROR_DS_ROOT_REQUIRES_CLASS_TOP")); - errorNames.insert(std::make_pair(8433, "ERROR_DS_REFUSING_FSMO_ROLES")); - errorNames.insert(std::make_pair(8434, "ERROR_DS_MISSING_FSMO_SETTINGS")); - errorNames.insert(std::make_pair(8435, "ERROR_DS_UNABLE_TO_SURRENDER_ROLES")); - errorNames.insert(std::make_pair(8436, "ERROR_DS_DRA_GENERIC")); - errorNames.insert(std::make_pair(8437, "ERROR_DS_DRA_INVALID_PARAMETER")); - errorNames.insert(std::make_pair(8438, "ERROR_DS_DRA_BUSY")); - errorNames.insert(std::make_pair(8439, "ERROR_DS_DRA_BAD_DN")); - errorNames.insert(std::make_pair(8440, "ERROR_DS_DRA_BAD_NC")); - errorNames.insert(std::make_pair(8441, "ERROR_DS_DRA_DN_EXISTS")); - errorNames.insert(std::make_pair(8442, "ERROR_DS_DRA_INTERNAL_ERROR")); - errorNames.insert(std::make_pair(8443, "ERROR_DS_DRA_INCONSISTENT_DIT")); - errorNames.insert(std::make_pair(8444, "ERROR_DS_DRA_CONNECTION_FAILED")); - errorNames.insert(std::make_pair(8445, "ERROR_DS_DRA_BAD_INSTANCE_TYPE")); - errorNames.insert(std::make_pair(8446, "ERROR_DS_DRA_OUT_OF_MEM")); - errorNames.insert(std::make_pair(8447, "ERROR_DS_DRA_MAIL_PROBLEM")); - errorNames.insert(std::make_pair(8448, "ERROR_DS_DRA_REF_ALREADY_EXISTS")); - errorNames.insert(std::make_pair(8449, "ERROR_DS_DRA_REF_NOT_FOUND")); - errorNames.insert(std::make_pair(8450, "ERROR_DS_DRA_OBJ_IS_REP_SOURCE")); - errorNames.insert(std::make_pair(8451, "ERROR_DS_DRA_DB_ERROR")); - errorNames.insert(std::make_pair(8452, "ERROR_DS_DRA_NO_REPLICA")); - errorNames.insert(std::make_pair(8453, "ERROR_DS_DRA_ACCESS_DENIED")); - errorNames.insert(std::make_pair(8454, "ERROR_DS_DRA_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(8455, "ERROR_DS_DRA_RPC_CANCELLED")); - errorNames.insert(std::make_pair(8456, "ERROR_DS_DRA_SOURCE_DISABLED")); - errorNames.insert(std::make_pair(8457, "ERROR_DS_DRA_SINK_DISABLED")); - errorNames.insert(std::make_pair(8458, "ERROR_DS_DRA_NAME_COLLISION")); - errorNames.insert(std::make_pair(8459, "ERROR_DS_DRA_SOURCE_REINSTALLED")); - errorNames.insert(std::make_pair(8460, "ERROR_DS_DRA_MISSING_PARENT")); - errorNames.insert(std::make_pair(8461, "ERROR_DS_DRA_PREEMPTED")); - errorNames.insert(std::make_pair(8462, "ERROR_DS_DRA_ABANDON_SYNC")); - errorNames.insert(std::make_pair(8463, "ERROR_DS_DRA_SHUTDOWN")); - errorNames.insert(std::make_pair(8464, "ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET")); - errorNames.insert(std::make_pair(8465, "ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA")); - errorNames.insert(std::make_pair(8466, "ERROR_DS_DRA_EXTN_CONNECTION_FAILED")); - errorNames.insert(std::make_pair(8467, "ERROR_DS_INSTALL_SCHEMA_MISMATCH")); - errorNames.insert(std::make_pair(8468, "ERROR_DS_DUP_LINK_ID")); - errorNames.insert(std::make_pair(8469, "ERROR_DS_NAME_ERROR_RESOLVING")); - errorNames.insert(std::make_pair(8470, "ERROR_DS_NAME_ERROR_NOT_FOUND")); - errorNames.insert(std::make_pair(8471, "ERROR_DS_NAME_ERROR_NOT_UNIQUE")); - errorNames.insert(std::make_pair(8472, "ERROR_DS_NAME_ERROR_NO_MAPPING")); - errorNames.insert(std::make_pair(8473, "ERROR_DS_NAME_ERROR_DOMAIN_ONLY")); - errorNames.insert(std::make_pair(8474, "ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING")); - errorNames.insert(std::make_pair(8475, "ERROR_DS_CONSTRUCTED_ATT_MOD")); - errorNames.insert(std::make_pair(8476, "ERROR_DS_WRONG_OM_OBJ_CLASS")); - errorNames.insert(std::make_pair(8477, "ERROR_DS_DRA_REPL_PENDING")); - errorNames.insert(std::make_pair(8478, "ERROR_DS_DS_REQUIRED")); - errorNames.insert(std::make_pair(8479, "ERROR_DS_INVALID_LDAP_DISPLAY_NAME")); - errorNames.insert(std::make_pair(8480, "ERROR_DS_NON_BASE_SEARCH")); - errorNames.insert(std::make_pair(8481, "ERROR_DS_CANT_RETRIEVE_ATTS")); - errorNames.insert(std::make_pair(8482, "ERROR_DS_BACKLINK_WITHOUT_LINK")); - errorNames.insert(std::make_pair(8483, "ERROR_DS_EPOCH_MISMATCH")); - errorNames.insert(std::make_pair(8484, "ERROR_DS_SRC_NAME_MISMATCH")); - errorNames.insert(std::make_pair(8485, "ERROR_DS_SRC_AND_DST_NC_IDENTICAL")); - errorNames.insert(std::make_pair(8486, "ERROR_DS_DST_NC_MISMATCH")); - errorNames.insert(std::make_pair(8487, "ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC")); - errorNames.insert(std::make_pair(8488, "ERROR_DS_SRC_GUID_MISMATCH")); - errorNames.insert(std::make_pair(8489, "ERROR_DS_CANT_MOVE_DELETED_OBJECT")); - errorNames.insert(std::make_pair(8490, "ERROR_DS_PDC_OPERATION_IN_PROGRESS")); - errorNames.insert(std::make_pair(8491, "ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD")); - errorNames.insert(std::make_pair(8492, "ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION")); - errorNames.insert(std::make_pair(8493, "ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS")); - errorNames.insert(std::make_pair(8494, "ERROR_DS_NC_MUST_HAVE_NC_PARENT")); - errorNames.insert(std::make_pair(8495, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE")); - errorNames.insert(std::make_pair(8496, "ERROR_DS_DST_DOMAIN_NOT_NATIVE")); - errorNames.insert(std::make_pair(8497, "ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER")); - errorNames.insert(std::make_pair(8498, "ERROR_DS_CANT_MOVE_ACCOUNT_GROUP")); - errorNames.insert(std::make_pair(8499, "ERROR_DS_CANT_MOVE_RESOURCE_GROUP")); - errorNames.insert(std::make_pair(8500, "ERROR_DS_INVALID_SEARCH_FLAG")); - errorNames.insert(std::make_pair(8501, "ERROR_DS_NO_TREE_DELETE_ABOVE_NC")); - errorNames.insert(std::make_pair(8502, "ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE")); - errorNames.insert(std::make_pair(8503, "ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE")); - errorNames.insert(std::make_pair(8504, "ERROR_DS_SAM_INIT_FAILURE")); - errorNames.insert(std::make_pair(8505, "ERROR_DS_SENSITIVE_GROUP_VIOLATION")); - errorNames.insert(std::make_pair(8506, "ERROR_DS_CANT_MOD_PRIMARYGROUPID")); - errorNames.insert(std::make_pair(8507, "ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD")); - errorNames.insert(std::make_pair(8508, "ERROR_DS_NONSAFE_SCHEMA_CHANGE")); - errorNames.insert(std::make_pair(8509, "ERROR_DS_SCHEMA_UPDATE_DISALLOWED")); - errorNames.insert(std::make_pair(8510, "ERROR_DS_CANT_CREATE_UNDER_SCHEMA")); - errorNames.insert(std::make_pair(8511, "ERROR_DS_INSTALL_NO_SRC_SCH_VERSION")); - errorNames.insert(std::make_pair(8512, "ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE")); - errorNames.insert(std::make_pair(8513, "ERROR_DS_INVALID_GROUP_TYPE")); - errorNames.insert(std::make_pair(8514, "ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN")); - errorNames.insert(std::make_pair(8515, "ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN")); - errorNames.insert(std::make_pair(8516, "ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER")); - errorNames.insert(std::make_pair(8517, "ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER")); - errorNames.insert(std::make_pair(8518, "ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER")); - errorNames.insert(std::make_pair(8519, "ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER")); - errorNames.insert(std::make_pair(8520, "ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER")); - errorNames.insert(std::make_pair(8521, "ERROR_DS_HAVE_PRIMARY_MEMBERS")); - errorNames.insert(std::make_pair(8522, "ERROR_DS_STRING_SD_CONVERSION_FAILED")); - errorNames.insert(std::make_pair(8523, "ERROR_DS_NAMING_MASTER_GC")); - errorNames.insert(std::make_pair(8524, "ERROR_DS_DNS_LOOKUP_FAILURE")); - errorNames.insert(std::make_pair(8525, "ERROR_DS_COULDNT_UPDATE_SPNS")); - errorNames.insert(std::make_pair(8526, "ERROR_DS_CANT_RETRIEVE_SD")); - errorNames.insert(std::make_pair(8527, "ERROR_DS_KEY_NOT_UNIQUE")); - errorNames.insert(std::make_pair(8528, "ERROR_DS_WRONG_LINKED_ATT_SYNTAX")); - errorNames.insert(std::make_pair(8529, "ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD")); - errorNames.insert(std::make_pair(8530, "ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY")); - errorNames.insert(std::make_pair(8531, "ERROR_DS_CANT_START")); - errorNames.insert(std::make_pair(8532, "ERROR_DS_INIT_FAILURE")); - errorNames.insert(std::make_pair(8533, "ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION")); - errorNames.insert(std::make_pair(8534, "ERROR_DS_SOURCE_DOMAIN_IN_FOREST")); - errorNames.insert(std::make_pair(8535, "ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST")); - errorNames.insert(std::make_pair(8536, "ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED")); - errorNames.insert(std::make_pair(8537, "ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN")); - errorNames.insert(std::make_pair(8538, "ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER")); - errorNames.insert(std::make_pair(8539, "ERROR_DS_SRC_SID_EXISTS_IN_FOREST")); - errorNames.insert(std::make_pair(8540, "ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH")); - errorNames.insert(std::make_pair(8541, "ERROR_SAM_INIT_FAILURE")); - errorNames.insert(std::make_pair(8542, "ERROR_DS_DRA_SCHEMA_INFO_SHIP")); - errorNames.insert(std::make_pair(8543, "ERROR_DS_DRA_SCHEMA_CONFLICT")); - errorNames.insert(std::make_pair(8544, "ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT")); - errorNames.insert(std::make_pair(8545, "ERROR_DS_DRA_OBJ_NC_MISMATCH")); - errorNames.insert(std::make_pair(8546, "ERROR_DS_NC_STILL_HAS_DSAS")); - errorNames.insert(std::make_pair(8547, "ERROR_DS_GC_REQUIRED")); - errorNames.insert(std::make_pair(8548, "ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY")); - errorNames.insert(std::make_pair(8549, "ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS")); - errorNames.insert(std::make_pair(8550, "ERROR_DS_CANT_ADD_TO_GC")); - errorNames.insert(std::make_pair(8551, "ERROR_DS_NO_CHECKPOINT_WITH_PDC")); - errorNames.insert(std::make_pair(8552, "ERROR_DS_SOURCE_AUDITING_NOT_ENABLED")); - errorNames.insert(std::make_pair(8553, "ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC")); - errorNames.insert(std::make_pair(8554, "ERROR_DS_INVALID_NAME_FOR_SPN")); - errorNames.insert(std::make_pair(8555, "ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS")); - errorNames.insert(std::make_pair(8556, "ERROR_DS_UNICODEPWD_NOT_IN_QUOTES")); - errorNames.insert(std::make_pair(8557, "ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED")); - errorNames.insert(std::make_pair(8558, "ERROR_DS_MUST_BE_RUN_ON_DST_DC")); - errorNames.insert(std::make_pair(8559, "ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER")); - errorNames.insert(std::make_pair(8560, "ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ")); - errorNames.insert(std::make_pair(8561, "ERROR_DS_INIT_FAILURE_CONSOLE")); - errorNames.insert(std::make_pair(8562, "ERROR_DS_SAM_INIT_FAILURE_CONSOLE")); - errorNames.insert(std::make_pair(8563, "ERROR_DS_FOREST_VERSION_TOO_HIGH")); - errorNames.insert(std::make_pair(8564, "ERROR_DS_DOMAIN_VERSION_TOO_HIGH")); - errorNames.insert(std::make_pair(8565, "ERROR_DS_FOREST_VERSION_TOO_LOW")); - errorNames.insert(std::make_pair(8566, "ERROR_DS_DOMAIN_VERSION_TOO_LOW")); - errorNames.insert(std::make_pair(8567, "ERROR_DS_INCOMPATIBLE_VERSION")); - errorNames.insert(std::make_pair(8568, "ERROR_DS_LOW_DSA_VERSION")); - errorNames.insert(std::make_pair(8569, "ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN")); - errorNames.insert(std::make_pair(8570, "ERROR_DS_NOT_SUPPORTED_SORT_ORDER")); - errorNames.insert(std::make_pair(8571, "ERROR_DS_NAME_NOT_UNIQUE")); - errorNames.insert(std::make_pair(8572, "ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4")); - errorNames.insert(std::make_pair(8573, "ERROR_DS_OUT_OF_VERSION_STORE")); - errorNames.insert(std::make_pair(8574, "ERROR_DS_INCOMPATIBLE_CONTROLS_USED")); - errorNames.insert(std::make_pair(8575, "ERROR_DS_NO_REF_DOMAIN")); - errorNames.insert(std::make_pair(8576, "ERROR_DS_RESERVED_LINK_ID")); - errorNames.insert(std::make_pair(8577, "ERROR_DS_LINK_ID_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(8578, "ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER")); - errorNames.insert(std::make_pair(8579, "ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE")); - errorNames.insert(std::make_pair(8580, "ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC")); - errorNames.insert(std::make_pair(8581, "ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG")); - errorNames.insert(std::make_pair(8582, "ERROR_DS_MODIFYDN_WRONG_GRANDPARENT")); - errorNames.insert(std::make_pair(8583, "ERROR_DS_NAME_ERROR_TRUST_REFERRAL")); - errorNames.insert(std::make_pair(8584, "ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER")); - errorNames.insert(std::make_pair(8585, "ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD")); - errorNames.insert(std::make_pair(8586, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2")); - errorNames.insert(std::make_pair(8587, "ERROR_DS_THREAD_LIMIT_EXCEEDED")); - errorNames.insert(std::make_pair(8588, "ERROR_DS_NOT_CLOSEST")); - errorNames.insert(std::make_pair(8589, "ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF")); - errorNames.insert(std::make_pair(8590, "ERROR_DS_SINGLE_USER_MODE_FAILED")); - errorNames.insert(std::make_pair(8591, "ERROR_DS_NTDSCRIPT_SYNTAX_ERROR")); - errorNames.insert(std::make_pair(8592, "ERROR_DS_NTDSCRIPT_PROCESS_ERROR")); - errorNames.insert(std::make_pair(8593, "ERROR_DS_DIFFERENT_REPL_EPOCHS")); - errorNames.insert(std::make_pair(8594, "ERROR_DS_DRS_EXTENSIONS_CHANGED")); - errorNames.insert(std::make_pair(8595, "ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR")); - errorNames.insert(std::make_pair(8596, "ERROR_DS_NO_MSDS_INTID")); - errorNames.insert(std::make_pair(8597, "ERROR_DS_DUP_MSDS_INTID")); - errorNames.insert(std::make_pair(8598, "ERROR_DS_EXISTS_IN_RDNATTID")); - errorNames.insert(std::make_pair(8599, "ERROR_DS_AUTHORIZATION_FAILED")); - errorNames.insert(std::make_pair(8600, "ERROR_DS_INVALID_SCRIPT")); - errorNames.insert(std::make_pair(8601, "ERROR_DS_REMOTE_CROSSREF_OP_FAILED")); - errorNames.insert(std::make_pair(8602, "ERROR_DS_CROSS_REF_BUSY")); - errorNames.insert(std::make_pair(8603, "ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN")); - errorNames.insert(std::make_pair(8604, "ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC")); - errorNames.insert(std::make_pair(8605, "ERROR_DS_DUPLICATE_ID_FOUND")); - errorNames.insert(std::make_pair(8606, "ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT")); - errorNames.insert(std::make_pair(8607, "ERROR_DS_GROUP_CONVERSION_ERROR")); - errorNames.insert(std::make_pair(8608, "ERROR_DS_CANT_MOVE_APP_BASIC_GROUP")); - errorNames.insert(std::make_pair(8609, "ERROR_DS_CANT_MOVE_APP_QUERY_GROUP")); - errorNames.insert(std::make_pair(8610, "ERROR_DS_ROLE_NOT_VERIFIED")); - errorNames.insert(std::make_pair(8611, "ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL")); - errorNames.insert(std::make_pair(8612, "ERROR_DS_DOMAIN_RENAME_IN_PROGRESS")); - errorNames.insert(std::make_pair(8613, "ERROR_DS_EXISTING_AD_CHILD_NC")); - errorNames.insert(std::make_pair(8614, "ERROR_DS_REPL_LIFETIME_EXCEEDED")); - errorNames.insert(std::make_pair(8615, "ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER")); - errorNames.insert(std::make_pair(8616, "ERROR_DS_LDAP_SEND_QUEUE_FULL")); - errorNames.insert(std::make_pair(8617, "ERROR_DS_DRA_OUT_SCHEDULE_WINDOW")); - errorNames.insert(std::make_pair(8618, "ERROR_DS_POLICY_NOT_KNOWN")); - errorNames.insert(std::make_pair(8619, "ERROR_NO_SITE_SETTINGS_OBJECT")); - errorNames.insert(std::make_pair(8620, "ERROR_NO_SECRETS")); - errorNames.insert(std::make_pair(8621, "ERROR_NO_WRITABLE_DC_FOUND")); - errorNames.insert(std::make_pair(8622, "ERROR_DS_NO_SERVER_OBJECT")); - errorNames.insert(std::make_pair(8623, "ERROR_DS_NO_NTDSA_OBJECT")); - errorNames.insert(std::make_pair(8624, "ERROR_DS_NON_ASQ_SEARCH")); - errorNames.insert(std::make_pair(8625, "ERROR_DS_AUDIT_FAILURE")); - errorNames.insert(std::make_pair(8626, "ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE")); - errorNames.insert(std::make_pair(8627, "ERROR_DS_INVALID_SEARCH_FLAG_TUPLE")); - errorNames.insert(std::make_pair(8628, "ERROR_DS_HIERARCHY_TABLE_TOO_DEEP")); - errorNames.insert(std::make_pair(8629, "ERROR_DS_DRA_CORRUPT_UTD_VECTOR")); - errorNames.insert(std::make_pair(8630, "ERROR_DS_DRA_SECRETS_DENIED")); - errorNames.insert(std::make_pair(8631, "ERROR_DS_RESERVED_MAPI_ID")); - errorNames.insert(std::make_pair(8632, "ERROR_DS_MAPI_ID_NOT_AVAILABLE")); - errorNames.insert(std::make_pair(8633, "ERROR_DS_DRA_MISSING_KRBTGT_SECRET")); - errorNames.insert(std::make_pair(8634, "ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST")); - errorNames.insert(std::make_pair(8635, "ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST")); - errorNames.insert(std::make_pair(8636, "ERROR_INVALID_USER_PRINCIPAL_NAME")); - errorNames.insert(std::make_pair(8637, "ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS")); - errorNames.insert(std::make_pair(8638, "ERROR_DS_OID_NOT_FOUND")); - errorNames.insert(std::make_pair(8639, "ERROR_DS_DRA_RECYCLED_TARGET")); - errorNames.insert(std::make_pair(13000, "ERROR_IPSEC_QM_POLICY_EXISTS")); - errorNames.insert(std::make_pair(13001, "ERROR_IPSEC_QM_POLICY_NOT_FOUND")); - errorNames.insert(std::make_pair(13002, "ERROR_IPSEC_QM_POLICY_IN_USE")); - errorNames.insert(std::make_pair(13003, "ERROR_IPSEC_MM_POLICY_EXISTS")); - errorNames.insert(std::make_pair(13004, "ERROR_IPSEC_MM_POLICY_NOT_FOUND")); - errorNames.insert(std::make_pair(13005, "ERROR_IPSEC_MM_POLICY_IN_USE")); - errorNames.insert(std::make_pair(13006, "ERROR_IPSEC_MM_FILTER_EXISTS")); - errorNames.insert(std::make_pair(13007, "ERROR_IPSEC_MM_FILTER_NOT_FOUND")); - errorNames.insert(std::make_pair(13008, "ERROR_IPSEC_TRANSPORT_FILTER_EXISTS")); - errorNames.insert(std::make_pair(13009, "ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND")); - errorNames.insert(std::make_pair(13010, "ERROR_IPSEC_MM_AUTH_EXISTS")); - errorNames.insert(std::make_pair(13011, "ERROR_IPSEC_MM_AUTH_NOT_FOUND")); - errorNames.insert(std::make_pair(13012, "ERROR_IPSEC_MM_AUTH_IN_USE")); - errorNames.insert(std::make_pair(13013, "ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND")); - errorNames.insert(std::make_pair(13014, "ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND")); - errorNames.insert(std::make_pair(13015, "ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND")); - errorNames.insert(std::make_pair(13016, "ERROR_IPSEC_TUNNEL_FILTER_EXISTS")); - errorNames.insert(std::make_pair(13017, "ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND")); - errorNames.insert(std::make_pair(13018, "ERROR_IPSEC_MM_FILTER_PENDING_DELETION")); - errorNames.insert(std::make_pair(13019, "ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION")); - errorNames.insert(std::make_pair(13020, "ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION")); - errorNames.insert(std::make_pair(13021, "ERROR_IPSEC_MM_POLICY_PENDING_DELETION")); - errorNames.insert(std::make_pair(13022, "ERROR_IPSEC_MM_AUTH_PENDING_DELETION")); - errorNames.insert(std::make_pair(13023, "ERROR_IPSEC_QM_POLICY_PENDING_DELETION")); - errorNames.insert(std::make_pair(13800, "ERROR_IPSEC_IKE_NEG_STATUS_BEGIN")); - errorNames.insert(std::make_pair(13801, "ERROR_IPSEC_IKE_AUTH_FAIL")); - errorNames.insert(std::make_pair(13802, "ERROR_IPSEC_IKE_ATTRIB_FAIL")); - errorNames.insert(std::make_pair(13803, "ERROR_IPSEC_IKE_NEGOTIATION_PENDING")); - errorNames.insert(std::make_pair(13804, "ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR")); - errorNames.insert(std::make_pair(13805, "ERROR_IPSEC_IKE_TIMED_OUT")); - errorNames.insert(std::make_pair(13806, "ERROR_IPSEC_IKE_NO_CERT")); - errorNames.insert(std::make_pair(13807, "ERROR_IPSEC_IKE_SA_DELETED")); - errorNames.insert(std::make_pair(13808, "ERROR_IPSEC_IKE_SA_REAPED")); - errorNames.insert(std::make_pair(13809, "ERROR_IPSEC_IKE_MM_ACQUIRE_DROP")); - errorNames.insert(std::make_pair(13810, "ERROR_IPSEC_IKE_QM_ACQUIRE_DROP")); - errorNames.insert(std::make_pair(13811, "ERROR_IPSEC_IKE_QUEUE_DROP_MM")); - errorNames.insert(std::make_pair(13812, "ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM")); - errorNames.insert(std::make_pair(13813, "ERROR_IPSEC_IKE_DROP_NO_RESPONSE")); - errorNames.insert(std::make_pair(13814, "ERROR_IPSEC_IKE_MM_DELAY_DROP")); - errorNames.insert(std::make_pair(13815, "ERROR_IPSEC_IKE_QM_DELAY_DROP")); - errorNames.insert(std::make_pair(13816, "ERROR_IPSEC_IKE_ERROR")); - errorNames.insert(std::make_pair(13817, "ERROR_IPSEC_IKE_CRL_FAILED")); - errorNames.insert(std::make_pair(13818, "ERROR_IPSEC_IKE_INVALID_KEY_USAGE")); - errorNames.insert(std::make_pair(13819, "ERROR_IPSEC_IKE_INVALID_CERT_TYPE")); - errorNames.insert(std::make_pair(13820, "ERROR_IPSEC_IKE_NO_PRIVATE_KEY")); - errorNames.insert(std::make_pair(13821, "ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY")); - errorNames.insert(std::make_pair(13822, "ERROR_IPSEC_IKE_DH_FAIL")); - errorNames.insert(std::make_pair(13823, "ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED")); - errorNames.insert(std::make_pair(13824, "ERROR_IPSEC_IKE_INVALID_HEADER")); - errorNames.insert(std::make_pair(13825, "ERROR_IPSEC_IKE_NO_POLICY")); - errorNames.insert(std::make_pair(13826, "ERROR_IPSEC_IKE_INVALID_SIGNATURE")); - errorNames.insert(std::make_pair(13827, "ERROR_IPSEC_IKE_KERBEROS_ERROR")); - errorNames.insert(std::make_pair(13828, "ERROR_IPSEC_IKE_NO_PUBLIC_KEY")); - errorNames.insert(std::make_pair(13829, "ERROR_IPSEC_IKE_PROCESS_ERR")); - errorNames.insert(std::make_pair(13830, "ERROR_IPSEC_IKE_PROCESS_ERR_SA")); - errorNames.insert(std::make_pair(13831, "ERROR_IPSEC_IKE_PROCESS_ERR_PROP")); - errorNames.insert(std::make_pair(13832, "ERROR_IPSEC_IKE_PROCESS_ERR_TRANS")); - errorNames.insert(std::make_pair(13833, "ERROR_IPSEC_IKE_PROCESS_ERR_KE")); - errorNames.insert(std::make_pair(13834, "ERROR_IPSEC_IKE_PROCESS_ERR_ID")); - errorNames.insert(std::make_pair(13835, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT")); - errorNames.insert(std::make_pair(13836, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ")); - errorNames.insert(std::make_pair(13837, "ERROR_IPSEC_IKE_PROCESS_ERR_HASH")); - errorNames.insert(std::make_pair(13838, "ERROR_IPSEC_IKE_PROCESS_ERR_SIG")); - errorNames.insert(std::make_pair(13839, "ERROR_IPSEC_IKE_PROCESS_ERR_NONCE")); - errorNames.insert(std::make_pair(13840, "ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY")); - errorNames.insert(std::make_pair(13841, "ERROR_IPSEC_IKE_PROCESS_ERR_DELETE")); - errorNames.insert(std::make_pair(13842, "ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR")); - errorNames.insert(std::make_pair(13843, "ERROR_IPSEC_IKE_INVALID_PAYLOAD")); - errorNames.insert(std::make_pair(13844, "ERROR_IPSEC_IKE_LOAD_SOFT_SA")); - errorNames.insert(std::make_pair(13845, "ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN")); - errorNames.insert(std::make_pair(13846, "ERROR_IPSEC_IKE_INVALID_COOKIE")); - errorNames.insert(std::make_pair(13847, "ERROR_IPSEC_IKE_NO_PEER_CERT")); - errorNames.insert(std::make_pair(13848, "ERROR_IPSEC_IKE_PEER_CRL_FAILED")); - errorNames.insert(std::make_pair(13849, "ERROR_IPSEC_IKE_POLICY_CHANGE")); - errorNames.insert(std::make_pair(13850, "ERROR_IPSEC_IKE_NO_MM_POLICY")); - errorNames.insert(std::make_pair(13851, "ERROR_IPSEC_IKE_NOTCBPRIV")); - errorNames.insert(std::make_pair(13852, "ERROR_IPSEC_IKE_SECLOADFAIL")); - errorNames.insert(std::make_pair(13853, "ERROR_IPSEC_IKE_FAILSSPINIT")); - errorNames.insert(std::make_pair(13854, "ERROR_IPSEC_IKE_FAILQUERYSSP")); - errorNames.insert(std::make_pair(13855, "ERROR_IPSEC_IKE_SRVACQFAIL")); - errorNames.insert(std::make_pair(13856, "ERROR_IPSEC_IKE_SRVQUERYCRED")); - errorNames.insert(std::make_pair(13857, "ERROR_IPSEC_IKE_GETSPIFAIL")); - errorNames.insert(std::make_pair(13858, "ERROR_IPSEC_IKE_INVALID_FILTER")); - errorNames.insert(std::make_pair(13859, "ERROR_IPSEC_IKE_OUT_OF_MEMORY")); - errorNames.insert(std::make_pair(13860, "ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED")); - errorNames.insert(std::make_pair(13861, "ERROR_IPSEC_IKE_INVALID_POLICY")); - errorNames.insert(std::make_pair(13862, "ERROR_IPSEC_IKE_UNKNOWN_DOI")); - errorNames.insert(std::make_pair(13863, "ERROR_IPSEC_IKE_INVALID_SITUATION")); - errorNames.insert(std::make_pair(13864, "ERROR_IPSEC_IKE_DH_FAILURE")); - errorNames.insert(std::make_pair(13865, "ERROR_IPSEC_IKE_INVALID_GROUP")); - errorNames.insert(std::make_pair(13866, "ERROR_IPSEC_IKE_ENCRYPT")); - errorNames.insert(std::make_pair(13867, "ERROR_IPSEC_IKE_DECRYPT")); - errorNames.insert(std::make_pair(13868, "ERROR_IPSEC_IKE_POLICY_MATCH")); - errorNames.insert(std::make_pair(13869, "ERROR_IPSEC_IKE_UNSUPPORTED_ID")); - errorNames.insert(std::make_pair(13870, "ERROR_IPSEC_IKE_INVALID_HASH")); - errorNames.insert(std::make_pair(13871, "ERROR_IPSEC_IKE_INVALID_HASH_ALG")); - errorNames.insert(std::make_pair(13872, "ERROR_IPSEC_IKE_INVALID_HASH_SIZE")); - errorNames.insert(std::make_pair(13873, "ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG")); - errorNames.insert(std::make_pair(13874, "ERROR_IPSEC_IKE_INVALID_AUTH_ALG")); - errorNames.insert(std::make_pair(13875, "ERROR_IPSEC_IKE_INVALID_SIG")); - errorNames.insert(std::make_pair(13876, "ERROR_IPSEC_IKE_LOAD_FAILED")); - errorNames.insert(std::make_pair(13877, "ERROR_IPSEC_IKE_RPC_DELETE")); - errorNames.insert(std::make_pair(13878, "ERROR_IPSEC_IKE_BENIGN_REINIT")); - errorNames.insert(std::make_pair(13879, "ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY")); - errorNames.insert(std::make_pair(13880, "ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION")); - errorNames.insert(std::make_pair(13881, "ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN")); - errorNames.insert(std::make_pair(13882, "ERROR_IPSEC_IKE_MM_LIMIT")); - errorNames.insert(std::make_pair(13883, "ERROR_IPSEC_IKE_NEGOTIATION_DISABLED")); - errorNames.insert(std::make_pair(13884, "ERROR_IPSEC_IKE_QM_LIMIT")); - errorNames.insert(std::make_pair(13885, "ERROR_IPSEC_IKE_MM_EXPIRED")); - errorNames.insert(std::make_pair(13886, "ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID")); - errorNames.insert(std::make_pair(13887, "ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH")); - errorNames.insert(std::make_pair(13888, "ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID")); - errorNames.insert(std::make_pair(13889, "ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD")); - errorNames.insert(std::make_pair(13890, "ERROR_IPSEC_IKE_DOS_COOKIE_SENT")); - errorNames.insert(std::make_pair(13891, "ERROR_IPSEC_IKE_SHUTTING_DOWN")); - errorNames.insert(std::make_pair(13892, "ERROR_IPSEC_IKE_CGA_AUTH_FAILED")); - errorNames.insert(std::make_pair(13893, "ERROR_IPSEC_IKE_PROCESS_ERR_NATOA")); - errorNames.insert(std::make_pair(13894, "ERROR_IPSEC_IKE_INVALID_MM_FOR_QM")); - errorNames.insert(std::make_pair(13895, "ERROR_IPSEC_IKE_QM_EXPIRED")); - errorNames.insert(std::make_pair(13896, "ERROR_IPSEC_IKE_TOO_MANY_FILTERS")); - errorNames.insert(std::make_pair(13897, "ERROR_IPSEC_IKE_NEG_STATUS_END")); - errorNames.insert(std::make_pair(13898, "ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL")); - errorNames.insert(std::make_pair(13899, "ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE")); - errorNames.insert(std::make_pair(13900, "ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING")); - errorNames.insert(std::make_pair(13901, "ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING")); - errorNames.insert(std::make_pair(13902, "ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS")); - errorNames.insert(std::make_pair(13903, "ERROR_IPSEC_IKE_RATELIMIT_DROP")); - errorNames.insert(std::make_pair(13904, "ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE")); - errorNames.insert(std::make_pair(13905, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE")); - errorNames.insert(std::make_pair(13906, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE")); - errorNames.insert(std::make_pair(13907, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY")); - errorNames.insert(std::make_pair(13908, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE")); - errorNames.insert(std::make_pair(13909, "ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END")); - errorNames.insert(std::make_pair(13910, "ERROR_IPSEC_BAD_SPI")); - errorNames.insert(std::make_pair(13911, "ERROR_IPSEC_SA_LIFETIME_EXPIRED")); - errorNames.insert(std::make_pair(13912, "ERROR_IPSEC_WRONG_SA")); - errorNames.insert(std::make_pair(13913, "ERROR_IPSEC_REPLAY_CHECK_FAILED")); - errorNames.insert(std::make_pair(13914, "ERROR_IPSEC_INVALID_PACKET")); - errorNames.insert(std::make_pair(13915, "ERROR_IPSEC_INTEGRITY_CHECK_FAILED")); - errorNames.insert(std::make_pair(13916, "ERROR_IPSEC_CLEAR_TEXT_DROP")); - errorNames.insert(std::make_pair(13917, "ERROR_IPSEC_AUTH_FIREWALL_DROP")); - errorNames.insert(std::make_pair(13918, "ERROR_IPSEC_THROTTLE_DROP")); - errorNames.insert(std::make_pair(13925, "ERROR_IPSEC_DOSP_BLOCK")); - errorNames.insert(std::make_pair(13926, "ERROR_IPSEC_DOSP_RECEIVED_MULTICAST")); - errorNames.insert(std::make_pair(13927, "ERROR_IPSEC_DOSP_INVALID_PACKET")); - errorNames.insert(std::make_pair(13928, "ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED")); - errorNames.insert(std::make_pair(13929, "ERROR_IPSEC_DOSP_MAX_ENTRIES")); - errorNames.insert(std::make_pair(13930, "ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED")); - errorNames.insert(std::make_pair(13931, "ERROR_IPSEC_DOSP_NOT_INSTALLED")); - errorNames.insert(std::make_pair(13932, "ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES")); - errorNames.insert(std::make_pair(14000, "ERROR_SXS_SECTION_NOT_FOUND")); - errorNames.insert(std::make_pair(14001, "ERROR_SXS_CANT_GEN_ACTCTX")); - errorNames.insert(std::make_pair(14002, "ERROR_SXS_INVALID_ACTCTXDATA_FORMAT")); - errorNames.insert(std::make_pair(14003, "ERROR_SXS_ASSEMBLY_NOT_FOUND")); - errorNames.insert(std::make_pair(14004, "ERROR_SXS_MANIFEST_FORMAT_ERROR")); - errorNames.insert(std::make_pair(14005, "ERROR_SXS_MANIFEST_PARSE_ERROR")); - errorNames.insert(std::make_pair(14006, "ERROR_SXS_ACTIVATION_CONTEXT_DISABLED")); - errorNames.insert(std::make_pair(14007, "ERROR_SXS_KEY_NOT_FOUND")); - errorNames.insert(std::make_pair(14008, "ERROR_SXS_VERSION_CONFLICT")); - errorNames.insert(std::make_pair(14009, "ERROR_SXS_WRONG_SECTION_TYPE")); - errorNames.insert(std::make_pair(14010, "ERROR_SXS_THREAD_QUERIES_DISABLED")); - errorNames.insert(std::make_pair(14011, "ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET")); - errorNames.insert(std::make_pair(14012, "ERROR_SXS_UNKNOWN_ENCODING_GROUP")); - errorNames.insert(std::make_pair(14013, "ERROR_SXS_UNKNOWN_ENCODING")); - errorNames.insert(std::make_pair(14014, "ERROR_SXS_INVALID_XML_NAMESPACE_URI")); - errorNames.insert(std::make_pair(14015, "ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED")); - errorNames.insert(std::make_pair(14016, "ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED")); - errorNames.insert(std::make_pair(14017, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE")); - errorNames.insert(std::make_pair(14018, "ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE")); - errorNames.insert(std::make_pair(14019, "ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE")); - errorNames.insert(std::make_pair(14020, "ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT")); - errorNames.insert(std::make_pair(14021, "ERROR_SXS_DUPLICATE_DLL_NAME")); - errorNames.insert(std::make_pair(14022, "ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME")); - errorNames.insert(std::make_pair(14023, "ERROR_SXS_DUPLICATE_CLSID")); - errorNames.insert(std::make_pair(14024, "ERROR_SXS_DUPLICATE_IID")); - errorNames.insert(std::make_pair(14025, "ERROR_SXS_DUPLICATE_TLBID")); - errorNames.insert(std::make_pair(14026, "ERROR_SXS_DUPLICATE_PROGID")); - errorNames.insert(std::make_pair(14027, "ERROR_SXS_DUPLICATE_ASSEMBLY_NAME")); - errorNames.insert(std::make_pair(14028, "ERROR_SXS_FILE_HASH_MISMATCH")); - errorNames.insert(std::make_pair(14029, "ERROR_SXS_POLICY_PARSE_ERROR")); - errorNames.insert(std::make_pair(14030, "ERROR_SXS_XML_E_MISSINGQUOTE")); - errorNames.insert(std::make_pair(14031, "ERROR_SXS_XML_E_COMMENTSYNTAX")); - errorNames.insert(std::make_pair(14032, "ERROR_SXS_XML_E_BADSTARTNAMECHAR")); - errorNames.insert(std::make_pair(14033, "ERROR_SXS_XML_E_BADNAMECHAR")); - errorNames.insert(std::make_pair(14034, "ERROR_SXS_XML_E_BADCHARINSTRING")); - errorNames.insert(std::make_pair(14035, "ERROR_SXS_XML_E_XMLDECLSYNTAX")); - errorNames.insert(std::make_pair(14036, "ERROR_SXS_XML_E_BADCHARDATA")); - errorNames.insert(std::make_pair(14037, "ERROR_SXS_XML_E_MISSINGWHITESPACE")); - errorNames.insert(std::make_pair(14038, "ERROR_SXS_XML_E_EXPECTINGTAGEND")); - errorNames.insert(std::make_pair(14039, "ERROR_SXS_XML_E_MISSINGSEMICOLON")); - errorNames.insert(std::make_pair(14040, "ERROR_SXS_XML_E_UNBALANCEDPAREN")); - errorNames.insert(std::make_pair(14041, "ERROR_SXS_XML_E_INTERNALERROR")); - errorNames.insert(std::make_pair(14042, "ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE")); - errorNames.insert(std::make_pair(14043, "ERROR_SXS_XML_E_INCOMPLETE_ENCODING")); - errorNames.insert(std::make_pair(14044, "ERROR_SXS_XML_E_MISSING_PAREN")); - errorNames.insert(std::make_pair(14045, "ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE")); - errorNames.insert(std::make_pair(14046, "ERROR_SXS_XML_E_MULTIPLE_COLONS")); - errorNames.insert(std::make_pair(14047, "ERROR_SXS_XML_E_INVALID_DECIMAL")); - errorNames.insert(std::make_pair(14048, "ERROR_SXS_XML_E_INVALID_HEXIDECIMAL")); - errorNames.insert(std::make_pair(14049, "ERROR_SXS_XML_E_INVALID_UNICODE")); - errorNames.insert(std::make_pair(14050, "ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK")); - errorNames.insert(std::make_pair(14051, "ERROR_SXS_XML_E_UNEXPECTEDENDTAG")); - errorNames.insert(std::make_pair(14052, "ERROR_SXS_XML_E_UNCLOSEDTAG")); - errorNames.insert(std::make_pair(14053, "ERROR_SXS_XML_E_DUPLICATEATTRIBUTE")); - errorNames.insert(std::make_pair(14054, "ERROR_SXS_XML_E_MULTIPLEROOTS")); - errorNames.insert(std::make_pair(14055, "ERROR_SXS_XML_E_INVALIDATROOTLEVEL")); - errorNames.insert(std::make_pair(14056, "ERROR_SXS_XML_E_BADXMLDECL")); - errorNames.insert(std::make_pair(14057, "ERROR_SXS_XML_E_MISSINGROOT")); - errorNames.insert(std::make_pair(14058, "ERROR_SXS_XML_E_UNEXPECTEDEOF")); - errorNames.insert(std::make_pair(14059, "ERROR_SXS_XML_E_BADPEREFINSUBSET")); - errorNames.insert(std::make_pair(14060, "ERROR_SXS_XML_E_UNCLOSEDSTARTTAG")); - errorNames.insert(std::make_pair(14061, "ERROR_SXS_XML_E_UNCLOSEDENDTAG")); - errorNames.insert(std::make_pair(14062, "ERROR_SXS_XML_E_UNCLOSEDSTRING")); - errorNames.insert(std::make_pair(14063, "ERROR_SXS_XML_E_UNCLOSEDCOMMENT")); - errorNames.insert(std::make_pair(14064, "ERROR_SXS_XML_E_UNCLOSEDDECL")); - errorNames.insert(std::make_pair(14065, "ERROR_SXS_XML_E_UNCLOSEDCDATA")); - errorNames.insert(std::make_pair(14066, "ERROR_SXS_XML_E_RESERVEDNAMESPACE")); - errorNames.insert(std::make_pair(14067, "ERROR_SXS_XML_E_INVALIDENCODING")); - errorNames.insert(std::make_pair(14068, "ERROR_SXS_XML_E_INVALIDSWITCH")); - errorNames.insert(std::make_pair(14069, "ERROR_SXS_XML_E_BADXMLCASE")); - errorNames.insert(std::make_pair(14070, "ERROR_SXS_XML_E_INVALID_STANDALONE")); - errorNames.insert(std::make_pair(14071, "ERROR_SXS_XML_E_UNEXPECTED_STANDALONE")); - errorNames.insert(std::make_pair(14072, "ERROR_SXS_XML_E_INVALID_VERSION")); - errorNames.insert(std::make_pair(14073, "ERROR_SXS_XML_E_MISSINGEQUALS")); - errorNames.insert(std::make_pair(14074, "ERROR_SXS_PROTECTION_RECOVERY_FAILED")); - errorNames.insert(std::make_pair(14075, "ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT")); - errorNames.insert(std::make_pair(14076, "ERROR_SXS_PROTECTION_CATALOG_NOT_VALID")); - errorNames.insert(std::make_pair(14077, "ERROR_SXS_UNTRANSLATABLE_HRESULT")); - errorNames.insert(std::make_pair(14078, "ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING")); - errorNames.insert(std::make_pair(14079, "ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE")); - errorNames.insert(std::make_pair(14080, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME")); - errorNames.insert(std::make_pair(14081, "ERROR_SXS_ASSEMBLY_MISSING")); - errorNames.insert(std::make_pair(14082, "ERROR_SXS_CORRUPT_ACTIVATION_STACK")); - errorNames.insert(std::make_pair(14083, "ERROR_SXS_CORRUPTION")); - errorNames.insert(std::make_pair(14084, "ERROR_SXS_EARLY_DEACTIVATION")); - errorNames.insert(std::make_pair(14085, "ERROR_SXS_INVALID_DEACTIVATION")); - errorNames.insert(std::make_pair(14086, "ERROR_SXS_MULTIPLE_DEACTIVATION")); - errorNames.insert(std::make_pair(14087, "ERROR_SXS_PROCESS_TERMINATION_REQUESTED")); - errorNames.insert(std::make_pair(14088, "ERROR_SXS_RELEASE_ACTIVATION_CONTEXT")); - errorNames.insert(std::make_pair(14089, "ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY")); - errorNames.insert(std::make_pair(14090, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE")); - errorNames.insert(std::make_pair(14091, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME")); - errorNames.insert(std::make_pair(14092, "ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE")); - errorNames.insert(std::make_pair(14093, "ERROR_SXS_IDENTITY_PARSE_ERROR")); - errorNames.insert(std::make_pair(14094, "ERROR_MALFORMED_SUBSTITUTION_STRING")); - errorNames.insert(std::make_pair(14095, "ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN")); - errorNames.insert(std::make_pair(14096, "ERROR_UNMAPPED_SUBSTITUTION_STRING")); - errorNames.insert(std::make_pair(14097, "ERROR_SXS_ASSEMBLY_NOT_LOCKED")); - errorNames.insert(std::make_pair(14098, "ERROR_SXS_COMPONENT_STORE_CORRUPT")); - errorNames.insert(std::make_pair(14099, "ERROR_ADVANCED_INSTALLER_FAILED")); - errorNames.insert(std::make_pair(14100, "ERROR_XML_ENCODING_MISMATCH")); - errorNames.insert(std::make_pair(14101, "ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT")); - errorNames.insert(std::make_pair(14102, "ERROR_SXS_IDENTITIES_DIFFERENT")); - errorNames.insert(std::make_pair(14103, "ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT")); - errorNames.insert(std::make_pair(14104, "ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY")); - errorNames.insert(std::make_pair(14105, "ERROR_SXS_MANIFEST_TOO_BIG")); - errorNames.insert(std::make_pair(14106, "ERROR_SXS_SETTING_NOT_REGISTERED")); - errorNames.insert(std::make_pair(14107, "ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE")); - errorNames.insert(std::make_pair(14108, "ERROR_SMI_PRIMITIVE_INSTALLER_FAILED")); - errorNames.insert(std::make_pair(14109, "ERROR_GENERIC_COMMAND_FAILED")); - errorNames.insert(std::make_pair(14110, "ERROR_SXS_FILE_HASH_MISSING")); - errorNames.insert(std::make_pair(15000, "ERROR_EVT_INVALID_CHANNEL_PATH")); - errorNames.insert(std::make_pair(15001, "ERROR_EVT_INVALID_QUERY")); - errorNames.insert(std::make_pair(15002, "ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND")); - errorNames.insert(std::make_pair(15003, "ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND")); - errorNames.insert(std::make_pair(15004, "ERROR_EVT_INVALID_PUBLISHER_NAME")); - errorNames.insert(std::make_pair(15005, "ERROR_EVT_INVALID_EVENT_DATA")); - errorNames.insert(std::make_pair(15007, "ERROR_EVT_CHANNEL_NOT_FOUND")); - errorNames.insert(std::make_pair(15008, "ERROR_EVT_MALFORMED_XML_TEXT")); - errorNames.insert(std::make_pair(15009, "ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL")); - errorNames.insert(std::make_pair(15010, "ERROR_EVT_CONFIGURATION_ERROR")); - errorNames.insert(std::make_pair(15011, "ERROR_EVT_QUERY_RESULT_STALE")); - errorNames.insert(std::make_pair(15012, "ERROR_EVT_QUERY_RESULT_INVALID_POSITION")); - errorNames.insert(std::make_pair(15013, "ERROR_EVT_NON_VALIDATING_MSXML")); - errorNames.insert(std::make_pair(15014, "ERROR_EVT_FILTER_ALREADYSCOPED")); - errorNames.insert(std::make_pair(15015, "ERROR_EVT_FILTER_NOTELTSET")); - errorNames.insert(std::make_pair(15016, "ERROR_EVT_FILTER_INVARG")); - errorNames.insert(std::make_pair(15017, "ERROR_EVT_FILTER_INVTEST")); - errorNames.insert(std::make_pair(15018, "ERROR_EVT_FILTER_INVTYPE")); - errorNames.insert(std::make_pair(15019, "ERROR_EVT_FILTER_PARSEERR")); - errorNames.insert(std::make_pair(15020, "ERROR_EVT_FILTER_UNSUPPORTEDOP")); - errorNames.insert(std::make_pair(15021, "ERROR_EVT_FILTER_UNEXPECTEDTOKEN")); - errorNames.insert(std::make_pair(15022, "ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL")); - errorNames.insert(std::make_pair(15023, "ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE")); - errorNames.insert(std::make_pair(15024, "ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE")); - errorNames.insert(std::make_pair(15025, "ERROR_EVT_CHANNEL_CANNOT_ACTIVATE")); - errorNames.insert(std::make_pair(15026, "ERROR_EVT_FILTER_TOO_COMPLEX")); - errorNames.insert(std::make_pair(15027, "ERROR_EVT_MESSAGE_NOT_FOUND")); - errorNames.insert(std::make_pair(15028, "ERROR_EVT_MESSAGE_ID_NOT_FOUND")); - errorNames.insert(std::make_pair(15029, "ERROR_EVT_UNRESOLVED_VALUE_INSERT")); - errorNames.insert(std::make_pair(15030, "ERROR_EVT_UNRESOLVED_PARAMETER_INSERT")); - errorNames.insert(std::make_pair(15031, "ERROR_EVT_MAX_INSERTS_REACHED")); - errorNames.insert(std::make_pair(15032, "ERROR_EVT_EVENT_DEFINITION_NOT_FOUND")); - errorNames.insert(std::make_pair(15033, "ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND")); - errorNames.insert(std::make_pair(15034, "ERROR_EVT_VERSION_TOO_OLD")); - errorNames.insert(std::make_pair(15035, "ERROR_EVT_VERSION_TOO_NEW")); - errorNames.insert(std::make_pair(15036, "ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY")); - errorNames.insert(std::make_pair(15037, "ERROR_EVT_PUBLISHER_DISABLED")); - errorNames.insert(std::make_pair(15038, "ERROR_EVT_FILTER_OUT_OF_RANGE")); - errorNames.insert(std::make_pair(15080, "ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE")); - errorNames.insert(std::make_pair(15081, "ERROR_EC_LOG_DISABLED")); - errorNames.insert(std::make_pair(15082, "ERROR_EC_CIRCULAR_FORWARDING")); - errorNames.insert(std::make_pair(15083, "ERROR_EC_CREDSTORE_FULL")); - errorNames.insert(std::make_pair(15084, "ERROR_EC_CRED_NOT_FOUND")); - errorNames.insert(std::make_pair(15085, "ERROR_EC_NO_ACTIVE_CHANNEL")); - errorNames.insert(std::make_pair(15100, "ERROR_MUI_FILE_NOT_FOUND")); - errorNames.insert(std::make_pair(15101, "ERROR_MUI_INVALID_FILE")); - errorNames.insert(std::make_pair(15102, "ERROR_MUI_INVALID_RC_CONFIG")); - errorNames.insert(std::make_pair(15103, "ERROR_MUI_INVALID_LOCALE_NAME")); - errorNames.insert(std::make_pair(15104, "ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME")); - errorNames.insert(std::make_pair(15105, "ERROR_MUI_FILE_NOT_LOADED")); - errorNames.insert(std::make_pair(15106, "ERROR_RESOURCE_ENUM_USER_STOP")); - errorNames.insert(std::make_pair(15107, "ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED")); - errorNames.insert(std::make_pair(15108, "ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME")); - errorNames.insert(std::make_pair(15200, "ERROR_MCA_INVALID_CAPABILITIES_STRING")); - errorNames.insert(std::make_pair(15201, "ERROR_MCA_INVALID_VCP_VERSION")); - errorNames.insert(std::make_pair(15202, "ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION")); - errorNames.insert(std::make_pair(15203, "ERROR_MCA_MCCS_VERSION_MISMATCH")); - errorNames.insert(std::make_pair(15204, "ERROR_MCA_UNSUPPORTED_MCCS_VERSION")); - errorNames.insert(std::make_pair(15205, "ERROR_MCA_INTERNAL_ERROR")); - errorNames.insert(std::make_pair(15206, "ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED")); - errorNames.insert(std::make_pair(15207, "ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE")); - errorNames.insert(std::make_pair(15250, "ERROR_AMBIGUOUS_SYSTEM_DEVICE")); - errorNames.insert(std::make_pair(15299, "ERROR_SYSTEM_DEVICE_NOT_FOUND")); - errorNames.insert(std::make_pair(15300, "ERROR_HASH_NOT_SUPPORTED")); - errorNames.insert(std::make_pair(15301, "ERROR_HASH_NOT_PRESENT")); + ErrorNames.insert(std::make_pair(0, "ERROR_SUCCESS")); + ErrorNames.insert(std::make_pair(1, "ERROR_INVALID_FUNCTION")); + ErrorNames.insert(std::make_pair(2, "ERROR_FILE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(3, "ERROR_PATH_NOT_FOUND")); + ErrorNames.insert(std::make_pair(4, "ERROR_TOO_MANY_OPEN_FILES")); + ErrorNames.insert(std::make_pair(5, "ERROR_ACCESS_DENIED")); + ErrorNames.insert(std::make_pair(6, "ERROR_INVALID_HANDLE")); + ErrorNames.insert(std::make_pair(7, "ERROR_ARENA_TRASHED")); + ErrorNames.insert(std::make_pair(8, "ERROR_NOT_ENOUGH_MEMORY")); + ErrorNames.insert(std::make_pair(9, "ERROR_INVALID_BLOCK")); + ErrorNames.insert(std::make_pair(10, "ERROR_BAD_ENVIRONMENT")); + ErrorNames.insert(std::make_pair(11, "ERROR_BAD_FORMAT")); + ErrorNames.insert(std::make_pair(12, "ERROR_INVALID_ACCESS")); + ErrorNames.insert(std::make_pair(13, "ERROR_INVALID_DATA")); + ErrorNames.insert(std::make_pair(14, "ERROR_OUTOFMEMORY")); + ErrorNames.insert(std::make_pair(15, "ERROR_INVALID_DRIVE")); + ErrorNames.insert(std::make_pair(16, "ERROR_CURRENT_DIRECTORY")); + ErrorNames.insert(std::make_pair(17, "ERROR_NOT_SAME_DEVICE")); + ErrorNames.insert(std::make_pair(18, "ERROR_NO_MORE_FILES")); + ErrorNames.insert(std::make_pair(19, "ERROR_WRITE_PROTECT")); + ErrorNames.insert(std::make_pair(20, "ERROR_BAD_UNIT")); + ErrorNames.insert(std::make_pair(21, "ERROR_NOT_READY")); + ErrorNames.insert(std::make_pair(22, "ERROR_BAD_COMMAND")); + ErrorNames.insert(std::make_pair(23, "ERROR_CRC")); + ErrorNames.insert(std::make_pair(24, "ERROR_BAD_LENGTH")); + ErrorNames.insert(std::make_pair(25, "ERROR_SEEK")); + ErrorNames.insert(std::make_pair(26, "ERROR_NOT_DOS_DISK")); + ErrorNames.insert(std::make_pair(27, "ERROR_SECTOR_NOT_FOUND")); + ErrorNames.insert(std::make_pair(28, "ERROR_OUT_OF_PAPER")); + ErrorNames.insert(std::make_pair(29, "ERROR_WRITE_FAULT")); + ErrorNames.insert(std::make_pair(30, "ERROR_READ_FAULT")); + ErrorNames.insert(std::make_pair(31, "ERROR_GEN_FAILURE")); + ErrorNames.insert(std::make_pair(32, "ERROR_SHARING_VIOLATION")); + ErrorNames.insert(std::make_pair(33, "ERROR_LOCK_VIOLATION")); + ErrorNames.insert(std::make_pair(34, "ERROR_WRONG_DISK")); + ErrorNames.insert(std::make_pair(36, "ERROR_SHARING_BUFFER_EXCEEDED")); + ErrorNames.insert(std::make_pair(38, "ERROR_HANDLE_EOF")); + ErrorNames.insert(std::make_pair(39, "ERROR_HANDLE_DISK_FULL")); + ErrorNames.insert(std::make_pair(50, "ERROR_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(51, "ERROR_REM_NOT_LIST")); + ErrorNames.insert(std::make_pair(52, "ERROR_DUP_NAME")); + ErrorNames.insert(std::make_pair(53, "ERROR_BAD_NETPATH")); + ErrorNames.insert(std::make_pair(54, "ERROR_NETWORK_BUSY")); + ErrorNames.insert(std::make_pair(55, "ERROR_DEV_NOT_EXIST")); + ErrorNames.insert(std::make_pair(56, "ERROR_TOO_MANY_CMDS")); + ErrorNames.insert(std::make_pair(57, "ERROR_ADAP_HDW_ERR")); + ErrorNames.insert(std::make_pair(58, "ERROR_BAD_NET_RESP")); + ErrorNames.insert(std::make_pair(59, "ERROR_UNEXP_NET_ERR")); + ErrorNames.insert(std::make_pair(60, "ERROR_BAD_REM_ADAP")); + ErrorNames.insert(std::make_pair(61, "ERROR_PRINTQ_FULL")); + ErrorNames.insert(std::make_pair(62, "ERROR_NO_SPOOL_SPACE")); + ErrorNames.insert(std::make_pair(63, "ERROR_PRINT_CANCELLED")); + ErrorNames.insert(std::make_pair(64, "ERROR_NETNAME_DELETED")); + ErrorNames.insert(std::make_pair(65, "ERROR_NETWORK_ACCESS_DENIED")); + ErrorNames.insert(std::make_pair(66, "ERROR_BAD_DEV_TYPE")); + ErrorNames.insert(std::make_pair(67, "ERROR_BAD_NET_NAME")); + ErrorNames.insert(std::make_pair(68, "ERROR_TOO_MANY_NAMES")); + ErrorNames.insert(std::make_pair(69, "ERROR_TOO_MANY_SESS")); + ErrorNames.insert(std::make_pair(70, "ERROR_SHARING_PAUSED")); + ErrorNames.insert(std::make_pair(71, "ERROR_REQ_NOT_ACCEP")); + ErrorNames.insert(std::make_pair(72, "ERROR_REDIR_PAUSED")); + ErrorNames.insert(std::make_pair(80, "ERROR_FILE_EXISTS")); + ErrorNames.insert(std::make_pair(82, "ERROR_CANNOT_MAKE")); + ErrorNames.insert(std::make_pair(83, "ERROR_FAIL_I24")); + ErrorNames.insert(std::make_pair(84, "ERROR_OUT_OF_STRUCTURES")); + ErrorNames.insert(std::make_pair(85, "ERROR_ALREADY_ASSIGNED")); + ErrorNames.insert(std::make_pair(86, "ERROR_INVALID_PASSWORD")); + ErrorNames.insert(std::make_pair(87, "ERROR_INVALID_PARAMETER")); + ErrorNames.insert(std::make_pair(88, "ERROR_NET_WRITE_FAULT")); + ErrorNames.insert(std::make_pair(89, "ERROR_NO_PROC_SLOTS")); + ErrorNames.insert(std::make_pair(100, "ERROR_TOO_MANY_SEMAPHORES")); + ErrorNames.insert(std::make_pair(101, "ERROR_EXCL_SEM_ALREADY_OWNED")); + ErrorNames.insert(std::make_pair(102, "ERROR_SEM_IS_SET")); + ErrorNames.insert(std::make_pair(103, "ERROR_TOO_MANY_SEM_REQUESTS")); + ErrorNames.insert(std::make_pair(104, "ERROR_INVALID_AT_INTERRUPT_TIME")); + ErrorNames.insert(std::make_pair(105, "ERROR_SEM_OWNER_DIED")); + ErrorNames.insert(std::make_pair(106, "ERROR_SEM_USER_LIMIT")); + ErrorNames.insert(std::make_pair(107, "ERROR_DISK_CHANGE")); + ErrorNames.insert(std::make_pair(108, "ERROR_DRIVE_LOCKED")); + ErrorNames.insert(std::make_pair(109, "ERROR_BROKEN_PIPE")); + ErrorNames.insert(std::make_pair(110, "ERROR_OPEN_FAILED")); + ErrorNames.insert(std::make_pair(111, "ERROR_BUFFER_OVERFLOW")); + ErrorNames.insert(std::make_pair(112, "ERROR_DISK_FULL")); + ErrorNames.insert(std::make_pair(113, "ERROR_NO_MORE_SEARCH_HANDLES")); + ErrorNames.insert(std::make_pair(114, "ERROR_INVALID_TARGET_HANDLE")); + ErrorNames.insert(std::make_pair(117, "ERROR_INVALID_CATEGORY")); + ErrorNames.insert(std::make_pair(118, "ERROR_INVALID_VERIFY_SWITCH")); + ErrorNames.insert(std::make_pair(119, "ERROR_BAD_DRIVER_LEVEL")); + ErrorNames.insert(std::make_pair(120, "ERROR_CALL_NOT_IMPLEMENTED")); + ErrorNames.insert(std::make_pair(121, "ERROR_SEM_TIMEOUT")); + ErrorNames.insert(std::make_pair(122, "ERROR_INSUFFICIENT_BUFFER")); + ErrorNames.insert(std::make_pair(123, "ERROR_INVALID_NAME")); + ErrorNames.insert(std::make_pair(124, "ERROR_INVALID_LEVEL")); + ErrorNames.insert(std::make_pair(125, "ERROR_NO_VOLUME_LABEL")); + ErrorNames.insert(std::make_pair(126, "ERROR_MOD_NOT_FOUND")); + ErrorNames.insert(std::make_pair(127, "ERROR_PROC_NOT_FOUND")); + ErrorNames.insert(std::make_pair(128, "ERROR_WAIT_NO_CHILDREN")); + ErrorNames.insert(std::make_pair(129, "ERROR_CHILD_NOT_COMPLETE")); + ErrorNames.insert(std::make_pair(130, "ERROR_DIRECT_ACCESS_HANDLE")); + ErrorNames.insert(std::make_pair(131, "ERROR_NEGATIVE_SEEK")); + ErrorNames.insert(std::make_pair(132, "ERROR_SEEK_ON_DEVICE")); + ErrorNames.insert(std::make_pair(133, "ERROR_IS_JOIN_TARGET")); + ErrorNames.insert(std::make_pair(134, "ERROR_IS_JOINED")); + ErrorNames.insert(std::make_pair(135, "ERROR_IS_SUBSTED")); + ErrorNames.insert(std::make_pair(136, "ERROR_NOT_JOINED")); + ErrorNames.insert(std::make_pair(137, "ERROR_NOT_SUBSTED")); + ErrorNames.insert(std::make_pair(138, "ERROR_JOIN_TO_JOIN")); + ErrorNames.insert(std::make_pair(139, "ERROR_SUBST_TO_SUBST")); + ErrorNames.insert(std::make_pair(140, "ERROR_JOIN_TO_SUBST")); + ErrorNames.insert(std::make_pair(141, "ERROR_SUBST_TO_JOIN")); + ErrorNames.insert(std::make_pair(142, "ERROR_BUSY_DRIVE")); + ErrorNames.insert(std::make_pair(143, "ERROR_SAME_DRIVE")); + ErrorNames.insert(std::make_pair(144, "ERROR_DIR_NOT_ROOT")); + ErrorNames.insert(std::make_pair(145, "ERROR_DIR_NOT_EMPTY")); + ErrorNames.insert(std::make_pair(146, "ERROR_IS_SUBST_PATH")); + ErrorNames.insert(std::make_pair(147, "ERROR_IS_JOIN_PATH")); + ErrorNames.insert(std::make_pair(148, "ERROR_PATH_BUSY")); + ErrorNames.insert(std::make_pair(149, "ERROR_IS_SUBST_TARGET")); + ErrorNames.insert(std::make_pair(150, "ERROR_SYSTEM_TRACE")); + ErrorNames.insert(std::make_pair(151, "ERROR_INVALID_EVENT_COUNT")); + ErrorNames.insert(std::make_pair(152, "ERROR_TOO_MANY_MUXWAITERS")); + ErrorNames.insert(std::make_pair(153, "ERROR_INVALID_LIST_FORMAT")); + ErrorNames.insert(std::make_pair(154, "ERROR_LABEL_TOO_LONG")); + ErrorNames.insert(std::make_pair(155, "ERROR_TOO_MANY_TCBS")); + ErrorNames.insert(std::make_pair(156, "ERROR_SIGNAL_REFUSED")); + ErrorNames.insert(std::make_pair(157, "ERROR_DISCARDED")); + ErrorNames.insert(std::make_pair(158, "ERROR_NOT_LOCKED")); + ErrorNames.insert(std::make_pair(159, "ERROR_BAD_THREADID_ADDR")); + ErrorNames.insert(std::make_pair(160, "ERROR_BAD_ARGUMENTS")); + ErrorNames.insert(std::make_pair(161, "ERROR_BAD_PATHNAME")); + ErrorNames.insert(std::make_pair(162, "ERROR_SIGNAL_PENDING")); + ErrorNames.insert(std::make_pair(164, "ERROR_MAX_THRDS_REACHED")); + ErrorNames.insert(std::make_pair(167, "ERROR_LOCK_FAILED")); + ErrorNames.insert(std::make_pair(170, "ERROR_BUSY")); + ErrorNames.insert(std::make_pair(173, "ERROR_CANCEL_VIOLATION")); + ErrorNames.insert(std::make_pair(174, "ERROR_ATOMIC_LOCKS_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(180, "ERROR_INVALID_SEGMENT_NUMBER")); + ErrorNames.insert(std::make_pair(182, "ERROR_INVALID_ORDINAL")); + ErrorNames.insert(std::make_pair(183, "ERROR_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(186, "ERROR_INVALID_FLAG_NUMBER")); + ErrorNames.insert(std::make_pair(187, "ERROR_SEM_NOT_FOUND")); + ErrorNames.insert(std::make_pair(188, "ERROR_INVALID_STARTING_CODESEG")); + ErrorNames.insert(std::make_pair(189, "ERROR_INVALID_STACKSEG")); + ErrorNames.insert(std::make_pair(190, "ERROR_INVALID_MODULETYPE")); + ErrorNames.insert(std::make_pair(191, "ERROR_INVALID_EXE_SIGNATURE")); + ErrorNames.insert(std::make_pair(192, "ERROR_EXE_MARKED_INVALID")); + ErrorNames.insert(std::make_pair(193, "ERROR_BAD_EXE_FORMAT")); + ErrorNames.insert(std::make_pair(194, "ERROR_ITERATED_DATA_EXCEEDS_64k")); + ErrorNames.insert(std::make_pair(195, "ERROR_INVALID_MINALLOCSIZE")); + ErrorNames.insert(std::make_pair(196, "ERROR_DYNLINK_FROM_INVALID_RING")); + ErrorNames.insert(std::make_pair(197, "ERROR_IOPL_NOT_ENABLED")); + ErrorNames.insert(std::make_pair(198, "ERROR_INVALID_SEGDPL")); + ErrorNames.insert(std::make_pair(199, "ERROR_AUTODATASEG_EXCEEDS_64k")); + ErrorNames.insert(std::make_pair(200, "ERROR_RING2SEG_MUST_BE_MOVABLE")); + ErrorNames.insert(std::make_pair(201, "ERROR_RELOC_CHAIN_XEEDS_SEGLIM")); + ErrorNames.insert(std::make_pair(202, "ERROR_INFLOOP_IN_RELOC_CHAIN")); + ErrorNames.insert(std::make_pair(203, "ERROR_ENVVAR_NOT_FOUND")); + ErrorNames.insert(std::make_pair(205, "ERROR_NO_SIGNAL_SENT")); + ErrorNames.insert(std::make_pair(206, "ERROR_FILENAME_EXCED_RANGE")); + ErrorNames.insert(std::make_pair(207, "ERROR_RING2_STACK_IN_USE")); + ErrorNames.insert(std::make_pair(208, "ERROR_META_EXPANSION_TOO_LONG")); + ErrorNames.insert(std::make_pair(209, "ERROR_INVALID_SIGNAL_NUMBER")); + ErrorNames.insert(std::make_pair(210, "ERROR_THREAD_1_INACTIVE")); + ErrorNames.insert(std::make_pair(212, "ERROR_LOCKED")); + ErrorNames.insert(std::make_pair(214, "ERROR_TOO_MANY_MODULES")); + ErrorNames.insert(std::make_pair(215, "ERROR_NESTING_NOT_ALLOWED")); + ErrorNames.insert(std::make_pair(216, "ERROR_EXE_MACHINE_TYPE_MISMATCH")); + ErrorNames.insert(std::make_pair(217, "ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY")); + ErrorNames.insert(std::make_pair(218, "ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY")); + ErrorNames.insert(std::make_pair(220, "ERROR_FILE_CHECKED_OUT")); + ErrorNames.insert(std::make_pair(221, "ERROR_CHECKOUT_REQUIRED")); + ErrorNames.insert(std::make_pair(222, "ERROR_BAD_FILE_TYPE")); + ErrorNames.insert(std::make_pair(223, "ERROR_FILE_TOO_LARGE")); + ErrorNames.insert(std::make_pair(224, "ERROR_FORMS_AUTH_REQUIRED")); + ErrorNames.insert(std::make_pair(225, "ERROR_VIRUS_INFECTED")); + ErrorNames.insert(std::make_pair(226, "ERROR_VIRUS_DELETED")); + ErrorNames.insert(std::make_pair(229, "ERROR_PIPE_LOCAL")); + ErrorNames.insert(std::make_pair(230, "ERROR_BAD_PIPE")); + ErrorNames.insert(std::make_pair(231, "ERROR_PIPE_BUSY")); + ErrorNames.insert(std::make_pair(232, "ERROR_NO_DATA")); + ErrorNames.insert(std::make_pair(233, "ERROR_PIPE_NOT_CONNECTED")); + ErrorNames.insert(std::make_pair(234, "ERROR_MORE_DATA")); + ErrorNames.insert(std::make_pair(240, "ERROR_VC_DISCONNECTED")); + ErrorNames.insert(std::make_pair(254, "ERROR_INVALID_EA_NAME")); + ErrorNames.insert(std::make_pair(255, "ERROR_EA_LIST_INCONSISTENT")); + ErrorNames.insert(std::make_pair(259, "ERROR_NO_MORE_ITEMS")); + ErrorNames.insert(std::make_pair(266, "ERROR_CANNOT_COPY")); + ErrorNames.insert(std::make_pair(267, "ERROR_DIRECTORY")); + ErrorNames.insert(std::make_pair(275, "ERROR_EAS_DIDNT_FIT")); + ErrorNames.insert(std::make_pair(276, "ERROR_EA_FILE_CORRUPT")); + ErrorNames.insert(std::make_pair(277, "ERROR_EA_TABLE_FULL")); + ErrorNames.insert(std::make_pair(278, "ERROR_INVALID_EA_HANDLE")); + ErrorNames.insert(std::make_pair(282, "ERROR_EAS_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(288, "ERROR_NOT_OWNER")); + ErrorNames.insert(std::make_pair(298, "ERROR_TOO_MANY_POSTS")); + ErrorNames.insert(std::make_pair(299, "ERROR_PARTIAL_COPY")); + ErrorNames.insert(std::make_pair(300, "ERROR_OPLOCK_NOT_GRANTED")); + ErrorNames.insert(std::make_pair(301, "ERROR_INVALID_OPLOCK_PROTOCOL")); + ErrorNames.insert(std::make_pair(302, "ERROR_DISK_TOO_FRAGMENTED")); + ErrorNames.insert(std::make_pair(303, "ERROR_DELETE_PENDING")); + ErrorNames.insert(std::make_pair(304, "ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING")); + ErrorNames.insert(std::make_pair(305, "ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME")); + ErrorNames.insert(std::make_pair(306, "ERROR_SECURITY_STREAM_IS_INCONSISTENT")); + ErrorNames.insert(std::make_pair(307, "ERROR_INVALID_LOCK_RANGE")); + ErrorNames.insert(std::make_pair(308, "ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT")); + ErrorNames.insert(std::make_pair(309, "ERROR_NOTIFICATION_GUID_ALREADY_DEFINED")); + ErrorNames.insert(std::make_pair(317, "ERROR_MR_MID_NOT_FOUND")); + ErrorNames.insert(std::make_pair(318, "ERROR_SCOPE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(350, "ERROR_FAIL_NOACTION_REBOOT")); + ErrorNames.insert(std::make_pair(351, "ERROR_FAIL_SHUTDOWN")); + ErrorNames.insert(std::make_pair(352, "ERROR_FAIL_RESTART")); + ErrorNames.insert(std::make_pair(353, "ERROR_MAX_SESSIONS_REACHED")); + ErrorNames.insert(std::make_pair(400, "ERROR_THREAD_MODE_ALREADY_BACKGROUND")); + ErrorNames.insert(std::make_pair(401, "ERROR_THREAD_MODE_NOT_BACKGROUND")); + ErrorNames.insert(std::make_pair(402, "ERROR_PROCESS_MODE_ALREADY_BACKGROUND")); + ErrorNames.insert(std::make_pair(403, "ERROR_PROCESS_MODE_NOT_BACKGROUND")); + ErrorNames.insert(std::make_pair(487, "ERROR_INVALID_ADDRESS")); + ErrorNames.insert(std::make_pair(500, "ERROR_USER_PROFILE_LOAD")); + ErrorNames.insert(std::make_pair(534, "ERROR_ARITHMETIC_OVERFLOW")); + ErrorNames.insert(std::make_pair(535, "ERROR_PIPE_CONNECTED")); + ErrorNames.insert(std::make_pair(536, "ERROR_PIPE_LISTENING")); + ErrorNames.insert(std::make_pair(537, "ERROR_VERIFIER_STOP")); + ErrorNames.insert(std::make_pair(538, "ERROR_ABIOS_ERROR")); + ErrorNames.insert(std::make_pair(539, "ERROR_WX86_WARNING")); + ErrorNames.insert(std::make_pair(540, "ERROR_WX86_ERROR")); + ErrorNames.insert(std::make_pair(541, "ERROR_TIMER_NOT_CANCELED")); + ErrorNames.insert(std::make_pair(542, "ERROR_UNWIND")); + ErrorNames.insert(std::make_pair(543, "ERROR_BAD_STACK")); + ErrorNames.insert(std::make_pair(544, "ERROR_INVALID_UNWIND_TARGET")); + ErrorNames.insert(std::make_pair(545, "ERROR_INVALID_PORT_ATTRIBUTES")); + ErrorNames.insert(std::make_pair(546, "ERROR_PORT_MESSAGE_TOO_LONG")); + ErrorNames.insert(std::make_pair(547, "ERROR_INVALID_QUOTA_LOWER")); + ErrorNames.insert(std::make_pair(548, "ERROR_DEVICE_ALREADY_ATTACHED")); + ErrorNames.insert(std::make_pair(549, "ERROR_INSTRUCTION_MISALIGNMENT")); + ErrorNames.insert(std::make_pair(550, "ERROR_PROFILING_NOT_STARTED")); + ErrorNames.insert(std::make_pair(551, "ERROR_PROFILING_NOT_STOPPED")); + ErrorNames.insert(std::make_pair(552, "ERROR_COULD_NOT_INTERPRET")); + ErrorNames.insert(std::make_pair(553, "ERROR_PROFILING_AT_LIMIT")); + ErrorNames.insert(std::make_pair(554, "ERROR_CANT_WAIT")); + ErrorNames.insert(std::make_pair(555, "ERROR_CANT_TERMINATE_SELF")); + ErrorNames.insert(std::make_pair(556, "ERROR_UNEXPECTED_MM_CREATE_ERR")); + ErrorNames.insert(std::make_pair(557, "ERROR_UNEXPECTED_MM_MAP_ERROR")); + ErrorNames.insert(std::make_pair(558, "ERROR_UNEXPECTED_MM_EXTEND_ERR")); + ErrorNames.insert(std::make_pair(559, "ERROR_BAD_FUNCTION_TABLE")); + ErrorNames.insert(std::make_pair(560, "ERROR_NO_GUID_TRANSLATION")); + ErrorNames.insert(std::make_pair(561, "ERROR_INVALID_LDT_SIZE")); + ErrorNames.insert(std::make_pair(563, "ERROR_INVALID_LDT_OFFSET")); + ErrorNames.insert(std::make_pair(564, "ERROR_INVALID_LDT_DESCRIPTOR")); + ErrorNames.insert(std::make_pair(565, "ERROR_TOO_MANY_THREADS")); + ErrorNames.insert(std::make_pair(566, "ERROR_THREAD_NOT_IN_PROCESS")); + ErrorNames.insert(std::make_pair(567, "ERROR_PAGEFILE_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(568, "ERROR_LOGON_SERVER_CONFLICT")); + ErrorNames.insert(std::make_pair(569, "ERROR_SYNCHRONIZATION_REQUIRED")); + ErrorNames.insert(std::make_pair(570, "ERROR_NET_OPEN_FAILED")); + ErrorNames.insert(std::make_pair(571, "ERROR_IO_PRIVILEGE_FAILED")); + ErrorNames.insert(std::make_pair(572, "ERROR_CONTROL_C_EXIT")); + ErrorNames.insert(std::make_pair(573, "ERROR_MISSING_SYSTEMFILE")); + ErrorNames.insert(std::make_pair(574, "ERROR_UNHANDLED_EXCEPTION")); + ErrorNames.insert(std::make_pair(575, "ERROR_APP_INIT_FAILURE")); + ErrorNames.insert(std::make_pair(576, "ERROR_PAGEFILE_CREATE_FAILED")); + ErrorNames.insert(std::make_pair(577, "ERROR_INVALID_IMAGE_HASH")); + ErrorNames.insert(std::make_pair(578, "ERROR_NO_PAGEFILE")); + ErrorNames.insert(std::make_pair(579, "ERROR_ILLEGAL_FLOAT_CONTEXT")); + ErrorNames.insert(std::make_pair(580, "ERROR_NO_EVENT_PAIR")); + ErrorNames.insert(std::make_pair(581, "ERROR_DOMAIN_CTRLR_CONFIG_ERROR")); + ErrorNames.insert(std::make_pair(582, "ERROR_ILLEGAL_CHARACTER")); + ErrorNames.insert(std::make_pair(583, "ERROR_UNDEFINED_CHARACTER")); + ErrorNames.insert(std::make_pair(584, "ERROR_FLOPPY_VOLUME")); + ErrorNames.insert(std::make_pair(585, "ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT")); + ErrorNames.insert(std::make_pair(586, "ERROR_BACKUP_CONTROLLER")); + ErrorNames.insert(std::make_pair(587, "ERROR_MUTANT_LIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(588, "ERROR_FS_DRIVER_REQUIRED")); + ErrorNames.insert(std::make_pair(589, "ERROR_CANNOT_LOAD_REGISTRY_FILE")); + ErrorNames.insert(std::make_pair(590, "ERROR_DEBUG_ATTACH_FAILED")); + ErrorNames.insert(std::make_pair(591, "ERROR_SYSTEM_PROCESS_TERMINATED")); + ErrorNames.insert(std::make_pair(592, "ERROR_DATA_NOT_ACCEPTED")); + ErrorNames.insert(std::make_pair(593, "ERROR_VDM_HARD_ERROR")); + ErrorNames.insert(std::make_pair(594, "ERROR_DRIVER_CANCEL_TIMEOUT")); + ErrorNames.insert(std::make_pair(595, "ERROR_REPLY_MESSAGE_MISMATCH")); + ErrorNames.insert(std::make_pair(596, "ERROR_LOST_WRITEBEHIND_DATA")); + ErrorNames.insert(std::make_pair(597, "ERROR_CLIENT_SERVER_PARAMETERS_INVALID")); + ErrorNames.insert(std::make_pair(598, "ERROR_NOT_TINY_STREAM")); + ErrorNames.insert(std::make_pair(599, "ERROR_STACK_OVERFLOW_READ")); + ErrorNames.insert(std::make_pair(600, "ERROR_CONVERT_TO_LARGE")); + ErrorNames.insert(std::make_pair(601, "ERROR_FOUND_OUT_OF_SCOPE")); + ErrorNames.insert(std::make_pair(602, "ERROR_ALLOCATE_BUCKET")); + ErrorNames.insert(std::make_pair(603, "ERROR_MARSHALL_OVERFLOW")); + ErrorNames.insert(std::make_pair(604, "ERROR_INVALID_VARIANT")); + ErrorNames.insert(std::make_pair(605, "ERROR_BAD_COMPRESSION_BUFFER")); + ErrorNames.insert(std::make_pair(606, "ERROR_AUDIT_FAILED")); + ErrorNames.insert(std::make_pair(607, "ERROR_TIMER_RESOLUTION_NOT_SET")); + ErrorNames.insert(std::make_pair(608, "ERROR_INSUFFICIENT_LOGON_INFO")); + ErrorNames.insert(std::make_pair(609, "ERROR_BAD_DLL_ENTRYPOINT")); + ErrorNames.insert(std::make_pair(610, "ERROR_BAD_SERVICE_ENTRYPOINT")); + ErrorNames.insert(std::make_pair(611, "ERROR_IP_ADDRESS_CONFLICT1")); + ErrorNames.insert(std::make_pair(612, "ERROR_IP_ADDRESS_CONFLICT2")); + ErrorNames.insert(std::make_pair(613, "ERROR_REGISTRY_QUOTA_LIMIT")); + ErrorNames.insert(std::make_pair(614, "ERROR_NO_CALLBACK_ACTIVE")); + ErrorNames.insert(std::make_pair(615, "ERROR_PWD_TOO_SHORT")); + ErrorNames.insert(std::make_pair(616, "ERROR_PWD_TOO_RECENT")); + ErrorNames.insert(std::make_pair(617, "ERROR_PWD_HISTORY_CONFLICT")); + ErrorNames.insert(std::make_pair(618, "ERROR_UNSUPPORTED_COMPRESSION")); + ErrorNames.insert(std::make_pair(619, "ERROR_INVALID_HW_PROFILE")); + ErrorNames.insert(std::make_pair(620, "ERROR_INVALID_PLUGPLAY_DEVICE_PATH")); + ErrorNames.insert(std::make_pair(621, "ERROR_QUOTA_LIST_INCONSISTENT")); + ErrorNames.insert(std::make_pair(622, "ERROR_EVALUATION_EXPIRATION")); + ErrorNames.insert(std::make_pair(623, "ERROR_ILLEGAL_DLL_RELOCATION")); + ErrorNames.insert(std::make_pair(624, "ERROR_DLL_INIT_FAILED_LOGOFF")); + ErrorNames.insert(std::make_pair(625, "ERROR_VALIDATE_CONTINUE")); + ErrorNames.insert(std::make_pair(626, "ERROR_NO_MORE_MATCHES")); + ErrorNames.insert(std::make_pair(627, "ERROR_RANGE_LIST_CONFLICT")); + ErrorNames.insert(std::make_pair(628, "ERROR_SERVER_SID_MISMATCH")); + ErrorNames.insert(std::make_pair(629, "ERROR_CANT_ENABLE_DENY_ONLY")); + ErrorNames.insert(std::make_pair(630, "ERROR_FLOAT_MULTIPLE_FAULTS")); + ErrorNames.insert(std::make_pair(631, "ERROR_FLOAT_MULTIPLE_TRAPS")); + ErrorNames.insert(std::make_pair(632, "ERROR_NOINTERFACE")); + ErrorNames.insert(std::make_pair(633, "ERROR_DRIVER_FAILED_SLEEP")); + ErrorNames.insert(std::make_pair(634, "ERROR_CORRUPT_SYSTEM_FILE")); + ErrorNames.insert(std::make_pair(635, "ERROR_COMMITMENT_MINIMUM")); + ErrorNames.insert(std::make_pair(636, "ERROR_PNP_RESTART_ENUMERATION")); + ErrorNames.insert(std::make_pair(637, "ERROR_SYSTEM_IMAGE_BAD_SIGNATURE")); + ErrorNames.insert(std::make_pair(638, "ERROR_PNP_REBOOT_REQUIRED")); + ErrorNames.insert(std::make_pair(639, "ERROR_INSUFFICIENT_POWER")); + ErrorNames.insert(std::make_pair(640, "ERROR_MULTIPLE_FAULT_VIOLATION")); + ErrorNames.insert(std::make_pair(641, "ERROR_SYSTEM_SHUTDOWN")); + ErrorNames.insert(std::make_pair(642, "ERROR_PORT_NOT_SET")); + ErrorNames.insert(std::make_pair(643, "ERROR_DS_VERSION_CHECK_FAILURE")); + ErrorNames.insert(std::make_pair(644, "ERROR_RANGE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(646, "ERROR_NOT_SAFE_MODE_DRIVER")); + ErrorNames.insert(std::make_pair(647, "ERROR_FAILED_DRIVER_ENTRY")); + ErrorNames.insert(std::make_pair(648, "ERROR_DEVICE_ENUMERATION_ERROR")); + ErrorNames.insert(std::make_pair(649, "ERROR_MOUNT_POINT_NOT_RESOLVED")); + ErrorNames.insert(std::make_pair(650, "ERROR_INVALID_DEVICE_OBJECT_PARAMETER")); + ErrorNames.insert(std::make_pair(651, "ERROR_MCA_OCCURED")); + ErrorNames.insert(std::make_pair(652, "ERROR_DRIVER_DATABASE_ERROR")); + ErrorNames.insert(std::make_pair(653, "ERROR_SYSTEM_HIVE_TOO_LARGE")); + ErrorNames.insert(std::make_pair(654, "ERROR_DRIVER_FAILED_PRIOR_UNLOAD")); + ErrorNames.insert(std::make_pair(655, "ERROR_VOLSNAP_PREPARE_HIBERNATE")); + ErrorNames.insert(std::make_pair(656, "ERROR_HIBERNATION_FAILURE")); + ErrorNames.insert(std::make_pair(665, "ERROR_FILE_SYSTEM_LIMITATION")); + ErrorNames.insert(std::make_pair(668, "ERROR_ASSERTION_FAILURE")); + ErrorNames.insert(std::make_pair(669, "ERROR_ACPI_ERROR")); + ErrorNames.insert(std::make_pair(670, "ERROR_WOW_ASSERTION")); + ErrorNames.insert(std::make_pair(671, "ERROR_PNP_BAD_MPS_TABLE")); + ErrorNames.insert(std::make_pair(672, "ERROR_PNP_TRANSLATION_FAILED")); + ErrorNames.insert(std::make_pair(673, "ERROR_PNP_IRQ_TRANSLATION_FAILED")); + ErrorNames.insert(std::make_pair(674, "ERROR_PNP_INVALID_ID")); + ErrorNames.insert(std::make_pair(675, "ERROR_WAKE_SYSTEM_DEBUGGER")); + ErrorNames.insert(std::make_pair(676, "ERROR_HANDLES_CLOSED")); + ErrorNames.insert(std::make_pair(677, "ERROR_EXTRANEOUS_INFORMATION")); + ErrorNames.insert(std::make_pair(678, "ERROR_RXACT_COMMIT_NECESSARY")); + ErrorNames.insert(std::make_pair(679, "ERROR_MEDIA_CHECK")); + ErrorNames.insert(std::make_pair(680, "ERROR_GUID_SUBSTITUTION_MADE")); + ErrorNames.insert(std::make_pair(681, "ERROR_STOPPED_ON_SYMLINK")); + ErrorNames.insert(std::make_pair(682, "ERROR_LONGJUMP")); + ErrorNames.insert(std::make_pair(683, "ERROR_PLUGPLAY_QUERY_VETOED")); + ErrorNames.insert(std::make_pair(684, "ERROR_UNWIND_CONSOLIDATE")); + ErrorNames.insert(std::make_pair(685, "ERROR_REGISTRY_HIVE_RECOVERED")); + ErrorNames.insert(std::make_pair(686, "ERROR_DLL_MIGHT_BE_INSECURE")); + ErrorNames.insert(std::make_pair(687, "ERROR_DLL_MIGHT_BE_INCOMPATIBLE")); + ErrorNames.insert(std::make_pair(688, "ERROR_DBG_EXCEPTION_NOT_HANDLED")); + ErrorNames.insert(std::make_pair(689, "ERROR_DBG_REPLY_LATER")); + ErrorNames.insert(std::make_pair(690, "ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE")); + ErrorNames.insert(std::make_pair(691, "ERROR_DBG_TERMINATE_THREAD")); + ErrorNames.insert(std::make_pair(692, "ERROR_DBG_TERMINATE_PROCESS")); + ErrorNames.insert(std::make_pair(693, "ERROR_DBG_CONTROL_C")); + ErrorNames.insert(std::make_pair(694, "ERROR_DBG_PRINTEXCEPTION_C")); + ErrorNames.insert(std::make_pair(695, "ERROR_DBG_RIPEXCEPTION")); + ErrorNames.insert(std::make_pair(696, "ERROR_DBG_CONTROL_BREAK")); + ErrorNames.insert(std::make_pair(697, "ERROR_DBG_COMMAND_EXCEPTION")); + ErrorNames.insert(std::make_pair(698, "ERROR_OBJECT_NAME_EXISTS")); + ErrorNames.insert(std::make_pair(699, "ERROR_THREAD_WAS_SUSPENDED")); + ErrorNames.insert(std::make_pair(700, "ERROR_IMAGE_NOT_AT_BASE")); + ErrorNames.insert(std::make_pair(701, "ERROR_RXACT_STATE_CREATED")); + ErrorNames.insert(std::make_pair(702, "ERROR_SEGMENT_NOTIFICATION")); + ErrorNames.insert(std::make_pair(703, "ERROR_BAD_CURRENT_DIRECTORY")); + ErrorNames.insert(std::make_pair(704, "ERROR_FT_READ_RECOVERY_FROM_BACKUP")); + ErrorNames.insert(std::make_pair(705, "ERROR_FT_WRITE_RECOVERY")); + ErrorNames.insert(std::make_pair(706, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH")); + ErrorNames.insert(std::make_pair(707, "ERROR_RECEIVE_PARTIAL")); + ErrorNames.insert(std::make_pair(708, "ERROR_RECEIVE_EXPEDITED")); + ErrorNames.insert(std::make_pair(709, "ERROR_RECEIVE_PARTIAL_EXPEDITED")); + ErrorNames.insert(std::make_pair(710, "ERROR_EVENT_DONE")); + ErrorNames.insert(std::make_pair(711, "ERROR_EVENT_PENDING")); + ErrorNames.insert(std::make_pair(712, "ERROR_CHECKING_FILE_SYSTEM")); + ErrorNames.insert(std::make_pair(713, "ERROR_FATAL_APP_EXIT")); + ErrorNames.insert(std::make_pair(714, "ERROR_PREDEFINED_HANDLE")); + ErrorNames.insert(std::make_pair(715, "ERROR_WAS_UNLOCKED")); + ErrorNames.insert(std::make_pair(716, "ERROR_SERVICE_NOTIFICATION")); + ErrorNames.insert(std::make_pair(717, "ERROR_WAS_LOCKED")); + ErrorNames.insert(std::make_pair(718, "ERROR_LOG_HARD_ERROR")); + ErrorNames.insert(std::make_pair(719, "ERROR_ALREADY_WIN32")); + ErrorNames.insert(std::make_pair(720, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE")); + ErrorNames.insert(std::make_pair(721, "ERROR_NO_YIELD_PERFORMED")); + ErrorNames.insert(std::make_pair(722, "ERROR_TIMER_RESUME_IGNORED")); + ErrorNames.insert(std::make_pair(723, "ERROR_ARBITRATION_UNHANDLED")); + ErrorNames.insert(std::make_pair(724, "ERROR_CARDBUS_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(725, "ERROR_MP_PROCESSOR_MISMATCH")); + ErrorNames.insert(std::make_pair(726, "ERROR_HIBERNATED")); + ErrorNames.insert(std::make_pair(727, "ERROR_RESUME_HIBERNATION")); + ErrorNames.insert(std::make_pair(728, "ERROR_FIRMWARE_UPDATED")); + ErrorNames.insert(std::make_pair(729, "ERROR_DRIVERS_LEAKING_LOCKED_PAGES")); + ErrorNames.insert(std::make_pair(730, "ERROR_WAKE_SYSTEM")); + ErrorNames.insert(std::make_pair(731, "ERROR_WAIT_1")); + ErrorNames.insert(std::make_pair(732, "ERROR_WAIT_2")); + ErrorNames.insert(std::make_pair(733, "ERROR_WAIT_3")); + ErrorNames.insert(std::make_pair(734, "ERROR_WAIT_63")); + ErrorNames.insert(std::make_pair(735, "ERROR_ABANDONED_WAIT_0")); + ErrorNames.insert(std::make_pair(736, "ERROR_ABANDONED_WAIT_63")); + ErrorNames.insert(std::make_pair(737, "ERROR_USER_APC")); + ErrorNames.insert(std::make_pair(738, "ERROR_KERNEL_APC")); + ErrorNames.insert(std::make_pair(739, "ERROR_ALERTED")); + ErrorNames.insert(std::make_pair(740, "ERROR_ELEVATION_REQUIRED")); + ErrorNames.insert(std::make_pair(741, "ERROR_REPARSE")); + ErrorNames.insert(std::make_pair(742, "ERROR_OPLOCK_BREAK_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(743, "ERROR_VOLUME_MOUNTED")); + ErrorNames.insert(std::make_pair(744, "ERROR_RXACT_COMMITTED")); + ErrorNames.insert(std::make_pair(745, "ERROR_NOTIFY_CLEANUP")); + ErrorNames.insert(std::make_pair(746, "ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED")); + ErrorNames.insert(std::make_pair(747, "ERROR_PAGE_FAULT_TRANSITION")); + ErrorNames.insert(std::make_pair(748, "ERROR_PAGE_FAULT_DEMAND_ZERO")); + ErrorNames.insert(std::make_pair(749, "ERROR_PAGE_FAULT_COPY_ON_WRITE")); + ErrorNames.insert(std::make_pair(750, "ERROR_PAGE_FAULT_GUARD_PAGE")); + ErrorNames.insert(std::make_pair(751, "ERROR_PAGE_FAULT_PAGING_FILE")); + ErrorNames.insert(std::make_pair(752, "ERROR_CACHE_PAGE_LOCKED")); + ErrorNames.insert(std::make_pair(753, "ERROR_CRASH_DUMP")); + ErrorNames.insert(std::make_pair(754, "ERROR_BUFFER_ALL_ZEROS")); + ErrorNames.insert(std::make_pair(755, "ERROR_REPARSE_OBJECT")); + ErrorNames.insert(std::make_pair(756, "ERROR_RESOURCE_REQUIREMENTS_CHANGED")); + ErrorNames.insert(std::make_pair(757, "ERROR_TRANSLATION_COMPLETE")); + ErrorNames.insert(std::make_pair(758, "ERROR_NOTHING_TO_TERMINATE")); + ErrorNames.insert(std::make_pair(759, "ERROR_PROCESS_NOT_IN_JOB")); + ErrorNames.insert(std::make_pair(760, "ERROR_PROCESS_IN_JOB")); + ErrorNames.insert(std::make_pair(761, "ERROR_VOLSNAP_HIBERNATE_READY")); + ErrorNames.insert(std::make_pair(762, "ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY")); + ErrorNames.insert(std::make_pair(763, "ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED")); + ErrorNames.insert(std::make_pair(764, "ERROR_INTERRUPT_STILL_CONNECTED")); + ErrorNames.insert(std::make_pair(765, "ERROR_WAIT_FOR_OPLOCK")); + ErrorNames.insert(std::make_pair(766, "ERROR_DBG_EXCEPTION_HANDLED")); + ErrorNames.insert(std::make_pair(767, "ERROR_DBG_CONTINUE")); + ErrorNames.insert(std::make_pair(768, "ERROR_CALLBACK_POP_STACK")); + ErrorNames.insert(std::make_pair(769, "ERROR_COMPRESSION_DISABLED")); + ErrorNames.insert(std::make_pair(770, "ERROR_CANTFETCHBACKWARDS")); + ErrorNames.insert(std::make_pair(771, "ERROR_CANTSCROLLBACKWARDS")); + ErrorNames.insert(std::make_pair(772, "ERROR_ROWSNOTRELEASED")); + ErrorNames.insert(std::make_pair(773, "ERROR_BAD_ACCESSOR_FLAGS")); + ErrorNames.insert(std::make_pair(774, "ERROR_ERRORS_ENCOUNTERED")); + ErrorNames.insert(std::make_pair(775, "ERROR_NOT_CAPABLE")); + ErrorNames.insert(std::make_pair(776, "ERROR_REQUEST_OUT_OF_SEQUENCE")); + ErrorNames.insert(std::make_pair(777, "ERROR_VERSION_PARSE_ERROR")); + ErrorNames.insert(std::make_pair(778, "ERROR_BADSTARTPOSITION")); + ErrorNames.insert(std::make_pair(779, "ERROR_MEMORY_HARDWARE")); + ErrorNames.insert(std::make_pair(780, "ERROR_DISK_REPAIR_DISABLED")); + ErrorNames.insert(std::make_pair(781, "ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE")); + ErrorNames.insert(std::make_pair(782, "ERROR_SYSTEM_POWERSTATE_TRANSITION")); + ErrorNames.insert(std::make_pair(783, "ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION")); + ErrorNames.insert(std::make_pair(784, "ERROR_MCA_EXCEPTION")); + ErrorNames.insert(std::make_pair(785, "ERROR_ACCESS_AUDIT_BY_POLICY")); + ErrorNames.insert(std::make_pair(786, "ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY")); + ErrorNames.insert(std::make_pair(787, "ERROR_ABANDON_HIBERFILE")); + ErrorNames.insert(std::make_pair(788, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED")); + ErrorNames.insert(std::make_pair(789, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR")); + ErrorNames.insert(std::make_pair(790, "ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR")); + ErrorNames.insert(std::make_pair(791, "ERROR_BAD_MCFG_TABLE")); + ErrorNames.insert(std::make_pair(800, "ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE")); + ErrorNames.insert(std::make_pair(801, "ERROR_CANNOT_GRANT_REQUESTED_OPLOCK")); + ErrorNames.insert(std::make_pair(802, "ERROR_CANNOT_BREAK_OPLOCK")); + ErrorNames.insert(std::make_pair(803, "ERROR_OPLOCK_HANDLE_CLOSED")); + ErrorNames.insert(std::make_pair(804, "ERROR_NO_ACE_CONDITION")); + ErrorNames.insert(std::make_pair(805, "ERROR_INVALID_ACE_CONDITION")); + ErrorNames.insert(std::make_pair(994, "ERROR_EA_ACCESS_DENIED")); + ErrorNames.insert(std::make_pair(995, "ERROR_OPERATION_ABORTED")); + ErrorNames.insert(std::make_pair(996, "ERROR_IO_INCOMPLETE")); + ErrorNames.insert(std::make_pair(997, "ERROR_IO_PENDING")); + ErrorNames.insert(std::make_pair(998, "ERROR_NOACCESS")); + ErrorNames.insert(std::make_pair(999, "ERROR_SWAPERROR")); + ErrorNames.insert(std::make_pair(1001, "ERROR_STACK_OVERFLOW")); + ErrorNames.insert(std::make_pair(1002, "ERROR_INVALID_MESSAGE")); + ErrorNames.insert(std::make_pair(1003, "ERROR_CAN_NOT_COMPLETE")); + ErrorNames.insert(std::make_pair(1004, "ERROR_INVALID_FLAGS")); + ErrorNames.insert(std::make_pair(1005, "ERROR_UNRECOGNIZED_VOLUME")); + ErrorNames.insert(std::make_pair(1006, "ERROR_FILE_INVALID")); + ErrorNames.insert(std::make_pair(1007, "ERROR_FULLSCREEN_MODE")); + ErrorNames.insert(std::make_pair(1008, "ERROR_NO_TOKEN")); + ErrorNames.insert(std::make_pair(1009, "ERROR_BADDB")); + ErrorNames.insert(std::make_pair(1010, "ERROR_BADKEY")); + ErrorNames.insert(std::make_pair(1011, "ERROR_CANTOPEN")); + ErrorNames.insert(std::make_pair(1012, "ERROR_CANTREAD")); + ErrorNames.insert(std::make_pair(1013, "ERROR_CANTWRITE")); + ErrorNames.insert(std::make_pair(1014, "ERROR_REGISTRY_RECOVERED")); + ErrorNames.insert(std::make_pair(1015, "ERROR_REGISTRY_CORRUPT")); + ErrorNames.insert(std::make_pair(1016, "ERROR_REGISTRY_IO_FAILED")); + ErrorNames.insert(std::make_pair(1017, "ERROR_NOT_REGISTRY_FILE")); + ErrorNames.insert(std::make_pair(1018, "ERROR_KEY_DELETED")); + ErrorNames.insert(std::make_pair(1019, "ERROR_NO_LOG_SPACE")); + ErrorNames.insert(std::make_pair(1020, "ERROR_KEY_HAS_CHILDREN")); + ErrorNames.insert(std::make_pair(1021, "ERROR_CHILD_MUST_BE_VOLATILE")); + ErrorNames.insert(std::make_pair(1022, "ERROR_NOTIFY_ENUM_DIR")); + ErrorNames.insert(std::make_pair(1051, "ERROR_DEPENDENT_SERVICES_RUNNING")); + ErrorNames.insert(std::make_pair(1052, "ERROR_INVALID_SERVICE_CONTROL")); + ErrorNames.insert(std::make_pair(1053, "ERROR_SERVICE_REQUEST_TIMEOUT")); + ErrorNames.insert(std::make_pair(1054, "ERROR_SERVICE_NO_THREAD")); + ErrorNames.insert(std::make_pair(1055, "ERROR_SERVICE_DATABASE_LOCKED")); + ErrorNames.insert(std::make_pair(1056, "ERROR_SERVICE_ALREADY_RUNNING")); + ErrorNames.insert(std::make_pair(1057, "ERROR_INVALID_SERVICE_ACCOUNT")); + ErrorNames.insert(std::make_pair(1058, "ERROR_SERVICE_DISABLED")); + ErrorNames.insert(std::make_pair(1059, "ERROR_CIRCULAR_DEPENDENCY")); + ErrorNames.insert(std::make_pair(1060, "ERROR_SERVICE_DOES_NOT_EXIST")); + ErrorNames.insert(std::make_pair(1061, "ERROR_SERVICE_CANNOT_ACCEPT_CTRL")); + ErrorNames.insert(std::make_pair(1062, "ERROR_SERVICE_NOT_ACTIVE")); + ErrorNames.insert(std::make_pair(1063, "ERROR_FAILED_SERVICE_CONTROLLER_CONNECT")); + ErrorNames.insert(std::make_pair(1064, "ERROR_EXCEPTION_IN_SERVICE")); + ErrorNames.insert(std::make_pair(1065, "ERROR_DATABASE_DOES_NOT_EXIST")); + ErrorNames.insert(std::make_pair(1066, "ERROR_SERVICE_SPECIFIC_ERROR")); + ErrorNames.insert(std::make_pair(1067, "ERROR_PROCESS_ABORTED")); + ErrorNames.insert(std::make_pair(1068, "ERROR_SERVICE_DEPENDENCY_FAIL")); + ErrorNames.insert(std::make_pair(1069, "ERROR_SERVICE_LOGON_FAILED")); + ErrorNames.insert(std::make_pair(1070, "ERROR_SERVICE_START_HANG")); + ErrorNames.insert(std::make_pair(1071, "ERROR_INVALID_SERVICE_LOCK")); + ErrorNames.insert(std::make_pair(1072, "ERROR_SERVICE_MARKED_FOR_DELETE")); + ErrorNames.insert(std::make_pair(1073, "ERROR_SERVICE_EXISTS")); + ErrorNames.insert(std::make_pair(1074, "ERROR_ALREADY_RUNNING_LKG")); + ErrorNames.insert(std::make_pair(1075, "ERROR_SERVICE_DEPENDENCY_DELETED")); + ErrorNames.insert(std::make_pair(1076, "ERROR_BOOT_ALREADY_ACCEPTED")); + ErrorNames.insert(std::make_pair(1077, "ERROR_SERVICE_NEVER_STARTED")); + ErrorNames.insert(std::make_pair(1078, "ERROR_DUPLICATE_SERVICE_NAME")); + ErrorNames.insert(std::make_pair(1079, "ERROR_DIFFERENT_SERVICE_ACCOUNT")); + ErrorNames.insert(std::make_pair(1080, "ERROR_CANNOT_DETECT_DRIVER_FAILURE")); + ErrorNames.insert(std::make_pair(1081, "ERROR_CANNOT_DETECT_PROCESS_ABORT")); + ErrorNames.insert(std::make_pair(1082, "ERROR_NO_RECOVERY_PROGRAM")); + ErrorNames.insert(std::make_pair(1083, "ERROR_SERVICE_NOT_IN_EXE")); + ErrorNames.insert(std::make_pair(1084, "ERROR_NOT_SAFEBOOT_SERVICE")); + ErrorNames.insert(std::make_pair(1100, "ERROR_END_OF_MEDIA")); + ErrorNames.insert(std::make_pair(1101, "ERROR_FILEMARK_DETECTED")); + ErrorNames.insert(std::make_pair(1102, "ERROR_BEGINNING_OF_MEDIA")); + ErrorNames.insert(std::make_pair(1103, "ERROR_SETMARK_DETECTED")); + ErrorNames.insert(std::make_pair(1104, "ERROR_NO_DATA_DETECTED")); + ErrorNames.insert(std::make_pair(1105, "ERROR_PARTITION_FAILURE")); + ErrorNames.insert(std::make_pair(1106, "ERROR_INVALID_BLOCK_LENGTH")); + ErrorNames.insert(std::make_pair(1107, "ERROR_DEVICE_NOT_PARTITIONED")); + ErrorNames.insert(std::make_pair(1108, "ERROR_UNABLE_TO_LOCK_MEDIA")); + ErrorNames.insert(std::make_pair(1109, "ERROR_UNABLE_TO_UNLOAD_MEDIA")); + ErrorNames.insert(std::make_pair(1110, "ERROR_MEDIA_CHANGED")); + ErrorNames.insert(std::make_pair(1111, "ERROR_BUS_RESET")); + ErrorNames.insert(std::make_pair(1112, "ERROR_NO_MEDIA_IN_DRIVE")); + ErrorNames.insert(std::make_pair(1113, "ERROR_NO_UNICODE_TRANSLATION")); + ErrorNames.insert(std::make_pair(1114, "ERROR_DLL_INIT_FAILED")); + ErrorNames.insert(std::make_pair(1115, "ERROR_SHUTDOWN_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(1116, "ERROR_NO_SHUTDOWN_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(1117, "ERROR_IO_DEVICE")); + ErrorNames.insert(std::make_pair(1118, "ERROR_SERIAL_NO_DEVICE")); + ErrorNames.insert(std::make_pair(1119, "ERROR_IRQ_BUSY")); + ErrorNames.insert(std::make_pair(1120, "ERROR_MORE_WRITES")); + ErrorNames.insert(std::make_pair(1121, "ERROR_COUNTER_TIMEOUT")); + ErrorNames.insert(std::make_pair(1122, "ERROR_FLOPPY_ID_MARK_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1123, "ERROR_FLOPPY_WRONG_CYLINDER")); + ErrorNames.insert(std::make_pair(1124, "ERROR_FLOPPY_UNKNOWN_ERROR")); + ErrorNames.insert(std::make_pair(1125, "ERROR_FLOPPY_BAD_REGISTERS")); + ErrorNames.insert(std::make_pair(1126, "ERROR_DISK_RECALIBRATE_FAILED")); + ErrorNames.insert(std::make_pair(1127, "ERROR_DISK_OPERATION_FAILED")); + ErrorNames.insert(std::make_pair(1128, "ERROR_DISK_RESET_FAILED")); + ErrorNames.insert(std::make_pair(1129, "ERROR_EOM_OVERFLOW")); + ErrorNames.insert(std::make_pair(1130, "ERROR_NOT_ENOUGH_SERVER_MEMORY")); + ErrorNames.insert(std::make_pair(1131, "ERROR_POSSIBLE_DEADLOCK")); + ErrorNames.insert(std::make_pair(1132, "ERROR_MAPPED_ALIGNMENT")); + ErrorNames.insert(std::make_pair(1140, "ERROR_SET_POWER_STATE_VETOED")); + ErrorNames.insert(std::make_pair(1141, "ERROR_SET_POWER_STATE_FAILED")); + ErrorNames.insert(std::make_pair(1142, "ERROR_TOO_MANY_LINKS")); + ErrorNames.insert(std::make_pair(1150, "ERROR_OLD_WIN_VERSION")); + ErrorNames.insert(std::make_pair(1151, "ERROR_APP_WRONG_OS")); + ErrorNames.insert(std::make_pair(1152, "ERROR_SINGLE_INSTANCE_APP")); + ErrorNames.insert(std::make_pair(1153, "ERROR_RMODE_APP")); + ErrorNames.insert(std::make_pair(1154, "ERROR_INVALID_DLL")); + ErrorNames.insert(std::make_pair(1155, "ERROR_NO_ASSOCIATION")); + ErrorNames.insert(std::make_pair(1156, "ERROR_DDE_FAIL")); + ErrorNames.insert(std::make_pair(1157, "ERROR_DLL_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1158, "ERROR_NO_MORE_USER_HANDLES")); + ErrorNames.insert(std::make_pair(1159, "ERROR_MESSAGE_SYNC_ONLY")); + ErrorNames.insert(std::make_pair(1160, "ERROR_SOURCE_ELEMENT_EMPTY")); + ErrorNames.insert(std::make_pair(1161, "ERROR_DESTINATION_ELEMENT_FULL")); + ErrorNames.insert(std::make_pair(1162, "ERROR_ILLEGAL_ELEMENT_ADDRESS")); + ErrorNames.insert(std::make_pair(1163, "ERROR_MAGAZINE_NOT_PRESENT")); + ErrorNames.insert(std::make_pair(1164, "ERROR_DEVICE_REINITIALIZATION_NEEDED")); + ErrorNames.insert(std::make_pair(1165, "ERROR_DEVICE_REQUIRES_CLEANING")); + ErrorNames.insert(std::make_pair(1166, "ERROR_DEVICE_DOOR_OPEN")); + ErrorNames.insert(std::make_pair(1167, "ERROR_DEVICE_NOT_CONNECTED")); + ErrorNames.insert(std::make_pair(1168, "ERROR_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1169, "ERROR_NO_MATCH")); + ErrorNames.insert(std::make_pair(1170, "ERROR_SET_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1171, "ERROR_POINT_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1172, "ERROR_NO_TRACKING_SERVICE")); + ErrorNames.insert(std::make_pair(1173, "ERROR_NO_VOLUME_ID")); + ErrorNames.insert(std::make_pair(1175, "ERROR_UNABLE_TO_REMOVE_REPLACED")); + ErrorNames.insert(std::make_pair(1176, "ERROR_UNABLE_TO_MOVE_REPLACEMENT")); + ErrorNames.insert(std::make_pair(1177, "ERROR_UNABLE_TO_MOVE_REPLACEMENT_2")); + ErrorNames.insert(std::make_pair(1178, "ERROR_JOURNAL_DELETE_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(1179, "ERROR_JOURNAL_NOT_ACTIVE")); + ErrorNames.insert(std::make_pair(1180, "ERROR_POTENTIAL_FILE_FOUND")); + ErrorNames.insert(std::make_pair(1181, "ERROR_JOURNAL_ENTRY_DELETED")); + ErrorNames.insert(std::make_pair(1190, "ERROR_SHUTDOWN_IS_SCHEDULED")); + ErrorNames.insert(std::make_pair(1191, "ERROR_SHUTDOWN_USERS_LOGGED_ON")); + ErrorNames.insert(std::make_pair(1200, "ERROR_BAD_DEVICE")); + ErrorNames.insert(std::make_pair(1201, "ERROR_CONNECTION_UNAVAIL")); + ErrorNames.insert(std::make_pair(1202, "ERROR_DEVICE_ALREADY_REMEMBERED")); + ErrorNames.insert(std::make_pair(1203, "ERROR_NO_NET_OR_BAD_PATH")); + ErrorNames.insert(std::make_pair(1204, "ERROR_BAD_PROVIDER")); + ErrorNames.insert(std::make_pair(1205, "ERROR_CANNOT_OPEN_PROFILE")); + ErrorNames.insert(std::make_pair(1206, "ERROR_BAD_PROFILE")); + ErrorNames.insert(std::make_pair(1207, "ERROR_NOT_CONTAINER")); + ErrorNames.insert(std::make_pair(1208, "ERROR_EXTENDED_ERROR")); + ErrorNames.insert(std::make_pair(1209, "ERROR_INVALID_GROUPNAME")); + ErrorNames.insert(std::make_pair(1210, "ERROR_INVALID_COMPUTERNAME")); + ErrorNames.insert(std::make_pair(1211, "ERROR_INVALID_EVENTNAME")); + ErrorNames.insert(std::make_pair(1212, "ERROR_INVALID_DOMAINNAME")); + ErrorNames.insert(std::make_pair(1213, "ERROR_INVALID_SERVICENAME")); + ErrorNames.insert(std::make_pair(1214, "ERROR_INVALID_NETNAME")); + ErrorNames.insert(std::make_pair(1215, "ERROR_INVALID_SHARENAME")); + ErrorNames.insert(std::make_pair(1216, "ERROR_INVALID_PASSWORDNAME")); + ErrorNames.insert(std::make_pair(1217, "ERROR_INVALID_MESSAGENAME")); + ErrorNames.insert(std::make_pair(1218, "ERROR_INVALID_MESSAGEDEST")); + ErrorNames.insert(std::make_pair(1219, "ERROR_SESSION_CREDENTIAL_CONFLICT")); + ErrorNames.insert(std::make_pair(1220, "ERROR_REMOTE_SESSION_LIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(1221, "ERROR_DUP_DOMAINNAME")); + ErrorNames.insert(std::make_pair(1222, "ERROR_NO_NETWORK")); + ErrorNames.insert(std::make_pair(1223, "ERROR_CANCELLED")); + ErrorNames.insert(std::make_pair(1224, "ERROR_USER_MAPPED_FILE")); + ErrorNames.insert(std::make_pair(1225, "ERROR_CONNECTION_REFUSED")); + ErrorNames.insert(std::make_pair(1226, "ERROR_GRACEFUL_DISCONNECT")); + ErrorNames.insert(std::make_pair(1227, "ERROR_ADDRESS_ALREADY_ASSOCIATED")); + ErrorNames.insert(std::make_pair(1228, "ERROR_ADDRESS_NOT_ASSOCIATED")); + ErrorNames.insert(std::make_pair(1229, "ERROR_CONNECTION_INVALID")); + ErrorNames.insert(std::make_pair(1230, "ERROR_CONNECTION_ACTIVE")); + ErrorNames.insert(std::make_pair(1231, "ERROR_NETWORK_UNREACHABLE")); + ErrorNames.insert(std::make_pair(1232, "ERROR_HOST_UNREACHABLE")); + ErrorNames.insert(std::make_pair(1233, "ERROR_PROTOCOL_UNREACHABLE")); + ErrorNames.insert(std::make_pair(1234, "ERROR_PORT_UNREACHABLE")); + ErrorNames.insert(std::make_pair(1235, "ERROR_REQUEST_ABORTED")); + ErrorNames.insert(std::make_pair(1236, "ERROR_CONNECTION_ABORTED")); + ErrorNames.insert(std::make_pair(1237, "ERROR_RETRY")); + ErrorNames.insert(std::make_pair(1238, "ERROR_CONNECTION_COUNT_LIMIT")); + ErrorNames.insert(std::make_pair(1239, "ERROR_LOGIN_TIME_RESTRICTION")); + ErrorNames.insert(std::make_pair(1240, "ERROR_LOGIN_WKSTA_RESTRICTION")); + ErrorNames.insert(std::make_pair(1241, "ERROR_INCORRECT_ADDRESS")); + ErrorNames.insert(std::make_pair(1242, "ERROR_ALREADY_REGISTERED")); + ErrorNames.insert(std::make_pair(1243, "ERROR_SERVICE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1244, "ERROR_NOT_AUTHENTICATED")); + ErrorNames.insert(std::make_pair(1245, "ERROR_NOT_LOGGED_ON")); + ErrorNames.insert(std::make_pair(1246, "ERROR_CONTINUE")); + ErrorNames.insert(std::make_pair(1247, "ERROR_ALREADY_INITIALIZED")); + ErrorNames.insert(std::make_pair(1248, "ERROR_NO_MORE_DEVICES")); + ErrorNames.insert(std::make_pair(1249, "ERROR_NO_SUCH_SITE")); + ErrorNames.insert(std::make_pair(1250, "ERROR_DOMAIN_CONTROLLER_EXISTS")); + ErrorNames.insert(std::make_pair(1251, "ERROR_ONLY_IF_CONNECTED")); + ErrorNames.insert(std::make_pair(1252, "ERROR_OVERRIDE_NOCHANGES")); + ErrorNames.insert(std::make_pair(1253, "ERROR_BAD_USER_PROFILE")); + ErrorNames.insert(std::make_pair(1254, "ERROR_NOT_SUPPORTED_ON_SBS")); + ErrorNames.insert(std::make_pair(1255, "ERROR_SERVER_SHUTDOWN_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(1256, "ERROR_HOST_DOWN")); + ErrorNames.insert(std::make_pair(1257, "ERROR_NON_ACCOUNT_SID")); + ErrorNames.insert(std::make_pair(1258, "ERROR_NON_DOMAIN_SID")); + ErrorNames.insert(std::make_pair(1259, "ERROR_APPHELP_BLOCK")); + ErrorNames.insert(std::make_pair(1260, "ERROR_ACCESS_DISABLED_BY_POLICY")); + ErrorNames.insert(std::make_pair(1261, "ERROR_REG_NAT_CONSUMPTION")); + ErrorNames.insert(std::make_pair(1262, "ERROR_CSCSHARE_OFFLINE")); + ErrorNames.insert(std::make_pair(1263, "ERROR_PKINIT_FAILURE")); + ErrorNames.insert(std::make_pair(1264, "ERROR_SMARTCARD_SUBSYSTEM_FAILURE")); + ErrorNames.insert(std::make_pair(1265, "ERROR_DOWNGRADE_DETECTED")); + ErrorNames.insert(std::make_pair(1271, "ERROR_MACHINE_LOCKED")); + ErrorNames.insert(std::make_pair(1273, "ERROR_CALLBACK_SUPPLIED_INVALID_DATA")); + ErrorNames.insert(std::make_pair(1274, "ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED")); + ErrorNames.insert(std::make_pair(1275, "ERROR_DRIVER_BLOCKED")); + ErrorNames.insert(std::make_pair(1276, "ERROR_INVALID_IMPORT_OF_NON_DLL")); + ErrorNames.insert(std::make_pair(1277, "ERROR_ACCESS_DISABLED_WEBBLADE")); + ErrorNames.insert(std::make_pair(1278, "ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER")); + ErrorNames.insert(std::make_pair(1279, "ERROR_RECOVERY_FAILURE")); + ErrorNames.insert(std::make_pair(1280, "ERROR_ALREADY_FIBER")); + ErrorNames.insert(std::make_pair(1281, "ERROR_ALREADY_THREAD")); + ErrorNames.insert(std::make_pair(1282, "ERROR_STACK_BUFFER_OVERRUN")); + ErrorNames.insert(std::make_pair(1283, "ERROR_PARAMETER_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(1284, "ERROR_DEBUGGER_INACTIVE")); + ErrorNames.insert(std::make_pair(1285, "ERROR_DELAY_LOAD_FAILED")); + ErrorNames.insert(std::make_pair(1286, "ERROR_VDM_DISALLOWED")); + ErrorNames.insert(std::make_pair(1287, "ERROR_UNIDENTIFIED_ERROR")); + ErrorNames.insert(std::make_pair(1288, "ERROR_INVALID_CRUNTIME_PARAMETER")); + ErrorNames.insert(std::make_pair(1289, "ERROR_BEYOND_VDL")); + ErrorNames.insert(std::make_pair(1290, "ERROR_INCOMPATIBLE_SERVICE_SID_TYPE")); + ErrorNames.insert(std::make_pair(1291, "ERROR_DRIVER_PROCESS_TERMINATED")); + ErrorNames.insert(std::make_pair(1292, "ERROR_IMPLEMENTATION_LIMIT")); + ErrorNames.insert(std::make_pair(1293, "ERROR_PROCESS_IS_PROTECTED")); + ErrorNames.insert(std::make_pair(1294, "ERROR_SERVICE_NOTIFY_CLIENT_LAGGING")); + ErrorNames.insert(std::make_pair(1295, "ERROR_DISK_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(1296, "ERROR_CONTENT_BLOCKED")); + ErrorNames.insert(std::make_pair(1297, "ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE")); + ErrorNames.insert(std::make_pair(1298, "ERROR_APP_HANG")); + ErrorNames.insert(std::make_pair(1299, "ERROR_INVALID_LABEL")); + ErrorNames.insert(std::make_pair(1300, "ERROR_NOT_ALL_ASSIGNED")); + ErrorNames.insert(std::make_pair(1301, "ERROR_SOME_NOT_MAPPED")); + ErrorNames.insert(std::make_pair(1302, "ERROR_NO_QUOTAS_FOR_ACCOUNT")); + ErrorNames.insert(std::make_pair(1303, "ERROR_LOCAL_USER_SESSION_KEY")); + ErrorNames.insert(std::make_pair(1304, "ERROR_NULL_LM_PASSWORD")); + ErrorNames.insert(std::make_pair(1305, "ERROR_UNKNOWN_REVISION")); + ErrorNames.insert(std::make_pair(1306, "ERROR_REVISION_MISMATCH")); + ErrorNames.insert(std::make_pair(1307, "ERROR_INVALID_OWNER")); + ErrorNames.insert(std::make_pair(1308, "ERROR_INVALID_PRIMARY_GROUP")); + ErrorNames.insert(std::make_pair(1309, "ERROR_NO_IMPERSONATION_TOKEN")); + ErrorNames.insert(std::make_pair(1310, "ERROR_CANT_DISABLE_MANDATORY")); + ErrorNames.insert(std::make_pair(1311, "ERROR_NO_LOGON_SERVERS")); + ErrorNames.insert(std::make_pair(1312, "ERROR_NO_SUCH_LOGON_SESSION")); + ErrorNames.insert(std::make_pair(1313, "ERROR_NO_SUCH_PRIVILEGE")); + ErrorNames.insert(std::make_pair(1314, "ERROR_PRIVILEGE_NOT_HELD")); + ErrorNames.insert(std::make_pair(1315, "ERROR_INVALID_ACCOUNT_NAME")); + ErrorNames.insert(std::make_pair(1316, "ERROR_USER_EXISTS")); + ErrorNames.insert(std::make_pair(1317, "ERROR_NO_SUCH_USER")); + ErrorNames.insert(std::make_pair(1318, "ERROR_GROUP_EXISTS")); + ErrorNames.insert(std::make_pair(1319, "ERROR_NO_SUCH_GROUP")); + ErrorNames.insert(std::make_pair(1320, "ERROR_MEMBER_IN_GROUP")); + ErrorNames.insert(std::make_pair(1321, "ERROR_MEMBER_NOT_IN_GROUP")); + ErrorNames.insert(std::make_pair(1322, "ERROR_LAST_ADMIN")); + ErrorNames.insert(std::make_pair(1323, "ERROR_WRONG_PASSWORD")); + ErrorNames.insert(std::make_pair(1324, "ERROR_ILL_FORMED_PASSWORD")); + ErrorNames.insert(std::make_pair(1325, "ERROR_PASSWORD_RESTRICTION")); + ErrorNames.insert(std::make_pair(1326, "ERROR_LOGON_FAILURE")); + ErrorNames.insert(std::make_pair(1327, "ERROR_ACCOUNT_RESTRICTION")); + ErrorNames.insert(std::make_pair(1328, "ERROR_INVALID_LOGON_HOURS")); + ErrorNames.insert(std::make_pair(1329, "ERROR_INVALID_WORKSTATION")); + ErrorNames.insert(std::make_pair(1330, "ERROR_PASSWORD_EXPIRED")); + ErrorNames.insert(std::make_pair(1331, "ERROR_ACCOUNT_DISABLED")); + ErrorNames.insert(std::make_pair(1332, "ERROR_NONE_MAPPED")); + ErrorNames.insert(std::make_pair(1333, "ERROR_TOO_MANY_LUIDS_REQUESTED")); + ErrorNames.insert(std::make_pair(1334, "ERROR_LUIDS_EXHAUSTED")); + ErrorNames.insert(std::make_pair(1335, "ERROR_INVALID_SUB_AUTHORITY")); + ErrorNames.insert(std::make_pair(1336, "ERROR_INVALID_ACL")); + ErrorNames.insert(std::make_pair(1337, "ERROR_INVALID_SID")); + ErrorNames.insert(std::make_pair(1338, "ERROR_INVALID_SECURITY_DESCR")); + ErrorNames.insert(std::make_pair(1340, "ERROR_BAD_INHERITANCE_ACL")); + ErrorNames.insert(std::make_pair(1341, "ERROR_SERVER_DISABLED")); + ErrorNames.insert(std::make_pair(1342, "ERROR_SERVER_NOT_DISABLED")); + ErrorNames.insert(std::make_pair(1343, "ERROR_INVALID_ID_AUTHORITY")); + ErrorNames.insert(std::make_pair(1344, "ERROR_ALLOTTED_SPACE_EXCEEDED")); + ErrorNames.insert(std::make_pair(1345, "ERROR_INVALID_GROUP_ATTRIBUTES")); + ErrorNames.insert(std::make_pair(1346, "ERROR_BAD_IMPERSONATION_LEVEL")); + ErrorNames.insert(std::make_pair(1347, "ERROR_CANT_OPEN_ANONYMOUS")); + ErrorNames.insert(std::make_pair(1348, "ERROR_BAD_VALIDATION_CLASS")); + ErrorNames.insert(std::make_pair(1349, "ERROR_BAD_TOKEN_TYPE")); + ErrorNames.insert(std::make_pair(1350, "ERROR_NO_SECURITY_ON_OBJECT")); + ErrorNames.insert(std::make_pair(1351, "ERROR_CANT_ACCESS_DOMAIN_INFO")); + ErrorNames.insert(std::make_pair(1352, "ERROR_INVALID_SERVER_STATE")); + ErrorNames.insert(std::make_pair(1353, "ERROR_INVALID_DOMAIN_STATE")); + ErrorNames.insert(std::make_pair(1354, "ERROR_INVALID_DOMAIN_ROLE")); + ErrorNames.insert(std::make_pair(1355, "ERROR_NO_SUCH_DOMAIN")); + ErrorNames.insert(std::make_pair(1356, "ERROR_DOMAIN_EXISTS")); + ErrorNames.insert(std::make_pair(1357, "ERROR_DOMAIN_LIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(1358, "ERROR_INTERNAL_DB_CORRUPTION")); + ErrorNames.insert(std::make_pair(1359, "ERROR_INTERNAL_ERROR")); + ErrorNames.insert(std::make_pair(1360, "ERROR_GENERIC_NOT_MAPPED")); + ErrorNames.insert(std::make_pair(1361, "ERROR_BAD_DESCRIPTOR_FORMAT")); + ErrorNames.insert(std::make_pair(1362, "ERROR_NOT_LOGON_PROCESS")); + ErrorNames.insert(std::make_pair(1363, "ERROR_LOGON_SESSION_EXISTS")); + ErrorNames.insert(std::make_pair(1364, "ERROR_NO_SUCH_PACKAGE")); + ErrorNames.insert(std::make_pair(1365, "ERROR_BAD_LOGON_SESSION_STATE")); + ErrorNames.insert(std::make_pair(1366, "ERROR_LOGON_SESSION_COLLISION")); + ErrorNames.insert(std::make_pair(1367, "ERROR_INVALID_LOGON_TYPE")); + ErrorNames.insert(std::make_pair(1368, "ERROR_CANNOT_IMPERSONATE")); + ErrorNames.insert(std::make_pair(1369, "ERROR_RXACT_INVALID_STATE")); + ErrorNames.insert(std::make_pair(1370, "ERROR_RXACT_COMMIT_FAILURE")); + ErrorNames.insert(std::make_pair(1371, "ERROR_SPECIAL_ACCOUNT")); + ErrorNames.insert(std::make_pair(1372, "ERROR_SPECIAL_GROUP")); + ErrorNames.insert(std::make_pair(1373, "ERROR_SPECIAL_USER")); + ErrorNames.insert(std::make_pair(1374, "ERROR_MEMBERS_PRIMARY_GROUP")); + ErrorNames.insert(std::make_pair(1375, "ERROR_TOKEN_ALREADY_IN_USE")); + ErrorNames.insert(std::make_pair(1376, "ERROR_NO_SUCH_ALIAS")); + ErrorNames.insert(std::make_pair(1377, "ERROR_MEMBER_NOT_IN_ALIAS")); + ErrorNames.insert(std::make_pair(1378, "ERROR_MEMBER_IN_ALIAS")); + ErrorNames.insert(std::make_pair(1379, "ERROR_ALIAS_EXISTS")); + ErrorNames.insert(std::make_pair(1380, "ERROR_LOGON_NOT_GRANTED")); + ErrorNames.insert(std::make_pair(1381, "ERROR_TOO_MANY_SECRETS")); + ErrorNames.insert(std::make_pair(1382, "ERROR_SECRET_TOO_LONG")); + ErrorNames.insert(std::make_pair(1383, "ERROR_INTERNAL_DB_ERROR")); + ErrorNames.insert(std::make_pair(1384, "ERROR_TOO_MANY_CONTEXT_IDS")); + ErrorNames.insert(std::make_pair(1385, "ERROR_LOGON_TYPE_NOT_GRANTED")); + ErrorNames.insert(std::make_pair(1386, "ERROR_NT_CROSS_ENCRYPTION_REQUIRED")); + ErrorNames.insert(std::make_pair(1387, "ERROR_NO_SUCH_MEMBER")); + ErrorNames.insert(std::make_pair(1388, "ERROR_INVALID_MEMBER")); + ErrorNames.insert(std::make_pair(1389, "ERROR_TOO_MANY_SIDS")); + ErrorNames.insert(std::make_pair(1390, "ERROR_LM_CROSS_ENCRYPTION_REQUIRED")); + ErrorNames.insert(std::make_pair(1391, "ERROR_NO_INHERITANCE")); + ErrorNames.insert(std::make_pair(1392, "ERROR_FILE_CORRUPT")); + ErrorNames.insert(std::make_pair(1393, "ERROR_DISK_CORRUPT")); + ErrorNames.insert(std::make_pair(1394, "ERROR_NO_USER_SESSION_KEY")); + ErrorNames.insert(std::make_pair(1395, "ERROR_LICENSE_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(1396, "ERROR_WRONG_TARGET_NAME")); + ErrorNames.insert(std::make_pair(1397, "ERROR_MUTUAL_AUTH_FAILED")); + ErrorNames.insert(std::make_pair(1398, "ERROR_TIME_SKEW")); + ErrorNames.insert(std::make_pair(1399, "ERROR_CURRENT_DOMAIN_NOT_ALLOWED")); + ErrorNames.insert(std::make_pair(1400, "ERROR_INVALID_WINDOW_HANDLE")); + ErrorNames.insert(std::make_pair(1401, "ERROR_INVALID_MENU_HANDLE")); + ErrorNames.insert(std::make_pair(1402, "ERROR_INVALID_CURSOR_HANDLE")); + ErrorNames.insert(std::make_pair(1403, "ERROR_INVALID_ACCEL_HANDLE")); + ErrorNames.insert(std::make_pair(1404, "ERROR_INVALID_HOOK_HANDLE")); + ErrorNames.insert(std::make_pair(1405, "ERROR_INVALID_DWP_HANDLE")); + ErrorNames.insert(std::make_pair(1406, "ERROR_TLW_WITH_WSCHILD")); + ErrorNames.insert(std::make_pair(1407, "ERROR_CANNOT_FIND_WND_CLASS")); + ErrorNames.insert(std::make_pair(1408, "ERROR_WINDOW_OF_OTHER_THREAD")); + ErrorNames.insert(std::make_pair(1409, "ERROR_HOTKEY_ALREADY_REGISTERED")); + ErrorNames.insert(std::make_pair(1410, "ERROR_CLASS_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(1411, "ERROR_CLASS_DOES_NOT_EXIST")); + ErrorNames.insert(std::make_pair(1412, "ERROR_CLASS_HAS_WINDOWS")); + ErrorNames.insert(std::make_pair(1413, "ERROR_INVALID_INDEX")); + ErrorNames.insert(std::make_pair(1414, "ERROR_INVALID_ICON_HANDLE")); + ErrorNames.insert(std::make_pair(1415, "ERROR_PRIVATE_DIALOG_INDEX")); + ErrorNames.insert(std::make_pair(1416, "ERROR_LISTBOX_ID_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1417, "ERROR_NO_WILDCARD_CHARACTERS")); + ErrorNames.insert(std::make_pair(1418, "ERROR_CLIPBOARD_NOT_OPEN")); + ErrorNames.insert(std::make_pair(1419, "ERROR_HOTKEY_NOT_REGISTERED")); + ErrorNames.insert(std::make_pair(1420, "ERROR_WINDOW_NOT_DIALOG")); + ErrorNames.insert(std::make_pair(1421, "ERROR_CONTROL_ID_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1422, "ERROR_INVALID_COMBOBOX_MESSAGE")); + ErrorNames.insert(std::make_pair(1423, "ERROR_WINDOW_NOT_COMBOBOX")); + ErrorNames.insert(std::make_pair(1424, "ERROR_INVALID_EDIT_HEIGHT")); + ErrorNames.insert(std::make_pair(1425, "ERROR_DC_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1426, "ERROR_INVALID_HOOK_FILTER")); + ErrorNames.insert(std::make_pair(1427, "ERROR_INVALID_FILTER_PROC")); + ErrorNames.insert(std::make_pair(1428, "ERROR_HOOK_NEEDS_HMOD")); + ErrorNames.insert(std::make_pair(1429, "ERROR_GLOBAL_ONLY_HOOK")); + ErrorNames.insert(std::make_pair(1430, "ERROR_JOURNAL_HOOK_SET")); + ErrorNames.insert(std::make_pair(1431, "ERROR_HOOK_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(1432, "ERROR_INVALID_LB_MESSAGE")); + ErrorNames.insert(std::make_pair(1433, "ERROR_SETCOUNT_ON_BAD_LB")); + ErrorNames.insert(std::make_pair(1434, "ERROR_LB_WITHOUT_TABSTOPS")); + ErrorNames.insert(std::make_pair(1435, "ERROR_DESTROY_OBJECT_OF_OTHER_THREAD")); + ErrorNames.insert(std::make_pair(1436, "ERROR_CHILD_WINDOW_MENU")); + ErrorNames.insert(std::make_pair(1437, "ERROR_NO_SYSTEM_MENU")); + ErrorNames.insert(std::make_pair(1438, "ERROR_INVALID_MSGBOX_STYLE")); + ErrorNames.insert(std::make_pair(1439, "ERROR_INVALID_SPI_VALUE")); + ErrorNames.insert(std::make_pair(1440, "ERROR_SCREEN_ALREADY_LOCKED")); + ErrorNames.insert(std::make_pair(1441, "ERROR_HWNDS_HAVE_DIFF_PARENT")); + ErrorNames.insert(std::make_pair(1442, "ERROR_NOT_CHILD_WINDOW")); + ErrorNames.insert(std::make_pair(1443, "ERROR_INVALID_GW_COMMAND")); + ErrorNames.insert(std::make_pair(1444, "ERROR_INVALID_THREAD_ID")); + ErrorNames.insert(std::make_pair(1445, "ERROR_NON_MDICHILD_WINDOW")); + ErrorNames.insert(std::make_pair(1446, "ERROR_POPUP_ALREADY_ACTIVE")); + ErrorNames.insert(std::make_pair(1447, "ERROR_NO_SCROLLBARS")); + ErrorNames.insert(std::make_pair(1448, "ERROR_INVALID_SCROLLBAR_RANGE")); + ErrorNames.insert(std::make_pair(1449, "ERROR_INVALID_SHOWWIN_COMMAND")); + ErrorNames.insert(std::make_pair(1450, "ERROR_NO_SYSTEM_RESOURCES")); + ErrorNames.insert(std::make_pair(1451, "ERROR_NONPAGED_SYSTEM_RESOURCES")); + ErrorNames.insert(std::make_pair(1452, "ERROR_PAGED_SYSTEM_RESOURCES")); + ErrorNames.insert(std::make_pair(1453, "ERROR_WORKING_SET_QUOTA")); + ErrorNames.insert(std::make_pair(1454, "ERROR_PAGEFILE_QUOTA")); + ErrorNames.insert(std::make_pair(1455, "ERROR_COMMITMENT_LIMIT")); + ErrorNames.insert(std::make_pair(1456, "ERROR_MENU_ITEM_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1457, "ERROR_INVALID_KEYBOARD_HANDLE")); + ErrorNames.insert(std::make_pair(1458, "ERROR_HOOK_TYPE_NOT_ALLOWED")); + ErrorNames.insert(std::make_pair(1459, "ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION")); + ErrorNames.insert(std::make_pair(1460, "ERROR_TIMEOUT")); + ErrorNames.insert(std::make_pair(1461, "ERROR_INVALID_MONITOR_HANDLE")); + ErrorNames.insert(std::make_pair(1462, "ERROR_INCORRECT_SIZE")); + ErrorNames.insert(std::make_pair(1463, "ERROR_SYMLINK_CLASS_DISABLED")); + ErrorNames.insert(std::make_pair(1464, "ERROR_SYMLINK_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(1465, "ERROR_XML_PARSE_ERROR")); + ErrorNames.insert(std::make_pair(1466, "ERROR_XMLDSIG_ERROR")); + ErrorNames.insert(std::make_pair(1467, "ERROR_RESTART_APPLICATION")); + ErrorNames.insert(std::make_pair(1468, "ERROR_WRONG_COMPARTMENT")); + ErrorNames.insert(std::make_pair(1469, "ERROR_AUTHIP_FAILURE")); + ErrorNames.insert(std::make_pair(1470, "ERROR_NO_NVRAM_RESOURCES")); + ErrorNames.insert(std::make_pair(1500, "ERROR_EVENTLOG_FILE_CORRUPT")); + ErrorNames.insert(std::make_pair(1501, "ERROR_EVENTLOG_CANT_START")); + ErrorNames.insert(std::make_pair(1502, "ERROR_LOG_FILE_FULL")); + ErrorNames.insert(std::make_pair(1503, "ERROR_EVENTLOG_FILE_CHANGED")); + ErrorNames.insert(std::make_pair(1550, "ERROR_INVALID_TASK_NAME")); + ErrorNames.insert(std::make_pair(1551, "ERROR_INVALID_TASK_INDEX")); + ErrorNames.insert(std::make_pair(1552, "ERROR_THREAD_ALREADY_IN_TASK")); + ErrorNames.insert(std::make_pair(1601, "ERROR_INSTALL_SERVICE_FAILURE")); + ErrorNames.insert(std::make_pair(1602, "ERROR_INSTALL_USEREXIT")); + ErrorNames.insert(std::make_pair(1603, "ERROR_INSTALL_FAILURE")); + ErrorNames.insert(std::make_pair(1604, "ERROR_INSTALL_SUSPEND")); + ErrorNames.insert(std::make_pair(1605, "ERROR_UNKNOWN_PRODUCT")); + ErrorNames.insert(std::make_pair(1606, "ERROR_UNKNOWN_FEATURE")); + ErrorNames.insert(std::make_pair(1607, "ERROR_UNKNOWN_COMPONENT")); + ErrorNames.insert(std::make_pair(1608, "ERROR_UNKNOWN_PROPERTY")); + ErrorNames.insert(std::make_pair(1609, "ERROR_INVALID_HANDLE_STATE")); + ErrorNames.insert(std::make_pair(1610, "ERROR_BAD_CONFIGURATION")); + ErrorNames.insert(std::make_pair(1611, "ERROR_INDEX_ABSENT")); + ErrorNames.insert(std::make_pair(1612, "ERROR_INSTALL_SOURCE_ABSENT")); + ErrorNames.insert(std::make_pair(1613, "ERROR_INSTALL_PACKAGE_VERSION")); + ErrorNames.insert(std::make_pair(1614, "ERROR_PRODUCT_UNINSTALLED")); + ErrorNames.insert(std::make_pair(1615, "ERROR_BAD_QUERY_SYNTAX")); + ErrorNames.insert(std::make_pair(1616, "ERROR_INVALID_FIELD")); + ErrorNames.insert(std::make_pair(1617, "ERROR_DEVICE_REMOVED")); + ErrorNames.insert(std::make_pair(1618, "ERROR_INSTALL_ALREADY_RUNNING")); + ErrorNames.insert(std::make_pair(1619, "ERROR_INSTALL_PACKAGE_OPEN_FAILED")); + ErrorNames.insert(std::make_pair(1620, "ERROR_INSTALL_PACKAGE_INVALID")); + ErrorNames.insert(std::make_pair(1621, "ERROR_INSTALL_UI_FAILURE")); + ErrorNames.insert(std::make_pair(1622, "ERROR_INSTALL_LOG_FAILURE")); + ErrorNames.insert(std::make_pair(1623, "ERROR_INSTALL_LANGUAGE_UNSUPPORTED")); + ErrorNames.insert(std::make_pair(1624, "ERROR_INSTALL_TRANSFORM_FAILURE")); + ErrorNames.insert(std::make_pair(1625, "ERROR_INSTALL_PACKAGE_REJECTED")); + ErrorNames.insert(std::make_pair(1626, "ERROR_FUNCTION_NOT_CALLED")); + ErrorNames.insert(std::make_pair(1627, "ERROR_FUNCTION_FAILED")); + ErrorNames.insert(std::make_pair(1628, "ERROR_INVALID_TABLE")); + ErrorNames.insert(std::make_pair(1629, "ERROR_DATATYPE_MISMATCH")); + ErrorNames.insert(std::make_pair(1630, "ERROR_UNSUPPORTED_TYPE")); + ErrorNames.insert(std::make_pair(1631, "ERROR_CREATE_FAILED")); + ErrorNames.insert(std::make_pair(1632, "ERROR_INSTALL_TEMP_UNWRITABLE")); + ErrorNames.insert(std::make_pair(1633, "ERROR_INSTALL_PLATFORM_UNSUPPORTED")); + ErrorNames.insert(std::make_pair(1634, "ERROR_INSTALL_NOTUSED")); + ErrorNames.insert(std::make_pair(1635, "ERROR_PATCH_PACKAGE_OPEN_FAILED")); + ErrorNames.insert(std::make_pair(1636, "ERROR_PATCH_PACKAGE_INVALID")); + ErrorNames.insert(std::make_pair(1637, "ERROR_PATCH_PACKAGE_UNSUPPORTED")); + ErrorNames.insert(std::make_pair(1638, "ERROR_PRODUCT_VERSION")); + ErrorNames.insert(std::make_pair(1639, "ERROR_INVALID_COMMAND_LINE")); + ErrorNames.insert(std::make_pair(1640, "ERROR_INSTALL_REMOTE_DISALLOWED")); + ErrorNames.insert(std::make_pair(1641, "ERROR_SUCCESS_REBOOT_INITIATED")); + ErrorNames.insert(std::make_pair(1642, "ERROR_PATCH_TARGET_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1643, "ERROR_PATCH_PACKAGE_REJECTED")); + ErrorNames.insert(std::make_pair(1644, "ERROR_INSTALL_TRANSFORM_REJECTED")); + ErrorNames.insert(std::make_pair(1645, "ERROR_INSTALL_REMOTE_PROHIBITED")); + ErrorNames.insert(std::make_pair(1646, "ERROR_PATCH_REMOVAL_UNSUPPORTED")); + ErrorNames.insert(std::make_pair(1647, "ERROR_UNKNOWN_PATCH")); + ErrorNames.insert(std::make_pair(1648, "ERROR_PATCH_NO_SEQUENCE")); + ErrorNames.insert(std::make_pair(1649, "ERROR_PATCH_REMOVAL_DISALLOWED")); + ErrorNames.insert(std::make_pair(1650, "ERROR_INVALID_PATCH_XML")); + ErrorNames.insert(std::make_pair(1651, "ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT")); + ErrorNames.insert(std::make_pair(1652, "ERROR_INSTALL_SERVICE_SAFEBOOT")); + ErrorNames.insert(std::make_pair(1653, "ERROR_FAIL_FAST_EXCEPTION")); + ErrorNames.insert(std::make_pair(1784, "ERROR_INVALID_USER_BUFFER")); + ErrorNames.insert(std::make_pair(1785, "ERROR_UNRECOGNIZED_MEDIA")); + ErrorNames.insert(std::make_pair(1786, "ERROR_NO_TRUST_LSA_SECRET")); + ErrorNames.insert(std::make_pair(1787, "ERROR_NO_TRUST_SAM_ACCOUNT")); + ErrorNames.insert(std::make_pair(1788, "ERROR_TRUSTED_DOMAIN_FAILURE")); + ErrorNames.insert(std::make_pair(1789, "ERROR_TRUSTED_RELATIONSHIP_FAILURE")); + ErrorNames.insert(std::make_pair(1790, "ERROR_TRUST_FAILURE")); + ErrorNames.insert(std::make_pair(1792, "ERROR_NETLOGON_NOT_STARTED")); + ErrorNames.insert(std::make_pair(1793, "ERROR_ACCOUNT_EXPIRED")); + ErrorNames.insert(std::make_pair(1794, "ERROR_REDIRECTOR_HAS_OPEN_HANDLES")); + ErrorNames.insert(std::make_pair(1795, "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED")); + ErrorNames.insert(std::make_pair(1796, "ERROR_UNKNOWN_PORT")); + ErrorNames.insert(std::make_pair(1797, "ERROR_UNKNOWN_PRINTER_DRIVER")); + ErrorNames.insert(std::make_pair(1798, "ERROR_UNKNOWN_PRINTPROCESSOR")); + ErrorNames.insert(std::make_pair(1799, "ERROR_INVALID_SEPARATOR_FILE")); + ErrorNames.insert(std::make_pair(1800, "ERROR_INVALID_PRIORITY")); + ErrorNames.insert(std::make_pair(1801, "ERROR_INVALID_PRINTER_NAME")); + ErrorNames.insert(std::make_pair(1802, "ERROR_PRINTER_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(1803, "ERROR_INVALID_PRINTER_COMMAND")); + ErrorNames.insert(std::make_pair(1804, "ERROR_INVALID_DATATYPE")); + ErrorNames.insert(std::make_pair(1805, "ERROR_INVALID_ENVIRONMENT")); + ErrorNames.insert(std::make_pair(1807, "ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT")); + ErrorNames.insert(std::make_pair(1808, "ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT")); + ErrorNames.insert(std::make_pair(1809, "ERROR_NOLOGON_SERVER_TRUST_ACCOUNT")); + ErrorNames.insert(std::make_pair(1810, "ERROR_DOMAIN_TRUST_INCONSISTENT")); + ErrorNames.insert(std::make_pair(1811, "ERROR_SERVER_HAS_OPEN_HANDLES")); + ErrorNames.insert(std::make_pair(1812, "ERROR_RESOURCE_DATA_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1813, "ERROR_RESOURCE_TYPE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1814, "ERROR_RESOURCE_NAME_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1815, "ERROR_RESOURCE_LANG_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1816, "ERROR_NOT_ENOUGH_QUOTA")); + ErrorNames.insert(std::make_pair(1901, "ERROR_INVALID_TIME")); + ErrorNames.insert(std::make_pair(1902, "ERROR_INVALID_FORM_NAME")); + ErrorNames.insert(std::make_pair(1903, "ERROR_INVALID_FORM_SIZE")); + ErrorNames.insert(std::make_pair(1904, "ERROR_ALREADY_WAITING")); + ErrorNames.insert(std::make_pair(1905, "ERROR_PRINTER_DELETED")); + ErrorNames.insert(std::make_pair(1906, "ERROR_INVALID_PRINTER_STATE")); + ErrorNames.insert(std::make_pair(1907, "ERROR_PASSWORD_MUST_CHANGE")); + ErrorNames.insert(std::make_pair(1908, "ERROR_DOMAIN_CONTROLLER_NOT_FOUND")); + ErrorNames.insert(std::make_pair(1909, "ERROR_ACCOUNT_LOCKED_OUT")); + ErrorNames.insert(std::make_pair(1919, "ERROR_NO_SITENAME")); + ErrorNames.insert(std::make_pair(1920, "ERROR_CANT_ACCESS_FILE")); + ErrorNames.insert(std::make_pair(1921, "ERROR_CANT_RESOLVE_FILENAME")); + ErrorNames.insert(std::make_pair(1930, "ERROR_KM_DRIVER_BLOCKED")); + ErrorNames.insert(std::make_pair(1931, "ERROR_CONTEXT_EXPIRED")); + ErrorNames.insert(std::make_pair(1932, "ERROR_PER_USER_TRUST_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(1933, "ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(1934, "ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(1935, "ERROR_AUTHENTICATION_FIREWALL_FAILED")); + ErrorNames.insert(std::make_pair(1936, "ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED")); + ErrorNames.insert(std::make_pair(1937, "ERROR_NTLM_BLOCKED")); + ErrorNames.insert(std::make_pair(2000, "ERROR_INVALID_PIXEL_FORMAT")); + ErrorNames.insert(std::make_pair(2001, "ERROR_BAD_DRIVER")); + ErrorNames.insert(std::make_pair(2002, "ERROR_INVALID_WINDOW_STYLE")); + ErrorNames.insert(std::make_pair(2003, "ERROR_METAFILE_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(2004, "ERROR_TRANSFORM_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(2005, "ERROR_CLIPPING_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(2010, "ERROR_INVALID_CMM")); + ErrorNames.insert(std::make_pair(2011, "ERROR_INVALID_PROFILE")); + ErrorNames.insert(std::make_pair(2012, "ERROR_TAG_NOT_FOUND")); + ErrorNames.insert(std::make_pair(2013, "ERROR_TAG_NOT_PRESENT")); + ErrorNames.insert(std::make_pair(2014, "ERROR_DUPLICATE_TAG")); + ErrorNames.insert(std::make_pair(2015, "ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE")); + ErrorNames.insert(std::make_pair(2016, "ERROR_PROFILE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(2017, "ERROR_INVALID_COLORSPACE")); + ErrorNames.insert(std::make_pair(2018, "ERROR_ICM_NOT_ENABLED")); + ErrorNames.insert(std::make_pair(2019, "ERROR_DELETING_ICM_XFORM")); + ErrorNames.insert(std::make_pair(2020, "ERROR_INVALID_TRANSFORM")); + ErrorNames.insert(std::make_pair(2021, "ERROR_COLORSPACE_MISMATCH")); + ErrorNames.insert(std::make_pair(2022, "ERROR_INVALID_COLORINDEX")); + ErrorNames.insert(std::make_pair(2023, "ERROR_PROFILE_DOES_NOT_MATCH_DEVICE")); + ErrorNames.insert(std::make_pair(2108, "ERROR_CONNECTED_OTHER_PASSWORD")); + ErrorNames.insert(std::make_pair(2109, "ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT")); + ErrorNames.insert(std::make_pair(2202, "ERROR_BAD_USERNAME")); + ErrorNames.insert(std::make_pair(2250, "ERROR_NOT_CONNECTED")); + ErrorNames.insert(std::make_pair(2401, "ERROR_OPEN_FILES")); + ErrorNames.insert(std::make_pair(2402, "ERROR_ACTIVE_CONNECTIONS")); + ErrorNames.insert(std::make_pair(2404, "ERROR_DEVICE_IN_USE")); + ErrorNames.insert(std::make_pair(3000, "ERROR_UNKNOWN_PRINT_MONITOR")); + ErrorNames.insert(std::make_pair(3001, "ERROR_PRINTER_DRIVER_IN_USE")); + ErrorNames.insert(std::make_pair(3002, "ERROR_SPOOL_FILE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(3003, "ERROR_SPL_NO_STARTDOC")); + ErrorNames.insert(std::make_pair(3004, "ERROR_SPL_NO_ADDJOB")); + ErrorNames.insert(std::make_pair(3005, "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED")); + ErrorNames.insert(std::make_pair(3006, "ERROR_PRINT_MONITOR_ALREADY_INSTALLED")); + ErrorNames.insert(std::make_pair(3007, "ERROR_INVALID_PRINT_MONITOR")); + ErrorNames.insert(std::make_pair(3008, "ERROR_PRINT_MONITOR_IN_USE")); + ErrorNames.insert(std::make_pair(3009, "ERROR_PRINTER_HAS_JOBS_QUEUED")); + ErrorNames.insert(std::make_pair(3010, "ERROR_SUCCESS_REBOOT_REQUIRED")); + ErrorNames.insert(std::make_pair(3011, "ERROR_SUCCESS_RESTART_REQUIRED")); + ErrorNames.insert(std::make_pair(3012, "ERROR_PRINTER_NOT_FOUND")); + ErrorNames.insert(std::make_pair(3013, "ERROR_PRINTER_DRIVER_WARNED")); + ErrorNames.insert(std::make_pair(3014, "ERROR_PRINTER_DRIVER_BLOCKED")); + ErrorNames.insert(std::make_pair(3015, "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE")); + ErrorNames.insert(std::make_pair(3016, "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(3017, "ERROR_FAIL_REBOOT_REQUIRED")); + ErrorNames.insert(std::make_pair(3018, "ERROR_FAIL_REBOOT_INITIATED")); + ErrorNames.insert(std::make_pair(3019, "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED")); + ErrorNames.insert(std::make_pair(3020, "ERROR_PRINT_JOB_RESTART_REQUIRED")); + ErrorNames.insert(std::make_pair(3950, "ERROR_IO_REISSUE_AS_CACHED")); + ErrorNames.insert(std::make_pair(4000, "ERROR_WINS_INTERNAL")); + ErrorNames.insert(std::make_pair(4001, "ERROR_CAN_NOT_DEL_LOCAL_WINS")); + ErrorNames.insert(std::make_pair(4002, "ERROR_STATIC_INIT")); + ErrorNames.insert(std::make_pair(4003, "ERROR_INC_BACKUP")); + ErrorNames.insert(std::make_pair(4004, "ERROR_FULL_BACKUP")); + ErrorNames.insert(std::make_pair(4005, "ERROR_REC_NON_EXISTENT")); + ErrorNames.insert(std::make_pair(4006, "ERROR_RPL_NOT_ALLOWED")); + ErrorNames.insert(std::make_pair(4100, "ERROR_DHCP_ADDRESS_CONFLICT")); + ErrorNames.insert(std::make_pair(4200, "ERROR_WMI_GUID_NOT_FOUND")); + ErrorNames.insert(std::make_pair(4201, "ERROR_WMI_INSTANCE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(4202, "ERROR_WMI_ITEMID_NOT_FOUND")); + ErrorNames.insert(std::make_pair(4203, "ERROR_WMI_TRY_AGAIN")); + ErrorNames.insert(std::make_pair(4204, "ERROR_WMI_DP_NOT_FOUND")); + ErrorNames.insert(std::make_pair(4205, "ERROR_WMI_UNRESOLVED_INSTANCE_REF")); + ErrorNames.insert(std::make_pair(4206, "ERROR_WMI_ALREADY_ENABLED")); + ErrorNames.insert(std::make_pair(4207, "ERROR_WMI_GUID_DISCONNECTED")); + ErrorNames.insert(std::make_pair(4208, "ERROR_WMI_SERVER_UNAVAILABLE")); + ErrorNames.insert(std::make_pair(4209, "ERROR_WMI_DP_FAILED")); + ErrorNames.insert(std::make_pair(4210, "ERROR_WMI_INVALID_MOF")); + ErrorNames.insert(std::make_pair(4211, "ERROR_WMI_INVALID_REGINFO")); + ErrorNames.insert(std::make_pair(4212, "ERROR_WMI_ALREADY_DISABLED")); + ErrorNames.insert(std::make_pair(4213, "ERROR_WMI_READ_ONLY")); + ErrorNames.insert(std::make_pair(4214, "ERROR_WMI_SET_FAILURE")); + ErrorNames.insert(std::make_pair(4300, "ERROR_INVALID_MEDIA")); + ErrorNames.insert(std::make_pair(4301, "ERROR_INVALID_LIBRARY")); + ErrorNames.insert(std::make_pair(4302, "ERROR_INVALID_MEDIA_POOL")); + ErrorNames.insert(std::make_pair(4303, "ERROR_DRIVE_MEDIA_MISMATCH")); + ErrorNames.insert(std::make_pair(4304, "ERROR_MEDIA_OFFLINE")); + ErrorNames.insert(std::make_pair(4305, "ERROR_LIBRARY_OFFLINE")); + ErrorNames.insert(std::make_pair(4306, "ERROR_EMPTY")); + ErrorNames.insert(std::make_pair(4307, "ERROR_NOT_EMPTY")); + ErrorNames.insert(std::make_pair(4308, "ERROR_MEDIA_UNAVAILABLE")); + ErrorNames.insert(std::make_pair(4309, "ERROR_RESOURCE_DISABLED")); + ErrorNames.insert(std::make_pair(4310, "ERROR_INVALID_CLEANER")); + ErrorNames.insert(std::make_pair(4311, "ERROR_UNABLE_TO_CLEAN")); + ErrorNames.insert(std::make_pair(4312, "ERROR_OBJECT_NOT_FOUND")); + ErrorNames.insert(std::make_pair(4313, "ERROR_DATABASE_FAILURE")); + ErrorNames.insert(std::make_pair(4314, "ERROR_DATABASE_FULL")); + ErrorNames.insert(std::make_pair(4315, "ERROR_MEDIA_INCOMPATIBLE")); + ErrorNames.insert(std::make_pair(4316, "ERROR_RESOURCE_NOT_PRESENT")); + ErrorNames.insert(std::make_pair(4317, "ERROR_INVALID_OPERATION")); + ErrorNames.insert(std::make_pair(4318, "ERROR_MEDIA_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(4319, "ERROR_DEVICE_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(4320, "ERROR_REQUEST_REFUSED")); + ErrorNames.insert(std::make_pair(4321, "ERROR_INVALID_DRIVE_OBJECT")); + ErrorNames.insert(std::make_pair(4322, "ERROR_LIBRARY_FULL")); + ErrorNames.insert(std::make_pair(4323, "ERROR_MEDIUM_NOT_ACCESSIBLE")); + ErrorNames.insert(std::make_pair(4324, "ERROR_UNABLE_TO_LOAD_MEDIUM")); + ErrorNames.insert(std::make_pair(4325, "ERROR_UNABLE_TO_INVENTORY_DRIVE")); + ErrorNames.insert(std::make_pair(4326, "ERROR_UNABLE_TO_INVENTORY_SLOT")); + ErrorNames.insert(std::make_pair(4327, "ERROR_UNABLE_TO_INVENTORY_TRANSPORT")); + ErrorNames.insert(std::make_pair(4328, "ERROR_TRANSPORT_FULL")); + ErrorNames.insert(std::make_pair(4329, "ERROR_CONTROLLING_IEPORT")); + ErrorNames.insert(std::make_pair(4330, "ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA")); + ErrorNames.insert(std::make_pair(4331, "ERROR_CLEANER_SLOT_SET")); + ErrorNames.insert(std::make_pair(4332, "ERROR_CLEANER_SLOT_NOT_SET")); + ErrorNames.insert(std::make_pair(4333, "ERROR_CLEANER_CARTRIDGE_SPENT")); + ErrorNames.insert(std::make_pair(4334, "ERROR_UNEXPECTED_OMID")); + ErrorNames.insert(std::make_pair(4335, "ERROR_CANT_DELETE_LAST_ITEM")); + ErrorNames.insert(std::make_pair(4336, "ERROR_MESSAGE_EXCEEDS_MAX_SIZE")); + ErrorNames.insert(std::make_pair(4337, "ERROR_VOLUME_CONTAINS_SYS_FILES")); + ErrorNames.insert(std::make_pair(4338, "ERROR_INDIGENOUS_TYPE")); + ErrorNames.insert(std::make_pair(4339, "ERROR_NO_SUPPORTING_DRIVES")); + ErrorNames.insert(std::make_pair(4340, "ERROR_CLEANER_CARTRIDGE_INSTALLED")); + ErrorNames.insert(std::make_pair(4341, "ERROR_IEPORT_FULL")); + ErrorNames.insert(std::make_pair(4350, "ERROR_FILE_OFFLINE")); + ErrorNames.insert(std::make_pair(4351, "ERROR_REMOTE_STORAGE_NOT_ACTIVE")); + ErrorNames.insert(std::make_pair(4352, "ERROR_REMOTE_STORAGE_MEDIA_ERROR")); + ErrorNames.insert(std::make_pair(4390, "ERROR_NOT_A_REPARSE_POINT")); + ErrorNames.insert(std::make_pair(4391, "ERROR_REPARSE_ATTRIBUTE_CONFLICT")); + ErrorNames.insert(std::make_pair(4392, "ERROR_INVALID_REPARSE_DATA")); + ErrorNames.insert(std::make_pair(4393, "ERROR_REPARSE_TAG_INVALID")); + ErrorNames.insert(std::make_pair(4394, "ERROR_REPARSE_TAG_MISMATCH")); + ErrorNames.insert(std::make_pair(4500, "ERROR_VOLUME_NOT_SIS_ENABLED")); + ErrorNames.insert(std::make_pair(5001, "ERROR_DEPENDENT_RESOURCE_EXISTS")); + ErrorNames.insert(std::make_pair(5002, "ERROR_DEPENDENCY_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5003, "ERROR_DEPENDENCY_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(5004, "ERROR_RESOURCE_NOT_ONLINE")); + ErrorNames.insert(std::make_pair(5005, "ERROR_HOST_NODE_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(5006, "ERROR_RESOURCE_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(5007, "ERROR_RESOURCE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5008, "ERROR_SHUTDOWN_CLUSTER")); + ErrorNames.insert(std::make_pair(5009, "ERROR_CANT_EVICT_ACTIVE_NODE")); + ErrorNames.insert(std::make_pair(5010, "ERROR_OBJECT_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(5011, "ERROR_OBJECT_IN_LIST")); + ErrorNames.insert(std::make_pair(5012, "ERROR_GROUP_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(5013, "ERROR_GROUP_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5014, "ERROR_GROUP_NOT_ONLINE")); + ErrorNames.insert(std::make_pair(5015, "ERROR_HOST_NODE_NOT_RESOURCE_OWNER")); + ErrorNames.insert(std::make_pair(5016, "ERROR_HOST_NODE_NOT_GROUP_OWNER")); + ErrorNames.insert(std::make_pair(5017, "ERROR_RESMON_CREATE_FAILED")); + ErrorNames.insert(std::make_pair(5018, "ERROR_RESMON_ONLINE_FAILED")); + ErrorNames.insert(std::make_pair(5019, "ERROR_RESOURCE_ONLINE")); + ErrorNames.insert(std::make_pair(5020, "ERROR_QUORUM_RESOURCE")); + ErrorNames.insert(std::make_pair(5021, "ERROR_NOT_QUORUM_CAPABLE")); + ErrorNames.insert(std::make_pair(5022, "ERROR_CLUSTER_SHUTTING_DOWN")); + ErrorNames.insert(std::make_pair(5023, "ERROR_INVALID_STATE")); + ErrorNames.insert(std::make_pair(5024, "ERROR_RESOURCE_PROPERTIES_STORED")); + ErrorNames.insert(std::make_pair(5025, "ERROR_NOT_QUORUM_CLASS")); + ErrorNames.insert(std::make_pair(5026, "ERROR_CORE_RESOURCE")); + ErrorNames.insert(std::make_pair(5027, "ERROR_QUORUM_RESOURCE_ONLINE_FAILED")); + ErrorNames.insert(std::make_pair(5028, "ERROR_QUORUMLOG_OPEN_FAILED")); + ErrorNames.insert(std::make_pair(5029, "ERROR_CLUSTERLOG_CORRUPT")); + ErrorNames.insert(std::make_pair(5030, "ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE")); + ErrorNames.insert(std::make_pair(5031, "ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE")); + ErrorNames.insert(std::make_pair(5032, "ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5033, "ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE")); + ErrorNames.insert(std::make_pair(5034, "ERROR_QUORUM_OWNER_ALIVE")); + ErrorNames.insert(std::make_pair(5035, "ERROR_NETWORK_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(5036, "ERROR_NODE_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(5037, "ERROR_ALL_NODES_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(5038, "ERROR_RESOURCE_FAILED")); + ErrorNames.insert(std::make_pair(5039, "ERROR_CLUSTER_INVALID_NODE")); + ErrorNames.insert(std::make_pair(5040, "ERROR_CLUSTER_NODE_EXISTS")); + ErrorNames.insert(std::make_pair(5041, "ERROR_CLUSTER_JOIN_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(5042, "ERROR_CLUSTER_NODE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5043, "ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5044, "ERROR_CLUSTER_NETWORK_EXISTS")); + ErrorNames.insert(std::make_pair(5045, "ERROR_CLUSTER_NETWORK_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5046, "ERROR_CLUSTER_NETINTERFACE_EXISTS")); + ErrorNames.insert(std::make_pair(5047, "ERROR_CLUSTER_NETINTERFACE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5048, "ERROR_CLUSTER_INVALID_REQUEST")); + ErrorNames.insert(std::make_pair(5049, "ERROR_CLUSTER_INVALID_NETWORK_PROVIDER")); + ErrorNames.insert(std::make_pair(5050, "ERROR_CLUSTER_NODE_DOWN")); + ErrorNames.insert(std::make_pair(5051, "ERROR_CLUSTER_NODE_UNREACHABLE")); + ErrorNames.insert(std::make_pair(5052, "ERROR_CLUSTER_NODE_NOT_MEMBER")); + ErrorNames.insert(std::make_pair(5053, "ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(5054, "ERROR_CLUSTER_INVALID_NETWORK")); + ErrorNames.insert(std::make_pair(5056, "ERROR_CLUSTER_NODE_UP")); + ErrorNames.insert(std::make_pair(5057, "ERROR_CLUSTER_IPADDR_IN_USE")); + ErrorNames.insert(std::make_pair(5058, "ERROR_CLUSTER_NODE_NOT_PAUSED")); + ErrorNames.insert(std::make_pair(5059, "ERROR_CLUSTER_NO_SECURITY_CONTEXT")); + ErrorNames.insert(std::make_pair(5060, "ERROR_CLUSTER_NETWORK_NOT_INTERNAL")); + ErrorNames.insert(std::make_pair(5061, "ERROR_CLUSTER_NODE_ALREADY_UP")); + ErrorNames.insert(std::make_pair(5062, "ERROR_CLUSTER_NODE_ALREADY_DOWN")); + ErrorNames.insert(std::make_pair(5063, "ERROR_CLUSTER_NETWORK_ALREADY_ONLINE")); + ErrorNames.insert(std::make_pair(5064, "ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE")); + ErrorNames.insert(std::make_pair(5065, "ERROR_CLUSTER_NODE_ALREADY_MEMBER")); + ErrorNames.insert(std::make_pair(5066, "ERROR_CLUSTER_LAST_INTERNAL_NETWORK")); + ErrorNames.insert(std::make_pair(5067, "ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS")); + ErrorNames.insert(std::make_pair(5068, "ERROR_INVALID_OPERATION_ON_QUORUM")); + ErrorNames.insert(std::make_pair(5069, "ERROR_DEPENDENCY_NOT_ALLOWED")); + ErrorNames.insert(std::make_pair(5070, "ERROR_CLUSTER_NODE_PAUSED")); + ErrorNames.insert(std::make_pair(5071, "ERROR_NODE_CANT_HOST_RESOURCE")); + ErrorNames.insert(std::make_pair(5072, "ERROR_CLUSTER_NODE_NOT_READY")); + ErrorNames.insert(std::make_pair(5073, "ERROR_CLUSTER_NODE_SHUTTING_DOWN")); + ErrorNames.insert(std::make_pair(5074, "ERROR_CLUSTER_JOIN_ABORTED")); + ErrorNames.insert(std::make_pair(5075, "ERROR_CLUSTER_INCOMPATIBLE_VERSIONS")); + ErrorNames.insert(std::make_pair(5076, "ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED")); + ErrorNames.insert(std::make_pair(5077, "ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED")); + ErrorNames.insert(std::make_pair(5078, "ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5079, "ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(5080, "ERROR_CLUSTER_RESNAME_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5081, "ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED")); + ErrorNames.insert(std::make_pair(5082, "ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST")); + ErrorNames.insert(std::make_pair(5083, "ERROR_CLUSTER_DATABASE_SEQMISMATCH")); + ErrorNames.insert(std::make_pair(5084, "ERROR_RESMON_INVALID_STATE")); + ErrorNames.insert(std::make_pair(5085, "ERROR_CLUSTER_GUM_NOT_LOCKER")); + ErrorNames.insert(std::make_pair(5086, "ERROR_QUORUM_DISK_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5087, "ERROR_DATABASE_BACKUP_CORRUPT")); + ErrorNames.insert(std::make_pair(5088, "ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT")); + ErrorNames.insert(std::make_pair(5089, "ERROR_RESOURCE_PROPERTY_UNCHANGEABLE")); + ErrorNames.insert(std::make_pair(5890, "ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE")); + ErrorNames.insert(std::make_pair(5891, "ERROR_CLUSTER_QUORUMLOG_NOT_FOUND")); + ErrorNames.insert(std::make_pair(5892, "ERROR_CLUSTER_MEMBERSHIP_HALT")); + ErrorNames.insert(std::make_pair(5893, "ERROR_CLUSTER_INSTANCE_ID_MISMATCH")); + ErrorNames.insert(std::make_pair(5894, "ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP")); + ErrorNames.insert(std::make_pair(5895, "ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH")); + ErrorNames.insert(std::make_pair(5896, "ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP")); + ErrorNames.insert(std::make_pair(5897, "ERROR_CLUSTER_PARAMETER_MISMATCH")); + ErrorNames.insert(std::make_pair(5898, "ERROR_NODE_CANNOT_BE_CLUSTERED")); + ErrorNames.insert(std::make_pair(5899, "ERROR_CLUSTER_WRONG_OS_VERSION")); + ErrorNames.insert(std::make_pair(5900, "ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME")); + ErrorNames.insert(std::make_pair(5901, "ERROR_CLUSCFG_ALREADY_COMMITTED")); + ErrorNames.insert(std::make_pair(5902, "ERROR_CLUSCFG_ROLLBACK_FAILED")); + ErrorNames.insert(std::make_pair(5903, "ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT")); + ErrorNames.insert(std::make_pair(5904, "ERROR_CLUSTER_OLD_VERSION")); + ErrorNames.insert(std::make_pair(5905, "ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME")); + ErrorNames.insert(std::make_pair(5906, "ERROR_CLUSTER_NO_NET_ADAPTERS")); + ErrorNames.insert(std::make_pair(5907, "ERROR_CLUSTER_POISONED")); + ErrorNames.insert(std::make_pair(5908, "ERROR_CLUSTER_GROUP_MOVING")); + ErrorNames.insert(std::make_pair(5909, "ERROR_CLUSTER_RESOURCE_TYPE_BUSY")); + ErrorNames.insert(std::make_pair(5910, "ERROR_RESOURCE_CALL_TIMED_OUT")); + ErrorNames.insert(std::make_pair(5911, "ERROR_INVALID_CLUSTER_IPV6_ADDRESS")); + ErrorNames.insert(std::make_pair(5912, "ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION")); + ErrorNames.insert(std::make_pair(5913, "ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS")); + ErrorNames.insert(std::make_pair(5914, "ERROR_CLUSTER_PARTIAL_SEND")); + ErrorNames.insert(std::make_pair(5915, "ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION")); + ErrorNames.insert(std::make_pair(5916, "ERROR_CLUSTER_INVALID_STRING_TERMINATION")); + ErrorNames.insert(std::make_pair(5917, "ERROR_CLUSTER_INVALID_STRING_FORMAT")); + ErrorNames.insert(std::make_pair(5918, "ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(5919, "ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(5920, "ERROR_CLUSTER_NULL_DATA")); + ErrorNames.insert(std::make_pair(5921, "ERROR_CLUSTER_PARTIAL_READ")); + ErrorNames.insert(std::make_pair(5922, "ERROR_CLUSTER_PARTIAL_WRITE")); + ErrorNames.insert(std::make_pair(5923, "ERROR_CLUSTER_CANT_DESERIALIZE_DATA")); + ErrorNames.insert(std::make_pair(5924, "ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT")); + ErrorNames.insert(std::make_pair(5925, "ERROR_CLUSTER_NO_QUORUM")); + ErrorNames.insert(std::make_pair(5926, "ERROR_CLUSTER_INVALID_IPV6_NETWORK")); + ErrorNames.insert(std::make_pair(5927, "ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK")); + ErrorNames.insert(std::make_pair(5928, "ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP")); + ErrorNames.insert(std::make_pair(5929, "ERROR_DEPENDENCY_TREE_TOO_COMPLEX")); + ErrorNames.insert(std::make_pair(5930, "ERROR_EXCEPTION_IN_RESOURCE_CALL")); + ErrorNames.insert(std::make_pair(5931, "ERROR_CLUSTER_RHS_FAILED_INITIALIZATION")); + ErrorNames.insert(std::make_pair(5932, "ERROR_CLUSTER_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(5933, "ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE")); + ErrorNames.insert(std::make_pair(5934, "ERROR_CLUSTER_MAX_NODES_IN_CLUSTER")); + ErrorNames.insert(std::make_pair(5935, "ERROR_CLUSTER_TOO_MANY_NODES")); + ErrorNames.insert(std::make_pair(5936, "ERROR_CLUSTER_OBJECT_ALREADY_USED")); + ErrorNames.insert(std::make_pair(5937, "ERROR_NONCORE_GROUPS_FOUND")); + ErrorNames.insert(std::make_pair(5938, "ERROR_FILE_SHARE_RESOURCE_CONFLICT")); + ErrorNames.insert(std::make_pair(5939, "ERROR_CLUSTER_EVICT_INVALID_REQUEST")); + ErrorNames.insert(std::make_pair(5940, "ERROR_CLUSTER_SINGLETON_RESOURCE")); + ErrorNames.insert(std::make_pair(5941, "ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE")); + ErrorNames.insert(std::make_pair(5942, "ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED")); + ErrorNames.insert(std::make_pair(5943, "ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR")); + ErrorNames.insert(std::make_pair(5944, "ERROR_CLUSTER_GROUP_BUSY")); + ErrorNames.insert(std::make_pair(5945, "ERROR_CLUSTER_NOT_SHARED_VOLUME")); + ErrorNames.insert(std::make_pair(5946, "ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR")); + ErrorNames.insert(std::make_pair(5947, "ERROR_CLUSTER_SHARED_VOLUMES_IN_USE")); + ErrorNames.insert(std::make_pair(5948, "ERROR_CLUSTER_USE_SHARED_VOLUMES_API")); + ErrorNames.insert(std::make_pair(5949, "ERROR_CLUSTER_BACKUP_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(5950, "ERROR_NON_CSV_PATH")); + ErrorNames.insert(std::make_pair(5951, "ERROR_CSV_VOLUME_NOT_LOCAL")); + ErrorNames.insert(std::make_pair(5952, "ERROR_CLUSTER_WATCHDOG_TERMINATING")); + ErrorNames.insert(std::make_pair(6000, "ERROR_ENCRYPTION_FAILED")); + ErrorNames.insert(std::make_pair(6001, "ERROR_DECRYPTION_FAILED")); + ErrorNames.insert(std::make_pair(6002, "ERROR_FILE_ENCRYPTED")); + ErrorNames.insert(std::make_pair(6003, "ERROR_NO_RECOVERY_POLICY")); + ErrorNames.insert(std::make_pair(6004, "ERROR_NO_EFS")); + ErrorNames.insert(std::make_pair(6005, "ERROR_WRONG_EFS")); + ErrorNames.insert(std::make_pair(6006, "ERROR_NO_USER_KEYS")); + ErrorNames.insert(std::make_pair(6007, "ERROR_FILE_NOT_ENCRYPTED")); + ErrorNames.insert(std::make_pair(6008, "ERROR_NOT_EXPORT_FORMAT")); + ErrorNames.insert(std::make_pair(6009, "ERROR_FILE_READ_ONLY")); + ErrorNames.insert(std::make_pair(6010, "ERROR_DIR_EFS_DISALLOWED")); + ErrorNames.insert(std::make_pair(6011, "ERROR_EFS_SERVER_NOT_TRUSTED")); + ErrorNames.insert(std::make_pair(6012, "ERROR_BAD_RECOVERY_POLICY")); + ErrorNames.insert(std::make_pair(6013, "ERROR_EFS_ALG_BLOB_TOO_BIG")); + ErrorNames.insert(std::make_pair(6014, "ERROR_VOLUME_NOT_SUPPORT_EFS")); + ErrorNames.insert(std::make_pair(6015, "ERROR_EFS_DISABLED")); + ErrorNames.insert(std::make_pair(6016, "ERROR_EFS_VERSION_NOT_SUPPORT")); + ErrorNames.insert(std::make_pair(6017, "ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE")); + ErrorNames.insert(std::make_pair(6018, "ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER")); + ErrorNames.insert(std::make_pair(6019, "ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE")); + ErrorNames.insert(std::make_pair(6020, "ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE")); + ErrorNames.insert(std::make_pair(6021, "ERROR_CS_ENCRYPTION_FILE_NOT_CSE")); + ErrorNames.insert(std::make_pair(6022, "ERROR_ENCRYPTION_POLICY_DENIES_OPERATION")); + ErrorNames.insert(std::make_pair(6118, "ERROR_NO_BROWSER_SERVERS_FOUND")); + ErrorNames.insert(std::make_pair(6600, "ERROR_LOG_SECTOR_INVALID")); + ErrorNames.insert(std::make_pair(6601, "ERROR_LOG_SECTOR_PARITY_INVALID")); + ErrorNames.insert(std::make_pair(6602, "ERROR_LOG_SECTOR_REMAPPED")); + ErrorNames.insert(std::make_pair(6603, "ERROR_LOG_BLOCK_INCOMPLETE")); + ErrorNames.insert(std::make_pair(6604, "ERROR_LOG_INVALID_RANGE")); + ErrorNames.insert(std::make_pair(6605, "ERROR_LOG_BLOCKS_EXHAUSTED")); + ErrorNames.insert(std::make_pair(6606, "ERROR_LOG_READ_CONTEXT_INVALID")); + ErrorNames.insert(std::make_pair(6607, "ERROR_LOG_RESTART_INVALID")); + ErrorNames.insert(std::make_pair(6608, "ERROR_LOG_BLOCK_VERSION")); + ErrorNames.insert(std::make_pair(6609, "ERROR_LOG_BLOCK_INVALID")); + ErrorNames.insert(std::make_pair(6610, "ERROR_LOG_READ_MODE_INVALID")); + ErrorNames.insert(std::make_pair(6611, "ERROR_LOG_NO_RESTART")); + ErrorNames.insert(std::make_pair(6612, "ERROR_LOG_METADATA_CORRUPT")); + ErrorNames.insert(std::make_pair(6613, "ERROR_LOG_METADATA_INVALID")); + ErrorNames.insert(std::make_pair(6614, "ERROR_LOG_METADATA_INCONSISTENT")); + ErrorNames.insert(std::make_pair(6615, "ERROR_LOG_RESERVATION_INVALID")); + ErrorNames.insert(std::make_pair(6616, "ERROR_LOG_CANT_DELETE")); + ErrorNames.insert(std::make_pair(6617, "ERROR_LOG_CONTAINER_LIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(6618, "ERROR_LOG_START_OF_LOG")); + ErrorNames.insert(std::make_pair(6619, "ERROR_LOG_POLICY_ALREADY_INSTALLED")); + ErrorNames.insert(std::make_pair(6620, "ERROR_LOG_POLICY_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(6621, "ERROR_LOG_POLICY_INVALID")); + ErrorNames.insert(std::make_pair(6622, "ERROR_LOG_POLICY_CONFLICT")); + ErrorNames.insert(std::make_pair(6623, "ERROR_LOG_PINNED_ARCHIVE_TAIL")); + ErrorNames.insert(std::make_pair(6624, "ERROR_LOG_RECORD_NONEXISTENT")); + ErrorNames.insert(std::make_pair(6625, "ERROR_LOG_RECORDS_RESERVED_INVALID")); + ErrorNames.insert(std::make_pair(6626, "ERROR_LOG_SPACE_RESERVED_INVALID")); + ErrorNames.insert(std::make_pair(6627, "ERROR_LOG_TAIL_INVALID")); + ErrorNames.insert(std::make_pair(6628, "ERROR_LOG_FULL")); + ErrorNames.insert(std::make_pair(6629, "ERROR_COULD_NOT_RESIZE_LOG")); + ErrorNames.insert(std::make_pair(6630, "ERROR_LOG_MULTIPLEXED")); + ErrorNames.insert(std::make_pair(6631, "ERROR_LOG_DEDICATED")); + ErrorNames.insert(std::make_pair(6632, "ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(6633, "ERROR_LOG_ARCHIVE_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(6634, "ERROR_LOG_EPHEMERAL")); + ErrorNames.insert(std::make_pair(6635, "ERROR_LOG_NOT_ENOUGH_CONTAINERS")); + ErrorNames.insert(std::make_pair(6636, "ERROR_LOG_CLIENT_ALREADY_REGISTERED")); + ErrorNames.insert(std::make_pair(6637, "ERROR_LOG_CLIENT_NOT_REGISTERED")); + ErrorNames.insert(std::make_pair(6638, "ERROR_LOG_FULL_HANDLER_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(6639, "ERROR_LOG_CONTAINER_READ_FAILED")); + ErrorNames.insert(std::make_pair(6640, "ERROR_LOG_CONTAINER_WRITE_FAILED")); + ErrorNames.insert(std::make_pair(6641, "ERROR_LOG_CONTAINER_OPEN_FAILED")); + ErrorNames.insert(std::make_pair(6642, "ERROR_LOG_CONTAINER_STATE_INVALID")); + ErrorNames.insert(std::make_pair(6643, "ERROR_LOG_STATE_INVALID")); + ErrorNames.insert(std::make_pair(6644, "ERROR_LOG_PINNED")); + ErrorNames.insert(std::make_pair(6645, "ERROR_LOG_METADATA_FLUSH_FAILED")); + ErrorNames.insert(std::make_pair(6646, "ERROR_LOG_INCONSISTENT_SECURITY")); + ErrorNames.insert(std::make_pair(6647, "ERROR_LOG_APPENDED_FLUSH_FAILED")); + ErrorNames.insert(std::make_pair(6648, "ERROR_LOG_PINNED_RESERVATION")); + ErrorNames.insert(std::make_pair(6700, "ERROR_INVALID_TRANSACTION")); + ErrorNames.insert(std::make_pair(6701, "ERROR_TRANSACTION_NOT_ACTIVE")); + ErrorNames.insert(std::make_pair(6702, "ERROR_TRANSACTION_REQUEST_NOT_VALID")); + ErrorNames.insert(std::make_pair(6703, "ERROR_TRANSACTION_NOT_REQUESTED")); + ErrorNames.insert(std::make_pair(6704, "ERROR_TRANSACTION_ALREADY_ABORTED")); + ErrorNames.insert(std::make_pair(6705, "ERROR_TRANSACTION_ALREADY_COMMITTED")); + ErrorNames.insert(std::make_pair(6706, "ERROR_TM_INITIALIZATION_FAILED")); + ErrorNames.insert(std::make_pair(6707, "ERROR_RESOURCEMANAGER_READ_ONLY")); + ErrorNames.insert(std::make_pair(6708, "ERROR_TRANSACTION_NOT_JOINED")); + ErrorNames.insert(std::make_pair(6709, "ERROR_TRANSACTION_SUPERIOR_EXISTS")); + ErrorNames.insert(std::make_pair(6710, "ERROR_CRM_PROTOCOL_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(6711, "ERROR_TRANSACTION_PROPAGATION_FAILED")); + ErrorNames.insert(std::make_pair(6712, "ERROR_CRM_PROTOCOL_NOT_FOUND")); + ErrorNames.insert(std::make_pair(6713, "ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER")); + ErrorNames.insert(std::make_pair(6714, "ERROR_CURRENT_TRANSACTION_NOT_VALID")); + ErrorNames.insert(std::make_pair(6715, "ERROR_TRANSACTION_NOT_FOUND")); + ErrorNames.insert(std::make_pair(6716, "ERROR_RESOURCEMANAGER_NOT_FOUND")); + ErrorNames.insert(std::make_pair(6717, "ERROR_ENLISTMENT_NOT_FOUND")); + ErrorNames.insert(std::make_pair(6718, "ERROR_TRANSACTIONMANAGER_NOT_FOUND")); + ErrorNames.insert(std::make_pair(6719, "ERROR_TRANSACTIONMANAGER_NOT_ONLINE")); + ErrorNames.insert(std::make_pair(6720, "ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION")); + ErrorNames.insert(std::make_pair(6721, "ERROR_TRANSACTION_NOT_ROOT")); + ErrorNames.insert(std::make_pair(6722, "ERROR_TRANSACTION_OBJECT_EXPIRED")); + ErrorNames.insert(std::make_pair(6723, "ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED")); + ErrorNames.insert(std::make_pair(6724, "ERROR_TRANSACTION_RECORD_TOO_LONG")); + ErrorNames.insert(std::make_pair(6725, "ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(6726, "ERROR_TRANSACTION_INTEGRITY_VIOLATED")); + ErrorNames.insert(std::make_pair(6727, "ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH")); + ErrorNames.insert(std::make_pair(6728, "ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT")); + ErrorNames.insert(std::make_pair(6729, "ERROR_TRANSACTION_MUST_WRITETHROUGH")); + ErrorNames.insert(std::make_pair(6730, "ERROR_TRANSACTION_NO_SUPERIOR")); + ErrorNames.insert(std::make_pair(6731, "ERROR_HEURISTIC_DAMAGE_POSSIBLE")); + ErrorNames.insert(std::make_pair(6800, "ERROR_TRANSACTIONAL_CONFLICT")); + ErrorNames.insert(std::make_pair(6801, "ERROR_RM_NOT_ACTIVE")); + ErrorNames.insert(std::make_pair(6802, "ERROR_RM_METADATA_CORRUPT")); + ErrorNames.insert(std::make_pair(6803, "ERROR_DIRECTORY_NOT_RM")); + ErrorNames.insert(std::make_pair(6805, "ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE")); + ErrorNames.insert(std::make_pair(6806, "ERROR_LOG_RESIZE_INVALID_SIZE")); + ErrorNames.insert(std::make_pair(6807, "ERROR_OBJECT_NO_LONGER_EXISTS")); + ErrorNames.insert(std::make_pair(6808, "ERROR_STREAM_MINIVERSION_NOT_FOUND")); + ErrorNames.insert(std::make_pair(6809, "ERROR_STREAM_MINIVERSION_NOT_VALID")); + ErrorNames.insert(std::make_pair(6810, "ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION")); + ErrorNames.insert(std::make_pair(6811, "ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT")); + ErrorNames.insert(std::make_pair(6812, "ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS")); + ErrorNames.insert(std::make_pair(6814, "ERROR_REMOTE_FILE_VERSION_MISMATCH")); + ErrorNames.insert(std::make_pair(6815, "ERROR_HANDLE_NO_LONGER_VALID")); + ErrorNames.insert(std::make_pair(6816, "ERROR_NO_TXF_METADATA")); + ErrorNames.insert(std::make_pair(6817, "ERROR_LOG_CORRUPTION_DETECTED")); + ErrorNames.insert(std::make_pair(6818, "ERROR_CANT_RECOVER_WITH_HANDLE_OPEN")); + ErrorNames.insert(std::make_pair(6819, "ERROR_RM_DISCONNECTED")); + ErrorNames.insert(std::make_pair(6820, "ERROR_ENLISTMENT_NOT_SUPERIOR")); + ErrorNames.insert(std::make_pair(6821, "ERROR_RECOVERY_NOT_NEEDED")); + ErrorNames.insert(std::make_pair(6822, "ERROR_RM_ALREADY_STARTED")); + ErrorNames.insert(std::make_pair(6823, "ERROR_FILE_IDENTITY_NOT_PERSISTENT")); + ErrorNames.insert(std::make_pair(6824, "ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY")); + ErrorNames.insert(std::make_pair(6825, "ERROR_CANT_CROSS_RM_BOUNDARY")); + ErrorNames.insert(std::make_pair(6826, "ERROR_TXF_DIR_NOT_EMPTY")); + ErrorNames.insert(std::make_pair(6827, "ERROR_INDOUBT_TRANSACTIONS_EXIST")); + ErrorNames.insert(std::make_pair(6828, "ERROR_TM_VOLATILE")); + ErrorNames.insert(std::make_pair(6829, "ERROR_ROLLBACK_TIMER_EXPIRED")); + ErrorNames.insert(std::make_pair(6830, "ERROR_TXF_ATTRIBUTE_CORRUPT")); + ErrorNames.insert(std::make_pair(6831, "ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION")); + ErrorNames.insert(std::make_pair(6832, "ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED")); + ErrorNames.insert(std::make_pair(6833, "ERROR_LOG_GROWTH_FAILED")); + ErrorNames.insert(std::make_pair(6834, "ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE")); + ErrorNames.insert(std::make_pair(6835, "ERROR_TXF_METADATA_ALREADY_PRESENT")); + ErrorNames.insert(std::make_pair(6836, "ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET")); + ErrorNames.insert(std::make_pair(6837, "ERROR_TRANSACTION_REQUIRED_PROMOTION")); + ErrorNames.insert(std::make_pair(6838, "ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION")); + ErrorNames.insert(std::make_pair(6839, "ERROR_TRANSACTIONS_NOT_FROZEN")); + ErrorNames.insert(std::make_pair(6840, "ERROR_TRANSACTION_FREEZE_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(6841, "ERROR_NOT_SNAPSHOT_VOLUME")); + ErrorNames.insert(std::make_pair(6842, "ERROR_NO_SAVEPOINT_WITH_OPEN_FILES")); + ErrorNames.insert(std::make_pair(6843, "ERROR_DATA_LOST_REPAIR")); + ErrorNames.insert(std::make_pair(6844, "ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION")); + ErrorNames.insert(std::make_pair(6845, "ERROR_TM_IDENTITY_MISMATCH")); + ErrorNames.insert(std::make_pair(6846, "ERROR_FLOATED_SECTION")); + ErrorNames.insert(std::make_pair(6847, "ERROR_CANNOT_ACCEPT_TRANSACTED_WORK")); + ErrorNames.insert(std::make_pair(6848, "ERROR_CANNOT_ABORT_TRANSACTIONS")); + ErrorNames.insert(std::make_pair(6849, "ERROR_BAD_CLUSTERS")); + ErrorNames.insert(std::make_pair(6850, "ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION")); + ErrorNames.insert(std::make_pair(6851, "ERROR_VOLUME_DIRTY")); + ErrorNames.insert(std::make_pair(6852, "ERROR_NO_LINK_TRACKING_IN_TRANSACTION")); + ErrorNames.insert(std::make_pair(6853, "ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION")); + ErrorNames.insert(std::make_pair(6854, "ERROR_EXPIRED_HANDLE")); + ErrorNames.insert(std::make_pair(6855, "ERROR_TRANSACTION_NOT_ENLISTED")); + ErrorNames.insert(std::make_pair(7001, "ERROR_CTX_WINSTATION_NAME_INVALID")); + ErrorNames.insert(std::make_pair(7002, "ERROR_CTX_INVALID_PD")); + ErrorNames.insert(std::make_pair(7003, "ERROR_CTX_PD_NOT_FOUND")); + ErrorNames.insert(std::make_pair(7004, "ERROR_CTX_WD_NOT_FOUND")); + ErrorNames.insert(std::make_pair(7005, "ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY")); + ErrorNames.insert(std::make_pair(7006, "ERROR_CTX_SERVICE_NAME_COLLISION")); + ErrorNames.insert(std::make_pair(7007, "ERROR_CTX_CLOSE_PENDING")); + ErrorNames.insert(std::make_pair(7008, "ERROR_CTX_NO_OUTBUF")); + ErrorNames.insert(std::make_pair(7009, "ERROR_CTX_MODEM_INF_NOT_FOUND")); + ErrorNames.insert(std::make_pair(7010, "ERROR_CTX_INVALID_MODEMNAME")); + ErrorNames.insert(std::make_pair(7011, "ERROR_CTX_MODEM_RESPONSE_ERROR")); + ErrorNames.insert(std::make_pair(7012, "ERROR_CTX_MODEM_RESPONSE_TIMEOUT")); + ErrorNames.insert(std::make_pair(7013, "ERROR_CTX_MODEM_RESPONSE_NO_CARRIER")); + ErrorNames.insert(std::make_pair(7014, "ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE")); + ErrorNames.insert(std::make_pair(7015, "ERROR_CTX_MODEM_RESPONSE_BUSY")); + ErrorNames.insert(std::make_pair(7016, "ERROR_CTX_MODEM_RESPONSE_VOICE")); + ErrorNames.insert(std::make_pair(7017, "ERROR_CTX_TD_ERROR")); + ErrorNames.insert(std::make_pair(7022, "ERROR_CTX_WINSTATION_NOT_FOUND")); + ErrorNames.insert(std::make_pair(7023, "ERROR_CTX_WINSTATION_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(7024, "ERROR_CTX_WINSTATION_BUSY")); + ErrorNames.insert(std::make_pair(7025, "ERROR_CTX_BAD_VIDEO_MODE")); + ErrorNames.insert(std::make_pair(7035, "ERROR_CTX_GRAPHICS_INVALID")); + ErrorNames.insert(std::make_pair(7037, "ERROR_CTX_LOGON_DISABLED")); + ErrorNames.insert(std::make_pair(7038, "ERROR_CTX_NOT_CONSOLE")); + ErrorNames.insert(std::make_pair(7040, "ERROR_CTX_CLIENT_QUERY_TIMEOUT")); + ErrorNames.insert(std::make_pair(7041, "ERROR_CTX_CONSOLE_DISCONNECT")); + ErrorNames.insert(std::make_pair(7042, "ERROR_CTX_CONSOLE_CONNECT")); + ErrorNames.insert(std::make_pair(7044, "ERROR_CTX_SHADOW_DENIED")); + ErrorNames.insert(std::make_pair(7045, "ERROR_CTX_WINSTATION_ACCESS_DENIED")); + ErrorNames.insert(std::make_pair(7049, "ERROR_CTX_INVALID_WD")); + ErrorNames.insert(std::make_pair(7050, "ERROR_CTX_SHADOW_INVALID")); + ErrorNames.insert(std::make_pair(7051, "ERROR_CTX_SHADOW_DISABLED")); + ErrorNames.insert(std::make_pair(7052, "ERROR_CTX_CLIENT_LICENSE_IN_USE")); + ErrorNames.insert(std::make_pair(7053, "ERROR_CTX_CLIENT_LICENSE_NOT_SET")); + ErrorNames.insert(std::make_pair(7054, "ERROR_CTX_LICENSE_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(7055, "ERROR_CTX_LICENSE_CLIENT_INVALID")); + ErrorNames.insert(std::make_pair(7056, "ERROR_CTX_LICENSE_EXPIRED")); + ErrorNames.insert(std::make_pair(7057, "ERROR_CTX_SHADOW_NOT_RUNNING")); + ErrorNames.insert(std::make_pair(7058, "ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE")); + ErrorNames.insert(std::make_pair(7059, "ERROR_ACTIVATION_COUNT_EXCEEDED")); + ErrorNames.insert(std::make_pair(7060, "ERROR_CTX_WINSTATIONS_DISABLED")); + ErrorNames.insert(std::make_pair(7061, "ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED")); + ErrorNames.insert(std::make_pair(7062, "ERROR_CTX_SESSION_IN_USE")); + ErrorNames.insert(std::make_pair(7063, "ERROR_CTX_NO_FORCE_LOGOFF")); + ErrorNames.insert(std::make_pair(7064, "ERROR_CTX_ACCOUNT_RESTRICTION")); + ErrorNames.insert(std::make_pair(7065, "ERROR_RDP_PROTOCOL_ERROR")); + ErrorNames.insert(std::make_pair(7066, "ERROR_CTX_CDM_CONNECT")); + ErrorNames.insert(std::make_pair(7067, "ERROR_CTX_CDM_DISCONNECT")); + ErrorNames.insert(std::make_pair(7068, "ERROR_CTX_SECURITY_LAYER_ERROR")); + ErrorNames.insert(std::make_pair(7069, "ERROR_TS_INCOMPATIBLE_SESSIONS")); + ErrorNames.insert(std::make_pair(7070, "ERROR_TS_VIDEO_SUBSYSTEM_ERROR")); + ErrorNames.insert(std::make_pair(8200, "ERROR_DS_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(8201, "ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY")); + ErrorNames.insert(std::make_pair(8202, "ERROR_DS_NO_ATTRIBUTE_OR_VALUE")); + ErrorNames.insert(std::make_pair(8203, "ERROR_DS_INVALID_ATTRIBUTE_SYNTAX")); + ErrorNames.insert(std::make_pair(8204, "ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED")); + ErrorNames.insert(std::make_pair(8205, "ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS")); + ErrorNames.insert(std::make_pair(8206, "ERROR_DS_BUSY")); + ErrorNames.insert(std::make_pair(8207, "ERROR_DS_UNAVAILABLE")); + ErrorNames.insert(std::make_pair(8208, "ERROR_DS_NO_RIDS_ALLOCATED")); + ErrorNames.insert(std::make_pair(8209, "ERROR_DS_NO_MORE_RIDS")); + ErrorNames.insert(std::make_pair(8210, "ERROR_DS_INCORRECT_ROLE_OWNER")); + ErrorNames.insert(std::make_pair(8211, "ERROR_DS_RIDMGR_INIT_ERROR")); + ErrorNames.insert(std::make_pair(8212, "ERROR_DS_OBJ_CLASS_VIOLATION")); + ErrorNames.insert(std::make_pair(8213, "ERROR_DS_CANT_ON_NON_LEAF")); + ErrorNames.insert(std::make_pair(8214, "ERROR_DS_CANT_ON_RDN")); + ErrorNames.insert(std::make_pair(8215, "ERROR_DS_CANT_MOD_OBJ_CLASS")); + ErrorNames.insert(std::make_pair(8216, "ERROR_DS_CROSS_DOM_MOVE_ERROR")); + ErrorNames.insert(std::make_pair(8217, "ERROR_DS_GC_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(8218, "ERROR_SHARED_POLICY")); + ErrorNames.insert(std::make_pair(8219, "ERROR_POLICY_OBJECT_NOT_FOUND")); + ErrorNames.insert(std::make_pair(8220, "ERROR_POLICY_ONLY_IN_DS")); + ErrorNames.insert(std::make_pair(8221, "ERROR_PROMOTION_ACTIVE")); + ErrorNames.insert(std::make_pair(8222, "ERROR_NO_PROMOTION_ACTIVE")); + ErrorNames.insert(std::make_pair(8224, "ERROR_DS_OPERATIONS_ERROR")); + ErrorNames.insert(std::make_pair(8225, "ERROR_DS_PROTOCOL_ERROR")); + ErrorNames.insert(std::make_pair(8226, "ERROR_DS_TIMELIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(8227, "ERROR_DS_SIZELIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(8228, "ERROR_DS_ADMIN_LIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(8229, "ERROR_DS_COMPARE_FALSE")); + ErrorNames.insert(std::make_pair(8230, "ERROR_DS_COMPARE_TRUE")); + ErrorNames.insert(std::make_pair(8231, "ERROR_DS_AUTH_METHOD_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(8232, "ERROR_DS_STRONG_AUTH_REQUIRED")); + ErrorNames.insert(std::make_pair(8233, "ERROR_DS_INAPPROPRIATE_AUTH")); + ErrorNames.insert(std::make_pair(8234, "ERROR_DS_AUTH_UNKNOWN")); + ErrorNames.insert(std::make_pair(8235, "ERROR_DS_REFERRAL")); + ErrorNames.insert(std::make_pair(8236, "ERROR_DS_UNAVAILABLE_CRIT_EXTENSION")); + ErrorNames.insert(std::make_pair(8237, "ERROR_DS_CONFIDENTIALITY_REQUIRED")); + ErrorNames.insert(std::make_pair(8238, "ERROR_DS_INAPPROPRIATE_MATCHING")); + ErrorNames.insert(std::make_pair(8239, "ERROR_DS_CONSTRAINT_VIOLATION")); + ErrorNames.insert(std::make_pair(8240, "ERROR_DS_NO_SUCH_OBJECT")); + ErrorNames.insert(std::make_pair(8241, "ERROR_DS_ALIAS_PROBLEM")); + ErrorNames.insert(std::make_pair(8242, "ERROR_DS_INVALID_DN_SYNTAX")); + ErrorNames.insert(std::make_pair(8243, "ERROR_DS_IS_LEAF")); + ErrorNames.insert(std::make_pair(8244, "ERROR_DS_ALIAS_DEREF_PROBLEM")); + ErrorNames.insert(std::make_pair(8245, "ERROR_DS_UNWILLING_TO_PERFORM")); + ErrorNames.insert(std::make_pair(8246, "ERROR_DS_LOOP_DETECT")); + ErrorNames.insert(std::make_pair(8247, "ERROR_DS_NAMING_VIOLATION")); + ErrorNames.insert(std::make_pair(8248, "ERROR_DS_OBJECT_RESULTS_TOO_LARGE")); + ErrorNames.insert(std::make_pair(8249, "ERROR_DS_AFFECTS_MULTIPLE_DSAS")); + ErrorNames.insert(std::make_pair(8250, "ERROR_DS_SERVER_DOWN")); + ErrorNames.insert(std::make_pair(8251, "ERROR_DS_LOCAL_ERROR")); + ErrorNames.insert(std::make_pair(8252, "ERROR_DS_ENCODING_ERROR")); + ErrorNames.insert(std::make_pair(8253, "ERROR_DS_DECODING_ERROR")); + ErrorNames.insert(std::make_pair(8254, "ERROR_DS_FILTER_UNKNOWN")); + ErrorNames.insert(std::make_pair(8255, "ERROR_DS_PARAM_ERROR")); + ErrorNames.insert(std::make_pair(8256, "ERROR_DS_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(8257, "ERROR_DS_NO_RESULTS_RETURNED")); + ErrorNames.insert(std::make_pair(8258, "ERROR_DS_CONTROL_NOT_FOUND")); + ErrorNames.insert(std::make_pair(8259, "ERROR_DS_CLIENT_LOOP")); + ErrorNames.insert(std::make_pair(8260, "ERROR_DS_REFERRAL_LIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(8261, "ERROR_DS_SORT_CONTROL_MISSING")); + ErrorNames.insert(std::make_pair(8262, "ERROR_DS_OFFSET_RANGE_ERROR")); + ErrorNames.insert(std::make_pair(8301, "ERROR_DS_ROOT_MUST_BE_NC")); + ErrorNames.insert(std::make_pair(8302, "ERROR_DS_ADD_REPLICA_INHIBITED")); + ErrorNames.insert(std::make_pair(8303, "ERROR_DS_ATT_NOT_DEF_IN_SCHEMA")); + ErrorNames.insert(std::make_pair(8304, "ERROR_DS_MAX_OBJ_SIZE_EXCEEDED")); + ErrorNames.insert(std::make_pair(8305, "ERROR_DS_OBJ_STRING_NAME_EXISTS")); + ErrorNames.insert(std::make_pair(8306, "ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA")); + ErrorNames.insert(std::make_pair(8307, "ERROR_DS_RDN_DOESNT_MATCH_SCHEMA")); + ErrorNames.insert(std::make_pair(8308, "ERROR_DS_NO_REQUESTED_ATTS_FOUND")); + ErrorNames.insert(std::make_pair(8309, "ERROR_DS_USER_BUFFER_TO_SMALL")); + ErrorNames.insert(std::make_pair(8310, "ERROR_DS_ATT_IS_NOT_ON_OBJ")); + ErrorNames.insert(std::make_pair(8311, "ERROR_DS_ILLEGAL_MOD_OPERATION")); + ErrorNames.insert(std::make_pair(8312, "ERROR_DS_OBJ_TOO_LARGE")); + ErrorNames.insert(std::make_pair(8313, "ERROR_DS_BAD_INSTANCE_TYPE")); + ErrorNames.insert(std::make_pair(8314, "ERROR_DS_MASTERDSA_REQUIRED")); + ErrorNames.insert(std::make_pair(8315, "ERROR_DS_OBJECT_CLASS_REQUIRED")); + ErrorNames.insert(std::make_pair(8316, "ERROR_DS_MISSING_REQUIRED_ATT")); + ErrorNames.insert(std::make_pair(8317, "ERROR_DS_ATT_NOT_DEF_FOR_CLASS")); + ErrorNames.insert(std::make_pair(8318, "ERROR_DS_ATT_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(8320, "ERROR_DS_CANT_ADD_ATT_VALUES")); + ErrorNames.insert(std::make_pair(8321, "ERROR_DS_SINGLE_VALUE_CONSTRAINT")); + ErrorNames.insert(std::make_pair(8322, "ERROR_DS_RANGE_CONSTRAINT")); + ErrorNames.insert(std::make_pair(8323, "ERROR_DS_ATT_VAL_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(8324, "ERROR_DS_CANT_REM_MISSING_ATT")); + ErrorNames.insert(std::make_pair(8325, "ERROR_DS_CANT_REM_MISSING_ATT_VAL")); + ErrorNames.insert(std::make_pair(8326, "ERROR_DS_ROOT_CANT_BE_SUBREF")); + ErrorNames.insert(std::make_pair(8327, "ERROR_DS_NO_CHAINING")); + ErrorNames.insert(std::make_pair(8328, "ERROR_DS_NO_CHAINED_EVAL")); + ErrorNames.insert(std::make_pair(8329, "ERROR_DS_NO_PARENT_OBJECT")); + ErrorNames.insert(std::make_pair(8330, "ERROR_DS_PARENT_IS_AN_ALIAS")); + ErrorNames.insert(std::make_pair(8331, "ERROR_DS_CANT_MIX_MASTER_AND_REPS")); + ErrorNames.insert(std::make_pair(8332, "ERROR_DS_CHILDREN_EXIST")); + ErrorNames.insert(std::make_pair(8333, "ERROR_DS_OBJ_NOT_FOUND")); + ErrorNames.insert(std::make_pair(8334, "ERROR_DS_ALIASED_OBJ_MISSING")); + ErrorNames.insert(std::make_pair(8335, "ERROR_DS_BAD_NAME_SYNTAX")); + ErrorNames.insert(std::make_pair(8336, "ERROR_DS_ALIAS_POINTS_TO_ALIAS")); + ErrorNames.insert(std::make_pair(8337, "ERROR_DS_CANT_DEREF_ALIAS")); + ErrorNames.insert(std::make_pair(8338, "ERROR_DS_OUT_OF_SCOPE")); + ErrorNames.insert(std::make_pair(8339, "ERROR_DS_OBJECT_BEING_REMOVED")); + ErrorNames.insert(std::make_pair(8340, "ERROR_DS_CANT_DELETE_DSA_OBJ")); + ErrorNames.insert(std::make_pair(8341, "ERROR_DS_GENERIC_ERROR")); + ErrorNames.insert(std::make_pair(8342, "ERROR_DS_DSA_MUST_BE_INT_MASTER")); + ErrorNames.insert(std::make_pair(8343, "ERROR_DS_CLASS_NOT_DSA")); + ErrorNames.insert(std::make_pair(8344, "ERROR_DS_INSUFF_ACCESS_RIGHTS")); + ErrorNames.insert(std::make_pair(8345, "ERROR_DS_ILLEGAL_SUPERIOR")); + ErrorNames.insert(std::make_pair(8346, "ERROR_DS_ATTRIBUTE_OWNED_BY_SAM")); + ErrorNames.insert(std::make_pair(8347, "ERROR_DS_NAME_TOO_MANY_PARTS")); + ErrorNames.insert(std::make_pair(8348, "ERROR_DS_NAME_TOO_LONG")); + ErrorNames.insert(std::make_pair(8349, "ERROR_DS_NAME_VALUE_TOO_LONG")); + ErrorNames.insert(std::make_pair(8350, "ERROR_DS_NAME_UNPARSEABLE")); + ErrorNames.insert(std::make_pair(8351, "ERROR_DS_NAME_TYPE_UNKNOWN")); + ErrorNames.insert(std::make_pair(8352, "ERROR_DS_NOT_AN_OBJECT")); + ErrorNames.insert(std::make_pair(8353, "ERROR_DS_SEC_DESC_TOO_SHORT")); + ErrorNames.insert(std::make_pair(8354, "ERROR_DS_SEC_DESC_INVALID")); + ErrorNames.insert(std::make_pair(8355, "ERROR_DS_NO_DELETED_NAME")); + ErrorNames.insert(std::make_pair(8356, "ERROR_DS_SUBREF_MUST_HAVE_PARENT")); + ErrorNames.insert(std::make_pair(8357, "ERROR_DS_NCNAME_MUST_BE_NC")); + ErrorNames.insert(std::make_pair(8358, "ERROR_DS_CANT_ADD_SYSTEM_ONLY")); + ErrorNames.insert(std::make_pair(8359, "ERROR_DS_CLASS_MUST_BE_CONCRETE")); + ErrorNames.insert(std::make_pair(8360, "ERROR_DS_INVALID_DMD")); + ErrorNames.insert(std::make_pair(8361, "ERROR_DS_OBJ_GUID_EXISTS")); + ErrorNames.insert(std::make_pair(8362, "ERROR_DS_NOT_ON_BACKLINK")); + ErrorNames.insert(std::make_pair(8363, "ERROR_DS_NO_CROSSREF_FOR_NC")); + ErrorNames.insert(std::make_pair(8364, "ERROR_DS_SHUTTING_DOWN")); + ErrorNames.insert(std::make_pair(8365, "ERROR_DS_UNKNOWN_OPERATION")); + ErrorNames.insert(std::make_pair(8366, "ERROR_DS_INVALID_ROLE_OWNER")); + ErrorNames.insert(std::make_pair(8367, "ERROR_DS_COULDNT_CONTACT_FSMO")); + ErrorNames.insert(std::make_pair(8368, "ERROR_DS_CROSS_NC_DN_RENAME")); + ErrorNames.insert(std::make_pair(8369, "ERROR_DS_CANT_MOD_SYSTEM_ONLY")); + ErrorNames.insert(std::make_pair(8370, "ERROR_DS_REPLICATOR_ONLY")); + ErrorNames.insert(std::make_pair(8371, "ERROR_DS_OBJ_CLASS_NOT_DEFINED")); + ErrorNames.insert(std::make_pair(8372, "ERROR_DS_OBJ_CLASS_NOT_SUBCLASS")); + ErrorNames.insert(std::make_pair(8373, "ERROR_DS_NAME_REFERENCE_INVALID")); + ErrorNames.insert(std::make_pair(8374, "ERROR_DS_CROSS_REF_EXISTS")); + ErrorNames.insert(std::make_pair(8375, "ERROR_DS_CANT_DEL_MASTER_CROSSREF")); + ErrorNames.insert(std::make_pair(8376, "ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD")); + ErrorNames.insert(std::make_pair(8377, "ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX")); + ErrorNames.insert(std::make_pair(8378, "ERROR_DS_DUP_RDN")); + ErrorNames.insert(std::make_pair(8379, "ERROR_DS_DUP_OID")); + ErrorNames.insert(std::make_pair(8380, "ERROR_DS_DUP_MAPI_ID")); + ErrorNames.insert(std::make_pair(8381, "ERROR_DS_DUP_SCHEMA_ID_GUID")); + ErrorNames.insert(std::make_pair(8382, "ERROR_DS_DUP_LDAP_DISPLAY_NAME")); + ErrorNames.insert(std::make_pair(8383, "ERROR_DS_SEMANTIC_ATT_TEST")); + ErrorNames.insert(std::make_pair(8384, "ERROR_DS_SYNTAX_MISMATCH")); + ErrorNames.insert(std::make_pair(8385, "ERROR_DS_EXISTS_IN_MUST_HAVE")); + ErrorNames.insert(std::make_pair(8386, "ERROR_DS_EXISTS_IN_MAY_HAVE")); + ErrorNames.insert(std::make_pair(8387, "ERROR_DS_NONEXISTENT_MAY_HAVE")); + ErrorNames.insert(std::make_pair(8388, "ERROR_DS_NONEXISTENT_MUST_HAVE")); + ErrorNames.insert(std::make_pair(8389, "ERROR_DS_AUX_CLS_TEST_FAIL")); + ErrorNames.insert(std::make_pair(8390, "ERROR_DS_NONEXISTENT_POSS_SUP")); + ErrorNames.insert(std::make_pair(8391, "ERROR_DS_SUB_CLS_TEST_FAIL")); + ErrorNames.insert(std::make_pair(8392, "ERROR_DS_BAD_RDN_ATT_ID_SYNTAX")); + ErrorNames.insert(std::make_pair(8393, "ERROR_DS_EXISTS_IN_AUX_CLS")); + ErrorNames.insert(std::make_pair(8394, "ERROR_DS_EXISTS_IN_SUB_CLS")); + ErrorNames.insert(std::make_pair(8395, "ERROR_DS_EXISTS_IN_POSS_SUP")); + ErrorNames.insert(std::make_pair(8396, "ERROR_DS_RECALCSCHEMA_FAILED")); + ErrorNames.insert(std::make_pair(8397, "ERROR_DS_TREE_DELETE_NOT_FINISHED")); + ErrorNames.insert(std::make_pair(8398, "ERROR_DS_CANT_DELETE")); + ErrorNames.insert(std::make_pair(8399, "ERROR_DS_ATT_SCHEMA_REQ_ID")); + ErrorNames.insert(std::make_pair(8400, "ERROR_DS_BAD_ATT_SCHEMA_SYNTAX")); + ErrorNames.insert(std::make_pair(8401, "ERROR_DS_CANT_CACHE_ATT")); + ErrorNames.insert(std::make_pair(8402, "ERROR_DS_CANT_CACHE_CLASS")); + ErrorNames.insert(std::make_pair(8403, "ERROR_DS_CANT_REMOVE_ATT_CACHE")); + ErrorNames.insert(std::make_pair(8404, "ERROR_DS_CANT_REMOVE_CLASS_CACHE")); + ErrorNames.insert(std::make_pair(8405, "ERROR_DS_CANT_RETRIEVE_DN")); + ErrorNames.insert(std::make_pair(8406, "ERROR_DS_MISSING_SUPREF")); + ErrorNames.insert(std::make_pair(8407, "ERROR_DS_CANT_RETRIEVE_INSTANCE")); + ErrorNames.insert(std::make_pair(8408, "ERROR_DS_CODE_INCONSISTENCY")); + ErrorNames.insert(std::make_pair(8409, "ERROR_DS_DATABASE_ERROR")); + ErrorNames.insert(std::make_pair(8410, "ERROR_DS_GOVERNSID_MISSING")); + ErrorNames.insert(std::make_pair(8411, "ERROR_DS_MISSING_EXPECTED_ATT")); + ErrorNames.insert(std::make_pair(8412, "ERROR_DS_NCNAME_MISSING_CR_REF")); + ErrorNames.insert(std::make_pair(8413, "ERROR_DS_SECURITY_CHECKING_ERROR")); + ErrorNames.insert(std::make_pair(8414, "ERROR_DS_SCHEMA_NOT_LOADED")); + ErrorNames.insert(std::make_pair(8415, "ERROR_DS_SCHEMA_ALLOC_FAILED")); + ErrorNames.insert(std::make_pair(8416, "ERROR_DS_ATT_SCHEMA_REQ_SYNTAX")); + ErrorNames.insert(std::make_pair(8417, "ERROR_DS_GCVERIFY_ERROR")); + ErrorNames.insert(std::make_pair(8418, "ERROR_DS_DRA_SCHEMA_MISMATCH")); + ErrorNames.insert(std::make_pair(8419, "ERROR_DS_CANT_FIND_DSA_OBJ")); + ErrorNames.insert(std::make_pair(8420, "ERROR_DS_CANT_FIND_EXPECTED_NC")); + ErrorNames.insert(std::make_pair(8421, "ERROR_DS_CANT_FIND_NC_IN_CACHE")); + ErrorNames.insert(std::make_pair(8422, "ERROR_DS_CANT_RETRIEVE_CHILD")); + ErrorNames.insert(std::make_pair(8423, "ERROR_DS_SECURITY_ILLEGAL_MODIFY")); + ErrorNames.insert(std::make_pair(8424, "ERROR_DS_CANT_REPLACE_HIDDEN_REC")); + ErrorNames.insert(std::make_pair(8425, "ERROR_DS_BAD_HIERARCHY_FILE")); + ErrorNames.insert(std::make_pair(8426, "ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED")); + ErrorNames.insert(std::make_pair(8427, "ERROR_DS_CONFIG_PARAM_MISSING")); + ErrorNames.insert(std::make_pair(8428, "ERROR_DS_COUNTING_AB_INDICES_FAILED")); + ErrorNames.insert(std::make_pair(8429, "ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED")); + ErrorNames.insert(std::make_pair(8430, "ERROR_DS_INTERNAL_FAILURE")); + ErrorNames.insert(std::make_pair(8431, "ERROR_DS_UNKNOWN_ERROR")); + ErrorNames.insert(std::make_pair(8432, "ERROR_DS_ROOT_REQUIRES_CLASS_TOP")); + ErrorNames.insert(std::make_pair(8433, "ERROR_DS_REFUSING_FSMO_ROLES")); + ErrorNames.insert(std::make_pair(8434, "ERROR_DS_MISSING_FSMO_SETTINGS")); + ErrorNames.insert(std::make_pair(8435, "ERROR_DS_UNABLE_TO_SURRENDER_ROLES")); + ErrorNames.insert(std::make_pair(8436, "ERROR_DS_DRA_GENERIC")); + ErrorNames.insert(std::make_pair(8437, "ERROR_DS_DRA_INVALID_PARAMETER")); + ErrorNames.insert(std::make_pair(8438, "ERROR_DS_DRA_BUSY")); + ErrorNames.insert(std::make_pair(8439, "ERROR_DS_DRA_BAD_DN")); + ErrorNames.insert(std::make_pair(8440, "ERROR_DS_DRA_BAD_NC")); + ErrorNames.insert(std::make_pair(8441, "ERROR_DS_DRA_DN_EXISTS")); + ErrorNames.insert(std::make_pair(8442, "ERROR_DS_DRA_INTERNAL_ERROR")); + ErrorNames.insert(std::make_pair(8443, "ERROR_DS_DRA_INCONSISTENT_DIT")); + ErrorNames.insert(std::make_pair(8444, "ERROR_DS_DRA_CONNECTION_FAILED")); + ErrorNames.insert(std::make_pair(8445, "ERROR_DS_DRA_BAD_INSTANCE_TYPE")); + ErrorNames.insert(std::make_pair(8446, "ERROR_DS_DRA_OUT_OF_MEM")); + ErrorNames.insert(std::make_pair(8447, "ERROR_DS_DRA_MAIL_PROBLEM")); + ErrorNames.insert(std::make_pair(8448, "ERROR_DS_DRA_REF_ALREADY_EXISTS")); + ErrorNames.insert(std::make_pair(8449, "ERROR_DS_DRA_REF_NOT_FOUND")); + ErrorNames.insert(std::make_pair(8450, "ERROR_DS_DRA_OBJ_IS_REP_SOURCE")); + ErrorNames.insert(std::make_pair(8451, "ERROR_DS_DRA_DB_ERROR")); + ErrorNames.insert(std::make_pair(8452, "ERROR_DS_DRA_NO_REPLICA")); + ErrorNames.insert(std::make_pair(8453, "ERROR_DS_DRA_ACCESS_DENIED")); + ErrorNames.insert(std::make_pair(8454, "ERROR_DS_DRA_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(8455, "ERROR_DS_DRA_RPC_CANCELLED")); + ErrorNames.insert(std::make_pair(8456, "ERROR_DS_DRA_SOURCE_DISABLED")); + ErrorNames.insert(std::make_pair(8457, "ERROR_DS_DRA_SINK_DISABLED")); + ErrorNames.insert(std::make_pair(8458, "ERROR_DS_DRA_NAME_COLLISION")); + ErrorNames.insert(std::make_pair(8459, "ERROR_DS_DRA_SOURCE_REINSTALLED")); + ErrorNames.insert(std::make_pair(8460, "ERROR_DS_DRA_MISSING_PARENT")); + ErrorNames.insert(std::make_pair(8461, "ERROR_DS_DRA_PREEMPTED")); + ErrorNames.insert(std::make_pair(8462, "ERROR_DS_DRA_ABANDON_SYNC")); + ErrorNames.insert(std::make_pair(8463, "ERROR_DS_DRA_SHUTDOWN")); + ErrorNames.insert(std::make_pair(8464, "ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET")); + ErrorNames.insert(std::make_pair(8465, "ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA")); + ErrorNames.insert(std::make_pair(8466, "ERROR_DS_DRA_EXTN_CONNECTION_FAILED")); + ErrorNames.insert(std::make_pair(8467, "ERROR_DS_INSTALL_SCHEMA_MISMATCH")); + ErrorNames.insert(std::make_pair(8468, "ERROR_DS_DUP_LINK_ID")); + ErrorNames.insert(std::make_pair(8469, "ERROR_DS_NAME_ERROR_RESOLVING")); + ErrorNames.insert(std::make_pair(8470, "ERROR_DS_NAME_ERROR_NOT_FOUND")); + ErrorNames.insert(std::make_pair(8471, "ERROR_DS_NAME_ERROR_NOT_UNIQUE")); + ErrorNames.insert(std::make_pair(8472, "ERROR_DS_NAME_ERROR_NO_MAPPING")); + ErrorNames.insert(std::make_pair(8473, "ERROR_DS_NAME_ERROR_DOMAIN_ONLY")); + ErrorNames.insert(std::make_pair(8474, "ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING")); + ErrorNames.insert(std::make_pair(8475, "ERROR_DS_CONSTRUCTED_ATT_MOD")); + ErrorNames.insert(std::make_pair(8476, "ERROR_DS_WRONG_OM_OBJ_CLASS")); + ErrorNames.insert(std::make_pair(8477, "ERROR_DS_DRA_REPL_PENDING")); + ErrorNames.insert(std::make_pair(8478, "ERROR_DS_DS_REQUIRED")); + ErrorNames.insert(std::make_pair(8479, "ERROR_DS_INVALID_LDAP_DISPLAY_NAME")); + ErrorNames.insert(std::make_pair(8480, "ERROR_DS_NON_BASE_SEARCH")); + ErrorNames.insert(std::make_pair(8481, "ERROR_DS_CANT_RETRIEVE_ATTS")); + ErrorNames.insert(std::make_pair(8482, "ERROR_DS_BACKLINK_WITHOUT_LINK")); + ErrorNames.insert(std::make_pair(8483, "ERROR_DS_EPOCH_MISMATCH")); + ErrorNames.insert(std::make_pair(8484, "ERROR_DS_SRC_NAME_MISMATCH")); + ErrorNames.insert(std::make_pair(8485, "ERROR_DS_SRC_AND_DST_NC_IDENTICAL")); + ErrorNames.insert(std::make_pair(8486, "ERROR_DS_DST_NC_MISMATCH")); + ErrorNames.insert(std::make_pair(8487, "ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC")); + ErrorNames.insert(std::make_pair(8488, "ERROR_DS_SRC_GUID_MISMATCH")); + ErrorNames.insert(std::make_pair(8489, "ERROR_DS_CANT_MOVE_DELETED_OBJECT")); + ErrorNames.insert(std::make_pair(8490, "ERROR_DS_PDC_OPERATION_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(8491, "ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD")); + ErrorNames.insert(std::make_pair(8492, "ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION")); + ErrorNames.insert(std::make_pair(8493, "ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS")); + ErrorNames.insert(std::make_pair(8494, "ERROR_DS_NC_MUST_HAVE_NC_PARENT")); + ErrorNames.insert(std::make_pair(8495, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE")); + ErrorNames.insert(std::make_pair(8496, "ERROR_DS_DST_DOMAIN_NOT_NATIVE")); + ErrorNames.insert(std::make_pair(8497, "ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER")); + ErrorNames.insert(std::make_pair(8498, "ERROR_DS_CANT_MOVE_ACCOUNT_GROUP")); + ErrorNames.insert(std::make_pair(8499, "ERROR_DS_CANT_MOVE_RESOURCE_GROUP")); + ErrorNames.insert(std::make_pair(8500, "ERROR_DS_INVALID_SEARCH_FLAG")); + ErrorNames.insert(std::make_pair(8501, "ERROR_DS_NO_TREE_DELETE_ABOVE_NC")); + ErrorNames.insert(std::make_pair(8502, "ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE")); + ErrorNames.insert(std::make_pair(8503, "ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE")); + ErrorNames.insert(std::make_pair(8504, "ERROR_DS_SAM_INIT_FAILURE")); + ErrorNames.insert(std::make_pair(8505, "ERROR_DS_SENSITIVE_GROUP_VIOLATION")); + ErrorNames.insert(std::make_pair(8506, "ERROR_DS_CANT_MOD_PRIMARYGROUPID")); + ErrorNames.insert(std::make_pair(8507, "ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD")); + ErrorNames.insert(std::make_pair(8508, "ERROR_DS_NONSAFE_SCHEMA_CHANGE")); + ErrorNames.insert(std::make_pair(8509, "ERROR_DS_SCHEMA_UPDATE_DISALLOWED")); + ErrorNames.insert(std::make_pair(8510, "ERROR_DS_CANT_CREATE_UNDER_SCHEMA")); + ErrorNames.insert(std::make_pair(8511, "ERROR_DS_INSTALL_NO_SRC_SCH_VERSION")); + ErrorNames.insert(std::make_pair(8512, "ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE")); + ErrorNames.insert(std::make_pair(8513, "ERROR_DS_INVALID_GROUP_TYPE")); + ErrorNames.insert(std::make_pair(8514, "ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN")); + ErrorNames.insert(std::make_pair(8515, "ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN")); + ErrorNames.insert(std::make_pair(8516, "ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER")); + ErrorNames.insert(std::make_pair(8517, "ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER")); + ErrorNames.insert(std::make_pair(8518, "ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER")); + ErrorNames.insert(std::make_pair(8519, "ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER")); + ErrorNames.insert(std::make_pair(8520, "ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER")); + ErrorNames.insert(std::make_pair(8521, "ERROR_DS_HAVE_PRIMARY_MEMBERS")); + ErrorNames.insert(std::make_pair(8522, "ERROR_DS_STRING_SD_CONVERSION_FAILED")); + ErrorNames.insert(std::make_pair(8523, "ERROR_DS_NAMING_MASTER_GC")); + ErrorNames.insert(std::make_pair(8524, "ERROR_DS_DNS_LOOKUP_FAILURE")); + ErrorNames.insert(std::make_pair(8525, "ERROR_DS_COULDNT_UPDATE_SPNS")); + ErrorNames.insert(std::make_pair(8526, "ERROR_DS_CANT_RETRIEVE_SD")); + ErrorNames.insert(std::make_pair(8527, "ERROR_DS_KEY_NOT_UNIQUE")); + ErrorNames.insert(std::make_pair(8528, "ERROR_DS_WRONG_LINKED_ATT_SYNTAX")); + ErrorNames.insert(std::make_pair(8529, "ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD")); + ErrorNames.insert(std::make_pair(8530, "ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY")); + ErrorNames.insert(std::make_pair(8531, "ERROR_DS_CANT_START")); + ErrorNames.insert(std::make_pair(8532, "ERROR_DS_INIT_FAILURE")); + ErrorNames.insert(std::make_pair(8533, "ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION")); + ErrorNames.insert(std::make_pair(8534, "ERROR_DS_SOURCE_DOMAIN_IN_FOREST")); + ErrorNames.insert(std::make_pair(8535, "ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST")); + ErrorNames.insert(std::make_pair(8536, "ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED")); + ErrorNames.insert(std::make_pair(8537, "ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN")); + ErrorNames.insert(std::make_pair(8538, "ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER")); + ErrorNames.insert(std::make_pair(8539, "ERROR_DS_SRC_SID_EXISTS_IN_FOREST")); + ErrorNames.insert(std::make_pair(8540, "ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH")); + ErrorNames.insert(std::make_pair(8541, "ERROR_SAM_INIT_FAILURE")); + ErrorNames.insert(std::make_pair(8542, "ERROR_DS_DRA_SCHEMA_INFO_SHIP")); + ErrorNames.insert(std::make_pair(8543, "ERROR_DS_DRA_SCHEMA_CONFLICT")); + ErrorNames.insert(std::make_pair(8544, "ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT")); + ErrorNames.insert(std::make_pair(8545, "ERROR_DS_DRA_OBJ_NC_MISMATCH")); + ErrorNames.insert(std::make_pair(8546, "ERROR_DS_NC_STILL_HAS_DSAS")); + ErrorNames.insert(std::make_pair(8547, "ERROR_DS_GC_REQUIRED")); + ErrorNames.insert(std::make_pair(8548, "ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY")); + ErrorNames.insert(std::make_pair(8549, "ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS")); + ErrorNames.insert(std::make_pair(8550, "ERROR_DS_CANT_ADD_TO_GC")); + ErrorNames.insert(std::make_pair(8551, "ERROR_DS_NO_CHECKPOINT_WITH_PDC")); + ErrorNames.insert(std::make_pair(8552, "ERROR_DS_SOURCE_AUDITING_NOT_ENABLED")); + ErrorNames.insert(std::make_pair(8553, "ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC")); + ErrorNames.insert(std::make_pair(8554, "ERROR_DS_INVALID_NAME_FOR_SPN")); + ErrorNames.insert(std::make_pair(8555, "ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS")); + ErrorNames.insert(std::make_pair(8556, "ERROR_DS_UNICODEPWD_NOT_IN_QUOTES")); + ErrorNames.insert(std::make_pair(8557, "ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED")); + ErrorNames.insert(std::make_pair(8558, "ERROR_DS_MUST_BE_RUN_ON_DST_DC")); + ErrorNames.insert(std::make_pair(8559, "ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER")); + ErrorNames.insert(std::make_pair(8560, "ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ")); + ErrorNames.insert(std::make_pair(8561, "ERROR_DS_INIT_FAILURE_CONSOLE")); + ErrorNames.insert(std::make_pair(8562, "ERROR_DS_SAM_INIT_FAILURE_CONSOLE")); + ErrorNames.insert(std::make_pair(8563, "ERROR_DS_FOREST_VERSION_TOO_HIGH")); + ErrorNames.insert(std::make_pair(8564, "ERROR_DS_DOMAIN_VERSION_TOO_HIGH")); + ErrorNames.insert(std::make_pair(8565, "ERROR_DS_FOREST_VERSION_TOO_LOW")); + ErrorNames.insert(std::make_pair(8566, "ERROR_DS_DOMAIN_VERSION_TOO_LOW")); + ErrorNames.insert(std::make_pair(8567, "ERROR_DS_INCOMPATIBLE_VERSION")); + ErrorNames.insert(std::make_pair(8568, "ERROR_DS_LOW_DSA_VERSION")); + ErrorNames.insert(std::make_pair(8569, "ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN")); + ErrorNames.insert(std::make_pair(8570, "ERROR_DS_NOT_SUPPORTED_SORT_ORDER")); + ErrorNames.insert(std::make_pair(8571, "ERROR_DS_NAME_NOT_UNIQUE")); + ErrorNames.insert(std::make_pair(8572, "ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4")); + ErrorNames.insert(std::make_pair(8573, "ERROR_DS_OUT_OF_VERSION_STORE")); + ErrorNames.insert(std::make_pair(8574, "ERROR_DS_INCOMPATIBLE_CONTROLS_USED")); + ErrorNames.insert(std::make_pair(8575, "ERROR_DS_NO_REF_DOMAIN")); + ErrorNames.insert(std::make_pair(8576, "ERROR_DS_RESERVED_LINK_ID")); + ErrorNames.insert(std::make_pair(8577, "ERROR_DS_LINK_ID_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(8578, "ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER")); + ErrorNames.insert(std::make_pair(8579, "ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE")); + ErrorNames.insert(std::make_pair(8580, "ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC")); + ErrorNames.insert(std::make_pair(8581, "ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG")); + ErrorNames.insert(std::make_pair(8582, "ERROR_DS_MODIFYDN_WRONG_GRANDPARENT")); + ErrorNames.insert(std::make_pair(8583, "ERROR_DS_NAME_ERROR_TRUST_REFERRAL")); + ErrorNames.insert(std::make_pair(8584, "ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER")); + ErrorNames.insert(std::make_pair(8585, "ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD")); + ErrorNames.insert(std::make_pair(8586, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2")); + ErrorNames.insert(std::make_pair(8587, "ERROR_DS_THREAD_LIMIT_EXCEEDED")); + ErrorNames.insert(std::make_pair(8588, "ERROR_DS_NOT_CLOSEST")); + ErrorNames.insert(std::make_pair(8589, "ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF")); + ErrorNames.insert(std::make_pair(8590, "ERROR_DS_SINGLE_USER_MODE_FAILED")); + ErrorNames.insert(std::make_pair(8591, "ERROR_DS_NTDSCRIPT_SYNTAX_ERROR")); + ErrorNames.insert(std::make_pair(8592, "ERROR_DS_NTDSCRIPT_PROCESS_ERROR")); + ErrorNames.insert(std::make_pair(8593, "ERROR_DS_DIFFERENT_REPL_EPOCHS")); + ErrorNames.insert(std::make_pair(8594, "ERROR_DS_DRS_EXTENSIONS_CHANGED")); + ErrorNames.insert(std::make_pair(8595, "ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR")); + ErrorNames.insert(std::make_pair(8596, "ERROR_DS_NO_MSDS_INTID")); + ErrorNames.insert(std::make_pair(8597, "ERROR_DS_DUP_MSDS_INTID")); + ErrorNames.insert(std::make_pair(8598, "ERROR_DS_EXISTS_IN_RDNATTID")); + ErrorNames.insert(std::make_pair(8599, "ERROR_DS_AUTHORIZATION_FAILED")); + ErrorNames.insert(std::make_pair(8600, "ERROR_DS_INVALID_SCRIPT")); + ErrorNames.insert(std::make_pair(8601, "ERROR_DS_REMOTE_CROSSREF_OP_FAILED")); + ErrorNames.insert(std::make_pair(8602, "ERROR_DS_CROSS_REF_BUSY")); + ErrorNames.insert(std::make_pair(8603, "ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN")); + ErrorNames.insert(std::make_pair(8604, "ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC")); + ErrorNames.insert(std::make_pair(8605, "ERROR_DS_DUPLICATE_ID_FOUND")); + ErrorNames.insert(std::make_pair(8606, "ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT")); + ErrorNames.insert(std::make_pair(8607, "ERROR_DS_GROUP_CONVERSION_ERROR")); + ErrorNames.insert(std::make_pair(8608, "ERROR_DS_CANT_MOVE_APP_BASIC_GROUP")); + ErrorNames.insert(std::make_pair(8609, "ERROR_DS_CANT_MOVE_APP_QUERY_GROUP")); + ErrorNames.insert(std::make_pair(8610, "ERROR_DS_ROLE_NOT_VERIFIED")); + ErrorNames.insert(std::make_pair(8611, "ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL")); + ErrorNames.insert(std::make_pair(8612, "ERROR_DS_DOMAIN_RENAME_IN_PROGRESS")); + ErrorNames.insert(std::make_pair(8613, "ERROR_DS_EXISTING_AD_CHILD_NC")); + ErrorNames.insert(std::make_pair(8614, "ERROR_DS_REPL_LIFETIME_EXCEEDED")); + ErrorNames.insert(std::make_pair(8615, "ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER")); + ErrorNames.insert(std::make_pair(8616, "ERROR_DS_LDAP_SEND_QUEUE_FULL")); + ErrorNames.insert(std::make_pair(8617, "ERROR_DS_DRA_OUT_SCHEDULE_WINDOW")); + ErrorNames.insert(std::make_pair(8618, "ERROR_DS_POLICY_NOT_KNOWN")); + ErrorNames.insert(std::make_pair(8619, "ERROR_NO_SITE_SETTINGS_OBJECT")); + ErrorNames.insert(std::make_pair(8620, "ERROR_NO_SECRETS")); + ErrorNames.insert(std::make_pair(8621, "ERROR_NO_WRITABLE_DC_FOUND")); + ErrorNames.insert(std::make_pair(8622, "ERROR_DS_NO_SERVER_OBJECT")); + ErrorNames.insert(std::make_pair(8623, "ERROR_DS_NO_NTDSA_OBJECT")); + ErrorNames.insert(std::make_pair(8624, "ERROR_DS_NON_ASQ_SEARCH")); + ErrorNames.insert(std::make_pair(8625, "ERROR_DS_AUDIT_FAILURE")); + ErrorNames.insert(std::make_pair(8626, "ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE")); + ErrorNames.insert(std::make_pair(8627, "ERROR_DS_INVALID_SEARCH_FLAG_TUPLE")); + ErrorNames.insert(std::make_pair(8628, "ERROR_DS_HIERARCHY_TABLE_TOO_DEEP")); + ErrorNames.insert(std::make_pair(8629, "ERROR_DS_DRA_CORRUPT_UTD_VECTOR")); + ErrorNames.insert(std::make_pair(8630, "ERROR_DS_DRA_SECRETS_DENIED")); + ErrorNames.insert(std::make_pair(8631, "ERROR_DS_RESERVED_MAPI_ID")); + ErrorNames.insert(std::make_pair(8632, "ERROR_DS_MAPI_ID_NOT_AVAILABLE")); + ErrorNames.insert(std::make_pair(8633, "ERROR_DS_DRA_MISSING_KRBTGT_SECRET")); + ErrorNames.insert(std::make_pair(8634, "ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST")); + ErrorNames.insert(std::make_pair(8635, "ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST")); + ErrorNames.insert(std::make_pair(8636, "ERROR_INVALID_USER_PRINCIPAL_NAME")); + ErrorNames.insert(std::make_pair(8637, "ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS")); + ErrorNames.insert(std::make_pair(8638, "ERROR_DS_OID_NOT_FOUND")); + ErrorNames.insert(std::make_pair(8639, "ERROR_DS_DRA_RECYCLED_TARGET")); + ErrorNames.insert(std::make_pair(13000, "ERROR_IPSEC_QM_POLICY_EXISTS")); + ErrorNames.insert(std::make_pair(13001, "ERROR_IPSEC_QM_POLICY_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13002, "ERROR_IPSEC_QM_POLICY_IN_USE")); + ErrorNames.insert(std::make_pair(13003, "ERROR_IPSEC_MM_POLICY_EXISTS")); + ErrorNames.insert(std::make_pair(13004, "ERROR_IPSEC_MM_POLICY_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13005, "ERROR_IPSEC_MM_POLICY_IN_USE")); + ErrorNames.insert(std::make_pair(13006, "ERROR_IPSEC_MM_FILTER_EXISTS")); + ErrorNames.insert(std::make_pair(13007, "ERROR_IPSEC_MM_FILTER_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13008, "ERROR_IPSEC_TRANSPORT_FILTER_EXISTS")); + ErrorNames.insert(std::make_pair(13009, "ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13010, "ERROR_IPSEC_MM_AUTH_EXISTS")); + ErrorNames.insert(std::make_pair(13011, "ERROR_IPSEC_MM_AUTH_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13012, "ERROR_IPSEC_MM_AUTH_IN_USE")); + ErrorNames.insert(std::make_pair(13013, "ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13014, "ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13015, "ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13016, "ERROR_IPSEC_TUNNEL_FILTER_EXISTS")); + ErrorNames.insert(std::make_pair(13017, "ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND")); + ErrorNames.insert(std::make_pair(13018, "ERROR_IPSEC_MM_FILTER_PENDING_DELETION")); + ErrorNames.insert(std::make_pair(13019, "ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION")); + ErrorNames.insert(std::make_pair(13020, "ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION")); + ErrorNames.insert(std::make_pair(13021, "ERROR_IPSEC_MM_POLICY_PENDING_DELETION")); + ErrorNames.insert(std::make_pair(13022, "ERROR_IPSEC_MM_AUTH_PENDING_DELETION")); + ErrorNames.insert(std::make_pair(13023, "ERROR_IPSEC_QM_POLICY_PENDING_DELETION")); + ErrorNames.insert(std::make_pair(13800, "ERROR_IPSEC_IKE_NEG_STATUS_BEGIN")); + ErrorNames.insert(std::make_pair(13801, "ERROR_IPSEC_IKE_AUTH_FAIL")); + ErrorNames.insert(std::make_pair(13802, "ERROR_IPSEC_IKE_ATTRIB_FAIL")); + ErrorNames.insert(std::make_pair(13803, "ERROR_IPSEC_IKE_NEGOTIATION_PENDING")); + ErrorNames.insert(std::make_pair(13804, "ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR")); + ErrorNames.insert(std::make_pair(13805, "ERROR_IPSEC_IKE_TIMED_OUT")); + ErrorNames.insert(std::make_pair(13806, "ERROR_IPSEC_IKE_NO_CERT")); + ErrorNames.insert(std::make_pair(13807, "ERROR_IPSEC_IKE_SA_DELETED")); + ErrorNames.insert(std::make_pair(13808, "ERROR_IPSEC_IKE_SA_REAPED")); + ErrorNames.insert(std::make_pair(13809, "ERROR_IPSEC_IKE_MM_ACQUIRE_DROP")); + ErrorNames.insert(std::make_pair(13810, "ERROR_IPSEC_IKE_QM_ACQUIRE_DROP")); + ErrorNames.insert(std::make_pair(13811, "ERROR_IPSEC_IKE_QUEUE_DROP_MM")); + ErrorNames.insert(std::make_pair(13812, "ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM")); + ErrorNames.insert(std::make_pair(13813, "ERROR_IPSEC_IKE_DROP_NO_RESPONSE")); + ErrorNames.insert(std::make_pair(13814, "ERROR_IPSEC_IKE_MM_DELAY_DROP")); + ErrorNames.insert(std::make_pair(13815, "ERROR_IPSEC_IKE_QM_DELAY_DROP")); + ErrorNames.insert(std::make_pair(13816, "ERROR_IPSEC_IKE_ERROR")); + ErrorNames.insert(std::make_pair(13817, "ERROR_IPSEC_IKE_CRL_FAILED")); + ErrorNames.insert(std::make_pair(13818, "ERROR_IPSEC_IKE_INVALID_KEY_USAGE")); + ErrorNames.insert(std::make_pair(13819, "ERROR_IPSEC_IKE_INVALID_CERT_TYPE")); + ErrorNames.insert(std::make_pair(13820, "ERROR_IPSEC_IKE_NO_PRIVATE_KEY")); + ErrorNames.insert(std::make_pair(13821, "ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY")); + ErrorNames.insert(std::make_pair(13822, "ERROR_IPSEC_IKE_DH_FAIL")); + ErrorNames.insert(std::make_pair(13823, "ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED")); + ErrorNames.insert(std::make_pair(13824, "ERROR_IPSEC_IKE_INVALID_HEADER")); + ErrorNames.insert(std::make_pair(13825, "ERROR_IPSEC_IKE_NO_POLICY")); + ErrorNames.insert(std::make_pair(13826, "ERROR_IPSEC_IKE_INVALID_SIGNATURE")); + ErrorNames.insert(std::make_pair(13827, "ERROR_IPSEC_IKE_KERBEROS_ERROR")); + ErrorNames.insert(std::make_pair(13828, "ERROR_IPSEC_IKE_NO_PUBLIC_KEY")); + ErrorNames.insert(std::make_pair(13829, "ERROR_IPSEC_IKE_PROCESS_ERR")); + ErrorNames.insert(std::make_pair(13830, "ERROR_IPSEC_IKE_PROCESS_ERR_SA")); + ErrorNames.insert(std::make_pair(13831, "ERROR_IPSEC_IKE_PROCESS_ERR_PROP")); + ErrorNames.insert(std::make_pair(13832, "ERROR_IPSEC_IKE_PROCESS_ERR_TRANS")); + ErrorNames.insert(std::make_pair(13833, "ERROR_IPSEC_IKE_PROCESS_ERR_KE")); + ErrorNames.insert(std::make_pair(13834, "ERROR_IPSEC_IKE_PROCESS_ERR_ID")); + ErrorNames.insert(std::make_pair(13835, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT")); + ErrorNames.insert(std::make_pair(13836, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ")); + ErrorNames.insert(std::make_pair(13837, "ERROR_IPSEC_IKE_PROCESS_ERR_HASH")); + ErrorNames.insert(std::make_pair(13838, "ERROR_IPSEC_IKE_PROCESS_ERR_SIG")); + ErrorNames.insert(std::make_pair(13839, "ERROR_IPSEC_IKE_PROCESS_ERR_NONCE")); + ErrorNames.insert(std::make_pair(13840, "ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY")); + ErrorNames.insert(std::make_pair(13841, "ERROR_IPSEC_IKE_PROCESS_ERR_DELETE")); + ErrorNames.insert(std::make_pair(13842, "ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR")); + ErrorNames.insert(std::make_pair(13843, "ERROR_IPSEC_IKE_INVALID_PAYLOAD")); + ErrorNames.insert(std::make_pair(13844, "ERROR_IPSEC_IKE_LOAD_SOFT_SA")); + ErrorNames.insert(std::make_pair(13845, "ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN")); + ErrorNames.insert(std::make_pair(13846, "ERROR_IPSEC_IKE_INVALID_COOKIE")); + ErrorNames.insert(std::make_pair(13847, "ERROR_IPSEC_IKE_NO_PEER_CERT")); + ErrorNames.insert(std::make_pair(13848, "ERROR_IPSEC_IKE_PEER_CRL_FAILED")); + ErrorNames.insert(std::make_pair(13849, "ERROR_IPSEC_IKE_POLICY_CHANGE")); + ErrorNames.insert(std::make_pair(13850, "ERROR_IPSEC_IKE_NO_MM_POLICY")); + ErrorNames.insert(std::make_pair(13851, "ERROR_IPSEC_IKE_NOTCBPRIV")); + ErrorNames.insert(std::make_pair(13852, "ERROR_IPSEC_IKE_SECLOADFAIL")); + ErrorNames.insert(std::make_pair(13853, "ERROR_IPSEC_IKE_FAILSSPINIT")); + ErrorNames.insert(std::make_pair(13854, "ERROR_IPSEC_IKE_FAILQUERYSSP")); + ErrorNames.insert(std::make_pair(13855, "ERROR_IPSEC_IKE_SRVACQFAIL")); + ErrorNames.insert(std::make_pair(13856, "ERROR_IPSEC_IKE_SRVQUERYCRED")); + ErrorNames.insert(std::make_pair(13857, "ERROR_IPSEC_IKE_GETSPIFAIL")); + ErrorNames.insert(std::make_pair(13858, "ERROR_IPSEC_IKE_INVALID_FILTER")); + ErrorNames.insert(std::make_pair(13859, "ERROR_IPSEC_IKE_OUT_OF_MEMORY")); + ErrorNames.insert(std::make_pair(13860, "ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED")); + ErrorNames.insert(std::make_pair(13861, "ERROR_IPSEC_IKE_INVALID_POLICY")); + ErrorNames.insert(std::make_pair(13862, "ERROR_IPSEC_IKE_UNKNOWN_DOI")); + ErrorNames.insert(std::make_pair(13863, "ERROR_IPSEC_IKE_INVALID_SITUATION")); + ErrorNames.insert(std::make_pair(13864, "ERROR_IPSEC_IKE_DH_FAILURE")); + ErrorNames.insert(std::make_pair(13865, "ERROR_IPSEC_IKE_INVALID_GROUP")); + ErrorNames.insert(std::make_pair(13866, "ERROR_IPSEC_IKE_ENCRYPT")); + ErrorNames.insert(std::make_pair(13867, "ERROR_IPSEC_IKE_DECRYPT")); + ErrorNames.insert(std::make_pair(13868, "ERROR_IPSEC_IKE_POLICY_MATCH")); + ErrorNames.insert(std::make_pair(13869, "ERROR_IPSEC_IKE_UNSUPPORTED_ID")); + ErrorNames.insert(std::make_pair(13870, "ERROR_IPSEC_IKE_INVALID_HASH")); + ErrorNames.insert(std::make_pair(13871, "ERROR_IPSEC_IKE_INVALID_HASH_ALG")); + ErrorNames.insert(std::make_pair(13872, "ERROR_IPSEC_IKE_INVALID_HASH_SIZE")); + ErrorNames.insert(std::make_pair(13873, "ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG")); + ErrorNames.insert(std::make_pair(13874, "ERROR_IPSEC_IKE_INVALID_AUTH_ALG")); + ErrorNames.insert(std::make_pair(13875, "ERROR_IPSEC_IKE_INVALID_SIG")); + ErrorNames.insert(std::make_pair(13876, "ERROR_IPSEC_IKE_LOAD_FAILED")); + ErrorNames.insert(std::make_pair(13877, "ERROR_IPSEC_IKE_RPC_DELETE")); + ErrorNames.insert(std::make_pair(13878, "ERROR_IPSEC_IKE_BENIGN_REINIT")); + ErrorNames.insert(std::make_pair(13879, "ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY")); + ErrorNames.insert(std::make_pair(13880, "ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION")); + ErrorNames.insert(std::make_pair(13881, "ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN")); + ErrorNames.insert(std::make_pair(13882, "ERROR_IPSEC_IKE_MM_LIMIT")); + ErrorNames.insert(std::make_pair(13883, "ERROR_IPSEC_IKE_NEGOTIATION_DISABLED")); + ErrorNames.insert(std::make_pair(13884, "ERROR_IPSEC_IKE_QM_LIMIT")); + ErrorNames.insert(std::make_pair(13885, "ERROR_IPSEC_IKE_MM_EXPIRED")); + ErrorNames.insert(std::make_pair(13886, "ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID")); + ErrorNames.insert(std::make_pair(13887, "ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH")); + ErrorNames.insert(std::make_pair(13888, "ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID")); + ErrorNames.insert(std::make_pair(13889, "ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD")); + ErrorNames.insert(std::make_pair(13890, "ERROR_IPSEC_IKE_DOS_COOKIE_SENT")); + ErrorNames.insert(std::make_pair(13891, "ERROR_IPSEC_IKE_SHUTTING_DOWN")); + ErrorNames.insert(std::make_pair(13892, "ERROR_IPSEC_IKE_CGA_AUTH_FAILED")); + ErrorNames.insert(std::make_pair(13893, "ERROR_IPSEC_IKE_PROCESS_ERR_NATOA")); + ErrorNames.insert(std::make_pair(13894, "ERROR_IPSEC_IKE_INVALID_MM_FOR_QM")); + ErrorNames.insert(std::make_pair(13895, "ERROR_IPSEC_IKE_QM_EXPIRED")); + ErrorNames.insert(std::make_pair(13896, "ERROR_IPSEC_IKE_TOO_MANY_FILTERS")); + ErrorNames.insert(std::make_pair(13897, "ERROR_IPSEC_IKE_NEG_STATUS_END")); + ErrorNames.insert(std::make_pair(13898, "ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL")); + ErrorNames.insert(std::make_pair(13899, "ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE")); + ErrorNames.insert(std::make_pair(13900, "ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING")); + ErrorNames.insert(std::make_pair(13901, "ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING")); + ErrorNames.insert(std::make_pair(13902, "ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS")); + ErrorNames.insert(std::make_pair(13903, "ERROR_IPSEC_IKE_RATELIMIT_DROP")); + ErrorNames.insert(std::make_pair(13904, "ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE")); + ErrorNames.insert(std::make_pair(13905, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE")); + ErrorNames.insert(std::make_pair(13906, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE")); + ErrorNames.insert(std::make_pair(13907, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY")); + ErrorNames.insert(std::make_pair(13908, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE")); + ErrorNames.insert(std::make_pair(13909, "ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END")); + ErrorNames.insert(std::make_pair(13910, "ERROR_IPSEC_BAD_SPI")); + ErrorNames.insert(std::make_pair(13911, "ERROR_IPSEC_SA_LIFETIME_EXPIRED")); + ErrorNames.insert(std::make_pair(13912, "ERROR_IPSEC_WRONG_SA")); + ErrorNames.insert(std::make_pair(13913, "ERROR_IPSEC_REPLAY_CHECK_FAILED")); + ErrorNames.insert(std::make_pair(13914, "ERROR_IPSEC_INVALID_PACKET")); + ErrorNames.insert(std::make_pair(13915, "ERROR_IPSEC_INTEGRITY_CHECK_FAILED")); + ErrorNames.insert(std::make_pair(13916, "ERROR_IPSEC_CLEAR_TEXT_DROP")); + ErrorNames.insert(std::make_pair(13917, "ERROR_IPSEC_AUTH_FIREWALL_DROP")); + ErrorNames.insert(std::make_pair(13918, "ERROR_IPSEC_THROTTLE_DROP")); + ErrorNames.insert(std::make_pair(13925, "ERROR_IPSEC_DOSP_BLOCK")); + ErrorNames.insert(std::make_pair(13926, "ERROR_IPSEC_DOSP_RECEIVED_MULTICAST")); + ErrorNames.insert(std::make_pair(13927, "ERROR_IPSEC_DOSP_INVALID_PACKET")); + ErrorNames.insert(std::make_pair(13928, "ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED")); + ErrorNames.insert(std::make_pair(13929, "ERROR_IPSEC_DOSP_MAX_ENTRIES")); + ErrorNames.insert(std::make_pair(13930, "ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED")); + ErrorNames.insert(std::make_pair(13931, "ERROR_IPSEC_DOSP_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(13932, "ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES")); + ErrorNames.insert(std::make_pair(14000, "ERROR_SXS_SECTION_NOT_FOUND")); + ErrorNames.insert(std::make_pair(14001, "ERROR_SXS_CANT_GEN_ACTCTX")); + ErrorNames.insert(std::make_pair(14002, "ERROR_SXS_INVALID_ACTCTXDATA_FORMAT")); + ErrorNames.insert(std::make_pair(14003, "ERROR_SXS_ASSEMBLY_NOT_FOUND")); + ErrorNames.insert(std::make_pair(14004, "ERROR_SXS_MANIFEST_FORMAT_ERROR")); + ErrorNames.insert(std::make_pair(14005, "ERROR_SXS_MANIFEST_PARSE_ERROR")); + ErrorNames.insert(std::make_pair(14006, "ERROR_SXS_ACTIVATION_CONTEXT_DISABLED")); + ErrorNames.insert(std::make_pair(14007, "ERROR_SXS_KEY_NOT_FOUND")); + ErrorNames.insert(std::make_pair(14008, "ERROR_SXS_VERSION_CONFLICT")); + ErrorNames.insert(std::make_pair(14009, "ERROR_SXS_WRONG_SECTION_TYPE")); + ErrorNames.insert(std::make_pair(14010, "ERROR_SXS_THREAD_QUERIES_DISABLED")); + ErrorNames.insert(std::make_pair(14011, "ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET")); + ErrorNames.insert(std::make_pair(14012, "ERROR_SXS_UNKNOWN_ENCODING_GROUP")); + ErrorNames.insert(std::make_pair(14013, "ERROR_SXS_UNKNOWN_ENCODING")); + ErrorNames.insert(std::make_pair(14014, "ERROR_SXS_INVALID_XML_NAMESPACE_URI")); + ErrorNames.insert(std::make_pair(14015, "ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(14016, "ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(14017, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE")); + ErrorNames.insert(std::make_pair(14018, "ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE")); + ErrorNames.insert(std::make_pair(14019, "ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE")); + ErrorNames.insert(std::make_pair(14020, "ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT")); + ErrorNames.insert(std::make_pair(14021, "ERROR_SXS_DUPLICATE_DLL_NAME")); + ErrorNames.insert(std::make_pair(14022, "ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME")); + ErrorNames.insert(std::make_pair(14023, "ERROR_SXS_DUPLICATE_CLSID")); + ErrorNames.insert(std::make_pair(14024, "ERROR_SXS_DUPLICATE_IID")); + ErrorNames.insert(std::make_pair(14025, "ERROR_SXS_DUPLICATE_TLBID")); + ErrorNames.insert(std::make_pair(14026, "ERROR_SXS_DUPLICATE_PROGID")); + ErrorNames.insert(std::make_pair(14027, "ERROR_SXS_DUPLICATE_ASSEMBLY_NAME")); + ErrorNames.insert(std::make_pair(14028, "ERROR_SXS_FILE_HASH_MISMATCH")); + ErrorNames.insert(std::make_pair(14029, "ERROR_SXS_POLICY_PARSE_ERROR")); + ErrorNames.insert(std::make_pair(14030, "ERROR_SXS_XML_E_MISSINGQUOTE")); + ErrorNames.insert(std::make_pair(14031, "ERROR_SXS_XML_E_COMMENTSYNTAX")); + ErrorNames.insert(std::make_pair(14032, "ERROR_SXS_XML_E_BADSTARTNAMECHAR")); + ErrorNames.insert(std::make_pair(14033, "ERROR_SXS_XML_E_BADNAMECHAR")); + ErrorNames.insert(std::make_pair(14034, "ERROR_SXS_XML_E_BADCHARINSTRING")); + ErrorNames.insert(std::make_pair(14035, "ERROR_SXS_XML_E_XMLDECLSYNTAX")); + ErrorNames.insert(std::make_pair(14036, "ERROR_SXS_XML_E_BADCHARDATA")); + ErrorNames.insert(std::make_pair(14037, "ERROR_SXS_XML_E_MISSINGWHITESPACE")); + ErrorNames.insert(std::make_pair(14038, "ERROR_SXS_XML_E_EXPECTINGTAGEND")); + ErrorNames.insert(std::make_pair(14039, "ERROR_SXS_XML_E_MISSINGSEMICOLON")); + ErrorNames.insert(std::make_pair(14040, "ERROR_SXS_XML_E_UNBALANCEDPAREN")); + ErrorNames.insert(std::make_pair(14041, "ERROR_SXS_XML_E_INTERNALERROR")); + ErrorNames.insert(std::make_pair(14042, "ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE")); + ErrorNames.insert(std::make_pair(14043, "ERROR_SXS_XML_E_INCOMPLETE_ENCODING")); + ErrorNames.insert(std::make_pair(14044, "ERROR_SXS_XML_E_MISSING_PAREN")); + ErrorNames.insert(std::make_pair(14045, "ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE")); + ErrorNames.insert(std::make_pair(14046, "ERROR_SXS_XML_E_MULTIPLE_COLONS")); + ErrorNames.insert(std::make_pair(14047, "ERROR_SXS_XML_E_INVALID_DECIMAL")); + ErrorNames.insert(std::make_pair(14048, "ERROR_SXS_XML_E_INVALID_HEXIDECIMAL")); + ErrorNames.insert(std::make_pair(14049, "ERROR_SXS_XML_E_INVALID_UNICODE")); + ErrorNames.insert(std::make_pair(14050, "ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK")); + ErrorNames.insert(std::make_pair(14051, "ERROR_SXS_XML_E_UNEXPECTEDENDTAG")); + ErrorNames.insert(std::make_pair(14052, "ERROR_SXS_XML_E_UNCLOSEDTAG")); + ErrorNames.insert(std::make_pair(14053, "ERROR_SXS_XML_E_DUPLICATEATTRIBUTE")); + ErrorNames.insert(std::make_pair(14054, "ERROR_SXS_XML_E_MULTIPLEROOTS")); + ErrorNames.insert(std::make_pair(14055, "ERROR_SXS_XML_E_INVALIDATROOTLEVEL")); + ErrorNames.insert(std::make_pair(14056, "ERROR_SXS_XML_E_BADXMLDECL")); + ErrorNames.insert(std::make_pair(14057, "ERROR_SXS_XML_E_MISSINGROOT")); + ErrorNames.insert(std::make_pair(14058, "ERROR_SXS_XML_E_UNEXPECTEDEOF")); + ErrorNames.insert(std::make_pair(14059, "ERROR_SXS_XML_E_BADPEREFINSUBSET")); + ErrorNames.insert(std::make_pair(14060, "ERROR_SXS_XML_E_UNCLOSEDSTARTTAG")); + ErrorNames.insert(std::make_pair(14061, "ERROR_SXS_XML_E_UNCLOSEDENDTAG")); + ErrorNames.insert(std::make_pair(14062, "ERROR_SXS_XML_E_UNCLOSEDSTRING")); + ErrorNames.insert(std::make_pair(14063, "ERROR_SXS_XML_E_UNCLOSEDCOMMENT")); + ErrorNames.insert(std::make_pair(14064, "ERROR_SXS_XML_E_UNCLOSEDDECL")); + ErrorNames.insert(std::make_pair(14065, "ERROR_SXS_XML_E_UNCLOSEDCDATA")); + ErrorNames.insert(std::make_pair(14066, "ERROR_SXS_XML_E_RESERVEDNAMESPACE")); + ErrorNames.insert(std::make_pair(14067, "ERROR_SXS_XML_E_INVALIDENCODING")); + ErrorNames.insert(std::make_pair(14068, "ERROR_SXS_XML_E_INVALIDSWITCH")); + ErrorNames.insert(std::make_pair(14069, "ERROR_SXS_XML_E_BADXMLCASE")); + ErrorNames.insert(std::make_pair(14070, "ERROR_SXS_XML_E_INVALID_STANDALONE")); + ErrorNames.insert(std::make_pair(14071, "ERROR_SXS_XML_E_UNEXPECTED_STANDALONE")); + ErrorNames.insert(std::make_pair(14072, "ERROR_SXS_XML_E_INVALID_VERSION")); + ErrorNames.insert(std::make_pair(14073, "ERROR_SXS_XML_E_MISSINGEQUALS")); + ErrorNames.insert(std::make_pair(14074, "ERROR_SXS_PROTECTION_RECOVERY_FAILED")); + ErrorNames.insert(std::make_pair(14075, "ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT")); + ErrorNames.insert(std::make_pair(14076, "ERROR_SXS_PROTECTION_CATALOG_NOT_VALID")); + ErrorNames.insert(std::make_pair(14077, "ERROR_SXS_UNTRANSLATABLE_HRESULT")); + ErrorNames.insert(std::make_pair(14078, "ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING")); + ErrorNames.insert(std::make_pair(14079, "ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE")); + ErrorNames.insert(std::make_pair(14080, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME")); + ErrorNames.insert(std::make_pair(14081, "ERROR_SXS_ASSEMBLY_MISSING")); + ErrorNames.insert(std::make_pair(14082, "ERROR_SXS_CORRUPT_ACTIVATION_STACK")); + ErrorNames.insert(std::make_pair(14083, "ERROR_SXS_CORRUPTION")); + ErrorNames.insert(std::make_pair(14084, "ERROR_SXS_EARLY_DEACTIVATION")); + ErrorNames.insert(std::make_pair(14085, "ERROR_SXS_INVALID_DEACTIVATION")); + ErrorNames.insert(std::make_pair(14086, "ERROR_SXS_MULTIPLE_DEACTIVATION")); + ErrorNames.insert(std::make_pair(14087, "ERROR_SXS_PROCESS_TERMINATION_REQUESTED")); + ErrorNames.insert(std::make_pair(14088, "ERROR_SXS_RELEASE_ACTIVATION_CONTEXT")); + ErrorNames.insert(std::make_pair(14089, "ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY")); + ErrorNames.insert(std::make_pair(14090, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE")); + ErrorNames.insert(std::make_pair(14091, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME")); + ErrorNames.insert(std::make_pair(14092, "ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE")); + ErrorNames.insert(std::make_pair(14093, "ERROR_SXS_IDENTITY_PARSE_ERROR")); + ErrorNames.insert(std::make_pair(14094, "ERROR_MALFORMED_SUBSTITUTION_STRING")); + ErrorNames.insert(std::make_pair(14095, "ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN")); + ErrorNames.insert(std::make_pair(14096, "ERROR_UNMAPPED_SUBSTITUTION_STRING")); + ErrorNames.insert(std::make_pair(14097, "ERROR_SXS_ASSEMBLY_NOT_LOCKED")); + ErrorNames.insert(std::make_pair(14098, "ERROR_SXS_COMPONENT_STORE_CORRUPT")); + ErrorNames.insert(std::make_pair(14099, "ERROR_ADVANCED_INSTALLER_FAILED")); + ErrorNames.insert(std::make_pair(14100, "ERROR_XML_ENCODING_MISMATCH")); + ErrorNames.insert(std::make_pair(14101, "ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT")); + ErrorNames.insert(std::make_pair(14102, "ERROR_SXS_IDENTITIES_DIFFERENT")); + ErrorNames.insert(std::make_pair(14103, "ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT")); + ErrorNames.insert(std::make_pair(14104, "ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY")); + ErrorNames.insert(std::make_pair(14105, "ERROR_SXS_MANIFEST_TOO_BIG")); + ErrorNames.insert(std::make_pair(14106, "ERROR_SXS_SETTING_NOT_REGISTERED")); + ErrorNames.insert(std::make_pair(14107, "ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE")); + ErrorNames.insert(std::make_pair(14108, "ERROR_SMI_PRIMITIVE_INSTALLER_FAILED")); + ErrorNames.insert(std::make_pair(14109, "ERROR_GENERIC_COMMAND_FAILED")); + ErrorNames.insert(std::make_pair(14110, "ERROR_SXS_FILE_HASH_MISSING")); + ErrorNames.insert(std::make_pair(15000, "ERROR_EVT_INVALID_CHANNEL_PATH")); + ErrorNames.insert(std::make_pair(15001, "ERROR_EVT_INVALID_QUERY")); + ErrorNames.insert(std::make_pair(15002, "ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15003, "ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15004, "ERROR_EVT_INVALID_PUBLISHER_NAME")); + ErrorNames.insert(std::make_pair(15005, "ERROR_EVT_INVALID_EVENT_DATA")); + ErrorNames.insert(std::make_pair(15007, "ERROR_EVT_CHANNEL_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15008, "ERROR_EVT_MALFORMED_XML_TEXT")); + ErrorNames.insert(std::make_pair(15009, "ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL")); + ErrorNames.insert(std::make_pair(15010, "ERROR_EVT_CONFIGURATION_ERROR")); + ErrorNames.insert(std::make_pair(15011, "ERROR_EVT_QUERY_RESULT_STALE")); + ErrorNames.insert(std::make_pair(15012, "ERROR_EVT_QUERY_RESULT_INVALID_POSITION")); + ErrorNames.insert(std::make_pair(15013, "ERROR_EVT_NON_VALIDATING_MSXML")); + ErrorNames.insert(std::make_pair(15014, "ERROR_EVT_FILTER_ALREADYSCOPED")); + ErrorNames.insert(std::make_pair(15015, "ERROR_EVT_FILTER_NOTELTSET")); + ErrorNames.insert(std::make_pair(15016, "ERROR_EVT_FILTER_INVARG")); + ErrorNames.insert(std::make_pair(15017, "ERROR_EVT_FILTER_INVTEST")); + ErrorNames.insert(std::make_pair(15018, "ERROR_EVT_FILTER_INVTYPE")); + ErrorNames.insert(std::make_pair(15019, "ERROR_EVT_FILTER_PARSEERR")); + ErrorNames.insert(std::make_pair(15020, "ERROR_EVT_FILTER_UNSUPPORTEDOP")); + ErrorNames.insert(std::make_pair(15021, "ERROR_EVT_FILTER_UNEXPECTEDTOKEN")); + ErrorNames.insert(std::make_pair(15022, "ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL")); + ErrorNames.insert(std::make_pair(15023, "ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE")); + ErrorNames.insert(std::make_pair(15024, "ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE")); + ErrorNames.insert(std::make_pair(15025, "ERROR_EVT_CHANNEL_CANNOT_ACTIVATE")); + ErrorNames.insert(std::make_pair(15026, "ERROR_EVT_FILTER_TOO_COMPLEX")); + ErrorNames.insert(std::make_pair(15027, "ERROR_EVT_MESSAGE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15028, "ERROR_EVT_MESSAGE_ID_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15029, "ERROR_EVT_UNRESOLVED_VALUE_INSERT")); + ErrorNames.insert(std::make_pair(15030, "ERROR_EVT_UNRESOLVED_PARAMETER_INSERT")); + ErrorNames.insert(std::make_pair(15031, "ERROR_EVT_MAX_INSERTS_REACHED")); + ErrorNames.insert(std::make_pair(15032, "ERROR_EVT_EVENT_DEFINITION_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15033, "ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15034, "ERROR_EVT_VERSION_TOO_OLD")); + ErrorNames.insert(std::make_pair(15035, "ERROR_EVT_VERSION_TOO_NEW")); + ErrorNames.insert(std::make_pair(15036, "ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY")); + ErrorNames.insert(std::make_pair(15037, "ERROR_EVT_PUBLISHER_DISABLED")); + ErrorNames.insert(std::make_pair(15038, "ERROR_EVT_FILTER_OUT_OF_RANGE")); + ErrorNames.insert(std::make_pair(15080, "ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE")); + ErrorNames.insert(std::make_pair(15081, "ERROR_EC_LOG_DISABLED")); + ErrorNames.insert(std::make_pair(15082, "ERROR_EC_CIRCULAR_FORWARDING")); + ErrorNames.insert(std::make_pair(15083, "ERROR_EC_CREDSTORE_FULL")); + ErrorNames.insert(std::make_pair(15084, "ERROR_EC_CRED_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15085, "ERROR_EC_NO_ACTIVE_CHANNEL")); + ErrorNames.insert(std::make_pair(15100, "ERROR_MUI_FILE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15101, "ERROR_MUI_INVALID_FILE")); + ErrorNames.insert(std::make_pair(15102, "ERROR_MUI_INVALID_RC_CONFIG")); + ErrorNames.insert(std::make_pair(15103, "ERROR_MUI_INVALID_LOCALE_NAME")); + ErrorNames.insert(std::make_pair(15104, "ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME")); + ErrorNames.insert(std::make_pair(15105, "ERROR_MUI_FILE_NOT_LOADED")); + ErrorNames.insert(std::make_pair(15106, "ERROR_RESOURCE_ENUM_USER_STOP")); + ErrorNames.insert(std::make_pair(15107, "ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED")); + ErrorNames.insert(std::make_pair(15108, "ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME")); + ErrorNames.insert(std::make_pair(15200, "ERROR_MCA_INVALID_CAPABILITIES_STRING")); + ErrorNames.insert(std::make_pair(15201, "ERROR_MCA_INVALID_VCP_VERSION")); + ErrorNames.insert(std::make_pair(15202, "ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION")); + ErrorNames.insert(std::make_pair(15203, "ERROR_MCA_MCCS_VERSION_MISMATCH")); + ErrorNames.insert(std::make_pair(15204, "ERROR_MCA_UNSUPPORTED_MCCS_VERSION")); + ErrorNames.insert(std::make_pair(15205, "ERROR_MCA_INTERNAL_ERROR")); + ErrorNames.insert(std::make_pair(15206, "ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED")); + ErrorNames.insert(std::make_pair(15207, "ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE")); + ErrorNames.insert(std::make_pair(15250, "ERROR_AMBIGUOUS_SYSTEM_DEVICE")); + ErrorNames.insert(std::make_pair(15299, "ERROR_SYSTEM_DEVICE_NOT_FOUND")); + ErrorNames.insert(std::make_pair(15300, "ERROR_HASH_NOT_SUPPORTED")); + ErrorNames.insert(std::make_pair(15301, "ERROR_HASH_NOT_PRESENT")); } const char* ErrorCodeToName(unsigned int ErrorCode) { - if(!errorNames.count(ErrorCode)) + if(!ErrorNames.count(ErrorCode)) return nullptr; - return errorNames[ErrorCode]; + return ErrorNames[ErrorCode]; } \ No newline at end of file diff --git a/x64_dbg_dbg/exception.cpp b/x64_dbg_dbg/exception.cpp index c44611cc..2429b29e 100644 --- a/x64_dbg_dbg/exception.cpp +++ b/x64_dbg_dbg/exception.cpp @@ -1,78 +1,78 @@ #include "exception.h" #include -std::unordered_map exceptionNames; +std::unordered_map ExceptionNames; void ExceptionCodeInit() { - exceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); - exceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); - exceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); - exceptionNames.insert(std::make_pair(0x4000001D, "STATUS_WX86_CONTINUE")); - exceptionNames.insert(std::make_pair(0x4000001E, "STATUS_WX86_SINGLE_STEP")); - exceptionNames.insert(std::make_pair(0x4000001F, "STATUS_WX86_BREAKPOINT")); - exceptionNames.insert(std::make_pair(0x40000020, "STATUS_WX86_EXCEPTION_CONTINUE")); - exceptionNames.insert(std::make_pair(0x40000021, "STATUS_WX86_EXCEPTION_LASTCHANCE")); - exceptionNames.insert(std::make_pair(0x40000022, "STATUS_WX86_EXCEPTION_CHAIN")); - exceptionNames.insert(std::make_pair(0x40000028, "STATUS_WX86_CREATEWX86TIB")); - exceptionNames.insert(std::make_pair(0x40010003, "DBG_TERMINATE_THREAD")); - exceptionNames.insert(std::make_pair(0x40010004, "DBG_TERMINATE_PROCESS")); - exceptionNames.insert(std::make_pair(0x40010005, "DBG_CONTROL_C")); - exceptionNames.insert(std::make_pair(0x40010006, "DBG_PRINTEXCEPTION_C")); - exceptionNames.insert(std::make_pair(0x40010007, "DBG_RIPEXCEPTION")); - exceptionNames.insert(std::make_pair(0x40010008, "DBG_CONTROL_BREAK")); - exceptionNames.insert(std::make_pair(0x40010009, "DBG_COMMAND_EXCEPTION")); - exceptionNames.insert(std::make_pair(0x406D1388, "MS_VC_EXCEPTION")); - exceptionNames.insert(std::make_pair(0x80000001, "EXCEPTION_GUARD_PAGE")); - exceptionNames.insert(std::make_pair(0x80000002, "EXCEPTION_DATATYPE_MISALIGNMENT")); - exceptionNames.insert(std::make_pair(0x80000003, "EXCEPTION_BREAKPOINT")); - exceptionNames.insert(std::make_pair(0x80000004, "EXCEPTION_SINGLE_STEP")); - exceptionNames.insert(std::make_pair(0x80000026, "STATUS_LONGJUMP")); - exceptionNames.insert(std::make_pair(0x80000029, "STATUS_UNWIND_CONSOLIDATE")); - exceptionNames.insert(std::make_pair(0x80010001, "DBG_EXCEPTION_NOT_HANDLED")); - exceptionNames.insert(std::make_pair(0xC0000005, "EXCEPTION_ACCESS_VIOLATION")); - exceptionNames.insert(std::make_pair(0xC0000006, "EXCEPTION_IN_PAGE_ERROR")); - exceptionNames.insert(std::make_pair(0xC0000008, "EXCEPTION_INVALID_HANDLE")); - exceptionNames.insert(std::make_pair(0xC000000D, "STATUS_INVALID_PARAMETER")); - exceptionNames.insert(std::make_pair(0xC0000017, "STATUS_NO_MEMORY")); - exceptionNames.insert(std::make_pair(0xC000001D, "EXCEPTION_ILLEGAL_INSTRUCTION")); - exceptionNames.insert(std::make_pair(0xC0000025, "EXCEPTION_NONCONTINUABLE_EXCEPTION")); - exceptionNames.insert(std::make_pair(0xC0000026, "EXCEPTION_INVALID_DISPOSITION")); - exceptionNames.insert(std::make_pair(0xC000008C, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED")); - exceptionNames.insert(std::make_pair(0xC000008D, "EXCEPTION_FLT_DENORMAL_OPERAND")); - exceptionNames.insert(std::make_pair(0xC000008E, "EXCEPTION_FLT_DIVIDE_BY_ZERO")); - exceptionNames.insert(std::make_pair(0xC000008F, "EXCEPTION_FLT_INEXACT_RESULT")); - exceptionNames.insert(std::make_pair(0xC0000090, "EXCEPTION_FLT_INVALID_OPERATION")); - exceptionNames.insert(std::make_pair(0xC0000091, "EXCEPTION_FLT_OVERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000092, "EXCEPTION_FLT_STACK_CHECK")); - exceptionNames.insert(std::make_pair(0xC0000093, "EXCEPTION_FLT_UNDERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000094, "EXCEPTION_INT_DIVIDE_BY_ZERO")); - exceptionNames.insert(std::make_pair(0xC0000095, "EXCEPTION_INT_OVERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000096, "EXCEPTION_PRIV_INSTRUCTION")); - exceptionNames.insert(std::make_pair(0xC00000FD, "EXCEPTION_STACK_OVERFLOW")); - exceptionNames.insert(std::make_pair(0xC0000135, "STATUS_DLL_NOT_FOUND")); - exceptionNames.insert(std::make_pair(0xC0000138, "STATUS_ORDINAL_NOT_FOUND")); - exceptionNames.insert(std::make_pair(0xC0000139, "STATUS_ENTRYPOINT_NOT_FOUND")); - exceptionNames.insert(std::make_pair(0xC000013A, "STATUS_CONTROL_C_EXIT")); - exceptionNames.insert(std::make_pair(0xC0000142, "STATUS_DLL_INIT_FAILED")); - exceptionNames.insert(std::make_pair(0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT")); - exceptionNames.insert(std::make_pair(0xC0000194, "EXCEPTION_POSSIBLE_DEADLOCK")); - exceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); - exceptionNames.insert(std::make_pair(0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS")); - exceptionNames.insert(std::make_pair(0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS")); - exceptionNames.insert(std::make_pair(0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR")); - exceptionNames.insert(std::make_pair(0xC00002C9, "STATUS_REG_NAT_CONSUMPTION")); - exceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN")); - exceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER")); - exceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE")); - exceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); - exceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); + ExceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); + ExceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); + ExceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); + ExceptionNames.insert(std::make_pair(0x4000001D, "STATUS_WX86_CONTINUE")); + ExceptionNames.insert(std::make_pair(0x4000001E, "STATUS_WX86_SINGLE_STEP")); + ExceptionNames.insert(std::make_pair(0x4000001F, "STATUS_WX86_BREAKPOINT")); + ExceptionNames.insert(std::make_pair(0x40000020, "STATUS_WX86_EXCEPTION_CONTINUE")); + ExceptionNames.insert(std::make_pair(0x40000021, "STATUS_WX86_EXCEPTION_LASTCHANCE")); + ExceptionNames.insert(std::make_pair(0x40000022, "STATUS_WX86_EXCEPTION_CHAIN")); + ExceptionNames.insert(std::make_pair(0x40000028, "STATUS_WX86_CREATEWX86TIB")); + ExceptionNames.insert(std::make_pair(0x40010003, "DBG_TERMINATE_THREAD")); + ExceptionNames.insert(std::make_pair(0x40010004, "DBG_TERMINATE_PROCESS")); + ExceptionNames.insert(std::make_pair(0x40010005, "DBG_CONTROL_C")); + ExceptionNames.insert(std::make_pair(0x40010006, "DBG_PRINTEXCEPTION_C")); + ExceptionNames.insert(std::make_pair(0x40010007, "DBG_RIPEXCEPTION")); + ExceptionNames.insert(std::make_pair(0x40010008, "DBG_CONTROL_BREAK")); + ExceptionNames.insert(std::make_pair(0x40010009, "DBG_COMMAND_EXCEPTION")); + ExceptionNames.insert(std::make_pair(0x406D1388, "MS_VC_EXCEPTION")); + ExceptionNames.insert(std::make_pair(0x80000001, "EXCEPTION_GUARD_PAGE")); + ExceptionNames.insert(std::make_pair(0x80000002, "EXCEPTION_DATATYPE_MISALIGNMENT")); + ExceptionNames.insert(std::make_pair(0x80000003, "EXCEPTION_BREAKPOINT")); + ExceptionNames.insert(std::make_pair(0x80000004, "EXCEPTION_SINGLE_STEP")); + ExceptionNames.insert(std::make_pair(0x80000026, "STATUS_LONGJUMP")); + ExceptionNames.insert(std::make_pair(0x80000029, "STATUS_UNWIND_CONSOLIDATE")); + ExceptionNames.insert(std::make_pair(0x80010001, "DBG_EXCEPTION_NOT_HANDLED")); + ExceptionNames.insert(std::make_pair(0xC0000005, "EXCEPTION_ACCESS_VIOLATION")); + ExceptionNames.insert(std::make_pair(0xC0000006, "EXCEPTION_IN_PAGE_ERROR")); + ExceptionNames.insert(std::make_pair(0xC0000008, "EXCEPTION_INVALID_HANDLE")); + ExceptionNames.insert(std::make_pair(0xC000000D, "STATUS_INVALID_PARAMETER")); + ExceptionNames.insert(std::make_pair(0xC0000017, "STATUS_NO_MEMORY")); + ExceptionNames.insert(std::make_pair(0xC000001D, "EXCEPTION_ILLEGAL_INSTRUCTION")); + ExceptionNames.insert(std::make_pair(0xC0000025, "EXCEPTION_NONCONTINUABLE_EXCEPTION")); + ExceptionNames.insert(std::make_pair(0xC0000026, "EXCEPTION_INVALID_DISPOSITION")); + ExceptionNames.insert(std::make_pair(0xC000008C, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED")); + ExceptionNames.insert(std::make_pair(0xC000008D, "EXCEPTION_FLT_DENORMAL_OPERAND")); + ExceptionNames.insert(std::make_pair(0xC000008E, "EXCEPTION_FLT_DIVIDE_BY_ZERO")); + ExceptionNames.insert(std::make_pair(0xC000008F, "EXCEPTION_FLT_INEXACT_RESULT")); + ExceptionNames.insert(std::make_pair(0xC0000090, "EXCEPTION_FLT_INVALID_OPERATION")); + ExceptionNames.insert(std::make_pair(0xC0000091, "EXCEPTION_FLT_OVERFLOW")); + ExceptionNames.insert(std::make_pair(0xC0000092, "EXCEPTION_FLT_STACK_CHECK")); + ExceptionNames.insert(std::make_pair(0xC0000093, "EXCEPTION_FLT_UNDERFLOW")); + ExceptionNames.insert(std::make_pair(0xC0000094, "EXCEPTION_INT_DIVIDE_BY_ZERO")); + ExceptionNames.insert(std::make_pair(0xC0000095, "EXCEPTION_INT_OVERFLOW")); + ExceptionNames.insert(std::make_pair(0xC0000096, "EXCEPTION_PRIV_INSTRUCTION")); + ExceptionNames.insert(std::make_pair(0xC00000FD, "EXCEPTION_STACK_OVERFLOW")); + ExceptionNames.insert(std::make_pair(0xC0000135, "STATUS_DLL_NOT_FOUND")); + ExceptionNames.insert(std::make_pair(0xC0000138, "STATUS_ORDINAL_NOT_FOUND")); + ExceptionNames.insert(std::make_pair(0xC0000139, "STATUS_ENTRYPOINT_NOT_FOUND")); + ExceptionNames.insert(std::make_pair(0xC000013A, "STATUS_CONTROL_C_EXIT")); + ExceptionNames.insert(std::make_pair(0xC0000142, "STATUS_DLL_INIT_FAILED")); + ExceptionNames.insert(std::make_pair(0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT")); + ExceptionNames.insert(std::make_pair(0xC0000194, "EXCEPTION_POSSIBLE_DEADLOCK")); + ExceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); + ExceptionNames.insert(std::make_pair(0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS")); + ExceptionNames.insert(std::make_pair(0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS")); + ExceptionNames.insert(std::make_pair(0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR")); + ExceptionNames.insert(std::make_pair(0xC00002C9, "STATUS_REG_NAT_CONSUMPTION")); + ExceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN")); + ExceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER")); + ExceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE")); + ExceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); + ExceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); } const char* ExceptionCodeToName(unsigned int ExceptionCode) { - if(!exceptionNames.count(ExceptionCode)) + if(!ExceptionNames.count(ExceptionCode)) return nullptr; - return exceptionNames[ExceptionCode]; + return ExceptionNames[ExceptionCode]; } \ No newline at end of file From 36caae2b4fcb800819154218ae895f65cf68512f Mon Sep 17 00:00:00 2001 From: Nukem Date: Thu, 26 Mar 2015 18:58:48 -0400 Subject: [PATCH 070/106] Fix possible memory leak in varfree --- x64_dbg_dbg/variable.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/x64_dbg_dbg/variable.cpp b/x64_dbg_dbg/variable.cpp index 82d9401d..2b84c077 100644 --- a/x64_dbg_dbg/variable.cpp +++ b/x64_dbg_dbg/variable.cpp @@ -68,13 +68,22 @@ void varinit() void varfree() { - EXCLUSIVE_ACQUIRE(LockVariables); + EXCLUSIVE_ACQUIRE(LockVariables); + + // Each variable must be deleted manually; strings especially + // because there are sub-allocations + VAR_VALUE emptyValue; + + for (auto& itr : variables) + varsetvalue(&itr.second, &emptyValue); + + // Now clear all vector elements variables.clear(); } VAR* vargetptr() { - // TODO: Implement this? Or remove it. + // TODO: Implement this? Or remove it return nullptr; } From cea1f32b2d4fe952526585a1afb81721ca6ab4c2 Mon Sep 17 00:00:00 2001 From: Nukem Date: Thu, 26 Mar 2015 19:54:01 -0400 Subject: [PATCH 071/106] More unordered_map conversions --- x64_dbg_dbg/_global.h | 1 + x64_dbg_dbg/bookmark.cpp | 2 +- x64_dbg_dbg/comment.cpp | 6 +++--- x64_dbg_dbg/error.cpp | 1 + x64_dbg_dbg/exception.cpp | 1 + x64_dbg_dbg/label.cpp | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index b752b2b7..2cfc131a 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "..\x64_dbg_bridge\bridgemain.h" #include "jansson\jansson.h" diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 954306d2..77728937 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -4,7 +4,7 @@ #include "debugger.h" #include "memory.h" -typedef std::map BookmarksInfo; +typedef std::unordered_map BookmarksInfo; static BookmarksInfo bookmarks; diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index 4c93087c..e6b948c0 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -4,7 +4,7 @@ #include "debugger.h" #include "memory.h" -typedef std::map CommentsInfo; +typedef std::unordered_map CommentsInfo; static CommentsInfo comments; @@ -23,7 +23,7 @@ bool CommentSet(uint Address, const char* Text, bool Manual) return false; // Delete the comment if no text was supplied - if(!*Text) + if(Text[0] == '\0') { CommentDelete(Address); return true; @@ -42,7 +42,7 @@ bool CommentSet(uint Address, const char* Text, bool Manual) EXCLUSIVE_ACQUIRE(LockComments); - // Only add if the key wasn't present + // Insert if possible, otherwise replace if(!comments.insert(std::make_pair(key, comment)).second) comments[key] = comment; diff --git a/x64_dbg_dbg/error.cpp b/x64_dbg_dbg/error.cpp index 8199ecc7..80d0da73 100644 --- a/x64_dbg_dbg/error.cpp +++ b/x64_dbg_dbg/error.cpp @@ -5,6 +5,7 @@ std::unordered_map ErrorNames; void ErrorCodeInit() { + ErrorNames.clear(); ErrorNames.insert(std::make_pair(0, "ERROR_SUCCESS")); ErrorNames.insert(std::make_pair(1, "ERROR_INVALID_FUNCTION")); ErrorNames.insert(std::make_pair(2, "ERROR_FILE_NOT_FOUND")); diff --git a/x64_dbg_dbg/exception.cpp b/x64_dbg_dbg/exception.cpp index 2429b29e..dda1b38e 100644 --- a/x64_dbg_dbg/exception.cpp +++ b/x64_dbg_dbg/exception.cpp @@ -5,6 +5,7 @@ std::unordered_map ExceptionNames; void ExceptionCodeInit() { + ExceptionNames.clear(); ExceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); ExceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); ExceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); diff --git a/x64_dbg_dbg/label.cpp b/x64_dbg_dbg/label.cpp index e336b4b6..56d7d745 100644 --- a/x64_dbg_dbg/label.cpp +++ b/x64_dbg_dbg/label.cpp @@ -4,7 +4,7 @@ #include "memory.h" #include "debugger.h" -typedef std::map LabelsInfo; +typedef std::unordered_map LabelsInfo; static LabelsInfo labels; From d0936894a99384c6ffc5140ce3f7d82401dc2c94 Mon Sep 17 00:00:00 2001 From: Nukem Date: Thu, 26 Mar 2015 21:57:45 -0400 Subject: [PATCH 072/106] Optimize MemRead/MemWrite (add MemIsCanonicalAddress) --- x64_dbg_dbg/memory.cpp | 117 +++++++++++++++++++++++++++++------------ x64_dbg_dbg/memory.h | 1 + 2 files changed, 85 insertions(+), 33 deletions(-) diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index e5ef2a1e..898c4e61 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -5,6 +5,12 @@ #include "threading.h" #include "module.h" +#define PAGE_SHIFT (12) +#define PAGE_SIZE (4096) +#define PAGE_ALIGN(Va) ((ULONG_PTR)((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1))) +#define BYTES_TO_PAGES(Size) (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) +#define ROUND_TO_PAGES(Size) (((ULONG_PTR)(Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) + MemoryMap memoryPages; bool bListAllPages = false; @@ -146,6 +152,10 @@ uint MemFindBaseAddr(uint addr, uint* Size, bool refresh) bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesRead) { + // Fast fail if address is invalid + if (!MemIsCanonicalAddress((uint)BaseAddress)) + return false; + // Buffer must be supplied and size must be greater than 0 if(!Buffer || Size <= 0) return false; @@ -159,33 +169,45 @@ bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytes // Normal single-call read bool ret = MemoryReadSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesRead); - // Did the normal memory read work? if(ret && *NumberOfBytesRead == Size) return true; - // Read byte-by-byte - // TODO: Replace this with a better method (PAGE_SIZE) - for(uint i = 0; i < Size; i++) - { - unsigned char* curaddr = (unsigned char*)BaseAddress + i; - unsigned char* curbuf = (unsigned char*)Buffer + i; + // Read page-by-page + // If (SIZE > PAGE_SIZE) or (ADDRESS exceeds boundary), multiple reads will be needed + SIZE_T pageCount = BYTES_TO_PAGES(Size); - ret = MemoryReadSafe(fdProcessInfo->hProcess, curaddr, curbuf, 1, nullptr); + // Determine the number of bytes between ADDRESS and the next page + uint offset = 0; + uint readBase = (uint)BaseAddress; + uint readSize = ROUND_TO_PAGES(readBase) - readBase; - if(!ret) - { - *NumberOfBytesRead = i; + // Reset the bytes read count + *NumberOfBytesRead = 0; - SetLastError(ERROR_PARTIAL_COPY); - return false; - } - } + for (SIZE_T i = 0; i < pageCount; i++) + { + SIZE_T bytesRead = 0; - return true; + if (MemoryReadSafe(fdProcessInfo->hProcess, (PVOID)readBase, ((PBYTE)Buffer + offset), readSize, &bytesRead)) + *NumberOfBytesRead += bytesRead; + + offset += readSize; + readBase += readSize; + + Size -= readSize; + readSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; + } + + SetLastError(ERROR_PARTIAL_COPY); + return (*NumberOfBytesRead > 0); } bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) { + // Fast fail if address is invalid + if (!MemIsCanonicalAddress((uint)BaseAddress)) + return false; + // Buffer must be supplied and size must be greater than 0 if(!Buffer || Size <= 0) return false; @@ -202,24 +224,34 @@ bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfByte if(ret and * NumberOfBytesWritten == Size) return true; - // Fallback: Write byte-by-byte - for(SIZE_T i = 0; i < Size; i++) - { - unsigned char* curaddr = (unsigned char*)BaseAddress + i; - unsigned char* curbuf = (unsigned char*)Buffer + i; + // Write page-by-page + // See: MemRead + SIZE_T pageCount = BYTES_TO_PAGES(Size); - ret = MemoryWriteSafe(fdProcessInfo->hProcess, curaddr, curbuf, 1, nullptr); + // Determine the number of bytes between ADDRESS and the next page + uint offset = 0; + uint writeBase = (uint)BaseAddress; + uint writeSize = ROUND_TO_PAGES(writeBase) - writeBase; - if(!ret) - { - *NumberOfBytesWritten = i; + // Reset the bytes read count + *NumberOfBytesWritten = 0; - SetLastError(ERROR_PARTIAL_COPY); - return false; - } - } + for (SIZE_T i = 0; i < pageCount; i++) + { + SIZE_T bytesWritten = 0; - return true; + if (MemoryWriteSafe(fdProcessInfo->hProcess, (PVOID)writeBase, ((PBYTE)Buffer + offset), writeSize, &bytesWritten)) + *NumberOfBytesWritten += bytesWritten; + + offset += writeSize; + writeBase += writeSize; + + Size -= writeSize; + writeSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; + } + + SetLastError(ERROR_PARTIAL_COPY); + return (*NumberOfBytesWritten > 0); } bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) @@ -229,9 +261,9 @@ bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfByte return false; // Allocate the memory - Memory olddata(Size, "mempatch:olddata"); + Memory oldData(Size, "mempatch:oldData"); - if(!MemRead(BaseAddress, olddata, Size, nullptr)) + if(!MemRead(BaseAddress, oldData, Size, nullptr)) { // If no memory can be read, no memory can be written. Fail out // of this function. @@ -239,7 +271,7 @@ bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfByte } for(SIZE_T i = 0; i < Size; i++) - patchset((uint)BaseAddress + i, olddata[i], ((unsigned char*)Buffer)[i]); + patchset((uint)BaseAddress + i, oldData[i], ((unsigned char*)Buffer)[i]); return MemWrite(BaseAddress, Buffer, Size, NumberOfBytesWritten); } @@ -250,6 +282,25 @@ bool MemIsValidReadPtr(uint Address) return MemRead((void*)Address, &a, 1, nullptr); } +bool MemIsCanonicalAddress(uint Address) +{ +#ifndef _WIN64 + // 32-bit mode only supports 4GB max + return true; +#else + // The most-significant 17 bits must be all 1 or all 0 + // NOTE: Compiler optimizes this to a few bit shifts + switch (Address & 0xFFFF800000000000) + { + case 0xFFFF800000000000: + case 0x0000000000000000: + return true; + } + + return false; +#endif // _WIN64 +} + void* MemAllocRemote(uint Address, SIZE_T Size, DWORD Protect) { return VirtualAllocEx(fdProcessInfo->hProcess, (void*)Address, Size, MEM_RESERVE | MEM_COMMIT, Protect); diff --git a/x64_dbg_dbg/memory.h b/x64_dbg_dbg/memory.h index 611f7ca8..4fd833f1 100644 --- a/x64_dbg_dbg/memory.h +++ b/x64_dbg_dbg/memory.h @@ -12,5 +12,6 @@ bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytes bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); bool MemIsValidReadPtr(uint Address); +bool MemIsCanonicalAddress(uint Address); void* MemAllocRemote(uint Address, SIZE_T Size, DWORD Protect); void MemFreeRemote(uint Address); \ No newline at end of file From f1a3e3cfa30ce6d65c9e501aae431a9b839ae550 Mon Sep 17 00:00:00 2001 From: Nukem Date: Thu, 26 Mar 2015 22:11:49 -0400 Subject: [PATCH 073/106] Add operator+ to dynamicmem Also refactor class --- x64_dbg_dbg/dynamicmem.h | 67 +++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/x64_dbg_dbg/dynamicmem.h b/x64_dbg_dbg/dynamicmem.h index 1e251e44..83156935 100644 --- a/x64_dbg_dbg/dynamicmem.h +++ b/x64_dbg_dbg/dynamicmem.h @@ -1,64 +1,69 @@ -#ifndef _DYNAMICMEM_H -#define _DYNAMICMEM_H +#pragma once template class Memory { public: - Memory(const char* reason = "Memory:???") + Memory(const char* Reason = "Memory:???") { - mPtr = 0; - mSize = 0; - mReason = reason; + m_Ptr = nullptr; + m_Size = 0; + m_Reason = Reason; } - Memory(size_t size, const char* reason = "Memory:???") + Memory(size_t Size, const char* Reason = "Memory:???") { - mPtr = reinterpret_cast(emalloc(size)); - mSize = size; - mReason = reason; - memset(mPtr, 0, size); + m_Ptr = reinterpret_cast(emalloc(Size)); + m_Size = Size; + m_Reason = Reason; + + memset(m_Ptr, 0, Size); } ~Memory() { - efree(mPtr); + if (m_Ptr) + efree(m_Ptr); } - T realloc(size_t size, const char* reason = "Memory:???") + T realloc(size_t Size, const char* Reason = "Memory:???") { - mPtr = reinterpret_cast(erealloc(mPtr, size)); - mSize = size; - mReason = reason; - memset(mPtr, 0, size); - return mPtr; + m_Ptr = reinterpret_cast(erealloc(m_Ptr, Size)); + m_Size = Size; + m_Reason = Reason; + + return (T)memset(m_Ptr, 0, m_Size); } + size_t size() + { + return m_Size; + } + template operator U() { - return (U)mPtr; + return (U)m_Ptr; } operator T() { - return mPtr; + return m_Ptr; } T operator()() { - return mPtr; + return m_Ptr; } - size_t size() - { - return mSize; - } + template + T operator+(const U& Other) + { + return m_Ptr + Other; + } private: - T mPtr; - size_t mSize; - const char* mReason; -}; - -#endif //_DYNAMICMEM_H \ No newline at end of file + T m_Ptr; + size_t m_Size; + const char* m_Reason; +}; \ No newline at end of file From 12fb5445bafdee1c295f857b07249934466695e0 Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 18:42:32 -0400 Subject: [PATCH 074/106] Fix formatting in memory.cpp --- x64_dbg_dbg/memory.cpp | 101 ++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 898c4e61..77c59c7c 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -156,46 +156,49 @@ bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytes if (!MemIsCanonicalAddress((uint)BaseAddress)) return false; - // Buffer must be supplied and size must be greater than 0 - if(!Buffer || Size <= 0) - return false; + // Buffer must be supplied and size must be greater than 0 + if (!Buffer || Size <= 0) + return false; - // If the 'bytes read' parameter is null, use a temp - SIZE_T bytesReadTemp = 0; + // If the 'bytes read' parameter is null, use a temp + SIZE_T bytesReadTemp = 0; - if(!NumberOfBytesRead) - NumberOfBytesRead = &bytesReadTemp; + if (!NumberOfBytesRead) + NumberOfBytesRead = &bytesReadTemp; - // Normal single-call read - bool ret = MemoryReadSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesRead); + // Normal single-call read + bool ret = MemoryReadSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesRead); - if(ret && *NumberOfBytesRead == Size) - return true; + if (ret && *NumberOfBytesRead == Size) + return true; - // Read page-by-page + // Read page-by-page (Skip if only 1 page exists) // If (SIZE > PAGE_SIZE) or (ADDRESS exceeds boundary), multiple reads will be needed SIZE_T pageCount = BYTES_TO_PAGES(Size); - // Determine the number of bytes between ADDRESS and the next page - uint offset = 0; - uint readBase = (uint)BaseAddress; - uint readSize = ROUND_TO_PAGES(readBase) - readBase; - - // Reset the bytes read count - *NumberOfBytesRead = 0; - - for (SIZE_T i = 0; i < pageCount; i++) + if (pageCount > 1) { - SIZE_T bytesRead = 0; + // Determine the number of bytes between ADDRESS and the next page + uint offset = 0; + uint readBase = (uint)BaseAddress; + uint readSize = ROUND_TO_PAGES(readBase) - readBase; - if (MemoryReadSafe(fdProcessInfo->hProcess, (PVOID)readBase, ((PBYTE)Buffer + offset), readSize, &bytesRead)) - *NumberOfBytesRead += bytesRead; + // Reset the bytes read count + *NumberOfBytesRead = 0; - offset += readSize; - readBase += readSize; + for (SIZE_T i = 0; i < pageCount; i++) + { + SIZE_T bytesRead = 0; - Size -= readSize; - readSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; + if (MemoryReadSafe(fdProcessInfo->hProcess, (PVOID)readBase, ((PBYTE)Buffer + offset), readSize, &bytesRead)) + *NumberOfBytesRead += bytesRead; + + offset += readSize; + readBase += readSize; + + Size -= readSize; + readSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; + } } SetLastError(ERROR_PARTIAL_COPY); @@ -224,30 +227,33 @@ bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfByte if(ret and * NumberOfBytesWritten == Size) return true; - // Write page-by-page + // Write page-by-page (Skip if only 1 page exists) // See: MemRead SIZE_T pageCount = BYTES_TO_PAGES(Size); - // Determine the number of bytes between ADDRESS and the next page - uint offset = 0; - uint writeBase = (uint)BaseAddress; - uint writeSize = ROUND_TO_PAGES(writeBase) - writeBase; - - // Reset the bytes read count - *NumberOfBytesWritten = 0; - - for (SIZE_T i = 0; i < pageCount; i++) + if (pageCount > 1) { - SIZE_T bytesWritten = 0; + // Determine the number of bytes between ADDRESS and the next page + uint offset = 0; + uint writeBase = (uint)BaseAddress; + uint writeSize = ROUND_TO_PAGES(writeBase) - writeBase; - if (MemoryWriteSafe(fdProcessInfo->hProcess, (PVOID)writeBase, ((PBYTE)Buffer + offset), writeSize, &bytesWritten)) - *NumberOfBytesWritten += bytesWritten; + // Reset the bytes read count + *NumberOfBytesWritten = 0; - offset += writeSize; - writeBase += writeSize; + for (SIZE_T i = 0; i < pageCount; i++) + { + SIZE_T bytesWritten = 0; - Size -= writeSize; - writeSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; + if (MemoryWriteSafe(fdProcessInfo->hProcess, (PVOID)writeBase, ((PBYTE)Buffer + offset), writeSize, &bytesWritten)) + *NumberOfBytesWritten += bytesWritten; + + offset += writeSize; + writeBase += writeSize; + + Size -= writeSize; + writeSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; + } } SetLastError(ERROR_PARTIAL_COPY); @@ -285,10 +291,11 @@ bool MemIsValidReadPtr(uint Address) bool MemIsCanonicalAddress(uint Address) { #ifndef _WIN64 - // 32-bit mode only supports 4GB max + // 32-bit mode only supports 4GB max, so limits are + // not an issue return true; #else - // The most-significant 17 bits must be all 1 or all 0 + // The most-significant 16 bits must be all 1 or all 0 // NOTE: Compiler optimizes this to a few bit shifts switch (Address & 0xFFFF800000000000) { From efaee6ffddb9fcc3a8a2640c80820388e2bc0feb Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 18:46:41 -0400 Subject: [PATCH 075/106] Add debug profile to visual studio project --- x64_dbg.sln | 23 +++++- x64_dbg_bridge/x64_dbg_bridge.vcxproj | 65 +++++++++++++++ x64_dbg_bridge/x64_dbg_bridge.vcxproj.user | 10 +++ x64_dbg_dbg/x64_dbg_dbg.vcxproj | 92 ++++++++++++++++++++++ x64_dbg_dbg/x64_dbg_dbg.vcxproj.user | 10 +++ x64_dbg_exe/x64_dbg_exe.vcxproj | 74 +++++++++++++++++ x64_dbg_launcher/x64_dbg_launcher.vcxproj | 39 +++++++++ 7 files changed, 311 insertions(+), 2 deletions(-) diff --git a/x64_dbg.sln b/x64_dbg.sln index a7e946e6..9f3fc16c 100644 --- a/x64_dbg.sln +++ b/x64_dbg.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64_dbg_bridge", "x64_dbg_bridge\x64_dbg_bridge.vcxproj", "{944D9923-CB1A-6F6C-BCBC-9E00A71954C1}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64_dbg_exe", "x64_dbg_exe\x64_dbg_exe.vcxproj", "{3A22175E-6B72-FDCC-1603-C4A2163C7900}" @@ -17,22 +19,39 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64_dbg_launcher", "x64_dbg EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|Win32.ActiveCfg = Debug|Win32 + {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|Win32.Build.0 = Debug|Win32 + {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|x64.ActiveCfg = Debug|x64 + {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|x64.Build.0 = Debug|x64 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|Win32.ActiveCfg = Release|Win32 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|Win32.Build.0 = Release|Win32 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|x64.ActiveCfg = Release|x64 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|x64.Build.0 = Release|x64 + {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|Win32.ActiveCfg = Debug|Win32 + {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|Win32.Build.0 = Debug|Win32 + {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|x64.ActiveCfg = Debug|x64 + {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|x64.Build.0 = Debug|x64 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|Win32.ActiveCfg = Release|Win32 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|Win32.Build.0 = Release|Win32 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|x64.ActiveCfg = Release|x64 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|x64.Build.0 = Release|x64 + {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|Win32.ActiveCfg = Debug|Win32 + {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|Win32.Build.0 = Debug|Win32 + {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|x64.ActiveCfg = Debug|x64 + {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|x64.Build.0 = Debug|x64 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|Win32.ActiveCfg = Release|Win32 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|Win32.Build.0 = Release|Win32 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|x64.ActiveCfg = Release|x64 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|x64.Build.0 = Release|x64 + {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Debug|Win32.Build.0 = Debug|Win32 + {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Debug|x64.ActiveCfg = Debug|Win32 {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|Win32.ActiveCfg = Release|Win32 {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|Win32.Build.0 = Release|Win32 {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|x64.ActiveCfg = Release|Win32 diff --git a/x64_dbg_bridge/x64_dbg_bridge.vcxproj b/x64_dbg_bridge/x64_dbg_bridge.vcxproj index 06f3aef2..da4f609d 100644 --- a/x64_dbg_bridge/x64_dbg_bridge.vcxproj +++ b/x64_dbg_bridge/x64_dbg_bridge.vcxproj @@ -1,6 +1,14 @@  + + Debug + Win32 + + + Debug + x64 + Release Win32 @@ -29,20 +37,36 @@ false v120 + + DynamicLibrary + false + v120 + DynamicLibrary false v120 + + DynamicLibrary + false + v120 + + + + + + + false @@ -50,11 +74,22 @@ $(Platform)\$(Configuration)\ x32_bridge + + false + $(SolutionDir)bin\x32\ + $(Platform)\$(Configuration)\ + x32_bridge + false $(SolutionDir)bin\x64\ x64_bridge + + false + $(SolutionDir)bin\x64\ + x64_bridge + BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -71,6 +106,22 @@ true + + + BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + MaxSpeed + + + MachineX86 + true + Windows + true + true + + BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -85,6 +136,20 @@ true + + + BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + true + Windows + true + true + + diff --git a/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user b/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user index b72054fc..bdb12b67 100644 --- a/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user +++ b/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user @@ -5,9 +5,19 @@ WindowsLocalDebugger $(OutDir) + + $(OutDir)\x32_dbg.exe + WindowsLocalDebugger + $(OutDir) + $(OutDir)\x64_dbg.exe WindowsLocalDebugger $(OutDir) + + $(OutDir)\x64_dbg.exe + WindowsLocalDebugger + $(OutDir) + \ No newline at end of file diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 06e5c3b5..342bd063 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -1,6 +1,14 @@  + + Debug + Win32 + + + Debug + x64 + Release Win32 @@ -124,20 +132,36 @@ false v120 + + DynamicLibrary + false + v120 + DynamicLibrary false v120 + + DynamicLibrary + false + v120 + + + + + + + false @@ -145,11 +169,22 @@ $(Platform)\$(Configuration)\ x32_dbg + + false + $(SolutionDir)bin\x32\ + $(Platform)\$(Configuration)\ + x32_dbg + false $(SolutionDir)bin\x64\ x64_dbg + + false + $(SolutionDir)bin\x64\ + x64_dbg + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -157,6 +192,35 @@ Level3 ProgramDatabase true + MultiFile + true + true + AVXI + None + None + true + Speed + + + MachineX86 + true + Windows + true + true + lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) + + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + true + NoIPO + false + true + Disabled MachineX86 @@ -174,6 +238,34 @@ Level3 ProgramDatabase true + MultiFile + true + true + AVXI + None + None + true + Speed + + + true + Windows + true + true + lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) + + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + true + NoIPO + false + true + Disabled true diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user index b72054fc..bdb12b67 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user @@ -5,9 +5,19 @@ WindowsLocalDebugger $(OutDir) + + $(OutDir)\x32_dbg.exe + WindowsLocalDebugger + $(OutDir) + $(OutDir)\x64_dbg.exe WindowsLocalDebugger $(OutDir) + + $(OutDir)\x64_dbg.exe + WindowsLocalDebugger + $(OutDir) + \ No newline at end of file diff --git a/x64_dbg_exe/x64_dbg_exe.vcxproj b/x64_dbg_exe/x64_dbg_exe.vcxproj index f6e1706e..dbe35e75 100644 --- a/x64_dbg_exe/x64_dbg_exe.vcxproj +++ b/x64_dbg_exe/x64_dbg_exe.vcxproj @@ -1,6 +1,14 @@  + + Debug + Win32 + + + Debug + x64 + Release Win32 @@ -33,20 +41,36 @@ false v120 + + Application + false + v120 + Application false v120 + + Application + false + v120 + + + + + + + false @@ -55,12 +79,25 @@ x32_dbg false + + false + $(SolutionDir)bin\x32\ + $(Platform)\$(Configuration)\ + x32_dbg + false + false $(SolutionDir)bin\x64\ x64_dbg false + + false + $(SolutionDir)bin\x64\ + x64_dbg + false + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -80,6 +117,25 @@ + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + MachineX86 + true + Windows + true + true + $(SolutionDir)bin\x32\x32_bridge.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(TargetDir)$(TargetName)_exe.pdb + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -98,6 +154,24 @@ + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + true + Windows + true + true + $(SolutionDir)bin\x64\x64_bridge.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(TargetDir)$(TargetName)_exe.pdb + + + + diff --git a/x64_dbg_launcher/x64_dbg_launcher.vcxproj b/x64_dbg_launcher/x64_dbg_launcher.vcxproj index d64cf9bd..b239d668 100644 --- a/x64_dbg_launcher/x64_dbg_launcher.vcxproj +++ b/x64_dbg_launcher/x64_dbg_launcher.vcxproj @@ -1,6 +1,10 @@  + + Debug + Win32 + Release Win32 @@ -23,6 +27,12 @@ Application false + v120 + + + Application + false + v120 @@ -30,6 +40,9 @@ + + + false @@ -38,6 +51,13 @@ x96_dbg false + + false + $(SolutionDir)bin\ + $(Platform)\$(Configuration)\ + x96_dbg + false + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -57,6 +77,25 @@ + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + MachineX86 + true + Windows + true + true + shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(TargetDir)$(TargetName).pdb + + + + From 16ae9a82fb5042369399ee9b7645b25763d7d1dd Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 19:31:43 -0400 Subject: [PATCH 076/106] Possible sign extension bug --- x64_dbg_dbg/bookmark.cpp | 3 ++- x64_dbg_dbg/breakpoint.cpp | 2 +- x64_dbg_dbg/comment.cpp | 3 ++- x64_dbg_dbg/console.cpp | 1 - x64_dbg_dbg/function.cpp | 3 ++- x64_dbg_dbg/thread.cpp | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 77728937..b60c209c 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -59,7 +59,8 @@ void BookmarkDelRange(uint Start, uint End) return; // Are all bookmarks going to be deleted? - if(Start == 0x00000000 && End == 0xFFFFFFFF) + // 0x00000000 - 0xFFFFFFFF + if(Start == 0 && End == ~0) { EXCLUSIVE_ACQUIRE(LockBookmarks); bookmarks.clear(); diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index efa4ae2e..d6230715 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -275,7 +275,7 @@ void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp) // bridge breakpoint // // TOOD: ASSERT(?) These should never be null - if(!Bp or !BridgeBp) + if(!Bp || !BridgeBp) return; memset(BridgeBp, 0, sizeof(BRIDGEBP)); diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index e6b948c0..68795cf2 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -85,7 +85,8 @@ void CommentDelRange(uint Start, uint End) return; // Are all comments going to be deleted? - if(Start == 0x00000000 && End == 0xFFFFFFFF) + // 0x00000000 - 0xFFFFFFFF + if(Start == 0 && End == ~0) { EXCLUSIVE_ACQUIRE(LockComments); comments.clear(); diff --git a/x64_dbg_dbg/console.cpp b/x64_dbg_dbg/console.cpp index 30a31e92..cdad80fe 100644 --- a/x64_dbg_dbg/console.cpp +++ b/x64_dbg_dbg/console.cpp @@ -1,5 +1,4 @@ #include "console.h" -#include "threading.h" void dputs(const char* Text) { diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp index f9d02d19..48059ad1 100644 --- a/x64_dbg_dbg/function.cpp +++ b/x64_dbg_dbg/function.cpp @@ -102,7 +102,8 @@ void FunctionDelRange(uint Start, uint End) return; // Should all functions be deleted? - if(Start == 0x00000000 && End == 0xFFFFFFFF) + // 0x00000000 - 0xFFFFFFFF + if(Start == 0 && End == ~0) { EXCLUSIVE_ACQUIRE(LockFunctions); functions.clear(); diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index 064263ea..d5cf7188 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -212,6 +212,7 @@ DWORD ThreadGetId(HANDLE hThread) } // Wasn't found, check with Windows + // NOTE: Requires VISTA+ DWORD id = GetThreadId(hThread); // Returns 0 on error; From c85f87fea2f69684d52da393f50b005130339bf3 Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 20:25:06 -0400 Subject: [PATCH 077/106] Remove redundant hashes in bookmarks --- x64_dbg_dbg/bookmark.cpp | 31 +++++++++++++++++-------------- x64_dbg_dbg/breakpoint.cpp | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index b60c209c..1669d3df 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -20,13 +20,13 @@ bool BookmarkSet(uint Address, bool Manual) BOOKMARKSINFO bookmark; ModNameFromAddr(Address, bookmark.mod, true); - bookmark.addr = Address - ModBaseFromAddr(Address); + bookmark.addr = Address; bookmark.manual = Manual; // Exclusive lock to insert new data EXCLUSIVE_ACQUIRE(LockBookmarks); - if(!bookmarks.insert(std::make_pair(ModHashFromAddr(Address), bookmark)).second) + if(!bookmarks.insert(std::make_pair(Address, bookmark)).second) return BookmarkDelete(Address); return true; @@ -39,7 +39,7 @@ bool BookmarkGet(uint Address) return false; SHARED_ACQUIRE(LockBookmarks); - return (bookmarks.count(ModHashFromAddr(Address)) > 0); + return (bookmarks.count(Address) > 0); } bool BookmarkDelete(uint Address) @@ -49,7 +49,7 @@ bool BookmarkDelete(uint Address) return false; EXCLUSIVE_ACQUIRE(LockBookmarks); - return (bookmarks.erase(ModHashFromAddr(Address)) > 0); + return (bookmarks.erase(Address) > 0); } void BookmarkDelRange(uint Start, uint End) @@ -73,10 +73,6 @@ void BookmarkDelRange(uint Start, uint End) if(moduleBase != ModBaseFromAddr(End)) return; - // Virtual -> relative offset - Start -= moduleBase; - End -= moduleBase; - EXCLUSIVE_ACQUIRE(LockBookmarks); for(auto itr = bookmarks.begin(); itr != bookmarks.end();) { @@ -108,8 +104,12 @@ void BookmarkCacheSave(JSON Root) { JSON currentBookmark = json_object(); + // The address must be adjusted to use an offset + // OFFSET = ADDRESS - MOD_BASE + uint virtualOffset = itr.second.addr - ModBaseFromAddr(itr.second.addr); + json_object_set_new(currentBookmark, "module", json_string(itr.second.mod)); - json_object_set_new(currentBookmark, "address", json_hex(itr.second.addr)); + json_object_set_new(currentBookmark, "address", json_hex(virtualOffset)); if(itr.second.manual) json_array_append_new(jsonBookmarks, currentBookmark); @@ -152,8 +152,11 @@ void BookmarkCacheLoad(JSON Root) bookmarkInfo.addr = (uint)json_hex_value(json_object_get(value, "address")); bookmarkInfo.manual = Manual; - const uint key = ModHashFromName(bookmarkInfo.mod) + bookmarkInfo.addr; - bookmarks.insert(std::make_pair(key, bookmarkInfo)); + // The offset must be adjusted to use virtual addressing + // ADDRESS = OFFSET + MOD_BASE + bookmarkInfo.addr += ModBaseFromName(bookmarkInfo.mod); + + bookmarks.insert(std::make_pair(bookmarkInfo.addr, bookmarkInfo)); } }; @@ -189,11 +192,11 @@ bool BookmarkEnum(BOOKMARKSINFO* List, size_t* Size) return true; } - // Copy struct and adjust the relative offset to a virtual address + // Copy struct over for(auto & itr : bookmarks) { - *List = itr.second; - List->addr += ModBaseFromName(List->mod); + *List = itr.second; + List++; } return true; diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index d6230715..c5447e86 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -48,7 +48,7 @@ int BpGetList(std::vector* List) } } - return breakpoints.size(); + return (int)breakpoints.size(); } bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name) From 4e9a588c362689dd0fe881802f9e9aee6cc7eed6 Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 20:30:22 -0400 Subject: [PATCH 078/106] Redundant hashes in comment.cpp --- x64_dbg_dbg/comment.cpp | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index 68795cf2..704cb83e 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -35,16 +35,13 @@ bool CommentSet(uint Address, const char* Text, bool Manual) ModNameFromAddr(Address, comment.mod, true); comment.manual = Manual; - comment.addr = Address - ModBaseFromAddr(Address); + comment.addr = Address; - // Insert into list - const uint key = ModHashFromAddr(Address); + EXCLUSIVE_ACQUIRE(LockComments); - EXCLUSIVE_ACQUIRE(LockComments); - - // Insert if possible, otherwise replace - if(!comments.insert(std::make_pair(key, comment)).second) - comments[key] = comment; + // Insert if possible, otherwise replace + if (!comments.insert(std::make_pair(Address, comment)).second) + comments[Address] = comment; return true; } @@ -58,7 +55,7 @@ bool CommentGet(uint Address, char* Text) SHARED_ACQUIRE(LockComments); // Get an existing comment and copy the string buffer - auto found = comments.find(ModHashFromAddr(Address)); + auto found = comments.find(Address); // Was it found? if(found == comments.end()) @@ -75,7 +72,7 @@ bool CommentDelete(uint Address) return false; EXCLUSIVE_ACQUIRE(LockComments); - return (comments.erase(ModHashFromAddr(Address)) > 0); + return (comments.erase(Address) > 0); } void CommentDelRange(uint Start, uint End) @@ -99,10 +96,6 @@ void CommentDelRange(uint Start, uint End) if(moduleBase != ModBaseFromAddr(End)) return; - // Virtual -> relative offset - Start -= moduleBase; - End -= moduleBase; - EXCLUSIVE_ACQUIRE(LockComments); for(auto itr = comments.begin(); itr != comments.end();) { @@ -126,16 +119,19 @@ void CommentCacheSave(JSON Root) { EXCLUSIVE_ACQUIRE(LockComments); - const JSON jsonComments = json_array(); - const JSON jsonAutoComments = json_array(); + const JSON jsonComments = json_array(); + const JSON jsonAutoComments = json_array(); // Build the JSON array for(auto & itr : comments) { JSON currentComment = json_object(); + // OFFSET = ADDRESS - MOD_BASE + uint virtualOffset = itr.second.addr - ModBaseFromAddr(itr.second.addr); + json_object_set_new(currentComment, "module", json_string(itr.second.mod)); - json_object_set_new(currentComment, "address", json_hex(itr.second.addr)); + json_object_set_new(currentComment, "address", json_hex(virtualOffset)); json_object_set_new(currentComment, "text", json_string(itr.second.text)); if(itr.second.manual) @@ -192,8 +188,10 @@ void CommentCacheLoad(JSON Root) continue; } - const uint key = ModHashFromName(commentInfo.mod) + commentInfo.addr; - comments.insert(std::make_pair(key, commentInfo)); + // ADDRESS = OFFSET + MOD_BASE + commentInfo.addr += ModBaseFromName(commentInfo.mod); + + comments.insert(std::make_pair(commentInfo.addr, commentInfo)); } }; @@ -236,9 +234,7 @@ bool CommentEnum(COMMENTSINFO* List, size_t* Size) // Populate the returned array for(auto & itr : comments) { - *List = itr.second; - List->addr += ModBaseFromName(List->mod); - + *List = itr.second; List++; } From 14ac3efd04e968cc8f9c04cf606e146fe271ef07 Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 21:35:45 -0400 Subject: [PATCH 079/106] GUI: Fix sign extension bug (visual only) --- x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h | 1 + x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/CPUStack.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp | 4 ++-- x64_dbg_gui/Project/Src/Gui/HexEditDialog.h | 4 ++-- x64_dbg_gui/Project/Src/Gui/ThreadView.cpp | 2 +- x64_dbg_gui/Project/x64_dbg.pro | 3 ++- 9 files changed, 12 insertions(+), 10 deletions(-) diff --git a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h index e72958eb..cfdbcb3d 100644 --- a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h +++ b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h @@ -8,6 +8,7 @@ #include #include #include "NewTypes.h" +#include "StringUtil.h" //Hacky class that fixes a really annoying cursor problem class AbstractTableScrollBar : public QScrollBar diff --git a/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp b/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp index c24b8dca..60d05ff7 100644 --- a/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp @@ -1480,7 +1480,7 @@ QString Disassembly::getAddrText(int_t cur_addr, char label[MAX_LABEL_SIZE]) #endif //_WIN64 } } - addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + addrText += AddressToString(cur_addr); char label_[MAX_LABEL_SIZE] = ""; if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label_)) //has label { diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index 7f05567f..c4a2d714 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -404,7 +404,7 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i #endif //_WIN64 } } - addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + addrText += AddressToString(cur_addr); if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label { char module[MAX_MODULE_SIZE] = ""; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp b/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp index 7d033177..6cde593b 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp @@ -184,7 +184,7 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA) char section[MAX_SECTION_SIZE] = ""; if(DbgFunctions()->SectionFromAddr(parVA, section)) info += "\"" + QString(section) + "\":"; - info += QString("%1").arg(parVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + info += AddressToString(parVA); char label[MAX_LABEL_SIZE] = ""; if(DbgGetLabelAt(parVA, SEG_DEFAULT, label)) info += " <" + QString(label) + ">"; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp index 3041bd4d..d7d795ac 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp @@ -224,7 +224,7 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset, #endif //_WIN64 } } - addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + addrText += AddressToString(cur_addr); if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label { char module[MAX_MODULE_SIZE] = ""; diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp index 9abd93d1..44e27f6d 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp @@ -123,12 +123,12 @@ void HexEditDialog::dataChangedSlot() ui->lineEditUnicode->setText(unicode); } -void HexEditDialog::on_lineEditAscii_textEdited(const QString &arg1) +void HexEditDialog::on_lineEditAscii_textEdited(const QString & arg1) { on_btnAscii2Hex_clicked(); } -void HexEditDialog::on_lineEditUnicode_textEdited(const QString &arg1) +void HexEditDialog::on_lineEditUnicode_textEdited(const QString & arg1) { on_btnUnicode2Hex_clicked(); } diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h index 13dd455f..8616abf3 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h @@ -28,8 +28,8 @@ private slots: void on_btnUnicode2Hex_clicked(); void on_chkKeepSize_toggled(bool checked); void dataChangedSlot(); - void on_lineEditAscii_textEdited(const QString &arg1); - void on_lineEditUnicode_textEdited(const QString &arg1); + void on_lineEditAscii_textEdited(const QString & arg1); + void on_lineEditUnicode_textEdited(const QString & arg1); private: Ui::HexEditDialog* ui; diff --git a/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp b/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp index 4266b420..236b1c10 100644 --- a/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp @@ -223,7 +223,7 @@ void ThreadView::updateThreadList() setCellContent(i, 0, "Main"); else setCellContent(i, 0, QString("%1").arg(threadList.list[i].BasicInfo.ThreadNumber, 0, 10)); - setCellContent(i, 1, QString("%1").arg(threadList.list[i].BasicInfo.dwThreadId, 0, 16).toUpper()); + setCellContent(i, 1, QString("%1").arg(threadList.list[i].BasicInfo.ThreadId, 0, 16).toUpper()); setCellContent(i, 2, QString("%1").arg(threadList.list[i].BasicInfo.ThreadStartAddress, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); setCellContent(i, 3, QString("%1").arg(threadList.list[i].BasicInfo.ThreadLocalBase, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); setCellContent(i, 4, QString("%1").arg(threadList.list[i].ThreadCip, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); diff --git a/x64_dbg_gui/Project/x64_dbg.pro b/x64_dbg_gui/Project/x64_dbg.pro index 1af66de0..314862a3 100644 --- a/x64_dbg_gui/Project/x64_dbg.pro +++ b/x64_dbg_gui/Project/x64_dbg.pro @@ -151,7 +151,8 @@ HEADERS += \ Src/Gui/PageMemoryRights.h \ Src/Gui/SelectFields.h \ Src/Gui/ReferenceManager.h \ - Src/Bridge/BridgeResult.h + Src/Bridge/BridgeResult.h \ + Src/Utils/StringUtil.h INCLUDEPATH += \ From b090e31085b9c50fbcc7ca42a7e15962a7bce7ac Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 21:36:56 -0400 Subject: [PATCH 080/106] Missing file --- x64_dbg_gui/Project/Src/Utils/StringUtil.h | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 x64_dbg_gui/Project/Src/Utils/StringUtil.h diff --git a/x64_dbg_gui/Project/Src/Utils/StringUtil.h b/x64_dbg_gui/Project/Src/Utils/StringUtil.h new file mode 100644 index 00000000..2425f90d --- /dev/null +++ b/x64_dbg_gui/Project/Src/Utils/StringUtil.h @@ -0,0 +1,27 @@ +#ifndef STRINGUTIL_H +#define STRINGUTIL_H + +#include +#include "NewTypes.h" + +static QString AddressToString(int_t Address) +{ + // + // This function exists because of how QT handles + // variables in strings. + // + // QString::arg(): + // ((int32)0xFFFF0000) == 0xFFFFFFFFFFFF0000 with sign extension + // + char temp[32]; + +#ifdef _WIN64 + sprintf_s(temp, "%16llX", Address); +#else + sprintf_s(temp, "%08X", Address); +#endif // _WIN64 + + return QString(temp); +} + +#endif // STRINGUTIL_H From 20fa55cc2b61d728e26d25f46c827db615b38ffe Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sat, 28 Mar 2015 03:28:06 +0100 Subject: [PATCH 081/106] DBG: safe dbghelp functions --- x64_dbg_dbg/_exports.cpp | 10 +- x64_dbg_dbg/_global.h | 7 +- x64_dbg_dbg/dbghelp_safe.cpp | 158 ++++++++++++++++++++++++ x64_dbg_dbg/dbghelp_safe.h | 105 ++++++++++++++++ x64_dbg_dbg/debugger.cpp | 18 +-- x64_dbg_dbg/debugger_commands.cpp | 14 +-- x64_dbg_dbg/symbolinfo.cpp | 24 ++-- x64_dbg_dbg/threading.h | 1 + x64_dbg_dbg/x64_dbg_dbg.vcxproj | 2 + x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters | 6 + 10 files changed, 306 insertions(+), 39 deletions(-) create mode 100644 x64_dbg_dbg/dbghelp_safe.cpp create mode 100644 x64_dbg_dbg/dbghelp_safe.h diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index e0e89df8..d4aa29db 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -107,10 +107,10 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); pSymbol->MaxNameLen = MAX_LABEL_SIZE; - if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement) + if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement) { pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0'; - if(!bUndecorateSymbolNames or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE)) + if(!bUndecorateSymbolNames or !SafeUnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE)) strcpy_s(addrinfo->label, pSymbol->Name); retval = true; } @@ -123,10 +123,10 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR uint val = 0; if(memread(fdProcessInfo->hProcess, (const void*)basicinfo.memory.value, &val, sizeof(val), 0)) { - if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement) + if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement) { pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0'; - if(!bUndecorateSymbolNames or !UnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE)) + if(!bUndecorateSymbolNames or !SafeUnDecorateSymbolName(pSymbol->Name, addrinfo->label, MAX_LABEL_SIZE, UNDNAME_COMPLETE)) sprintf_s(addrinfo->label, "JMP.&%s", pSymbol->Name); retval = true; } @@ -160,7 +160,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR DWORD dwDisplacement; IMAGEHLP_LINE64 line; line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); - if(SymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) and !dwDisplacement) + if(SafeSymGetLineFromAddr64(fdProcessInfo->hProcess, (DWORD64)addr, &dwDisplacement, &line) and !dwDisplacement) { char filename[deflen] = ""; strcpy_s(filename, line.FileName); diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index c3f6fcfd..60bf68f9 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -22,12 +22,7 @@ #include "DeviceNameResolver\DeviceNameResolver.h" #include "handle.h" #include "stringutils.h" - -#ifdef __GNUC__ -#include "dbghelp\dbghelp.h" -#else -#include -#endif //__GNUC__ +#include "dbghelp_safe.h" #ifndef __GNUC__ #define and && diff --git a/x64_dbg_dbg/dbghelp_safe.cpp b/x64_dbg_dbg/dbghelp_safe.cpp new file mode 100644 index 00000000..46bb5ffa --- /dev/null +++ b/x64_dbg_dbg/dbghelp_safe.cpp @@ -0,0 +1,158 @@ +#include "_global.h" +#include "dbghelp_safe.h" +#include "threading.h" + +DWORD + SafeUnDecorateSymbolName( + __in PCSTR name, + __out_ecount(maxStringLength) PSTR outputString, + __in DWORD maxStringLength, + __in DWORD flags + ) +{ + CriticalSectionLocker locker(LockSym); + return UnDecorateSymbolName(name, outputString, maxStringLength, flags); +} +BOOL + SafeSymUnloadModule64( + __in HANDLE hProcess, + __in DWORD64 BaseOfDll + ) +{ + CriticalSectionLocker locker(LockSym); + return SymUnloadModule64(hProcess, BaseOfDll); +} +BOOL + SafeSymSetSearchPath( + __in HANDLE hProcess, + __in_opt PCSTR SearchPath + ) +{ + CriticalSectionLocker locker(LockSym); + return SymSetSearchPath(hProcess, SearchPath); +} +DWORD + SafeSymSetOptions( + __in DWORD SymOptions + ) +{ + CriticalSectionLocker locker(LockSym); + return SymSetOptions(SymOptions); +} +BOOL + SafeSymInitialize( + __in HANDLE hProcess, + __in_opt PCSTR UserSearchPath, + __in BOOL fInvadeProcess + ) +{ + CriticalSectionLocker locker(LockSym); + return SymInitialize(hProcess, UserSearchPath, fInvadeProcess); +} +BOOL + SafeSymRegisterCallback64( + __in HANDLE hProcess, + __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, + __in ULONG64 UserContext + ) +{ + CriticalSectionLocker locker(LockSym); + return SymRegisterCallback64(hProcess, CallbackFunction, UserContext); +} +DWORD64 + SafeSymLoadModuleEx( + __in HANDLE hProcess, + __in_opt HANDLE hFile, + __in_opt PCSTR ImageName, + __in_opt PCSTR ModuleName, + __in DWORD64 BaseOfDll, + __in DWORD DllSize, + __in_opt PMODLOAD_DATA Data, + __in_opt DWORD Flags + ) +{ + CriticalSectionLocker locker(LockSym); + return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags); +} +BOOL + SafeSymGetModuleInfo64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out PIMAGEHLP_MODULE64 ModuleInfo + ) +{ + CriticalSectionLocker locker(LockSym); + return SymGetModuleInfo64(hProcess, qwAddr, ModuleInfo); +} +BOOL + SafeSymGetSearchPath( + __in HANDLE hProcess, + __out_ecount(SearchPathLength) PSTR SearchPath, + __in DWORD SearchPathLength + ) +{ + CriticalSectionLocker locker(LockSym); + return SymGetSearchPath(hProcess, SearchPath, SearchPathLength); +} +BOOL + SafeSymEnumSymbols( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCSTR Mask, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ) +{ + CriticalSectionLocker locker(LockSym); + return SymEnumSymbols(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext); +} +BOOL + SafeSymEnumerateModules( + __in HANDLE hProcess, + __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, + __in_opt PVOID UserContext + ) +{ + CriticalSectionLocker locker(LockSym); + return SymEnumerateModules(hProcess, EnumModulesCallback, UserContext); +} +BOOL + SafeSymGetLineFromAddr64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out PDWORD pdwDisplacement, + __out PIMAGEHLP_LINE64 Line64 + ) +{ + CriticalSectionLocker locker(LockSym); + return SymGetLineFromAddr64(hProcess, qwAddr, pdwDisplacement, Line64); +} +BOOL + SafeSymFromName( + __in HANDLE hProcess, + __in PCSTR Name, + __inout PSYMBOL_INFO Symbol + ) +{ + CriticalSectionLocker locker(LockSym); + return SymFromName(hProcess, Name, Symbol); +} +BOOL + SafeSymFromAddr( + __in HANDLE hProcess, + __in DWORD64 Address, + __out_opt PDWORD64 Displacement, + __inout PSYMBOL_INFO Symbol + ) +{ + CriticalSectionLocker locker(LockSym); + return SymFromAddr(hProcess, Address, Displacement, Symbol); +} +BOOL + SafeSymCleanup( + __in HANDLE hProcess + ) +{ + CriticalSectionLocker locker(LockSym); + return SymCleanup(hProcess); +} \ No newline at end of file diff --git a/x64_dbg_dbg/dbghelp_safe.h b/x64_dbg_dbg/dbghelp_safe.h new file mode 100644 index 00000000..b6364f33 --- /dev/null +++ b/x64_dbg_dbg/dbghelp_safe.h @@ -0,0 +1,105 @@ +#ifndef _DBGHELP_SAFE_H +#define _DBGHELP_SAFE_H + +#ifdef __GNUC__ +#include "dbghelp\dbghelp.h" +#else +#include +#endif //__GNUC__ + +DWORD + SafeUnDecorateSymbolName( + __in PCSTR name, + __out_ecount(maxStringLength) PSTR outputString, + __in DWORD maxStringLength, + __in DWORD flags + ); +BOOL + SafeSymUnloadModule64( + __in HANDLE hProcess, + __in DWORD64 BaseOfDll + ); +BOOL + SafeSymSetSearchPath( + __in HANDLE hProcess, + __in_opt PCSTR SearchPath + ); +DWORD + SafeSymSetOptions( + __in DWORD SymOptions + ); +BOOL + SafeSymInitialize( + __in HANDLE hProcess, + __in_opt PCSTR UserSearchPath, + __in BOOL fInvadeProcess + ); +BOOL + SafeSymRegisterCallback64( + __in HANDLE hProcess, + __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, + __in ULONG64 UserContext + ); +DWORD64 + SafeSymLoadModuleEx( + __in HANDLE hProcess, + __in_opt HANDLE hFile, + __in_opt PCSTR ImageName, + __in_opt PCSTR ModuleName, + __in DWORD64 BaseOfDll, + __in DWORD DllSize, + __in_opt PMODLOAD_DATA Data, + __in_opt DWORD Flags + ); +BOOL + SafeSymGetModuleInfo64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out PIMAGEHLP_MODULE64 ModuleInfo + ); +BOOL + SafeSymGetSearchPath( + __in HANDLE hProcess, + __out_ecount(SearchPathLength) PSTR SearchPath, + __in DWORD SearchPathLength + ); +BOOL + SafeSymEnumSymbols( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCSTR Mask, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ); +BOOL + SafeSymEnumerateModules( + __in HANDLE hProcess, + __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, + __in_opt PVOID UserContext + ); +BOOL + SafeSymGetLineFromAddr64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out PDWORD pdwDisplacement, + __out PIMAGEHLP_LINE64 Line64 + ); +BOOL + SafeSymFromName( + __in HANDLE hProcess, + __in PCSTR Name, + __inout PSYMBOL_INFO Symbol + ); +BOOL + SafeSymFromAddr( + __in HANDLE hProcess, + __in DWORD64 Address, + __out_opt PDWORD64 Displacement, + __inout PSYMBOL_INFO Symbol + ); +BOOL + SafeSymCleanup( + __in HANDLE hProcess + ); + +#endif //_DBGHELP_SAFE_H \ No newline at end of file diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 0bde1dad..f9cf4054 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -622,17 +622,17 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) sprintf(dbpath, "%s\\%s", dbbasepath, sqlitedb); dprintf("Database file: %s\n", dbpath); dbload(); - SymSetOptions(SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS | SYMOPT_FAVOR_COMPRESSED | SYMOPT_IGNORE_NT_SYMPATH); + SafeSymSetOptions(SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS | SYMOPT_FAVOR_COMPRESSED | SYMOPT_IGNORE_NT_SYMPATH); GuiSymbolLogClear(); char szServerSearchPath[MAX_PATH * 2] = ""; sprintf_s(szServerSearchPath, "SRV*%s", szSymbolCachePath); - SymInitialize(fdProcessInfo->hProcess, szServerSearchPath, false); //initialize symbols - SymRegisterCallback64(fdProcessInfo->hProcess, SymRegisterCallbackProc64, 0); - SymLoadModuleEx(fdProcessInfo->hProcess, CreateProcessInfo->hFile, DebugFileName, 0, (DWORD64)base, 0, 0, 0); + SafeSymInitialize(fdProcessInfo->hProcess, szServerSearchPath, false); //initialize symbols + SafeSymRegisterCallback64(fdProcessInfo->hProcess, SymRegisterCallbackProc64, 0); + SafeSymLoadModuleEx(fdProcessInfo->hProcess, CreateProcessInfo->hFile, DebugFileName, 0, (DWORD64)base, 0, 0, 0); IMAGEHLP_MODULE64 modInfo; memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(modInfo); - if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) + if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) modload((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); memupdatemap(fdProcessInfo->hProcess); //update memory map @@ -697,7 +697,7 @@ static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess) callbackInfo.ExitProcess = ExitProcess; plugincbcall(CB_EXITPROCESS, &callbackInfo); //Cleanup - SymCleanup(fdProcessInfo->hProcess); + SafeSymCleanup(fdProcessInfo->hProcess); } static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) @@ -808,11 +808,11 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) else strcpy_s(DLLDebugFileName, MAX_PATH, StringUtils::Utf16ToUtf8(wszFileName).c_str()); } - SymLoadModuleEx(fdProcessInfo->hProcess, LoadDll->hFile, DLLDebugFileName, 0, (DWORD64)base, 0, 0, 0); + SafeSymLoadModuleEx(fdProcessInfo->hProcess, LoadDll->hFile, DLLDebugFileName, 0, (DWORD64)base, 0, 0, 0); IMAGEHLP_MODULE64 modInfo; memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); - if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) + if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) modload((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); memupdatemap(fdProcessInfo->hProcess); //update memory map @@ -910,7 +910,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) if(modnamefromaddr((uint)base, modname, true)) bpenumall(cbRemoveModuleBreakpoints, modname); GuiUpdateBreakpointsView(); - SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base); + SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base); dprintf("DLL Unloaded: "fhex" %s\n", base, modname); if(bBreakOnNextDll || settingboolget("Events", "DllUnload")) diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 5aa69737..6da4a30a 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -1405,7 +1405,7 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) char szModulePath[MAX_PATH] = ""; strcpy_s(szModulePath, StringUtils::Utf16ToUtf8(wszModulePath).c_str()); char szOldSearchPath[MAX_PATH] = ""; - if(!SymGetSearchPath(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current search path + if(!SafeSymGetSearchPath(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current search path { dputs("SymGetSearchPath failed!"); return STATUS_ERROR; @@ -1414,24 +1414,24 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) if(argc > 2) szSymbolStore = argv[2]; sprintf_s(szServerSearchPath, "SRV*%s*%s", szSymbolCachePath, szSymbolStore); - if(!SymSetSearchPath(fdProcessInfo->hProcess, szServerSearchPath)) //set new search path + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, szServerSearchPath)) //set new search path { dputs("SymSetSearchPath (1) failed!"); return STATUS_ERROR; } - if(!SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) //unload module + if(!SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) //unload module { - SymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath); + SafeSymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath); dputs("SymUnloadModule64 failed!"); return STATUS_ERROR; } - if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, szModulePath, 0, (DWORD64)modbase, 0, 0, 0)) //load module + if(!SafeSymLoadModuleEx(fdProcessInfo->hProcess, 0, szModulePath, 0, (DWORD64)modbase, 0, 0, 0)) //load module { dputs("SymLoadModuleEx failed!"); - SymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath); + SafeSymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath); return STATUS_ERROR; } - if(!SymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath)) + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath)) { dputs("SymSetSearchPath (2) failed!"); return STATUS_ERROR; diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 37162335..e1e05ab7 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -26,7 +26,7 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID if(pSymInfo->Address == pSymInfo->ModBase) return TRUE; } - if(!UnDecorateSymbolName(pSymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) + if(!SafeUnDecorateSymbolName(pSymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) { BridgeFree(curSymbol.undecoratedSymbol); curSymbol.undecoratedSymbol = 0; @@ -47,7 +47,7 @@ void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user) symbolCbData.cbSymbolEnum = cbSymbolEnum; symbolCbData.user = user; char mask[] = "*"; - SymEnumSymbols(fdProcessInfo->hProcess, base, mask, EnumSymbols, &symbolCbData); + SafeSymEnumSymbols(fdProcessInfo->hProcess, base, mask, EnumSymbols, &symbolCbData); } #ifdef _WIN64 @@ -68,7 +68,7 @@ void symupdatemodulelist() { std::vector modList; modList.clear(); - SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); + SafeSymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); int modcount = (int)modList.size(); SYMBOLMODULEINFO* modListBridge = (SYMBOLMODULEINFO*)BridgeAlloc(sizeof(SYMBOLMODULEINFO) * modcount); for(int i = 0; i < modcount; i++) @@ -82,19 +82,19 @@ void symdownloadallsymbols(const char* szSymbolStore) szSymbolStore = "http://msdl.microsoft.com/download/symbols"; std::vector modList; modList.clear(); - SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); + SafeSymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); int modcount = (int)modList.size(); if(!modcount) return; char szOldSearchPath[MAX_PATH] = ""; - if(!SymGetSearchPath(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current path + if(!SafeSymGetSearchPath(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current path { dputs("SymGetSearchPath failed!"); return; } char szServerSearchPath[MAX_PATH * 2] = ""; sprintf_s(szServerSearchPath, "SRV*%s*%s", szSymbolCachePath, szSymbolStore); - if(!SymSetSearchPath(fdProcessInfo->hProcess, szServerSearchPath)) //update search path + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, szServerSearchPath)) //update search path { dputs("SymSetSearchPath (1) failed!"); return; @@ -109,18 +109,18 @@ void symdownloadallsymbols(const char* szSymbolStore) dprintf("GetModuleFileNameExW("fhex") failed!\n", modbase); continue; } - if(!SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) + if(!SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) { dprintf("SymUnloadModule64("fhex") failed!\n", modbase); continue; } - if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(szModulePath).c_str(), 0, (DWORD64)modbase, 0, 0, 0)) + if(!SafeSymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(szModulePath).c_str(), 0, (DWORD64)modbase, 0, 0, 0)) { dprintf("SymLoadModuleEx("fhex") failed!\n", modbase); continue; } } - if(!SymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath)) //restore search path + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath)) //restore search path { dputs("SymSetSearchPath (2) failed!"); } @@ -134,7 +134,7 @@ bool symfromname(const char* name, uint* addr) PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); pSymbol->MaxNameLen = MAX_LABEL_SIZE; - if(!SymFromName(fdProcessInfo->hProcess, name, pSymbol)) + if(!SafeSymFromName(fdProcessInfo->hProcess, name, pSymbol)) return false; *addr = (uint)pSymbol->Address; return true; @@ -155,10 +155,10 @@ const char* symgetsymbolicname(uint addr) PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); pSymbol->MaxNameLen = MAX_LABEL_SIZE; - if(SymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement) + if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement) { pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0'; - if(!bUndecorateSymbolNames or !UnDecorateSymbolName(pSymbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) + if(!bUndecorateSymbolNames or !SafeUnDecorateSymbolName(pSymbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) strcpy_s(label, pSymbol->Name); retval = true; } diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 1ccb95e4..6d6800ad 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -32,6 +32,7 @@ enum CriticalSectionLock LockPatches, LockThreads, LockDprintf, + LockSym, LockLast }; diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 0f88f150..c544ed20 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -19,6 +19,7 @@ + @@ -68,6 +69,7 @@ + diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 2538b0a5..4974409f 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -195,6 +195,9 @@ Source Files\Utilities + + Source Files\Utilities + @@ -371,5 +374,8 @@ Header Files\Utilities + + Header Files\Utilities + \ No newline at end of file From 269f42f09f1b2336283c5f888e18ff92cf59dec7 Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 22:49:53 -0400 Subject: [PATCH 082/106] Application manifest to fix AcLayers hooking --- rpm.cpp | 93 ------------------------- x64_dbg_dbg/module.cpp | 7 +- x64_dbg_exe/x64_dbg_exe.vcxproj | 3 + x64_dbg_exe/x64_dbg_exe.vcxproj.filters | 3 + 4 files changed, 10 insertions(+), 96 deletions(-) delete mode 100644 rpm.cpp diff --git a/rpm.cpp b/rpm.cpp deleted file mode 100644 index fc354e12..00000000 --- a/rpm.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include -#include - -#define uint size_t -#define PAGE_SIZE 0x1000 - -#ifdef _WIN64 -#define HIGHEST_USER_ADDR 0x7FFFFFEFFFF -#else //x86 -#define HIGHEST_USER_ADDR 0x7FFEFFFF -#endif // _WIN64 - -bool readblock(uint addr, unsigned char block[PAGE_SIZE]) -{ - printf("readblock(%X[%X])\n", addr, PAGE_SIZE); - memset(block, 0xFF, PAGE_SIZE); - return true; -} - -bool memread(uint addr, unsigned char* data, uint size) -{ - //check if the address is inside user space - if(addr > HIGHEST_USER_ADDR) - return false; - - puts("-start-"); - printf(" addr: %X\n size: %X\n", addr, size); - - //calculate the start page - uint start = addr & ~(PAGE_SIZE - 1); - printf(" start: %X\n", start); - - //calculate the end page - uint end = addr + size; - uint x = end & (PAGE_SIZE - 1); - if(x) - end += (PAGE_SIZE - x); - printf(" end: %X\n", end); - - //calculate the number of pages to read - uint npages = (end - start) / PAGE_SIZE; - printf("npages: %d\n\n", npages); - - //go over all pages - for(uint i = 0, j = start; i < npages; i++) - { - //read one page (j should always align with PAGE_SIZE) - unsigned char block[PAGE_SIZE]; - if(!readblock(j, block)) - { - return false; - } - - //these are the offsets and sizes in the block to write to append to the output buffer - uint roffset = 0; - uint rsize = PAGE_SIZE; - - if(i == npages - 1) //last page (first because there might only be one page) - { - rsize = size - (j - start); //remaining size - } - else if(i == 0) //first page - { - roffset = addr & (PAGE_SIZE - 1); - rsize = PAGE_SIZE - roffset; - } - - printf("roffset: %X\n rsize: %X\n", roffset, rsize); - puts(""); - - //copy the required block data in the output buffer - memcpy(data, block + roffset, rsize); - data += rsize; - - j += rsize; - } - - puts("--end--\n"); - return true; -} - -int main() -{ - unsigned char out[0x10000] = {0}; - memread(0x12A45, out, 0x3456); - memread(0x12000, out, 0x456); - memread(0x12000, out, 0x3456); - memread(0x12000, out, 0x4000); - memread(0x12ff0, out, 0x16); - memread(0x100, out, 0x3090); - return 0; -} \ No newline at end of file diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index bb7eeac4..3ec8edb0 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -198,11 +198,12 @@ uint ModBaseFromName(const char* Module) for(auto itr = modinfo.begin(); itr != modinfo.end(); itr++) { - char curmodname[MAX_MODULE_SIZE]; - sprintf(curmodname, "%s%s", itr->second.name, itr->second.extension); + char currentModule[MAX_MODULE_SIZE]; + strcpy_s(currentModule, itr->second.name); + strcat_s(currentModule, itr->second.extension); // Test with and without extension - if(!_stricmp(curmodname, Module) || !_stricmp(itr->second.name, Module)) + if(!_stricmp(currentModule, Module) || !_stricmp(itr->second.name, Module)) return itr->second.base; } diff --git a/x64_dbg_exe/x64_dbg_exe.vcxproj b/x64_dbg_exe/x64_dbg_exe.vcxproj index dbe35e75..0750ddb4 100644 --- a/x64_dbg_exe/x64_dbg_exe.vcxproj +++ b/x64_dbg_exe/x64_dbg_exe.vcxproj @@ -31,6 +31,9 @@ + + + {3A22175E-6B72-FDCC-1603-C4A2163C7900} Win32Proj diff --git a/x64_dbg_exe/x64_dbg_exe.vcxproj.filters b/x64_dbg_exe/x64_dbg_exe.vcxproj.filters index c37e6d1a..26d9b663 100644 --- a/x64_dbg_exe/x64_dbg_exe.vcxproj.filters +++ b/x64_dbg_exe/x64_dbg_exe.vcxproj.filters @@ -35,4 +35,7 @@ + + + \ No newline at end of file From f02e4d5f170a08ba2733b4e5fe1f33fd5c5be6a6 Mon Sep 17 00:00:00 2001 From: Nukem Date: Fri, 27 Mar 2015 23:11:56 -0400 Subject: [PATCH 083/106] GUI: Fix memory deallocation bug --- x64_dbg_gui/Project/Src/Gui/SymbolView.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp index 8e96cb3e..adb61c5d 100644 --- a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp @@ -195,12 +195,10 @@ void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules) for(int i = 0; i < module_count; i++) { mModuleBaseList.insert(modules[i].name, modules[i].base); - mModuleList->setCellContent(i, 0, QString("%1").arg(modules[i].base, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); + mModuleList->setCellContent(i, 0, AddressToString(modules[i].base)); mModuleList->setCellContent(i, 1, modules[i].name); } mModuleList->reloadData(); - if(modules) - BridgeFree(modules); } void SymbolView::symbolContextMenu(QMenu* wMenu) From 0f7b253c51c03aff852485b74dfe1fc104ca5fe4 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 00:10:32 -0400 Subject: [PATCH 084/106] Revert "GUI: Fix memory deallocation bug" This reverts commit f02e4d5f170a08ba2733b4e5fe1f33fd5c5be6a6. --- x64_dbg_gui/Project/Src/Gui/SymbolView.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp index adb61c5d..8e96cb3e 100644 --- a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp @@ -195,10 +195,12 @@ void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules) for(int i = 0; i < module_count; i++) { mModuleBaseList.insert(modules[i].name, modules[i].base); - mModuleList->setCellContent(i, 0, AddressToString(modules[i].base)); + mModuleList->setCellContent(i, 0, QString("%1").arg(modules[i].base, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); mModuleList->setCellContent(i, 1, modules[i].name); } mModuleList->reloadData(); + if(modules) + BridgeFree(modules); } void SymbolView::symbolContextMenu(QMenu* wMenu) From 79fa4e85c13184025240f534143d37f1fc2c76d6 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 00:10:56 -0400 Subject: [PATCH 085/106] Disable more debug profile optimizations --- x64_dbg_dbg/x64_dbg_dbg.vcxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 342bd063..a8f11b1e 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -226,8 +226,8 @@ MachineX86 true Windows - true - true + false + false lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) @@ -270,8 +270,8 @@ true Windows - true - true + false + false lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) From bf91af33e7b8c05428fb7cda42d1520d70308c97 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 14:40:28 -0400 Subject: [PATCH 086/106] Inconsistent static functions in math.cpp --- x64_dbg_dbg/math.cpp | 35 +++++++++++++++++++++-------------- x64_dbg_dbg/math.h | 7 ++----- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/x64_dbg_dbg/math.cpp b/x64_dbg_dbg/math.cpp index 5d1759b9..19804a3c 100644 --- a/x64_dbg_dbg/math.cpp +++ b/x64_dbg_dbg/math.cpp @@ -1,12 +1,19 @@ #include "math.h" #include "value.h" +enum BRACKET_TYPE +{ + BRACKET_FREE, + BRACKET_OPEN, + BRACKET_CLOSE, +}; + struct BRACKET_PAIR { int openpos; int closepos; int layer; - int isset; //0=free, 1=open, 2=close + BRACKET_TYPE isset; }; struct EXPRESSION @@ -79,37 +86,37 @@ bool mathcontains(const char* text) } #ifdef __MINGW64__ -static inline unsigned long long umulhi(unsigned long long x, unsigned long long y) +inline unsigned long long umulhi(unsigned long long x, unsigned long long y) { return (unsigned long long)(((__uint128_t)x * y) >> 64); } -static inline long long mulhi(long long x, long long y) +inline long long mulhi(long long x, long long y) { return (long long)(((__int128_t)x * y) >> 64); } #elif _WIN64 #include -static inline unsigned long long umulhi(unsigned long long x, unsigned long long y) +inline unsigned long long umulhi(unsigned long long x, unsigned long long y) { unsigned __int64 res; _umul128(x, y, &res); return res; } -static inline long long mulhi(long long x, long long y) +inline long long mulhi(long long x, long long y) { __int64 res; _mul128(x, y, &res); return res; } #else -static inline unsigned int umulhi(unsigned int x, unsigned int y) +inline unsigned int umulhi(unsigned int x, unsigned int y) { return (unsigned int)(((unsigned long long)x * y) >> 32); } -static inline int mulhi(int x, int y) +inline int mulhi(int x, int y) { return (int)(((long long)x * y) >> 32); } @@ -213,7 +220,7 @@ bool mathdosignedoperation(char op, sint left, sint right, sint* result) return false; } -static void fillpair(EXPRESSION* expstruct, int pos, int layer) +void fillpair(EXPRESSION* expstruct, int pos, int layer) { for(int i = 0; i < expstruct->total_pairs; i++) { @@ -221,20 +228,20 @@ static void fillpair(EXPRESSION* expstruct, int pos, int layer) { expstruct->pairs[i].layer = layer; expstruct->pairs[i].openpos = pos; - expstruct->pairs[i].isset = 1; + expstruct->pairs[i].isset = BRACKET_OPEN; break; } else if(expstruct->pairs[i].layer == layer and expstruct->pairs[i].isset == 1) { expstruct->pairs[i].closepos = pos; - expstruct->pairs[i].isset = 2; + expstruct->pairs[i].isset = BRACKET_CLOSE; break; } } } -static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer) +int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer) { int layer = endlayer; int len = (int)strlen(expression); @@ -262,7 +269,7 @@ static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer) return 0; } -static int expressionformat(char* exp) +int expressionformat(char* exp) { int len = (int)strlen(exp); int open = 0; @@ -285,7 +292,7 @@ static int expressionformat(char* exp) return open; } -static void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int new_len) +void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int new_len) { for(int i = 0; i < exps->total_pairs; i++) { @@ -296,7 +303,7 @@ static void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_l } } -static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly) +bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly) { for(int i = 0; i < exps->total_pairs; i++) { diff --git a/x64_dbg_dbg/math.h b/x64_dbg_dbg/math.h index 97fa745c..d6ea8867 100644 --- a/x64_dbg_dbg/math.h +++ b/x64_dbg_dbg/math.h @@ -1,5 +1,4 @@ -#ifndef _MATH_H -#define _MATH_H +#pragma once #include "_global.h" @@ -9,6 +8,4 @@ bool mathcontains(const char* text); bool mathhandlebrackets(char* expression, bool silent, bool baseonly); bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar); bool mathdounsignedoperation(char op, uint left, uint right, uint* result); -bool mathdosignedoperation(char op, sint left, sint right, sint* result); - -#endif // _MATH_H +bool mathdosignedoperation(char op, sint left, sint right, sint* result); \ No newline at end of file From b56a1d4b91b7d097cdb9d6d66306b2031f4f17e5 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 15:03:58 -0400 Subject: [PATCH 087/106] Small code/style changes in math module --- x64_dbg_dbg/_global.cpp | 4 +- x64_dbg_dbg/dynamicmem.h | 4 + x64_dbg_dbg/math.cpp | 256 ++++++++++++++++++--------------------- 3 files changed, 124 insertions(+), 140 deletions(-) diff --git a/x64_dbg_dbg/_global.cpp b/x64_dbg_dbg/_global.cpp index 3e1fc67e..63822d1c 100644 --- a/x64_dbg_dbg/_global.cpp +++ b/x64_dbg_dbg/_global.cpp @@ -97,9 +97,7 @@ bool arraycontains(const char* cmd_list, const char* cmd) bool scmp(const char* a, const char* b) { - if(_stricmp(a, b)) - return false; - return true; + return _stricmp(a, b) == 0; } void formathex(char* string) diff --git a/x64_dbg_dbg/dynamicmem.h b/x64_dbg_dbg/dynamicmem.h index 83156935..69bbb89e 100644 --- a/x64_dbg_dbg/dynamicmem.h +++ b/x64_dbg_dbg/dynamicmem.h @@ -4,6 +4,10 @@ template class Memory { public: + // + // This class guarantees that the returned allocated memory + // will always be zeroed + // Memory(const char* Reason = "Memory:???") { m_Ptr = nullptr; diff --git a/x64_dbg_dbg/math.cpp b/x64_dbg_dbg/math.cpp index 19804a3c..85914657 100644 --- a/x64_dbg_dbg/math.cpp +++ b/x64_dbg_dbg/math.cpp @@ -25,7 +25,8 @@ struct EXPRESSION /* operator precedence -1 ( ) +0 (INVALID/NONE) +1 ( ) (PARENTHESIS) 2 ~ (NOT) 3 * / % (MUL DIV) 4 + - (ADD SUB) @@ -34,18 +35,21 @@ operator precedence 7 ^ (XOR) 8 | (OR) */ - int mathisoperator(char ch) { - if(ch == '(' or ch == ')') + // + // The lower the number, the higher the priority. + // Zero indicates no operator was found. + // + if(ch == '(' || ch == ')') return 1; else if(ch == '~') return 2; - else if(ch == '*' or ch == '`' or ch == '/' or ch == '%') + else if(ch == '*' || ch == '`' || ch == '/' || ch == '%') return 3; - else if(ch == '+' or ch == '-') + else if(ch == '+' || ch == '-') return 4; - else if(ch == '<' or ch == '>') + else if(ch == '<' || ch == '>') return 5; else if(ch == '&') return 6; @@ -53,6 +57,7 @@ int mathisoperator(char ch) return 7; else if(ch == '|') return 8; + return 0; } @@ -64,10 +69,13 @@ void mathformat(char* text) { int len = (int)strlen(text); Memory temp(len + 1, "mathformat:temp"); - memset(temp, 0, len + 1); - for(int i = 0, j = 0; i < len; i++) - if(mathisoperator(text[i]) < 3 or text[i] != text[i + 1]) - j += sprintf(temp + j, "%c", text[i]); + + for (int i = 0, j = 0; i < len; i++) + { + if (mathisoperator(text[i]) < 3 || text[i] != text[i + 1]) + j += sprintf(temp + j, "%c", text[i]); + } + strcpy(text, temp); } @@ -76,12 +84,17 @@ void mathformat(char* text) */ bool mathcontains(const char* text) { - if(*text == '-') //ignore negative values + // Skip negative values + if(*text == '-') text++; - int len = (int)strlen(text); - for(int i = 0; i < len; i++) - if(mathisoperator(text[i])) - return true; + + // Search the entire string looking for a math operator + for (; text[0] != '\0'; text++) + { + if (mathisoperator(text[0])) + return true; + } + return false; } @@ -122,125 +135,86 @@ inline int mulhi(int x, int y) } #endif //__MINGW64__ +template +bool MathDoOperation(char op, T left, T right, T* result) +{ + switch (op) + { + case '*': + *result = left * right; + return true; + case '`': + *result = umulhi(left, right); + return true; + case '/': + if (right) + { + *result = left / right; + return true; + } + return false; + case '%': + if (right) + { + *result = left % right; + return true; + } + return false; + case '+': + *result = left + right; + return true; + case '-': + *result = left - right; + return true; + case '<': + *result = left << right; + return true; + case '>': + *result = left >> right; + return true; + case '&': + *result = left & right; + return true; + case '^': + *result = left ^ right; + return true; + case '|': + *result = left | right; + return true; + } + return false; +} + bool mathdounsignedoperation(char op, uint left, uint right, uint* result) { - switch(op) - { - case '*': - *result = left * right; - return true; - case '`': - *result = umulhi(left, right); - return true; - case '/': - if(right) - { - *result = left / right; - return true; - } - return false; - case '%': - if(right) - { - *result = left % right; - return true; - } - return false; - case '+': - *result = left + right; - return true; - case '-': - *result = left - right; - return true; - case '<': - *result = left << right; - return true; - case '>': - *result = left >> right; - return true; - case '&': - *result = left & right; - return true; - case '^': - *result = left ^ right; - return true; - case '|': - *result = left | right; - return true; - } - return false; + return MathDoOperation(op, left, right, result); } bool mathdosignedoperation(char op, sint left, sint right, sint* result) { - switch(op) - { - case '*': - *result = left * right; - return true; - case '`': - *result = mulhi(left, right); - return true; - case '/': - if(right) - { - *result = left / right; - return true; - } - return false; - case '%': - if(right) - { - *result = left % right; - return true; - } - return false; - case '+': - *result = left + right; - return true; - case '-': - *result = left - right; - return true; - case '<': - *result = left << right; - return true; - case '>': - *result = left >> right; - return true; - case '&': - *result = left & right; - return true; - case '^': - *result = left ^ right; - return true; - case '|': - *result = left | right; - return true; - } - return false; + return MathDoOperation(op, left, right, result); } void fillpair(EXPRESSION* expstruct, int pos, int layer) { for(int i = 0; i < expstruct->total_pairs; i++) { - if(!expstruct->pairs[i].isset) + if(expstruct->pairs[i].isset == BRACKET_FREE) { - expstruct->pairs[i].layer = layer; - expstruct->pairs[i].openpos = pos; - expstruct->pairs[i].isset = BRACKET_OPEN; + expstruct->pairs[i].layer = layer; + expstruct->pairs[i].openpos = pos; + expstruct->pairs[i].isset = BRACKET_OPEN; break; } - else if(expstruct->pairs[i].layer == layer and expstruct->pairs[i].isset == 1) + else if(expstruct->pairs[i].layer == layer && expstruct->pairs[i].isset == BRACKET_OPEN) { - expstruct->pairs[i].closepos = pos; - expstruct->pairs[i].isset = BRACKET_CLOSE; + expstruct->pairs[i].closepos = pos; + expstruct->pairs[i].isset = BRACKET_CLOSE; break; } } } - int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer) { int layer = endlayer; @@ -298,6 +272,7 @@ void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int { if(exps->pairs[i].openpos > cur_open) exps->pairs[i].openpos += new_len - cur_len; + if(exps->pairs[i].closepos > cur_close) exps->pairs[i].closepos += new_len - cur_len; } @@ -309,18 +284,18 @@ bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseon { if(exps->pairs[i].layer == layer) { - char temp[256] = ""; - char backup[256] = ""; + int open = exps->pairs[i].openpos; + int close = exps->pairs[i].closepos; + int len = close - open; - int open = exps->pairs[i].openpos; - int close = exps->pairs[i].closepos; - int len = close - open; + char temp[256]; strncpy(temp, exp + open + 1, len - 1); + char backup[256]; strcpy_s(backup, exp + open + len + 1); uint value; - if(!mathfromstring(temp, &value, silent, baseonly, 0, 0)) + if(!mathfromstring(temp, &value, silent, baseonly, nullptr, nullptr)) return false; adjustpairs(exps, open, close, len + 1, sprintf(exp + open, "%"fext"X", value)); @@ -330,32 +305,41 @@ bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseon } } + return true; } bool mathhandlebrackets(char* expression, bool silent, bool baseonly) { - EXPRESSION expstruct; - expstruct.expression = expression; - int total_pairs = expressionformat(expression); - if(total_pairs == -1) + int totalPairs = expressionformat(expression); + + if(totalPairs == -1) return false; - else if(!total_pairs) + else if(!totalPairs) return true; - expstruct.total_pairs = total_pairs; - Memory pairs(expstruct.total_pairs * sizeof(BRACKET_PAIR), "mathhandlebrackets:expstruct.pairs"); - expstruct.pairs = pairs; - memset(expstruct.pairs, 0, expstruct.total_pairs * sizeof(BRACKET_PAIR)); - matchpairs(&expstruct, expression, 0); + Memory pairs(totalPairs * sizeof(BRACKET_PAIR), "mathhandlebrackets:pairs"); + + EXPRESSION expStruct; + expStruct.expression = expression; + expStruct.total_pairs = totalPairs; + expStruct.pairs = pairs; + + matchpairs(&expStruct, expression, 0); + int deepest = 0; - for(int i = 0; i < expstruct.total_pairs; i++) - if(expstruct.pairs[i].layer > deepest) - deepest = expstruct.pairs[i].layer; + for (int i = 0; i < expStruct.total_pairs; i++) + { + if (expStruct.pairs[i].layer > deepest) + deepest = expStruct.pairs[i].layer; + } + + for (int i = deepest; i > 0; i--) + { + if (!printlayer(expression, &expStruct, i, silent, baseonly)) + return false; + } - for(int i = deepest; i > 0; i--) - if(!printlayer(expression, &expstruct, i, silent, baseonly)) - return false; return true; } @@ -386,8 +370,6 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, return valfromstring(string, value, silent, baseonly, value_size, isvar, 0); Memory strleft(len + 1 + negative, "mathfromstring:strleft"); Memory strright(len + 1, "mathfromstring:strright"); - memset(strleft, 0, len + 1); - memset(strright, 0, len + 1); strncpy(strleft, string - negative, highestop_pos + negative); strcpy(strright, string + highestop_pos + 1); strcpy(strleft, StringUtils::Trim(strleft).c_str()); From c69ae2053416d3fe14eeb0efdc76c58bc6b33a4d Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 15:24:28 -0400 Subject: [PATCH 088/106] Newer locks in dbghelp_safe --- x64_dbg_dbg/dbghelp_safe.cpp | 40 ++++++++++++++++++++++-------------- x64_dbg_dbg/dbghelp_safe.h | 6 ++++++ x64_dbg_dbg/debugger.cpp | 19 ++++++++--------- x64_dbg_dbg/loop.cpp | 21 +++++++++---------- x64_dbg_dbg/symbolinfo.cpp | 22 ++++++++++---------- x64_dbg_dbg/threading.h | 4 ++-- 6 files changed, 63 insertions(+), 49 deletions(-) diff --git a/x64_dbg_dbg/dbghelp_safe.cpp b/x64_dbg_dbg/dbghelp_safe.cpp index 46bb5ffa..9edeae2e 100644 --- a/x64_dbg_dbg/dbghelp_safe.cpp +++ b/x64_dbg_dbg/dbghelp_safe.cpp @@ -10,7 +10,7 @@ DWORD __in DWORD flags ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return UnDecorateSymbolName(name, outputString, maxStringLength, flags); } BOOL @@ -19,7 +19,7 @@ BOOL __in DWORD64 BaseOfDll ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymUnloadModule64(hProcess, BaseOfDll); } BOOL @@ -28,7 +28,7 @@ BOOL __in_opt PCSTR SearchPath ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymSetSearchPath(hProcess, SearchPath); } DWORD @@ -36,7 +36,7 @@ DWORD __in DWORD SymOptions ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymSetOptions(SymOptions); } BOOL @@ -46,7 +46,7 @@ BOOL __in BOOL fInvadeProcess ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymInitialize(hProcess, UserSearchPath, fInvadeProcess); } BOOL @@ -56,7 +56,7 @@ BOOL __in ULONG64 UserContext ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymRegisterCallback64(hProcess, CallbackFunction, UserContext); } DWORD64 @@ -71,7 +71,7 @@ DWORD64 __in_opt DWORD Flags ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags); } BOOL @@ -81,7 +81,7 @@ BOOL __out PIMAGEHLP_MODULE64 ModuleInfo ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymGetModuleInfo64(hProcess, qwAddr, ModuleInfo); } BOOL @@ -91,7 +91,7 @@ BOOL __in DWORD SearchPathLength ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymGetSearchPath(hProcess, SearchPath, SearchPathLength); } BOOL @@ -103,9 +103,19 @@ BOOL __in_opt PVOID UserContext ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymEnumSymbols(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext); } +BOOL + SafeSymEnumerateModules64( + __in HANDLE hProcess, + __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, + __in_opt PVOID UserContext + ) +{ + EXCLUSIVE_ACQUIRE(LockSym); + return SymEnumerateModules64(hProcess, EnumModulesCallback, UserContext); +} BOOL SafeSymEnumerateModules( __in HANDLE hProcess, @@ -113,7 +123,7 @@ BOOL __in_opt PVOID UserContext ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymEnumerateModules(hProcess, EnumModulesCallback, UserContext); } BOOL @@ -124,7 +134,7 @@ BOOL __out PIMAGEHLP_LINE64 Line64 ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymGetLineFromAddr64(hProcess, qwAddr, pdwDisplacement, Line64); } BOOL @@ -134,7 +144,7 @@ BOOL __inout PSYMBOL_INFO Symbol ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymFromName(hProcess, Name, Symbol); } BOOL @@ -145,7 +155,7 @@ BOOL __inout PSYMBOL_INFO Symbol ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymFromAddr(hProcess, Address, Displacement, Symbol); } BOOL @@ -153,6 +163,6 @@ BOOL __in HANDLE hProcess ) { - CriticalSectionLocker locker(LockSym); + EXCLUSIVE_ACQUIRE(LockSym); return SymCleanup(hProcess); } \ No newline at end of file diff --git a/x64_dbg_dbg/dbghelp_safe.h b/x64_dbg_dbg/dbghelp_safe.h index b6364f33..59063992 100644 --- a/x64_dbg_dbg/dbghelp_safe.h +++ b/x64_dbg_dbg/dbghelp_safe.h @@ -71,6 +71,12 @@ BOOL __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, __in_opt PVOID UserContext ); +BOOL + SafeSymEnumerateModules64( + __in HANDLE hProcess, + __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, + __in_opt PVOID UserContext + ); BOOL SafeSymEnumerateModules( __in HANDLE hProcess, diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 89743ca6..e4dcd674 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -622,17 +622,17 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) sprintf(dbpath, "%s\\%s", dbbasepath, sqlitedb); dprintf("Database file: %s\n", dbpath); dbload(); - SymSetOptions(SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS | SYMOPT_FAVOR_COMPRESSED | SYMOPT_IGNORE_NT_SYMPATH); + SafeSymSetOptions(SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS | SYMOPT_FAVOR_COMPRESSED | SYMOPT_IGNORE_NT_SYMPATH); GuiSymbolLogClear(); char szServerSearchPath[MAX_PATH * 2] = ""; sprintf_s(szServerSearchPath, "SRV*%s", szSymbolCachePath); - SymInitialize(fdProcessInfo->hProcess, szServerSearchPath, false); //initialize symbols - SymRegisterCallback64(fdProcessInfo->hProcess, SymRegisterCallbackProc64, 0); - SymLoadModuleEx(fdProcessInfo->hProcess, CreateProcessInfo->hFile, DebugFileName, 0, (DWORD64)base, 0, 0, 0); + SafeSymInitialize(fdProcessInfo->hProcess, szServerSearchPath, false); //initialize symbols + SafeSymRegisterCallback64(fdProcessInfo->hProcess, SymRegisterCallbackProc64, 0); + SafeSymLoadModuleEx(fdProcessInfo->hProcess, CreateProcessInfo->hFile, DebugFileName, 0, (DWORD64)base, 0, 0, 0); IMAGEHLP_MODULE64 modInfo; memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(modInfo); - if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) + if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); MemUpdateMap(fdProcessInfo->hProcess); //update memory map @@ -697,7 +697,7 @@ static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess) callbackInfo.ExitProcess = ExitProcess; plugincbcall(CB_EXITPROCESS, &callbackInfo); //Cleanup - SymCleanup(fdProcessInfo->hProcess); + SafeSymCleanup(fdProcessInfo->hProcess); } static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) @@ -808,11 +808,11 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) else strcpy_s(DLLDebugFileName, MAX_PATH, StringUtils::Utf16ToUtf8(wszFileName).c_str()); } - SymLoadModuleEx(fdProcessInfo->hProcess, LoadDll->hFile, DLLDebugFileName, 0, (DWORD64)base, 0, 0, 0); + SafeSymLoadModuleEx(fdProcessInfo->hProcess, LoadDll->hFile, DLLDebugFileName, 0, (DWORD64)base, 0, 0, 0); IMAGEHLP_MODULE64 modInfo; memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); - if(SymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) + if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); MemUpdateMap(fdProcessInfo->hProcess); //update memory map @@ -910,7 +910,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) if(ModNameFromAddr((uint)base, modname, true)) BpEnumAll(cbRemoveModuleBreakpoints, modname); GuiUpdateBreakpointsView(); - SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base); + SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base); dprintf("DLL Unloaded: "fhex" %s\n", base, modname); if(bBreakOnNextDll || settingboolget("Events", "DllUnload")) @@ -933,7 +933,6 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); PLUG_CB_OUTPUTDEBUGSTRING callbackInfo; callbackInfo.DebugString = DebugString; diff --git a/x64_dbg_dbg/loop.cpp b/x64_dbg_dbg/loop.cpp index 247267d7..50c42327 100644 --- a/x64_dbg_dbg/loop.cpp +++ b/x64_dbg_dbg/loop.cpp @@ -173,33 +173,33 @@ void loopcacheload(JSON root) } } -bool loopenum(LOOPSINFO* looplist, size_t* cbsize) +bool loopenum(LOOPSINFO* List, size_t* Size) { // If looplist or size is not requested, fail - if(!looplist && !cbsize) + if(!List && !Size) return false; SHARED_ACQUIRE(LockLoops); // See if the caller requested an output size - if(cbsize) + if(Size) { - *cbsize = loops.size() * sizeof(LOOPSINFO); + *Size = loops.size() * sizeof(LOOPSINFO); - if(!looplist) + if(!List) return true; } for(auto itr = loops.begin(); itr != loops.end(); itr++) { - *looplist = itr->second; + *List = itr->second; // Adjust the offset to a real virtual address - uint modbase = ModBaseFromName(looplist->mod); - looplist->start += modbase; - looplist->end += modbase; + uint modbase = ModBaseFromName(List->mod); + List->start += modbase; + List->end += modbase; - looplist++; + List++; } return true; @@ -209,5 +209,4 @@ void loopclear() { EXCLUSIVE_ACQUIRE(LockLoops); loops.clear(); - EXCLUSIVE_RELEASE(); } \ No newline at end of file diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index b44d1133..d26593bc 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -30,7 +30,7 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO SymInfo, ULONG SymbolSize, PVOID U } // Convert a mangled/decorated C++ name to a readable format - if(!UnDecorateSymbolName(SymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) + if(!SafeUnDecorateSymbolName(SymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) { BridgeFree(curSymbol.undecoratedSymbol); curSymbol.undecoratedSymbol = nullptr; @@ -53,7 +53,7 @@ void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData) symbolCbData.user = UserData; // Enumerate every single symbol for the module in 'base' - if(!SymEnumSymbols(fdProcessInfo->hProcess, Base, "*", EnumSymbols, &symbolCbData)) + if(!SafeSymEnumSymbols(fdProcessInfo->hProcess, Base, "*", EnumSymbols, &symbolCbData)) dputs("SymEnumSymbols failed!"); } @@ -76,7 +76,7 @@ bool SymGetModuleList(std::vector* List) }; // Execute the symbol enumerator (Force cast to STDCALL) - if(!SymEnumerateModules64(fdProcessInfo->hProcess, EnumModules, List)) + if(!SafeSymEnumerateModules64(fdProcessInfo->hProcess, EnumModules, List)) { dputs("SymEnumerateModules64 failed!"); return false; @@ -116,7 +116,7 @@ void SymDownloadAllSymbols(const char* SymbolStore) // Backup the current symbol search path char oldSearchPath[MAX_PATH]; - if(!SymGetSearchPath(fdProcessInfo->hProcess, oldSearchPath, MAX_PATH)) + if(!SafeSymGetSearchPath(fdProcessInfo->hProcess, oldSearchPath, MAX_PATH)) { dputs("SymGetSearchPath failed!"); return; @@ -126,7 +126,7 @@ void SymDownloadAllSymbols(const char* SymbolStore) char customSearchPath[MAX_PATH * 2]; sprintf_s(customSearchPath, "SRV*%s*%s", szSymbolCachePath, SymbolStore); - if(!SymSetSearchPath(fdProcessInfo->hProcess, customSearchPath)) + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, customSearchPath)) { dputs("SymSetSearchPath (1) failed!"); return; @@ -144,13 +144,13 @@ void SymDownloadAllSymbols(const char* SymbolStore) continue; } - if(!SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)module.base)) + if(!SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)module.base)) { dprintf("SymUnloadModule64("fhex") failed!\n", module.base); continue; } - if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(modulePath).c_str(), 0, (DWORD64)module.base, 0, 0, 0)) + if(!SafeSymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(modulePath).c_str(), 0, (DWORD64)module.base, 0, 0, 0)) { dprintf("SymLoadModuleEx("fhex") failed!\n", module.base); continue; @@ -158,7 +158,7 @@ void SymDownloadAllSymbols(const char* SymbolStore) } // Restore the old search path - if(!SymSetSearchPath(fdProcessInfo->hProcess, oldSearchPath)) + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, oldSearchPath)) dputs("SymSetSearchPath (2) failed!"); } @@ -182,7 +182,7 @@ bool SymAddrFromName(const char* Name, uint* Address) symbol->SizeOfStruct = sizeof(SYMBOL_INFO); symbol->MaxNameLen = MAX_LABEL_SIZE; - if(!SymFromName(fdProcessInfo->hProcess, Name, symbol)) + if(!SafeSymFromName(fdProcessInfo->hProcess, Name, symbol)) return false; *Address = (uint)symbol->Address; @@ -210,7 +210,7 @@ const char* SymGetSymbolicName(uint Address) // Perform a symbol lookup DWORD64 displacement = 0; - if(!SymFromAddr(fdProcessInfo->hProcess, (DWORD64)Address, &displacement, symbol)) + if(!SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)Address, &displacement, symbol)) return nullptr; // If the symbol wasn't at offset 0 (start from the beginning) ignore it @@ -220,7 +220,7 @@ const char* SymGetSymbolicName(uint Address) // Terminate the string for sanity symbol->Name[symbol->MaxNameLen - 1] = '\0'; - if(!bUndecorateSymbolNames || !UnDecorateSymbolName(symbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) + if(!bUndecorateSymbolNames || !SafeUnDecorateSymbolName(symbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) strcpy_s(label, symbol->Name); } diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index b24f8546..02cbb577 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -45,14 +45,14 @@ enum SectionLock LockPatches, LockThreads, LockDprintf, + LockSym, // This is defined because of a bug in the Windows 8.1 kernel; // Calling VirtualQuery/VirtualProtect/ReadProcessMemory can and will cause // a deadlock. // https://bitbucket.org/mrexodia/x64_dbg/issue/247/x64-dbg-bug-string-references-function LockWin8Workaround, - - LockLast + LockLast, }; class SectionLockerGlobal From ee797cf55c1d0b85a0055d870ff1bb300401072f Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 15:24:58 -0400 Subject: [PATCH 089/106] Eliminate recursive lock in SafeUnDecorateSymbolName --- x64_dbg_dbg/dbghelp_safe.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/x64_dbg_dbg/dbghelp_safe.cpp b/x64_dbg_dbg/dbghelp_safe.cpp index 9edeae2e..f8a9d3a0 100644 --- a/x64_dbg_dbg/dbghelp_safe.cpp +++ b/x64_dbg_dbg/dbghelp_safe.cpp @@ -10,7 +10,6 @@ DWORD __in DWORD flags ) { - EXCLUSIVE_ACQUIRE(LockSym); return UnDecorateSymbolName(name, outputString, maxStringLength, flags); } BOOL From 4913813f4e32ea0eef67c5b26b76adfd67744cf1 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 15:27:33 -0400 Subject: [PATCH 090/106] Remove unused enum 'BITMASK' --- x64_dbg_dbg/_global.h | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index b3304f29..54b7c1f4 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -52,42 +52,6 @@ typedef unsigned long uint; typedef long sint; #endif // _WIN64 -enum BITMASK -{ - BIT1 = 0x1, - BIT2 = 0x2, - BIT3 = 0x4, - BIT4 = 0x8, - BIT5 = 0x10, - BIT6 = 0x20, - BIT7 = 0x40, - BIT8 = 0x80, - BIT9 = 0x100, - BIT10 = 0x200, - BIT11 = 0x400, - BIT12 = 0x800, - BIT13 = 0x1000, - BIT14 = 0x2000, - BIT15 = 0x4000, - BIT16 = 0x8000, - BIT17 = 0x10000, - BIT18 = 0x20000, - BIT19 = 0x40000, - BIT20 = 0x80000, - BIT21 = 0x100000, - BIT22 = 0x200000, - BIT23 = 0x400000, - BIT24 = 0x800000, - BIT25 = 0x1000000, - BIT26 = 0x2000000, - BIT27 = 0x4000000, - BIT28 = 0x8000000, - BIT29 = 0x10000000, - BIT30 = 0x20000000, - BIT31 = 0x40000000, - BIT32 = 0x80000000 -}; - enum arch { notfound, From efac966b3924032eafce82fe50e40953312101ef Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 15:32:24 -0400 Subject: [PATCH 091/106] Project: define _DEBUG when needed --- x64_dbg_dbg/memory.cpp | 2 +- x64_dbg_dbg/threading.h | 1 + x64_dbg_dbg/x64_dbg_dbg.vcxproj | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 77c59c7c..87f78e69 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -224,7 +224,7 @@ bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfByte // Try a regular WriteProcessMemory call bool ret = MemoryWriteSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesWritten); - if(ret and * NumberOfBytesWritten == Size) + if(ret && * NumberOfBytesWritten == Size) return true; // Write page-by-page (Skip if only 1 page exists) diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 02cbb577..8fdecca5 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -52,6 +52,7 @@ enum SectionLock // a deadlock. // https://bitbucket.org/mrexodia/x64_dbg/issue/247/x64-dbg-bug-string-references-function LockWin8Workaround, + LockLast, }; diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 2a7ad4b4..e75d3c02 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -214,8 +214,8 @@ - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL + WIN32;_DEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL Level3 ProgramDatabase true @@ -259,8 +259,8 @@ - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL + WIN32;_DEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL Level3 ProgramDatabase true From fe2cdf26de8ffe36454db08b4b028814ae2489c3 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 16:38:41 -0400 Subject: [PATCH 092/106] Compiler-optimized MemIsCanonicalAddress --- x64_dbg_dbg/memory.cpp | 28 ++++++++++++---------------- x64_dbg_dbg/threading.h | 4 ++-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 87f78e69..22f331e7 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -179,9 +179,9 @@ bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytes if (pageCount > 1) { // Determine the number of bytes between ADDRESS and the next page - uint offset = 0; - uint readBase = (uint)BaseAddress; - uint readSize = ROUND_TO_PAGES(readBase) - readBase; + uint offset = 0; + uint readBase = (uint)BaseAddress; + uint readSize = ROUND_TO_PAGES(readBase) - readBase; // Reset the bytes read count *NumberOfBytesRead = 0; @@ -234,9 +234,9 @@ bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfByte if (pageCount > 1) { // Determine the number of bytes between ADDRESS and the next page - uint offset = 0; - uint writeBase = (uint)BaseAddress; - uint writeSize = ROUND_TO_PAGES(writeBase) - writeBase; + uint offset = 0; + uint writeBase = (uint)BaseAddress; + uint writeSize = ROUND_TO_PAGES(writeBase) - writeBase; // Reset the bytes read count *NumberOfBytesWritten = 0; @@ -295,16 +295,12 @@ bool MemIsCanonicalAddress(uint Address) // not an issue return true; #else - // The most-significant 16 bits must be all 1 or all 0 - // NOTE: Compiler optimizes this to a few bit shifts - switch (Address & 0xFFFF800000000000) - { - case 0xFFFF800000000000: - case 0x0000000000000000: - return true; - } - - return false; + // The most-significant 16 bits must be all 1 or all 0. + // (64 - 16) = 48bit linear address range. + // + // 0xFFFF800000000000 = Significant 16 bits set + // 0x0000800000000000 = 48th bit set + return (((Address & 0xFFFF800000000000) + 0x800000000000) & ~0x800000000000) == 0; #endif // _WIN64 } diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 8fdecca5..7d092b54 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -84,9 +84,9 @@ public: if(m_LockCount > 0) Unlock(); - // TODO: Assert that the lock count is zero on destructor #ifdef _DEBUG - if(m_LockCount > 0) + // TODO: Assert that the lock count is zero on destructor + if (m_LockCount > 0) __debugbreak(); #endif } From 402fc9ced7da20a09f331806a842557e1ed04aeb Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 17:19:53 -0400 Subject: [PATCH 093/106] 64bit address display was not 0-padded --- x64_dbg_gui/Project/Src/Utils/StringUtil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x64_dbg_gui/Project/Src/Utils/StringUtil.h b/x64_dbg_gui/Project/Src/Utils/StringUtil.h index 2425f90d..6f27817d 100644 --- a/x64_dbg_gui/Project/Src/Utils/StringUtil.h +++ b/x64_dbg_gui/Project/Src/Utils/StringUtil.h @@ -16,7 +16,7 @@ static QString AddressToString(int_t Address) char temp[32]; #ifdef _WIN64 - sprintf_s(temp, "%16llX", Address); + sprintf_s(temp, "%016llX", Address); #else sprintf_s(temp, "%08X", Address); #endif // _WIN64 From 86791702da305aa4aec8ef2836e5802e066187ac Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 17:26:41 -0400 Subject: [PATCH 094/106] Fix memory corruption --- x64_dbg_dbg/symbolinfo.cpp | 9 ++++++++- x64_dbg_dbg/x64_dbg_dbg.vcxproj | 8 +++++++- x64_dbg_gui/Project/Src/Gui/SymbolView.cpp | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index d26593bc..0e58fb9d 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -93,8 +93,15 @@ void SymUpdateModuleList() if(!SymGetModuleList(&modList)) return; + // Create a new array to be sent to the GUI thread + size_t moduleCount = modList.size(); + SYMBOLMODULEINFO *data = (SYMBOLMODULEINFO *)BridgeAlloc(moduleCount * sizeof(SYMBOLMODULEINFO)); + + // Direct copy from std::vector data + memcpy(data, modList.data(), moduleCount * sizeof(SYMBOLMODULEINFO)); + // Send the module data to the GUI for updating - GuiSymbolUpdateModuleList((int)modList.size(), modList.data()); + GuiSymbolUpdateModuleList((int)moduleCount, data); } void SymDownloadAllSymbols(const char* SymbolStore) diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index e75d3c02..8fb7b44e 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -248,6 +248,9 @@ None true Speed + AVXI + false + None true @@ -266,8 +269,11 @@ true NoIPO false - true + false Disabled + Rw + None + true true diff --git a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp index 8e96cb3e..85edc9b3 100644 --- a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp @@ -199,6 +199,10 @@ void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules) mModuleList->setCellContent(i, 1, modules[i].name); } mModuleList->reloadData(); + + // This BridgeFree call must remain here because of how arguments + // are passed; they are thread-thread delayed so passing a stack + // variable can not work. if(modules) BridgeFree(modules); } From 11e03be0411d8223d94b718b7718bd0cefa2b052 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 18:05:55 -0400 Subject: [PATCH 095/106] GUI: Memory map double click for disasm --- x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp | 6 ++++++ x64_dbg_gui/Project/Src/Gui/MemoryMapView.h | 1 + 2 files changed, 7 insertions(+) diff --git a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp index 92ca43f2..66328826 100644 --- a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp @@ -20,6 +20,7 @@ MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent) connect(Bridge::getBridge(), SIGNAL(updateMemory()), this, SLOT(refreshMap())); connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(stateChangedSlot(DBGSTATE))); connect(this, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(contextMenuSlot(QPoint))); + connect(this, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot())); setupContextMenu(); } @@ -146,6 +147,11 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos) wMenu->exec(mapToGlobal(pos)); //execute context menu } +void MemoryMapView::doubleClickedSlot() +{ + followDisassemblerSlot(); +} + QString MemoryMapView::getProtectionString(DWORD Protect) { #define RIGHTS_STRING (sizeof("ERWCG") + 1) diff --git a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h index 1d7e4e37..7c0847d6 100644 --- a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h +++ b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h @@ -28,6 +28,7 @@ public slots: void memoryRemoveSlot(); void memoryExecuteSingleshootToggleSlot(); void contextMenuSlot(const QPoint & pos); + void doubleClickedSlot(); void switchView(); void pageMemoryRights(); void refreshMap(); From 24bc4b44601faffae107e4b6ec4228a98359d8e2 Mon Sep 17 00:00:00 2001 From: Nukem Date: Sat, 28 Mar 2015 18:09:53 -0400 Subject: [PATCH 096/106] GUI: Hide horizontal scrollbars until an option is added --- x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp index 96715382..4fa6df51 100644 --- a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp @@ -32,6 +32,7 @@ AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(pare setVerticalScrollBar(new AbstractTableScrollBar(verticalScrollBar())); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); memset(&mScrollBarAttributes, 0, sizeof(mScrollBarAttributes)); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); horizontalScrollBar()->setRange(0, 0); horizontalScrollBar()->setPageStep(650); mMouseWheelScrollDelta = 4; From 4798a2966056a2766fbd60f6961191a94969a0bb Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 16:57:45 +0200 Subject: [PATCH 097/106] Revert "Merged in Nukem9/x64_dbg/master (pull request #45)" This reverts commit b6735aad53c36d4b192a4baaa9ee1df3e964925c, reversing changes made to 20fa55cc2b61d728e26d25f46c827db615b38ffe. --- rpm.cpp | 93 + x64_dbg.sln | 23 +- x64_dbg_bridge/bridgemain.h | 4 +- x64_dbg_bridge/x64_dbg_bridge.vcxproj | 67 - x64_dbg_bridge/x64_dbg_bridge.vcxproj.user | 10 - x64_dbg_dbg/_dbgfunctions.cpp | 20 +- x64_dbg_dbg/_exports.cpp | 69 +- x64_dbg_dbg/_global.cpp | 4 +- x64_dbg_dbg/_global.h | 39 +- x64_dbg_dbg/addrinfo.cpp | 44 +- x64_dbg_dbg/assemble.cpp | 4 +- x64_dbg_dbg/bookmark.cpp | 257 +- x64_dbg_dbg/bookmark.h | 21 +- x64_dbg_dbg/breakpoint.cpp | 573 +-- x64_dbg_dbg/breakpoint.h | 40 +- x64_dbg_dbg/comment.cpp | 294 +- x64_dbg_dbg/comment.h | 21 +- x64_dbg_dbg/console.cpp | 20 +- x64_dbg_dbg/console.h | 10 +- x64_dbg_dbg/dbghelp_safe.cpp | 39 +- x64_dbg_dbg/dbghelp_safe.h | 6 - x64_dbg_dbg/debugger.cpp | 167 +- x64_dbg_dbg/debugger_commands.cpp | 188 +- x64_dbg_dbg/disasm_fast.cpp | 2 +- x64_dbg_dbg/disasm_helper.cpp | 10 +- x64_dbg_dbg/dynamicmem.h | 71 +- x64_dbg_dbg/error.cpp | 4390 ++++++++--------- x64_dbg_dbg/error.h | 9 +- x64_dbg_dbg/exception.cpp | 140 +- x64_dbg_dbg/exception.h | 9 +- x64_dbg_dbg/function.cpp | 316 +- x64_dbg_dbg/function.h | 23 +- x64_dbg_dbg/instruction.cpp | 44 +- x64_dbg_dbg/label.cpp | 28 +- x64_dbg_dbg/loop.cpp | 63 +- x64_dbg_dbg/math.cpp | 287 +- x64_dbg_dbg/math.h | 7 +- x64_dbg_dbg/memory.cpp | 253 +- x64_dbg_dbg/memory.h | 22 +- x64_dbg_dbg/module.cpp | 320 +- x64_dbg_dbg/module.h | 59 +- x64_dbg_dbg/patches.cpp | 26 +- x64_dbg_dbg/plugin_loader.cpp | 2 +- x64_dbg_dbg/reference.cpp | 6 +- x64_dbg_dbg/stackinfo.cpp | 30 +- x64_dbg_dbg/symbolinfo.cpp | 260 +- x64_dbg_dbg/symbolinfo.h | 16 +- x64_dbg_dbg/thread.cpp | 284 +- x64_dbg_dbg/thread.h | 34 +- x64_dbg_dbg/threading.cpp | 62 +- x64_dbg_dbg/threading.h | 98 +- x64_dbg_dbg/value.cpp | 18 +- x64_dbg_dbg/variable.cpp | 109 +- x64_dbg_dbg/x64_dbg.cpp | 4 +- x64_dbg_dbg/x64_dbg_dbg.vcxproj | 102 - x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters | 4 + x64_dbg_dbg/x64_dbg_dbg.vcxproj.user | 10 - x64_dbg_exe/x64_dbg_exe.vcxproj | 79 - x64_dbg_exe/x64_dbg_exe.vcxproj.filters | 3 - .../Src/BasicView/AbstractTableView.cpp | 1 - .../Project/Src/BasicView/AbstractTableView.h | 1 - .../Project/Src/BasicView/Disassembly.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/CPUStack.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp | 4 +- x64_dbg_gui/Project/Src/Gui/HexEditDialog.h | 4 +- x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp | 6 - x64_dbg_gui/Project/Src/Gui/MemoryMapView.h | 1 - x64_dbg_gui/Project/Src/Gui/SymbolView.cpp | 4 - x64_dbg_gui/Project/Src/Gui/ThreadView.cpp | 2 +- x64_dbg_gui/Project/Src/Utils/StringUtil.h | 27 - x64_dbg_gui/Project/x64_dbg.pro | 3 +- x64_dbg_launcher/x64_dbg_launcher.vcxproj | 39 - 74 files changed, 4176 insertions(+), 5137 deletions(-) create mode 100644 rpm.cpp delete mode 100644 x64_dbg_gui/Project/Src/Utils/StringUtil.h diff --git a/rpm.cpp b/rpm.cpp new file mode 100644 index 00000000..fc354e12 --- /dev/null +++ b/rpm.cpp @@ -0,0 +1,93 @@ +#include +#include +#include + +#define uint size_t +#define PAGE_SIZE 0x1000 + +#ifdef _WIN64 +#define HIGHEST_USER_ADDR 0x7FFFFFEFFFF +#else //x86 +#define HIGHEST_USER_ADDR 0x7FFEFFFF +#endif // _WIN64 + +bool readblock(uint addr, unsigned char block[PAGE_SIZE]) +{ + printf("readblock(%X[%X])\n", addr, PAGE_SIZE); + memset(block, 0xFF, PAGE_SIZE); + return true; +} + +bool memread(uint addr, unsigned char* data, uint size) +{ + //check if the address is inside user space + if(addr > HIGHEST_USER_ADDR) + return false; + + puts("-start-"); + printf(" addr: %X\n size: %X\n", addr, size); + + //calculate the start page + uint start = addr & ~(PAGE_SIZE - 1); + printf(" start: %X\n", start); + + //calculate the end page + uint end = addr + size; + uint x = end & (PAGE_SIZE - 1); + if(x) + end += (PAGE_SIZE - x); + printf(" end: %X\n", end); + + //calculate the number of pages to read + uint npages = (end - start) / PAGE_SIZE; + printf("npages: %d\n\n", npages); + + //go over all pages + for(uint i = 0, j = start; i < npages; i++) + { + //read one page (j should always align with PAGE_SIZE) + unsigned char block[PAGE_SIZE]; + if(!readblock(j, block)) + { + return false; + } + + //these are the offsets and sizes in the block to write to append to the output buffer + uint roffset = 0; + uint rsize = PAGE_SIZE; + + if(i == npages - 1) //last page (first because there might only be one page) + { + rsize = size - (j - start); //remaining size + } + else if(i == 0) //first page + { + roffset = addr & (PAGE_SIZE - 1); + rsize = PAGE_SIZE - roffset; + } + + printf("roffset: %X\n rsize: %X\n", roffset, rsize); + puts(""); + + //copy the required block data in the output buffer + memcpy(data, block + roffset, rsize); + data += rsize; + + j += rsize; + } + + puts("--end--\n"); + return true; +} + +int main() +{ + unsigned char out[0x10000] = {0}; + memread(0x12A45, out, 0x3456); + memread(0x12000, out, 0x456); + memread(0x12000, out, 0x3456); + memread(0x12000, out, 0x4000); + memread(0x12ff0, out, 0x16); + memread(0x100, out, 0x3090); + return 0; +} \ No newline at end of file diff --git a/x64_dbg.sln b/x64_dbg.sln index 9f3fc16c..a7e946e6 100644 --- a/x64_dbg.sln +++ b/x64_dbg.sln @@ -1,8 +1,6 @@  -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64_dbg_bridge", "x64_dbg_bridge\x64_dbg_bridge.vcxproj", "{944D9923-CB1A-6F6C-BCBC-9E00A71954C1}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64_dbg_exe", "x64_dbg_exe\x64_dbg_exe.vcxproj", "{3A22175E-6B72-FDCC-1603-C4A2163C7900}" @@ -19,39 +17,22 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64_dbg_launcher", "x64_dbg EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|Win32.Build.0 = Debug|Win32 - {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|x64.ActiveCfg = Debug|x64 - {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Debug|x64.Build.0 = Debug|x64 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|Win32.ActiveCfg = Release|Win32 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|Win32.Build.0 = Release|Win32 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|x64.ActiveCfg = Release|x64 {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}.Release|x64.Build.0 = Release|x64 - {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|Win32.ActiveCfg = Debug|Win32 - {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|Win32.Build.0 = Debug|Win32 - {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|x64.ActiveCfg = Debug|x64 - {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Debug|x64.Build.0 = Debug|x64 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|Win32.ActiveCfg = Release|Win32 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|Win32.Build.0 = Release|Win32 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|x64.ActiveCfg = Release|x64 {3A22175E-6B72-FDCC-1603-C4A2163C7900}.Release|x64.Build.0 = Release|x64 - {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|Win32.ActiveCfg = Debug|Win32 - {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|Win32.Build.0 = Debug|Win32 - {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|x64.ActiveCfg = Debug|x64 - {E6548308-401E-3A8A-5819-905DB90522A6}.Debug|x64.Build.0 = Debug|x64 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|Win32.ActiveCfg = Release|Win32 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|Win32.Build.0 = Release|Win32 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|x64.ActiveCfg = Release|x64 {E6548308-401E-3A8A-5819-905DB90522A6}.Release|x64.Build.0 = Release|x64 - {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Debug|Win32.ActiveCfg = Debug|Win32 - {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Debug|Win32.Build.0 = Debug|Win32 - {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Debug|x64.ActiveCfg = Debug|Win32 {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|Win32.ActiveCfg = Release|Win32 {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|Win32.Build.0 = Release|Win32 {AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|x64.ActiveCfg = Release|Win32 diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index 28cbfa2c..c64fe3c1 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -540,8 +540,8 @@ typedef struct typedef struct { int ThreadNumber; - HANDLE Handle; - DWORD ThreadId; + HANDLE hThread; + DWORD dwThreadId; duint ThreadStartAddress; duint ThreadLocalBase; char threadName[MAX_THREAD_NAME_SIZE]; diff --git a/x64_dbg_bridge/x64_dbg_bridge.vcxproj b/x64_dbg_bridge/x64_dbg_bridge.vcxproj index da4f609d..a68af05d 100644 --- a/x64_dbg_bridge/x64_dbg_bridge.vcxproj +++ b/x64_dbg_bridge/x64_dbg_bridge.vcxproj @@ -1,14 +1,6 @@  - - Debug - Win32 - - - Debug - x64 - Release Win32 @@ -35,22 +27,10 @@ DynamicLibrary false - v120 - - - DynamicLibrary - false - v120 DynamicLibrary false - v120 - - - DynamicLibrary - false - v120 @@ -58,15 +38,9 @@ - - - - - - false @@ -74,22 +48,11 @@ $(Platform)\$(Configuration)\ x32_bridge - - false - $(SolutionDir)bin\x32\ - $(Platform)\$(Configuration)\ - x32_bridge - false $(SolutionDir)bin\x64\ x64_bridge - - false - $(SolutionDir)bin\x64\ - x64_bridge - BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -106,22 +69,6 @@ true - - - BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - MaxSpeed - - - MachineX86 - true - Windows - true - true - - BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -136,20 +83,6 @@ true - - - BUILD_BRIDGE;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - - - true - Windows - true - true - - diff --git a/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user b/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user index bdb12b67..b72054fc 100644 --- a/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user +++ b/x64_dbg_bridge/x64_dbg_bridge.vcxproj.user @@ -5,19 +5,9 @@ WindowsLocalDebugger $(OutDir) - - $(OutDir)\x32_dbg.exe - WindowsLocalDebugger - $(OutDir) - $(OutDir)\x64_dbg.exe WindowsLocalDebugger $(OutDir) - - $(OutDir)\x64_dbg.exe - WindowsLocalDebugger - $(OutDir) - \ No newline at end of file diff --git a/x64_dbg_dbg/_dbgfunctions.cpp b/x64_dbg_dbg/_dbgfunctions.cpp index 6accb9cd..57bc9934 100644 --- a/x64_dbg_dbg/_dbgfunctions.cpp +++ b/x64_dbg_dbg/_dbgfunctions.cpp @@ -24,7 +24,7 @@ static bool _assembleatex(duint addr, const char* instruction, char* error, bool static bool _sectionfromaddr(duint addr, char* section) { - HMODULE hMod = (HMODULE)ModBaseFromAddr(addr); + HMODULE hMod = (HMODULE)modbasefromaddr(addr); if(!hMod) return false; wchar_t curModPath[MAX_PATH] = L""; @@ -72,7 +72,7 @@ static bool _patchinrange(duint start, duint end) static bool _mempatch(duint va, const unsigned char* src, duint size) { - return MemPatch((void*)va, (void*)src, size, 0); + return mempatch(fdProcessInfo->hProcess, (void*)va, src, size, 0); } static void _patchrestorerange(duint start, duint end) @@ -162,17 +162,17 @@ bool _getprocesslist(DBGPROCESSINFO** entries, int* count) static void _memupdatemap() { - MemUpdateMap(fdProcessInfo->hProcess); + memupdatemap(fdProcessInfo->hProcess); } void dbgfunctionsinit() { _dbgfunctions.AssembleAtEx = _assembleatex; _dbgfunctions.SectionFromAddr = _sectionfromaddr; - _dbgfunctions.ModNameFromAddr = ModNameFromAddr; - _dbgfunctions.ModBaseFromAddr = ModBaseFromAddr; - _dbgfunctions.ModBaseFromName = ModBaseFromName; - _dbgfunctions.ModSizeFromAddr = ModSizeFromAddr; + _dbgfunctions.ModNameFromAddr = modnamefromaddr; + _dbgfunctions.ModBaseFromAddr = modbasefromaddr; + _dbgfunctions.ModBaseFromName = modbasefromname; + _dbgfunctions.ModSizeFromAddr = modsizefromaddr; _dbgfunctions.Assemble = assemble; _dbgfunctions.PatchGet = _patchget; _dbgfunctions.PatchInRange = _patchinrange; @@ -181,12 +181,12 @@ void dbgfunctionsinit() _dbgfunctions.PatchEnum = (PATCHENUM)patchenum; _dbgfunctions.PatchRestore = _patchrestore; _dbgfunctions.PatchFile = (PATCHFILE)patchfile; - _dbgfunctions.ModPathFromAddr = ModPathFromAddr; - _dbgfunctions.ModPathFromName = ModPathFromName; + _dbgfunctions.ModPathFromAddr = modpathfromaddr; + _dbgfunctions.ModPathFromName = modpathfromname; _dbgfunctions.DisasmFast = disasmfast; _dbgfunctions.MemUpdateMap = _memupdatemap; _dbgfunctions.GetCallStack = _getcallstack; - _dbgfunctions.SymbolDownloadAllSymbols = SymDownloadAllSymbols; + _dbgfunctions.SymbolDownloadAllSymbols = symdownloadallsymbols; _dbgfunctions.GetJit = _getjit; _dbgfunctions.GetJitAuto = _getjitauto; _dbgfunctions.GetDefJit = dbggetdefjit; diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index ab8592ff..d4aa29db 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -26,17 +26,17 @@ static bool bOnlyCipAutoComments = false; extern "C" DLL_EXPORT duint _dbg_memfindbaseaddr(duint addr, duint* size) { - return MemFindBaseAddr(addr, size); + return memfindbaseaddr(addr, size); } extern "C" DLL_EXPORT bool _dbg_memread(duint addr, unsigned char* dest, duint size, duint* read) { - return MemRead((void*)addr, dest, size, read); + return memread(fdProcessInfo->hProcess, (void*)addr, dest, size, read); } extern "C" DLL_EXPORT bool _dbg_memwrite(duint addr, const unsigned char* src, duint size, duint* written) { - return MemWrite((void*)addr, (void*)src, size, written); + return memwrite(fdProcessInfo->hProcess, (void*)addr, src, size, written); } extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap) @@ -57,7 +57,7 @@ extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap) extern "C" DLL_EXPORT bool _dbg_memisvalidreadptr(duint addr) { - return MemIsValidReadPtr(addr); + return memisvalidreadptr(fdProcessInfo->hProcess, addr); } extern "C" DLL_EXPORT bool _dbg_valfromstring(const char* string, duint* value) @@ -69,7 +69,6 @@ extern "C" DLL_EXPORT bool _dbg_isdebugging() { if(IsFileBeingDebugged()) return true; - return false; } @@ -94,7 +93,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR bool retval = false; if(addrinfo->flags & flagmodule) //get module { - if(ModNameFromAddr(addr, addrinfo->module, false)) //get module name + if(modnamefromaddr(addr, addrinfo->module, false)) //get module name retval = true; } if(addrinfo->flags & flaglabel) @@ -122,7 +121,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR if(disasmfast(addr, &basicinfo) && basicinfo.branch && !basicinfo.call && basicinfo.memory.value) //thing is a JMP { uint val = 0; - if(MemRead((void*)basicinfo.memory.value, &val, sizeof(val), 0)) + if(memread(fdProcessInfo->hProcess, (const void*)basicinfo.memory.value, &val, sizeof(val), 0)) { if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)val, &displacement, pSymbol) and !displacement) { @@ -138,12 +137,12 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR } if(addrinfo->flags & flagbookmark) { - addrinfo->isbookmark = BookmarkGet(addr); + addrinfo->isbookmark = bookmarkget(addr); retval = true; } if(addrinfo->flags & flagfunction) { - if(FunctionGet(addr, &addrinfo->function.start, &addrinfo->function.end)) + if(functionget(addr, &addrinfo->function.start, &addrinfo->function.end)) retval = true; } if(addrinfo->flags & flagloop) @@ -154,7 +153,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR if(addrinfo->flags & flagcomment) { *addrinfo->comment = 0; - if(CommentGet(addr, addrinfo->comment)) + if(commentget(addr, addrinfo->comment)) retval = true; else { @@ -300,15 +299,15 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoset(duint addr, ADDRINFO* addrinfo) } if(addrinfo->flags & flagcomment) //set comment { - if(CommentSet(addr, addrinfo->comment, true)) + if(commentset(addr, addrinfo->comment, true)) retval = true; } if(addrinfo->flags & flagbookmark) //set bookmark { if(addrinfo->isbookmark) - retval = BookmarkSet(addr, true); + retval = bookmarkset(addr, true); else - retval = BookmarkDelete(addr); + retval = bookmarkdel(addr); } return retval; } @@ -318,20 +317,20 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr) static uint cacheAddr; static int cacheBpCount; static int cacheResult; - int bpcount = BpGetList(nullptr); + int bpcount = bpgetlist(0); if(cacheAddr != addr or cacheBpCount != bpcount) { BREAKPOINT bp; cacheAddr = addr; cacheResult = 0; cacheBpCount = bpcount; - if(BpGet(addr, BPNORMAL, 0, &bp)) + if(bpget(addr, BPNORMAL, 0, &bp)) if(bp.enabled) cacheResult |= bp_normal; - if(BpGet(addr, BPHARDWARE, 0, &bp)) + if(bpget(addr, BPHARDWARE, 0, &bp)) if(bp.enabled) cacheResult |= bp_hardware; - if(BpGet(addr, BPMEMORY, 0, &bp)) + if(bpget(addr, BPMEMORY, 0, &bp)) if(bp.enabled) cacheResult |= bp_memory; } @@ -504,7 +503,7 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap) if(!bpmap) return 0; std::vector list; - int bpcount = BpGetList(&list); + int bpcount = bpgetlist(&list); if(bpcount == 0) { bpmap->count = 0; @@ -567,7 +566,7 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap) curBp.addr = list[i].addr; curBp.enabled = list[i].enabled; //TODO: fix this - if(MemIsValidReadPtr(curBp.addr)) + if(memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr)) curBp.active = true; strcpy_s(curBp.mod, list[i].mod); strcpy_s(curBp.name, list[i].name); @@ -614,7 +613,7 @@ extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr) extern "C" DLL_EXPORT bool _dbg_functionoverlaps(uint start, uint end) { - return FunctionOverlaps(start, end); + return functionoverlaps(start, end); } extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* param2) @@ -690,7 +689,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_SYMBOL_ENUM: { SYMBOLCBINFO* cbInfo = (SYMBOLCBINFO*)param1; - SymEnum(cbInfo->base, cbInfo->cbSymbolEnum, cbInfo->user); + symenum(cbInfo->base, cbInfo->cbSymbolEnum, cbInfo->user); } break; @@ -702,7 +701,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_MODBASE_FROM_NAME: { - return ModBaseFromName((const char*)param1); + return modbasefromname((const char*)param1); } break; @@ -720,7 +719,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_GET_THREAD_LIST: { - ThreadGetList((THREADLIST*)param1); + threadgetlist((THREADLIST*)param1); } break; @@ -776,7 +775,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par if(!param1 or !param2) return 0; unsigned char data[16]; - if(!MemRead(param1, data, sizeof(data), 0)) + if(!memread(fdProcessInfo->hProcess, param1, data, sizeof(data), 0)) return 0; DISASM disasm; memset(&disasm, 0, sizeof(disasm)); @@ -805,28 +804,28 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_FUNCTION_GET: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)FunctionGet(info->addr, &info->start, &info->end); + return (uint)functionget(info->addr, &info->start, &info->end); } break; case DBG_FUNCTION_OVERLAPS: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)FunctionOverlaps(info->start, info->end); + return (uint)functionoverlaps(info->start, info->end); } break; case DBG_FUNCTION_ADD: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)FunctionAdd(info->start, info->end, info->manual); + return (uint)functionadd(info->start, info->end, info->manual); } break; case DBG_FUNCTION_DEL: { FUNCTION_LOOP_INFO* info = (FUNCTION_LOOP_INFO*)param1; - return (uint)FunctionDelete(info->addr); + return (uint)functiondel(info->addr); } break; @@ -867,7 +866,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_IS_BP_DISABLED: { BREAKPOINT bp; - if(BpGet((uint)param1, BPNORMAL, 0, &bp)) + if(bpget((uint)param1, BPNORMAL, 0, &bp)) return !(uint)bp.enabled; return (uint)false; } @@ -875,13 +874,13 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_SET_AUTO_COMMENT_AT: { - return (uint)CommentSet((uint)param1, (const char*)param2, false); + return (uint)commentset((uint)param1, (const char*)param2, false); } break; case DBG_DELETE_AUTO_COMMENT_RANGE: { - CommentDelRange((uint)param1, (uint)param2); + commentdelrange((uint)param1, (uint)param2); } break; @@ -899,25 +898,25 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par case DBG_SET_AUTO_BOOKMARK_AT: { - return (uint)BookmarkSet((uint)param1, false); + return (uint)bookmarkset((uint)param1, false); } break; case DBG_DELETE_AUTO_BOOKMARK_RANGE: { - BookmarkDelRange((uint)param1, (uint)param2); + bookmarkdelrange((uint)param1, (uint)param2); } break; case DBG_SET_AUTO_FUNCTION_AT: { - return (uint)FunctionAdd((uint)param1, (uint)param2, false); + return (uint)functionadd((uint)param1, (uint)param2, false); } break; case DBG_DELETE_AUTO_FUNCTION_RANGE: { - FunctionDelRange((uint)param1, (uint)param2); + functiondelrange((uint)param1, (uint)param2); } break; diff --git a/x64_dbg_dbg/_global.cpp b/x64_dbg_dbg/_global.cpp index 63822d1c..3e1fc67e 100644 --- a/x64_dbg_dbg/_global.cpp +++ b/x64_dbg_dbg/_global.cpp @@ -97,7 +97,9 @@ bool arraycontains(const char* cmd_list, const char* cmd) bool scmp(const char* a, const char* b) { - return _stricmp(a, b) == 0; + if(_stricmp(a, b)) + return false; + return true; } void formathex(char* string) diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index 54b7c1f4..60bf68f9 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -1,7 +1,7 @@ #ifndef _GLOBAL_H #define _GLOBAL_H -#define _WIN32_WINNT 0x0600 +#define _WIN32_WINNT 0x0501 #define WINVER 0x0501 #define _WIN32_IE 0x0500 @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "..\x64_dbg_bridge\bridgemain.h" #include "jansson\jansson.h" @@ -52,6 +51,42 @@ typedef unsigned long uint; typedef long sint; #endif // _WIN64 +enum BITMASK +{ + BIT1 = 0x1, + BIT2 = 0x2, + BIT3 = 0x4, + BIT4 = 0x8, + BIT5 = 0x10, + BIT6 = 0x20, + BIT7 = 0x40, + BIT8 = 0x80, + BIT9 = 0x100, + BIT10 = 0x200, + BIT11 = 0x400, + BIT12 = 0x800, + BIT13 = 0x1000, + BIT14 = 0x2000, + BIT15 = 0x4000, + BIT16 = 0x8000, + BIT17 = 0x10000, + BIT18 = 0x20000, + BIT19 = 0x40000, + BIT20 = 0x80000, + BIT21 = 0x100000, + BIT22 = 0x200000, + BIT23 = 0x400000, + BIT24 = 0x800000, + BIT25 = 0x1000000, + BIT26 = 0x2000000, + BIT27 = 0x4000000, + BIT28 = 0x8000000, + BIT29 = 0x10000000, + BIT30 = 0x20000000, + BIT31 = 0x40000000, + BIT32 = 0x80000000 +}; + enum arch { notfound, diff --git a/x64_dbg_dbg/addrinfo.cpp b/x64_dbg_dbg/addrinfo.cpp index f8fba9e9..b49f2d87 100644 --- a/x64_dbg_dbg/addrinfo.cpp +++ b/x64_dbg_dbg/addrinfo.cpp @@ -21,12 +21,12 @@ void dbsave() dprintf("saving database..."); DWORD ticks = GetTickCount(); JSON root = json_object(); - CommentCacheSave(root); + commentcachesave(root); labelcachesave(root); - BookmarkCacheSave(root); - FunctionCacheSave(root); + bookmarkcachesave(root); + functioncachesave(root); loopcachesave(root); - BpCacheSave(root); + bpcachesave(root); WString wdbpath = StringUtils::Utf8ToUtf16(dbpath); if(json_object_size(root)) { @@ -68,7 +68,7 @@ void dbload() return; } FILE* jsonFile = 0; - if(_wfopen_s(&jsonFile, wdbpath.c_str(), L"rb") != 0) + if(_wfopen_s(&jsonFile, wdbpath.c_str(), L"rb")) { dputs("\nfailed to open database file!"); return; @@ -82,12 +82,12 @@ void dbload() dputs("\ninvalid database file (JSON)!"); return; } - CommentCacheLoad(root); + commentcacheload(root); labelcacheload(root); - BookmarkCacheLoad(root); - FunctionCacheLoad(root); + bookmarkcacheload(root); + functioncacheload(root); loopcacheload(root); - BpCacheLoad(root); + bpcacheload(root); json_decref(root); //free root dprintf("%ums\n", GetTickCount() - ticks); } @@ -95,12 +95,12 @@ void dbload() void dbclose() { dbsave(); - CommentClear(); + commentclear(); labelclear(); - BookmarkClear(); - FunctionClear(); + bookmarkclear(); + functionclear(); loopclear(); - BpClear(); + bpclear(); patchclear(); } @@ -111,44 +111,44 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum) VirtualQueryEx(fdProcessInfo->hProcess, (const void*)base, &mbi, sizeof(mbi)); uint size = mbi.RegionSize; Memory buffer(size, "apienumexports:buffer"); - if(!MemRead((void*)base, buffer, size, 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)base, buffer, size, 0)) return false; IMAGE_NT_HEADERS* pnth = (IMAGE_NT_HEADERS*)((uint)buffer + GetPE32DataFromMappedFile((ULONG_PTR)buffer, 0, UE_PE_OFFSET)); uint export_dir_rva = pnth->OptionalHeader.DataDirectory[0].VirtualAddress; uint export_dir_size = pnth->OptionalHeader.DataDirectory[0].Size; IMAGE_EXPORT_DIRECTORY export_dir; memset(&export_dir, 0, sizeof(export_dir)); - MemRead((void*)(export_dir_rva + base), &export_dir, sizeof(export_dir), 0); + memread(fdProcessInfo->hProcess, (const void*)(export_dir_rva + base), &export_dir, sizeof(export_dir), 0); unsigned int NumberOfNames = export_dir.NumberOfNames; if(!export_dir.NumberOfFunctions or !NumberOfNames) //no named exports return false; char modname[MAX_MODULE_SIZE] = ""; - ModNameFromAddr(base, modname, true); + modnamefromaddr(base, modname, true); uint original_name_va = export_dir.Name + base; char original_name[deflen] = ""; memset(original_name, 0, sizeof(original_name)); - MemRead((void*)original_name_va, original_name, deflen, 0); + memread(fdProcessInfo->hProcess, (const void*)original_name_va, original_name, deflen, 0); char* AddrOfFunctions_va = (char*)(export_dir.AddressOfFunctions + base); char* AddrOfNames_va = (char*)(export_dir.AddressOfNames + base); char* AddrOfNameOrdinals_va = (char*)(export_dir.AddressOfNameOrdinals + base); for(DWORD i = 0; i < NumberOfNames; i++) { DWORD curAddrOfName = 0; - MemRead(AddrOfNames_va + sizeof(DWORD)*i, &curAddrOfName, sizeof(DWORD), 0); + memread(fdProcessInfo->hProcess, AddrOfNames_va + sizeof(DWORD)*i, &curAddrOfName, sizeof(DWORD), 0); char* cur_name_va = (char*)(curAddrOfName + base); char cur_name[deflen] = ""; memset(cur_name, 0, deflen); - MemRead(cur_name_va, cur_name, deflen, 0); + memread(fdProcessInfo->hProcess, cur_name_va, cur_name, deflen, 0); WORD curAddrOfNameOrdinals = 0; - MemRead(AddrOfNameOrdinals_va + sizeof(WORD)*i, &curAddrOfNameOrdinals, sizeof(WORD), 0); + memread(fdProcessInfo->hProcess, AddrOfNameOrdinals_va + sizeof(WORD)*i, &curAddrOfNameOrdinals, sizeof(WORD), 0); DWORD curFunctionRva = 0; - MemRead(AddrOfFunctions_va + sizeof(DWORD)*curAddrOfNameOrdinals, &curFunctionRva, sizeof(DWORD), 0); + memread(fdProcessInfo->hProcess, AddrOfFunctions_va + sizeof(DWORD)*curAddrOfNameOrdinals, &curFunctionRva, sizeof(DWORD), 0); if(curFunctionRva >= export_dir_rva and curFunctionRva < export_dir_rva + export_dir_size) { char forwarded_api[deflen] = ""; memset(forwarded_api, 0, deflen); - MemRead((void*)(curFunctionRva + base), forwarded_api, deflen, 0); + memread(fdProcessInfo->hProcess, (void*)(curFunctionRva + base), forwarded_api, deflen, 0); int len = (int)strlen(forwarded_api); int j = 0; while(forwarded_api[j] != '.' and j < len) diff --git a/x64_dbg_dbg/assemble.cpp b/x64_dbg_dbg/assemble.cpp index a8389045..6c6f1f11 100644 --- a/x64_dbg_dbg/assemble.cpp +++ b/x64_dbg_dbg/assemble.cpp @@ -67,12 +67,12 @@ bool assembleat(uint addr, const char* instruction, int* size, char* error, bool if(size) *size = destSize; - bool ret = MemPatch((void*)addr, dest, destSize, 0); + bool ret = mempatch(fdProcessInfo->hProcess, (void*)addr, dest, destSize, 0); if(ret && fillnop && nopsize) { if(size) *size += nopsize; - if(!MemPatch((void*)(addr + destSize), nops, nopsize, 0)) + if(!mempatch(fdProcessInfo->hProcess, (void*)(addr + destSize), nops, nopsize, 0)) ret = false; } GuiUpdatePatches(); diff --git a/x64_dbg_dbg/bookmark.cpp b/x64_dbg_dbg/bookmark.cpp index 1669d3df..7f66977d 100644 --- a/x64_dbg_dbg/bookmark.cpp +++ b/x64_dbg_dbg/bookmark.cpp @@ -4,206 +4,159 @@ #include "debugger.h" #include "memory.h" -typedef std::unordered_map BookmarksInfo; +typedef std::map BookmarksInfo; static BookmarksInfo bookmarks; -bool BookmarkSet(uint Address, bool Manual) +bool bookmarkset(uint addr, bool manual) { - // CHECK: Export call - if(!DbgIsDebugging()) + if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr)) return false; - - // Validate the incoming address - if(!MemIsValidReadPtr(Address)) - return false; - BOOKMARKSINFO bookmark; - ModNameFromAddr(Address, bookmark.mod, true); - bookmark.addr = Address; - bookmark.manual = Manual; - - // Exclusive lock to insert new data - EXCLUSIVE_ACQUIRE(LockBookmarks); - - if(!bookmarks.insert(std::make_pair(Address, bookmark)).second) - return BookmarkDelete(Address); - + modnamefromaddr(addr, bookmark.mod, true); + bookmark.addr = addr - modbasefromaddr(addr); + bookmark.manual = manual; + CriticalSectionLocker locker(LockBookmarks); + if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second) + return bookmarkdel(addr); return true; } -bool BookmarkGet(uint Address) +bool bookmarkget(uint addr) { - // CHECK: Export call if(!DbgIsDebugging()) return false; - - SHARED_ACQUIRE(LockBookmarks); - return (bookmarks.count(Address) > 0); + CriticalSectionLocker locker(LockBookmarks); + if(bookmarks.count(modhashfromva(addr))) + return true; + return false; } -bool BookmarkDelete(uint Address) +bool bookmarkdel(uint addr) { - // CHECK: Export call if(!DbgIsDebugging()) return false; - - EXCLUSIVE_ACQUIRE(LockBookmarks); - return (bookmarks.erase(Address) > 0); + CriticalSectionLocker locker(LockBookmarks); + return (bookmarks.erase(modhashfromva(addr)) > 0); } -void BookmarkDelRange(uint Start, uint End) +void bookmarkdelrange(uint start, uint end) { - // CHECK: Export call if(!DbgIsDebugging()) return; - - // Are all bookmarks going to be deleted? - // 0x00000000 - 0xFFFFFFFF - if(Start == 0 && End == ~0) + bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) + return; + start -= modbase; + end -= modbase; + CriticalSectionLocker locker(LockBookmarks); + BookmarksInfo::iterator i = bookmarks.begin(); + while(i != bookmarks.end()) { - EXCLUSIVE_ACQUIRE(LockBookmarks); - bookmarks.clear(); - } - else - { - // Make sure 'Start' and 'End' reference the same module - uint moduleBase = ModBaseFromAddr(Start); - - if(moduleBase != ModBaseFromAddr(End)) - return; - - EXCLUSIVE_ACQUIRE(LockBookmarks); - for(auto itr = bookmarks.begin(); itr != bookmarks.end();) + if(i->second.manual) //ignore manual { - // Ignore manually set entries - if(itr->second.manual) - { - itr++; - continue; - } - - // [Start, End) - if(itr->second.addr >= Start && itr->second.addr < End) - itr = bookmarks.erase(itr); - else - itr++; + i++; + continue; } - } -} - -void BookmarkCacheSave(JSON Root) -{ - EXCLUSIVE_ACQUIRE(LockBookmarks); - - const JSON jsonBookmarks = json_array(); - const JSON jsonAutoBookmarks = json_array(); - - // Save to the JSON root - for(auto & itr : bookmarks) - { - JSON currentBookmark = json_object(); - - // The address must be adjusted to use an offset - // OFFSET = ADDRESS - MOD_BASE - uint virtualOffset = itr.second.addr - ModBaseFromAddr(itr.second.addr); - - json_object_set_new(currentBookmark, "module", json_string(itr.second.mod)); - json_object_set_new(currentBookmark, "address", json_hex(virtualOffset)); - - if(itr.second.manual) - json_array_append_new(jsonBookmarks, currentBookmark); + if(bDelAll || (i->second.addr >= start && i->second.addr < end)) + bookmarks.erase(i++); else - json_array_append_new(jsonAutoBookmarks, currentBookmark); + i++; } - - if(json_array_size(jsonBookmarks)) - json_object_set(Root, "bookmarks", jsonBookmarks); - - if(json_array_size(jsonAutoBookmarks)) - json_object_set(Root, "autobookmarks", jsonAutoBookmarks); - - json_decref(jsonBookmarks); - json_decref(jsonAutoBookmarks); } -void BookmarkCacheLoad(JSON Root) +void bookmarkcachesave(JSON root) { - EXCLUSIVE_ACQUIRE(LockBookmarks); + CriticalSectionLocker locker(LockBookmarks); + const JSON jsonbookmarks = json_array(); + const JSON jsonautobookmarks = json_array(); + for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i) + { + const BOOKMARKSINFO curBookmark = i->second; + JSON curjsonbookmark = json_object(); + json_object_set_new(curjsonbookmark, "module", json_string(curBookmark.mod)); + json_object_set_new(curjsonbookmark, "address", json_hex(curBookmark.addr)); + if(curBookmark.manual) + json_array_append_new(jsonbookmarks, curjsonbookmark); + else + json_array_append_new(jsonautobookmarks, curjsonbookmark); + } + if(json_array_size(jsonbookmarks)) + json_object_set(root, "bookmarks", jsonbookmarks); + json_decref(jsonbookmarks); + if(json_array_size(jsonautobookmarks)) + json_object_set(root, "autobookmarks", jsonautobookmarks); + json_decref(jsonautobookmarks); +} - // Inline lambda to parse each JSON entry - auto AddBookmarks = [](const JSON Object, bool Manual) +void bookmarkcacheload(JSON root) +{ + CriticalSectionLocker locker(LockBookmarks); + bookmarks.clear(); + const JSON jsonbookmarks = json_object_get(root, "bookmarks"); + if(jsonbookmarks) { size_t i; JSON value; - - json_array_foreach(Object, i, value) + json_array_foreach(jsonbookmarks, i, value) { - BOOKMARKSINFO bookmarkInfo; - memset(&bookmarkInfo, 0, sizeof(BOOKMARKSINFO)); - - // Load the module name + BOOKMARKSINFO curBookmark; const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(bookmarkInfo.mod, mod); - - // Load address and set auto-generated flag - bookmarkInfo.addr = (uint)json_hex_value(json_object_get(value, "address")); - bookmarkInfo.manual = Manual; - - // The offset must be adjusted to use virtual addressing - // ADDRESS = OFFSET + MOD_BASE - bookmarkInfo.addr += ModBaseFromName(bookmarkInfo.mod); - - bookmarks.insert(std::make_pair(bookmarkInfo.addr, bookmarkInfo)); + strcpy_s(curBookmark.mod, mod); + else + *curBookmark.mod = '\0'; + curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); + curBookmark.manual = true; + const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; + bookmarks.insert(std::make_pair(key, curBookmark)); } - }; - - // Remove existing entries - bookmarks.clear(); - - const JSON jsonBookmarks = json_object_get(Root, "bookmarks"); - const JSON jsonAutoBookmarks = json_object_get(Root, "autobookmarks"); - - // Load user-set bookmarks - if(jsonBookmarks) - AddBookmarks(jsonBookmarks, true); - - // Load auto-set bookmarks - if(jsonAutoBookmarks) - AddBookmarks(jsonAutoBookmarks, false); + } + JSON jsonautobookmarks = json_object_get(root, "autobookmarks"); + if(jsonautobookmarks) + { + size_t i; + JSON value; + json_array_foreach(jsonautobookmarks, i, value) + { + BOOKMARKSINFO curBookmark; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy_s(curBookmark.mod, mod); + else + *curBookmark.mod = '\0'; + curBookmark.addr = (uint)json_hex_value(json_object_get(value, "address")); + curBookmark.manual = false; + const uint key = modhashfromname(curBookmark.mod) + curBookmark.addr; + bookmarks.insert(std::make_pair(key, curBookmark)); + } + } } -bool BookmarkEnum(BOOKMARKSINFO* List, size_t* Size) +bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize) { - // The array container must be set, or the size must be set, or both - if(!List && !Size) + if(!DbgIsDebugging()) return false; - - SHARED_ACQUIRE(LockBookmarks); - - // Return the size if set - if(Size) + if(!bookmarklist && !cbsize) + return false; + CriticalSectionLocker locker(LockBookmarks); + if(!bookmarklist && cbsize) { - *Size = bookmarks.size() * sizeof(BOOKMARKSINFO); - - if(!List) - return true; + *cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO); + return true; } - - // Copy struct over - for(auto & itr : bookmarks) + int j = 0; + for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i, j++) { - *List = itr.second; - List++; + bookmarklist[j] = i->second; + bookmarklist[j].addr += modbasefromname(bookmarklist[j].mod); } - return true; } -void BookmarkClear() +void bookmarkclear() { - EXCLUSIVE_ACQUIRE(LockBookmarks); - bookmarks.clear(); + CriticalSectionLocker locker(LockBookmarks); + BookmarksInfo().swap(bookmarks); } \ No newline at end of file diff --git a/x64_dbg_dbg/bookmark.h b/x64_dbg_dbg/bookmark.h index a6898ddc..1ee9ee82 100644 --- a/x64_dbg_dbg/bookmark.h +++ b/x64_dbg_dbg/bookmark.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _BOOKMARK_H +#define _BOOKMARK_H #include "_global.h" @@ -9,11 +10,13 @@ struct BOOKMARKSINFO bool manual; }; -bool BookmarkSet(uint Address, bool Manual); -bool BookmarkGet(uint Address); -bool BookmarkDelete(uint Address); -void BookmarkDelRange(uint Start, uint End); -void BookmarkCacheSave(JSON Root); -void BookmarkCacheLoad(JSON Root); -bool BookmarkEnum(BOOKMARKSINFO* List, size_t* Size); -void BookmarkClear(); \ No newline at end of file +bool bookmarkset(uint addr, bool manual); +bool bookmarkget(uint addr); +bool bookmarkdel(uint addr); +void bookmarkdelrange(uint start, uint end); +void bookmarkcachesave(JSON root); +void bookmarkcacheload(JSON root); +bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize); +void bookmarkclear(); + +#endif //_BOOKMARK_H \ No newline at end of file diff --git a/x64_dbg_dbg/breakpoint.cpp b/x64_dbg_dbg/breakpoint.cpp index c5447e86..f673d0f1 100644 --- a/x64_dbg_dbg/breakpoint.cpp +++ b/x64_dbg_dbg/breakpoint.cpp @@ -11,385 +11,266 @@ typedef std::map BreakpointsInfo; static BreakpointsInfo breakpoints; -BREAKPOINT* BpInfoFromAddr(BP_TYPE Type, uint Address) -{ - // - // NOTE: THIS DOES _NOT_ USE LOCKS - // - auto found = breakpoints.find(BreakpointKey(Type, ModHashFromAddr(Address))); - - // Was the module found with this address? - if(found == breakpoints.end()) - return nullptr; - - return &found->second; -} - -int BpGetList(std::vector* List) -{ - // CHECK: Exported function - if(!DbgIsDebugging()) - return false; - - SHARED_ACQUIRE(LockBreakpoints); - - // Did the caller request an output? - if(List) - { - // Enumerate all breakpoints in the global list, fixing the relative - // offset to a virtual address - for(auto & i : breakpoints) - { - BREAKPOINT currentBp = i.second; - currentBp.addr += ModBaseFromName(currentBp.mod); - currentBp.active = MemIsValidReadPtr(currentBp.addr); - - List->push_back(currentBp); - } - } - - return (int)breakpoints.size(); -} - -bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name) -{ - // CHECK: Command function - if(!DbgIsDebugging()) - return false; - - // Fail if the address is a bad memory region - if(!MemIsValidReadPtr(Address)) - return false; - - // Fail if the breakpoint already exists - if(BpGet(Address, Type, Name, nullptr)) - return false; - - // Default to an empty name if one wasn't supplied - if(!Name) - Name = ""; - - BREAKPOINT bp; - memset(&bp, 0, sizeof(BREAKPOINT)); - - ModNameFromAddr(Address, bp.mod, true); - strcpy_s(bp.name, Name); - - bp.active = true; - bp.addr = Address - ModBaseFromAddr(Address); - bp.enabled = Enable; - bp.oldbytes = OldBytes; - bp.singleshoot = Singleshot; - bp.titantype = TitanType; - bp.type = Type; - - // Insert new entry to the global list - EXCLUSIVE_ACQUIRE(LockBreakpoints); - - breakpoints.insert(std::make_pair(BreakpointKey(Type, ModHashFromAddr(Address)), bp)); - return true; -} - -bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp) -{ - // CHECK: Export/Command function - if(!DbgIsDebugging()) - return false; - - SHARED_ACQUIRE(LockBreakpoints); - - // Name is optional - if(!Name || Name[0] == '\0') - { - // Perform a lookup by address only - BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); - - if(!bpInfo) - return false; - - // Succeed even if the user didn't request anything - if(!Bp) - return true; - - *Bp = *bpInfo; - Bp->addr += ModBaseFromAddr(Address); - Bp->active = MemIsValidReadPtr(Bp->addr); - return true; - } - - // Do a lookup by breakpoint name - for(auto & i : breakpoints) - { - // Do the names match? - if(strcmp(Name, i.second.name) != 0) - continue; - - // Fill out the optional user buffer - if(Bp) - { - *Bp = i.second; - Bp->addr += ModBaseFromAddr(Address); - Bp->active = MemIsValidReadPtr(Bp->addr); - } - - // Return true if the name was found at all - return true; - } - - return false; -} - -bool BpDelete(uint Address, BP_TYPE Type) -{ - // CHECK: Command function - if(!DbgIsDebugging()) - return false; - - // Erase the index from the global list - EXCLUSIVE_ACQUIRE(LockBreakpoints); - - return (breakpoints.erase(BreakpointKey(Type, ModHashFromAddr(Address))) > 0); -} - -bool BpEnable(uint Address, BP_TYPE Type, bool Enable) -{ - // CHECK: Command function - if(!DbgIsDebugging()) - return false; - - EXCLUSIVE_ACQUIRE(LockBreakpoints); - - // Check if the breakpoint exists first - BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); - - if(!bpInfo) - return false; - - bpInfo->enabled = Enable; - return true; -} - -bool BpSetName(uint Address, BP_TYPE Type, const char* Name) -{ - // CHECK: Future(?); This is not used anywhere - if(!DbgIsDebugging()) - return false; - - // If a name wasn't supplied, set to nothing - if(!Name) - Name = ""; - - EXCLUSIVE_ACQUIRE(LockBreakpoints); - - // Check if the breakpoint exists first - BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); - - if(!bpInfo) - return false; - - strcpy_s(bpInfo->name, Name); - return true; -} - -bool BpSetTitanType(uint Address, BP_TYPE Type, int TitanType) -{ - // CHECK: Command function - if(!DbgIsDebugging()) - return false; - - EXCLUSIVE_ACQUIRE(LockBreakpoints); - - // Set the TitanEngine type, separate from BP_TYPE - BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address); - - if(!bpInfo) - return false; - - bpInfo->titantype = TitanType; - return true; -} - -bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module) +int bpgetlist(std::vector* list) { if(!DbgIsDebugging()) return false; - - SHARED_ACQUIRE(LockBreakpoints); - - // Loop each entry, executing the user's callback - bool callbackStatus = false; - - for(auto & i : breakpoints) - { - // If a module name was sent, check it - if(Module && Module[0] != '\0') - { - if(strcmp(i.second.mod, Module) != 0) - continue; - } - - BREAKPOINT bpInfo = i.second; - bpInfo.addr += ModBaseFromName(bpInfo.mod); - bpInfo.active = MemIsValidReadPtr(bpInfo.addr); - - // Execute the callback - if(!EnumCallback(&bpInfo)) - callbackStatus = false; - } - - return callbackStatus; -} - -bool BpEnumAll(BPENUMCALLBACK EnumCallback) -{ - return BpEnumAll(EnumCallback, nullptr); -} - -int BpGetCount(BP_TYPE Type, bool EnabledOnly) -{ - SHARED_ACQUIRE(LockBreakpoints); - - // Count the number of enabled/disabled breakpoint types + BREAKPOINT curBp; int count = 0; - - for(auto & i : breakpoints) + CriticalSectionLocker locker(LockBreakpoints); + for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) { - // Check if the type matches - if(i.first.first != Type) - continue; - - // If it's not enabled, skip it - if(EnabledOnly && !i.second.enabled) - continue; - + curBp = i->second; + curBp.addr += modbasefromname(curBp.mod); + curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); count++; + if(list) + list->push_back(curBp); } - return count; } -void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp) +bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name) { - // - // Convert a debugger breakpoint to an open/exported - // bridge breakpoint - // - // TOOD: ASSERT(?) These should never be null - if(!Bp || !BridgeBp) + if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or bpget(addr, type, name, 0)) + return false; + BREAKPOINT bp; + modnamefromaddr(addr, bp.mod, true); + uint modbase = modbasefromaddr(addr); + bp.active = true; + bp.addr = addr - modbase; + bp.enabled = enabled; + if(name and * name) + strcpy_s(bp.name, name); + else + *bp.name = '\0'; + bp.oldbytes = oldbytes; + bp.singleshoot = singleshoot; + bp.titantype = titantype; + bp.type = type; + CriticalSectionLocker locker(LockBreakpoints); + breakpoints.insert(std::make_pair(BreakpointKey(type, modhashfromva(addr)), bp)); + return true; +} + +bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp) +{ + if(!DbgIsDebugging()) + return false; + BREAKPOINT curBp; + CriticalSectionLocker locker(LockBreakpoints); + if(!name) + { + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + if(found == breakpoints.end()) //not found + return false; + if(!bp) + return true; + curBp = found->second; + curBp.addr += modbasefromaddr(addr); + curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); + *bp = curBp; + return true; + } + for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) + { + curBp = i->second; + if(name and * name) + { + if(!strcmp(name, curBp.name)) + { + if(bp) + { + curBp.addr += modbasefromname(curBp.mod); + curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); + *bp = curBp; + } + return true; + } + } + } + return false; +} + +bool bpdel(uint addr, BP_TYPE type) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockBreakpoints); + return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0); +} + +bool bpenable(uint addr, BP_TYPE type, bool enable) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockBreakpoints); + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + if(found == breakpoints.end()) //not found + return false; + breakpoints[found->first].enabled = enable; + return true; +} + +bool bpsetname(uint addr, BP_TYPE type, const char* name) +{ + if(!DbgIsDebugging() or !name or !*name) + return false; + CriticalSectionLocker locker(LockBreakpoints); + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + if(found == breakpoints.end()) //not found + return false; + strcpy_s(breakpoints[found->first].name, name); + return true; +} + +bool bpsettitantype(uint addr, BP_TYPE type, int titantype) +{ + if(!DbgIsDebugging()) + return false; + CriticalSectionLocker locker(LockBreakpoints); + BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr))); + if(found == breakpoints.end()) //not found + return false; + breakpoints[found->first].titantype = titantype; + return true; +} + +bool bpenumall(BPENUMCALLBACK cbEnum, const char* module) +{ + if(!DbgIsDebugging()) + return false; + bool retval = true; + BREAKPOINT curBp; + CriticalSectionLocker locker(LockBreakpoints); + BreakpointsInfo::iterator i = breakpoints.begin(); + while(i != breakpoints.end()) + { + BreakpointsInfo::iterator j = i; + ++i; + curBp = j->second; + curBp.addr += modbasefromname(curBp.mod); //RVA to VA + curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing? + if(module and * module) + { + if(!strcmp(curBp.mod, module)) + { + if(!cbEnum(&curBp)) + retval = false; + } + } + else + { + if(!cbEnum(&curBp)) + retval = false; + } + } + return retval; +} + +bool bpenumall(BPENUMCALLBACK cbEnum) +{ + return bpenumall(cbEnum, 0); +} + +int bpgetcount(BP_TYPE type, bool enabledonly) +{ + int count = 0; + CriticalSectionLocker locker(LockBreakpoints); + for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) + { + if(i->first.first == type && (!enabledonly || i->second.enabled)) + count++; + } + return count; +} + +void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge) +{ + if(!bp or !bridge) return; - - memset(BridgeBp, 0, sizeof(BRIDGEBP)); - strcpy_s(BridgeBp->mod, Bp->mod); - strcpy_s(BridgeBp->name, Bp->name); - - BridgeBp->active = Bp->active; - BridgeBp->addr = Bp->addr; - BridgeBp->enabled = Bp->enabled; - BridgeBp->singleshoot = Bp->singleshoot; - - switch(Bp->type) + memset(bridge, 0, sizeof(BRIDGEBP)); + bridge->active = bp->active; + bridge->addr = bp->addr; + bridge->enabled = bp->enabled; + strcpy_s(bridge->mod, bp->mod); + strcpy_s(bridge->name, bp->name); + bridge->singleshoot = bp->singleshoot; + switch(bp->type) { case BPNORMAL: - BridgeBp->type = bp_normal; + bridge->type = bp_normal; break; case BPHARDWARE: - BridgeBp->type = bp_hardware; + bridge->type = bp_hardware; break; case BPMEMORY: - BridgeBp->type = bp_memory; - break; + bridge->type = bp_memory; + break; //so that's why it didn't show in the gui. default: - BridgeBp->type = bp_none; + bridge->type = bp_none; break; } } -void BpCacheSave(JSON Root) +void bpcachesave(JSON root) { - EXCLUSIVE_ACQUIRE(LockBreakpoints); - - // Create a JSON array to store each sub-object with a breakpoint - const JSON jsonBreakpoints = json_array(); - - // Loop all breakpoints - for(auto & i : breakpoints) + CriticalSectionLocker locker(LockBreakpoints); + const JSON jsonbreakpoints = json_array(); + for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i) { - auto & breakpoint = i.second; - - // Ignore single-shot breakpoints - if(breakpoint.singleshoot) - continue; - - JSON jsonObj = json_object(); - json_object_set_new(jsonObj, "address", json_hex(breakpoint.addr)); - json_object_set_new(jsonObj, "enabled", json_boolean(breakpoint.enabled)); - - // "Normal" breakpoints save the old data - if(breakpoint.type == BPNORMAL) - json_object_set_new(jsonObj, "oldbytes", json_hex(breakpoint.oldbytes)); - - json_object_set_new(jsonObj, "type", json_integer(breakpoint.type)); - json_object_set_new(jsonObj, "titantype", json_hex(breakpoint.titantype)); - json_object_set_new(jsonObj, "name", json_string(breakpoint.name)); - json_object_set_new(jsonObj, "module", json_string(breakpoint.mod)); - json_array_append_new(jsonBreakpoints, jsonObj); + const BREAKPOINT curBreakpoint = i->second; + if(curBreakpoint.singleshoot) + continue; //skip + JSON curjsonbreakpoint = json_object(); + json_object_set_new(curjsonbreakpoint, "address", json_hex(curBreakpoint.addr)); + json_object_set_new(curjsonbreakpoint, "enabled", json_boolean(curBreakpoint.enabled)); + if(curBreakpoint.type == BPNORMAL) + json_object_set_new(curjsonbreakpoint, "oldbytes", json_hex(curBreakpoint.oldbytes)); + json_object_set_new(curjsonbreakpoint, "type", json_integer(curBreakpoint.type)); + json_object_set_new(curjsonbreakpoint, "titantype", json_hex(curBreakpoint.titantype)); + json_object_set_new(curjsonbreakpoint, "name", json_string(curBreakpoint.name)); + json_object_set_new(curjsonbreakpoint, "module", json_string(curBreakpoint.mod)); + json_array_append_new(jsonbreakpoints, curjsonbreakpoint); } - - if(json_array_size(jsonBreakpoints)) - json_object_set(Root, "breakpoints", jsonBreakpoints); - - // Notify garbage collector - json_decref(jsonBreakpoints); + if(json_array_size(jsonbreakpoints)) + json_object_set(root, "breakpoints", jsonbreakpoints); + json_decref(jsonbreakpoints); } -void BpCacheLoad(JSON Root) +void bpcacheload(JSON root) { - EXCLUSIVE_ACQUIRE(LockBreakpoints); - - // Remove all existing elements + CriticalSectionLocker locker(LockBreakpoints); breakpoints.clear(); - - // Get a handle to the root object -> breakpoints subtree - const JSON jsonBreakpoints = json_object_get(Root, "breakpoints"); - - // Return if there was nothing to load - if(!jsonBreakpoints) - return; - - size_t i; - JSON value; - json_array_foreach(jsonBreakpoints, i, value) + const JSON jsonbreakpoints = json_object_get(root, "breakpoints"); + if(jsonbreakpoints) { - BREAKPOINT breakpoint; - memset(&breakpoint, 0, sizeof(BREAKPOINT)); - - if(breakpoint.type == BPNORMAL) - breakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes")); - breakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type")); - breakpoint.addr = (uint)json_hex_value(json_object_get(value, "address")); - breakpoint.enabled = json_boolean_value(json_object_get(value, "enabled")); - breakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype")); - - // Name - const char* name = json_string_value(json_object_get(value, "name")); - - if(name) - strcpy_s(breakpoint.name, name); - - // Module - const char* mod = json_string_value(json_object_get(value, "module")); - - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(breakpoint.mod, mod); - - // Build the hash map key: MOD_HASH + ADDRESS - const uint key = ModHashFromName(breakpoint.mod) + breakpoint.addr; - breakpoints.insert(std::make_pair(BreakpointKey(breakpoint.type, key), breakpoint)); + size_t i; + JSON value; + json_array_foreach(jsonbreakpoints, i, value) + { + BREAKPOINT curBreakpoint; + memset(&curBreakpoint, 0, sizeof(BREAKPOINT)); + curBreakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type")); + if(curBreakpoint.type == BPNORMAL) + curBreakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes")); + curBreakpoint.addr = (uint)json_hex_value(json_object_get(value, "address")); + curBreakpoint.enabled = json_boolean_value(json_object_get(value, "enabled")); + curBreakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype")); + const char* name = json_string_value(json_object_get(value, "name")); + if(name) + strcpy_s(curBreakpoint.name, name); + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy_s(curBreakpoint.mod, mod); + const uint key = modhashfromname(curBreakpoint.mod) + curBreakpoint.addr; + breakpoints.insert(std::make_pair(BreakpointKey(curBreakpoint.type, key), curBreakpoint)); + } } } -void BpClear() +void bpclear() { - EXCLUSIVE_ACQUIRE(LockBreakpoints); - breakpoints.clear(); + CriticalSectionLocker locker(LockBreakpoints); + BreakpointsInfo().swap(breakpoints); } \ No newline at end of file diff --git a/x64_dbg_dbg/breakpoint.h b/x64_dbg_dbg/breakpoint.h index d9806102..bda1828c 100644 --- a/x64_dbg_dbg/breakpoint.h +++ b/x64_dbg_dbg/breakpoint.h @@ -1,8 +1,10 @@ -#pragma once +#ifndef _BREAKPOINT_H +#define _BREAKPOINT_H #include "_global.h" #include "TitanEngine\TitanEngine.h" +//macros #define TITANSETDRX(titantype, drx) titantype &= 0x0FF; titantype |= (drx<<8) #define TITANGETDRX(titantype) (titantype >> 8) & 0xF #define TITANSETTYPE(titantype, type) titantype &= 0xF0F; titantype |= (type<<4) @@ -10,6 +12,7 @@ #define TITANSETSIZE(titantype, size) titantype &= 0xFF0; titantype |= size; #define TITANGETSIZE(titantype) titantype & 0xF +//enums enum BP_TYPE { BPNORMAL = 0, @@ -17,6 +20,7 @@ enum BP_TYPE BPMEMORY = 2 }; +//structs struct BREAKPOINT { uint addr; @@ -30,21 +34,23 @@ struct BREAKPOINT char mod[MAX_MODULE_SIZE]; }; -// Breakpoint enumeration callback +//typedefs typedef bool (*BPENUMCALLBACK)(const BREAKPOINT* bp); -BREAKPOINT* BpInfoFromAddr(BP_TYPE Type, uint Address); -int BpGetList(std::vector* List); -bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name); -bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp); -bool BpDelete(uint Address, BP_TYPE Type); -bool BpEnable(uint Address, BP_TYPE Type, bool Enable); -bool BpSetName(uint Address, BP_TYPE Type, const char* Name); -bool BpSetTitanType(uint Address, BP_TYPE Type, int TitanType); -bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module); -bool BpEnumAll(BPENUMCALLBACK EnumCallback); -int BpGetCount(BP_TYPE Type, bool EnabledOnly = false); -void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp); -void BpCacheSave(JSON Root); -void BpCacheLoad(JSON Root); -void BpClear(); \ No newline at end of file +//functions +int bpgetlist(std::vector* list); +bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name); +bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp); +bool bpdel(uint addr, BP_TYPE type); +bool bpenable(uint addr, BP_TYPE type, bool enable); +bool bpsetname(uint addr, BP_TYPE type, const char* name); +bool bpsettitantype(uint addr, BP_TYPE type, int titantype); +bool bpenumall(BPENUMCALLBACK cbEnum); +bool bpenumall(BPENUMCALLBACK cbEnum, const char* module); +int bpgetcount(BP_TYPE type, bool enabledonly = false); +void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge); +void bpcachesave(JSON root); +void bpcacheload(JSON root); +void bpclear(); + +#endif // _BREAKPOINT_H diff --git a/x64_dbg_dbg/comment.cpp b/x64_dbg_dbg/comment.cpp index 704cb83e..ab9c1db8 100644 --- a/x64_dbg_dbg/comment.cpp +++ b/x64_dbg_dbg/comment.cpp @@ -4,245 +4,179 @@ #include "debugger.h" #include "memory.h" -typedef std::unordered_map CommentsInfo; +typedef std::map CommentsInfo; static CommentsInfo comments; -bool CommentSet(uint Address, const char* Text, bool Manual) +bool commentset(uint addr, const char* text, bool manual) { - // CHECK: Exported/Command function - if(!DbgIsDebugging()) + if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or text[0] == '\1' or strlen(text) >= MAX_COMMENT_SIZE - 1) return false; - - // A valid memory address must be supplied - if(!MemIsValidReadPtr(Address)) - return false; - - // Make sure the string is supplied, within bounds, and not a special delimiter - if(!Text || Text[0] == '\1' || strlen(Text) >= MAX_COMMENT_SIZE - 1) - return false; - - // Delete the comment if no text was supplied - if(Text[0] == '\0') + if(!*text) //NOTE: delete when there is no text { - CommentDelete(Address); + commentdel(addr); return true; } - - // Fill out the structure COMMENTSINFO comment; - strcpy_s(comment.text, Text); - ModNameFromAddr(Address, comment.mod, true); - - comment.manual = Manual; - comment.addr = Address; - - EXCLUSIVE_ACQUIRE(LockComments); - - // Insert if possible, otherwise replace - if (!comments.insert(std::make_pair(Address, comment)).second) - comments[Address] = comment; - + comment.manual = manual; + strcpy_s(comment.text, text); + modnamefromaddr(addr, comment.mod, true); + comment.addr = addr - modbasefromaddr(addr); + const uint key = modhashfromva(addr); + CriticalSectionLocker locker(LockComments); + if(!comments.insert(std::make_pair(key, comment)).second) //key already present + comments[key] = comment; return true; } -bool CommentGet(uint Address, char* Text) +bool commentget(uint addr, char* text) { - // CHECK: Exported/Command function if(!DbgIsDebugging()) return false; - - SHARED_ACQUIRE(LockComments); - - // Get an existing comment and copy the string buffer - auto found = comments.find(Address); - - // Was it found? - if(found == comments.end()) + CriticalSectionLocker locker(LockComments); + const CommentsInfo::iterator found = comments.find(modhashfromva(addr)); + if(found == comments.end()) //not found return false; - - strcpy_s(Text, MAX_COMMENT_SIZE, found->second.text); + strcpy_s(text, MAX_COMMENT_SIZE, found->second.text); return true; } -bool CommentDelete(uint Address) +bool commentdel(uint addr) { - // CHECK: Command/Sub function if(!DbgIsDebugging()) return false; - - EXCLUSIVE_ACQUIRE(LockComments); - return (comments.erase(Address) > 0); + CriticalSectionLocker locker(LockComments); + return (comments.erase(modhashfromva(addr)) == 1); } -void CommentDelRange(uint Start, uint End) +void commentdelrange(uint start, uint end) { - // CHECK: Export function if(!DbgIsDebugging()) return; - - // Are all comments going to be deleted? - // 0x00000000 - 0xFFFFFFFF - if(Start == 0 && End == ~0) + bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) + return; + start -= modbase; + end -= modbase; + CriticalSectionLocker locker(LockComments); + CommentsInfo::iterator i = comments.begin(); + while(i != comments.end()) { - EXCLUSIVE_ACQUIRE(LockComments); - comments.clear(); - } - else - { - // Make sure 'Start' and 'End' reference the same module - uint moduleBase = ModBaseFromAddr(Start); - - if(moduleBase != ModBaseFromAddr(End)) - return; - - EXCLUSIVE_ACQUIRE(LockComments); - for(auto itr = comments.begin(); itr != comments.end();) + if(i->second.manual) //ignore manual { - // Ignore manually set entries - if(itr->second.manual) - { - itr++; - continue; - } - - // [Start, End) - if(itr->second.addr >= Start && itr->second.addr < End) - itr = comments.erase(itr); - else - itr++; + i++; + continue; } - } -} - -void CommentCacheSave(JSON Root) -{ - EXCLUSIVE_ACQUIRE(LockComments); - - const JSON jsonComments = json_array(); - const JSON jsonAutoComments = json_array(); - - // Build the JSON array - for(auto & itr : comments) - { - JSON currentComment = json_object(); - - // OFFSET = ADDRESS - MOD_BASE - uint virtualOffset = itr.second.addr - ModBaseFromAddr(itr.second.addr); - - json_object_set_new(currentComment, "module", json_string(itr.second.mod)); - json_object_set_new(currentComment, "address", json_hex(virtualOffset)); - json_object_set_new(currentComment, "text", json_string(itr.second.text)); - - if(itr.second.manual) - json_array_append_new(jsonComments, currentComment); + if(bDelAll || (i->second.addr >= start && i->second.addr < end)) + comments.erase(i++); else - json_array_append_new(jsonAutoComments, currentComment); + i++; } - - // Save to the JSON root - if(json_array_size(jsonComments)) - json_object_set(Root, "comments", jsonComments); - - if(json_array_size(jsonAutoComments)) - json_object_set(Root, "autocomments", jsonAutoComments); - - json_decref(jsonComments); - json_decref(jsonAutoComments); } -void CommentCacheLoad(JSON Root) +void commentcachesave(JSON root) { - EXCLUSIVE_ACQUIRE(LockBookmarks); + CriticalSectionLocker locker(LockComments); + const JSON jsoncomments = json_array(); + const JSON jsonautocomments = json_array(); + for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i) + { + const COMMENTSINFO curComment = i->second; + JSON curjsoncomment = json_object(); + json_object_set_new(curjsoncomment, "module", json_string(curComment.mod)); + json_object_set_new(curjsoncomment, "address", json_hex(curComment.addr)); + json_object_set_new(curjsoncomment, "text", json_string(curComment.text)); + if(curComment.manual) + json_array_append_new(jsoncomments, curjsoncomment); + else + json_array_append_new(jsonautocomments, curjsoncomment); + } + if(json_array_size(jsoncomments)) + json_object_set(root, "comments", jsoncomments); + json_decref(jsoncomments); + if(json_array_size(jsonautocomments)) + json_object_set(root, "autocomments", jsonautocomments); + json_decref(jsonautocomments); +} - // Inline lambda to parse each JSON entry - auto AddBookmarks = [](const JSON Object, bool Manual) +void commentcacheload(JSON root) +{ + CriticalSectionLocker locker(LockComments); + comments.clear(); + const JSON jsoncomments = json_object_get(root, "comments"); + if(jsoncomments) { size_t i; JSON value; - - json_array_foreach(Object, i, value) + json_array_foreach(jsoncomments, i, value) { - COMMENTSINFO commentInfo; - - // Module + COMMENTSINFO curComment; const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(commentInfo.mod, mod); + strcpy_s(curComment.mod, mod); else - commentInfo.mod[0] = '\0'; - - // Address/Manual - commentInfo.addr = (uint)json_hex_value(json_object_get(value, "address")); - commentInfo.manual = Manual; - - // String value + *curComment.mod = '\0'; + curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); + curComment.manual = true; const char* text = json_string_value(json_object_get(value, "text")); - if(text) - strcpy_s(commentInfo.text, text); + strcpy_s(curComment.text, text); else - { - // Skip blank comments - continue; - } - - // ADDRESS = OFFSET + MOD_BASE - commentInfo.addr += ModBaseFromName(commentInfo.mod); - - comments.insert(std::make_pair(commentInfo.addr, commentInfo)); + continue; //skip + const uint key = modhashfromname(curComment.mod) + curComment.addr; + comments.insert(std::make_pair(key, curComment)); } - }; - - // Remove existing entries - comments.clear(); - - const JSON jsonComments = json_object_get(Root, "comments"); - const JSON jsonAutoComments = json_object_get(Root, "autocomments"); - - // Load user-set comments - if(jsonComments) - AddBookmarks(jsonComments, true); - - // Load auto-set comments - if(jsonAutoComments) - AddBookmarks(jsonAutoComments, false); + } + JSON jsonautocomments = json_object_get(root, "autocomments"); + if(jsonautocomments) + { + size_t i; + JSON value; + json_array_foreach(jsonautocomments, i, value) + { + COMMENTSINFO curComment; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy_s(curComment.mod, mod); + else + *curComment.mod = '\0'; + curComment.addr = (uint)json_hex_value(json_object_get(value, "address")); + curComment.manual = false; + const char* text = json_string_value(json_object_get(value, "text")); + if(text) + strcpy_s(curComment.text, text); + else + continue; //skip + const uint key = modhashfromname(curComment.mod) + curComment.addr; + comments.insert(std::make_pair(key, curComment)); + } + } } -bool CommentEnum(COMMENTSINFO* List, size_t* Size) +bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize) { - // CHECK: Command function if(!DbgIsDebugging()) return false; - - // At least 1 parameter must be supplied - if(!List && !Size) + if(!commentlist && !cbsize) return false; - - SHARED_ACQUIRE(LockComments); - - // Check if the user requested size only - if(Size) + CriticalSectionLocker locker(LockComments); + if(!commentlist && cbsize) { - *Size = comments.size() * sizeof(COMMENTSINFO); - - if(!List) - return true; + *cbsize = comments.size() * sizeof(COMMENTSINFO); + return true; } - - // Populate the returned array - for(auto & itr : comments) + int j = 0; + for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i, j++) { - *List = itr.second; - List++; + commentlist[j] = i->second; + commentlist[j].addr += modbasefromname(commentlist[j].mod); } - return true; } -void CommentClear() +void commentclear() { - EXCLUSIVE_ACQUIRE(LockComments); - comments.clear(); + CriticalSectionLocker locker(LockComments); + CommentsInfo().swap(comments); } \ No newline at end of file diff --git a/x64_dbg_dbg/comment.h b/x64_dbg_dbg/comment.h index 993a63fa..3f25f6ef 100644 --- a/x64_dbg_dbg/comment.h +++ b/x64_dbg_dbg/comment.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _COMMENT_H +#define _COMMENT_H #include "_global.h" @@ -10,11 +11,13 @@ struct COMMENTSINFO bool manual; }; -bool CommentSet(uint Address, const char* Text, bool Manual); -bool CommentGet(uint Address, char* Text); -bool CommentDelete(uint Address); -void CommentDelRange(uint Start, uint End); -void CommentCacheSave(JSON Root); -void CommentCacheLoad(JSON Root); -bool CommentEnum(COMMENTSINFO* List, size_t* Size); -void CommentClear(); \ No newline at end of file +bool commentset(uint addr, const char* text, bool manual); +bool commentget(uint addr, char* text); +bool commentdel(uint addr); +void commentdelrange(uint start, uint end); +void commentcachesave(JSON root); +void commentcacheload(JSON root); +bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize); +void commentclear(); + +#endif //_COMMENT_H \ No newline at end of file diff --git a/x64_dbg_dbg/console.cpp b/x64_dbg_dbg/console.cpp index cdad80fe..15895114 100644 --- a/x64_dbg_dbg/console.cpp +++ b/x64_dbg_dbg/console.cpp @@ -1,18 +1,18 @@ #include "console.h" +#include "threading.h" -void dputs(const char* Text) +static char msg[66000] = ""; + +void dputs(const char* text) { - dprintf("%s\n", Text); + dprintf("%s\n", text); } -void dprintf(const char* Format, ...) +void dprintf(const char* format, ...) { + CriticalSectionLocker locker(LockDprintf); va_list args; - char buffer[16384]; - - va_start(args, Format); - vsnprintf_s(buffer, _TRUNCATE, Format, args); - va_end(args); - - GuiAddLogMessage(buffer); + va_start(args, format); + vsnprintf(msg, sizeof(msg), format, args); + GuiAddLogMessage(msg); } diff --git a/x64_dbg_dbg/console.h b/x64_dbg_dbg/console.h index 52e4e488..1407ed0d 100644 --- a/x64_dbg_dbg/console.h +++ b/x64_dbg_dbg/console.h @@ -1,6 +1,10 @@ -#pragma once +#ifndef _CONSOLE_H +#define _CONSOLE_H #include "_global.h" -void dputs(const char* Text); -void dprintf(const char* Format, ...); \ No newline at end of file +//functions +void dputs(const char* text); +void dprintf(const char* format, ...); + +#endif // _CONSOLE_H diff --git a/x64_dbg_dbg/dbghelp_safe.cpp b/x64_dbg_dbg/dbghelp_safe.cpp index f8a9d3a0..46bb5ffa 100644 --- a/x64_dbg_dbg/dbghelp_safe.cpp +++ b/x64_dbg_dbg/dbghelp_safe.cpp @@ -10,6 +10,7 @@ DWORD __in DWORD flags ) { + CriticalSectionLocker locker(LockSym); return UnDecorateSymbolName(name, outputString, maxStringLength, flags); } BOOL @@ -18,7 +19,7 @@ BOOL __in DWORD64 BaseOfDll ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymUnloadModule64(hProcess, BaseOfDll); } BOOL @@ -27,7 +28,7 @@ BOOL __in_opt PCSTR SearchPath ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymSetSearchPath(hProcess, SearchPath); } DWORD @@ -35,7 +36,7 @@ DWORD __in DWORD SymOptions ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymSetOptions(SymOptions); } BOOL @@ -45,7 +46,7 @@ BOOL __in BOOL fInvadeProcess ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymInitialize(hProcess, UserSearchPath, fInvadeProcess); } BOOL @@ -55,7 +56,7 @@ BOOL __in ULONG64 UserContext ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymRegisterCallback64(hProcess, CallbackFunction, UserContext); } DWORD64 @@ -70,7 +71,7 @@ DWORD64 __in_opt DWORD Flags ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags); } BOOL @@ -80,7 +81,7 @@ BOOL __out PIMAGEHLP_MODULE64 ModuleInfo ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymGetModuleInfo64(hProcess, qwAddr, ModuleInfo); } BOOL @@ -90,7 +91,7 @@ BOOL __in DWORD SearchPathLength ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymGetSearchPath(hProcess, SearchPath, SearchPathLength); } BOOL @@ -102,19 +103,9 @@ BOOL __in_opt PVOID UserContext ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymEnumSymbols(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext); } -BOOL - SafeSymEnumerateModules64( - __in HANDLE hProcess, - __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, - __in_opt PVOID UserContext - ) -{ - EXCLUSIVE_ACQUIRE(LockSym); - return SymEnumerateModules64(hProcess, EnumModulesCallback, UserContext); -} BOOL SafeSymEnumerateModules( __in HANDLE hProcess, @@ -122,7 +113,7 @@ BOOL __in_opt PVOID UserContext ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymEnumerateModules(hProcess, EnumModulesCallback, UserContext); } BOOL @@ -133,7 +124,7 @@ BOOL __out PIMAGEHLP_LINE64 Line64 ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymGetLineFromAddr64(hProcess, qwAddr, pdwDisplacement, Line64); } BOOL @@ -143,7 +134,7 @@ BOOL __inout PSYMBOL_INFO Symbol ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymFromName(hProcess, Name, Symbol); } BOOL @@ -154,7 +145,7 @@ BOOL __inout PSYMBOL_INFO Symbol ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymFromAddr(hProcess, Address, Displacement, Symbol); } BOOL @@ -162,6 +153,6 @@ BOOL __in HANDLE hProcess ) { - EXCLUSIVE_ACQUIRE(LockSym); + CriticalSectionLocker locker(LockSym); return SymCleanup(hProcess); } \ No newline at end of file diff --git a/x64_dbg_dbg/dbghelp_safe.h b/x64_dbg_dbg/dbghelp_safe.h index 59063992..b6364f33 100644 --- a/x64_dbg_dbg/dbghelp_safe.h +++ b/x64_dbg_dbg/dbghelp_safe.h @@ -71,12 +71,6 @@ BOOL __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, __in_opt PVOID UserContext ); -BOOL - SafeSymEnumerateModules64( - __in HANDLE hProcess, - __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, - __in_opt PVOID UserContext - ); BOOL SafeSymEnumerateModules( __in HANDLE hProcess, diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index e4dcd674..f9cf4054 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -49,7 +49,7 @@ static DWORD WINAPI memMapThread(void* ptr) if(cachePrivateUsage != PrivateUsage && !dbgisrunning()) //update the memory map when { cachePrivateUsage = PrivateUsage; - MemUpdateMap(fdProcessInfo->hProcess); + memupdatemap(fdProcessInfo->hProcess); } Sleep(1000); } @@ -58,8 +58,8 @@ static DWORD WINAPI memMapThread(void* ptr) void dbginit() { - ExceptionCodeInit(); - ErrorCodeInit(); + exceptioninit(); + errorinit(); CloseHandle(CreateThread(0, 0, memMapThread, 0, 0, 0)); } @@ -82,7 +82,7 @@ uint dbgdebuggedbase() void dbgdisablebpx() { std::vector list; - int bpcount = BpGetList(&list); + int bpcount = bpgetlist(&list); for(int i = 0; i < bpcount; i++) { if(list[i].type == BPNORMAL and IsBPXEnabled(list[i].addr)) @@ -93,7 +93,7 @@ void dbgdisablebpx() void dbgenablebpx() { std::vector list; - int bpcount = BpGetList(&list); + int bpcount = bpgetlist(&list); for(int i = 0; i < bpcount; i++) { if(list[i].type == BPNORMAL and !IsBPXEnabled(list[i].addr) and list[i].enabled) @@ -185,7 +185,7 @@ DWORD WINAPI updateCallStackThread(void* ptr) void DebugUpdateGui(uint disasm_addr, bool stack) { uint cip = GetContextDataEx(hActiveThread, UE_CIP); - if(MemIsValidReadPtr(disasm_addr)) + if(memisvalidreadptr(fdProcessInfo->hProcess, disasm_addr)) GuiDisasmAt(disasm_addr, cip); uint csp = GetContextDataEx(hActiveThread, UE_CSP); if(stack) @@ -198,24 +198,24 @@ void DebugUpdateGui(uint disasm_addr, bool stack) } char modname[MAX_MODULE_SIZE] = ""; char modtext[MAX_MODULE_SIZE * 2] = ""; - if(!ModNameFromAddr(disasm_addr, modname, true)) + if(!modnamefromaddr(disasm_addr, modname, true)) *modname = 0; else sprintf(modtext, "Module: %s - ", modname); char title[1024] = ""; - sprintf(title, "File: %s - PID: %X - %sThread: %X", szBaseFileName, fdProcessInfo->dwProcessId, modtext, ThreadGetId(hActiveThread)); + sprintf(title, "File: %s - PID: %X - %sThread: %X", szBaseFileName, fdProcessInfo->dwProcessId, modtext, threadgetid(hActiveThread)); GuiUpdateWindowTitle(title); GuiUpdateAllViews(); } void cbUserBreakpoint() { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); BREAKPOINT bp; BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; - if(!BpGet(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled) + if(!bpget(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled) dputs("Breakpoint reached not in list!"); else { @@ -225,7 +225,7 @@ void cbUserBreakpoint() bptype = "UD2"; else if((titantype & UE_BREAKPOINT_TYPE_LONG_INT3) == UE_BREAKPOINT_TYPE_LONG_INT3) bptype = "LONG INT3"; - const char* symbolicname = SymGetSymbolicName(bp.addr); + const char* symbolicname = symgetsymbolicname(bp.addr); if(symbolicname) { if(*bp.name) @@ -241,8 +241,8 @@ void cbUserBreakpoint() dprintf("%s breakpoint at "fhex"!\n", bptype, bp.addr); } if(bp.singleshoot) - BpDelete(bp.addr, BPNORMAL); - BpToBridge(&bp, &pluginBp); + bpdel(bp.addr, BPNORMAL); + bptobridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; } GuiSetDebugState(paused); @@ -260,13 +260,13 @@ void cbUserBreakpoint() void cbHardwareBreakpoint(void* ExceptionAddress) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); uint cip = GetContextDataEx(hActiveThread, UE_CIP); BREAKPOINT bp; BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; - if(!BpGet((uint)ExceptionAddress, BPHARDWARE, 0, &bp)) + if(!bpget((uint)ExceptionAddress, BPHARDWARE, 0, &bp)) dputs("Hardware breakpoint reached not in list!"); else { @@ -302,7 +302,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress) bptype = "write"; break; } - const char* symbolicname = SymGetSymbolicName(bp.addr); + const char* symbolicname = symgetsymbolicname(bp.addr); if(symbolicname) { if(*bp.name) @@ -317,7 +317,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress) else dprintf("Hardware breakpoint (%s%s) at "fhex"!\n", bpsize, bptype, bp.addr); } - BpToBridge(&bp, &pluginBp); + bptobridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; } GuiSetDebugState(paused); @@ -335,15 +335,15 @@ void cbHardwareBreakpoint(void* ExceptionAddress) void cbMemoryBreakpoint(void* ExceptionAddress) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); uint cip = GetContextDataEx(hActiveThread, UE_CIP); uint size; - uint base = MemFindBaseAddr((uint)ExceptionAddress, &size, true); + uint base = memfindbaseaddr((uint)ExceptionAddress, &size, true); BREAKPOINT bp; BRIDGEBP pluginBp; PLUG_CB_BREAKPOINT bpInfo; bpInfo.breakpoint = 0; - if(!BpGet(base, BPMEMORY, 0, &bp)) + if(!bpget(base, BPMEMORY, 0, &bp)) dputs("Memory breakpoint reached not in list!"); else { @@ -363,7 +363,7 @@ void cbMemoryBreakpoint(void* ExceptionAddress) bptype = " (read/write/execute)"; break; } - const char* symbolicname = SymGetSymbolicName(bp.addr); + const char* symbolicname = symgetsymbolicname(bp.addr); if(symbolicname) { if(*bp.name) @@ -378,11 +378,11 @@ void cbMemoryBreakpoint(void* ExceptionAddress) else dprintf("Memory breakpoint%s at "fhex" ("fhex")!\n", bptype, bp.addr, ExceptionAddress); } - BpToBridge(&bp, &pluginBp); + bptobridge(&bp, &pluginBp); bpInfo.breakpoint = &pluginBp; } if(bp.singleshoot) - BpDelete(bp.addr, BPMEMORY); //delete from breakpoint list + bpdel(bp.addr, BPMEMORY); //delete from breakpoint list GuiSetDebugState(paused); DebugUpdateGui(cip, true); //lock @@ -487,7 +487,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp) case BPMEMORY: { uint size = 0; - MemFindBaseAddr(bp->addr, &size); + memfindbaseaddr(bp->addr, &size); if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) dprintf("Could not set memory breakpoint "fhex"!\n", bp->addr); } @@ -503,7 +503,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp) } int titantype = bp->titantype; TITANSETDRX(titantype, drx); - BpSetTitanType(bp->addr, BPHARDWARE, titantype); + bpsettitantype(bp->addr, BPHARDWARE, titantype); if(!SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) dprintf("Could not set hardware breakpoint "fhex"!\n", bp->addr); } @@ -540,7 +540,7 @@ static bool cbRemoveModuleBreakpoints(const BREAKPOINT* bp) void cbStep() { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); isStepping = false; GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); @@ -559,7 +559,7 @@ void cbStep() static void cbRtrFinalStep() { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); //lock @@ -576,7 +576,7 @@ static unsigned char getCIPch() { unsigned char ch = 0x90; uint cip = GetContextDataEx(hActiveThread, UE_CIP); - MemRead((void*)cip, &ch, 1, 0); + memread(fdProcessInfo->hProcess, (void*)cip, &ch, 1, 0); return ch; } @@ -604,8 +604,8 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) } dprintf("Process Started: "fhex" %s\n", base, DebugFileName); - MemUpdateMap(fdProcessInfo->hProcess); - GuiDumpAt(MemFindBaseAddr(GetContextData(UE_CIP), 0) + PAGE_SIZE); //dump somewhere + memupdatemap(fdProcessInfo->hProcess); + GuiDumpAt(memfindbaseaddr(GetContextData(UE_CIP), 0)+PAGE_SIZE); //dump somewhere //init program database int len = (int)strlen(szFileName); @@ -633,12 +633,12 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(modInfo); if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) - ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); + modload((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); - MemUpdateMap(fdProcessInfo->hProcess); //update memory map + memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; - if(ModNameFromAddr((uint)base, modname, true)) - BpEnumAll(cbSetModuleBreakpoints, modname); + if(modnamefromaddr((uint)base, modname, true)) + bpenumall(cbSetModuleBreakpoints, modname); GuiUpdateBreakpointsView(); if(!bFileIsDll and !bIsAttached) //Set entry breakpoint { @@ -688,7 +688,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) threadInfo.hThread = CreateProcessInfo->hThread; threadInfo.lpStartAddress = CreateProcessInfo->lpStartAddress; threadInfo.lpThreadLocalBase = CreateProcessInfo->lpThreadLocalBase; - ThreadCreate(&threadInfo); + threadcreate(&threadInfo); } static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess) @@ -702,9 +702,9 @@ static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess) static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) { - ThreadCreate(CreateThread); //update thread list + threadcreate(CreateThread); //update thread list DWORD dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; - hActiveThread = ThreadGetHandle(dwThreadId); + hActiveThread = threadgethandle(dwThreadId); if(settingboolget("Events", "ThreadEntry")) { @@ -723,7 +723,7 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) if(settingboolget("Events", "ThreadStart")) { dbggetprivateusage(fdProcessInfo->hProcess, true); - MemUpdateMap(fdProcessInfo->hProcess); //update memory map + memupdatemap(fdProcessInfo->hProcess); //update memory map //update GUI GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); @@ -739,13 +739,13 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread) static void cbExitThread(EXIT_THREAD_DEBUG_INFO* ExitThread) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); DWORD dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; PLUG_CB_EXITTHREAD callbackInfo; callbackInfo.ExitThread = ExitThread; callbackInfo.dwThreadId = dwThreadId; plugincbcall(CB_EXITTHREAD, &callbackInfo); - ThreadExit(dwThreadId); + threadexit(dwThreadId); dprintf("Thread %X exit\n", dwThreadId); if(settingboolget("Events", "ThreadEnd")) @@ -765,7 +765,7 @@ static void cbExitThread(EXIT_THREAD_DEBUG_INFO* ExitThread) static void cbSystemBreakpoint(void* ExceptionData) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); //log message if(bIsAttached) dputs("Attach breakpoint reached!"); @@ -773,7 +773,7 @@ static void cbSystemBreakpoint(void* ExceptionData) dputs("System breakpoint reached!"); bSkipExceptions = false; //we are not skipping first-chance exceptions uint cip = GetContextDataEx(hActiveThread, UE_CIP); - GuiDumpAt(MemFindBaseAddr(cip, 0, true)); //dump somewhere + GuiDumpAt(memfindbaseaddr(cip, 0, true)); //dump somewhere //plugin callbacks PLUG_CB_SYSTEMBREAKPOINT callbackInfo; @@ -797,7 +797,7 @@ static void cbSystemBreakpoint(void* ExceptionData) static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); void* base = LoadDll->lpBaseOfDll; char DLLDebugFileName[deflen] = ""; if(!GetFileNameFromHandle(LoadDll->hFile, DLLDebugFileName)) @@ -813,12 +813,12 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) memset(&modInfo, 0, sizeof(modInfo)); modInfo.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo)) - ModLoad((uint)base, modInfo.ImageSize, modInfo.ImageName); + modload((uint)base, modInfo.ImageSize, modInfo.ImageName); dbggetprivateusage(fdProcessInfo->hProcess, true); - MemUpdateMap(fdProcessInfo->hProcess); //update memory map + memupdatemap(fdProcessInfo->hProcess); //update memory map char modname[256] = ""; - if(ModNameFromAddr((uint)base, modname, true)) - BpEnumAll(cbSetModuleBreakpoints, modname); + if(modnamefromaddr((uint)base, modname, true)) + bpenumall(cbSetModuleBreakpoints, modname); GuiUpdateBreakpointsView(); bool bAlreadySetEntry = false; @@ -900,15 +900,15 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); PLUG_CB_UNLOADDLL callbackInfo; callbackInfo.UnloadDll = UnloadDll; plugincbcall(CB_UNLOADDLL, &callbackInfo); void* base = UnloadDll->lpBaseOfDll; char modname[256] = "???"; - if(ModNameFromAddr((uint)base, modname, true)) - BpEnumAll(cbRemoveModuleBreakpoints, modname); + if(modnamefromaddr((uint)base, modname, true)) + bpenumall(cbRemoveModuleBreakpoints, modname); GuiUpdateBreakpointsView(); SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base); dprintf("DLL Unloaded: "fhex" %s\n", base, modname); @@ -928,12 +928,13 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll) wait(WAITID_RUN); } - ModUnload((uint)base); + modunload((uint)base); } static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); PLUG_CB_OUTPUTDEBUGSTRING callbackInfo; callbackInfo.DebugString = DebugString; plugincbcall(CB_OUTPUTDEBUGSTRING, &callbackInfo); @@ -941,7 +942,7 @@ static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) if(!DebugString->fUnicode) //ASCII { Memory DebugText(DebugString->nDebugStringLength + 1, "cbOutputDebugString:DebugText"); - if(MemRead(DebugString->lpDebugStringData, DebugText, DebugString->nDebugStringLength, 0)) + if(memread(fdProcessInfo->hProcess, DebugString->lpDebugStringData, DebugText, DebugString->nDebugStringLength, 0)) { String str = String(DebugText); if(str != lastDebugText) //fix for every string being printed twice @@ -972,7 +973,7 @@ static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString) static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) { - hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); + hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); PLUG_CB_EXCEPTION callbackInfo; callbackInfo.Exception = ExceptionData; unsigned int ExceptionCode = ExceptionData->ExceptionRecord.ExceptionCode; @@ -1018,18 +1019,18 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData) memcpy(&nameInfo, ExceptionData->ExceptionRecord.ExceptionInformation, sizeof(THREADNAME_INFO)); if(nameInfo.dwThreadID == -1) //current thread nameInfo.dwThreadID = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; - if(nameInfo.dwType == 0x1000 and nameInfo.dwFlags == 0 and ThreadIsValid(nameInfo.dwThreadID)) //passed basic checks + if(nameInfo.dwType == 0x1000 and nameInfo.dwFlags == 0 and threadisvalid(nameInfo.dwThreadID)) //passed basic checks { Memory ThreadName(MAX_THREAD_NAME_SIZE, "cbException:ThreadName"); - if(MemRead((void*)nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0)) + if(memread(fdProcessInfo->hProcess, nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0)) { String ThreadNameEscaped = StringUtils::Escape(ThreadName); dprintf("SetThreadName(%X, \"%s\")\n", nameInfo.dwThreadID, ThreadNameEscaped.c_str()); - ThreadSetName(nameInfo.dwThreadID, ThreadNameEscaped.c_str()); + threadsetname(nameInfo.dwThreadID, ThreadNameEscaped.c_str()); } } } - const char* exceptionName = ExceptionCodeToName(ExceptionCode); + const char* exceptionName = exceptionnamefromcode(ExceptionCode); if(ExceptionData->dwFirstChance) //first chance exception { if(exceptionName) @@ -1150,8 +1151,8 @@ DWORD WINAPI threadDebugLoop(void* lpParameter) RemoveAllBreakPoints(UE_OPTION_REMOVEALL); //remove all breakpoints //cleanup dbclose(); - ModClear(); - ThreadClear(); + modclear(); + threadclear(); GuiSetDebugState(stopped); dputs("debugging stopped!"); varset("$hp", (uint)0, true); @@ -1162,7 +1163,7 @@ DWORD WINAPI threadDebugLoop(void* lpParameter) bool cbDeleteAllBreakpoints(const BREAKPOINT* bp) { - if(BpDelete(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr))) + if(bpdel(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr))) return true; dprintf("Delete breakpoint failed: "fhex"\n", bp->addr); @@ -1174,7 +1175,7 @@ bool cbEnableAllBreakpoints(const BREAKPOINT* bp) if(bp->type != BPNORMAL or bp->enabled) return true; - if(!BpEnable(bp->addr, BPNORMAL, true) or !SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint)) + if(!bpenable(bp->addr, BPNORMAL, true) or !SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint)) { dprintf("Could not enable breakpoint "fhex"\n", bp->addr); return false; @@ -1187,7 +1188,7 @@ bool cbDisableAllBreakpoints(const BREAKPOINT* bp) if(bp->type != BPNORMAL or !bp->enabled) return true; - if(!BpEnable(bp->addr, BPNORMAL, false) or !DeleteBPX(bp->addr)) + if(!bpenable(bp->addr, BPNORMAL, false) or !DeleteBPX(bp->addr)) { dprintf("Could not disable breakpoint "fhex"\n", bp->addr); return false; @@ -1207,8 +1208,8 @@ bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp) } int titantype = bp->titantype; TITANSETDRX(titantype, drx); - BpSetTitanType(bp->addr, BPHARDWARE, titantype); - if(!BpEnable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) + bpsettitantype(bp->addr, BPHARDWARE, titantype); + if(!bpenable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) { dprintf("could not enable hardware breakpoint "fhex"\n", bp->addr); return false; @@ -1220,7 +1221,7 @@ bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp) { if(bp->type != BPHARDWARE or !bp->enabled) return true; - if(!BpEnable(bp->addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) + if(!bpenable(bp->addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { dprintf("Could not disable hardware breakpoint "fhex"\n", bp->addr); return false; @@ -1233,8 +1234,8 @@ bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp) if(bp->type != BPMEMORY or bp->enabled) return true; uint size = 0; - MemFindBaseAddr(bp->addr, &size); - if(!BpEnable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) + memfindbaseaddr(bp->addr, &size); + if(!bpenable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) { dprintf("Could not enable memory breakpoint "fhex"\n", bp->addr); return false; @@ -1246,7 +1247,7 @@ bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp) { if(bp->type != BPMEMORY or !bp->enabled) return true; - if(!BpEnable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) + if(!bpenable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { dprintf("Could not disable memory breakpoint "fhex"\n", bp->addr); return false; @@ -1281,8 +1282,8 @@ bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp) if(!bp->enabled) return true; uint size; - MemFindBaseAddr(bp->addr, &size); - if(!BpDelete(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size)) + memfindbaseaddr(bp->addr, &size); + if(!bpdel(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", bp->addr); return STATUS_ERROR; @@ -1294,7 +1295,7 @@ bool cbDeleteAllHardwareBreakpoints(const BREAKPOINT* bp) { if(!bp->enabled) return true; - if(!BpDelete(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) + if(!bpdel(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) { dprintf("Delete hardware breakpoint failed: "fhex"\n", bp->addr); return STATUS_ERROR; @@ -1366,8 +1367,8 @@ DWORD WINAPI threadAttachLoop(void* lpParameter) RemoveAllBreakPoints(UE_OPTION_REMOVEALL); //remove all breakpoints //cleanup dbclose(); - ModClear(); - ThreadClear(); + modclear(); + threadclear(); GuiSetDebugState(stopped); dputs("debugging stopped!"); varset("$hp", (uint)0, true); @@ -1742,7 +1743,7 @@ static bool getcommandlineaddr(uint* addr, cmdline_error_t* cmd_line_error) //cast-trick to calculate the address of the remote peb field ProcessParameters cmd_line_error->addr = (uint) & (((PPEB) cmd_line_error->addr)->ProcessParameters); - if(!MemRead((void*)cmd_line_error->addr, &pprocess_parameters, sizeof(pprocess_parameters), &size)) + if(!memread(fdProcessInfo->hProcess, (const void*)cmd_line_error->addr, &pprocess_parameters, sizeof(pprocess_parameters), &size)) { cmd_line_error->type = CMDL_ERR_READ_PEBBASE; return false; @@ -1761,7 +1762,7 @@ static bool patchcmdline(uint getcommandline, uint new_command_line, cmdline_err unsigned char data[100]; cmd_line_error->addr = getcommandline; - if(!MemRead((void*) cmd_line_error->addr, & data, sizeof(data), & size)) + if(!memread(fdProcessInfo->hProcess, (const void*) cmd_line_error->addr, & data, sizeof(data), & size)) { cmd_line_error->type = CMDL_ERR_READ_GETCOMMANDLINEBASE; return false; @@ -1795,7 +1796,7 @@ static bool patchcmdline(uint getcommandline, uint new_command_line, cmdline_err #endif //update the pointer in the debuggee - if(!MemWrite((void*)command_line_stored, &new_command_line, sizeof(new_command_line), &size)) + if(!memwrite(fdProcessInfo->hProcess, (void*)command_line_stored, &new_command_line, sizeof(new_command_line), &size)) { cmd_line_error->addr = command_line_stored; cmd_line_error->type = CMDL_ERR_WRITE_GETCOMMANDLINESTORED; @@ -1864,21 +1865,21 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error) new_command_line.Buffer = command_linewstr; - uint mem = (uint)MemAllocRemote(0, new_command_line.Length * 2, PAGE_READWRITE); + uint mem = (uint)memalloc(fdProcessInfo->hProcess, 0, new_command_line.Length * 2, PAGE_READWRITE); if(!mem) { cmd_line_error->type = CMDL_ERR_ALLOC_UNICODEANSI_COMMANDLINE; return false; } - if(!MemWrite((void*)mem, new_command_line.Buffer, new_command_line.Length, &size)) + if(!memwrite(fdProcessInfo->hProcess, (void*)mem, new_command_line.Buffer, new_command_line.Length, &size)) { cmd_line_error->addr = mem; cmd_line_error->type = CMDL_ERR_WRITE_UNICODE_COMMANDLINE; return false; } - if(!MemWrite((void*)(mem + new_command_line.Length), (void*)cmd_line, strlen(cmd_line) + 1, &size)) + if(!memwrite(fdProcessInfo->hProcess, (void*)(mem + new_command_line.Length), cmd_line, strlen(cmd_line) + 1, &size)) { cmd_line_error->addr = mem + new_command_line.Length; cmd_line_error->type = CMDL_ERR_WRITE_ANSI_COMMANDLINE; @@ -1889,7 +1890,7 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error) return false; new_command_line.Buffer = (PWSTR) mem; - if(!MemWrite((void*)command_line_addr, &new_command_line, sizeof(new_command_line), &size)) + if(!memwrite(fdProcessInfo->hProcess, (void*)command_line_addr, &new_command_line, sizeof(new_command_line), &size)) { cmd_line_error->addr = command_line_addr; cmd_line_error->type = CMDL_ERR_WRITE_PEBUNICODE_COMMANDLINE; @@ -1911,7 +1912,7 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error) if(!getcommandlineaddr(&cmd_line_error->addr, cmd_line_error)) return false; - if(!MemRead((void*)cmd_line_error->addr, &CommandLine, sizeof(CommandLine), &size)) + if(!memread(fdProcessInfo->hProcess, (const void*)cmd_line_error->addr, &CommandLine, sizeof(CommandLine), &size)) { cmd_line_error->type = CMDL_ERR_READ_PROCPARM_PTR; return false; @@ -1920,7 +1921,7 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error) Memory wstr_cmd(CommandLine.Length + sizeof(wchar_t)); cmd_line_error->addr = (uint) CommandLine.Buffer; - if(!MemRead((void*)cmd_line_error->addr, wstr_cmd, CommandLine.Length, &size)) + if(!memread(fdProcessInfo->hProcess, (const void*)cmd_line_error->addr, wstr_cmd, CommandLine.Length, &size)) { cmd_line_error->type = CMDL_ERR_READ_PROCPARM_CMDLINE; return false; diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 128e24c2..6da4a30a 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -209,7 +209,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] const char* bpname = 0; if(*argname) bpname = argname; - if(BpGet(addr, BPNORMAL, bpname, 0)) + if(bpget(addr, BPNORMAL, bpname, 0)) { dputs("Breakpoint already set!"); return STATUS_CONTINUE; @@ -219,12 +219,12 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]] dprintf("Error setting breakpoint at "fhex"! (IsBPXEnabled)\n", addr); return STATUS_ERROR; } - else if(!MemRead((void*)addr, &oldbytes, sizeof(short), 0)) + else if(!memread(fdProcessInfo->hProcess, (void*)addr, &oldbytes, sizeof(short), 0)) { dprintf("Error setting breakpoint at "fhex"! (memread)\n", addr); return STATUS_ERROR; } - else if(!BpNew(addr, true, singleshoot, oldbytes, BPNORMAL, type, bpname)) + else if(!bpnew(addr, true, singleshoot, oldbytes, BPNORMAL, type, bpname)) { dprintf("Error setting breakpoint at "fhex"! (bpnew)\n", addr); return STATUS_ERROR; @@ -244,21 +244,21 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!BpGetCount(BPNORMAL)) + if(!bpgetcount(BPNORMAL)) { dputs("No breakpoints to delete!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbDeleteAllBreakpoints)) //at least one deletion failed + if(!bpenumall(cbDeleteAllBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name + if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name { - if(!BpDelete(found.addr, BPNORMAL)) + if(!bpdel(found.addr, BPNORMAL)) { dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr); return STATUS_ERROR; @@ -272,12 +272,12 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint { dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } - if(!BpDelete(found.addr, BPNORMAL)) + if(!bpdel(found.addr, BPNORMAL)) { dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr); return STATUS_ERROR; @@ -298,21 +298,21 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //enable all breakpoints { - if(!BpGetCount(BPNORMAL)) + if(!bpgetcount(BPNORMAL)) { dputs("No breakpoints to enable!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbEnableAllBreakpoints)) //at least one enable failed + if(!bpenumall(cbEnableAllBreakpoints)) //at least one enable failed return STATUS_ERROR; dputs("All breakpoints enabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name + if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name { - if(!BpEnable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) + if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) { dprintf("Could not enable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -321,7 +321,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint { dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -332,7 +332,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[]) GuiUpdateAllViews(); return STATUS_CONTINUE; } - if(!BpEnable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) + if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint)) { dprintf("Could not enable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -347,21 +347,21 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!BpGetCount(BPNORMAL)) + if(!bpgetcount(BPNORMAL)) { dputs("No breakpoints to disable!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbDisableAllBreakpoints)) //at least one deletion failed + if(!bpenumall(cbDisableAllBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All breakpoints disabled!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name + if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name { - if(!BpEnable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) + if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) { dprintf("Could not disable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -370,7 +370,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint { dprintf("No such breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -380,7 +380,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) dputs("Breakpoint already disabled!"); return STATUS_CONTINUE; } - if(!BpEnable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) + if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr)) { dprintf("Could not disable breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -392,7 +392,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[]) CMDRESULT cbDebugBplist(int argc, char* argv[]) { - BpEnumAll(cbBreakpointList); + bpenumall(cbBreakpointList); return STATUS_CONTINUE; } @@ -458,7 +458,7 @@ CMDRESULT cbDebugDisasm(int argc, char* argv[]) if(argget(*argv, arg1, 0, true)) if(!valfromstring(arg1, &addr)) addr = GetContextDataEx(hActiveThread, UE_CIP); - if(!MemIsValidReadPtr(addr)) + if(!memisvalidreadptr(fdProcessInfo->hProcess, addr)) return STATUS_CONTINUE; DebugUpdateGui(addr, false); return STATUS_CONTINUE; @@ -505,16 +505,16 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]) } } uint size = 0; - uint base = MemFindBaseAddr(addr, &size, true); + uint base = memfindbaseaddr(addr, &size, true); bool singleshoot = false; if(!restore) singleshoot = true; - if(BpGet(base, BPMEMORY, 0, 0)) + if(bpget(base, BPMEMORY, 0, 0)) { dputs("Hardware breakpoint already set!"); return STATUS_CONTINUE; } - if(!BpNew(base, true, singleshoot, 0, BPMEMORY, type, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint)) + if(!bpnew(base, true, singleshoot, 0, BPMEMORY, type, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint)) { dputs("Error setting memory breakpoint!"); return STATUS_ERROR; @@ -529,23 +529,23 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!BpGetCount(BPMEMORY)) + if(!bpgetcount(BPMEMORY)) { dputs("no memory breakpoints to delete!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed + if(!bpenumall(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All memory breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(BpGet(0, BPMEMORY, arg1, &found)) //found a breakpoint with name + if(bpget(0, BPMEMORY, arg1, &found)) //found a breakpoint with name { uint size; - MemFindBaseAddr(found.addr, &size); - if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) + memfindbaseaddr(found.addr, &size); + if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -553,14 +553,14 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid breakpoint { dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } uint size; - MemFindBaseAddr(found.addr, &size); - if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) + memfindbaseaddr(found.addr, &size); + if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -655,12 +655,12 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]) TITANSETTYPE(titantype, type); TITANSETSIZE(titantype, titsize); //TODO: hwbp in multiple threads TEST - if(BpGet(addr, BPHARDWARE, 0, 0)) + if(bpget(addr, BPHARDWARE, 0, 0)) { dputs("Hardware breakpoint already set!"); return STATUS_CONTINUE; } - if(!BpNew(addr, true, false, 0, BPHARDWARE, titantype, 0)) + if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0)) { dputs("error setting hardware breakpoint (bpnew)!"); return STATUS_ERROR; @@ -680,21 +680,21 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all breakpoints { - if(!BpGetCount(BPHARDWARE)) + if(!bpgetcount(BPHARDWARE)) { dputs("No hardware breakpoints to delete!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed + if(!bpenumall(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All hardware breakpoints deleted!"); GuiUpdateAllViews(); return STATUS_CONTINUE; } BREAKPOINT found; - if(BpGet(0, BPHARDWARE, arg1, &found)) //found a breakpoint with name + if(bpget(0, BPHARDWARE, arg1, &found)) //found a breakpoint with name { - if(!BpDelete(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) + if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -702,12 +702,12 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid breakpoint { dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; } - if(!BpDelete(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) + if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr); return STATUS_ERROR; @@ -724,7 +724,7 @@ CMDRESULT cbDebugAlloc(int argc, char* argv[]) if(argget(*argv, arg1, 0, true)) if(!valfromstring(arg1, &size, false)) return STATUS_ERROR; - uint mem = (uint)MemAllocRemote(0, size, PAGE_EXECUTE_READWRITE); + uint mem = (uint)memalloc(fdProcessInfo->hProcess, 0, size, PAGE_EXECUTE_READWRITE); if(!mem) dputs("VirtualAllocEx failed"); else @@ -732,7 +732,7 @@ CMDRESULT cbDebugAlloc(int argc, char* argv[]) if(mem) varset("$lastalloc", mem, true); dbggetprivateusage(fdProcessInfo->hProcess, true); - MemUpdateMap(fdProcessInfo->hProcess); + memupdatemap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); varset("$res", mem, false); return STATUS_CONTINUE; @@ -760,7 +760,7 @@ CMDRESULT cbDebugFree(int argc, char* argv[]) if(!ok) dputs("VirtualFreeEx failed"); dbggetprivateusage(fdProcessInfo->hProcess, true); - MemUpdateMap(fdProcessInfo->hProcess); + memupdatemap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); varset("$res", ok, false); return STATUS_CONTINUE; @@ -786,7 +786,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[]) } else { - uint base = MemFindBaseAddr(addr, &size, true); + uint base = memfindbaseaddr(addr, &size, true); if(!base) { dputs("invalid address specified"); @@ -806,15 +806,15 @@ CMDRESULT cbDebugMemset(int argc, char* argv[]) CMDRESULT cbDebugBenchmark(int argc, char* argv[]) { - uint addr = MemFindBaseAddr(GetContextDataEx(hActiveThread, UE_CIP), 0); + uint addr = memfindbaseaddr(GetContextDataEx(hActiveThread, UE_CIP), 0); DWORD ticks = GetTickCount(); char comment[MAX_COMMENT_SIZE] = ""; for(uint i = addr; i < addr + 100000; i++) { - CommentSet(i, "test", false); + commentset(i, "test", false); labelset(i, "test", false); - BookmarkSet(i, false); - FunctionAdd(i, i, false); + bookmarkset(i, false); + functionadd(i, i, false); } dprintf("%ums\n", GetTickCount() - ticks); return STATUS_CONTINUE; @@ -962,7 +962,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[]) } duint csp = GetContextDataEx(hActiveThread, UE_CSP); duint size = 0; - duint base = MemFindBaseAddr(csp, &size); + duint base = memfindbaseaddr(csp, &size); if(base && addr >= base && addr < (base + size)) GuiStackDumpAt(addr, csp); else @@ -1035,13 +1035,13 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[]) if(argc > 1) if(!valfromstring(argv[1], &threadid, false)) return STATUS_ERROR; - if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid + if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //switch thread - hActiveThread = ThreadGetHandle((DWORD)threadid); + hActiveThread = threadgethandle((DWORD)threadid); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); dputs("Thread switched!"); return STATUS_CONTINUE; @@ -1053,13 +1053,13 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[]) if(argc > 1) if(!valfromstring(argv[1], &threadid, false)) return STATUS_ERROR; - if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid + if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //suspend thread - if(SuspendThread(ThreadGetHandle((DWORD)threadid)) == -1) + if(SuspendThread(threadgethandle((DWORD)threadid)) == -1) { dputs("Error suspending thread"); return STATUS_ERROR; @@ -1075,13 +1075,13 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[]) if(argc > 1) if(!valfromstring(argv[1], &threadid, false)) return STATUS_ERROR; - if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid + if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //resume thread - if(ResumeThread(ThreadGetHandle((DWORD)threadid)) == -1) + if(ResumeThread(threadgethandle((DWORD)threadid)) == -1) { dputs("Error resuming thread"); return STATUS_ERROR; @@ -1101,13 +1101,13 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[]) if(argc > 2) if(!valfromstring(argv[2], &exitcode, false)) return STATUS_ERROR; - if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid + if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //terminate thread - if(TerminateThread(ThreadGetHandle((DWORD)threadid), (DWORD)exitcode) != 0) + if(TerminateThread(threadgethandle((DWORD)threadid), (DWORD)exitcode) != 0) { GuiUpdateAllViews(); dputs("Thread terminated"); @@ -1119,16 +1119,18 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[]) CMDRESULT cbDebugSuspendAllThreads(int argc, char* argv[]) { - dprintf("%d/%d thread(s) suspended\n", ThreadSuspendAll(), ThreadGetCount()); - + int threadCount = threadgetcount(); + int suspendedCount = threadsuspendall(); + dprintf("%d/%d thread(s) suspended\n", suspendedCount, threadCount); GuiUpdateAllViews(); return STATUS_CONTINUE; } CMDRESULT cbDebugResumeAllThreads(int argc, char* argv[]) { - dprintf("%d/%d thread(s) resumed\n", ThreadResumeAll(), ThreadGetCount()); - + int threadCount = threadgetcount(); + int resumeCount = threadresumeall(); + dprintf("%d/%d thread(s) resumed\n", resumeCount, threadCount); GuiUpdateAllViews(); return STATUS_CONTINUE; } @@ -1183,13 +1185,13 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[]) return STATUS_ERROR; } } - if(!ThreadIsValid((DWORD)threadid)) //check if the thread is valid + if(!threadisvalid((DWORD)threadid)) //check if the thread is valid { dprintf("Invalid thread %X\n", threadid); return STATUS_ERROR; } //set thread priority - if(SetThreadPriority(ThreadGetHandle((DWORD)threadid), (int)priority) == 0) + if(SetThreadPriority(threadgethandle((DWORD)threadid), (int)priority) == 0) { dputs("Error setting thread priority"); return STATUS_ERROR; @@ -1210,12 +1212,12 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) } if(!argget(*argv, arg1, 0, true)) //enable all hardware breakpoints { - if(!BpGetCount(BPHARDWARE)) + if(!bpgetcount(BPHARDWARE)) { dputs("No hardware breakpoints to enable!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed + if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed return STATUS_ERROR; dputs("All hardware breakpoints enabled!"); GuiUpdateAllViews(); @@ -1223,7 +1225,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint { dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1235,8 +1237,8 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } TITANSETDRX(found.titantype, drx); - BpSetTitanType(found.addr, BPHARDWARE, found.titantype); - if(!BpEnable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint)) + bpsettitantype(found.addr, BPHARDWARE, found.titantype); + if(!bpenable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint)) { dprintf("Could not enable hardware breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -1251,12 +1253,12 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all hardware breakpoints { - if(!BpGetCount(BPHARDWARE)) + if(!bpgetcount(BPHARDWARE)) { dputs("No hardware breakpoints to disable!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbDisableAllHardwareBreakpoints)) //at least one deletion failed + if(!bpenumall(cbDisableAllHardwareBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All hardware breakpoints disabled!"); GuiUpdateAllViews(); @@ -1264,7 +1266,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint { dprintf("No such hardware breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1274,7 +1276,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) dputs("Hardware breakpoint already disabled!"); return STATUS_CONTINUE; } - if(!BpEnable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) + if(!bpenable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) { dprintf("Could not disable hardware breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -1295,12 +1297,12 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) } if(!argget(*argv, arg1, 0, true)) //enable all memory breakpoints { - if(!BpGetCount(BPMEMORY)) + if(!bpgetcount(BPMEMORY)) { dputs("No hardware breakpoints to enable!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed + if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed return STATUS_ERROR; dputs("All memory breakpoints enabled!"); GuiUpdateAllViews(); @@ -1308,7 +1310,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint { dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1320,8 +1322,8 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint size = 0; - MemFindBaseAddr(found.addr, &size); - if(!BpEnable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint)) + memfindbaseaddr(found.addr, &size); + if(!bpenable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint)) { dprintf("Could not enable memory breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -1336,12 +1338,12 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, true)) //delete all memory breakpoints { - if(!BpGetCount(BPMEMORY)) + if(!bpgetcount(BPMEMORY)) { dputs("No memory breakpoints to disable!"); return STATUS_CONTINUE; } - if(!BpEnumAll(cbDisableAllMemoryBreakpoints)) //at least one deletion failed + if(!bpenumall(cbDisableAllMemoryBreakpoints)) //at least one deletion failed return STATUS_ERROR; dputs("All memory breakpoints disabled!"); GuiUpdateAllViews(); @@ -1349,7 +1351,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) } BREAKPOINT found; uint addr = 0; - if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint + if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint { dprintf("No such memory breakpoint \"%s\"\n", arg1); return STATUS_ERROR; @@ -1360,8 +1362,8 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } uint size = 0; - MemFindBaseAddr(found.addr, &size); - if(!BpEnable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size)) + memfindbaseaddr(found.addr, &size); + if(!bpenable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size)) { dprintf("Could not disable memory breakpoint "fhex"\n", found.addr); return STATUS_ERROR; @@ -1382,13 +1384,13 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[]) } if(argc < 2) //no arguments { - SymDownloadAllSymbols(szSymbolStore); //download symbols for all modules + symdownloadallsymbols(szSymbolStore); //download symbols for all modules GuiSymbolRefreshCurrent(); dputs("Done! See symbol log for more information"); return STATUS_CONTINUE; } //get some module information - uint modbase = ModBaseFromName(argv[1]); + uint modbase = modbasefromname(argv[1]); if(!modbase) { dprintf("Invalid module \"%s\"!\n", argv[1]); @@ -1798,7 +1800,7 @@ CMDRESULT cbDebugSetPageRights(int argc, char* argv[]) //update the memory map dbggetprivateusage(fdProcessInfo->hProcess, true); - MemUpdateMap(fdProcessInfo->hProcess); + memupdatemap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); dprintf("New rights of "fhex": %s\n", addr, rights); @@ -1815,7 +1817,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) } LoadLibThreadID = fdProcessInfo->dwThreadId; - HANDLE LoadLibThread = ThreadGetHandle((DWORD)LoadLibThreadID); + HANDLE LoadLibThread = threadgethandle((DWORD)LoadLibThreadID); DLLNameMem = VirtualAllocEx(fdProcessInfo->hProcess, NULL, strlen(argv[1]) + 1, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); ASMAddr = VirtualAllocEx(fdProcessInfo->hProcess, NULL, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); @@ -1826,7 +1828,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) return STATUS_ERROR; } - if(!MemWrite(DLLNameMem, argv[1], strlen(argv[1]), NULL)) + if(!memwrite(fdProcessInfo->hProcess, DLLNameMem, argv[1], strlen(argv[1]), NULL)) { dprintf("Error: couldn't write process memory"); return STATUS_ERROR; @@ -1867,7 +1869,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) SetContextDataEx(LoadLibThread, UE_CIP, (uint)ASMAddr); SetBPX((uint)ASMAddr + counter, UE_SINGLESHOOT | UE_BREAKPOINT_TYPE_INT3, (void*)cbLoadLibBPX); - ThreadSuspendAll(); + threadsuspendall(); ResumeThread(LoadLibThread); unlock(WAITID_RUN); @@ -1878,7 +1880,7 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) void cbLoadLibBPX() { uint LibAddr = 0; - HANDLE LoadLibThread = ThreadGetHandle((DWORD)LoadLibThreadID); + HANDLE LoadLibThread = threadgethandle((DWORD)LoadLibThreadID); #ifdef _WIN64 LibAddr = GetContextDataEx(LoadLibThread, UE_RAX); #else @@ -1889,7 +1891,7 @@ void cbLoadLibBPX() SetFullContextDataEx(LoadLibThread, &backupctx); VirtualFreeEx(fdProcessInfo->hProcess, DLLNameMem, 0, MEM_RELEASE); VirtualFreeEx(fdProcessInfo->hProcess, ASMAddr, 0, MEM_RELEASE); - ThreadResumeAll(); + threadresumeall(); //update GUI GuiSetDebugState(paused); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); @@ -2000,7 +2002,7 @@ CMDRESULT cbDebugSetCmdline(int argc, char* argv[]) //update the memory map dbggetprivateusage(fdProcessInfo->hProcess, true); - MemUpdateMap(fdProcessInfo->hProcess); + memupdatemap(fdProcessInfo->hProcess); GuiUpdateMemoryView(); dprintf("New command line: %s\n", argv[1]); diff --git a/x64_dbg_dbg/disasm_fast.cpp b/x64_dbg_dbg/disasm_fast.cpp index 137f30fa..c68e5052 100644 --- a/x64_dbg_dbg/disasm_fast.cpp +++ b/x64_dbg_dbg/disasm_fast.cpp @@ -117,7 +117,7 @@ bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinf bool disasmfast(uint addr, BASIC_INSTRUCTION_INFO* basicinfo) { unsigned int data[16]; - if(!MemRead((void*)addr, data, sizeof(data), 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data), 0)) return false; return disasmfast((unsigned char*)data, addr, basicinfo); } \ No newline at end of file diff --git a/x64_dbg_dbg/disasm_helper.cpp b/x64_dbg_dbg/disasm_helper.cpp index ca179165..cdee9c63 100644 --- a/x64_dbg_dbg/disasm_helper.cpp +++ b/x64_dbg_dbg/disasm_helper.cpp @@ -321,11 +321,11 @@ bool disasmispossiblestring(uint addr) { unsigned char data[11]; memset(data, 0, sizeof(data)); - if(!MemRead((void*)addr, data, sizeof(data) - 3, 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data) - 3, 0)) return false; uint test = 0; memcpy(&test, data, sizeof(uint)); - if(MemIsValidReadPtr(test)) //imports/pointers + if(memisvalidreadptr(fdProcessInfo->hProcess, test)) //imports/pointers return false; if(isasciistring(data, sizeof(data)) or isunicodestring(data, _countof(data))) return true; @@ -340,11 +340,11 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, return false; Memory data((maxlen + 1) * 2, "disasmgetstringat:data"); memset(data, 0, (maxlen + 1) * 2); - if(!MemRead((void*)addr, data, (maxlen + 1) * 2, 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, (maxlen + 1) * 2, 0)) return false; uint test = 0; memcpy(&test, data, sizeof(uint)); - if(MemIsValidReadPtr(test)) + if(memisvalidreadptr(fdProcessInfo->hProcess, test)) return false; if(isasciistring(data, maxlen)) { @@ -442,7 +442,7 @@ int disasmgetsize(uint addr, unsigned char* data) int disasmgetsize(uint addr) { char data[16]; - if(!MemRead((void*)addr, data, sizeof(data), 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)addr, data, sizeof(data), 0)) return 1; return disasmgetsize(addr, (unsigned char*)data); } \ No newline at end of file diff --git a/x64_dbg_dbg/dynamicmem.h b/x64_dbg_dbg/dynamicmem.h index 69bbb89e..1e251e44 100644 --- a/x64_dbg_dbg/dynamicmem.h +++ b/x64_dbg_dbg/dynamicmem.h @@ -1,73 +1,64 @@ -#pragma once +#ifndef _DYNAMICMEM_H +#define _DYNAMICMEM_H template class Memory { public: - // - // This class guarantees that the returned allocated memory - // will always be zeroed - // - Memory(const char* Reason = "Memory:???") + Memory(const char* reason = "Memory:???") { - m_Ptr = nullptr; - m_Size = 0; - m_Reason = Reason; + mPtr = 0; + mSize = 0; + mReason = reason; } - Memory(size_t Size, const char* Reason = "Memory:???") + Memory(size_t size, const char* reason = "Memory:???") { - m_Ptr = reinterpret_cast(emalloc(Size)); - m_Size = Size; - m_Reason = Reason; - - memset(m_Ptr, 0, Size); + mPtr = reinterpret_cast(emalloc(size)); + mSize = size; + mReason = reason; + memset(mPtr, 0, size); } ~Memory() { - if (m_Ptr) - efree(m_Ptr); + efree(mPtr); } - T realloc(size_t Size, const char* Reason = "Memory:???") + T realloc(size_t size, const char* reason = "Memory:???") { - m_Ptr = reinterpret_cast(erealloc(m_Ptr, Size)); - m_Size = Size; - m_Reason = Reason; - - return (T)memset(m_Ptr, 0, m_Size); + mPtr = reinterpret_cast(erealloc(mPtr, size)); + mSize = size; + mReason = reason; + memset(mPtr, 0, size); + return mPtr; } - size_t size() - { - return m_Size; - } - template operator U() { - return (U)m_Ptr; + return (U)mPtr; } operator T() { - return m_Ptr; + return mPtr; } T operator()() { - return m_Ptr; + return mPtr; } - template - T operator+(const U& Other) - { - return m_Ptr + Other; - } + size_t size() + { + return mSize; + } private: - T m_Ptr; - size_t m_Size; - const char* m_Reason; -}; \ No newline at end of file + T mPtr; + size_t mSize; + const char* mReason; +}; + +#endif //_DYNAMICMEM_H \ No newline at end of file diff --git a/x64_dbg_dbg/error.cpp b/x64_dbg_dbg/error.cpp index 80d0da73..c950011d 100644 --- a/x64_dbg_dbg/error.cpp +++ b/x64_dbg_dbg/error.cpp @@ -1,2204 +1,2202 @@ #include "error.h" -#include +#include -std::unordered_map ErrorNames; +static std::map errorNames; -void ErrorCodeInit() +void errorinit() { - ErrorNames.clear(); - ErrorNames.insert(std::make_pair(0, "ERROR_SUCCESS")); - ErrorNames.insert(std::make_pair(1, "ERROR_INVALID_FUNCTION")); - ErrorNames.insert(std::make_pair(2, "ERROR_FILE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(3, "ERROR_PATH_NOT_FOUND")); - ErrorNames.insert(std::make_pair(4, "ERROR_TOO_MANY_OPEN_FILES")); - ErrorNames.insert(std::make_pair(5, "ERROR_ACCESS_DENIED")); - ErrorNames.insert(std::make_pair(6, "ERROR_INVALID_HANDLE")); - ErrorNames.insert(std::make_pair(7, "ERROR_ARENA_TRASHED")); - ErrorNames.insert(std::make_pair(8, "ERROR_NOT_ENOUGH_MEMORY")); - ErrorNames.insert(std::make_pair(9, "ERROR_INVALID_BLOCK")); - ErrorNames.insert(std::make_pair(10, "ERROR_BAD_ENVIRONMENT")); - ErrorNames.insert(std::make_pair(11, "ERROR_BAD_FORMAT")); - ErrorNames.insert(std::make_pair(12, "ERROR_INVALID_ACCESS")); - ErrorNames.insert(std::make_pair(13, "ERROR_INVALID_DATA")); - ErrorNames.insert(std::make_pair(14, "ERROR_OUTOFMEMORY")); - ErrorNames.insert(std::make_pair(15, "ERROR_INVALID_DRIVE")); - ErrorNames.insert(std::make_pair(16, "ERROR_CURRENT_DIRECTORY")); - ErrorNames.insert(std::make_pair(17, "ERROR_NOT_SAME_DEVICE")); - ErrorNames.insert(std::make_pair(18, "ERROR_NO_MORE_FILES")); - ErrorNames.insert(std::make_pair(19, "ERROR_WRITE_PROTECT")); - ErrorNames.insert(std::make_pair(20, "ERROR_BAD_UNIT")); - ErrorNames.insert(std::make_pair(21, "ERROR_NOT_READY")); - ErrorNames.insert(std::make_pair(22, "ERROR_BAD_COMMAND")); - ErrorNames.insert(std::make_pair(23, "ERROR_CRC")); - ErrorNames.insert(std::make_pair(24, "ERROR_BAD_LENGTH")); - ErrorNames.insert(std::make_pair(25, "ERROR_SEEK")); - ErrorNames.insert(std::make_pair(26, "ERROR_NOT_DOS_DISK")); - ErrorNames.insert(std::make_pair(27, "ERROR_SECTOR_NOT_FOUND")); - ErrorNames.insert(std::make_pair(28, "ERROR_OUT_OF_PAPER")); - ErrorNames.insert(std::make_pair(29, "ERROR_WRITE_FAULT")); - ErrorNames.insert(std::make_pair(30, "ERROR_READ_FAULT")); - ErrorNames.insert(std::make_pair(31, "ERROR_GEN_FAILURE")); - ErrorNames.insert(std::make_pair(32, "ERROR_SHARING_VIOLATION")); - ErrorNames.insert(std::make_pair(33, "ERROR_LOCK_VIOLATION")); - ErrorNames.insert(std::make_pair(34, "ERROR_WRONG_DISK")); - ErrorNames.insert(std::make_pair(36, "ERROR_SHARING_BUFFER_EXCEEDED")); - ErrorNames.insert(std::make_pair(38, "ERROR_HANDLE_EOF")); - ErrorNames.insert(std::make_pair(39, "ERROR_HANDLE_DISK_FULL")); - ErrorNames.insert(std::make_pair(50, "ERROR_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(51, "ERROR_REM_NOT_LIST")); - ErrorNames.insert(std::make_pair(52, "ERROR_DUP_NAME")); - ErrorNames.insert(std::make_pair(53, "ERROR_BAD_NETPATH")); - ErrorNames.insert(std::make_pair(54, "ERROR_NETWORK_BUSY")); - ErrorNames.insert(std::make_pair(55, "ERROR_DEV_NOT_EXIST")); - ErrorNames.insert(std::make_pair(56, "ERROR_TOO_MANY_CMDS")); - ErrorNames.insert(std::make_pair(57, "ERROR_ADAP_HDW_ERR")); - ErrorNames.insert(std::make_pair(58, "ERROR_BAD_NET_RESP")); - ErrorNames.insert(std::make_pair(59, "ERROR_UNEXP_NET_ERR")); - ErrorNames.insert(std::make_pair(60, "ERROR_BAD_REM_ADAP")); - ErrorNames.insert(std::make_pair(61, "ERROR_PRINTQ_FULL")); - ErrorNames.insert(std::make_pair(62, "ERROR_NO_SPOOL_SPACE")); - ErrorNames.insert(std::make_pair(63, "ERROR_PRINT_CANCELLED")); - ErrorNames.insert(std::make_pair(64, "ERROR_NETNAME_DELETED")); - ErrorNames.insert(std::make_pair(65, "ERROR_NETWORK_ACCESS_DENIED")); - ErrorNames.insert(std::make_pair(66, "ERROR_BAD_DEV_TYPE")); - ErrorNames.insert(std::make_pair(67, "ERROR_BAD_NET_NAME")); - ErrorNames.insert(std::make_pair(68, "ERROR_TOO_MANY_NAMES")); - ErrorNames.insert(std::make_pair(69, "ERROR_TOO_MANY_SESS")); - ErrorNames.insert(std::make_pair(70, "ERROR_SHARING_PAUSED")); - ErrorNames.insert(std::make_pair(71, "ERROR_REQ_NOT_ACCEP")); - ErrorNames.insert(std::make_pair(72, "ERROR_REDIR_PAUSED")); - ErrorNames.insert(std::make_pair(80, "ERROR_FILE_EXISTS")); - ErrorNames.insert(std::make_pair(82, "ERROR_CANNOT_MAKE")); - ErrorNames.insert(std::make_pair(83, "ERROR_FAIL_I24")); - ErrorNames.insert(std::make_pair(84, "ERROR_OUT_OF_STRUCTURES")); - ErrorNames.insert(std::make_pair(85, "ERROR_ALREADY_ASSIGNED")); - ErrorNames.insert(std::make_pair(86, "ERROR_INVALID_PASSWORD")); - ErrorNames.insert(std::make_pair(87, "ERROR_INVALID_PARAMETER")); - ErrorNames.insert(std::make_pair(88, "ERROR_NET_WRITE_FAULT")); - ErrorNames.insert(std::make_pair(89, "ERROR_NO_PROC_SLOTS")); - ErrorNames.insert(std::make_pair(100, "ERROR_TOO_MANY_SEMAPHORES")); - ErrorNames.insert(std::make_pair(101, "ERROR_EXCL_SEM_ALREADY_OWNED")); - ErrorNames.insert(std::make_pair(102, "ERROR_SEM_IS_SET")); - ErrorNames.insert(std::make_pair(103, "ERROR_TOO_MANY_SEM_REQUESTS")); - ErrorNames.insert(std::make_pair(104, "ERROR_INVALID_AT_INTERRUPT_TIME")); - ErrorNames.insert(std::make_pair(105, "ERROR_SEM_OWNER_DIED")); - ErrorNames.insert(std::make_pair(106, "ERROR_SEM_USER_LIMIT")); - ErrorNames.insert(std::make_pair(107, "ERROR_DISK_CHANGE")); - ErrorNames.insert(std::make_pair(108, "ERROR_DRIVE_LOCKED")); - ErrorNames.insert(std::make_pair(109, "ERROR_BROKEN_PIPE")); - ErrorNames.insert(std::make_pair(110, "ERROR_OPEN_FAILED")); - ErrorNames.insert(std::make_pair(111, "ERROR_BUFFER_OVERFLOW")); - ErrorNames.insert(std::make_pair(112, "ERROR_DISK_FULL")); - ErrorNames.insert(std::make_pair(113, "ERROR_NO_MORE_SEARCH_HANDLES")); - ErrorNames.insert(std::make_pair(114, "ERROR_INVALID_TARGET_HANDLE")); - ErrorNames.insert(std::make_pair(117, "ERROR_INVALID_CATEGORY")); - ErrorNames.insert(std::make_pair(118, "ERROR_INVALID_VERIFY_SWITCH")); - ErrorNames.insert(std::make_pair(119, "ERROR_BAD_DRIVER_LEVEL")); - ErrorNames.insert(std::make_pair(120, "ERROR_CALL_NOT_IMPLEMENTED")); - ErrorNames.insert(std::make_pair(121, "ERROR_SEM_TIMEOUT")); - ErrorNames.insert(std::make_pair(122, "ERROR_INSUFFICIENT_BUFFER")); - ErrorNames.insert(std::make_pair(123, "ERROR_INVALID_NAME")); - ErrorNames.insert(std::make_pair(124, "ERROR_INVALID_LEVEL")); - ErrorNames.insert(std::make_pair(125, "ERROR_NO_VOLUME_LABEL")); - ErrorNames.insert(std::make_pair(126, "ERROR_MOD_NOT_FOUND")); - ErrorNames.insert(std::make_pair(127, "ERROR_PROC_NOT_FOUND")); - ErrorNames.insert(std::make_pair(128, "ERROR_WAIT_NO_CHILDREN")); - ErrorNames.insert(std::make_pair(129, "ERROR_CHILD_NOT_COMPLETE")); - ErrorNames.insert(std::make_pair(130, "ERROR_DIRECT_ACCESS_HANDLE")); - ErrorNames.insert(std::make_pair(131, "ERROR_NEGATIVE_SEEK")); - ErrorNames.insert(std::make_pair(132, "ERROR_SEEK_ON_DEVICE")); - ErrorNames.insert(std::make_pair(133, "ERROR_IS_JOIN_TARGET")); - ErrorNames.insert(std::make_pair(134, "ERROR_IS_JOINED")); - ErrorNames.insert(std::make_pair(135, "ERROR_IS_SUBSTED")); - ErrorNames.insert(std::make_pair(136, "ERROR_NOT_JOINED")); - ErrorNames.insert(std::make_pair(137, "ERROR_NOT_SUBSTED")); - ErrorNames.insert(std::make_pair(138, "ERROR_JOIN_TO_JOIN")); - ErrorNames.insert(std::make_pair(139, "ERROR_SUBST_TO_SUBST")); - ErrorNames.insert(std::make_pair(140, "ERROR_JOIN_TO_SUBST")); - ErrorNames.insert(std::make_pair(141, "ERROR_SUBST_TO_JOIN")); - ErrorNames.insert(std::make_pair(142, "ERROR_BUSY_DRIVE")); - ErrorNames.insert(std::make_pair(143, "ERROR_SAME_DRIVE")); - ErrorNames.insert(std::make_pair(144, "ERROR_DIR_NOT_ROOT")); - ErrorNames.insert(std::make_pair(145, "ERROR_DIR_NOT_EMPTY")); - ErrorNames.insert(std::make_pair(146, "ERROR_IS_SUBST_PATH")); - ErrorNames.insert(std::make_pair(147, "ERROR_IS_JOIN_PATH")); - ErrorNames.insert(std::make_pair(148, "ERROR_PATH_BUSY")); - ErrorNames.insert(std::make_pair(149, "ERROR_IS_SUBST_TARGET")); - ErrorNames.insert(std::make_pair(150, "ERROR_SYSTEM_TRACE")); - ErrorNames.insert(std::make_pair(151, "ERROR_INVALID_EVENT_COUNT")); - ErrorNames.insert(std::make_pair(152, "ERROR_TOO_MANY_MUXWAITERS")); - ErrorNames.insert(std::make_pair(153, "ERROR_INVALID_LIST_FORMAT")); - ErrorNames.insert(std::make_pair(154, "ERROR_LABEL_TOO_LONG")); - ErrorNames.insert(std::make_pair(155, "ERROR_TOO_MANY_TCBS")); - ErrorNames.insert(std::make_pair(156, "ERROR_SIGNAL_REFUSED")); - ErrorNames.insert(std::make_pair(157, "ERROR_DISCARDED")); - ErrorNames.insert(std::make_pair(158, "ERROR_NOT_LOCKED")); - ErrorNames.insert(std::make_pair(159, "ERROR_BAD_THREADID_ADDR")); - ErrorNames.insert(std::make_pair(160, "ERROR_BAD_ARGUMENTS")); - ErrorNames.insert(std::make_pair(161, "ERROR_BAD_PATHNAME")); - ErrorNames.insert(std::make_pair(162, "ERROR_SIGNAL_PENDING")); - ErrorNames.insert(std::make_pair(164, "ERROR_MAX_THRDS_REACHED")); - ErrorNames.insert(std::make_pair(167, "ERROR_LOCK_FAILED")); - ErrorNames.insert(std::make_pair(170, "ERROR_BUSY")); - ErrorNames.insert(std::make_pair(173, "ERROR_CANCEL_VIOLATION")); - ErrorNames.insert(std::make_pair(174, "ERROR_ATOMIC_LOCKS_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(180, "ERROR_INVALID_SEGMENT_NUMBER")); - ErrorNames.insert(std::make_pair(182, "ERROR_INVALID_ORDINAL")); - ErrorNames.insert(std::make_pair(183, "ERROR_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(186, "ERROR_INVALID_FLAG_NUMBER")); - ErrorNames.insert(std::make_pair(187, "ERROR_SEM_NOT_FOUND")); - ErrorNames.insert(std::make_pair(188, "ERROR_INVALID_STARTING_CODESEG")); - ErrorNames.insert(std::make_pair(189, "ERROR_INVALID_STACKSEG")); - ErrorNames.insert(std::make_pair(190, "ERROR_INVALID_MODULETYPE")); - ErrorNames.insert(std::make_pair(191, "ERROR_INVALID_EXE_SIGNATURE")); - ErrorNames.insert(std::make_pair(192, "ERROR_EXE_MARKED_INVALID")); - ErrorNames.insert(std::make_pair(193, "ERROR_BAD_EXE_FORMAT")); - ErrorNames.insert(std::make_pair(194, "ERROR_ITERATED_DATA_EXCEEDS_64k")); - ErrorNames.insert(std::make_pair(195, "ERROR_INVALID_MINALLOCSIZE")); - ErrorNames.insert(std::make_pair(196, "ERROR_DYNLINK_FROM_INVALID_RING")); - ErrorNames.insert(std::make_pair(197, "ERROR_IOPL_NOT_ENABLED")); - ErrorNames.insert(std::make_pair(198, "ERROR_INVALID_SEGDPL")); - ErrorNames.insert(std::make_pair(199, "ERROR_AUTODATASEG_EXCEEDS_64k")); - ErrorNames.insert(std::make_pair(200, "ERROR_RING2SEG_MUST_BE_MOVABLE")); - ErrorNames.insert(std::make_pair(201, "ERROR_RELOC_CHAIN_XEEDS_SEGLIM")); - ErrorNames.insert(std::make_pair(202, "ERROR_INFLOOP_IN_RELOC_CHAIN")); - ErrorNames.insert(std::make_pair(203, "ERROR_ENVVAR_NOT_FOUND")); - ErrorNames.insert(std::make_pair(205, "ERROR_NO_SIGNAL_SENT")); - ErrorNames.insert(std::make_pair(206, "ERROR_FILENAME_EXCED_RANGE")); - ErrorNames.insert(std::make_pair(207, "ERROR_RING2_STACK_IN_USE")); - ErrorNames.insert(std::make_pair(208, "ERROR_META_EXPANSION_TOO_LONG")); - ErrorNames.insert(std::make_pair(209, "ERROR_INVALID_SIGNAL_NUMBER")); - ErrorNames.insert(std::make_pair(210, "ERROR_THREAD_1_INACTIVE")); - ErrorNames.insert(std::make_pair(212, "ERROR_LOCKED")); - ErrorNames.insert(std::make_pair(214, "ERROR_TOO_MANY_MODULES")); - ErrorNames.insert(std::make_pair(215, "ERROR_NESTING_NOT_ALLOWED")); - ErrorNames.insert(std::make_pair(216, "ERROR_EXE_MACHINE_TYPE_MISMATCH")); - ErrorNames.insert(std::make_pair(217, "ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY")); - ErrorNames.insert(std::make_pair(218, "ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY")); - ErrorNames.insert(std::make_pair(220, "ERROR_FILE_CHECKED_OUT")); - ErrorNames.insert(std::make_pair(221, "ERROR_CHECKOUT_REQUIRED")); - ErrorNames.insert(std::make_pair(222, "ERROR_BAD_FILE_TYPE")); - ErrorNames.insert(std::make_pair(223, "ERROR_FILE_TOO_LARGE")); - ErrorNames.insert(std::make_pair(224, "ERROR_FORMS_AUTH_REQUIRED")); - ErrorNames.insert(std::make_pair(225, "ERROR_VIRUS_INFECTED")); - ErrorNames.insert(std::make_pair(226, "ERROR_VIRUS_DELETED")); - ErrorNames.insert(std::make_pair(229, "ERROR_PIPE_LOCAL")); - ErrorNames.insert(std::make_pair(230, "ERROR_BAD_PIPE")); - ErrorNames.insert(std::make_pair(231, "ERROR_PIPE_BUSY")); - ErrorNames.insert(std::make_pair(232, "ERROR_NO_DATA")); - ErrorNames.insert(std::make_pair(233, "ERROR_PIPE_NOT_CONNECTED")); - ErrorNames.insert(std::make_pair(234, "ERROR_MORE_DATA")); - ErrorNames.insert(std::make_pair(240, "ERROR_VC_DISCONNECTED")); - ErrorNames.insert(std::make_pair(254, "ERROR_INVALID_EA_NAME")); - ErrorNames.insert(std::make_pair(255, "ERROR_EA_LIST_INCONSISTENT")); - ErrorNames.insert(std::make_pair(259, "ERROR_NO_MORE_ITEMS")); - ErrorNames.insert(std::make_pair(266, "ERROR_CANNOT_COPY")); - ErrorNames.insert(std::make_pair(267, "ERROR_DIRECTORY")); - ErrorNames.insert(std::make_pair(275, "ERROR_EAS_DIDNT_FIT")); - ErrorNames.insert(std::make_pair(276, "ERROR_EA_FILE_CORRUPT")); - ErrorNames.insert(std::make_pair(277, "ERROR_EA_TABLE_FULL")); - ErrorNames.insert(std::make_pair(278, "ERROR_INVALID_EA_HANDLE")); - ErrorNames.insert(std::make_pair(282, "ERROR_EAS_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(288, "ERROR_NOT_OWNER")); - ErrorNames.insert(std::make_pair(298, "ERROR_TOO_MANY_POSTS")); - ErrorNames.insert(std::make_pair(299, "ERROR_PARTIAL_COPY")); - ErrorNames.insert(std::make_pair(300, "ERROR_OPLOCK_NOT_GRANTED")); - ErrorNames.insert(std::make_pair(301, "ERROR_INVALID_OPLOCK_PROTOCOL")); - ErrorNames.insert(std::make_pair(302, "ERROR_DISK_TOO_FRAGMENTED")); - ErrorNames.insert(std::make_pair(303, "ERROR_DELETE_PENDING")); - ErrorNames.insert(std::make_pair(304, "ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING")); - ErrorNames.insert(std::make_pair(305, "ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME")); - ErrorNames.insert(std::make_pair(306, "ERROR_SECURITY_STREAM_IS_INCONSISTENT")); - ErrorNames.insert(std::make_pair(307, "ERROR_INVALID_LOCK_RANGE")); - ErrorNames.insert(std::make_pair(308, "ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT")); - ErrorNames.insert(std::make_pair(309, "ERROR_NOTIFICATION_GUID_ALREADY_DEFINED")); - ErrorNames.insert(std::make_pair(317, "ERROR_MR_MID_NOT_FOUND")); - ErrorNames.insert(std::make_pair(318, "ERROR_SCOPE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(350, "ERROR_FAIL_NOACTION_REBOOT")); - ErrorNames.insert(std::make_pair(351, "ERROR_FAIL_SHUTDOWN")); - ErrorNames.insert(std::make_pair(352, "ERROR_FAIL_RESTART")); - ErrorNames.insert(std::make_pair(353, "ERROR_MAX_SESSIONS_REACHED")); - ErrorNames.insert(std::make_pair(400, "ERROR_THREAD_MODE_ALREADY_BACKGROUND")); - ErrorNames.insert(std::make_pair(401, "ERROR_THREAD_MODE_NOT_BACKGROUND")); - ErrorNames.insert(std::make_pair(402, "ERROR_PROCESS_MODE_ALREADY_BACKGROUND")); - ErrorNames.insert(std::make_pair(403, "ERROR_PROCESS_MODE_NOT_BACKGROUND")); - ErrorNames.insert(std::make_pair(487, "ERROR_INVALID_ADDRESS")); - ErrorNames.insert(std::make_pair(500, "ERROR_USER_PROFILE_LOAD")); - ErrorNames.insert(std::make_pair(534, "ERROR_ARITHMETIC_OVERFLOW")); - ErrorNames.insert(std::make_pair(535, "ERROR_PIPE_CONNECTED")); - ErrorNames.insert(std::make_pair(536, "ERROR_PIPE_LISTENING")); - ErrorNames.insert(std::make_pair(537, "ERROR_VERIFIER_STOP")); - ErrorNames.insert(std::make_pair(538, "ERROR_ABIOS_ERROR")); - ErrorNames.insert(std::make_pair(539, "ERROR_WX86_WARNING")); - ErrorNames.insert(std::make_pair(540, "ERROR_WX86_ERROR")); - ErrorNames.insert(std::make_pair(541, "ERROR_TIMER_NOT_CANCELED")); - ErrorNames.insert(std::make_pair(542, "ERROR_UNWIND")); - ErrorNames.insert(std::make_pair(543, "ERROR_BAD_STACK")); - ErrorNames.insert(std::make_pair(544, "ERROR_INVALID_UNWIND_TARGET")); - ErrorNames.insert(std::make_pair(545, "ERROR_INVALID_PORT_ATTRIBUTES")); - ErrorNames.insert(std::make_pair(546, "ERROR_PORT_MESSAGE_TOO_LONG")); - ErrorNames.insert(std::make_pair(547, "ERROR_INVALID_QUOTA_LOWER")); - ErrorNames.insert(std::make_pair(548, "ERROR_DEVICE_ALREADY_ATTACHED")); - ErrorNames.insert(std::make_pair(549, "ERROR_INSTRUCTION_MISALIGNMENT")); - ErrorNames.insert(std::make_pair(550, "ERROR_PROFILING_NOT_STARTED")); - ErrorNames.insert(std::make_pair(551, "ERROR_PROFILING_NOT_STOPPED")); - ErrorNames.insert(std::make_pair(552, "ERROR_COULD_NOT_INTERPRET")); - ErrorNames.insert(std::make_pair(553, "ERROR_PROFILING_AT_LIMIT")); - ErrorNames.insert(std::make_pair(554, "ERROR_CANT_WAIT")); - ErrorNames.insert(std::make_pair(555, "ERROR_CANT_TERMINATE_SELF")); - ErrorNames.insert(std::make_pair(556, "ERROR_UNEXPECTED_MM_CREATE_ERR")); - ErrorNames.insert(std::make_pair(557, "ERROR_UNEXPECTED_MM_MAP_ERROR")); - ErrorNames.insert(std::make_pair(558, "ERROR_UNEXPECTED_MM_EXTEND_ERR")); - ErrorNames.insert(std::make_pair(559, "ERROR_BAD_FUNCTION_TABLE")); - ErrorNames.insert(std::make_pair(560, "ERROR_NO_GUID_TRANSLATION")); - ErrorNames.insert(std::make_pair(561, "ERROR_INVALID_LDT_SIZE")); - ErrorNames.insert(std::make_pair(563, "ERROR_INVALID_LDT_OFFSET")); - ErrorNames.insert(std::make_pair(564, "ERROR_INVALID_LDT_DESCRIPTOR")); - ErrorNames.insert(std::make_pair(565, "ERROR_TOO_MANY_THREADS")); - ErrorNames.insert(std::make_pair(566, "ERROR_THREAD_NOT_IN_PROCESS")); - ErrorNames.insert(std::make_pair(567, "ERROR_PAGEFILE_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(568, "ERROR_LOGON_SERVER_CONFLICT")); - ErrorNames.insert(std::make_pair(569, "ERROR_SYNCHRONIZATION_REQUIRED")); - ErrorNames.insert(std::make_pair(570, "ERROR_NET_OPEN_FAILED")); - ErrorNames.insert(std::make_pair(571, "ERROR_IO_PRIVILEGE_FAILED")); - ErrorNames.insert(std::make_pair(572, "ERROR_CONTROL_C_EXIT")); - ErrorNames.insert(std::make_pair(573, "ERROR_MISSING_SYSTEMFILE")); - ErrorNames.insert(std::make_pair(574, "ERROR_UNHANDLED_EXCEPTION")); - ErrorNames.insert(std::make_pair(575, "ERROR_APP_INIT_FAILURE")); - ErrorNames.insert(std::make_pair(576, "ERROR_PAGEFILE_CREATE_FAILED")); - ErrorNames.insert(std::make_pair(577, "ERROR_INVALID_IMAGE_HASH")); - ErrorNames.insert(std::make_pair(578, "ERROR_NO_PAGEFILE")); - ErrorNames.insert(std::make_pair(579, "ERROR_ILLEGAL_FLOAT_CONTEXT")); - ErrorNames.insert(std::make_pair(580, "ERROR_NO_EVENT_PAIR")); - ErrorNames.insert(std::make_pair(581, "ERROR_DOMAIN_CTRLR_CONFIG_ERROR")); - ErrorNames.insert(std::make_pair(582, "ERROR_ILLEGAL_CHARACTER")); - ErrorNames.insert(std::make_pair(583, "ERROR_UNDEFINED_CHARACTER")); - ErrorNames.insert(std::make_pair(584, "ERROR_FLOPPY_VOLUME")); - ErrorNames.insert(std::make_pair(585, "ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT")); - ErrorNames.insert(std::make_pair(586, "ERROR_BACKUP_CONTROLLER")); - ErrorNames.insert(std::make_pair(587, "ERROR_MUTANT_LIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(588, "ERROR_FS_DRIVER_REQUIRED")); - ErrorNames.insert(std::make_pair(589, "ERROR_CANNOT_LOAD_REGISTRY_FILE")); - ErrorNames.insert(std::make_pair(590, "ERROR_DEBUG_ATTACH_FAILED")); - ErrorNames.insert(std::make_pair(591, "ERROR_SYSTEM_PROCESS_TERMINATED")); - ErrorNames.insert(std::make_pair(592, "ERROR_DATA_NOT_ACCEPTED")); - ErrorNames.insert(std::make_pair(593, "ERROR_VDM_HARD_ERROR")); - ErrorNames.insert(std::make_pair(594, "ERROR_DRIVER_CANCEL_TIMEOUT")); - ErrorNames.insert(std::make_pair(595, "ERROR_REPLY_MESSAGE_MISMATCH")); - ErrorNames.insert(std::make_pair(596, "ERROR_LOST_WRITEBEHIND_DATA")); - ErrorNames.insert(std::make_pair(597, "ERROR_CLIENT_SERVER_PARAMETERS_INVALID")); - ErrorNames.insert(std::make_pair(598, "ERROR_NOT_TINY_STREAM")); - ErrorNames.insert(std::make_pair(599, "ERROR_STACK_OVERFLOW_READ")); - ErrorNames.insert(std::make_pair(600, "ERROR_CONVERT_TO_LARGE")); - ErrorNames.insert(std::make_pair(601, "ERROR_FOUND_OUT_OF_SCOPE")); - ErrorNames.insert(std::make_pair(602, "ERROR_ALLOCATE_BUCKET")); - ErrorNames.insert(std::make_pair(603, "ERROR_MARSHALL_OVERFLOW")); - ErrorNames.insert(std::make_pair(604, "ERROR_INVALID_VARIANT")); - ErrorNames.insert(std::make_pair(605, "ERROR_BAD_COMPRESSION_BUFFER")); - ErrorNames.insert(std::make_pair(606, "ERROR_AUDIT_FAILED")); - ErrorNames.insert(std::make_pair(607, "ERROR_TIMER_RESOLUTION_NOT_SET")); - ErrorNames.insert(std::make_pair(608, "ERROR_INSUFFICIENT_LOGON_INFO")); - ErrorNames.insert(std::make_pair(609, "ERROR_BAD_DLL_ENTRYPOINT")); - ErrorNames.insert(std::make_pair(610, "ERROR_BAD_SERVICE_ENTRYPOINT")); - ErrorNames.insert(std::make_pair(611, "ERROR_IP_ADDRESS_CONFLICT1")); - ErrorNames.insert(std::make_pair(612, "ERROR_IP_ADDRESS_CONFLICT2")); - ErrorNames.insert(std::make_pair(613, "ERROR_REGISTRY_QUOTA_LIMIT")); - ErrorNames.insert(std::make_pair(614, "ERROR_NO_CALLBACK_ACTIVE")); - ErrorNames.insert(std::make_pair(615, "ERROR_PWD_TOO_SHORT")); - ErrorNames.insert(std::make_pair(616, "ERROR_PWD_TOO_RECENT")); - ErrorNames.insert(std::make_pair(617, "ERROR_PWD_HISTORY_CONFLICT")); - ErrorNames.insert(std::make_pair(618, "ERROR_UNSUPPORTED_COMPRESSION")); - ErrorNames.insert(std::make_pair(619, "ERROR_INVALID_HW_PROFILE")); - ErrorNames.insert(std::make_pair(620, "ERROR_INVALID_PLUGPLAY_DEVICE_PATH")); - ErrorNames.insert(std::make_pair(621, "ERROR_QUOTA_LIST_INCONSISTENT")); - ErrorNames.insert(std::make_pair(622, "ERROR_EVALUATION_EXPIRATION")); - ErrorNames.insert(std::make_pair(623, "ERROR_ILLEGAL_DLL_RELOCATION")); - ErrorNames.insert(std::make_pair(624, "ERROR_DLL_INIT_FAILED_LOGOFF")); - ErrorNames.insert(std::make_pair(625, "ERROR_VALIDATE_CONTINUE")); - ErrorNames.insert(std::make_pair(626, "ERROR_NO_MORE_MATCHES")); - ErrorNames.insert(std::make_pair(627, "ERROR_RANGE_LIST_CONFLICT")); - ErrorNames.insert(std::make_pair(628, "ERROR_SERVER_SID_MISMATCH")); - ErrorNames.insert(std::make_pair(629, "ERROR_CANT_ENABLE_DENY_ONLY")); - ErrorNames.insert(std::make_pair(630, "ERROR_FLOAT_MULTIPLE_FAULTS")); - ErrorNames.insert(std::make_pair(631, "ERROR_FLOAT_MULTIPLE_TRAPS")); - ErrorNames.insert(std::make_pair(632, "ERROR_NOINTERFACE")); - ErrorNames.insert(std::make_pair(633, "ERROR_DRIVER_FAILED_SLEEP")); - ErrorNames.insert(std::make_pair(634, "ERROR_CORRUPT_SYSTEM_FILE")); - ErrorNames.insert(std::make_pair(635, "ERROR_COMMITMENT_MINIMUM")); - ErrorNames.insert(std::make_pair(636, "ERROR_PNP_RESTART_ENUMERATION")); - ErrorNames.insert(std::make_pair(637, "ERROR_SYSTEM_IMAGE_BAD_SIGNATURE")); - ErrorNames.insert(std::make_pair(638, "ERROR_PNP_REBOOT_REQUIRED")); - ErrorNames.insert(std::make_pair(639, "ERROR_INSUFFICIENT_POWER")); - ErrorNames.insert(std::make_pair(640, "ERROR_MULTIPLE_FAULT_VIOLATION")); - ErrorNames.insert(std::make_pair(641, "ERROR_SYSTEM_SHUTDOWN")); - ErrorNames.insert(std::make_pair(642, "ERROR_PORT_NOT_SET")); - ErrorNames.insert(std::make_pair(643, "ERROR_DS_VERSION_CHECK_FAILURE")); - ErrorNames.insert(std::make_pair(644, "ERROR_RANGE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(646, "ERROR_NOT_SAFE_MODE_DRIVER")); - ErrorNames.insert(std::make_pair(647, "ERROR_FAILED_DRIVER_ENTRY")); - ErrorNames.insert(std::make_pair(648, "ERROR_DEVICE_ENUMERATION_ERROR")); - ErrorNames.insert(std::make_pair(649, "ERROR_MOUNT_POINT_NOT_RESOLVED")); - ErrorNames.insert(std::make_pair(650, "ERROR_INVALID_DEVICE_OBJECT_PARAMETER")); - ErrorNames.insert(std::make_pair(651, "ERROR_MCA_OCCURED")); - ErrorNames.insert(std::make_pair(652, "ERROR_DRIVER_DATABASE_ERROR")); - ErrorNames.insert(std::make_pair(653, "ERROR_SYSTEM_HIVE_TOO_LARGE")); - ErrorNames.insert(std::make_pair(654, "ERROR_DRIVER_FAILED_PRIOR_UNLOAD")); - ErrorNames.insert(std::make_pair(655, "ERROR_VOLSNAP_PREPARE_HIBERNATE")); - ErrorNames.insert(std::make_pair(656, "ERROR_HIBERNATION_FAILURE")); - ErrorNames.insert(std::make_pair(665, "ERROR_FILE_SYSTEM_LIMITATION")); - ErrorNames.insert(std::make_pair(668, "ERROR_ASSERTION_FAILURE")); - ErrorNames.insert(std::make_pair(669, "ERROR_ACPI_ERROR")); - ErrorNames.insert(std::make_pair(670, "ERROR_WOW_ASSERTION")); - ErrorNames.insert(std::make_pair(671, "ERROR_PNP_BAD_MPS_TABLE")); - ErrorNames.insert(std::make_pair(672, "ERROR_PNP_TRANSLATION_FAILED")); - ErrorNames.insert(std::make_pair(673, "ERROR_PNP_IRQ_TRANSLATION_FAILED")); - ErrorNames.insert(std::make_pair(674, "ERROR_PNP_INVALID_ID")); - ErrorNames.insert(std::make_pair(675, "ERROR_WAKE_SYSTEM_DEBUGGER")); - ErrorNames.insert(std::make_pair(676, "ERROR_HANDLES_CLOSED")); - ErrorNames.insert(std::make_pair(677, "ERROR_EXTRANEOUS_INFORMATION")); - ErrorNames.insert(std::make_pair(678, "ERROR_RXACT_COMMIT_NECESSARY")); - ErrorNames.insert(std::make_pair(679, "ERROR_MEDIA_CHECK")); - ErrorNames.insert(std::make_pair(680, "ERROR_GUID_SUBSTITUTION_MADE")); - ErrorNames.insert(std::make_pair(681, "ERROR_STOPPED_ON_SYMLINK")); - ErrorNames.insert(std::make_pair(682, "ERROR_LONGJUMP")); - ErrorNames.insert(std::make_pair(683, "ERROR_PLUGPLAY_QUERY_VETOED")); - ErrorNames.insert(std::make_pair(684, "ERROR_UNWIND_CONSOLIDATE")); - ErrorNames.insert(std::make_pair(685, "ERROR_REGISTRY_HIVE_RECOVERED")); - ErrorNames.insert(std::make_pair(686, "ERROR_DLL_MIGHT_BE_INSECURE")); - ErrorNames.insert(std::make_pair(687, "ERROR_DLL_MIGHT_BE_INCOMPATIBLE")); - ErrorNames.insert(std::make_pair(688, "ERROR_DBG_EXCEPTION_NOT_HANDLED")); - ErrorNames.insert(std::make_pair(689, "ERROR_DBG_REPLY_LATER")); - ErrorNames.insert(std::make_pair(690, "ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE")); - ErrorNames.insert(std::make_pair(691, "ERROR_DBG_TERMINATE_THREAD")); - ErrorNames.insert(std::make_pair(692, "ERROR_DBG_TERMINATE_PROCESS")); - ErrorNames.insert(std::make_pair(693, "ERROR_DBG_CONTROL_C")); - ErrorNames.insert(std::make_pair(694, "ERROR_DBG_PRINTEXCEPTION_C")); - ErrorNames.insert(std::make_pair(695, "ERROR_DBG_RIPEXCEPTION")); - ErrorNames.insert(std::make_pair(696, "ERROR_DBG_CONTROL_BREAK")); - ErrorNames.insert(std::make_pair(697, "ERROR_DBG_COMMAND_EXCEPTION")); - ErrorNames.insert(std::make_pair(698, "ERROR_OBJECT_NAME_EXISTS")); - ErrorNames.insert(std::make_pair(699, "ERROR_THREAD_WAS_SUSPENDED")); - ErrorNames.insert(std::make_pair(700, "ERROR_IMAGE_NOT_AT_BASE")); - ErrorNames.insert(std::make_pair(701, "ERROR_RXACT_STATE_CREATED")); - ErrorNames.insert(std::make_pair(702, "ERROR_SEGMENT_NOTIFICATION")); - ErrorNames.insert(std::make_pair(703, "ERROR_BAD_CURRENT_DIRECTORY")); - ErrorNames.insert(std::make_pair(704, "ERROR_FT_READ_RECOVERY_FROM_BACKUP")); - ErrorNames.insert(std::make_pair(705, "ERROR_FT_WRITE_RECOVERY")); - ErrorNames.insert(std::make_pair(706, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH")); - ErrorNames.insert(std::make_pair(707, "ERROR_RECEIVE_PARTIAL")); - ErrorNames.insert(std::make_pair(708, "ERROR_RECEIVE_EXPEDITED")); - ErrorNames.insert(std::make_pair(709, "ERROR_RECEIVE_PARTIAL_EXPEDITED")); - ErrorNames.insert(std::make_pair(710, "ERROR_EVENT_DONE")); - ErrorNames.insert(std::make_pair(711, "ERROR_EVENT_PENDING")); - ErrorNames.insert(std::make_pair(712, "ERROR_CHECKING_FILE_SYSTEM")); - ErrorNames.insert(std::make_pair(713, "ERROR_FATAL_APP_EXIT")); - ErrorNames.insert(std::make_pair(714, "ERROR_PREDEFINED_HANDLE")); - ErrorNames.insert(std::make_pair(715, "ERROR_WAS_UNLOCKED")); - ErrorNames.insert(std::make_pair(716, "ERROR_SERVICE_NOTIFICATION")); - ErrorNames.insert(std::make_pair(717, "ERROR_WAS_LOCKED")); - ErrorNames.insert(std::make_pair(718, "ERROR_LOG_HARD_ERROR")); - ErrorNames.insert(std::make_pair(719, "ERROR_ALREADY_WIN32")); - ErrorNames.insert(std::make_pair(720, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE")); - ErrorNames.insert(std::make_pair(721, "ERROR_NO_YIELD_PERFORMED")); - ErrorNames.insert(std::make_pair(722, "ERROR_TIMER_RESUME_IGNORED")); - ErrorNames.insert(std::make_pair(723, "ERROR_ARBITRATION_UNHANDLED")); - ErrorNames.insert(std::make_pair(724, "ERROR_CARDBUS_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(725, "ERROR_MP_PROCESSOR_MISMATCH")); - ErrorNames.insert(std::make_pair(726, "ERROR_HIBERNATED")); - ErrorNames.insert(std::make_pair(727, "ERROR_RESUME_HIBERNATION")); - ErrorNames.insert(std::make_pair(728, "ERROR_FIRMWARE_UPDATED")); - ErrorNames.insert(std::make_pair(729, "ERROR_DRIVERS_LEAKING_LOCKED_PAGES")); - ErrorNames.insert(std::make_pair(730, "ERROR_WAKE_SYSTEM")); - ErrorNames.insert(std::make_pair(731, "ERROR_WAIT_1")); - ErrorNames.insert(std::make_pair(732, "ERROR_WAIT_2")); - ErrorNames.insert(std::make_pair(733, "ERROR_WAIT_3")); - ErrorNames.insert(std::make_pair(734, "ERROR_WAIT_63")); - ErrorNames.insert(std::make_pair(735, "ERROR_ABANDONED_WAIT_0")); - ErrorNames.insert(std::make_pair(736, "ERROR_ABANDONED_WAIT_63")); - ErrorNames.insert(std::make_pair(737, "ERROR_USER_APC")); - ErrorNames.insert(std::make_pair(738, "ERROR_KERNEL_APC")); - ErrorNames.insert(std::make_pair(739, "ERROR_ALERTED")); - ErrorNames.insert(std::make_pair(740, "ERROR_ELEVATION_REQUIRED")); - ErrorNames.insert(std::make_pair(741, "ERROR_REPARSE")); - ErrorNames.insert(std::make_pair(742, "ERROR_OPLOCK_BREAK_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(743, "ERROR_VOLUME_MOUNTED")); - ErrorNames.insert(std::make_pair(744, "ERROR_RXACT_COMMITTED")); - ErrorNames.insert(std::make_pair(745, "ERROR_NOTIFY_CLEANUP")); - ErrorNames.insert(std::make_pair(746, "ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED")); - ErrorNames.insert(std::make_pair(747, "ERROR_PAGE_FAULT_TRANSITION")); - ErrorNames.insert(std::make_pair(748, "ERROR_PAGE_FAULT_DEMAND_ZERO")); - ErrorNames.insert(std::make_pair(749, "ERROR_PAGE_FAULT_COPY_ON_WRITE")); - ErrorNames.insert(std::make_pair(750, "ERROR_PAGE_FAULT_GUARD_PAGE")); - ErrorNames.insert(std::make_pair(751, "ERROR_PAGE_FAULT_PAGING_FILE")); - ErrorNames.insert(std::make_pair(752, "ERROR_CACHE_PAGE_LOCKED")); - ErrorNames.insert(std::make_pair(753, "ERROR_CRASH_DUMP")); - ErrorNames.insert(std::make_pair(754, "ERROR_BUFFER_ALL_ZEROS")); - ErrorNames.insert(std::make_pair(755, "ERROR_REPARSE_OBJECT")); - ErrorNames.insert(std::make_pair(756, "ERROR_RESOURCE_REQUIREMENTS_CHANGED")); - ErrorNames.insert(std::make_pair(757, "ERROR_TRANSLATION_COMPLETE")); - ErrorNames.insert(std::make_pair(758, "ERROR_NOTHING_TO_TERMINATE")); - ErrorNames.insert(std::make_pair(759, "ERROR_PROCESS_NOT_IN_JOB")); - ErrorNames.insert(std::make_pair(760, "ERROR_PROCESS_IN_JOB")); - ErrorNames.insert(std::make_pair(761, "ERROR_VOLSNAP_HIBERNATE_READY")); - ErrorNames.insert(std::make_pair(762, "ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY")); - ErrorNames.insert(std::make_pair(763, "ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED")); - ErrorNames.insert(std::make_pair(764, "ERROR_INTERRUPT_STILL_CONNECTED")); - ErrorNames.insert(std::make_pair(765, "ERROR_WAIT_FOR_OPLOCK")); - ErrorNames.insert(std::make_pair(766, "ERROR_DBG_EXCEPTION_HANDLED")); - ErrorNames.insert(std::make_pair(767, "ERROR_DBG_CONTINUE")); - ErrorNames.insert(std::make_pair(768, "ERROR_CALLBACK_POP_STACK")); - ErrorNames.insert(std::make_pair(769, "ERROR_COMPRESSION_DISABLED")); - ErrorNames.insert(std::make_pair(770, "ERROR_CANTFETCHBACKWARDS")); - ErrorNames.insert(std::make_pair(771, "ERROR_CANTSCROLLBACKWARDS")); - ErrorNames.insert(std::make_pair(772, "ERROR_ROWSNOTRELEASED")); - ErrorNames.insert(std::make_pair(773, "ERROR_BAD_ACCESSOR_FLAGS")); - ErrorNames.insert(std::make_pair(774, "ERROR_ERRORS_ENCOUNTERED")); - ErrorNames.insert(std::make_pair(775, "ERROR_NOT_CAPABLE")); - ErrorNames.insert(std::make_pair(776, "ERROR_REQUEST_OUT_OF_SEQUENCE")); - ErrorNames.insert(std::make_pair(777, "ERROR_VERSION_PARSE_ERROR")); - ErrorNames.insert(std::make_pair(778, "ERROR_BADSTARTPOSITION")); - ErrorNames.insert(std::make_pair(779, "ERROR_MEMORY_HARDWARE")); - ErrorNames.insert(std::make_pair(780, "ERROR_DISK_REPAIR_DISABLED")); - ErrorNames.insert(std::make_pair(781, "ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE")); - ErrorNames.insert(std::make_pair(782, "ERROR_SYSTEM_POWERSTATE_TRANSITION")); - ErrorNames.insert(std::make_pair(783, "ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION")); - ErrorNames.insert(std::make_pair(784, "ERROR_MCA_EXCEPTION")); - ErrorNames.insert(std::make_pair(785, "ERROR_ACCESS_AUDIT_BY_POLICY")); - ErrorNames.insert(std::make_pair(786, "ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY")); - ErrorNames.insert(std::make_pair(787, "ERROR_ABANDON_HIBERFILE")); - ErrorNames.insert(std::make_pair(788, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED")); - ErrorNames.insert(std::make_pair(789, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR")); - ErrorNames.insert(std::make_pair(790, "ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR")); - ErrorNames.insert(std::make_pair(791, "ERROR_BAD_MCFG_TABLE")); - ErrorNames.insert(std::make_pair(800, "ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE")); - ErrorNames.insert(std::make_pair(801, "ERROR_CANNOT_GRANT_REQUESTED_OPLOCK")); - ErrorNames.insert(std::make_pair(802, "ERROR_CANNOT_BREAK_OPLOCK")); - ErrorNames.insert(std::make_pair(803, "ERROR_OPLOCK_HANDLE_CLOSED")); - ErrorNames.insert(std::make_pair(804, "ERROR_NO_ACE_CONDITION")); - ErrorNames.insert(std::make_pair(805, "ERROR_INVALID_ACE_CONDITION")); - ErrorNames.insert(std::make_pair(994, "ERROR_EA_ACCESS_DENIED")); - ErrorNames.insert(std::make_pair(995, "ERROR_OPERATION_ABORTED")); - ErrorNames.insert(std::make_pair(996, "ERROR_IO_INCOMPLETE")); - ErrorNames.insert(std::make_pair(997, "ERROR_IO_PENDING")); - ErrorNames.insert(std::make_pair(998, "ERROR_NOACCESS")); - ErrorNames.insert(std::make_pair(999, "ERROR_SWAPERROR")); - ErrorNames.insert(std::make_pair(1001, "ERROR_STACK_OVERFLOW")); - ErrorNames.insert(std::make_pair(1002, "ERROR_INVALID_MESSAGE")); - ErrorNames.insert(std::make_pair(1003, "ERROR_CAN_NOT_COMPLETE")); - ErrorNames.insert(std::make_pair(1004, "ERROR_INVALID_FLAGS")); - ErrorNames.insert(std::make_pair(1005, "ERROR_UNRECOGNIZED_VOLUME")); - ErrorNames.insert(std::make_pair(1006, "ERROR_FILE_INVALID")); - ErrorNames.insert(std::make_pair(1007, "ERROR_FULLSCREEN_MODE")); - ErrorNames.insert(std::make_pair(1008, "ERROR_NO_TOKEN")); - ErrorNames.insert(std::make_pair(1009, "ERROR_BADDB")); - ErrorNames.insert(std::make_pair(1010, "ERROR_BADKEY")); - ErrorNames.insert(std::make_pair(1011, "ERROR_CANTOPEN")); - ErrorNames.insert(std::make_pair(1012, "ERROR_CANTREAD")); - ErrorNames.insert(std::make_pair(1013, "ERROR_CANTWRITE")); - ErrorNames.insert(std::make_pair(1014, "ERROR_REGISTRY_RECOVERED")); - ErrorNames.insert(std::make_pair(1015, "ERROR_REGISTRY_CORRUPT")); - ErrorNames.insert(std::make_pair(1016, "ERROR_REGISTRY_IO_FAILED")); - ErrorNames.insert(std::make_pair(1017, "ERROR_NOT_REGISTRY_FILE")); - ErrorNames.insert(std::make_pair(1018, "ERROR_KEY_DELETED")); - ErrorNames.insert(std::make_pair(1019, "ERROR_NO_LOG_SPACE")); - ErrorNames.insert(std::make_pair(1020, "ERROR_KEY_HAS_CHILDREN")); - ErrorNames.insert(std::make_pair(1021, "ERROR_CHILD_MUST_BE_VOLATILE")); - ErrorNames.insert(std::make_pair(1022, "ERROR_NOTIFY_ENUM_DIR")); - ErrorNames.insert(std::make_pair(1051, "ERROR_DEPENDENT_SERVICES_RUNNING")); - ErrorNames.insert(std::make_pair(1052, "ERROR_INVALID_SERVICE_CONTROL")); - ErrorNames.insert(std::make_pair(1053, "ERROR_SERVICE_REQUEST_TIMEOUT")); - ErrorNames.insert(std::make_pair(1054, "ERROR_SERVICE_NO_THREAD")); - ErrorNames.insert(std::make_pair(1055, "ERROR_SERVICE_DATABASE_LOCKED")); - ErrorNames.insert(std::make_pair(1056, "ERROR_SERVICE_ALREADY_RUNNING")); - ErrorNames.insert(std::make_pair(1057, "ERROR_INVALID_SERVICE_ACCOUNT")); - ErrorNames.insert(std::make_pair(1058, "ERROR_SERVICE_DISABLED")); - ErrorNames.insert(std::make_pair(1059, "ERROR_CIRCULAR_DEPENDENCY")); - ErrorNames.insert(std::make_pair(1060, "ERROR_SERVICE_DOES_NOT_EXIST")); - ErrorNames.insert(std::make_pair(1061, "ERROR_SERVICE_CANNOT_ACCEPT_CTRL")); - ErrorNames.insert(std::make_pair(1062, "ERROR_SERVICE_NOT_ACTIVE")); - ErrorNames.insert(std::make_pair(1063, "ERROR_FAILED_SERVICE_CONTROLLER_CONNECT")); - ErrorNames.insert(std::make_pair(1064, "ERROR_EXCEPTION_IN_SERVICE")); - ErrorNames.insert(std::make_pair(1065, "ERROR_DATABASE_DOES_NOT_EXIST")); - ErrorNames.insert(std::make_pair(1066, "ERROR_SERVICE_SPECIFIC_ERROR")); - ErrorNames.insert(std::make_pair(1067, "ERROR_PROCESS_ABORTED")); - ErrorNames.insert(std::make_pair(1068, "ERROR_SERVICE_DEPENDENCY_FAIL")); - ErrorNames.insert(std::make_pair(1069, "ERROR_SERVICE_LOGON_FAILED")); - ErrorNames.insert(std::make_pair(1070, "ERROR_SERVICE_START_HANG")); - ErrorNames.insert(std::make_pair(1071, "ERROR_INVALID_SERVICE_LOCK")); - ErrorNames.insert(std::make_pair(1072, "ERROR_SERVICE_MARKED_FOR_DELETE")); - ErrorNames.insert(std::make_pair(1073, "ERROR_SERVICE_EXISTS")); - ErrorNames.insert(std::make_pair(1074, "ERROR_ALREADY_RUNNING_LKG")); - ErrorNames.insert(std::make_pair(1075, "ERROR_SERVICE_DEPENDENCY_DELETED")); - ErrorNames.insert(std::make_pair(1076, "ERROR_BOOT_ALREADY_ACCEPTED")); - ErrorNames.insert(std::make_pair(1077, "ERROR_SERVICE_NEVER_STARTED")); - ErrorNames.insert(std::make_pair(1078, "ERROR_DUPLICATE_SERVICE_NAME")); - ErrorNames.insert(std::make_pair(1079, "ERROR_DIFFERENT_SERVICE_ACCOUNT")); - ErrorNames.insert(std::make_pair(1080, "ERROR_CANNOT_DETECT_DRIVER_FAILURE")); - ErrorNames.insert(std::make_pair(1081, "ERROR_CANNOT_DETECT_PROCESS_ABORT")); - ErrorNames.insert(std::make_pair(1082, "ERROR_NO_RECOVERY_PROGRAM")); - ErrorNames.insert(std::make_pair(1083, "ERROR_SERVICE_NOT_IN_EXE")); - ErrorNames.insert(std::make_pair(1084, "ERROR_NOT_SAFEBOOT_SERVICE")); - ErrorNames.insert(std::make_pair(1100, "ERROR_END_OF_MEDIA")); - ErrorNames.insert(std::make_pair(1101, "ERROR_FILEMARK_DETECTED")); - ErrorNames.insert(std::make_pair(1102, "ERROR_BEGINNING_OF_MEDIA")); - ErrorNames.insert(std::make_pair(1103, "ERROR_SETMARK_DETECTED")); - ErrorNames.insert(std::make_pair(1104, "ERROR_NO_DATA_DETECTED")); - ErrorNames.insert(std::make_pair(1105, "ERROR_PARTITION_FAILURE")); - ErrorNames.insert(std::make_pair(1106, "ERROR_INVALID_BLOCK_LENGTH")); - ErrorNames.insert(std::make_pair(1107, "ERROR_DEVICE_NOT_PARTITIONED")); - ErrorNames.insert(std::make_pair(1108, "ERROR_UNABLE_TO_LOCK_MEDIA")); - ErrorNames.insert(std::make_pair(1109, "ERROR_UNABLE_TO_UNLOAD_MEDIA")); - ErrorNames.insert(std::make_pair(1110, "ERROR_MEDIA_CHANGED")); - ErrorNames.insert(std::make_pair(1111, "ERROR_BUS_RESET")); - ErrorNames.insert(std::make_pair(1112, "ERROR_NO_MEDIA_IN_DRIVE")); - ErrorNames.insert(std::make_pair(1113, "ERROR_NO_UNICODE_TRANSLATION")); - ErrorNames.insert(std::make_pair(1114, "ERROR_DLL_INIT_FAILED")); - ErrorNames.insert(std::make_pair(1115, "ERROR_SHUTDOWN_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(1116, "ERROR_NO_SHUTDOWN_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(1117, "ERROR_IO_DEVICE")); - ErrorNames.insert(std::make_pair(1118, "ERROR_SERIAL_NO_DEVICE")); - ErrorNames.insert(std::make_pair(1119, "ERROR_IRQ_BUSY")); - ErrorNames.insert(std::make_pair(1120, "ERROR_MORE_WRITES")); - ErrorNames.insert(std::make_pair(1121, "ERROR_COUNTER_TIMEOUT")); - ErrorNames.insert(std::make_pair(1122, "ERROR_FLOPPY_ID_MARK_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1123, "ERROR_FLOPPY_WRONG_CYLINDER")); - ErrorNames.insert(std::make_pair(1124, "ERROR_FLOPPY_UNKNOWN_ERROR")); - ErrorNames.insert(std::make_pair(1125, "ERROR_FLOPPY_BAD_REGISTERS")); - ErrorNames.insert(std::make_pair(1126, "ERROR_DISK_RECALIBRATE_FAILED")); - ErrorNames.insert(std::make_pair(1127, "ERROR_DISK_OPERATION_FAILED")); - ErrorNames.insert(std::make_pair(1128, "ERROR_DISK_RESET_FAILED")); - ErrorNames.insert(std::make_pair(1129, "ERROR_EOM_OVERFLOW")); - ErrorNames.insert(std::make_pair(1130, "ERROR_NOT_ENOUGH_SERVER_MEMORY")); - ErrorNames.insert(std::make_pair(1131, "ERROR_POSSIBLE_DEADLOCK")); - ErrorNames.insert(std::make_pair(1132, "ERROR_MAPPED_ALIGNMENT")); - ErrorNames.insert(std::make_pair(1140, "ERROR_SET_POWER_STATE_VETOED")); - ErrorNames.insert(std::make_pair(1141, "ERROR_SET_POWER_STATE_FAILED")); - ErrorNames.insert(std::make_pair(1142, "ERROR_TOO_MANY_LINKS")); - ErrorNames.insert(std::make_pair(1150, "ERROR_OLD_WIN_VERSION")); - ErrorNames.insert(std::make_pair(1151, "ERROR_APP_WRONG_OS")); - ErrorNames.insert(std::make_pair(1152, "ERROR_SINGLE_INSTANCE_APP")); - ErrorNames.insert(std::make_pair(1153, "ERROR_RMODE_APP")); - ErrorNames.insert(std::make_pair(1154, "ERROR_INVALID_DLL")); - ErrorNames.insert(std::make_pair(1155, "ERROR_NO_ASSOCIATION")); - ErrorNames.insert(std::make_pair(1156, "ERROR_DDE_FAIL")); - ErrorNames.insert(std::make_pair(1157, "ERROR_DLL_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1158, "ERROR_NO_MORE_USER_HANDLES")); - ErrorNames.insert(std::make_pair(1159, "ERROR_MESSAGE_SYNC_ONLY")); - ErrorNames.insert(std::make_pair(1160, "ERROR_SOURCE_ELEMENT_EMPTY")); - ErrorNames.insert(std::make_pair(1161, "ERROR_DESTINATION_ELEMENT_FULL")); - ErrorNames.insert(std::make_pair(1162, "ERROR_ILLEGAL_ELEMENT_ADDRESS")); - ErrorNames.insert(std::make_pair(1163, "ERROR_MAGAZINE_NOT_PRESENT")); - ErrorNames.insert(std::make_pair(1164, "ERROR_DEVICE_REINITIALIZATION_NEEDED")); - ErrorNames.insert(std::make_pair(1165, "ERROR_DEVICE_REQUIRES_CLEANING")); - ErrorNames.insert(std::make_pair(1166, "ERROR_DEVICE_DOOR_OPEN")); - ErrorNames.insert(std::make_pair(1167, "ERROR_DEVICE_NOT_CONNECTED")); - ErrorNames.insert(std::make_pair(1168, "ERROR_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1169, "ERROR_NO_MATCH")); - ErrorNames.insert(std::make_pair(1170, "ERROR_SET_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1171, "ERROR_POINT_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1172, "ERROR_NO_TRACKING_SERVICE")); - ErrorNames.insert(std::make_pair(1173, "ERROR_NO_VOLUME_ID")); - ErrorNames.insert(std::make_pair(1175, "ERROR_UNABLE_TO_REMOVE_REPLACED")); - ErrorNames.insert(std::make_pair(1176, "ERROR_UNABLE_TO_MOVE_REPLACEMENT")); - ErrorNames.insert(std::make_pair(1177, "ERROR_UNABLE_TO_MOVE_REPLACEMENT_2")); - ErrorNames.insert(std::make_pair(1178, "ERROR_JOURNAL_DELETE_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(1179, "ERROR_JOURNAL_NOT_ACTIVE")); - ErrorNames.insert(std::make_pair(1180, "ERROR_POTENTIAL_FILE_FOUND")); - ErrorNames.insert(std::make_pair(1181, "ERROR_JOURNAL_ENTRY_DELETED")); - ErrorNames.insert(std::make_pair(1190, "ERROR_SHUTDOWN_IS_SCHEDULED")); - ErrorNames.insert(std::make_pair(1191, "ERROR_SHUTDOWN_USERS_LOGGED_ON")); - ErrorNames.insert(std::make_pair(1200, "ERROR_BAD_DEVICE")); - ErrorNames.insert(std::make_pair(1201, "ERROR_CONNECTION_UNAVAIL")); - ErrorNames.insert(std::make_pair(1202, "ERROR_DEVICE_ALREADY_REMEMBERED")); - ErrorNames.insert(std::make_pair(1203, "ERROR_NO_NET_OR_BAD_PATH")); - ErrorNames.insert(std::make_pair(1204, "ERROR_BAD_PROVIDER")); - ErrorNames.insert(std::make_pair(1205, "ERROR_CANNOT_OPEN_PROFILE")); - ErrorNames.insert(std::make_pair(1206, "ERROR_BAD_PROFILE")); - ErrorNames.insert(std::make_pair(1207, "ERROR_NOT_CONTAINER")); - ErrorNames.insert(std::make_pair(1208, "ERROR_EXTENDED_ERROR")); - ErrorNames.insert(std::make_pair(1209, "ERROR_INVALID_GROUPNAME")); - ErrorNames.insert(std::make_pair(1210, "ERROR_INVALID_COMPUTERNAME")); - ErrorNames.insert(std::make_pair(1211, "ERROR_INVALID_EVENTNAME")); - ErrorNames.insert(std::make_pair(1212, "ERROR_INVALID_DOMAINNAME")); - ErrorNames.insert(std::make_pair(1213, "ERROR_INVALID_SERVICENAME")); - ErrorNames.insert(std::make_pair(1214, "ERROR_INVALID_NETNAME")); - ErrorNames.insert(std::make_pair(1215, "ERROR_INVALID_SHARENAME")); - ErrorNames.insert(std::make_pair(1216, "ERROR_INVALID_PASSWORDNAME")); - ErrorNames.insert(std::make_pair(1217, "ERROR_INVALID_MESSAGENAME")); - ErrorNames.insert(std::make_pair(1218, "ERROR_INVALID_MESSAGEDEST")); - ErrorNames.insert(std::make_pair(1219, "ERROR_SESSION_CREDENTIAL_CONFLICT")); - ErrorNames.insert(std::make_pair(1220, "ERROR_REMOTE_SESSION_LIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(1221, "ERROR_DUP_DOMAINNAME")); - ErrorNames.insert(std::make_pair(1222, "ERROR_NO_NETWORK")); - ErrorNames.insert(std::make_pair(1223, "ERROR_CANCELLED")); - ErrorNames.insert(std::make_pair(1224, "ERROR_USER_MAPPED_FILE")); - ErrorNames.insert(std::make_pair(1225, "ERROR_CONNECTION_REFUSED")); - ErrorNames.insert(std::make_pair(1226, "ERROR_GRACEFUL_DISCONNECT")); - ErrorNames.insert(std::make_pair(1227, "ERROR_ADDRESS_ALREADY_ASSOCIATED")); - ErrorNames.insert(std::make_pair(1228, "ERROR_ADDRESS_NOT_ASSOCIATED")); - ErrorNames.insert(std::make_pair(1229, "ERROR_CONNECTION_INVALID")); - ErrorNames.insert(std::make_pair(1230, "ERROR_CONNECTION_ACTIVE")); - ErrorNames.insert(std::make_pair(1231, "ERROR_NETWORK_UNREACHABLE")); - ErrorNames.insert(std::make_pair(1232, "ERROR_HOST_UNREACHABLE")); - ErrorNames.insert(std::make_pair(1233, "ERROR_PROTOCOL_UNREACHABLE")); - ErrorNames.insert(std::make_pair(1234, "ERROR_PORT_UNREACHABLE")); - ErrorNames.insert(std::make_pair(1235, "ERROR_REQUEST_ABORTED")); - ErrorNames.insert(std::make_pair(1236, "ERROR_CONNECTION_ABORTED")); - ErrorNames.insert(std::make_pair(1237, "ERROR_RETRY")); - ErrorNames.insert(std::make_pair(1238, "ERROR_CONNECTION_COUNT_LIMIT")); - ErrorNames.insert(std::make_pair(1239, "ERROR_LOGIN_TIME_RESTRICTION")); - ErrorNames.insert(std::make_pair(1240, "ERROR_LOGIN_WKSTA_RESTRICTION")); - ErrorNames.insert(std::make_pair(1241, "ERROR_INCORRECT_ADDRESS")); - ErrorNames.insert(std::make_pair(1242, "ERROR_ALREADY_REGISTERED")); - ErrorNames.insert(std::make_pair(1243, "ERROR_SERVICE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1244, "ERROR_NOT_AUTHENTICATED")); - ErrorNames.insert(std::make_pair(1245, "ERROR_NOT_LOGGED_ON")); - ErrorNames.insert(std::make_pair(1246, "ERROR_CONTINUE")); - ErrorNames.insert(std::make_pair(1247, "ERROR_ALREADY_INITIALIZED")); - ErrorNames.insert(std::make_pair(1248, "ERROR_NO_MORE_DEVICES")); - ErrorNames.insert(std::make_pair(1249, "ERROR_NO_SUCH_SITE")); - ErrorNames.insert(std::make_pair(1250, "ERROR_DOMAIN_CONTROLLER_EXISTS")); - ErrorNames.insert(std::make_pair(1251, "ERROR_ONLY_IF_CONNECTED")); - ErrorNames.insert(std::make_pair(1252, "ERROR_OVERRIDE_NOCHANGES")); - ErrorNames.insert(std::make_pair(1253, "ERROR_BAD_USER_PROFILE")); - ErrorNames.insert(std::make_pair(1254, "ERROR_NOT_SUPPORTED_ON_SBS")); - ErrorNames.insert(std::make_pair(1255, "ERROR_SERVER_SHUTDOWN_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(1256, "ERROR_HOST_DOWN")); - ErrorNames.insert(std::make_pair(1257, "ERROR_NON_ACCOUNT_SID")); - ErrorNames.insert(std::make_pair(1258, "ERROR_NON_DOMAIN_SID")); - ErrorNames.insert(std::make_pair(1259, "ERROR_APPHELP_BLOCK")); - ErrorNames.insert(std::make_pair(1260, "ERROR_ACCESS_DISABLED_BY_POLICY")); - ErrorNames.insert(std::make_pair(1261, "ERROR_REG_NAT_CONSUMPTION")); - ErrorNames.insert(std::make_pair(1262, "ERROR_CSCSHARE_OFFLINE")); - ErrorNames.insert(std::make_pair(1263, "ERROR_PKINIT_FAILURE")); - ErrorNames.insert(std::make_pair(1264, "ERROR_SMARTCARD_SUBSYSTEM_FAILURE")); - ErrorNames.insert(std::make_pair(1265, "ERROR_DOWNGRADE_DETECTED")); - ErrorNames.insert(std::make_pair(1271, "ERROR_MACHINE_LOCKED")); - ErrorNames.insert(std::make_pair(1273, "ERROR_CALLBACK_SUPPLIED_INVALID_DATA")); - ErrorNames.insert(std::make_pair(1274, "ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED")); - ErrorNames.insert(std::make_pair(1275, "ERROR_DRIVER_BLOCKED")); - ErrorNames.insert(std::make_pair(1276, "ERROR_INVALID_IMPORT_OF_NON_DLL")); - ErrorNames.insert(std::make_pair(1277, "ERROR_ACCESS_DISABLED_WEBBLADE")); - ErrorNames.insert(std::make_pair(1278, "ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER")); - ErrorNames.insert(std::make_pair(1279, "ERROR_RECOVERY_FAILURE")); - ErrorNames.insert(std::make_pair(1280, "ERROR_ALREADY_FIBER")); - ErrorNames.insert(std::make_pair(1281, "ERROR_ALREADY_THREAD")); - ErrorNames.insert(std::make_pair(1282, "ERROR_STACK_BUFFER_OVERRUN")); - ErrorNames.insert(std::make_pair(1283, "ERROR_PARAMETER_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(1284, "ERROR_DEBUGGER_INACTIVE")); - ErrorNames.insert(std::make_pair(1285, "ERROR_DELAY_LOAD_FAILED")); - ErrorNames.insert(std::make_pair(1286, "ERROR_VDM_DISALLOWED")); - ErrorNames.insert(std::make_pair(1287, "ERROR_UNIDENTIFIED_ERROR")); - ErrorNames.insert(std::make_pair(1288, "ERROR_INVALID_CRUNTIME_PARAMETER")); - ErrorNames.insert(std::make_pair(1289, "ERROR_BEYOND_VDL")); - ErrorNames.insert(std::make_pair(1290, "ERROR_INCOMPATIBLE_SERVICE_SID_TYPE")); - ErrorNames.insert(std::make_pair(1291, "ERROR_DRIVER_PROCESS_TERMINATED")); - ErrorNames.insert(std::make_pair(1292, "ERROR_IMPLEMENTATION_LIMIT")); - ErrorNames.insert(std::make_pair(1293, "ERROR_PROCESS_IS_PROTECTED")); - ErrorNames.insert(std::make_pair(1294, "ERROR_SERVICE_NOTIFY_CLIENT_LAGGING")); - ErrorNames.insert(std::make_pair(1295, "ERROR_DISK_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(1296, "ERROR_CONTENT_BLOCKED")); - ErrorNames.insert(std::make_pair(1297, "ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE")); - ErrorNames.insert(std::make_pair(1298, "ERROR_APP_HANG")); - ErrorNames.insert(std::make_pair(1299, "ERROR_INVALID_LABEL")); - ErrorNames.insert(std::make_pair(1300, "ERROR_NOT_ALL_ASSIGNED")); - ErrorNames.insert(std::make_pair(1301, "ERROR_SOME_NOT_MAPPED")); - ErrorNames.insert(std::make_pair(1302, "ERROR_NO_QUOTAS_FOR_ACCOUNT")); - ErrorNames.insert(std::make_pair(1303, "ERROR_LOCAL_USER_SESSION_KEY")); - ErrorNames.insert(std::make_pair(1304, "ERROR_NULL_LM_PASSWORD")); - ErrorNames.insert(std::make_pair(1305, "ERROR_UNKNOWN_REVISION")); - ErrorNames.insert(std::make_pair(1306, "ERROR_REVISION_MISMATCH")); - ErrorNames.insert(std::make_pair(1307, "ERROR_INVALID_OWNER")); - ErrorNames.insert(std::make_pair(1308, "ERROR_INVALID_PRIMARY_GROUP")); - ErrorNames.insert(std::make_pair(1309, "ERROR_NO_IMPERSONATION_TOKEN")); - ErrorNames.insert(std::make_pair(1310, "ERROR_CANT_DISABLE_MANDATORY")); - ErrorNames.insert(std::make_pair(1311, "ERROR_NO_LOGON_SERVERS")); - ErrorNames.insert(std::make_pair(1312, "ERROR_NO_SUCH_LOGON_SESSION")); - ErrorNames.insert(std::make_pair(1313, "ERROR_NO_SUCH_PRIVILEGE")); - ErrorNames.insert(std::make_pair(1314, "ERROR_PRIVILEGE_NOT_HELD")); - ErrorNames.insert(std::make_pair(1315, "ERROR_INVALID_ACCOUNT_NAME")); - ErrorNames.insert(std::make_pair(1316, "ERROR_USER_EXISTS")); - ErrorNames.insert(std::make_pair(1317, "ERROR_NO_SUCH_USER")); - ErrorNames.insert(std::make_pair(1318, "ERROR_GROUP_EXISTS")); - ErrorNames.insert(std::make_pair(1319, "ERROR_NO_SUCH_GROUP")); - ErrorNames.insert(std::make_pair(1320, "ERROR_MEMBER_IN_GROUP")); - ErrorNames.insert(std::make_pair(1321, "ERROR_MEMBER_NOT_IN_GROUP")); - ErrorNames.insert(std::make_pair(1322, "ERROR_LAST_ADMIN")); - ErrorNames.insert(std::make_pair(1323, "ERROR_WRONG_PASSWORD")); - ErrorNames.insert(std::make_pair(1324, "ERROR_ILL_FORMED_PASSWORD")); - ErrorNames.insert(std::make_pair(1325, "ERROR_PASSWORD_RESTRICTION")); - ErrorNames.insert(std::make_pair(1326, "ERROR_LOGON_FAILURE")); - ErrorNames.insert(std::make_pair(1327, "ERROR_ACCOUNT_RESTRICTION")); - ErrorNames.insert(std::make_pair(1328, "ERROR_INVALID_LOGON_HOURS")); - ErrorNames.insert(std::make_pair(1329, "ERROR_INVALID_WORKSTATION")); - ErrorNames.insert(std::make_pair(1330, "ERROR_PASSWORD_EXPIRED")); - ErrorNames.insert(std::make_pair(1331, "ERROR_ACCOUNT_DISABLED")); - ErrorNames.insert(std::make_pair(1332, "ERROR_NONE_MAPPED")); - ErrorNames.insert(std::make_pair(1333, "ERROR_TOO_MANY_LUIDS_REQUESTED")); - ErrorNames.insert(std::make_pair(1334, "ERROR_LUIDS_EXHAUSTED")); - ErrorNames.insert(std::make_pair(1335, "ERROR_INVALID_SUB_AUTHORITY")); - ErrorNames.insert(std::make_pair(1336, "ERROR_INVALID_ACL")); - ErrorNames.insert(std::make_pair(1337, "ERROR_INVALID_SID")); - ErrorNames.insert(std::make_pair(1338, "ERROR_INVALID_SECURITY_DESCR")); - ErrorNames.insert(std::make_pair(1340, "ERROR_BAD_INHERITANCE_ACL")); - ErrorNames.insert(std::make_pair(1341, "ERROR_SERVER_DISABLED")); - ErrorNames.insert(std::make_pair(1342, "ERROR_SERVER_NOT_DISABLED")); - ErrorNames.insert(std::make_pair(1343, "ERROR_INVALID_ID_AUTHORITY")); - ErrorNames.insert(std::make_pair(1344, "ERROR_ALLOTTED_SPACE_EXCEEDED")); - ErrorNames.insert(std::make_pair(1345, "ERROR_INVALID_GROUP_ATTRIBUTES")); - ErrorNames.insert(std::make_pair(1346, "ERROR_BAD_IMPERSONATION_LEVEL")); - ErrorNames.insert(std::make_pair(1347, "ERROR_CANT_OPEN_ANONYMOUS")); - ErrorNames.insert(std::make_pair(1348, "ERROR_BAD_VALIDATION_CLASS")); - ErrorNames.insert(std::make_pair(1349, "ERROR_BAD_TOKEN_TYPE")); - ErrorNames.insert(std::make_pair(1350, "ERROR_NO_SECURITY_ON_OBJECT")); - ErrorNames.insert(std::make_pair(1351, "ERROR_CANT_ACCESS_DOMAIN_INFO")); - ErrorNames.insert(std::make_pair(1352, "ERROR_INVALID_SERVER_STATE")); - ErrorNames.insert(std::make_pair(1353, "ERROR_INVALID_DOMAIN_STATE")); - ErrorNames.insert(std::make_pair(1354, "ERROR_INVALID_DOMAIN_ROLE")); - ErrorNames.insert(std::make_pair(1355, "ERROR_NO_SUCH_DOMAIN")); - ErrorNames.insert(std::make_pair(1356, "ERROR_DOMAIN_EXISTS")); - ErrorNames.insert(std::make_pair(1357, "ERROR_DOMAIN_LIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(1358, "ERROR_INTERNAL_DB_CORRUPTION")); - ErrorNames.insert(std::make_pair(1359, "ERROR_INTERNAL_ERROR")); - ErrorNames.insert(std::make_pair(1360, "ERROR_GENERIC_NOT_MAPPED")); - ErrorNames.insert(std::make_pair(1361, "ERROR_BAD_DESCRIPTOR_FORMAT")); - ErrorNames.insert(std::make_pair(1362, "ERROR_NOT_LOGON_PROCESS")); - ErrorNames.insert(std::make_pair(1363, "ERROR_LOGON_SESSION_EXISTS")); - ErrorNames.insert(std::make_pair(1364, "ERROR_NO_SUCH_PACKAGE")); - ErrorNames.insert(std::make_pair(1365, "ERROR_BAD_LOGON_SESSION_STATE")); - ErrorNames.insert(std::make_pair(1366, "ERROR_LOGON_SESSION_COLLISION")); - ErrorNames.insert(std::make_pair(1367, "ERROR_INVALID_LOGON_TYPE")); - ErrorNames.insert(std::make_pair(1368, "ERROR_CANNOT_IMPERSONATE")); - ErrorNames.insert(std::make_pair(1369, "ERROR_RXACT_INVALID_STATE")); - ErrorNames.insert(std::make_pair(1370, "ERROR_RXACT_COMMIT_FAILURE")); - ErrorNames.insert(std::make_pair(1371, "ERROR_SPECIAL_ACCOUNT")); - ErrorNames.insert(std::make_pair(1372, "ERROR_SPECIAL_GROUP")); - ErrorNames.insert(std::make_pair(1373, "ERROR_SPECIAL_USER")); - ErrorNames.insert(std::make_pair(1374, "ERROR_MEMBERS_PRIMARY_GROUP")); - ErrorNames.insert(std::make_pair(1375, "ERROR_TOKEN_ALREADY_IN_USE")); - ErrorNames.insert(std::make_pair(1376, "ERROR_NO_SUCH_ALIAS")); - ErrorNames.insert(std::make_pair(1377, "ERROR_MEMBER_NOT_IN_ALIAS")); - ErrorNames.insert(std::make_pair(1378, "ERROR_MEMBER_IN_ALIAS")); - ErrorNames.insert(std::make_pair(1379, "ERROR_ALIAS_EXISTS")); - ErrorNames.insert(std::make_pair(1380, "ERROR_LOGON_NOT_GRANTED")); - ErrorNames.insert(std::make_pair(1381, "ERROR_TOO_MANY_SECRETS")); - ErrorNames.insert(std::make_pair(1382, "ERROR_SECRET_TOO_LONG")); - ErrorNames.insert(std::make_pair(1383, "ERROR_INTERNAL_DB_ERROR")); - ErrorNames.insert(std::make_pair(1384, "ERROR_TOO_MANY_CONTEXT_IDS")); - ErrorNames.insert(std::make_pair(1385, "ERROR_LOGON_TYPE_NOT_GRANTED")); - ErrorNames.insert(std::make_pair(1386, "ERROR_NT_CROSS_ENCRYPTION_REQUIRED")); - ErrorNames.insert(std::make_pair(1387, "ERROR_NO_SUCH_MEMBER")); - ErrorNames.insert(std::make_pair(1388, "ERROR_INVALID_MEMBER")); - ErrorNames.insert(std::make_pair(1389, "ERROR_TOO_MANY_SIDS")); - ErrorNames.insert(std::make_pair(1390, "ERROR_LM_CROSS_ENCRYPTION_REQUIRED")); - ErrorNames.insert(std::make_pair(1391, "ERROR_NO_INHERITANCE")); - ErrorNames.insert(std::make_pair(1392, "ERROR_FILE_CORRUPT")); - ErrorNames.insert(std::make_pair(1393, "ERROR_DISK_CORRUPT")); - ErrorNames.insert(std::make_pair(1394, "ERROR_NO_USER_SESSION_KEY")); - ErrorNames.insert(std::make_pair(1395, "ERROR_LICENSE_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(1396, "ERROR_WRONG_TARGET_NAME")); - ErrorNames.insert(std::make_pair(1397, "ERROR_MUTUAL_AUTH_FAILED")); - ErrorNames.insert(std::make_pair(1398, "ERROR_TIME_SKEW")); - ErrorNames.insert(std::make_pair(1399, "ERROR_CURRENT_DOMAIN_NOT_ALLOWED")); - ErrorNames.insert(std::make_pair(1400, "ERROR_INVALID_WINDOW_HANDLE")); - ErrorNames.insert(std::make_pair(1401, "ERROR_INVALID_MENU_HANDLE")); - ErrorNames.insert(std::make_pair(1402, "ERROR_INVALID_CURSOR_HANDLE")); - ErrorNames.insert(std::make_pair(1403, "ERROR_INVALID_ACCEL_HANDLE")); - ErrorNames.insert(std::make_pair(1404, "ERROR_INVALID_HOOK_HANDLE")); - ErrorNames.insert(std::make_pair(1405, "ERROR_INVALID_DWP_HANDLE")); - ErrorNames.insert(std::make_pair(1406, "ERROR_TLW_WITH_WSCHILD")); - ErrorNames.insert(std::make_pair(1407, "ERROR_CANNOT_FIND_WND_CLASS")); - ErrorNames.insert(std::make_pair(1408, "ERROR_WINDOW_OF_OTHER_THREAD")); - ErrorNames.insert(std::make_pair(1409, "ERROR_HOTKEY_ALREADY_REGISTERED")); - ErrorNames.insert(std::make_pair(1410, "ERROR_CLASS_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(1411, "ERROR_CLASS_DOES_NOT_EXIST")); - ErrorNames.insert(std::make_pair(1412, "ERROR_CLASS_HAS_WINDOWS")); - ErrorNames.insert(std::make_pair(1413, "ERROR_INVALID_INDEX")); - ErrorNames.insert(std::make_pair(1414, "ERROR_INVALID_ICON_HANDLE")); - ErrorNames.insert(std::make_pair(1415, "ERROR_PRIVATE_DIALOG_INDEX")); - ErrorNames.insert(std::make_pair(1416, "ERROR_LISTBOX_ID_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1417, "ERROR_NO_WILDCARD_CHARACTERS")); - ErrorNames.insert(std::make_pair(1418, "ERROR_CLIPBOARD_NOT_OPEN")); - ErrorNames.insert(std::make_pair(1419, "ERROR_HOTKEY_NOT_REGISTERED")); - ErrorNames.insert(std::make_pair(1420, "ERROR_WINDOW_NOT_DIALOG")); - ErrorNames.insert(std::make_pair(1421, "ERROR_CONTROL_ID_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1422, "ERROR_INVALID_COMBOBOX_MESSAGE")); - ErrorNames.insert(std::make_pair(1423, "ERROR_WINDOW_NOT_COMBOBOX")); - ErrorNames.insert(std::make_pair(1424, "ERROR_INVALID_EDIT_HEIGHT")); - ErrorNames.insert(std::make_pair(1425, "ERROR_DC_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1426, "ERROR_INVALID_HOOK_FILTER")); - ErrorNames.insert(std::make_pair(1427, "ERROR_INVALID_FILTER_PROC")); - ErrorNames.insert(std::make_pair(1428, "ERROR_HOOK_NEEDS_HMOD")); - ErrorNames.insert(std::make_pair(1429, "ERROR_GLOBAL_ONLY_HOOK")); - ErrorNames.insert(std::make_pair(1430, "ERROR_JOURNAL_HOOK_SET")); - ErrorNames.insert(std::make_pair(1431, "ERROR_HOOK_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(1432, "ERROR_INVALID_LB_MESSAGE")); - ErrorNames.insert(std::make_pair(1433, "ERROR_SETCOUNT_ON_BAD_LB")); - ErrorNames.insert(std::make_pair(1434, "ERROR_LB_WITHOUT_TABSTOPS")); - ErrorNames.insert(std::make_pair(1435, "ERROR_DESTROY_OBJECT_OF_OTHER_THREAD")); - ErrorNames.insert(std::make_pair(1436, "ERROR_CHILD_WINDOW_MENU")); - ErrorNames.insert(std::make_pair(1437, "ERROR_NO_SYSTEM_MENU")); - ErrorNames.insert(std::make_pair(1438, "ERROR_INVALID_MSGBOX_STYLE")); - ErrorNames.insert(std::make_pair(1439, "ERROR_INVALID_SPI_VALUE")); - ErrorNames.insert(std::make_pair(1440, "ERROR_SCREEN_ALREADY_LOCKED")); - ErrorNames.insert(std::make_pair(1441, "ERROR_HWNDS_HAVE_DIFF_PARENT")); - ErrorNames.insert(std::make_pair(1442, "ERROR_NOT_CHILD_WINDOW")); - ErrorNames.insert(std::make_pair(1443, "ERROR_INVALID_GW_COMMAND")); - ErrorNames.insert(std::make_pair(1444, "ERROR_INVALID_THREAD_ID")); - ErrorNames.insert(std::make_pair(1445, "ERROR_NON_MDICHILD_WINDOW")); - ErrorNames.insert(std::make_pair(1446, "ERROR_POPUP_ALREADY_ACTIVE")); - ErrorNames.insert(std::make_pair(1447, "ERROR_NO_SCROLLBARS")); - ErrorNames.insert(std::make_pair(1448, "ERROR_INVALID_SCROLLBAR_RANGE")); - ErrorNames.insert(std::make_pair(1449, "ERROR_INVALID_SHOWWIN_COMMAND")); - ErrorNames.insert(std::make_pair(1450, "ERROR_NO_SYSTEM_RESOURCES")); - ErrorNames.insert(std::make_pair(1451, "ERROR_NONPAGED_SYSTEM_RESOURCES")); - ErrorNames.insert(std::make_pair(1452, "ERROR_PAGED_SYSTEM_RESOURCES")); - ErrorNames.insert(std::make_pair(1453, "ERROR_WORKING_SET_QUOTA")); - ErrorNames.insert(std::make_pair(1454, "ERROR_PAGEFILE_QUOTA")); - ErrorNames.insert(std::make_pair(1455, "ERROR_COMMITMENT_LIMIT")); - ErrorNames.insert(std::make_pair(1456, "ERROR_MENU_ITEM_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1457, "ERROR_INVALID_KEYBOARD_HANDLE")); - ErrorNames.insert(std::make_pair(1458, "ERROR_HOOK_TYPE_NOT_ALLOWED")); - ErrorNames.insert(std::make_pair(1459, "ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION")); - ErrorNames.insert(std::make_pair(1460, "ERROR_TIMEOUT")); - ErrorNames.insert(std::make_pair(1461, "ERROR_INVALID_MONITOR_HANDLE")); - ErrorNames.insert(std::make_pair(1462, "ERROR_INCORRECT_SIZE")); - ErrorNames.insert(std::make_pair(1463, "ERROR_SYMLINK_CLASS_DISABLED")); - ErrorNames.insert(std::make_pair(1464, "ERROR_SYMLINK_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(1465, "ERROR_XML_PARSE_ERROR")); - ErrorNames.insert(std::make_pair(1466, "ERROR_XMLDSIG_ERROR")); - ErrorNames.insert(std::make_pair(1467, "ERROR_RESTART_APPLICATION")); - ErrorNames.insert(std::make_pair(1468, "ERROR_WRONG_COMPARTMENT")); - ErrorNames.insert(std::make_pair(1469, "ERROR_AUTHIP_FAILURE")); - ErrorNames.insert(std::make_pair(1470, "ERROR_NO_NVRAM_RESOURCES")); - ErrorNames.insert(std::make_pair(1500, "ERROR_EVENTLOG_FILE_CORRUPT")); - ErrorNames.insert(std::make_pair(1501, "ERROR_EVENTLOG_CANT_START")); - ErrorNames.insert(std::make_pair(1502, "ERROR_LOG_FILE_FULL")); - ErrorNames.insert(std::make_pair(1503, "ERROR_EVENTLOG_FILE_CHANGED")); - ErrorNames.insert(std::make_pair(1550, "ERROR_INVALID_TASK_NAME")); - ErrorNames.insert(std::make_pair(1551, "ERROR_INVALID_TASK_INDEX")); - ErrorNames.insert(std::make_pair(1552, "ERROR_THREAD_ALREADY_IN_TASK")); - ErrorNames.insert(std::make_pair(1601, "ERROR_INSTALL_SERVICE_FAILURE")); - ErrorNames.insert(std::make_pair(1602, "ERROR_INSTALL_USEREXIT")); - ErrorNames.insert(std::make_pair(1603, "ERROR_INSTALL_FAILURE")); - ErrorNames.insert(std::make_pair(1604, "ERROR_INSTALL_SUSPEND")); - ErrorNames.insert(std::make_pair(1605, "ERROR_UNKNOWN_PRODUCT")); - ErrorNames.insert(std::make_pair(1606, "ERROR_UNKNOWN_FEATURE")); - ErrorNames.insert(std::make_pair(1607, "ERROR_UNKNOWN_COMPONENT")); - ErrorNames.insert(std::make_pair(1608, "ERROR_UNKNOWN_PROPERTY")); - ErrorNames.insert(std::make_pair(1609, "ERROR_INVALID_HANDLE_STATE")); - ErrorNames.insert(std::make_pair(1610, "ERROR_BAD_CONFIGURATION")); - ErrorNames.insert(std::make_pair(1611, "ERROR_INDEX_ABSENT")); - ErrorNames.insert(std::make_pair(1612, "ERROR_INSTALL_SOURCE_ABSENT")); - ErrorNames.insert(std::make_pair(1613, "ERROR_INSTALL_PACKAGE_VERSION")); - ErrorNames.insert(std::make_pair(1614, "ERROR_PRODUCT_UNINSTALLED")); - ErrorNames.insert(std::make_pair(1615, "ERROR_BAD_QUERY_SYNTAX")); - ErrorNames.insert(std::make_pair(1616, "ERROR_INVALID_FIELD")); - ErrorNames.insert(std::make_pair(1617, "ERROR_DEVICE_REMOVED")); - ErrorNames.insert(std::make_pair(1618, "ERROR_INSTALL_ALREADY_RUNNING")); - ErrorNames.insert(std::make_pair(1619, "ERROR_INSTALL_PACKAGE_OPEN_FAILED")); - ErrorNames.insert(std::make_pair(1620, "ERROR_INSTALL_PACKAGE_INVALID")); - ErrorNames.insert(std::make_pair(1621, "ERROR_INSTALL_UI_FAILURE")); - ErrorNames.insert(std::make_pair(1622, "ERROR_INSTALL_LOG_FAILURE")); - ErrorNames.insert(std::make_pair(1623, "ERROR_INSTALL_LANGUAGE_UNSUPPORTED")); - ErrorNames.insert(std::make_pair(1624, "ERROR_INSTALL_TRANSFORM_FAILURE")); - ErrorNames.insert(std::make_pair(1625, "ERROR_INSTALL_PACKAGE_REJECTED")); - ErrorNames.insert(std::make_pair(1626, "ERROR_FUNCTION_NOT_CALLED")); - ErrorNames.insert(std::make_pair(1627, "ERROR_FUNCTION_FAILED")); - ErrorNames.insert(std::make_pair(1628, "ERROR_INVALID_TABLE")); - ErrorNames.insert(std::make_pair(1629, "ERROR_DATATYPE_MISMATCH")); - ErrorNames.insert(std::make_pair(1630, "ERROR_UNSUPPORTED_TYPE")); - ErrorNames.insert(std::make_pair(1631, "ERROR_CREATE_FAILED")); - ErrorNames.insert(std::make_pair(1632, "ERROR_INSTALL_TEMP_UNWRITABLE")); - ErrorNames.insert(std::make_pair(1633, "ERROR_INSTALL_PLATFORM_UNSUPPORTED")); - ErrorNames.insert(std::make_pair(1634, "ERROR_INSTALL_NOTUSED")); - ErrorNames.insert(std::make_pair(1635, "ERROR_PATCH_PACKAGE_OPEN_FAILED")); - ErrorNames.insert(std::make_pair(1636, "ERROR_PATCH_PACKAGE_INVALID")); - ErrorNames.insert(std::make_pair(1637, "ERROR_PATCH_PACKAGE_UNSUPPORTED")); - ErrorNames.insert(std::make_pair(1638, "ERROR_PRODUCT_VERSION")); - ErrorNames.insert(std::make_pair(1639, "ERROR_INVALID_COMMAND_LINE")); - ErrorNames.insert(std::make_pair(1640, "ERROR_INSTALL_REMOTE_DISALLOWED")); - ErrorNames.insert(std::make_pair(1641, "ERROR_SUCCESS_REBOOT_INITIATED")); - ErrorNames.insert(std::make_pair(1642, "ERROR_PATCH_TARGET_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1643, "ERROR_PATCH_PACKAGE_REJECTED")); - ErrorNames.insert(std::make_pair(1644, "ERROR_INSTALL_TRANSFORM_REJECTED")); - ErrorNames.insert(std::make_pair(1645, "ERROR_INSTALL_REMOTE_PROHIBITED")); - ErrorNames.insert(std::make_pair(1646, "ERROR_PATCH_REMOVAL_UNSUPPORTED")); - ErrorNames.insert(std::make_pair(1647, "ERROR_UNKNOWN_PATCH")); - ErrorNames.insert(std::make_pair(1648, "ERROR_PATCH_NO_SEQUENCE")); - ErrorNames.insert(std::make_pair(1649, "ERROR_PATCH_REMOVAL_DISALLOWED")); - ErrorNames.insert(std::make_pair(1650, "ERROR_INVALID_PATCH_XML")); - ErrorNames.insert(std::make_pair(1651, "ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT")); - ErrorNames.insert(std::make_pair(1652, "ERROR_INSTALL_SERVICE_SAFEBOOT")); - ErrorNames.insert(std::make_pair(1653, "ERROR_FAIL_FAST_EXCEPTION")); - ErrorNames.insert(std::make_pair(1784, "ERROR_INVALID_USER_BUFFER")); - ErrorNames.insert(std::make_pair(1785, "ERROR_UNRECOGNIZED_MEDIA")); - ErrorNames.insert(std::make_pair(1786, "ERROR_NO_TRUST_LSA_SECRET")); - ErrorNames.insert(std::make_pair(1787, "ERROR_NO_TRUST_SAM_ACCOUNT")); - ErrorNames.insert(std::make_pair(1788, "ERROR_TRUSTED_DOMAIN_FAILURE")); - ErrorNames.insert(std::make_pair(1789, "ERROR_TRUSTED_RELATIONSHIP_FAILURE")); - ErrorNames.insert(std::make_pair(1790, "ERROR_TRUST_FAILURE")); - ErrorNames.insert(std::make_pair(1792, "ERROR_NETLOGON_NOT_STARTED")); - ErrorNames.insert(std::make_pair(1793, "ERROR_ACCOUNT_EXPIRED")); - ErrorNames.insert(std::make_pair(1794, "ERROR_REDIRECTOR_HAS_OPEN_HANDLES")); - ErrorNames.insert(std::make_pair(1795, "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED")); - ErrorNames.insert(std::make_pair(1796, "ERROR_UNKNOWN_PORT")); - ErrorNames.insert(std::make_pair(1797, "ERROR_UNKNOWN_PRINTER_DRIVER")); - ErrorNames.insert(std::make_pair(1798, "ERROR_UNKNOWN_PRINTPROCESSOR")); - ErrorNames.insert(std::make_pair(1799, "ERROR_INVALID_SEPARATOR_FILE")); - ErrorNames.insert(std::make_pair(1800, "ERROR_INVALID_PRIORITY")); - ErrorNames.insert(std::make_pair(1801, "ERROR_INVALID_PRINTER_NAME")); - ErrorNames.insert(std::make_pair(1802, "ERROR_PRINTER_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(1803, "ERROR_INVALID_PRINTER_COMMAND")); - ErrorNames.insert(std::make_pair(1804, "ERROR_INVALID_DATATYPE")); - ErrorNames.insert(std::make_pair(1805, "ERROR_INVALID_ENVIRONMENT")); - ErrorNames.insert(std::make_pair(1807, "ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT")); - ErrorNames.insert(std::make_pair(1808, "ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT")); - ErrorNames.insert(std::make_pair(1809, "ERROR_NOLOGON_SERVER_TRUST_ACCOUNT")); - ErrorNames.insert(std::make_pair(1810, "ERROR_DOMAIN_TRUST_INCONSISTENT")); - ErrorNames.insert(std::make_pair(1811, "ERROR_SERVER_HAS_OPEN_HANDLES")); - ErrorNames.insert(std::make_pair(1812, "ERROR_RESOURCE_DATA_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1813, "ERROR_RESOURCE_TYPE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1814, "ERROR_RESOURCE_NAME_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1815, "ERROR_RESOURCE_LANG_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1816, "ERROR_NOT_ENOUGH_QUOTA")); - ErrorNames.insert(std::make_pair(1901, "ERROR_INVALID_TIME")); - ErrorNames.insert(std::make_pair(1902, "ERROR_INVALID_FORM_NAME")); - ErrorNames.insert(std::make_pair(1903, "ERROR_INVALID_FORM_SIZE")); - ErrorNames.insert(std::make_pair(1904, "ERROR_ALREADY_WAITING")); - ErrorNames.insert(std::make_pair(1905, "ERROR_PRINTER_DELETED")); - ErrorNames.insert(std::make_pair(1906, "ERROR_INVALID_PRINTER_STATE")); - ErrorNames.insert(std::make_pair(1907, "ERROR_PASSWORD_MUST_CHANGE")); - ErrorNames.insert(std::make_pair(1908, "ERROR_DOMAIN_CONTROLLER_NOT_FOUND")); - ErrorNames.insert(std::make_pair(1909, "ERROR_ACCOUNT_LOCKED_OUT")); - ErrorNames.insert(std::make_pair(1919, "ERROR_NO_SITENAME")); - ErrorNames.insert(std::make_pair(1920, "ERROR_CANT_ACCESS_FILE")); - ErrorNames.insert(std::make_pair(1921, "ERROR_CANT_RESOLVE_FILENAME")); - ErrorNames.insert(std::make_pair(1930, "ERROR_KM_DRIVER_BLOCKED")); - ErrorNames.insert(std::make_pair(1931, "ERROR_CONTEXT_EXPIRED")); - ErrorNames.insert(std::make_pair(1932, "ERROR_PER_USER_TRUST_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(1933, "ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(1934, "ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(1935, "ERROR_AUTHENTICATION_FIREWALL_FAILED")); - ErrorNames.insert(std::make_pair(1936, "ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED")); - ErrorNames.insert(std::make_pair(1937, "ERROR_NTLM_BLOCKED")); - ErrorNames.insert(std::make_pair(2000, "ERROR_INVALID_PIXEL_FORMAT")); - ErrorNames.insert(std::make_pair(2001, "ERROR_BAD_DRIVER")); - ErrorNames.insert(std::make_pair(2002, "ERROR_INVALID_WINDOW_STYLE")); - ErrorNames.insert(std::make_pair(2003, "ERROR_METAFILE_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(2004, "ERROR_TRANSFORM_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(2005, "ERROR_CLIPPING_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(2010, "ERROR_INVALID_CMM")); - ErrorNames.insert(std::make_pair(2011, "ERROR_INVALID_PROFILE")); - ErrorNames.insert(std::make_pair(2012, "ERROR_TAG_NOT_FOUND")); - ErrorNames.insert(std::make_pair(2013, "ERROR_TAG_NOT_PRESENT")); - ErrorNames.insert(std::make_pair(2014, "ERROR_DUPLICATE_TAG")); - ErrorNames.insert(std::make_pair(2015, "ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE")); - ErrorNames.insert(std::make_pair(2016, "ERROR_PROFILE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(2017, "ERROR_INVALID_COLORSPACE")); - ErrorNames.insert(std::make_pair(2018, "ERROR_ICM_NOT_ENABLED")); - ErrorNames.insert(std::make_pair(2019, "ERROR_DELETING_ICM_XFORM")); - ErrorNames.insert(std::make_pair(2020, "ERROR_INVALID_TRANSFORM")); - ErrorNames.insert(std::make_pair(2021, "ERROR_COLORSPACE_MISMATCH")); - ErrorNames.insert(std::make_pair(2022, "ERROR_INVALID_COLORINDEX")); - ErrorNames.insert(std::make_pair(2023, "ERROR_PROFILE_DOES_NOT_MATCH_DEVICE")); - ErrorNames.insert(std::make_pair(2108, "ERROR_CONNECTED_OTHER_PASSWORD")); - ErrorNames.insert(std::make_pair(2109, "ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT")); - ErrorNames.insert(std::make_pair(2202, "ERROR_BAD_USERNAME")); - ErrorNames.insert(std::make_pair(2250, "ERROR_NOT_CONNECTED")); - ErrorNames.insert(std::make_pair(2401, "ERROR_OPEN_FILES")); - ErrorNames.insert(std::make_pair(2402, "ERROR_ACTIVE_CONNECTIONS")); - ErrorNames.insert(std::make_pair(2404, "ERROR_DEVICE_IN_USE")); - ErrorNames.insert(std::make_pair(3000, "ERROR_UNKNOWN_PRINT_MONITOR")); - ErrorNames.insert(std::make_pair(3001, "ERROR_PRINTER_DRIVER_IN_USE")); - ErrorNames.insert(std::make_pair(3002, "ERROR_SPOOL_FILE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(3003, "ERROR_SPL_NO_STARTDOC")); - ErrorNames.insert(std::make_pair(3004, "ERROR_SPL_NO_ADDJOB")); - ErrorNames.insert(std::make_pair(3005, "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED")); - ErrorNames.insert(std::make_pair(3006, "ERROR_PRINT_MONITOR_ALREADY_INSTALLED")); - ErrorNames.insert(std::make_pair(3007, "ERROR_INVALID_PRINT_MONITOR")); - ErrorNames.insert(std::make_pair(3008, "ERROR_PRINT_MONITOR_IN_USE")); - ErrorNames.insert(std::make_pair(3009, "ERROR_PRINTER_HAS_JOBS_QUEUED")); - ErrorNames.insert(std::make_pair(3010, "ERROR_SUCCESS_REBOOT_REQUIRED")); - ErrorNames.insert(std::make_pair(3011, "ERROR_SUCCESS_RESTART_REQUIRED")); - ErrorNames.insert(std::make_pair(3012, "ERROR_PRINTER_NOT_FOUND")); - ErrorNames.insert(std::make_pair(3013, "ERROR_PRINTER_DRIVER_WARNED")); - ErrorNames.insert(std::make_pair(3014, "ERROR_PRINTER_DRIVER_BLOCKED")); - ErrorNames.insert(std::make_pair(3015, "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE")); - ErrorNames.insert(std::make_pair(3016, "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(3017, "ERROR_FAIL_REBOOT_REQUIRED")); - ErrorNames.insert(std::make_pair(3018, "ERROR_FAIL_REBOOT_INITIATED")); - ErrorNames.insert(std::make_pair(3019, "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED")); - ErrorNames.insert(std::make_pair(3020, "ERROR_PRINT_JOB_RESTART_REQUIRED")); - ErrorNames.insert(std::make_pair(3950, "ERROR_IO_REISSUE_AS_CACHED")); - ErrorNames.insert(std::make_pair(4000, "ERROR_WINS_INTERNAL")); - ErrorNames.insert(std::make_pair(4001, "ERROR_CAN_NOT_DEL_LOCAL_WINS")); - ErrorNames.insert(std::make_pair(4002, "ERROR_STATIC_INIT")); - ErrorNames.insert(std::make_pair(4003, "ERROR_INC_BACKUP")); - ErrorNames.insert(std::make_pair(4004, "ERROR_FULL_BACKUP")); - ErrorNames.insert(std::make_pair(4005, "ERROR_REC_NON_EXISTENT")); - ErrorNames.insert(std::make_pair(4006, "ERROR_RPL_NOT_ALLOWED")); - ErrorNames.insert(std::make_pair(4100, "ERROR_DHCP_ADDRESS_CONFLICT")); - ErrorNames.insert(std::make_pair(4200, "ERROR_WMI_GUID_NOT_FOUND")); - ErrorNames.insert(std::make_pair(4201, "ERROR_WMI_INSTANCE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(4202, "ERROR_WMI_ITEMID_NOT_FOUND")); - ErrorNames.insert(std::make_pair(4203, "ERROR_WMI_TRY_AGAIN")); - ErrorNames.insert(std::make_pair(4204, "ERROR_WMI_DP_NOT_FOUND")); - ErrorNames.insert(std::make_pair(4205, "ERROR_WMI_UNRESOLVED_INSTANCE_REF")); - ErrorNames.insert(std::make_pair(4206, "ERROR_WMI_ALREADY_ENABLED")); - ErrorNames.insert(std::make_pair(4207, "ERROR_WMI_GUID_DISCONNECTED")); - ErrorNames.insert(std::make_pair(4208, "ERROR_WMI_SERVER_UNAVAILABLE")); - ErrorNames.insert(std::make_pair(4209, "ERROR_WMI_DP_FAILED")); - ErrorNames.insert(std::make_pair(4210, "ERROR_WMI_INVALID_MOF")); - ErrorNames.insert(std::make_pair(4211, "ERROR_WMI_INVALID_REGINFO")); - ErrorNames.insert(std::make_pair(4212, "ERROR_WMI_ALREADY_DISABLED")); - ErrorNames.insert(std::make_pair(4213, "ERROR_WMI_READ_ONLY")); - ErrorNames.insert(std::make_pair(4214, "ERROR_WMI_SET_FAILURE")); - ErrorNames.insert(std::make_pair(4300, "ERROR_INVALID_MEDIA")); - ErrorNames.insert(std::make_pair(4301, "ERROR_INVALID_LIBRARY")); - ErrorNames.insert(std::make_pair(4302, "ERROR_INVALID_MEDIA_POOL")); - ErrorNames.insert(std::make_pair(4303, "ERROR_DRIVE_MEDIA_MISMATCH")); - ErrorNames.insert(std::make_pair(4304, "ERROR_MEDIA_OFFLINE")); - ErrorNames.insert(std::make_pair(4305, "ERROR_LIBRARY_OFFLINE")); - ErrorNames.insert(std::make_pair(4306, "ERROR_EMPTY")); - ErrorNames.insert(std::make_pair(4307, "ERROR_NOT_EMPTY")); - ErrorNames.insert(std::make_pair(4308, "ERROR_MEDIA_UNAVAILABLE")); - ErrorNames.insert(std::make_pair(4309, "ERROR_RESOURCE_DISABLED")); - ErrorNames.insert(std::make_pair(4310, "ERROR_INVALID_CLEANER")); - ErrorNames.insert(std::make_pair(4311, "ERROR_UNABLE_TO_CLEAN")); - ErrorNames.insert(std::make_pair(4312, "ERROR_OBJECT_NOT_FOUND")); - ErrorNames.insert(std::make_pair(4313, "ERROR_DATABASE_FAILURE")); - ErrorNames.insert(std::make_pair(4314, "ERROR_DATABASE_FULL")); - ErrorNames.insert(std::make_pair(4315, "ERROR_MEDIA_INCOMPATIBLE")); - ErrorNames.insert(std::make_pair(4316, "ERROR_RESOURCE_NOT_PRESENT")); - ErrorNames.insert(std::make_pair(4317, "ERROR_INVALID_OPERATION")); - ErrorNames.insert(std::make_pair(4318, "ERROR_MEDIA_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(4319, "ERROR_DEVICE_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(4320, "ERROR_REQUEST_REFUSED")); - ErrorNames.insert(std::make_pair(4321, "ERROR_INVALID_DRIVE_OBJECT")); - ErrorNames.insert(std::make_pair(4322, "ERROR_LIBRARY_FULL")); - ErrorNames.insert(std::make_pair(4323, "ERROR_MEDIUM_NOT_ACCESSIBLE")); - ErrorNames.insert(std::make_pair(4324, "ERROR_UNABLE_TO_LOAD_MEDIUM")); - ErrorNames.insert(std::make_pair(4325, "ERROR_UNABLE_TO_INVENTORY_DRIVE")); - ErrorNames.insert(std::make_pair(4326, "ERROR_UNABLE_TO_INVENTORY_SLOT")); - ErrorNames.insert(std::make_pair(4327, "ERROR_UNABLE_TO_INVENTORY_TRANSPORT")); - ErrorNames.insert(std::make_pair(4328, "ERROR_TRANSPORT_FULL")); - ErrorNames.insert(std::make_pair(4329, "ERROR_CONTROLLING_IEPORT")); - ErrorNames.insert(std::make_pair(4330, "ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA")); - ErrorNames.insert(std::make_pair(4331, "ERROR_CLEANER_SLOT_SET")); - ErrorNames.insert(std::make_pair(4332, "ERROR_CLEANER_SLOT_NOT_SET")); - ErrorNames.insert(std::make_pair(4333, "ERROR_CLEANER_CARTRIDGE_SPENT")); - ErrorNames.insert(std::make_pair(4334, "ERROR_UNEXPECTED_OMID")); - ErrorNames.insert(std::make_pair(4335, "ERROR_CANT_DELETE_LAST_ITEM")); - ErrorNames.insert(std::make_pair(4336, "ERROR_MESSAGE_EXCEEDS_MAX_SIZE")); - ErrorNames.insert(std::make_pair(4337, "ERROR_VOLUME_CONTAINS_SYS_FILES")); - ErrorNames.insert(std::make_pair(4338, "ERROR_INDIGENOUS_TYPE")); - ErrorNames.insert(std::make_pair(4339, "ERROR_NO_SUPPORTING_DRIVES")); - ErrorNames.insert(std::make_pair(4340, "ERROR_CLEANER_CARTRIDGE_INSTALLED")); - ErrorNames.insert(std::make_pair(4341, "ERROR_IEPORT_FULL")); - ErrorNames.insert(std::make_pair(4350, "ERROR_FILE_OFFLINE")); - ErrorNames.insert(std::make_pair(4351, "ERROR_REMOTE_STORAGE_NOT_ACTIVE")); - ErrorNames.insert(std::make_pair(4352, "ERROR_REMOTE_STORAGE_MEDIA_ERROR")); - ErrorNames.insert(std::make_pair(4390, "ERROR_NOT_A_REPARSE_POINT")); - ErrorNames.insert(std::make_pair(4391, "ERROR_REPARSE_ATTRIBUTE_CONFLICT")); - ErrorNames.insert(std::make_pair(4392, "ERROR_INVALID_REPARSE_DATA")); - ErrorNames.insert(std::make_pair(4393, "ERROR_REPARSE_TAG_INVALID")); - ErrorNames.insert(std::make_pair(4394, "ERROR_REPARSE_TAG_MISMATCH")); - ErrorNames.insert(std::make_pair(4500, "ERROR_VOLUME_NOT_SIS_ENABLED")); - ErrorNames.insert(std::make_pair(5001, "ERROR_DEPENDENT_RESOURCE_EXISTS")); - ErrorNames.insert(std::make_pair(5002, "ERROR_DEPENDENCY_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5003, "ERROR_DEPENDENCY_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(5004, "ERROR_RESOURCE_NOT_ONLINE")); - ErrorNames.insert(std::make_pair(5005, "ERROR_HOST_NODE_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(5006, "ERROR_RESOURCE_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(5007, "ERROR_RESOURCE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5008, "ERROR_SHUTDOWN_CLUSTER")); - ErrorNames.insert(std::make_pair(5009, "ERROR_CANT_EVICT_ACTIVE_NODE")); - ErrorNames.insert(std::make_pair(5010, "ERROR_OBJECT_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(5011, "ERROR_OBJECT_IN_LIST")); - ErrorNames.insert(std::make_pair(5012, "ERROR_GROUP_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(5013, "ERROR_GROUP_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5014, "ERROR_GROUP_NOT_ONLINE")); - ErrorNames.insert(std::make_pair(5015, "ERROR_HOST_NODE_NOT_RESOURCE_OWNER")); - ErrorNames.insert(std::make_pair(5016, "ERROR_HOST_NODE_NOT_GROUP_OWNER")); - ErrorNames.insert(std::make_pair(5017, "ERROR_RESMON_CREATE_FAILED")); - ErrorNames.insert(std::make_pair(5018, "ERROR_RESMON_ONLINE_FAILED")); - ErrorNames.insert(std::make_pair(5019, "ERROR_RESOURCE_ONLINE")); - ErrorNames.insert(std::make_pair(5020, "ERROR_QUORUM_RESOURCE")); - ErrorNames.insert(std::make_pair(5021, "ERROR_NOT_QUORUM_CAPABLE")); - ErrorNames.insert(std::make_pair(5022, "ERROR_CLUSTER_SHUTTING_DOWN")); - ErrorNames.insert(std::make_pair(5023, "ERROR_INVALID_STATE")); - ErrorNames.insert(std::make_pair(5024, "ERROR_RESOURCE_PROPERTIES_STORED")); - ErrorNames.insert(std::make_pair(5025, "ERROR_NOT_QUORUM_CLASS")); - ErrorNames.insert(std::make_pair(5026, "ERROR_CORE_RESOURCE")); - ErrorNames.insert(std::make_pair(5027, "ERROR_QUORUM_RESOURCE_ONLINE_FAILED")); - ErrorNames.insert(std::make_pair(5028, "ERROR_QUORUMLOG_OPEN_FAILED")); - ErrorNames.insert(std::make_pair(5029, "ERROR_CLUSTERLOG_CORRUPT")); - ErrorNames.insert(std::make_pair(5030, "ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE")); - ErrorNames.insert(std::make_pair(5031, "ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE")); - ErrorNames.insert(std::make_pair(5032, "ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5033, "ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE")); - ErrorNames.insert(std::make_pair(5034, "ERROR_QUORUM_OWNER_ALIVE")); - ErrorNames.insert(std::make_pair(5035, "ERROR_NETWORK_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(5036, "ERROR_NODE_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(5037, "ERROR_ALL_NODES_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(5038, "ERROR_RESOURCE_FAILED")); - ErrorNames.insert(std::make_pair(5039, "ERROR_CLUSTER_INVALID_NODE")); - ErrorNames.insert(std::make_pair(5040, "ERROR_CLUSTER_NODE_EXISTS")); - ErrorNames.insert(std::make_pair(5041, "ERROR_CLUSTER_JOIN_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(5042, "ERROR_CLUSTER_NODE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5043, "ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5044, "ERROR_CLUSTER_NETWORK_EXISTS")); - ErrorNames.insert(std::make_pair(5045, "ERROR_CLUSTER_NETWORK_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5046, "ERROR_CLUSTER_NETINTERFACE_EXISTS")); - ErrorNames.insert(std::make_pair(5047, "ERROR_CLUSTER_NETINTERFACE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5048, "ERROR_CLUSTER_INVALID_REQUEST")); - ErrorNames.insert(std::make_pair(5049, "ERROR_CLUSTER_INVALID_NETWORK_PROVIDER")); - ErrorNames.insert(std::make_pair(5050, "ERROR_CLUSTER_NODE_DOWN")); - ErrorNames.insert(std::make_pair(5051, "ERROR_CLUSTER_NODE_UNREACHABLE")); - ErrorNames.insert(std::make_pair(5052, "ERROR_CLUSTER_NODE_NOT_MEMBER")); - ErrorNames.insert(std::make_pair(5053, "ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(5054, "ERROR_CLUSTER_INVALID_NETWORK")); - ErrorNames.insert(std::make_pair(5056, "ERROR_CLUSTER_NODE_UP")); - ErrorNames.insert(std::make_pair(5057, "ERROR_CLUSTER_IPADDR_IN_USE")); - ErrorNames.insert(std::make_pair(5058, "ERROR_CLUSTER_NODE_NOT_PAUSED")); - ErrorNames.insert(std::make_pair(5059, "ERROR_CLUSTER_NO_SECURITY_CONTEXT")); - ErrorNames.insert(std::make_pair(5060, "ERROR_CLUSTER_NETWORK_NOT_INTERNAL")); - ErrorNames.insert(std::make_pair(5061, "ERROR_CLUSTER_NODE_ALREADY_UP")); - ErrorNames.insert(std::make_pair(5062, "ERROR_CLUSTER_NODE_ALREADY_DOWN")); - ErrorNames.insert(std::make_pair(5063, "ERROR_CLUSTER_NETWORK_ALREADY_ONLINE")); - ErrorNames.insert(std::make_pair(5064, "ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE")); - ErrorNames.insert(std::make_pair(5065, "ERROR_CLUSTER_NODE_ALREADY_MEMBER")); - ErrorNames.insert(std::make_pair(5066, "ERROR_CLUSTER_LAST_INTERNAL_NETWORK")); - ErrorNames.insert(std::make_pair(5067, "ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS")); - ErrorNames.insert(std::make_pair(5068, "ERROR_INVALID_OPERATION_ON_QUORUM")); - ErrorNames.insert(std::make_pair(5069, "ERROR_DEPENDENCY_NOT_ALLOWED")); - ErrorNames.insert(std::make_pair(5070, "ERROR_CLUSTER_NODE_PAUSED")); - ErrorNames.insert(std::make_pair(5071, "ERROR_NODE_CANT_HOST_RESOURCE")); - ErrorNames.insert(std::make_pair(5072, "ERROR_CLUSTER_NODE_NOT_READY")); - ErrorNames.insert(std::make_pair(5073, "ERROR_CLUSTER_NODE_SHUTTING_DOWN")); - ErrorNames.insert(std::make_pair(5074, "ERROR_CLUSTER_JOIN_ABORTED")); - ErrorNames.insert(std::make_pair(5075, "ERROR_CLUSTER_INCOMPATIBLE_VERSIONS")); - ErrorNames.insert(std::make_pair(5076, "ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED")); - ErrorNames.insert(std::make_pair(5077, "ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED")); - ErrorNames.insert(std::make_pair(5078, "ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5079, "ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(5080, "ERROR_CLUSTER_RESNAME_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5081, "ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED")); - ErrorNames.insert(std::make_pair(5082, "ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST")); - ErrorNames.insert(std::make_pair(5083, "ERROR_CLUSTER_DATABASE_SEQMISMATCH")); - ErrorNames.insert(std::make_pair(5084, "ERROR_RESMON_INVALID_STATE")); - ErrorNames.insert(std::make_pair(5085, "ERROR_CLUSTER_GUM_NOT_LOCKER")); - ErrorNames.insert(std::make_pair(5086, "ERROR_QUORUM_DISK_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5087, "ERROR_DATABASE_BACKUP_CORRUPT")); - ErrorNames.insert(std::make_pair(5088, "ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT")); - ErrorNames.insert(std::make_pair(5089, "ERROR_RESOURCE_PROPERTY_UNCHANGEABLE")); - ErrorNames.insert(std::make_pair(5890, "ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE")); - ErrorNames.insert(std::make_pair(5891, "ERROR_CLUSTER_QUORUMLOG_NOT_FOUND")); - ErrorNames.insert(std::make_pair(5892, "ERROR_CLUSTER_MEMBERSHIP_HALT")); - ErrorNames.insert(std::make_pair(5893, "ERROR_CLUSTER_INSTANCE_ID_MISMATCH")); - ErrorNames.insert(std::make_pair(5894, "ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP")); - ErrorNames.insert(std::make_pair(5895, "ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH")); - ErrorNames.insert(std::make_pair(5896, "ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP")); - ErrorNames.insert(std::make_pair(5897, "ERROR_CLUSTER_PARAMETER_MISMATCH")); - ErrorNames.insert(std::make_pair(5898, "ERROR_NODE_CANNOT_BE_CLUSTERED")); - ErrorNames.insert(std::make_pair(5899, "ERROR_CLUSTER_WRONG_OS_VERSION")); - ErrorNames.insert(std::make_pair(5900, "ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME")); - ErrorNames.insert(std::make_pair(5901, "ERROR_CLUSCFG_ALREADY_COMMITTED")); - ErrorNames.insert(std::make_pair(5902, "ERROR_CLUSCFG_ROLLBACK_FAILED")); - ErrorNames.insert(std::make_pair(5903, "ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT")); - ErrorNames.insert(std::make_pair(5904, "ERROR_CLUSTER_OLD_VERSION")); - ErrorNames.insert(std::make_pair(5905, "ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME")); - ErrorNames.insert(std::make_pair(5906, "ERROR_CLUSTER_NO_NET_ADAPTERS")); - ErrorNames.insert(std::make_pair(5907, "ERROR_CLUSTER_POISONED")); - ErrorNames.insert(std::make_pair(5908, "ERROR_CLUSTER_GROUP_MOVING")); - ErrorNames.insert(std::make_pair(5909, "ERROR_CLUSTER_RESOURCE_TYPE_BUSY")); - ErrorNames.insert(std::make_pair(5910, "ERROR_RESOURCE_CALL_TIMED_OUT")); - ErrorNames.insert(std::make_pair(5911, "ERROR_INVALID_CLUSTER_IPV6_ADDRESS")); - ErrorNames.insert(std::make_pair(5912, "ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION")); - ErrorNames.insert(std::make_pair(5913, "ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS")); - ErrorNames.insert(std::make_pair(5914, "ERROR_CLUSTER_PARTIAL_SEND")); - ErrorNames.insert(std::make_pair(5915, "ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION")); - ErrorNames.insert(std::make_pair(5916, "ERROR_CLUSTER_INVALID_STRING_TERMINATION")); - ErrorNames.insert(std::make_pair(5917, "ERROR_CLUSTER_INVALID_STRING_FORMAT")); - ErrorNames.insert(std::make_pair(5918, "ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(5919, "ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(5920, "ERROR_CLUSTER_NULL_DATA")); - ErrorNames.insert(std::make_pair(5921, "ERROR_CLUSTER_PARTIAL_READ")); - ErrorNames.insert(std::make_pair(5922, "ERROR_CLUSTER_PARTIAL_WRITE")); - ErrorNames.insert(std::make_pair(5923, "ERROR_CLUSTER_CANT_DESERIALIZE_DATA")); - ErrorNames.insert(std::make_pair(5924, "ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT")); - ErrorNames.insert(std::make_pair(5925, "ERROR_CLUSTER_NO_QUORUM")); - ErrorNames.insert(std::make_pair(5926, "ERROR_CLUSTER_INVALID_IPV6_NETWORK")); - ErrorNames.insert(std::make_pair(5927, "ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK")); - ErrorNames.insert(std::make_pair(5928, "ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP")); - ErrorNames.insert(std::make_pair(5929, "ERROR_DEPENDENCY_TREE_TOO_COMPLEX")); - ErrorNames.insert(std::make_pair(5930, "ERROR_EXCEPTION_IN_RESOURCE_CALL")); - ErrorNames.insert(std::make_pair(5931, "ERROR_CLUSTER_RHS_FAILED_INITIALIZATION")); - ErrorNames.insert(std::make_pair(5932, "ERROR_CLUSTER_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(5933, "ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE")); - ErrorNames.insert(std::make_pair(5934, "ERROR_CLUSTER_MAX_NODES_IN_CLUSTER")); - ErrorNames.insert(std::make_pair(5935, "ERROR_CLUSTER_TOO_MANY_NODES")); - ErrorNames.insert(std::make_pair(5936, "ERROR_CLUSTER_OBJECT_ALREADY_USED")); - ErrorNames.insert(std::make_pair(5937, "ERROR_NONCORE_GROUPS_FOUND")); - ErrorNames.insert(std::make_pair(5938, "ERROR_FILE_SHARE_RESOURCE_CONFLICT")); - ErrorNames.insert(std::make_pair(5939, "ERROR_CLUSTER_EVICT_INVALID_REQUEST")); - ErrorNames.insert(std::make_pair(5940, "ERROR_CLUSTER_SINGLETON_RESOURCE")); - ErrorNames.insert(std::make_pair(5941, "ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE")); - ErrorNames.insert(std::make_pair(5942, "ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED")); - ErrorNames.insert(std::make_pair(5943, "ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR")); - ErrorNames.insert(std::make_pair(5944, "ERROR_CLUSTER_GROUP_BUSY")); - ErrorNames.insert(std::make_pair(5945, "ERROR_CLUSTER_NOT_SHARED_VOLUME")); - ErrorNames.insert(std::make_pair(5946, "ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR")); - ErrorNames.insert(std::make_pair(5947, "ERROR_CLUSTER_SHARED_VOLUMES_IN_USE")); - ErrorNames.insert(std::make_pair(5948, "ERROR_CLUSTER_USE_SHARED_VOLUMES_API")); - ErrorNames.insert(std::make_pair(5949, "ERROR_CLUSTER_BACKUP_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(5950, "ERROR_NON_CSV_PATH")); - ErrorNames.insert(std::make_pair(5951, "ERROR_CSV_VOLUME_NOT_LOCAL")); - ErrorNames.insert(std::make_pair(5952, "ERROR_CLUSTER_WATCHDOG_TERMINATING")); - ErrorNames.insert(std::make_pair(6000, "ERROR_ENCRYPTION_FAILED")); - ErrorNames.insert(std::make_pair(6001, "ERROR_DECRYPTION_FAILED")); - ErrorNames.insert(std::make_pair(6002, "ERROR_FILE_ENCRYPTED")); - ErrorNames.insert(std::make_pair(6003, "ERROR_NO_RECOVERY_POLICY")); - ErrorNames.insert(std::make_pair(6004, "ERROR_NO_EFS")); - ErrorNames.insert(std::make_pair(6005, "ERROR_WRONG_EFS")); - ErrorNames.insert(std::make_pair(6006, "ERROR_NO_USER_KEYS")); - ErrorNames.insert(std::make_pair(6007, "ERROR_FILE_NOT_ENCRYPTED")); - ErrorNames.insert(std::make_pair(6008, "ERROR_NOT_EXPORT_FORMAT")); - ErrorNames.insert(std::make_pair(6009, "ERROR_FILE_READ_ONLY")); - ErrorNames.insert(std::make_pair(6010, "ERROR_DIR_EFS_DISALLOWED")); - ErrorNames.insert(std::make_pair(6011, "ERROR_EFS_SERVER_NOT_TRUSTED")); - ErrorNames.insert(std::make_pair(6012, "ERROR_BAD_RECOVERY_POLICY")); - ErrorNames.insert(std::make_pair(6013, "ERROR_EFS_ALG_BLOB_TOO_BIG")); - ErrorNames.insert(std::make_pair(6014, "ERROR_VOLUME_NOT_SUPPORT_EFS")); - ErrorNames.insert(std::make_pair(6015, "ERROR_EFS_DISABLED")); - ErrorNames.insert(std::make_pair(6016, "ERROR_EFS_VERSION_NOT_SUPPORT")); - ErrorNames.insert(std::make_pair(6017, "ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE")); - ErrorNames.insert(std::make_pair(6018, "ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER")); - ErrorNames.insert(std::make_pair(6019, "ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE")); - ErrorNames.insert(std::make_pair(6020, "ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE")); - ErrorNames.insert(std::make_pair(6021, "ERROR_CS_ENCRYPTION_FILE_NOT_CSE")); - ErrorNames.insert(std::make_pair(6022, "ERROR_ENCRYPTION_POLICY_DENIES_OPERATION")); - ErrorNames.insert(std::make_pair(6118, "ERROR_NO_BROWSER_SERVERS_FOUND")); - ErrorNames.insert(std::make_pair(6600, "ERROR_LOG_SECTOR_INVALID")); - ErrorNames.insert(std::make_pair(6601, "ERROR_LOG_SECTOR_PARITY_INVALID")); - ErrorNames.insert(std::make_pair(6602, "ERROR_LOG_SECTOR_REMAPPED")); - ErrorNames.insert(std::make_pair(6603, "ERROR_LOG_BLOCK_INCOMPLETE")); - ErrorNames.insert(std::make_pair(6604, "ERROR_LOG_INVALID_RANGE")); - ErrorNames.insert(std::make_pair(6605, "ERROR_LOG_BLOCKS_EXHAUSTED")); - ErrorNames.insert(std::make_pair(6606, "ERROR_LOG_READ_CONTEXT_INVALID")); - ErrorNames.insert(std::make_pair(6607, "ERROR_LOG_RESTART_INVALID")); - ErrorNames.insert(std::make_pair(6608, "ERROR_LOG_BLOCK_VERSION")); - ErrorNames.insert(std::make_pair(6609, "ERROR_LOG_BLOCK_INVALID")); - ErrorNames.insert(std::make_pair(6610, "ERROR_LOG_READ_MODE_INVALID")); - ErrorNames.insert(std::make_pair(6611, "ERROR_LOG_NO_RESTART")); - ErrorNames.insert(std::make_pair(6612, "ERROR_LOG_METADATA_CORRUPT")); - ErrorNames.insert(std::make_pair(6613, "ERROR_LOG_METADATA_INVALID")); - ErrorNames.insert(std::make_pair(6614, "ERROR_LOG_METADATA_INCONSISTENT")); - ErrorNames.insert(std::make_pair(6615, "ERROR_LOG_RESERVATION_INVALID")); - ErrorNames.insert(std::make_pair(6616, "ERROR_LOG_CANT_DELETE")); - ErrorNames.insert(std::make_pair(6617, "ERROR_LOG_CONTAINER_LIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(6618, "ERROR_LOG_START_OF_LOG")); - ErrorNames.insert(std::make_pair(6619, "ERROR_LOG_POLICY_ALREADY_INSTALLED")); - ErrorNames.insert(std::make_pair(6620, "ERROR_LOG_POLICY_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(6621, "ERROR_LOG_POLICY_INVALID")); - ErrorNames.insert(std::make_pair(6622, "ERROR_LOG_POLICY_CONFLICT")); - ErrorNames.insert(std::make_pair(6623, "ERROR_LOG_PINNED_ARCHIVE_TAIL")); - ErrorNames.insert(std::make_pair(6624, "ERROR_LOG_RECORD_NONEXISTENT")); - ErrorNames.insert(std::make_pair(6625, "ERROR_LOG_RECORDS_RESERVED_INVALID")); - ErrorNames.insert(std::make_pair(6626, "ERROR_LOG_SPACE_RESERVED_INVALID")); - ErrorNames.insert(std::make_pair(6627, "ERROR_LOG_TAIL_INVALID")); - ErrorNames.insert(std::make_pair(6628, "ERROR_LOG_FULL")); - ErrorNames.insert(std::make_pair(6629, "ERROR_COULD_NOT_RESIZE_LOG")); - ErrorNames.insert(std::make_pair(6630, "ERROR_LOG_MULTIPLEXED")); - ErrorNames.insert(std::make_pair(6631, "ERROR_LOG_DEDICATED")); - ErrorNames.insert(std::make_pair(6632, "ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(6633, "ERROR_LOG_ARCHIVE_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(6634, "ERROR_LOG_EPHEMERAL")); - ErrorNames.insert(std::make_pair(6635, "ERROR_LOG_NOT_ENOUGH_CONTAINERS")); - ErrorNames.insert(std::make_pair(6636, "ERROR_LOG_CLIENT_ALREADY_REGISTERED")); - ErrorNames.insert(std::make_pair(6637, "ERROR_LOG_CLIENT_NOT_REGISTERED")); - ErrorNames.insert(std::make_pair(6638, "ERROR_LOG_FULL_HANDLER_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(6639, "ERROR_LOG_CONTAINER_READ_FAILED")); - ErrorNames.insert(std::make_pair(6640, "ERROR_LOG_CONTAINER_WRITE_FAILED")); - ErrorNames.insert(std::make_pair(6641, "ERROR_LOG_CONTAINER_OPEN_FAILED")); - ErrorNames.insert(std::make_pair(6642, "ERROR_LOG_CONTAINER_STATE_INVALID")); - ErrorNames.insert(std::make_pair(6643, "ERROR_LOG_STATE_INVALID")); - ErrorNames.insert(std::make_pair(6644, "ERROR_LOG_PINNED")); - ErrorNames.insert(std::make_pair(6645, "ERROR_LOG_METADATA_FLUSH_FAILED")); - ErrorNames.insert(std::make_pair(6646, "ERROR_LOG_INCONSISTENT_SECURITY")); - ErrorNames.insert(std::make_pair(6647, "ERROR_LOG_APPENDED_FLUSH_FAILED")); - ErrorNames.insert(std::make_pair(6648, "ERROR_LOG_PINNED_RESERVATION")); - ErrorNames.insert(std::make_pair(6700, "ERROR_INVALID_TRANSACTION")); - ErrorNames.insert(std::make_pair(6701, "ERROR_TRANSACTION_NOT_ACTIVE")); - ErrorNames.insert(std::make_pair(6702, "ERROR_TRANSACTION_REQUEST_NOT_VALID")); - ErrorNames.insert(std::make_pair(6703, "ERROR_TRANSACTION_NOT_REQUESTED")); - ErrorNames.insert(std::make_pair(6704, "ERROR_TRANSACTION_ALREADY_ABORTED")); - ErrorNames.insert(std::make_pair(6705, "ERROR_TRANSACTION_ALREADY_COMMITTED")); - ErrorNames.insert(std::make_pair(6706, "ERROR_TM_INITIALIZATION_FAILED")); - ErrorNames.insert(std::make_pair(6707, "ERROR_RESOURCEMANAGER_READ_ONLY")); - ErrorNames.insert(std::make_pair(6708, "ERROR_TRANSACTION_NOT_JOINED")); - ErrorNames.insert(std::make_pair(6709, "ERROR_TRANSACTION_SUPERIOR_EXISTS")); - ErrorNames.insert(std::make_pair(6710, "ERROR_CRM_PROTOCOL_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(6711, "ERROR_TRANSACTION_PROPAGATION_FAILED")); - ErrorNames.insert(std::make_pair(6712, "ERROR_CRM_PROTOCOL_NOT_FOUND")); - ErrorNames.insert(std::make_pair(6713, "ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER")); - ErrorNames.insert(std::make_pair(6714, "ERROR_CURRENT_TRANSACTION_NOT_VALID")); - ErrorNames.insert(std::make_pair(6715, "ERROR_TRANSACTION_NOT_FOUND")); - ErrorNames.insert(std::make_pair(6716, "ERROR_RESOURCEMANAGER_NOT_FOUND")); - ErrorNames.insert(std::make_pair(6717, "ERROR_ENLISTMENT_NOT_FOUND")); - ErrorNames.insert(std::make_pair(6718, "ERROR_TRANSACTIONMANAGER_NOT_FOUND")); - ErrorNames.insert(std::make_pair(6719, "ERROR_TRANSACTIONMANAGER_NOT_ONLINE")); - ErrorNames.insert(std::make_pair(6720, "ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION")); - ErrorNames.insert(std::make_pair(6721, "ERROR_TRANSACTION_NOT_ROOT")); - ErrorNames.insert(std::make_pair(6722, "ERROR_TRANSACTION_OBJECT_EXPIRED")); - ErrorNames.insert(std::make_pair(6723, "ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED")); - ErrorNames.insert(std::make_pair(6724, "ERROR_TRANSACTION_RECORD_TOO_LONG")); - ErrorNames.insert(std::make_pair(6725, "ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(6726, "ERROR_TRANSACTION_INTEGRITY_VIOLATED")); - ErrorNames.insert(std::make_pair(6727, "ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH")); - ErrorNames.insert(std::make_pair(6728, "ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT")); - ErrorNames.insert(std::make_pair(6729, "ERROR_TRANSACTION_MUST_WRITETHROUGH")); - ErrorNames.insert(std::make_pair(6730, "ERROR_TRANSACTION_NO_SUPERIOR")); - ErrorNames.insert(std::make_pair(6731, "ERROR_HEURISTIC_DAMAGE_POSSIBLE")); - ErrorNames.insert(std::make_pair(6800, "ERROR_TRANSACTIONAL_CONFLICT")); - ErrorNames.insert(std::make_pair(6801, "ERROR_RM_NOT_ACTIVE")); - ErrorNames.insert(std::make_pair(6802, "ERROR_RM_METADATA_CORRUPT")); - ErrorNames.insert(std::make_pair(6803, "ERROR_DIRECTORY_NOT_RM")); - ErrorNames.insert(std::make_pair(6805, "ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE")); - ErrorNames.insert(std::make_pair(6806, "ERROR_LOG_RESIZE_INVALID_SIZE")); - ErrorNames.insert(std::make_pair(6807, "ERROR_OBJECT_NO_LONGER_EXISTS")); - ErrorNames.insert(std::make_pair(6808, "ERROR_STREAM_MINIVERSION_NOT_FOUND")); - ErrorNames.insert(std::make_pair(6809, "ERROR_STREAM_MINIVERSION_NOT_VALID")); - ErrorNames.insert(std::make_pair(6810, "ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION")); - ErrorNames.insert(std::make_pair(6811, "ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT")); - ErrorNames.insert(std::make_pair(6812, "ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS")); - ErrorNames.insert(std::make_pair(6814, "ERROR_REMOTE_FILE_VERSION_MISMATCH")); - ErrorNames.insert(std::make_pair(6815, "ERROR_HANDLE_NO_LONGER_VALID")); - ErrorNames.insert(std::make_pair(6816, "ERROR_NO_TXF_METADATA")); - ErrorNames.insert(std::make_pair(6817, "ERROR_LOG_CORRUPTION_DETECTED")); - ErrorNames.insert(std::make_pair(6818, "ERROR_CANT_RECOVER_WITH_HANDLE_OPEN")); - ErrorNames.insert(std::make_pair(6819, "ERROR_RM_DISCONNECTED")); - ErrorNames.insert(std::make_pair(6820, "ERROR_ENLISTMENT_NOT_SUPERIOR")); - ErrorNames.insert(std::make_pair(6821, "ERROR_RECOVERY_NOT_NEEDED")); - ErrorNames.insert(std::make_pair(6822, "ERROR_RM_ALREADY_STARTED")); - ErrorNames.insert(std::make_pair(6823, "ERROR_FILE_IDENTITY_NOT_PERSISTENT")); - ErrorNames.insert(std::make_pair(6824, "ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY")); - ErrorNames.insert(std::make_pair(6825, "ERROR_CANT_CROSS_RM_BOUNDARY")); - ErrorNames.insert(std::make_pair(6826, "ERROR_TXF_DIR_NOT_EMPTY")); - ErrorNames.insert(std::make_pair(6827, "ERROR_INDOUBT_TRANSACTIONS_EXIST")); - ErrorNames.insert(std::make_pair(6828, "ERROR_TM_VOLATILE")); - ErrorNames.insert(std::make_pair(6829, "ERROR_ROLLBACK_TIMER_EXPIRED")); - ErrorNames.insert(std::make_pair(6830, "ERROR_TXF_ATTRIBUTE_CORRUPT")); - ErrorNames.insert(std::make_pair(6831, "ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION")); - ErrorNames.insert(std::make_pair(6832, "ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED")); - ErrorNames.insert(std::make_pair(6833, "ERROR_LOG_GROWTH_FAILED")); - ErrorNames.insert(std::make_pair(6834, "ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE")); - ErrorNames.insert(std::make_pair(6835, "ERROR_TXF_METADATA_ALREADY_PRESENT")); - ErrorNames.insert(std::make_pair(6836, "ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET")); - ErrorNames.insert(std::make_pair(6837, "ERROR_TRANSACTION_REQUIRED_PROMOTION")); - ErrorNames.insert(std::make_pair(6838, "ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION")); - ErrorNames.insert(std::make_pair(6839, "ERROR_TRANSACTIONS_NOT_FROZEN")); - ErrorNames.insert(std::make_pair(6840, "ERROR_TRANSACTION_FREEZE_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(6841, "ERROR_NOT_SNAPSHOT_VOLUME")); - ErrorNames.insert(std::make_pair(6842, "ERROR_NO_SAVEPOINT_WITH_OPEN_FILES")); - ErrorNames.insert(std::make_pair(6843, "ERROR_DATA_LOST_REPAIR")); - ErrorNames.insert(std::make_pair(6844, "ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION")); - ErrorNames.insert(std::make_pair(6845, "ERROR_TM_IDENTITY_MISMATCH")); - ErrorNames.insert(std::make_pair(6846, "ERROR_FLOATED_SECTION")); - ErrorNames.insert(std::make_pair(6847, "ERROR_CANNOT_ACCEPT_TRANSACTED_WORK")); - ErrorNames.insert(std::make_pair(6848, "ERROR_CANNOT_ABORT_TRANSACTIONS")); - ErrorNames.insert(std::make_pair(6849, "ERROR_BAD_CLUSTERS")); - ErrorNames.insert(std::make_pair(6850, "ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION")); - ErrorNames.insert(std::make_pair(6851, "ERROR_VOLUME_DIRTY")); - ErrorNames.insert(std::make_pair(6852, "ERROR_NO_LINK_TRACKING_IN_TRANSACTION")); - ErrorNames.insert(std::make_pair(6853, "ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION")); - ErrorNames.insert(std::make_pair(6854, "ERROR_EXPIRED_HANDLE")); - ErrorNames.insert(std::make_pair(6855, "ERROR_TRANSACTION_NOT_ENLISTED")); - ErrorNames.insert(std::make_pair(7001, "ERROR_CTX_WINSTATION_NAME_INVALID")); - ErrorNames.insert(std::make_pair(7002, "ERROR_CTX_INVALID_PD")); - ErrorNames.insert(std::make_pair(7003, "ERROR_CTX_PD_NOT_FOUND")); - ErrorNames.insert(std::make_pair(7004, "ERROR_CTX_WD_NOT_FOUND")); - ErrorNames.insert(std::make_pair(7005, "ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY")); - ErrorNames.insert(std::make_pair(7006, "ERROR_CTX_SERVICE_NAME_COLLISION")); - ErrorNames.insert(std::make_pair(7007, "ERROR_CTX_CLOSE_PENDING")); - ErrorNames.insert(std::make_pair(7008, "ERROR_CTX_NO_OUTBUF")); - ErrorNames.insert(std::make_pair(7009, "ERROR_CTX_MODEM_INF_NOT_FOUND")); - ErrorNames.insert(std::make_pair(7010, "ERROR_CTX_INVALID_MODEMNAME")); - ErrorNames.insert(std::make_pair(7011, "ERROR_CTX_MODEM_RESPONSE_ERROR")); - ErrorNames.insert(std::make_pair(7012, "ERROR_CTX_MODEM_RESPONSE_TIMEOUT")); - ErrorNames.insert(std::make_pair(7013, "ERROR_CTX_MODEM_RESPONSE_NO_CARRIER")); - ErrorNames.insert(std::make_pair(7014, "ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE")); - ErrorNames.insert(std::make_pair(7015, "ERROR_CTX_MODEM_RESPONSE_BUSY")); - ErrorNames.insert(std::make_pair(7016, "ERROR_CTX_MODEM_RESPONSE_VOICE")); - ErrorNames.insert(std::make_pair(7017, "ERROR_CTX_TD_ERROR")); - ErrorNames.insert(std::make_pair(7022, "ERROR_CTX_WINSTATION_NOT_FOUND")); - ErrorNames.insert(std::make_pair(7023, "ERROR_CTX_WINSTATION_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(7024, "ERROR_CTX_WINSTATION_BUSY")); - ErrorNames.insert(std::make_pair(7025, "ERROR_CTX_BAD_VIDEO_MODE")); - ErrorNames.insert(std::make_pair(7035, "ERROR_CTX_GRAPHICS_INVALID")); - ErrorNames.insert(std::make_pair(7037, "ERROR_CTX_LOGON_DISABLED")); - ErrorNames.insert(std::make_pair(7038, "ERROR_CTX_NOT_CONSOLE")); - ErrorNames.insert(std::make_pair(7040, "ERROR_CTX_CLIENT_QUERY_TIMEOUT")); - ErrorNames.insert(std::make_pair(7041, "ERROR_CTX_CONSOLE_DISCONNECT")); - ErrorNames.insert(std::make_pair(7042, "ERROR_CTX_CONSOLE_CONNECT")); - ErrorNames.insert(std::make_pair(7044, "ERROR_CTX_SHADOW_DENIED")); - ErrorNames.insert(std::make_pair(7045, "ERROR_CTX_WINSTATION_ACCESS_DENIED")); - ErrorNames.insert(std::make_pair(7049, "ERROR_CTX_INVALID_WD")); - ErrorNames.insert(std::make_pair(7050, "ERROR_CTX_SHADOW_INVALID")); - ErrorNames.insert(std::make_pair(7051, "ERROR_CTX_SHADOW_DISABLED")); - ErrorNames.insert(std::make_pair(7052, "ERROR_CTX_CLIENT_LICENSE_IN_USE")); - ErrorNames.insert(std::make_pair(7053, "ERROR_CTX_CLIENT_LICENSE_NOT_SET")); - ErrorNames.insert(std::make_pair(7054, "ERROR_CTX_LICENSE_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(7055, "ERROR_CTX_LICENSE_CLIENT_INVALID")); - ErrorNames.insert(std::make_pair(7056, "ERROR_CTX_LICENSE_EXPIRED")); - ErrorNames.insert(std::make_pair(7057, "ERROR_CTX_SHADOW_NOT_RUNNING")); - ErrorNames.insert(std::make_pair(7058, "ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE")); - ErrorNames.insert(std::make_pair(7059, "ERROR_ACTIVATION_COUNT_EXCEEDED")); - ErrorNames.insert(std::make_pair(7060, "ERROR_CTX_WINSTATIONS_DISABLED")); - ErrorNames.insert(std::make_pair(7061, "ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED")); - ErrorNames.insert(std::make_pair(7062, "ERROR_CTX_SESSION_IN_USE")); - ErrorNames.insert(std::make_pair(7063, "ERROR_CTX_NO_FORCE_LOGOFF")); - ErrorNames.insert(std::make_pair(7064, "ERROR_CTX_ACCOUNT_RESTRICTION")); - ErrorNames.insert(std::make_pair(7065, "ERROR_RDP_PROTOCOL_ERROR")); - ErrorNames.insert(std::make_pair(7066, "ERROR_CTX_CDM_CONNECT")); - ErrorNames.insert(std::make_pair(7067, "ERROR_CTX_CDM_DISCONNECT")); - ErrorNames.insert(std::make_pair(7068, "ERROR_CTX_SECURITY_LAYER_ERROR")); - ErrorNames.insert(std::make_pair(7069, "ERROR_TS_INCOMPATIBLE_SESSIONS")); - ErrorNames.insert(std::make_pair(7070, "ERROR_TS_VIDEO_SUBSYSTEM_ERROR")); - ErrorNames.insert(std::make_pair(8200, "ERROR_DS_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(8201, "ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY")); - ErrorNames.insert(std::make_pair(8202, "ERROR_DS_NO_ATTRIBUTE_OR_VALUE")); - ErrorNames.insert(std::make_pair(8203, "ERROR_DS_INVALID_ATTRIBUTE_SYNTAX")); - ErrorNames.insert(std::make_pair(8204, "ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED")); - ErrorNames.insert(std::make_pair(8205, "ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS")); - ErrorNames.insert(std::make_pair(8206, "ERROR_DS_BUSY")); - ErrorNames.insert(std::make_pair(8207, "ERROR_DS_UNAVAILABLE")); - ErrorNames.insert(std::make_pair(8208, "ERROR_DS_NO_RIDS_ALLOCATED")); - ErrorNames.insert(std::make_pair(8209, "ERROR_DS_NO_MORE_RIDS")); - ErrorNames.insert(std::make_pair(8210, "ERROR_DS_INCORRECT_ROLE_OWNER")); - ErrorNames.insert(std::make_pair(8211, "ERROR_DS_RIDMGR_INIT_ERROR")); - ErrorNames.insert(std::make_pair(8212, "ERROR_DS_OBJ_CLASS_VIOLATION")); - ErrorNames.insert(std::make_pair(8213, "ERROR_DS_CANT_ON_NON_LEAF")); - ErrorNames.insert(std::make_pair(8214, "ERROR_DS_CANT_ON_RDN")); - ErrorNames.insert(std::make_pair(8215, "ERROR_DS_CANT_MOD_OBJ_CLASS")); - ErrorNames.insert(std::make_pair(8216, "ERROR_DS_CROSS_DOM_MOVE_ERROR")); - ErrorNames.insert(std::make_pair(8217, "ERROR_DS_GC_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(8218, "ERROR_SHARED_POLICY")); - ErrorNames.insert(std::make_pair(8219, "ERROR_POLICY_OBJECT_NOT_FOUND")); - ErrorNames.insert(std::make_pair(8220, "ERROR_POLICY_ONLY_IN_DS")); - ErrorNames.insert(std::make_pair(8221, "ERROR_PROMOTION_ACTIVE")); - ErrorNames.insert(std::make_pair(8222, "ERROR_NO_PROMOTION_ACTIVE")); - ErrorNames.insert(std::make_pair(8224, "ERROR_DS_OPERATIONS_ERROR")); - ErrorNames.insert(std::make_pair(8225, "ERROR_DS_PROTOCOL_ERROR")); - ErrorNames.insert(std::make_pair(8226, "ERROR_DS_TIMELIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(8227, "ERROR_DS_SIZELIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(8228, "ERROR_DS_ADMIN_LIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(8229, "ERROR_DS_COMPARE_FALSE")); - ErrorNames.insert(std::make_pair(8230, "ERROR_DS_COMPARE_TRUE")); - ErrorNames.insert(std::make_pair(8231, "ERROR_DS_AUTH_METHOD_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(8232, "ERROR_DS_STRONG_AUTH_REQUIRED")); - ErrorNames.insert(std::make_pair(8233, "ERROR_DS_INAPPROPRIATE_AUTH")); - ErrorNames.insert(std::make_pair(8234, "ERROR_DS_AUTH_UNKNOWN")); - ErrorNames.insert(std::make_pair(8235, "ERROR_DS_REFERRAL")); - ErrorNames.insert(std::make_pair(8236, "ERROR_DS_UNAVAILABLE_CRIT_EXTENSION")); - ErrorNames.insert(std::make_pair(8237, "ERROR_DS_CONFIDENTIALITY_REQUIRED")); - ErrorNames.insert(std::make_pair(8238, "ERROR_DS_INAPPROPRIATE_MATCHING")); - ErrorNames.insert(std::make_pair(8239, "ERROR_DS_CONSTRAINT_VIOLATION")); - ErrorNames.insert(std::make_pair(8240, "ERROR_DS_NO_SUCH_OBJECT")); - ErrorNames.insert(std::make_pair(8241, "ERROR_DS_ALIAS_PROBLEM")); - ErrorNames.insert(std::make_pair(8242, "ERROR_DS_INVALID_DN_SYNTAX")); - ErrorNames.insert(std::make_pair(8243, "ERROR_DS_IS_LEAF")); - ErrorNames.insert(std::make_pair(8244, "ERROR_DS_ALIAS_DEREF_PROBLEM")); - ErrorNames.insert(std::make_pair(8245, "ERROR_DS_UNWILLING_TO_PERFORM")); - ErrorNames.insert(std::make_pair(8246, "ERROR_DS_LOOP_DETECT")); - ErrorNames.insert(std::make_pair(8247, "ERROR_DS_NAMING_VIOLATION")); - ErrorNames.insert(std::make_pair(8248, "ERROR_DS_OBJECT_RESULTS_TOO_LARGE")); - ErrorNames.insert(std::make_pair(8249, "ERROR_DS_AFFECTS_MULTIPLE_DSAS")); - ErrorNames.insert(std::make_pair(8250, "ERROR_DS_SERVER_DOWN")); - ErrorNames.insert(std::make_pair(8251, "ERROR_DS_LOCAL_ERROR")); - ErrorNames.insert(std::make_pair(8252, "ERROR_DS_ENCODING_ERROR")); - ErrorNames.insert(std::make_pair(8253, "ERROR_DS_DECODING_ERROR")); - ErrorNames.insert(std::make_pair(8254, "ERROR_DS_FILTER_UNKNOWN")); - ErrorNames.insert(std::make_pair(8255, "ERROR_DS_PARAM_ERROR")); - ErrorNames.insert(std::make_pair(8256, "ERROR_DS_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(8257, "ERROR_DS_NO_RESULTS_RETURNED")); - ErrorNames.insert(std::make_pair(8258, "ERROR_DS_CONTROL_NOT_FOUND")); - ErrorNames.insert(std::make_pair(8259, "ERROR_DS_CLIENT_LOOP")); - ErrorNames.insert(std::make_pair(8260, "ERROR_DS_REFERRAL_LIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(8261, "ERROR_DS_SORT_CONTROL_MISSING")); - ErrorNames.insert(std::make_pair(8262, "ERROR_DS_OFFSET_RANGE_ERROR")); - ErrorNames.insert(std::make_pair(8301, "ERROR_DS_ROOT_MUST_BE_NC")); - ErrorNames.insert(std::make_pair(8302, "ERROR_DS_ADD_REPLICA_INHIBITED")); - ErrorNames.insert(std::make_pair(8303, "ERROR_DS_ATT_NOT_DEF_IN_SCHEMA")); - ErrorNames.insert(std::make_pair(8304, "ERROR_DS_MAX_OBJ_SIZE_EXCEEDED")); - ErrorNames.insert(std::make_pair(8305, "ERROR_DS_OBJ_STRING_NAME_EXISTS")); - ErrorNames.insert(std::make_pair(8306, "ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA")); - ErrorNames.insert(std::make_pair(8307, "ERROR_DS_RDN_DOESNT_MATCH_SCHEMA")); - ErrorNames.insert(std::make_pair(8308, "ERROR_DS_NO_REQUESTED_ATTS_FOUND")); - ErrorNames.insert(std::make_pair(8309, "ERROR_DS_USER_BUFFER_TO_SMALL")); - ErrorNames.insert(std::make_pair(8310, "ERROR_DS_ATT_IS_NOT_ON_OBJ")); - ErrorNames.insert(std::make_pair(8311, "ERROR_DS_ILLEGAL_MOD_OPERATION")); - ErrorNames.insert(std::make_pair(8312, "ERROR_DS_OBJ_TOO_LARGE")); - ErrorNames.insert(std::make_pair(8313, "ERROR_DS_BAD_INSTANCE_TYPE")); - ErrorNames.insert(std::make_pair(8314, "ERROR_DS_MASTERDSA_REQUIRED")); - ErrorNames.insert(std::make_pair(8315, "ERROR_DS_OBJECT_CLASS_REQUIRED")); - ErrorNames.insert(std::make_pair(8316, "ERROR_DS_MISSING_REQUIRED_ATT")); - ErrorNames.insert(std::make_pair(8317, "ERROR_DS_ATT_NOT_DEF_FOR_CLASS")); - ErrorNames.insert(std::make_pair(8318, "ERROR_DS_ATT_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(8320, "ERROR_DS_CANT_ADD_ATT_VALUES")); - ErrorNames.insert(std::make_pair(8321, "ERROR_DS_SINGLE_VALUE_CONSTRAINT")); - ErrorNames.insert(std::make_pair(8322, "ERROR_DS_RANGE_CONSTRAINT")); - ErrorNames.insert(std::make_pair(8323, "ERROR_DS_ATT_VAL_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(8324, "ERROR_DS_CANT_REM_MISSING_ATT")); - ErrorNames.insert(std::make_pair(8325, "ERROR_DS_CANT_REM_MISSING_ATT_VAL")); - ErrorNames.insert(std::make_pair(8326, "ERROR_DS_ROOT_CANT_BE_SUBREF")); - ErrorNames.insert(std::make_pair(8327, "ERROR_DS_NO_CHAINING")); - ErrorNames.insert(std::make_pair(8328, "ERROR_DS_NO_CHAINED_EVAL")); - ErrorNames.insert(std::make_pair(8329, "ERROR_DS_NO_PARENT_OBJECT")); - ErrorNames.insert(std::make_pair(8330, "ERROR_DS_PARENT_IS_AN_ALIAS")); - ErrorNames.insert(std::make_pair(8331, "ERROR_DS_CANT_MIX_MASTER_AND_REPS")); - ErrorNames.insert(std::make_pair(8332, "ERROR_DS_CHILDREN_EXIST")); - ErrorNames.insert(std::make_pair(8333, "ERROR_DS_OBJ_NOT_FOUND")); - ErrorNames.insert(std::make_pair(8334, "ERROR_DS_ALIASED_OBJ_MISSING")); - ErrorNames.insert(std::make_pair(8335, "ERROR_DS_BAD_NAME_SYNTAX")); - ErrorNames.insert(std::make_pair(8336, "ERROR_DS_ALIAS_POINTS_TO_ALIAS")); - ErrorNames.insert(std::make_pair(8337, "ERROR_DS_CANT_DEREF_ALIAS")); - ErrorNames.insert(std::make_pair(8338, "ERROR_DS_OUT_OF_SCOPE")); - ErrorNames.insert(std::make_pair(8339, "ERROR_DS_OBJECT_BEING_REMOVED")); - ErrorNames.insert(std::make_pair(8340, "ERROR_DS_CANT_DELETE_DSA_OBJ")); - ErrorNames.insert(std::make_pair(8341, "ERROR_DS_GENERIC_ERROR")); - ErrorNames.insert(std::make_pair(8342, "ERROR_DS_DSA_MUST_BE_INT_MASTER")); - ErrorNames.insert(std::make_pair(8343, "ERROR_DS_CLASS_NOT_DSA")); - ErrorNames.insert(std::make_pair(8344, "ERROR_DS_INSUFF_ACCESS_RIGHTS")); - ErrorNames.insert(std::make_pair(8345, "ERROR_DS_ILLEGAL_SUPERIOR")); - ErrorNames.insert(std::make_pair(8346, "ERROR_DS_ATTRIBUTE_OWNED_BY_SAM")); - ErrorNames.insert(std::make_pair(8347, "ERROR_DS_NAME_TOO_MANY_PARTS")); - ErrorNames.insert(std::make_pair(8348, "ERROR_DS_NAME_TOO_LONG")); - ErrorNames.insert(std::make_pair(8349, "ERROR_DS_NAME_VALUE_TOO_LONG")); - ErrorNames.insert(std::make_pair(8350, "ERROR_DS_NAME_UNPARSEABLE")); - ErrorNames.insert(std::make_pair(8351, "ERROR_DS_NAME_TYPE_UNKNOWN")); - ErrorNames.insert(std::make_pair(8352, "ERROR_DS_NOT_AN_OBJECT")); - ErrorNames.insert(std::make_pair(8353, "ERROR_DS_SEC_DESC_TOO_SHORT")); - ErrorNames.insert(std::make_pair(8354, "ERROR_DS_SEC_DESC_INVALID")); - ErrorNames.insert(std::make_pair(8355, "ERROR_DS_NO_DELETED_NAME")); - ErrorNames.insert(std::make_pair(8356, "ERROR_DS_SUBREF_MUST_HAVE_PARENT")); - ErrorNames.insert(std::make_pair(8357, "ERROR_DS_NCNAME_MUST_BE_NC")); - ErrorNames.insert(std::make_pair(8358, "ERROR_DS_CANT_ADD_SYSTEM_ONLY")); - ErrorNames.insert(std::make_pair(8359, "ERROR_DS_CLASS_MUST_BE_CONCRETE")); - ErrorNames.insert(std::make_pair(8360, "ERROR_DS_INVALID_DMD")); - ErrorNames.insert(std::make_pair(8361, "ERROR_DS_OBJ_GUID_EXISTS")); - ErrorNames.insert(std::make_pair(8362, "ERROR_DS_NOT_ON_BACKLINK")); - ErrorNames.insert(std::make_pair(8363, "ERROR_DS_NO_CROSSREF_FOR_NC")); - ErrorNames.insert(std::make_pair(8364, "ERROR_DS_SHUTTING_DOWN")); - ErrorNames.insert(std::make_pair(8365, "ERROR_DS_UNKNOWN_OPERATION")); - ErrorNames.insert(std::make_pair(8366, "ERROR_DS_INVALID_ROLE_OWNER")); - ErrorNames.insert(std::make_pair(8367, "ERROR_DS_COULDNT_CONTACT_FSMO")); - ErrorNames.insert(std::make_pair(8368, "ERROR_DS_CROSS_NC_DN_RENAME")); - ErrorNames.insert(std::make_pair(8369, "ERROR_DS_CANT_MOD_SYSTEM_ONLY")); - ErrorNames.insert(std::make_pair(8370, "ERROR_DS_REPLICATOR_ONLY")); - ErrorNames.insert(std::make_pair(8371, "ERROR_DS_OBJ_CLASS_NOT_DEFINED")); - ErrorNames.insert(std::make_pair(8372, "ERROR_DS_OBJ_CLASS_NOT_SUBCLASS")); - ErrorNames.insert(std::make_pair(8373, "ERROR_DS_NAME_REFERENCE_INVALID")); - ErrorNames.insert(std::make_pair(8374, "ERROR_DS_CROSS_REF_EXISTS")); - ErrorNames.insert(std::make_pair(8375, "ERROR_DS_CANT_DEL_MASTER_CROSSREF")); - ErrorNames.insert(std::make_pair(8376, "ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD")); - ErrorNames.insert(std::make_pair(8377, "ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX")); - ErrorNames.insert(std::make_pair(8378, "ERROR_DS_DUP_RDN")); - ErrorNames.insert(std::make_pair(8379, "ERROR_DS_DUP_OID")); - ErrorNames.insert(std::make_pair(8380, "ERROR_DS_DUP_MAPI_ID")); - ErrorNames.insert(std::make_pair(8381, "ERROR_DS_DUP_SCHEMA_ID_GUID")); - ErrorNames.insert(std::make_pair(8382, "ERROR_DS_DUP_LDAP_DISPLAY_NAME")); - ErrorNames.insert(std::make_pair(8383, "ERROR_DS_SEMANTIC_ATT_TEST")); - ErrorNames.insert(std::make_pair(8384, "ERROR_DS_SYNTAX_MISMATCH")); - ErrorNames.insert(std::make_pair(8385, "ERROR_DS_EXISTS_IN_MUST_HAVE")); - ErrorNames.insert(std::make_pair(8386, "ERROR_DS_EXISTS_IN_MAY_HAVE")); - ErrorNames.insert(std::make_pair(8387, "ERROR_DS_NONEXISTENT_MAY_HAVE")); - ErrorNames.insert(std::make_pair(8388, "ERROR_DS_NONEXISTENT_MUST_HAVE")); - ErrorNames.insert(std::make_pair(8389, "ERROR_DS_AUX_CLS_TEST_FAIL")); - ErrorNames.insert(std::make_pair(8390, "ERROR_DS_NONEXISTENT_POSS_SUP")); - ErrorNames.insert(std::make_pair(8391, "ERROR_DS_SUB_CLS_TEST_FAIL")); - ErrorNames.insert(std::make_pair(8392, "ERROR_DS_BAD_RDN_ATT_ID_SYNTAX")); - ErrorNames.insert(std::make_pair(8393, "ERROR_DS_EXISTS_IN_AUX_CLS")); - ErrorNames.insert(std::make_pair(8394, "ERROR_DS_EXISTS_IN_SUB_CLS")); - ErrorNames.insert(std::make_pair(8395, "ERROR_DS_EXISTS_IN_POSS_SUP")); - ErrorNames.insert(std::make_pair(8396, "ERROR_DS_RECALCSCHEMA_FAILED")); - ErrorNames.insert(std::make_pair(8397, "ERROR_DS_TREE_DELETE_NOT_FINISHED")); - ErrorNames.insert(std::make_pair(8398, "ERROR_DS_CANT_DELETE")); - ErrorNames.insert(std::make_pair(8399, "ERROR_DS_ATT_SCHEMA_REQ_ID")); - ErrorNames.insert(std::make_pair(8400, "ERROR_DS_BAD_ATT_SCHEMA_SYNTAX")); - ErrorNames.insert(std::make_pair(8401, "ERROR_DS_CANT_CACHE_ATT")); - ErrorNames.insert(std::make_pair(8402, "ERROR_DS_CANT_CACHE_CLASS")); - ErrorNames.insert(std::make_pair(8403, "ERROR_DS_CANT_REMOVE_ATT_CACHE")); - ErrorNames.insert(std::make_pair(8404, "ERROR_DS_CANT_REMOVE_CLASS_CACHE")); - ErrorNames.insert(std::make_pair(8405, "ERROR_DS_CANT_RETRIEVE_DN")); - ErrorNames.insert(std::make_pair(8406, "ERROR_DS_MISSING_SUPREF")); - ErrorNames.insert(std::make_pair(8407, "ERROR_DS_CANT_RETRIEVE_INSTANCE")); - ErrorNames.insert(std::make_pair(8408, "ERROR_DS_CODE_INCONSISTENCY")); - ErrorNames.insert(std::make_pair(8409, "ERROR_DS_DATABASE_ERROR")); - ErrorNames.insert(std::make_pair(8410, "ERROR_DS_GOVERNSID_MISSING")); - ErrorNames.insert(std::make_pair(8411, "ERROR_DS_MISSING_EXPECTED_ATT")); - ErrorNames.insert(std::make_pair(8412, "ERROR_DS_NCNAME_MISSING_CR_REF")); - ErrorNames.insert(std::make_pair(8413, "ERROR_DS_SECURITY_CHECKING_ERROR")); - ErrorNames.insert(std::make_pair(8414, "ERROR_DS_SCHEMA_NOT_LOADED")); - ErrorNames.insert(std::make_pair(8415, "ERROR_DS_SCHEMA_ALLOC_FAILED")); - ErrorNames.insert(std::make_pair(8416, "ERROR_DS_ATT_SCHEMA_REQ_SYNTAX")); - ErrorNames.insert(std::make_pair(8417, "ERROR_DS_GCVERIFY_ERROR")); - ErrorNames.insert(std::make_pair(8418, "ERROR_DS_DRA_SCHEMA_MISMATCH")); - ErrorNames.insert(std::make_pair(8419, "ERROR_DS_CANT_FIND_DSA_OBJ")); - ErrorNames.insert(std::make_pair(8420, "ERROR_DS_CANT_FIND_EXPECTED_NC")); - ErrorNames.insert(std::make_pair(8421, "ERROR_DS_CANT_FIND_NC_IN_CACHE")); - ErrorNames.insert(std::make_pair(8422, "ERROR_DS_CANT_RETRIEVE_CHILD")); - ErrorNames.insert(std::make_pair(8423, "ERROR_DS_SECURITY_ILLEGAL_MODIFY")); - ErrorNames.insert(std::make_pair(8424, "ERROR_DS_CANT_REPLACE_HIDDEN_REC")); - ErrorNames.insert(std::make_pair(8425, "ERROR_DS_BAD_HIERARCHY_FILE")); - ErrorNames.insert(std::make_pair(8426, "ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED")); - ErrorNames.insert(std::make_pair(8427, "ERROR_DS_CONFIG_PARAM_MISSING")); - ErrorNames.insert(std::make_pair(8428, "ERROR_DS_COUNTING_AB_INDICES_FAILED")); - ErrorNames.insert(std::make_pair(8429, "ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED")); - ErrorNames.insert(std::make_pair(8430, "ERROR_DS_INTERNAL_FAILURE")); - ErrorNames.insert(std::make_pair(8431, "ERROR_DS_UNKNOWN_ERROR")); - ErrorNames.insert(std::make_pair(8432, "ERROR_DS_ROOT_REQUIRES_CLASS_TOP")); - ErrorNames.insert(std::make_pair(8433, "ERROR_DS_REFUSING_FSMO_ROLES")); - ErrorNames.insert(std::make_pair(8434, "ERROR_DS_MISSING_FSMO_SETTINGS")); - ErrorNames.insert(std::make_pair(8435, "ERROR_DS_UNABLE_TO_SURRENDER_ROLES")); - ErrorNames.insert(std::make_pair(8436, "ERROR_DS_DRA_GENERIC")); - ErrorNames.insert(std::make_pair(8437, "ERROR_DS_DRA_INVALID_PARAMETER")); - ErrorNames.insert(std::make_pair(8438, "ERROR_DS_DRA_BUSY")); - ErrorNames.insert(std::make_pair(8439, "ERROR_DS_DRA_BAD_DN")); - ErrorNames.insert(std::make_pair(8440, "ERROR_DS_DRA_BAD_NC")); - ErrorNames.insert(std::make_pair(8441, "ERROR_DS_DRA_DN_EXISTS")); - ErrorNames.insert(std::make_pair(8442, "ERROR_DS_DRA_INTERNAL_ERROR")); - ErrorNames.insert(std::make_pair(8443, "ERROR_DS_DRA_INCONSISTENT_DIT")); - ErrorNames.insert(std::make_pair(8444, "ERROR_DS_DRA_CONNECTION_FAILED")); - ErrorNames.insert(std::make_pair(8445, "ERROR_DS_DRA_BAD_INSTANCE_TYPE")); - ErrorNames.insert(std::make_pair(8446, "ERROR_DS_DRA_OUT_OF_MEM")); - ErrorNames.insert(std::make_pair(8447, "ERROR_DS_DRA_MAIL_PROBLEM")); - ErrorNames.insert(std::make_pair(8448, "ERROR_DS_DRA_REF_ALREADY_EXISTS")); - ErrorNames.insert(std::make_pair(8449, "ERROR_DS_DRA_REF_NOT_FOUND")); - ErrorNames.insert(std::make_pair(8450, "ERROR_DS_DRA_OBJ_IS_REP_SOURCE")); - ErrorNames.insert(std::make_pair(8451, "ERROR_DS_DRA_DB_ERROR")); - ErrorNames.insert(std::make_pair(8452, "ERROR_DS_DRA_NO_REPLICA")); - ErrorNames.insert(std::make_pair(8453, "ERROR_DS_DRA_ACCESS_DENIED")); - ErrorNames.insert(std::make_pair(8454, "ERROR_DS_DRA_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(8455, "ERROR_DS_DRA_RPC_CANCELLED")); - ErrorNames.insert(std::make_pair(8456, "ERROR_DS_DRA_SOURCE_DISABLED")); - ErrorNames.insert(std::make_pair(8457, "ERROR_DS_DRA_SINK_DISABLED")); - ErrorNames.insert(std::make_pair(8458, "ERROR_DS_DRA_NAME_COLLISION")); - ErrorNames.insert(std::make_pair(8459, "ERROR_DS_DRA_SOURCE_REINSTALLED")); - ErrorNames.insert(std::make_pair(8460, "ERROR_DS_DRA_MISSING_PARENT")); - ErrorNames.insert(std::make_pair(8461, "ERROR_DS_DRA_PREEMPTED")); - ErrorNames.insert(std::make_pair(8462, "ERROR_DS_DRA_ABANDON_SYNC")); - ErrorNames.insert(std::make_pair(8463, "ERROR_DS_DRA_SHUTDOWN")); - ErrorNames.insert(std::make_pair(8464, "ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET")); - ErrorNames.insert(std::make_pair(8465, "ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA")); - ErrorNames.insert(std::make_pair(8466, "ERROR_DS_DRA_EXTN_CONNECTION_FAILED")); - ErrorNames.insert(std::make_pair(8467, "ERROR_DS_INSTALL_SCHEMA_MISMATCH")); - ErrorNames.insert(std::make_pair(8468, "ERROR_DS_DUP_LINK_ID")); - ErrorNames.insert(std::make_pair(8469, "ERROR_DS_NAME_ERROR_RESOLVING")); - ErrorNames.insert(std::make_pair(8470, "ERROR_DS_NAME_ERROR_NOT_FOUND")); - ErrorNames.insert(std::make_pair(8471, "ERROR_DS_NAME_ERROR_NOT_UNIQUE")); - ErrorNames.insert(std::make_pair(8472, "ERROR_DS_NAME_ERROR_NO_MAPPING")); - ErrorNames.insert(std::make_pair(8473, "ERROR_DS_NAME_ERROR_DOMAIN_ONLY")); - ErrorNames.insert(std::make_pair(8474, "ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING")); - ErrorNames.insert(std::make_pair(8475, "ERROR_DS_CONSTRUCTED_ATT_MOD")); - ErrorNames.insert(std::make_pair(8476, "ERROR_DS_WRONG_OM_OBJ_CLASS")); - ErrorNames.insert(std::make_pair(8477, "ERROR_DS_DRA_REPL_PENDING")); - ErrorNames.insert(std::make_pair(8478, "ERROR_DS_DS_REQUIRED")); - ErrorNames.insert(std::make_pair(8479, "ERROR_DS_INVALID_LDAP_DISPLAY_NAME")); - ErrorNames.insert(std::make_pair(8480, "ERROR_DS_NON_BASE_SEARCH")); - ErrorNames.insert(std::make_pair(8481, "ERROR_DS_CANT_RETRIEVE_ATTS")); - ErrorNames.insert(std::make_pair(8482, "ERROR_DS_BACKLINK_WITHOUT_LINK")); - ErrorNames.insert(std::make_pair(8483, "ERROR_DS_EPOCH_MISMATCH")); - ErrorNames.insert(std::make_pair(8484, "ERROR_DS_SRC_NAME_MISMATCH")); - ErrorNames.insert(std::make_pair(8485, "ERROR_DS_SRC_AND_DST_NC_IDENTICAL")); - ErrorNames.insert(std::make_pair(8486, "ERROR_DS_DST_NC_MISMATCH")); - ErrorNames.insert(std::make_pair(8487, "ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC")); - ErrorNames.insert(std::make_pair(8488, "ERROR_DS_SRC_GUID_MISMATCH")); - ErrorNames.insert(std::make_pair(8489, "ERROR_DS_CANT_MOVE_DELETED_OBJECT")); - ErrorNames.insert(std::make_pair(8490, "ERROR_DS_PDC_OPERATION_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(8491, "ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD")); - ErrorNames.insert(std::make_pair(8492, "ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION")); - ErrorNames.insert(std::make_pair(8493, "ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS")); - ErrorNames.insert(std::make_pair(8494, "ERROR_DS_NC_MUST_HAVE_NC_PARENT")); - ErrorNames.insert(std::make_pair(8495, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE")); - ErrorNames.insert(std::make_pair(8496, "ERROR_DS_DST_DOMAIN_NOT_NATIVE")); - ErrorNames.insert(std::make_pair(8497, "ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER")); - ErrorNames.insert(std::make_pair(8498, "ERROR_DS_CANT_MOVE_ACCOUNT_GROUP")); - ErrorNames.insert(std::make_pair(8499, "ERROR_DS_CANT_MOVE_RESOURCE_GROUP")); - ErrorNames.insert(std::make_pair(8500, "ERROR_DS_INVALID_SEARCH_FLAG")); - ErrorNames.insert(std::make_pair(8501, "ERROR_DS_NO_TREE_DELETE_ABOVE_NC")); - ErrorNames.insert(std::make_pair(8502, "ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE")); - ErrorNames.insert(std::make_pair(8503, "ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE")); - ErrorNames.insert(std::make_pair(8504, "ERROR_DS_SAM_INIT_FAILURE")); - ErrorNames.insert(std::make_pair(8505, "ERROR_DS_SENSITIVE_GROUP_VIOLATION")); - ErrorNames.insert(std::make_pair(8506, "ERROR_DS_CANT_MOD_PRIMARYGROUPID")); - ErrorNames.insert(std::make_pair(8507, "ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD")); - ErrorNames.insert(std::make_pair(8508, "ERROR_DS_NONSAFE_SCHEMA_CHANGE")); - ErrorNames.insert(std::make_pair(8509, "ERROR_DS_SCHEMA_UPDATE_DISALLOWED")); - ErrorNames.insert(std::make_pair(8510, "ERROR_DS_CANT_CREATE_UNDER_SCHEMA")); - ErrorNames.insert(std::make_pair(8511, "ERROR_DS_INSTALL_NO_SRC_SCH_VERSION")); - ErrorNames.insert(std::make_pair(8512, "ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE")); - ErrorNames.insert(std::make_pair(8513, "ERROR_DS_INVALID_GROUP_TYPE")); - ErrorNames.insert(std::make_pair(8514, "ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN")); - ErrorNames.insert(std::make_pair(8515, "ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN")); - ErrorNames.insert(std::make_pair(8516, "ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER")); - ErrorNames.insert(std::make_pair(8517, "ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER")); - ErrorNames.insert(std::make_pair(8518, "ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER")); - ErrorNames.insert(std::make_pair(8519, "ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER")); - ErrorNames.insert(std::make_pair(8520, "ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER")); - ErrorNames.insert(std::make_pair(8521, "ERROR_DS_HAVE_PRIMARY_MEMBERS")); - ErrorNames.insert(std::make_pair(8522, "ERROR_DS_STRING_SD_CONVERSION_FAILED")); - ErrorNames.insert(std::make_pair(8523, "ERROR_DS_NAMING_MASTER_GC")); - ErrorNames.insert(std::make_pair(8524, "ERROR_DS_DNS_LOOKUP_FAILURE")); - ErrorNames.insert(std::make_pair(8525, "ERROR_DS_COULDNT_UPDATE_SPNS")); - ErrorNames.insert(std::make_pair(8526, "ERROR_DS_CANT_RETRIEVE_SD")); - ErrorNames.insert(std::make_pair(8527, "ERROR_DS_KEY_NOT_UNIQUE")); - ErrorNames.insert(std::make_pair(8528, "ERROR_DS_WRONG_LINKED_ATT_SYNTAX")); - ErrorNames.insert(std::make_pair(8529, "ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD")); - ErrorNames.insert(std::make_pair(8530, "ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY")); - ErrorNames.insert(std::make_pair(8531, "ERROR_DS_CANT_START")); - ErrorNames.insert(std::make_pair(8532, "ERROR_DS_INIT_FAILURE")); - ErrorNames.insert(std::make_pair(8533, "ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION")); - ErrorNames.insert(std::make_pair(8534, "ERROR_DS_SOURCE_DOMAIN_IN_FOREST")); - ErrorNames.insert(std::make_pair(8535, "ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST")); - ErrorNames.insert(std::make_pair(8536, "ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED")); - ErrorNames.insert(std::make_pair(8537, "ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN")); - ErrorNames.insert(std::make_pair(8538, "ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER")); - ErrorNames.insert(std::make_pair(8539, "ERROR_DS_SRC_SID_EXISTS_IN_FOREST")); - ErrorNames.insert(std::make_pair(8540, "ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH")); - ErrorNames.insert(std::make_pair(8541, "ERROR_SAM_INIT_FAILURE")); - ErrorNames.insert(std::make_pair(8542, "ERROR_DS_DRA_SCHEMA_INFO_SHIP")); - ErrorNames.insert(std::make_pair(8543, "ERROR_DS_DRA_SCHEMA_CONFLICT")); - ErrorNames.insert(std::make_pair(8544, "ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT")); - ErrorNames.insert(std::make_pair(8545, "ERROR_DS_DRA_OBJ_NC_MISMATCH")); - ErrorNames.insert(std::make_pair(8546, "ERROR_DS_NC_STILL_HAS_DSAS")); - ErrorNames.insert(std::make_pair(8547, "ERROR_DS_GC_REQUIRED")); - ErrorNames.insert(std::make_pair(8548, "ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY")); - ErrorNames.insert(std::make_pair(8549, "ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS")); - ErrorNames.insert(std::make_pair(8550, "ERROR_DS_CANT_ADD_TO_GC")); - ErrorNames.insert(std::make_pair(8551, "ERROR_DS_NO_CHECKPOINT_WITH_PDC")); - ErrorNames.insert(std::make_pair(8552, "ERROR_DS_SOURCE_AUDITING_NOT_ENABLED")); - ErrorNames.insert(std::make_pair(8553, "ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC")); - ErrorNames.insert(std::make_pair(8554, "ERROR_DS_INVALID_NAME_FOR_SPN")); - ErrorNames.insert(std::make_pair(8555, "ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS")); - ErrorNames.insert(std::make_pair(8556, "ERROR_DS_UNICODEPWD_NOT_IN_QUOTES")); - ErrorNames.insert(std::make_pair(8557, "ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED")); - ErrorNames.insert(std::make_pair(8558, "ERROR_DS_MUST_BE_RUN_ON_DST_DC")); - ErrorNames.insert(std::make_pair(8559, "ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER")); - ErrorNames.insert(std::make_pair(8560, "ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ")); - ErrorNames.insert(std::make_pair(8561, "ERROR_DS_INIT_FAILURE_CONSOLE")); - ErrorNames.insert(std::make_pair(8562, "ERROR_DS_SAM_INIT_FAILURE_CONSOLE")); - ErrorNames.insert(std::make_pair(8563, "ERROR_DS_FOREST_VERSION_TOO_HIGH")); - ErrorNames.insert(std::make_pair(8564, "ERROR_DS_DOMAIN_VERSION_TOO_HIGH")); - ErrorNames.insert(std::make_pair(8565, "ERROR_DS_FOREST_VERSION_TOO_LOW")); - ErrorNames.insert(std::make_pair(8566, "ERROR_DS_DOMAIN_VERSION_TOO_LOW")); - ErrorNames.insert(std::make_pair(8567, "ERROR_DS_INCOMPATIBLE_VERSION")); - ErrorNames.insert(std::make_pair(8568, "ERROR_DS_LOW_DSA_VERSION")); - ErrorNames.insert(std::make_pair(8569, "ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN")); - ErrorNames.insert(std::make_pair(8570, "ERROR_DS_NOT_SUPPORTED_SORT_ORDER")); - ErrorNames.insert(std::make_pair(8571, "ERROR_DS_NAME_NOT_UNIQUE")); - ErrorNames.insert(std::make_pair(8572, "ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4")); - ErrorNames.insert(std::make_pair(8573, "ERROR_DS_OUT_OF_VERSION_STORE")); - ErrorNames.insert(std::make_pair(8574, "ERROR_DS_INCOMPATIBLE_CONTROLS_USED")); - ErrorNames.insert(std::make_pair(8575, "ERROR_DS_NO_REF_DOMAIN")); - ErrorNames.insert(std::make_pair(8576, "ERROR_DS_RESERVED_LINK_ID")); - ErrorNames.insert(std::make_pair(8577, "ERROR_DS_LINK_ID_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(8578, "ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER")); - ErrorNames.insert(std::make_pair(8579, "ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE")); - ErrorNames.insert(std::make_pair(8580, "ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC")); - ErrorNames.insert(std::make_pair(8581, "ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG")); - ErrorNames.insert(std::make_pair(8582, "ERROR_DS_MODIFYDN_WRONG_GRANDPARENT")); - ErrorNames.insert(std::make_pair(8583, "ERROR_DS_NAME_ERROR_TRUST_REFERRAL")); - ErrorNames.insert(std::make_pair(8584, "ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER")); - ErrorNames.insert(std::make_pair(8585, "ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD")); - ErrorNames.insert(std::make_pair(8586, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2")); - ErrorNames.insert(std::make_pair(8587, "ERROR_DS_THREAD_LIMIT_EXCEEDED")); - ErrorNames.insert(std::make_pair(8588, "ERROR_DS_NOT_CLOSEST")); - ErrorNames.insert(std::make_pair(8589, "ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF")); - ErrorNames.insert(std::make_pair(8590, "ERROR_DS_SINGLE_USER_MODE_FAILED")); - ErrorNames.insert(std::make_pair(8591, "ERROR_DS_NTDSCRIPT_SYNTAX_ERROR")); - ErrorNames.insert(std::make_pair(8592, "ERROR_DS_NTDSCRIPT_PROCESS_ERROR")); - ErrorNames.insert(std::make_pair(8593, "ERROR_DS_DIFFERENT_REPL_EPOCHS")); - ErrorNames.insert(std::make_pair(8594, "ERROR_DS_DRS_EXTENSIONS_CHANGED")); - ErrorNames.insert(std::make_pair(8595, "ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR")); - ErrorNames.insert(std::make_pair(8596, "ERROR_DS_NO_MSDS_INTID")); - ErrorNames.insert(std::make_pair(8597, "ERROR_DS_DUP_MSDS_INTID")); - ErrorNames.insert(std::make_pair(8598, "ERROR_DS_EXISTS_IN_RDNATTID")); - ErrorNames.insert(std::make_pair(8599, "ERROR_DS_AUTHORIZATION_FAILED")); - ErrorNames.insert(std::make_pair(8600, "ERROR_DS_INVALID_SCRIPT")); - ErrorNames.insert(std::make_pair(8601, "ERROR_DS_REMOTE_CROSSREF_OP_FAILED")); - ErrorNames.insert(std::make_pair(8602, "ERROR_DS_CROSS_REF_BUSY")); - ErrorNames.insert(std::make_pair(8603, "ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN")); - ErrorNames.insert(std::make_pair(8604, "ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC")); - ErrorNames.insert(std::make_pair(8605, "ERROR_DS_DUPLICATE_ID_FOUND")); - ErrorNames.insert(std::make_pair(8606, "ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT")); - ErrorNames.insert(std::make_pair(8607, "ERROR_DS_GROUP_CONVERSION_ERROR")); - ErrorNames.insert(std::make_pair(8608, "ERROR_DS_CANT_MOVE_APP_BASIC_GROUP")); - ErrorNames.insert(std::make_pair(8609, "ERROR_DS_CANT_MOVE_APP_QUERY_GROUP")); - ErrorNames.insert(std::make_pair(8610, "ERROR_DS_ROLE_NOT_VERIFIED")); - ErrorNames.insert(std::make_pair(8611, "ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL")); - ErrorNames.insert(std::make_pair(8612, "ERROR_DS_DOMAIN_RENAME_IN_PROGRESS")); - ErrorNames.insert(std::make_pair(8613, "ERROR_DS_EXISTING_AD_CHILD_NC")); - ErrorNames.insert(std::make_pair(8614, "ERROR_DS_REPL_LIFETIME_EXCEEDED")); - ErrorNames.insert(std::make_pair(8615, "ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER")); - ErrorNames.insert(std::make_pair(8616, "ERROR_DS_LDAP_SEND_QUEUE_FULL")); - ErrorNames.insert(std::make_pair(8617, "ERROR_DS_DRA_OUT_SCHEDULE_WINDOW")); - ErrorNames.insert(std::make_pair(8618, "ERROR_DS_POLICY_NOT_KNOWN")); - ErrorNames.insert(std::make_pair(8619, "ERROR_NO_SITE_SETTINGS_OBJECT")); - ErrorNames.insert(std::make_pair(8620, "ERROR_NO_SECRETS")); - ErrorNames.insert(std::make_pair(8621, "ERROR_NO_WRITABLE_DC_FOUND")); - ErrorNames.insert(std::make_pair(8622, "ERROR_DS_NO_SERVER_OBJECT")); - ErrorNames.insert(std::make_pair(8623, "ERROR_DS_NO_NTDSA_OBJECT")); - ErrorNames.insert(std::make_pair(8624, "ERROR_DS_NON_ASQ_SEARCH")); - ErrorNames.insert(std::make_pair(8625, "ERROR_DS_AUDIT_FAILURE")); - ErrorNames.insert(std::make_pair(8626, "ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE")); - ErrorNames.insert(std::make_pair(8627, "ERROR_DS_INVALID_SEARCH_FLAG_TUPLE")); - ErrorNames.insert(std::make_pair(8628, "ERROR_DS_HIERARCHY_TABLE_TOO_DEEP")); - ErrorNames.insert(std::make_pair(8629, "ERROR_DS_DRA_CORRUPT_UTD_VECTOR")); - ErrorNames.insert(std::make_pair(8630, "ERROR_DS_DRA_SECRETS_DENIED")); - ErrorNames.insert(std::make_pair(8631, "ERROR_DS_RESERVED_MAPI_ID")); - ErrorNames.insert(std::make_pair(8632, "ERROR_DS_MAPI_ID_NOT_AVAILABLE")); - ErrorNames.insert(std::make_pair(8633, "ERROR_DS_DRA_MISSING_KRBTGT_SECRET")); - ErrorNames.insert(std::make_pair(8634, "ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST")); - ErrorNames.insert(std::make_pair(8635, "ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST")); - ErrorNames.insert(std::make_pair(8636, "ERROR_INVALID_USER_PRINCIPAL_NAME")); - ErrorNames.insert(std::make_pair(8637, "ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS")); - ErrorNames.insert(std::make_pair(8638, "ERROR_DS_OID_NOT_FOUND")); - ErrorNames.insert(std::make_pair(8639, "ERROR_DS_DRA_RECYCLED_TARGET")); - ErrorNames.insert(std::make_pair(13000, "ERROR_IPSEC_QM_POLICY_EXISTS")); - ErrorNames.insert(std::make_pair(13001, "ERROR_IPSEC_QM_POLICY_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13002, "ERROR_IPSEC_QM_POLICY_IN_USE")); - ErrorNames.insert(std::make_pair(13003, "ERROR_IPSEC_MM_POLICY_EXISTS")); - ErrorNames.insert(std::make_pair(13004, "ERROR_IPSEC_MM_POLICY_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13005, "ERROR_IPSEC_MM_POLICY_IN_USE")); - ErrorNames.insert(std::make_pair(13006, "ERROR_IPSEC_MM_FILTER_EXISTS")); - ErrorNames.insert(std::make_pair(13007, "ERROR_IPSEC_MM_FILTER_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13008, "ERROR_IPSEC_TRANSPORT_FILTER_EXISTS")); - ErrorNames.insert(std::make_pair(13009, "ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13010, "ERROR_IPSEC_MM_AUTH_EXISTS")); - ErrorNames.insert(std::make_pair(13011, "ERROR_IPSEC_MM_AUTH_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13012, "ERROR_IPSEC_MM_AUTH_IN_USE")); - ErrorNames.insert(std::make_pair(13013, "ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13014, "ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13015, "ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13016, "ERROR_IPSEC_TUNNEL_FILTER_EXISTS")); - ErrorNames.insert(std::make_pair(13017, "ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND")); - ErrorNames.insert(std::make_pair(13018, "ERROR_IPSEC_MM_FILTER_PENDING_DELETION")); - ErrorNames.insert(std::make_pair(13019, "ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION")); - ErrorNames.insert(std::make_pair(13020, "ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION")); - ErrorNames.insert(std::make_pair(13021, "ERROR_IPSEC_MM_POLICY_PENDING_DELETION")); - ErrorNames.insert(std::make_pair(13022, "ERROR_IPSEC_MM_AUTH_PENDING_DELETION")); - ErrorNames.insert(std::make_pair(13023, "ERROR_IPSEC_QM_POLICY_PENDING_DELETION")); - ErrorNames.insert(std::make_pair(13800, "ERROR_IPSEC_IKE_NEG_STATUS_BEGIN")); - ErrorNames.insert(std::make_pair(13801, "ERROR_IPSEC_IKE_AUTH_FAIL")); - ErrorNames.insert(std::make_pair(13802, "ERROR_IPSEC_IKE_ATTRIB_FAIL")); - ErrorNames.insert(std::make_pair(13803, "ERROR_IPSEC_IKE_NEGOTIATION_PENDING")); - ErrorNames.insert(std::make_pair(13804, "ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR")); - ErrorNames.insert(std::make_pair(13805, "ERROR_IPSEC_IKE_TIMED_OUT")); - ErrorNames.insert(std::make_pair(13806, "ERROR_IPSEC_IKE_NO_CERT")); - ErrorNames.insert(std::make_pair(13807, "ERROR_IPSEC_IKE_SA_DELETED")); - ErrorNames.insert(std::make_pair(13808, "ERROR_IPSEC_IKE_SA_REAPED")); - ErrorNames.insert(std::make_pair(13809, "ERROR_IPSEC_IKE_MM_ACQUIRE_DROP")); - ErrorNames.insert(std::make_pair(13810, "ERROR_IPSEC_IKE_QM_ACQUIRE_DROP")); - ErrorNames.insert(std::make_pair(13811, "ERROR_IPSEC_IKE_QUEUE_DROP_MM")); - ErrorNames.insert(std::make_pair(13812, "ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM")); - ErrorNames.insert(std::make_pair(13813, "ERROR_IPSEC_IKE_DROP_NO_RESPONSE")); - ErrorNames.insert(std::make_pair(13814, "ERROR_IPSEC_IKE_MM_DELAY_DROP")); - ErrorNames.insert(std::make_pair(13815, "ERROR_IPSEC_IKE_QM_DELAY_DROP")); - ErrorNames.insert(std::make_pair(13816, "ERROR_IPSEC_IKE_ERROR")); - ErrorNames.insert(std::make_pair(13817, "ERROR_IPSEC_IKE_CRL_FAILED")); - ErrorNames.insert(std::make_pair(13818, "ERROR_IPSEC_IKE_INVALID_KEY_USAGE")); - ErrorNames.insert(std::make_pair(13819, "ERROR_IPSEC_IKE_INVALID_CERT_TYPE")); - ErrorNames.insert(std::make_pair(13820, "ERROR_IPSEC_IKE_NO_PRIVATE_KEY")); - ErrorNames.insert(std::make_pair(13821, "ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY")); - ErrorNames.insert(std::make_pair(13822, "ERROR_IPSEC_IKE_DH_FAIL")); - ErrorNames.insert(std::make_pair(13823, "ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED")); - ErrorNames.insert(std::make_pair(13824, "ERROR_IPSEC_IKE_INVALID_HEADER")); - ErrorNames.insert(std::make_pair(13825, "ERROR_IPSEC_IKE_NO_POLICY")); - ErrorNames.insert(std::make_pair(13826, "ERROR_IPSEC_IKE_INVALID_SIGNATURE")); - ErrorNames.insert(std::make_pair(13827, "ERROR_IPSEC_IKE_KERBEROS_ERROR")); - ErrorNames.insert(std::make_pair(13828, "ERROR_IPSEC_IKE_NO_PUBLIC_KEY")); - ErrorNames.insert(std::make_pair(13829, "ERROR_IPSEC_IKE_PROCESS_ERR")); - ErrorNames.insert(std::make_pair(13830, "ERROR_IPSEC_IKE_PROCESS_ERR_SA")); - ErrorNames.insert(std::make_pair(13831, "ERROR_IPSEC_IKE_PROCESS_ERR_PROP")); - ErrorNames.insert(std::make_pair(13832, "ERROR_IPSEC_IKE_PROCESS_ERR_TRANS")); - ErrorNames.insert(std::make_pair(13833, "ERROR_IPSEC_IKE_PROCESS_ERR_KE")); - ErrorNames.insert(std::make_pair(13834, "ERROR_IPSEC_IKE_PROCESS_ERR_ID")); - ErrorNames.insert(std::make_pair(13835, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT")); - ErrorNames.insert(std::make_pair(13836, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ")); - ErrorNames.insert(std::make_pair(13837, "ERROR_IPSEC_IKE_PROCESS_ERR_HASH")); - ErrorNames.insert(std::make_pair(13838, "ERROR_IPSEC_IKE_PROCESS_ERR_SIG")); - ErrorNames.insert(std::make_pair(13839, "ERROR_IPSEC_IKE_PROCESS_ERR_NONCE")); - ErrorNames.insert(std::make_pair(13840, "ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY")); - ErrorNames.insert(std::make_pair(13841, "ERROR_IPSEC_IKE_PROCESS_ERR_DELETE")); - ErrorNames.insert(std::make_pair(13842, "ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR")); - ErrorNames.insert(std::make_pair(13843, "ERROR_IPSEC_IKE_INVALID_PAYLOAD")); - ErrorNames.insert(std::make_pair(13844, "ERROR_IPSEC_IKE_LOAD_SOFT_SA")); - ErrorNames.insert(std::make_pair(13845, "ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN")); - ErrorNames.insert(std::make_pair(13846, "ERROR_IPSEC_IKE_INVALID_COOKIE")); - ErrorNames.insert(std::make_pair(13847, "ERROR_IPSEC_IKE_NO_PEER_CERT")); - ErrorNames.insert(std::make_pair(13848, "ERROR_IPSEC_IKE_PEER_CRL_FAILED")); - ErrorNames.insert(std::make_pair(13849, "ERROR_IPSEC_IKE_POLICY_CHANGE")); - ErrorNames.insert(std::make_pair(13850, "ERROR_IPSEC_IKE_NO_MM_POLICY")); - ErrorNames.insert(std::make_pair(13851, "ERROR_IPSEC_IKE_NOTCBPRIV")); - ErrorNames.insert(std::make_pair(13852, "ERROR_IPSEC_IKE_SECLOADFAIL")); - ErrorNames.insert(std::make_pair(13853, "ERROR_IPSEC_IKE_FAILSSPINIT")); - ErrorNames.insert(std::make_pair(13854, "ERROR_IPSEC_IKE_FAILQUERYSSP")); - ErrorNames.insert(std::make_pair(13855, "ERROR_IPSEC_IKE_SRVACQFAIL")); - ErrorNames.insert(std::make_pair(13856, "ERROR_IPSEC_IKE_SRVQUERYCRED")); - ErrorNames.insert(std::make_pair(13857, "ERROR_IPSEC_IKE_GETSPIFAIL")); - ErrorNames.insert(std::make_pair(13858, "ERROR_IPSEC_IKE_INVALID_FILTER")); - ErrorNames.insert(std::make_pair(13859, "ERROR_IPSEC_IKE_OUT_OF_MEMORY")); - ErrorNames.insert(std::make_pair(13860, "ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED")); - ErrorNames.insert(std::make_pair(13861, "ERROR_IPSEC_IKE_INVALID_POLICY")); - ErrorNames.insert(std::make_pair(13862, "ERROR_IPSEC_IKE_UNKNOWN_DOI")); - ErrorNames.insert(std::make_pair(13863, "ERROR_IPSEC_IKE_INVALID_SITUATION")); - ErrorNames.insert(std::make_pair(13864, "ERROR_IPSEC_IKE_DH_FAILURE")); - ErrorNames.insert(std::make_pair(13865, "ERROR_IPSEC_IKE_INVALID_GROUP")); - ErrorNames.insert(std::make_pair(13866, "ERROR_IPSEC_IKE_ENCRYPT")); - ErrorNames.insert(std::make_pair(13867, "ERROR_IPSEC_IKE_DECRYPT")); - ErrorNames.insert(std::make_pair(13868, "ERROR_IPSEC_IKE_POLICY_MATCH")); - ErrorNames.insert(std::make_pair(13869, "ERROR_IPSEC_IKE_UNSUPPORTED_ID")); - ErrorNames.insert(std::make_pair(13870, "ERROR_IPSEC_IKE_INVALID_HASH")); - ErrorNames.insert(std::make_pair(13871, "ERROR_IPSEC_IKE_INVALID_HASH_ALG")); - ErrorNames.insert(std::make_pair(13872, "ERROR_IPSEC_IKE_INVALID_HASH_SIZE")); - ErrorNames.insert(std::make_pair(13873, "ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG")); - ErrorNames.insert(std::make_pair(13874, "ERROR_IPSEC_IKE_INVALID_AUTH_ALG")); - ErrorNames.insert(std::make_pair(13875, "ERROR_IPSEC_IKE_INVALID_SIG")); - ErrorNames.insert(std::make_pair(13876, "ERROR_IPSEC_IKE_LOAD_FAILED")); - ErrorNames.insert(std::make_pair(13877, "ERROR_IPSEC_IKE_RPC_DELETE")); - ErrorNames.insert(std::make_pair(13878, "ERROR_IPSEC_IKE_BENIGN_REINIT")); - ErrorNames.insert(std::make_pair(13879, "ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY")); - ErrorNames.insert(std::make_pair(13880, "ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION")); - ErrorNames.insert(std::make_pair(13881, "ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN")); - ErrorNames.insert(std::make_pair(13882, "ERROR_IPSEC_IKE_MM_LIMIT")); - ErrorNames.insert(std::make_pair(13883, "ERROR_IPSEC_IKE_NEGOTIATION_DISABLED")); - ErrorNames.insert(std::make_pair(13884, "ERROR_IPSEC_IKE_QM_LIMIT")); - ErrorNames.insert(std::make_pair(13885, "ERROR_IPSEC_IKE_MM_EXPIRED")); - ErrorNames.insert(std::make_pair(13886, "ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID")); - ErrorNames.insert(std::make_pair(13887, "ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH")); - ErrorNames.insert(std::make_pair(13888, "ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID")); - ErrorNames.insert(std::make_pair(13889, "ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD")); - ErrorNames.insert(std::make_pair(13890, "ERROR_IPSEC_IKE_DOS_COOKIE_SENT")); - ErrorNames.insert(std::make_pair(13891, "ERROR_IPSEC_IKE_SHUTTING_DOWN")); - ErrorNames.insert(std::make_pair(13892, "ERROR_IPSEC_IKE_CGA_AUTH_FAILED")); - ErrorNames.insert(std::make_pair(13893, "ERROR_IPSEC_IKE_PROCESS_ERR_NATOA")); - ErrorNames.insert(std::make_pair(13894, "ERROR_IPSEC_IKE_INVALID_MM_FOR_QM")); - ErrorNames.insert(std::make_pair(13895, "ERROR_IPSEC_IKE_QM_EXPIRED")); - ErrorNames.insert(std::make_pair(13896, "ERROR_IPSEC_IKE_TOO_MANY_FILTERS")); - ErrorNames.insert(std::make_pair(13897, "ERROR_IPSEC_IKE_NEG_STATUS_END")); - ErrorNames.insert(std::make_pair(13898, "ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL")); - ErrorNames.insert(std::make_pair(13899, "ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE")); - ErrorNames.insert(std::make_pair(13900, "ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING")); - ErrorNames.insert(std::make_pair(13901, "ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING")); - ErrorNames.insert(std::make_pair(13902, "ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS")); - ErrorNames.insert(std::make_pair(13903, "ERROR_IPSEC_IKE_RATELIMIT_DROP")); - ErrorNames.insert(std::make_pair(13904, "ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE")); - ErrorNames.insert(std::make_pair(13905, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE")); - ErrorNames.insert(std::make_pair(13906, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE")); - ErrorNames.insert(std::make_pair(13907, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY")); - ErrorNames.insert(std::make_pair(13908, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE")); - ErrorNames.insert(std::make_pair(13909, "ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END")); - ErrorNames.insert(std::make_pair(13910, "ERROR_IPSEC_BAD_SPI")); - ErrorNames.insert(std::make_pair(13911, "ERROR_IPSEC_SA_LIFETIME_EXPIRED")); - ErrorNames.insert(std::make_pair(13912, "ERROR_IPSEC_WRONG_SA")); - ErrorNames.insert(std::make_pair(13913, "ERROR_IPSEC_REPLAY_CHECK_FAILED")); - ErrorNames.insert(std::make_pair(13914, "ERROR_IPSEC_INVALID_PACKET")); - ErrorNames.insert(std::make_pair(13915, "ERROR_IPSEC_INTEGRITY_CHECK_FAILED")); - ErrorNames.insert(std::make_pair(13916, "ERROR_IPSEC_CLEAR_TEXT_DROP")); - ErrorNames.insert(std::make_pair(13917, "ERROR_IPSEC_AUTH_FIREWALL_DROP")); - ErrorNames.insert(std::make_pair(13918, "ERROR_IPSEC_THROTTLE_DROP")); - ErrorNames.insert(std::make_pair(13925, "ERROR_IPSEC_DOSP_BLOCK")); - ErrorNames.insert(std::make_pair(13926, "ERROR_IPSEC_DOSP_RECEIVED_MULTICAST")); - ErrorNames.insert(std::make_pair(13927, "ERROR_IPSEC_DOSP_INVALID_PACKET")); - ErrorNames.insert(std::make_pair(13928, "ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED")); - ErrorNames.insert(std::make_pair(13929, "ERROR_IPSEC_DOSP_MAX_ENTRIES")); - ErrorNames.insert(std::make_pair(13930, "ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED")); - ErrorNames.insert(std::make_pair(13931, "ERROR_IPSEC_DOSP_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(13932, "ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES")); - ErrorNames.insert(std::make_pair(14000, "ERROR_SXS_SECTION_NOT_FOUND")); - ErrorNames.insert(std::make_pair(14001, "ERROR_SXS_CANT_GEN_ACTCTX")); - ErrorNames.insert(std::make_pair(14002, "ERROR_SXS_INVALID_ACTCTXDATA_FORMAT")); - ErrorNames.insert(std::make_pair(14003, "ERROR_SXS_ASSEMBLY_NOT_FOUND")); - ErrorNames.insert(std::make_pair(14004, "ERROR_SXS_MANIFEST_FORMAT_ERROR")); - ErrorNames.insert(std::make_pair(14005, "ERROR_SXS_MANIFEST_PARSE_ERROR")); - ErrorNames.insert(std::make_pair(14006, "ERROR_SXS_ACTIVATION_CONTEXT_DISABLED")); - ErrorNames.insert(std::make_pair(14007, "ERROR_SXS_KEY_NOT_FOUND")); - ErrorNames.insert(std::make_pair(14008, "ERROR_SXS_VERSION_CONFLICT")); - ErrorNames.insert(std::make_pair(14009, "ERROR_SXS_WRONG_SECTION_TYPE")); - ErrorNames.insert(std::make_pair(14010, "ERROR_SXS_THREAD_QUERIES_DISABLED")); - ErrorNames.insert(std::make_pair(14011, "ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET")); - ErrorNames.insert(std::make_pair(14012, "ERROR_SXS_UNKNOWN_ENCODING_GROUP")); - ErrorNames.insert(std::make_pair(14013, "ERROR_SXS_UNKNOWN_ENCODING")); - ErrorNames.insert(std::make_pair(14014, "ERROR_SXS_INVALID_XML_NAMESPACE_URI")); - ErrorNames.insert(std::make_pair(14015, "ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(14016, "ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(14017, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE")); - ErrorNames.insert(std::make_pair(14018, "ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE")); - ErrorNames.insert(std::make_pair(14019, "ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE")); - ErrorNames.insert(std::make_pair(14020, "ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT")); - ErrorNames.insert(std::make_pair(14021, "ERROR_SXS_DUPLICATE_DLL_NAME")); - ErrorNames.insert(std::make_pair(14022, "ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME")); - ErrorNames.insert(std::make_pair(14023, "ERROR_SXS_DUPLICATE_CLSID")); - ErrorNames.insert(std::make_pair(14024, "ERROR_SXS_DUPLICATE_IID")); - ErrorNames.insert(std::make_pair(14025, "ERROR_SXS_DUPLICATE_TLBID")); - ErrorNames.insert(std::make_pair(14026, "ERROR_SXS_DUPLICATE_PROGID")); - ErrorNames.insert(std::make_pair(14027, "ERROR_SXS_DUPLICATE_ASSEMBLY_NAME")); - ErrorNames.insert(std::make_pair(14028, "ERROR_SXS_FILE_HASH_MISMATCH")); - ErrorNames.insert(std::make_pair(14029, "ERROR_SXS_POLICY_PARSE_ERROR")); - ErrorNames.insert(std::make_pair(14030, "ERROR_SXS_XML_E_MISSINGQUOTE")); - ErrorNames.insert(std::make_pair(14031, "ERROR_SXS_XML_E_COMMENTSYNTAX")); - ErrorNames.insert(std::make_pair(14032, "ERROR_SXS_XML_E_BADSTARTNAMECHAR")); - ErrorNames.insert(std::make_pair(14033, "ERROR_SXS_XML_E_BADNAMECHAR")); - ErrorNames.insert(std::make_pair(14034, "ERROR_SXS_XML_E_BADCHARINSTRING")); - ErrorNames.insert(std::make_pair(14035, "ERROR_SXS_XML_E_XMLDECLSYNTAX")); - ErrorNames.insert(std::make_pair(14036, "ERROR_SXS_XML_E_BADCHARDATA")); - ErrorNames.insert(std::make_pair(14037, "ERROR_SXS_XML_E_MISSINGWHITESPACE")); - ErrorNames.insert(std::make_pair(14038, "ERROR_SXS_XML_E_EXPECTINGTAGEND")); - ErrorNames.insert(std::make_pair(14039, "ERROR_SXS_XML_E_MISSINGSEMICOLON")); - ErrorNames.insert(std::make_pair(14040, "ERROR_SXS_XML_E_UNBALANCEDPAREN")); - ErrorNames.insert(std::make_pair(14041, "ERROR_SXS_XML_E_INTERNALERROR")); - ErrorNames.insert(std::make_pair(14042, "ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE")); - ErrorNames.insert(std::make_pair(14043, "ERROR_SXS_XML_E_INCOMPLETE_ENCODING")); - ErrorNames.insert(std::make_pair(14044, "ERROR_SXS_XML_E_MISSING_PAREN")); - ErrorNames.insert(std::make_pair(14045, "ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE")); - ErrorNames.insert(std::make_pair(14046, "ERROR_SXS_XML_E_MULTIPLE_COLONS")); - ErrorNames.insert(std::make_pair(14047, "ERROR_SXS_XML_E_INVALID_DECIMAL")); - ErrorNames.insert(std::make_pair(14048, "ERROR_SXS_XML_E_INVALID_HEXIDECIMAL")); - ErrorNames.insert(std::make_pair(14049, "ERROR_SXS_XML_E_INVALID_UNICODE")); - ErrorNames.insert(std::make_pair(14050, "ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK")); - ErrorNames.insert(std::make_pair(14051, "ERROR_SXS_XML_E_UNEXPECTEDENDTAG")); - ErrorNames.insert(std::make_pair(14052, "ERROR_SXS_XML_E_UNCLOSEDTAG")); - ErrorNames.insert(std::make_pair(14053, "ERROR_SXS_XML_E_DUPLICATEATTRIBUTE")); - ErrorNames.insert(std::make_pair(14054, "ERROR_SXS_XML_E_MULTIPLEROOTS")); - ErrorNames.insert(std::make_pair(14055, "ERROR_SXS_XML_E_INVALIDATROOTLEVEL")); - ErrorNames.insert(std::make_pair(14056, "ERROR_SXS_XML_E_BADXMLDECL")); - ErrorNames.insert(std::make_pair(14057, "ERROR_SXS_XML_E_MISSINGROOT")); - ErrorNames.insert(std::make_pair(14058, "ERROR_SXS_XML_E_UNEXPECTEDEOF")); - ErrorNames.insert(std::make_pair(14059, "ERROR_SXS_XML_E_BADPEREFINSUBSET")); - ErrorNames.insert(std::make_pair(14060, "ERROR_SXS_XML_E_UNCLOSEDSTARTTAG")); - ErrorNames.insert(std::make_pair(14061, "ERROR_SXS_XML_E_UNCLOSEDENDTAG")); - ErrorNames.insert(std::make_pair(14062, "ERROR_SXS_XML_E_UNCLOSEDSTRING")); - ErrorNames.insert(std::make_pair(14063, "ERROR_SXS_XML_E_UNCLOSEDCOMMENT")); - ErrorNames.insert(std::make_pair(14064, "ERROR_SXS_XML_E_UNCLOSEDDECL")); - ErrorNames.insert(std::make_pair(14065, "ERROR_SXS_XML_E_UNCLOSEDCDATA")); - ErrorNames.insert(std::make_pair(14066, "ERROR_SXS_XML_E_RESERVEDNAMESPACE")); - ErrorNames.insert(std::make_pair(14067, "ERROR_SXS_XML_E_INVALIDENCODING")); - ErrorNames.insert(std::make_pair(14068, "ERROR_SXS_XML_E_INVALIDSWITCH")); - ErrorNames.insert(std::make_pair(14069, "ERROR_SXS_XML_E_BADXMLCASE")); - ErrorNames.insert(std::make_pair(14070, "ERROR_SXS_XML_E_INVALID_STANDALONE")); - ErrorNames.insert(std::make_pair(14071, "ERROR_SXS_XML_E_UNEXPECTED_STANDALONE")); - ErrorNames.insert(std::make_pair(14072, "ERROR_SXS_XML_E_INVALID_VERSION")); - ErrorNames.insert(std::make_pair(14073, "ERROR_SXS_XML_E_MISSINGEQUALS")); - ErrorNames.insert(std::make_pair(14074, "ERROR_SXS_PROTECTION_RECOVERY_FAILED")); - ErrorNames.insert(std::make_pair(14075, "ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT")); - ErrorNames.insert(std::make_pair(14076, "ERROR_SXS_PROTECTION_CATALOG_NOT_VALID")); - ErrorNames.insert(std::make_pair(14077, "ERROR_SXS_UNTRANSLATABLE_HRESULT")); - ErrorNames.insert(std::make_pair(14078, "ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING")); - ErrorNames.insert(std::make_pair(14079, "ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE")); - ErrorNames.insert(std::make_pair(14080, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME")); - ErrorNames.insert(std::make_pair(14081, "ERROR_SXS_ASSEMBLY_MISSING")); - ErrorNames.insert(std::make_pair(14082, "ERROR_SXS_CORRUPT_ACTIVATION_STACK")); - ErrorNames.insert(std::make_pair(14083, "ERROR_SXS_CORRUPTION")); - ErrorNames.insert(std::make_pair(14084, "ERROR_SXS_EARLY_DEACTIVATION")); - ErrorNames.insert(std::make_pair(14085, "ERROR_SXS_INVALID_DEACTIVATION")); - ErrorNames.insert(std::make_pair(14086, "ERROR_SXS_MULTIPLE_DEACTIVATION")); - ErrorNames.insert(std::make_pair(14087, "ERROR_SXS_PROCESS_TERMINATION_REQUESTED")); - ErrorNames.insert(std::make_pair(14088, "ERROR_SXS_RELEASE_ACTIVATION_CONTEXT")); - ErrorNames.insert(std::make_pair(14089, "ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY")); - ErrorNames.insert(std::make_pair(14090, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE")); - ErrorNames.insert(std::make_pair(14091, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME")); - ErrorNames.insert(std::make_pair(14092, "ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE")); - ErrorNames.insert(std::make_pair(14093, "ERROR_SXS_IDENTITY_PARSE_ERROR")); - ErrorNames.insert(std::make_pair(14094, "ERROR_MALFORMED_SUBSTITUTION_STRING")); - ErrorNames.insert(std::make_pair(14095, "ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN")); - ErrorNames.insert(std::make_pair(14096, "ERROR_UNMAPPED_SUBSTITUTION_STRING")); - ErrorNames.insert(std::make_pair(14097, "ERROR_SXS_ASSEMBLY_NOT_LOCKED")); - ErrorNames.insert(std::make_pair(14098, "ERROR_SXS_COMPONENT_STORE_CORRUPT")); - ErrorNames.insert(std::make_pair(14099, "ERROR_ADVANCED_INSTALLER_FAILED")); - ErrorNames.insert(std::make_pair(14100, "ERROR_XML_ENCODING_MISMATCH")); - ErrorNames.insert(std::make_pair(14101, "ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT")); - ErrorNames.insert(std::make_pair(14102, "ERROR_SXS_IDENTITIES_DIFFERENT")); - ErrorNames.insert(std::make_pair(14103, "ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT")); - ErrorNames.insert(std::make_pair(14104, "ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY")); - ErrorNames.insert(std::make_pair(14105, "ERROR_SXS_MANIFEST_TOO_BIG")); - ErrorNames.insert(std::make_pair(14106, "ERROR_SXS_SETTING_NOT_REGISTERED")); - ErrorNames.insert(std::make_pair(14107, "ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE")); - ErrorNames.insert(std::make_pair(14108, "ERROR_SMI_PRIMITIVE_INSTALLER_FAILED")); - ErrorNames.insert(std::make_pair(14109, "ERROR_GENERIC_COMMAND_FAILED")); - ErrorNames.insert(std::make_pair(14110, "ERROR_SXS_FILE_HASH_MISSING")); - ErrorNames.insert(std::make_pair(15000, "ERROR_EVT_INVALID_CHANNEL_PATH")); - ErrorNames.insert(std::make_pair(15001, "ERROR_EVT_INVALID_QUERY")); - ErrorNames.insert(std::make_pair(15002, "ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15003, "ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15004, "ERROR_EVT_INVALID_PUBLISHER_NAME")); - ErrorNames.insert(std::make_pair(15005, "ERROR_EVT_INVALID_EVENT_DATA")); - ErrorNames.insert(std::make_pair(15007, "ERROR_EVT_CHANNEL_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15008, "ERROR_EVT_MALFORMED_XML_TEXT")); - ErrorNames.insert(std::make_pair(15009, "ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL")); - ErrorNames.insert(std::make_pair(15010, "ERROR_EVT_CONFIGURATION_ERROR")); - ErrorNames.insert(std::make_pair(15011, "ERROR_EVT_QUERY_RESULT_STALE")); - ErrorNames.insert(std::make_pair(15012, "ERROR_EVT_QUERY_RESULT_INVALID_POSITION")); - ErrorNames.insert(std::make_pair(15013, "ERROR_EVT_NON_VALIDATING_MSXML")); - ErrorNames.insert(std::make_pair(15014, "ERROR_EVT_FILTER_ALREADYSCOPED")); - ErrorNames.insert(std::make_pair(15015, "ERROR_EVT_FILTER_NOTELTSET")); - ErrorNames.insert(std::make_pair(15016, "ERROR_EVT_FILTER_INVARG")); - ErrorNames.insert(std::make_pair(15017, "ERROR_EVT_FILTER_INVTEST")); - ErrorNames.insert(std::make_pair(15018, "ERROR_EVT_FILTER_INVTYPE")); - ErrorNames.insert(std::make_pair(15019, "ERROR_EVT_FILTER_PARSEERR")); - ErrorNames.insert(std::make_pair(15020, "ERROR_EVT_FILTER_UNSUPPORTEDOP")); - ErrorNames.insert(std::make_pair(15021, "ERROR_EVT_FILTER_UNEXPECTEDTOKEN")); - ErrorNames.insert(std::make_pair(15022, "ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL")); - ErrorNames.insert(std::make_pair(15023, "ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE")); - ErrorNames.insert(std::make_pair(15024, "ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE")); - ErrorNames.insert(std::make_pair(15025, "ERROR_EVT_CHANNEL_CANNOT_ACTIVATE")); - ErrorNames.insert(std::make_pair(15026, "ERROR_EVT_FILTER_TOO_COMPLEX")); - ErrorNames.insert(std::make_pair(15027, "ERROR_EVT_MESSAGE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15028, "ERROR_EVT_MESSAGE_ID_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15029, "ERROR_EVT_UNRESOLVED_VALUE_INSERT")); - ErrorNames.insert(std::make_pair(15030, "ERROR_EVT_UNRESOLVED_PARAMETER_INSERT")); - ErrorNames.insert(std::make_pair(15031, "ERROR_EVT_MAX_INSERTS_REACHED")); - ErrorNames.insert(std::make_pair(15032, "ERROR_EVT_EVENT_DEFINITION_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15033, "ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15034, "ERROR_EVT_VERSION_TOO_OLD")); - ErrorNames.insert(std::make_pair(15035, "ERROR_EVT_VERSION_TOO_NEW")); - ErrorNames.insert(std::make_pair(15036, "ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY")); - ErrorNames.insert(std::make_pair(15037, "ERROR_EVT_PUBLISHER_DISABLED")); - ErrorNames.insert(std::make_pair(15038, "ERROR_EVT_FILTER_OUT_OF_RANGE")); - ErrorNames.insert(std::make_pair(15080, "ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE")); - ErrorNames.insert(std::make_pair(15081, "ERROR_EC_LOG_DISABLED")); - ErrorNames.insert(std::make_pair(15082, "ERROR_EC_CIRCULAR_FORWARDING")); - ErrorNames.insert(std::make_pair(15083, "ERROR_EC_CREDSTORE_FULL")); - ErrorNames.insert(std::make_pair(15084, "ERROR_EC_CRED_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15085, "ERROR_EC_NO_ACTIVE_CHANNEL")); - ErrorNames.insert(std::make_pair(15100, "ERROR_MUI_FILE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15101, "ERROR_MUI_INVALID_FILE")); - ErrorNames.insert(std::make_pair(15102, "ERROR_MUI_INVALID_RC_CONFIG")); - ErrorNames.insert(std::make_pair(15103, "ERROR_MUI_INVALID_LOCALE_NAME")); - ErrorNames.insert(std::make_pair(15104, "ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME")); - ErrorNames.insert(std::make_pair(15105, "ERROR_MUI_FILE_NOT_LOADED")); - ErrorNames.insert(std::make_pair(15106, "ERROR_RESOURCE_ENUM_USER_STOP")); - ErrorNames.insert(std::make_pair(15107, "ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED")); - ErrorNames.insert(std::make_pair(15108, "ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME")); - ErrorNames.insert(std::make_pair(15200, "ERROR_MCA_INVALID_CAPABILITIES_STRING")); - ErrorNames.insert(std::make_pair(15201, "ERROR_MCA_INVALID_VCP_VERSION")); - ErrorNames.insert(std::make_pair(15202, "ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION")); - ErrorNames.insert(std::make_pair(15203, "ERROR_MCA_MCCS_VERSION_MISMATCH")); - ErrorNames.insert(std::make_pair(15204, "ERROR_MCA_UNSUPPORTED_MCCS_VERSION")); - ErrorNames.insert(std::make_pair(15205, "ERROR_MCA_INTERNAL_ERROR")); - ErrorNames.insert(std::make_pair(15206, "ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED")); - ErrorNames.insert(std::make_pair(15207, "ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE")); - ErrorNames.insert(std::make_pair(15250, "ERROR_AMBIGUOUS_SYSTEM_DEVICE")); - ErrorNames.insert(std::make_pair(15299, "ERROR_SYSTEM_DEVICE_NOT_FOUND")); - ErrorNames.insert(std::make_pair(15300, "ERROR_HASH_NOT_SUPPORTED")); - ErrorNames.insert(std::make_pair(15301, "ERROR_HASH_NOT_PRESENT")); + errorNames.insert(std::make_pair(0, "ERROR_SUCCESS")); + errorNames.insert(std::make_pair(1, "ERROR_INVALID_FUNCTION")); + errorNames.insert(std::make_pair(2, "ERROR_FILE_NOT_FOUND")); + errorNames.insert(std::make_pair(3, "ERROR_PATH_NOT_FOUND")); + errorNames.insert(std::make_pair(4, "ERROR_TOO_MANY_OPEN_FILES")); + errorNames.insert(std::make_pair(5, "ERROR_ACCESS_DENIED")); + errorNames.insert(std::make_pair(6, "ERROR_INVALID_HANDLE")); + errorNames.insert(std::make_pair(7, "ERROR_ARENA_TRASHED")); + errorNames.insert(std::make_pair(8, "ERROR_NOT_ENOUGH_MEMORY")); + errorNames.insert(std::make_pair(9, "ERROR_INVALID_BLOCK")); + errorNames.insert(std::make_pair(10, "ERROR_BAD_ENVIRONMENT")); + errorNames.insert(std::make_pair(11, "ERROR_BAD_FORMAT")); + errorNames.insert(std::make_pair(12, "ERROR_INVALID_ACCESS")); + errorNames.insert(std::make_pair(13, "ERROR_INVALID_DATA")); + errorNames.insert(std::make_pair(14, "ERROR_OUTOFMEMORY")); + errorNames.insert(std::make_pair(15, "ERROR_INVALID_DRIVE")); + errorNames.insert(std::make_pair(16, "ERROR_CURRENT_DIRECTORY")); + errorNames.insert(std::make_pair(17, "ERROR_NOT_SAME_DEVICE")); + errorNames.insert(std::make_pair(18, "ERROR_NO_MORE_FILES")); + errorNames.insert(std::make_pair(19, "ERROR_WRITE_PROTECT")); + errorNames.insert(std::make_pair(20, "ERROR_BAD_UNIT")); + errorNames.insert(std::make_pair(21, "ERROR_NOT_READY")); + errorNames.insert(std::make_pair(22, "ERROR_BAD_COMMAND")); + errorNames.insert(std::make_pair(23, "ERROR_CRC")); + errorNames.insert(std::make_pair(24, "ERROR_BAD_LENGTH")); + errorNames.insert(std::make_pair(25, "ERROR_SEEK")); + errorNames.insert(std::make_pair(26, "ERROR_NOT_DOS_DISK")); + errorNames.insert(std::make_pair(27, "ERROR_SECTOR_NOT_FOUND")); + errorNames.insert(std::make_pair(28, "ERROR_OUT_OF_PAPER")); + errorNames.insert(std::make_pair(29, "ERROR_WRITE_FAULT")); + errorNames.insert(std::make_pair(30, "ERROR_READ_FAULT")); + errorNames.insert(std::make_pair(31, "ERROR_GEN_FAILURE")); + errorNames.insert(std::make_pair(32, "ERROR_SHARING_VIOLATION")); + errorNames.insert(std::make_pair(33, "ERROR_LOCK_VIOLATION")); + errorNames.insert(std::make_pair(34, "ERROR_WRONG_DISK")); + errorNames.insert(std::make_pair(36, "ERROR_SHARING_BUFFER_EXCEEDED")); + errorNames.insert(std::make_pair(38, "ERROR_HANDLE_EOF")); + errorNames.insert(std::make_pair(39, "ERROR_HANDLE_DISK_FULL")); + errorNames.insert(std::make_pair(50, "ERROR_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(51, "ERROR_REM_NOT_LIST")); + errorNames.insert(std::make_pair(52, "ERROR_DUP_NAME")); + errorNames.insert(std::make_pair(53, "ERROR_BAD_NETPATH")); + errorNames.insert(std::make_pair(54, "ERROR_NETWORK_BUSY")); + errorNames.insert(std::make_pair(55, "ERROR_DEV_NOT_EXIST")); + errorNames.insert(std::make_pair(56, "ERROR_TOO_MANY_CMDS")); + errorNames.insert(std::make_pair(57, "ERROR_ADAP_HDW_ERR")); + errorNames.insert(std::make_pair(58, "ERROR_BAD_NET_RESP")); + errorNames.insert(std::make_pair(59, "ERROR_UNEXP_NET_ERR")); + errorNames.insert(std::make_pair(60, "ERROR_BAD_REM_ADAP")); + errorNames.insert(std::make_pair(61, "ERROR_PRINTQ_FULL")); + errorNames.insert(std::make_pair(62, "ERROR_NO_SPOOL_SPACE")); + errorNames.insert(std::make_pair(63, "ERROR_PRINT_CANCELLED")); + errorNames.insert(std::make_pair(64, "ERROR_NETNAME_DELETED")); + errorNames.insert(std::make_pair(65, "ERROR_NETWORK_ACCESS_DENIED")); + errorNames.insert(std::make_pair(66, "ERROR_BAD_DEV_TYPE")); + errorNames.insert(std::make_pair(67, "ERROR_BAD_NET_NAME")); + errorNames.insert(std::make_pair(68, "ERROR_TOO_MANY_NAMES")); + errorNames.insert(std::make_pair(69, "ERROR_TOO_MANY_SESS")); + errorNames.insert(std::make_pair(70, "ERROR_SHARING_PAUSED")); + errorNames.insert(std::make_pair(71, "ERROR_REQ_NOT_ACCEP")); + errorNames.insert(std::make_pair(72, "ERROR_REDIR_PAUSED")); + errorNames.insert(std::make_pair(80, "ERROR_FILE_EXISTS")); + errorNames.insert(std::make_pair(82, "ERROR_CANNOT_MAKE")); + errorNames.insert(std::make_pair(83, "ERROR_FAIL_I24")); + errorNames.insert(std::make_pair(84, "ERROR_OUT_OF_STRUCTURES")); + errorNames.insert(std::make_pair(85, "ERROR_ALREADY_ASSIGNED")); + errorNames.insert(std::make_pair(86, "ERROR_INVALID_PASSWORD")); + errorNames.insert(std::make_pair(87, "ERROR_INVALID_PARAMETER")); + errorNames.insert(std::make_pair(88, "ERROR_NET_WRITE_FAULT")); + errorNames.insert(std::make_pair(89, "ERROR_NO_PROC_SLOTS")); + errorNames.insert(std::make_pair(100, "ERROR_TOO_MANY_SEMAPHORES")); + errorNames.insert(std::make_pair(101, "ERROR_EXCL_SEM_ALREADY_OWNED")); + errorNames.insert(std::make_pair(102, "ERROR_SEM_IS_SET")); + errorNames.insert(std::make_pair(103, "ERROR_TOO_MANY_SEM_REQUESTS")); + errorNames.insert(std::make_pair(104, "ERROR_INVALID_AT_INTERRUPT_TIME")); + errorNames.insert(std::make_pair(105, "ERROR_SEM_OWNER_DIED")); + errorNames.insert(std::make_pair(106, "ERROR_SEM_USER_LIMIT")); + errorNames.insert(std::make_pair(107, "ERROR_DISK_CHANGE")); + errorNames.insert(std::make_pair(108, "ERROR_DRIVE_LOCKED")); + errorNames.insert(std::make_pair(109, "ERROR_BROKEN_PIPE")); + errorNames.insert(std::make_pair(110, "ERROR_OPEN_FAILED")); + errorNames.insert(std::make_pair(111, "ERROR_BUFFER_OVERFLOW")); + errorNames.insert(std::make_pair(112, "ERROR_DISK_FULL")); + errorNames.insert(std::make_pair(113, "ERROR_NO_MORE_SEARCH_HANDLES")); + errorNames.insert(std::make_pair(114, "ERROR_INVALID_TARGET_HANDLE")); + errorNames.insert(std::make_pair(117, "ERROR_INVALID_CATEGORY")); + errorNames.insert(std::make_pair(118, "ERROR_INVALID_VERIFY_SWITCH")); + errorNames.insert(std::make_pair(119, "ERROR_BAD_DRIVER_LEVEL")); + errorNames.insert(std::make_pair(120, "ERROR_CALL_NOT_IMPLEMENTED")); + errorNames.insert(std::make_pair(121, "ERROR_SEM_TIMEOUT")); + errorNames.insert(std::make_pair(122, "ERROR_INSUFFICIENT_BUFFER")); + errorNames.insert(std::make_pair(123, "ERROR_INVALID_NAME")); + errorNames.insert(std::make_pair(124, "ERROR_INVALID_LEVEL")); + errorNames.insert(std::make_pair(125, "ERROR_NO_VOLUME_LABEL")); + errorNames.insert(std::make_pair(126, "ERROR_MOD_NOT_FOUND")); + errorNames.insert(std::make_pair(127, "ERROR_PROC_NOT_FOUND")); + errorNames.insert(std::make_pair(128, "ERROR_WAIT_NO_CHILDREN")); + errorNames.insert(std::make_pair(129, "ERROR_CHILD_NOT_COMPLETE")); + errorNames.insert(std::make_pair(130, "ERROR_DIRECT_ACCESS_HANDLE")); + errorNames.insert(std::make_pair(131, "ERROR_NEGATIVE_SEEK")); + errorNames.insert(std::make_pair(132, "ERROR_SEEK_ON_DEVICE")); + errorNames.insert(std::make_pair(133, "ERROR_IS_JOIN_TARGET")); + errorNames.insert(std::make_pair(134, "ERROR_IS_JOINED")); + errorNames.insert(std::make_pair(135, "ERROR_IS_SUBSTED")); + errorNames.insert(std::make_pair(136, "ERROR_NOT_JOINED")); + errorNames.insert(std::make_pair(137, "ERROR_NOT_SUBSTED")); + errorNames.insert(std::make_pair(138, "ERROR_JOIN_TO_JOIN")); + errorNames.insert(std::make_pair(139, "ERROR_SUBST_TO_SUBST")); + errorNames.insert(std::make_pair(140, "ERROR_JOIN_TO_SUBST")); + errorNames.insert(std::make_pair(141, "ERROR_SUBST_TO_JOIN")); + errorNames.insert(std::make_pair(142, "ERROR_BUSY_DRIVE")); + errorNames.insert(std::make_pair(143, "ERROR_SAME_DRIVE")); + errorNames.insert(std::make_pair(144, "ERROR_DIR_NOT_ROOT")); + errorNames.insert(std::make_pair(145, "ERROR_DIR_NOT_EMPTY")); + errorNames.insert(std::make_pair(146, "ERROR_IS_SUBST_PATH")); + errorNames.insert(std::make_pair(147, "ERROR_IS_JOIN_PATH")); + errorNames.insert(std::make_pair(148, "ERROR_PATH_BUSY")); + errorNames.insert(std::make_pair(149, "ERROR_IS_SUBST_TARGET")); + errorNames.insert(std::make_pair(150, "ERROR_SYSTEM_TRACE")); + errorNames.insert(std::make_pair(151, "ERROR_INVALID_EVENT_COUNT")); + errorNames.insert(std::make_pair(152, "ERROR_TOO_MANY_MUXWAITERS")); + errorNames.insert(std::make_pair(153, "ERROR_INVALID_LIST_FORMAT")); + errorNames.insert(std::make_pair(154, "ERROR_LABEL_TOO_LONG")); + errorNames.insert(std::make_pair(155, "ERROR_TOO_MANY_TCBS")); + errorNames.insert(std::make_pair(156, "ERROR_SIGNAL_REFUSED")); + errorNames.insert(std::make_pair(157, "ERROR_DISCARDED")); + errorNames.insert(std::make_pair(158, "ERROR_NOT_LOCKED")); + errorNames.insert(std::make_pair(159, "ERROR_BAD_THREADID_ADDR")); + errorNames.insert(std::make_pair(160, "ERROR_BAD_ARGUMENTS")); + errorNames.insert(std::make_pair(161, "ERROR_BAD_PATHNAME")); + errorNames.insert(std::make_pair(162, "ERROR_SIGNAL_PENDING")); + errorNames.insert(std::make_pair(164, "ERROR_MAX_THRDS_REACHED")); + errorNames.insert(std::make_pair(167, "ERROR_LOCK_FAILED")); + errorNames.insert(std::make_pair(170, "ERROR_BUSY")); + errorNames.insert(std::make_pair(173, "ERROR_CANCEL_VIOLATION")); + errorNames.insert(std::make_pair(174, "ERROR_ATOMIC_LOCKS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(180, "ERROR_INVALID_SEGMENT_NUMBER")); + errorNames.insert(std::make_pair(182, "ERROR_INVALID_ORDINAL")); + errorNames.insert(std::make_pair(183, "ERROR_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(186, "ERROR_INVALID_FLAG_NUMBER")); + errorNames.insert(std::make_pair(187, "ERROR_SEM_NOT_FOUND")); + errorNames.insert(std::make_pair(188, "ERROR_INVALID_STARTING_CODESEG")); + errorNames.insert(std::make_pair(189, "ERROR_INVALID_STACKSEG")); + errorNames.insert(std::make_pair(190, "ERROR_INVALID_MODULETYPE")); + errorNames.insert(std::make_pair(191, "ERROR_INVALID_EXE_SIGNATURE")); + errorNames.insert(std::make_pair(192, "ERROR_EXE_MARKED_INVALID")); + errorNames.insert(std::make_pair(193, "ERROR_BAD_EXE_FORMAT")); + errorNames.insert(std::make_pair(194, "ERROR_ITERATED_DATA_EXCEEDS_64k")); + errorNames.insert(std::make_pair(195, "ERROR_INVALID_MINALLOCSIZE")); + errorNames.insert(std::make_pair(196, "ERROR_DYNLINK_FROM_INVALID_RING")); + errorNames.insert(std::make_pair(197, "ERROR_IOPL_NOT_ENABLED")); + errorNames.insert(std::make_pair(198, "ERROR_INVALID_SEGDPL")); + errorNames.insert(std::make_pair(199, "ERROR_AUTODATASEG_EXCEEDS_64k")); + errorNames.insert(std::make_pair(200, "ERROR_RING2SEG_MUST_BE_MOVABLE")); + errorNames.insert(std::make_pair(201, "ERROR_RELOC_CHAIN_XEEDS_SEGLIM")); + errorNames.insert(std::make_pair(202, "ERROR_INFLOOP_IN_RELOC_CHAIN")); + errorNames.insert(std::make_pair(203, "ERROR_ENVVAR_NOT_FOUND")); + errorNames.insert(std::make_pair(205, "ERROR_NO_SIGNAL_SENT")); + errorNames.insert(std::make_pair(206, "ERROR_FILENAME_EXCED_RANGE")); + errorNames.insert(std::make_pair(207, "ERROR_RING2_STACK_IN_USE")); + errorNames.insert(std::make_pair(208, "ERROR_META_EXPANSION_TOO_LONG")); + errorNames.insert(std::make_pair(209, "ERROR_INVALID_SIGNAL_NUMBER")); + errorNames.insert(std::make_pair(210, "ERROR_THREAD_1_INACTIVE")); + errorNames.insert(std::make_pair(212, "ERROR_LOCKED")); + errorNames.insert(std::make_pair(214, "ERROR_TOO_MANY_MODULES")); + errorNames.insert(std::make_pair(215, "ERROR_NESTING_NOT_ALLOWED")); + errorNames.insert(std::make_pair(216, "ERROR_EXE_MACHINE_TYPE_MISMATCH")); + errorNames.insert(std::make_pair(217, "ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY")); + errorNames.insert(std::make_pair(218, "ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY")); + errorNames.insert(std::make_pair(220, "ERROR_FILE_CHECKED_OUT")); + errorNames.insert(std::make_pair(221, "ERROR_CHECKOUT_REQUIRED")); + errorNames.insert(std::make_pair(222, "ERROR_BAD_FILE_TYPE")); + errorNames.insert(std::make_pair(223, "ERROR_FILE_TOO_LARGE")); + errorNames.insert(std::make_pair(224, "ERROR_FORMS_AUTH_REQUIRED")); + errorNames.insert(std::make_pair(225, "ERROR_VIRUS_INFECTED")); + errorNames.insert(std::make_pair(226, "ERROR_VIRUS_DELETED")); + errorNames.insert(std::make_pair(229, "ERROR_PIPE_LOCAL")); + errorNames.insert(std::make_pair(230, "ERROR_BAD_PIPE")); + errorNames.insert(std::make_pair(231, "ERROR_PIPE_BUSY")); + errorNames.insert(std::make_pair(232, "ERROR_NO_DATA")); + errorNames.insert(std::make_pair(233, "ERROR_PIPE_NOT_CONNECTED")); + errorNames.insert(std::make_pair(234, "ERROR_MORE_DATA")); + errorNames.insert(std::make_pair(240, "ERROR_VC_DISCONNECTED")); + errorNames.insert(std::make_pair(254, "ERROR_INVALID_EA_NAME")); + errorNames.insert(std::make_pair(255, "ERROR_EA_LIST_INCONSISTENT")); + errorNames.insert(std::make_pair(259, "ERROR_NO_MORE_ITEMS")); + errorNames.insert(std::make_pair(266, "ERROR_CANNOT_COPY")); + errorNames.insert(std::make_pair(267, "ERROR_DIRECTORY")); + errorNames.insert(std::make_pair(275, "ERROR_EAS_DIDNT_FIT")); + errorNames.insert(std::make_pair(276, "ERROR_EA_FILE_CORRUPT")); + errorNames.insert(std::make_pair(277, "ERROR_EA_TABLE_FULL")); + errorNames.insert(std::make_pair(278, "ERROR_INVALID_EA_HANDLE")); + errorNames.insert(std::make_pair(282, "ERROR_EAS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(288, "ERROR_NOT_OWNER")); + errorNames.insert(std::make_pair(298, "ERROR_TOO_MANY_POSTS")); + errorNames.insert(std::make_pair(299, "ERROR_PARTIAL_COPY")); + errorNames.insert(std::make_pair(300, "ERROR_OPLOCK_NOT_GRANTED")); + errorNames.insert(std::make_pair(301, "ERROR_INVALID_OPLOCK_PROTOCOL")); + errorNames.insert(std::make_pair(302, "ERROR_DISK_TOO_FRAGMENTED")); + errorNames.insert(std::make_pair(303, "ERROR_DELETE_PENDING")); + errorNames.insert(std::make_pair(304, "ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING")); + errorNames.insert(std::make_pair(305, "ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME")); + errorNames.insert(std::make_pair(306, "ERROR_SECURITY_STREAM_IS_INCONSISTENT")); + errorNames.insert(std::make_pair(307, "ERROR_INVALID_LOCK_RANGE")); + errorNames.insert(std::make_pair(308, "ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT")); + errorNames.insert(std::make_pair(309, "ERROR_NOTIFICATION_GUID_ALREADY_DEFINED")); + errorNames.insert(std::make_pair(317, "ERROR_MR_MID_NOT_FOUND")); + errorNames.insert(std::make_pair(318, "ERROR_SCOPE_NOT_FOUND")); + errorNames.insert(std::make_pair(350, "ERROR_FAIL_NOACTION_REBOOT")); + errorNames.insert(std::make_pair(351, "ERROR_FAIL_SHUTDOWN")); + errorNames.insert(std::make_pair(352, "ERROR_FAIL_RESTART")); + errorNames.insert(std::make_pair(353, "ERROR_MAX_SESSIONS_REACHED")); + errorNames.insert(std::make_pair(400, "ERROR_THREAD_MODE_ALREADY_BACKGROUND")); + errorNames.insert(std::make_pair(401, "ERROR_THREAD_MODE_NOT_BACKGROUND")); + errorNames.insert(std::make_pair(402, "ERROR_PROCESS_MODE_ALREADY_BACKGROUND")); + errorNames.insert(std::make_pair(403, "ERROR_PROCESS_MODE_NOT_BACKGROUND")); + errorNames.insert(std::make_pair(487, "ERROR_INVALID_ADDRESS")); + errorNames.insert(std::make_pair(500, "ERROR_USER_PROFILE_LOAD")); + errorNames.insert(std::make_pair(534, "ERROR_ARITHMETIC_OVERFLOW")); + errorNames.insert(std::make_pair(535, "ERROR_PIPE_CONNECTED")); + errorNames.insert(std::make_pair(536, "ERROR_PIPE_LISTENING")); + errorNames.insert(std::make_pair(537, "ERROR_VERIFIER_STOP")); + errorNames.insert(std::make_pair(538, "ERROR_ABIOS_ERROR")); + errorNames.insert(std::make_pair(539, "ERROR_WX86_WARNING")); + errorNames.insert(std::make_pair(540, "ERROR_WX86_ERROR")); + errorNames.insert(std::make_pair(541, "ERROR_TIMER_NOT_CANCELED")); + errorNames.insert(std::make_pair(542, "ERROR_UNWIND")); + errorNames.insert(std::make_pair(543, "ERROR_BAD_STACK")); + errorNames.insert(std::make_pair(544, "ERROR_INVALID_UNWIND_TARGET")); + errorNames.insert(std::make_pair(545, "ERROR_INVALID_PORT_ATTRIBUTES")); + errorNames.insert(std::make_pair(546, "ERROR_PORT_MESSAGE_TOO_LONG")); + errorNames.insert(std::make_pair(547, "ERROR_INVALID_QUOTA_LOWER")); + errorNames.insert(std::make_pair(548, "ERROR_DEVICE_ALREADY_ATTACHED")); + errorNames.insert(std::make_pair(549, "ERROR_INSTRUCTION_MISALIGNMENT")); + errorNames.insert(std::make_pair(550, "ERROR_PROFILING_NOT_STARTED")); + errorNames.insert(std::make_pair(551, "ERROR_PROFILING_NOT_STOPPED")); + errorNames.insert(std::make_pair(552, "ERROR_COULD_NOT_INTERPRET")); + errorNames.insert(std::make_pair(553, "ERROR_PROFILING_AT_LIMIT")); + errorNames.insert(std::make_pair(554, "ERROR_CANT_WAIT")); + errorNames.insert(std::make_pair(555, "ERROR_CANT_TERMINATE_SELF")); + errorNames.insert(std::make_pair(556, "ERROR_UNEXPECTED_MM_CREATE_ERR")); + errorNames.insert(std::make_pair(557, "ERROR_UNEXPECTED_MM_MAP_ERROR")); + errorNames.insert(std::make_pair(558, "ERROR_UNEXPECTED_MM_EXTEND_ERR")); + errorNames.insert(std::make_pair(559, "ERROR_BAD_FUNCTION_TABLE")); + errorNames.insert(std::make_pair(560, "ERROR_NO_GUID_TRANSLATION")); + errorNames.insert(std::make_pair(561, "ERROR_INVALID_LDT_SIZE")); + errorNames.insert(std::make_pair(563, "ERROR_INVALID_LDT_OFFSET")); + errorNames.insert(std::make_pair(564, "ERROR_INVALID_LDT_DESCRIPTOR")); + errorNames.insert(std::make_pair(565, "ERROR_TOO_MANY_THREADS")); + errorNames.insert(std::make_pair(566, "ERROR_THREAD_NOT_IN_PROCESS")); + errorNames.insert(std::make_pair(567, "ERROR_PAGEFILE_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(568, "ERROR_LOGON_SERVER_CONFLICT")); + errorNames.insert(std::make_pair(569, "ERROR_SYNCHRONIZATION_REQUIRED")); + errorNames.insert(std::make_pair(570, "ERROR_NET_OPEN_FAILED")); + errorNames.insert(std::make_pair(571, "ERROR_IO_PRIVILEGE_FAILED")); + errorNames.insert(std::make_pair(572, "ERROR_CONTROL_C_EXIT")); + errorNames.insert(std::make_pair(573, "ERROR_MISSING_SYSTEMFILE")); + errorNames.insert(std::make_pair(574, "ERROR_UNHANDLED_EXCEPTION")); + errorNames.insert(std::make_pair(575, "ERROR_APP_INIT_FAILURE")); + errorNames.insert(std::make_pair(576, "ERROR_PAGEFILE_CREATE_FAILED")); + errorNames.insert(std::make_pair(577, "ERROR_INVALID_IMAGE_HASH")); + errorNames.insert(std::make_pair(578, "ERROR_NO_PAGEFILE")); + errorNames.insert(std::make_pair(579, "ERROR_ILLEGAL_FLOAT_CONTEXT")); + errorNames.insert(std::make_pair(580, "ERROR_NO_EVENT_PAIR")); + errorNames.insert(std::make_pair(581, "ERROR_DOMAIN_CTRLR_CONFIG_ERROR")); + errorNames.insert(std::make_pair(582, "ERROR_ILLEGAL_CHARACTER")); + errorNames.insert(std::make_pair(583, "ERROR_UNDEFINED_CHARACTER")); + errorNames.insert(std::make_pair(584, "ERROR_FLOPPY_VOLUME")); + errorNames.insert(std::make_pair(585, "ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT")); + errorNames.insert(std::make_pair(586, "ERROR_BACKUP_CONTROLLER")); + errorNames.insert(std::make_pair(587, "ERROR_MUTANT_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(588, "ERROR_FS_DRIVER_REQUIRED")); + errorNames.insert(std::make_pair(589, "ERROR_CANNOT_LOAD_REGISTRY_FILE")); + errorNames.insert(std::make_pair(590, "ERROR_DEBUG_ATTACH_FAILED")); + errorNames.insert(std::make_pair(591, "ERROR_SYSTEM_PROCESS_TERMINATED")); + errorNames.insert(std::make_pair(592, "ERROR_DATA_NOT_ACCEPTED")); + errorNames.insert(std::make_pair(593, "ERROR_VDM_HARD_ERROR")); + errorNames.insert(std::make_pair(594, "ERROR_DRIVER_CANCEL_TIMEOUT")); + errorNames.insert(std::make_pair(595, "ERROR_REPLY_MESSAGE_MISMATCH")); + errorNames.insert(std::make_pair(596, "ERROR_LOST_WRITEBEHIND_DATA")); + errorNames.insert(std::make_pair(597, "ERROR_CLIENT_SERVER_PARAMETERS_INVALID")); + errorNames.insert(std::make_pair(598, "ERROR_NOT_TINY_STREAM")); + errorNames.insert(std::make_pair(599, "ERROR_STACK_OVERFLOW_READ")); + errorNames.insert(std::make_pair(600, "ERROR_CONVERT_TO_LARGE")); + errorNames.insert(std::make_pair(601, "ERROR_FOUND_OUT_OF_SCOPE")); + errorNames.insert(std::make_pair(602, "ERROR_ALLOCATE_BUCKET")); + errorNames.insert(std::make_pair(603, "ERROR_MARSHALL_OVERFLOW")); + errorNames.insert(std::make_pair(604, "ERROR_INVALID_VARIANT")); + errorNames.insert(std::make_pair(605, "ERROR_BAD_COMPRESSION_BUFFER")); + errorNames.insert(std::make_pair(606, "ERROR_AUDIT_FAILED")); + errorNames.insert(std::make_pair(607, "ERROR_TIMER_RESOLUTION_NOT_SET")); + errorNames.insert(std::make_pair(608, "ERROR_INSUFFICIENT_LOGON_INFO")); + errorNames.insert(std::make_pair(609, "ERROR_BAD_DLL_ENTRYPOINT")); + errorNames.insert(std::make_pair(610, "ERROR_BAD_SERVICE_ENTRYPOINT")); + errorNames.insert(std::make_pair(611, "ERROR_IP_ADDRESS_CONFLICT1")); + errorNames.insert(std::make_pair(612, "ERROR_IP_ADDRESS_CONFLICT2")); + errorNames.insert(std::make_pair(613, "ERROR_REGISTRY_QUOTA_LIMIT")); + errorNames.insert(std::make_pair(614, "ERROR_NO_CALLBACK_ACTIVE")); + errorNames.insert(std::make_pair(615, "ERROR_PWD_TOO_SHORT")); + errorNames.insert(std::make_pair(616, "ERROR_PWD_TOO_RECENT")); + errorNames.insert(std::make_pair(617, "ERROR_PWD_HISTORY_CONFLICT")); + errorNames.insert(std::make_pair(618, "ERROR_UNSUPPORTED_COMPRESSION")); + errorNames.insert(std::make_pair(619, "ERROR_INVALID_HW_PROFILE")); + errorNames.insert(std::make_pair(620, "ERROR_INVALID_PLUGPLAY_DEVICE_PATH")); + errorNames.insert(std::make_pair(621, "ERROR_QUOTA_LIST_INCONSISTENT")); + errorNames.insert(std::make_pair(622, "ERROR_EVALUATION_EXPIRATION")); + errorNames.insert(std::make_pair(623, "ERROR_ILLEGAL_DLL_RELOCATION")); + errorNames.insert(std::make_pair(624, "ERROR_DLL_INIT_FAILED_LOGOFF")); + errorNames.insert(std::make_pair(625, "ERROR_VALIDATE_CONTINUE")); + errorNames.insert(std::make_pair(626, "ERROR_NO_MORE_MATCHES")); + errorNames.insert(std::make_pair(627, "ERROR_RANGE_LIST_CONFLICT")); + errorNames.insert(std::make_pair(628, "ERROR_SERVER_SID_MISMATCH")); + errorNames.insert(std::make_pair(629, "ERROR_CANT_ENABLE_DENY_ONLY")); + errorNames.insert(std::make_pair(630, "ERROR_FLOAT_MULTIPLE_FAULTS")); + errorNames.insert(std::make_pair(631, "ERROR_FLOAT_MULTIPLE_TRAPS")); + errorNames.insert(std::make_pair(632, "ERROR_NOINTERFACE")); + errorNames.insert(std::make_pair(633, "ERROR_DRIVER_FAILED_SLEEP")); + errorNames.insert(std::make_pair(634, "ERROR_CORRUPT_SYSTEM_FILE")); + errorNames.insert(std::make_pair(635, "ERROR_COMMITMENT_MINIMUM")); + errorNames.insert(std::make_pair(636, "ERROR_PNP_RESTART_ENUMERATION")); + errorNames.insert(std::make_pair(637, "ERROR_SYSTEM_IMAGE_BAD_SIGNATURE")); + errorNames.insert(std::make_pair(638, "ERROR_PNP_REBOOT_REQUIRED")); + errorNames.insert(std::make_pair(639, "ERROR_INSUFFICIENT_POWER")); + errorNames.insert(std::make_pair(640, "ERROR_MULTIPLE_FAULT_VIOLATION")); + errorNames.insert(std::make_pair(641, "ERROR_SYSTEM_SHUTDOWN")); + errorNames.insert(std::make_pair(642, "ERROR_PORT_NOT_SET")); + errorNames.insert(std::make_pair(643, "ERROR_DS_VERSION_CHECK_FAILURE")); + errorNames.insert(std::make_pair(644, "ERROR_RANGE_NOT_FOUND")); + errorNames.insert(std::make_pair(646, "ERROR_NOT_SAFE_MODE_DRIVER")); + errorNames.insert(std::make_pair(647, "ERROR_FAILED_DRIVER_ENTRY")); + errorNames.insert(std::make_pair(648, "ERROR_DEVICE_ENUMERATION_ERROR")); + errorNames.insert(std::make_pair(649, "ERROR_MOUNT_POINT_NOT_RESOLVED")); + errorNames.insert(std::make_pair(650, "ERROR_INVALID_DEVICE_OBJECT_PARAMETER")); + errorNames.insert(std::make_pair(651, "ERROR_MCA_OCCURED")); + errorNames.insert(std::make_pair(652, "ERROR_DRIVER_DATABASE_ERROR")); + errorNames.insert(std::make_pair(653, "ERROR_SYSTEM_HIVE_TOO_LARGE")); + errorNames.insert(std::make_pair(654, "ERROR_DRIVER_FAILED_PRIOR_UNLOAD")); + errorNames.insert(std::make_pair(655, "ERROR_VOLSNAP_PREPARE_HIBERNATE")); + errorNames.insert(std::make_pair(656, "ERROR_HIBERNATION_FAILURE")); + errorNames.insert(std::make_pair(665, "ERROR_FILE_SYSTEM_LIMITATION")); + errorNames.insert(std::make_pair(668, "ERROR_ASSERTION_FAILURE")); + errorNames.insert(std::make_pair(669, "ERROR_ACPI_ERROR")); + errorNames.insert(std::make_pair(670, "ERROR_WOW_ASSERTION")); + errorNames.insert(std::make_pair(671, "ERROR_PNP_BAD_MPS_TABLE")); + errorNames.insert(std::make_pair(672, "ERROR_PNP_TRANSLATION_FAILED")); + errorNames.insert(std::make_pair(673, "ERROR_PNP_IRQ_TRANSLATION_FAILED")); + errorNames.insert(std::make_pair(674, "ERROR_PNP_INVALID_ID")); + errorNames.insert(std::make_pair(675, "ERROR_WAKE_SYSTEM_DEBUGGER")); + errorNames.insert(std::make_pair(676, "ERROR_HANDLES_CLOSED")); + errorNames.insert(std::make_pair(677, "ERROR_EXTRANEOUS_INFORMATION")); + errorNames.insert(std::make_pair(678, "ERROR_RXACT_COMMIT_NECESSARY")); + errorNames.insert(std::make_pair(679, "ERROR_MEDIA_CHECK")); + errorNames.insert(std::make_pair(680, "ERROR_GUID_SUBSTITUTION_MADE")); + errorNames.insert(std::make_pair(681, "ERROR_STOPPED_ON_SYMLINK")); + errorNames.insert(std::make_pair(682, "ERROR_LONGJUMP")); + errorNames.insert(std::make_pair(683, "ERROR_PLUGPLAY_QUERY_VETOED")); + errorNames.insert(std::make_pair(684, "ERROR_UNWIND_CONSOLIDATE")); + errorNames.insert(std::make_pair(685, "ERROR_REGISTRY_HIVE_RECOVERED")); + errorNames.insert(std::make_pair(686, "ERROR_DLL_MIGHT_BE_INSECURE")); + errorNames.insert(std::make_pair(687, "ERROR_DLL_MIGHT_BE_INCOMPATIBLE")); + errorNames.insert(std::make_pair(688, "ERROR_DBG_EXCEPTION_NOT_HANDLED")); + errorNames.insert(std::make_pair(689, "ERROR_DBG_REPLY_LATER")); + errorNames.insert(std::make_pair(690, "ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE")); + errorNames.insert(std::make_pair(691, "ERROR_DBG_TERMINATE_THREAD")); + errorNames.insert(std::make_pair(692, "ERROR_DBG_TERMINATE_PROCESS")); + errorNames.insert(std::make_pair(693, "ERROR_DBG_CONTROL_C")); + errorNames.insert(std::make_pair(694, "ERROR_DBG_PRINTEXCEPTION_C")); + errorNames.insert(std::make_pair(695, "ERROR_DBG_RIPEXCEPTION")); + errorNames.insert(std::make_pair(696, "ERROR_DBG_CONTROL_BREAK")); + errorNames.insert(std::make_pair(697, "ERROR_DBG_COMMAND_EXCEPTION")); + errorNames.insert(std::make_pair(698, "ERROR_OBJECT_NAME_EXISTS")); + errorNames.insert(std::make_pair(699, "ERROR_THREAD_WAS_SUSPENDED")); + errorNames.insert(std::make_pair(700, "ERROR_IMAGE_NOT_AT_BASE")); + errorNames.insert(std::make_pair(701, "ERROR_RXACT_STATE_CREATED")); + errorNames.insert(std::make_pair(702, "ERROR_SEGMENT_NOTIFICATION")); + errorNames.insert(std::make_pair(703, "ERROR_BAD_CURRENT_DIRECTORY")); + errorNames.insert(std::make_pair(704, "ERROR_FT_READ_RECOVERY_FROM_BACKUP")); + errorNames.insert(std::make_pair(705, "ERROR_FT_WRITE_RECOVERY")); + errorNames.insert(std::make_pair(706, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH")); + errorNames.insert(std::make_pair(707, "ERROR_RECEIVE_PARTIAL")); + errorNames.insert(std::make_pair(708, "ERROR_RECEIVE_EXPEDITED")); + errorNames.insert(std::make_pair(709, "ERROR_RECEIVE_PARTIAL_EXPEDITED")); + errorNames.insert(std::make_pair(710, "ERROR_EVENT_DONE")); + errorNames.insert(std::make_pair(711, "ERROR_EVENT_PENDING")); + errorNames.insert(std::make_pair(712, "ERROR_CHECKING_FILE_SYSTEM")); + errorNames.insert(std::make_pair(713, "ERROR_FATAL_APP_EXIT")); + errorNames.insert(std::make_pair(714, "ERROR_PREDEFINED_HANDLE")); + errorNames.insert(std::make_pair(715, "ERROR_WAS_UNLOCKED")); + errorNames.insert(std::make_pair(716, "ERROR_SERVICE_NOTIFICATION")); + errorNames.insert(std::make_pair(717, "ERROR_WAS_LOCKED")); + errorNames.insert(std::make_pair(718, "ERROR_LOG_HARD_ERROR")); + errorNames.insert(std::make_pair(719, "ERROR_ALREADY_WIN32")); + errorNames.insert(std::make_pair(720, "ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE")); + errorNames.insert(std::make_pair(721, "ERROR_NO_YIELD_PERFORMED")); + errorNames.insert(std::make_pair(722, "ERROR_TIMER_RESUME_IGNORED")); + errorNames.insert(std::make_pair(723, "ERROR_ARBITRATION_UNHANDLED")); + errorNames.insert(std::make_pair(724, "ERROR_CARDBUS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(725, "ERROR_MP_PROCESSOR_MISMATCH")); + errorNames.insert(std::make_pair(726, "ERROR_HIBERNATED")); + errorNames.insert(std::make_pair(727, "ERROR_RESUME_HIBERNATION")); + errorNames.insert(std::make_pair(728, "ERROR_FIRMWARE_UPDATED")); + errorNames.insert(std::make_pair(729, "ERROR_DRIVERS_LEAKING_LOCKED_PAGES")); + errorNames.insert(std::make_pair(730, "ERROR_WAKE_SYSTEM")); + errorNames.insert(std::make_pair(731, "ERROR_WAIT_1")); + errorNames.insert(std::make_pair(732, "ERROR_WAIT_2")); + errorNames.insert(std::make_pair(733, "ERROR_WAIT_3")); + errorNames.insert(std::make_pair(734, "ERROR_WAIT_63")); + errorNames.insert(std::make_pair(735, "ERROR_ABANDONED_WAIT_0")); + errorNames.insert(std::make_pair(736, "ERROR_ABANDONED_WAIT_63")); + errorNames.insert(std::make_pair(737, "ERROR_USER_APC")); + errorNames.insert(std::make_pair(738, "ERROR_KERNEL_APC")); + errorNames.insert(std::make_pair(739, "ERROR_ALERTED")); + errorNames.insert(std::make_pair(740, "ERROR_ELEVATION_REQUIRED")); + errorNames.insert(std::make_pair(741, "ERROR_REPARSE")); + errorNames.insert(std::make_pair(742, "ERROR_OPLOCK_BREAK_IN_PROGRESS")); + errorNames.insert(std::make_pair(743, "ERROR_VOLUME_MOUNTED")); + errorNames.insert(std::make_pair(744, "ERROR_RXACT_COMMITTED")); + errorNames.insert(std::make_pair(745, "ERROR_NOTIFY_CLEANUP")); + errorNames.insert(std::make_pair(746, "ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED")); + errorNames.insert(std::make_pair(747, "ERROR_PAGE_FAULT_TRANSITION")); + errorNames.insert(std::make_pair(748, "ERROR_PAGE_FAULT_DEMAND_ZERO")); + errorNames.insert(std::make_pair(749, "ERROR_PAGE_FAULT_COPY_ON_WRITE")); + errorNames.insert(std::make_pair(750, "ERROR_PAGE_FAULT_GUARD_PAGE")); + errorNames.insert(std::make_pair(751, "ERROR_PAGE_FAULT_PAGING_FILE")); + errorNames.insert(std::make_pair(752, "ERROR_CACHE_PAGE_LOCKED")); + errorNames.insert(std::make_pair(753, "ERROR_CRASH_DUMP")); + errorNames.insert(std::make_pair(754, "ERROR_BUFFER_ALL_ZEROS")); + errorNames.insert(std::make_pair(755, "ERROR_REPARSE_OBJECT")); + errorNames.insert(std::make_pair(756, "ERROR_RESOURCE_REQUIREMENTS_CHANGED")); + errorNames.insert(std::make_pair(757, "ERROR_TRANSLATION_COMPLETE")); + errorNames.insert(std::make_pair(758, "ERROR_NOTHING_TO_TERMINATE")); + errorNames.insert(std::make_pair(759, "ERROR_PROCESS_NOT_IN_JOB")); + errorNames.insert(std::make_pair(760, "ERROR_PROCESS_IN_JOB")); + errorNames.insert(std::make_pair(761, "ERROR_VOLSNAP_HIBERNATE_READY")); + errorNames.insert(std::make_pair(762, "ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY")); + errorNames.insert(std::make_pair(763, "ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED")); + errorNames.insert(std::make_pair(764, "ERROR_INTERRUPT_STILL_CONNECTED")); + errorNames.insert(std::make_pair(765, "ERROR_WAIT_FOR_OPLOCK")); + errorNames.insert(std::make_pair(766, "ERROR_DBG_EXCEPTION_HANDLED")); + errorNames.insert(std::make_pair(767, "ERROR_DBG_CONTINUE")); + errorNames.insert(std::make_pair(768, "ERROR_CALLBACK_POP_STACK")); + errorNames.insert(std::make_pair(769, "ERROR_COMPRESSION_DISABLED")); + errorNames.insert(std::make_pair(770, "ERROR_CANTFETCHBACKWARDS")); + errorNames.insert(std::make_pair(771, "ERROR_CANTSCROLLBACKWARDS")); + errorNames.insert(std::make_pair(772, "ERROR_ROWSNOTRELEASED")); + errorNames.insert(std::make_pair(773, "ERROR_BAD_ACCESSOR_FLAGS")); + errorNames.insert(std::make_pair(774, "ERROR_ERRORS_ENCOUNTERED")); + errorNames.insert(std::make_pair(775, "ERROR_NOT_CAPABLE")); + errorNames.insert(std::make_pair(776, "ERROR_REQUEST_OUT_OF_SEQUENCE")); + errorNames.insert(std::make_pair(777, "ERROR_VERSION_PARSE_ERROR")); + errorNames.insert(std::make_pair(778, "ERROR_BADSTARTPOSITION")); + errorNames.insert(std::make_pair(779, "ERROR_MEMORY_HARDWARE")); + errorNames.insert(std::make_pair(780, "ERROR_DISK_REPAIR_DISABLED")); + errorNames.insert(std::make_pair(781, "ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE")); + errorNames.insert(std::make_pair(782, "ERROR_SYSTEM_POWERSTATE_TRANSITION")); + errorNames.insert(std::make_pair(783, "ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION")); + errorNames.insert(std::make_pair(784, "ERROR_MCA_EXCEPTION")); + errorNames.insert(std::make_pair(785, "ERROR_ACCESS_AUDIT_BY_POLICY")); + errorNames.insert(std::make_pair(786, "ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY")); + errorNames.insert(std::make_pair(787, "ERROR_ABANDON_HIBERFILE")); + errorNames.insert(std::make_pair(788, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED")); + errorNames.insert(std::make_pair(789, "ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR")); + errorNames.insert(std::make_pair(790, "ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR")); + errorNames.insert(std::make_pair(791, "ERROR_BAD_MCFG_TABLE")); + errorNames.insert(std::make_pair(800, "ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE")); + errorNames.insert(std::make_pair(801, "ERROR_CANNOT_GRANT_REQUESTED_OPLOCK")); + errorNames.insert(std::make_pair(802, "ERROR_CANNOT_BREAK_OPLOCK")); + errorNames.insert(std::make_pair(803, "ERROR_OPLOCK_HANDLE_CLOSED")); + errorNames.insert(std::make_pair(804, "ERROR_NO_ACE_CONDITION")); + errorNames.insert(std::make_pair(805, "ERROR_INVALID_ACE_CONDITION")); + errorNames.insert(std::make_pair(994, "ERROR_EA_ACCESS_DENIED")); + errorNames.insert(std::make_pair(995, "ERROR_OPERATION_ABORTED")); + errorNames.insert(std::make_pair(996, "ERROR_IO_INCOMPLETE")); + errorNames.insert(std::make_pair(997, "ERROR_IO_PENDING")); + errorNames.insert(std::make_pair(998, "ERROR_NOACCESS")); + errorNames.insert(std::make_pair(999, "ERROR_SWAPERROR")); + errorNames.insert(std::make_pair(1001, "ERROR_STACK_OVERFLOW")); + errorNames.insert(std::make_pair(1002, "ERROR_INVALID_MESSAGE")); + errorNames.insert(std::make_pair(1003, "ERROR_CAN_NOT_COMPLETE")); + errorNames.insert(std::make_pair(1004, "ERROR_INVALID_FLAGS")); + errorNames.insert(std::make_pair(1005, "ERROR_UNRECOGNIZED_VOLUME")); + errorNames.insert(std::make_pair(1006, "ERROR_FILE_INVALID")); + errorNames.insert(std::make_pair(1007, "ERROR_FULLSCREEN_MODE")); + errorNames.insert(std::make_pair(1008, "ERROR_NO_TOKEN")); + errorNames.insert(std::make_pair(1009, "ERROR_BADDB")); + errorNames.insert(std::make_pair(1010, "ERROR_BADKEY")); + errorNames.insert(std::make_pair(1011, "ERROR_CANTOPEN")); + errorNames.insert(std::make_pair(1012, "ERROR_CANTREAD")); + errorNames.insert(std::make_pair(1013, "ERROR_CANTWRITE")); + errorNames.insert(std::make_pair(1014, "ERROR_REGISTRY_RECOVERED")); + errorNames.insert(std::make_pair(1015, "ERROR_REGISTRY_CORRUPT")); + errorNames.insert(std::make_pair(1016, "ERROR_REGISTRY_IO_FAILED")); + errorNames.insert(std::make_pair(1017, "ERROR_NOT_REGISTRY_FILE")); + errorNames.insert(std::make_pair(1018, "ERROR_KEY_DELETED")); + errorNames.insert(std::make_pair(1019, "ERROR_NO_LOG_SPACE")); + errorNames.insert(std::make_pair(1020, "ERROR_KEY_HAS_CHILDREN")); + errorNames.insert(std::make_pair(1021, "ERROR_CHILD_MUST_BE_VOLATILE")); + errorNames.insert(std::make_pair(1022, "ERROR_NOTIFY_ENUM_DIR")); + errorNames.insert(std::make_pair(1051, "ERROR_DEPENDENT_SERVICES_RUNNING")); + errorNames.insert(std::make_pair(1052, "ERROR_INVALID_SERVICE_CONTROL")); + errorNames.insert(std::make_pair(1053, "ERROR_SERVICE_REQUEST_TIMEOUT")); + errorNames.insert(std::make_pair(1054, "ERROR_SERVICE_NO_THREAD")); + errorNames.insert(std::make_pair(1055, "ERROR_SERVICE_DATABASE_LOCKED")); + errorNames.insert(std::make_pair(1056, "ERROR_SERVICE_ALREADY_RUNNING")); + errorNames.insert(std::make_pair(1057, "ERROR_INVALID_SERVICE_ACCOUNT")); + errorNames.insert(std::make_pair(1058, "ERROR_SERVICE_DISABLED")); + errorNames.insert(std::make_pair(1059, "ERROR_CIRCULAR_DEPENDENCY")); + errorNames.insert(std::make_pair(1060, "ERROR_SERVICE_DOES_NOT_EXIST")); + errorNames.insert(std::make_pair(1061, "ERROR_SERVICE_CANNOT_ACCEPT_CTRL")); + errorNames.insert(std::make_pair(1062, "ERROR_SERVICE_NOT_ACTIVE")); + errorNames.insert(std::make_pair(1063, "ERROR_FAILED_SERVICE_CONTROLLER_CONNECT")); + errorNames.insert(std::make_pair(1064, "ERROR_EXCEPTION_IN_SERVICE")); + errorNames.insert(std::make_pair(1065, "ERROR_DATABASE_DOES_NOT_EXIST")); + errorNames.insert(std::make_pair(1066, "ERROR_SERVICE_SPECIFIC_ERROR")); + errorNames.insert(std::make_pair(1067, "ERROR_PROCESS_ABORTED")); + errorNames.insert(std::make_pair(1068, "ERROR_SERVICE_DEPENDENCY_FAIL")); + errorNames.insert(std::make_pair(1069, "ERROR_SERVICE_LOGON_FAILED")); + errorNames.insert(std::make_pair(1070, "ERROR_SERVICE_START_HANG")); + errorNames.insert(std::make_pair(1071, "ERROR_INVALID_SERVICE_LOCK")); + errorNames.insert(std::make_pair(1072, "ERROR_SERVICE_MARKED_FOR_DELETE")); + errorNames.insert(std::make_pair(1073, "ERROR_SERVICE_EXISTS")); + errorNames.insert(std::make_pair(1074, "ERROR_ALREADY_RUNNING_LKG")); + errorNames.insert(std::make_pair(1075, "ERROR_SERVICE_DEPENDENCY_DELETED")); + errorNames.insert(std::make_pair(1076, "ERROR_BOOT_ALREADY_ACCEPTED")); + errorNames.insert(std::make_pair(1077, "ERROR_SERVICE_NEVER_STARTED")); + errorNames.insert(std::make_pair(1078, "ERROR_DUPLICATE_SERVICE_NAME")); + errorNames.insert(std::make_pair(1079, "ERROR_DIFFERENT_SERVICE_ACCOUNT")); + errorNames.insert(std::make_pair(1080, "ERROR_CANNOT_DETECT_DRIVER_FAILURE")); + errorNames.insert(std::make_pair(1081, "ERROR_CANNOT_DETECT_PROCESS_ABORT")); + errorNames.insert(std::make_pair(1082, "ERROR_NO_RECOVERY_PROGRAM")); + errorNames.insert(std::make_pair(1083, "ERROR_SERVICE_NOT_IN_EXE")); + errorNames.insert(std::make_pair(1084, "ERROR_NOT_SAFEBOOT_SERVICE")); + errorNames.insert(std::make_pair(1100, "ERROR_END_OF_MEDIA")); + errorNames.insert(std::make_pair(1101, "ERROR_FILEMARK_DETECTED")); + errorNames.insert(std::make_pair(1102, "ERROR_BEGINNING_OF_MEDIA")); + errorNames.insert(std::make_pair(1103, "ERROR_SETMARK_DETECTED")); + errorNames.insert(std::make_pair(1104, "ERROR_NO_DATA_DETECTED")); + errorNames.insert(std::make_pair(1105, "ERROR_PARTITION_FAILURE")); + errorNames.insert(std::make_pair(1106, "ERROR_INVALID_BLOCK_LENGTH")); + errorNames.insert(std::make_pair(1107, "ERROR_DEVICE_NOT_PARTITIONED")); + errorNames.insert(std::make_pair(1108, "ERROR_UNABLE_TO_LOCK_MEDIA")); + errorNames.insert(std::make_pair(1109, "ERROR_UNABLE_TO_UNLOAD_MEDIA")); + errorNames.insert(std::make_pair(1110, "ERROR_MEDIA_CHANGED")); + errorNames.insert(std::make_pair(1111, "ERROR_BUS_RESET")); + errorNames.insert(std::make_pair(1112, "ERROR_NO_MEDIA_IN_DRIVE")); + errorNames.insert(std::make_pair(1113, "ERROR_NO_UNICODE_TRANSLATION")); + errorNames.insert(std::make_pair(1114, "ERROR_DLL_INIT_FAILED")); + errorNames.insert(std::make_pair(1115, "ERROR_SHUTDOWN_IN_PROGRESS")); + errorNames.insert(std::make_pair(1116, "ERROR_NO_SHUTDOWN_IN_PROGRESS")); + errorNames.insert(std::make_pair(1117, "ERROR_IO_DEVICE")); + errorNames.insert(std::make_pair(1118, "ERROR_SERIAL_NO_DEVICE")); + errorNames.insert(std::make_pair(1119, "ERROR_IRQ_BUSY")); + errorNames.insert(std::make_pair(1120, "ERROR_MORE_WRITES")); + errorNames.insert(std::make_pair(1121, "ERROR_COUNTER_TIMEOUT")); + errorNames.insert(std::make_pair(1122, "ERROR_FLOPPY_ID_MARK_NOT_FOUND")); + errorNames.insert(std::make_pair(1123, "ERROR_FLOPPY_WRONG_CYLINDER")); + errorNames.insert(std::make_pair(1124, "ERROR_FLOPPY_UNKNOWN_ERROR")); + errorNames.insert(std::make_pair(1125, "ERROR_FLOPPY_BAD_REGISTERS")); + errorNames.insert(std::make_pair(1126, "ERROR_DISK_RECALIBRATE_FAILED")); + errorNames.insert(std::make_pair(1127, "ERROR_DISK_OPERATION_FAILED")); + errorNames.insert(std::make_pair(1128, "ERROR_DISK_RESET_FAILED")); + errorNames.insert(std::make_pair(1129, "ERROR_EOM_OVERFLOW")); + errorNames.insert(std::make_pair(1130, "ERROR_NOT_ENOUGH_SERVER_MEMORY")); + errorNames.insert(std::make_pair(1131, "ERROR_POSSIBLE_DEADLOCK")); + errorNames.insert(std::make_pair(1132, "ERROR_MAPPED_ALIGNMENT")); + errorNames.insert(std::make_pair(1140, "ERROR_SET_POWER_STATE_VETOED")); + errorNames.insert(std::make_pair(1141, "ERROR_SET_POWER_STATE_FAILED")); + errorNames.insert(std::make_pair(1142, "ERROR_TOO_MANY_LINKS")); + errorNames.insert(std::make_pair(1150, "ERROR_OLD_WIN_VERSION")); + errorNames.insert(std::make_pair(1151, "ERROR_APP_WRONG_OS")); + errorNames.insert(std::make_pair(1152, "ERROR_SINGLE_INSTANCE_APP")); + errorNames.insert(std::make_pair(1153, "ERROR_RMODE_APP")); + errorNames.insert(std::make_pair(1154, "ERROR_INVALID_DLL")); + errorNames.insert(std::make_pair(1155, "ERROR_NO_ASSOCIATION")); + errorNames.insert(std::make_pair(1156, "ERROR_DDE_FAIL")); + errorNames.insert(std::make_pair(1157, "ERROR_DLL_NOT_FOUND")); + errorNames.insert(std::make_pair(1158, "ERROR_NO_MORE_USER_HANDLES")); + errorNames.insert(std::make_pair(1159, "ERROR_MESSAGE_SYNC_ONLY")); + errorNames.insert(std::make_pair(1160, "ERROR_SOURCE_ELEMENT_EMPTY")); + errorNames.insert(std::make_pair(1161, "ERROR_DESTINATION_ELEMENT_FULL")); + errorNames.insert(std::make_pair(1162, "ERROR_ILLEGAL_ELEMENT_ADDRESS")); + errorNames.insert(std::make_pair(1163, "ERROR_MAGAZINE_NOT_PRESENT")); + errorNames.insert(std::make_pair(1164, "ERROR_DEVICE_REINITIALIZATION_NEEDED")); + errorNames.insert(std::make_pair(1165, "ERROR_DEVICE_REQUIRES_CLEANING")); + errorNames.insert(std::make_pair(1166, "ERROR_DEVICE_DOOR_OPEN")); + errorNames.insert(std::make_pair(1167, "ERROR_DEVICE_NOT_CONNECTED")); + errorNames.insert(std::make_pair(1168, "ERROR_NOT_FOUND")); + errorNames.insert(std::make_pair(1169, "ERROR_NO_MATCH")); + errorNames.insert(std::make_pair(1170, "ERROR_SET_NOT_FOUND")); + errorNames.insert(std::make_pair(1171, "ERROR_POINT_NOT_FOUND")); + errorNames.insert(std::make_pair(1172, "ERROR_NO_TRACKING_SERVICE")); + errorNames.insert(std::make_pair(1173, "ERROR_NO_VOLUME_ID")); + errorNames.insert(std::make_pair(1175, "ERROR_UNABLE_TO_REMOVE_REPLACED")); + errorNames.insert(std::make_pair(1176, "ERROR_UNABLE_TO_MOVE_REPLACEMENT")); + errorNames.insert(std::make_pair(1177, "ERROR_UNABLE_TO_MOVE_REPLACEMENT_2")); + errorNames.insert(std::make_pair(1178, "ERROR_JOURNAL_DELETE_IN_PROGRESS")); + errorNames.insert(std::make_pair(1179, "ERROR_JOURNAL_NOT_ACTIVE")); + errorNames.insert(std::make_pair(1180, "ERROR_POTENTIAL_FILE_FOUND")); + errorNames.insert(std::make_pair(1181, "ERROR_JOURNAL_ENTRY_DELETED")); + errorNames.insert(std::make_pair(1190, "ERROR_SHUTDOWN_IS_SCHEDULED")); + errorNames.insert(std::make_pair(1191, "ERROR_SHUTDOWN_USERS_LOGGED_ON")); + errorNames.insert(std::make_pair(1200, "ERROR_BAD_DEVICE")); + errorNames.insert(std::make_pair(1201, "ERROR_CONNECTION_UNAVAIL")); + errorNames.insert(std::make_pair(1202, "ERROR_DEVICE_ALREADY_REMEMBERED")); + errorNames.insert(std::make_pair(1203, "ERROR_NO_NET_OR_BAD_PATH")); + errorNames.insert(std::make_pair(1204, "ERROR_BAD_PROVIDER")); + errorNames.insert(std::make_pair(1205, "ERROR_CANNOT_OPEN_PROFILE")); + errorNames.insert(std::make_pair(1206, "ERROR_BAD_PROFILE")); + errorNames.insert(std::make_pair(1207, "ERROR_NOT_CONTAINER")); + errorNames.insert(std::make_pair(1208, "ERROR_EXTENDED_ERROR")); + errorNames.insert(std::make_pair(1209, "ERROR_INVALID_GROUPNAME")); + errorNames.insert(std::make_pair(1210, "ERROR_INVALID_COMPUTERNAME")); + errorNames.insert(std::make_pair(1211, "ERROR_INVALID_EVENTNAME")); + errorNames.insert(std::make_pair(1212, "ERROR_INVALID_DOMAINNAME")); + errorNames.insert(std::make_pair(1213, "ERROR_INVALID_SERVICENAME")); + errorNames.insert(std::make_pair(1214, "ERROR_INVALID_NETNAME")); + errorNames.insert(std::make_pair(1215, "ERROR_INVALID_SHARENAME")); + errorNames.insert(std::make_pair(1216, "ERROR_INVALID_PASSWORDNAME")); + errorNames.insert(std::make_pair(1217, "ERROR_INVALID_MESSAGENAME")); + errorNames.insert(std::make_pair(1218, "ERROR_INVALID_MESSAGEDEST")); + errorNames.insert(std::make_pair(1219, "ERROR_SESSION_CREDENTIAL_CONFLICT")); + errorNames.insert(std::make_pair(1220, "ERROR_REMOTE_SESSION_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(1221, "ERROR_DUP_DOMAINNAME")); + errorNames.insert(std::make_pair(1222, "ERROR_NO_NETWORK")); + errorNames.insert(std::make_pair(1223, "ERROR_CANCELLED")); + errorNames.insert(std::make_pair(1224, "ERROR_USER_MAPPED_FILE")); + errorNames.insert(std::make_pair(1225, "ERROR_CONNECTION_REFUSED")); + errorNames.insert(std::make_pair(1226, "ERROR_GRACEFUL_DISCONNECT")); + errorNames.insert(std::make_pair(1227, "ERROR_ADDRESS_ALREADY_ASSOCIATED")); + errorNames.insert(std::make_pair(1228, "ERROR_ADDRESS_NOT_ASSOCIATED")); + errorNames.insert(std::make_pair(1229, "ERROR_CONNECTION_INVALID")); + errorNames.insert(std::make_pair(1230, "ERROR_CONNECTION_ACTIVE")); + errorNames.insert(std::make_pair(1231, "ERROR_NETWORK_UNREACHABLE")); + errorNames.insert(std::make_pair(1232, "ERROR_HOST_UNREACHABLE")); + errorNames.insert(std::make_pair(1233, "ERROR_PROTOCOL_UNREACHABLE")); + errorNames.insert(std::make_pair(1234, "ERROR_PORT_UNREACHABLE")); + errorNames.insert(std::make_pair(1235, "ERROR_REQUEST_ABORTED")); + errorNames.insert(std::make_pair(1236, "ERROR_CONNECTION_ABORTED")); + errorNames.insert(std::make_pair(1237, "ERROR_RETRY")); + errorNames.insert(std::make_pair(1238, "ERROR_CONNECTION_COUNT_LIMIT")); + errorNames.insert(std::make_pair(1239, "ERROR_LOGIN_TIME_RESTRICTION")); + errorNames.insert(std::make_pair(1240, "ERROR_LOGIN_WKSTA_RESTRICTION")); + errorNames.insert(std::make_pair(1241, "ERROR_INCORRECT_ADDRESS")); + errorNames.insert(std::make_pair(1242, "ERROR_ALREADY_REGISTERED")); + errorNames.insert(std::make_pair(1243, "ERROR_SERVICE_NOT_FOUND")); + errorNames.insert(std::make_pair(1244, "ERROR_NOT_AUTHENTICATED")); + errorNames.insert(std::make_pair(1245, "ERROR_NOT_LOGGED_ON")); + errorNames.insert(std::make_pair(1246, "ERROR_CONTINUE")); + errorNames.insert(std::make_pair(1247, "ERROR_ALREADY_INITIALIZED")); + errorNames.insert(std::make_pair(1248, "ERROR_NO_MORE_DEVICES")); + errorNames.insert(std::make_pair(1249, "ERROR_NO_SUCH_SITE")); + errorNames.insert(std::make_pair(1250, "ERROR_DOMAIN_CONTROLLER_EXISTS")); + errorNames.insert(std::make_pair(1251, "ERROR_ONLY_IF_CONNECTED")); + errorNames.insert(std::make_pair(1252, "ERROR_OVERRIDE_NOCHANGES")); + errorNames.insert(std::make_pair(1253, "ERROR_BAD_USER_PROFILE")); + errorNames.insert(std::make_pair(1254, "ERROR_NOT_SUPPORTED_ON_SBS")); + errorNames.insert(std::make_pair(1255, "ERROR_SERVER_SHUTDOWN_IN_PROGRESS")); + errorNames.insert(std::make_pair(1256, "ERROR_HOST_DOWN")); + errorNames.insert(std::make_pair(1257, "ERROR_NON_ACCOUNT_SID")); + errorNames.insert(std::make_pair(1258, "ERROR_NON_DOMAIN_SID")); + errorNames.insert(std::make_pair(1259, "ERROR_APPHELP_BLOCK")); + errorNames.insert(std::make_pair(1260, "ERROR_ACCESS_DISABLED_BY_POLICY")); + errorNames.insert(std::make_pair(1261, "ERROR_REG_NAT_CONSUMPTION")); + errorNames.insert(std::make_pair(1262, "ERROR_CSCSHARE_OFFLINE")); + errorNames.insert(std::make_pair(1263, "ERROR_PKINIT_FAILURE")); + errorNames.insert(std::make_pair(1264, "ERROR_SMARTCARD_SUBSYSTEM_FAILURE")); + errorNames.insert(std::make_pair(1265, "ERROR_DOWNGRADE_DETECTED")); + errorNames.insert(std::make_pair(1271, "ERROR_MACHINE_LOCKED")); + errorNames.insert(std::make_pair(1273, "ERROR_CALLBACK_SUPPLIED_INVALID_DATA")); + errorNames.insert(std::make_pair(1274, "ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED")); + errorNames.insert(std::make_pair(1275, "ERROR_DRIVER_BLOCKED")); + errorNames.insert(std::make_pair(1276, "ERROR_INVALID_IMPORT_OF_NON_DLL")); + errorNames.insert(std::make_pair(1277, "ERROR_ACCESS_DISABLED_WEBBLADE")); + errorNames.insert(std::make_pair(1278, "ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER")); + errorNames.insert(std::make_pair(1279, "ERROR_RECOVERY_FAILURE")); + errorNames.insert(std::make_pair(1280, "ERROR_ALREADY_FIBER")); + errorNames.insert(std::make_pair(1281, "ERROR_ALREADY_THREAD")); + errorNames.insert(std::make_pair(1282, "ERROR_STACK_BUFFER_OVERRUN")); + errorNames.insert(std::make_pair(1283, "ERROR_PARAMETER_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1284, "ERROR_DEBUGGER_INACTIVE")); + errorNames.insert(std::make_pair(1285, "ERROR_DELAY_LOAD_FAILED")); + errorNames.insert(std::make_pair(1286, "ERROR_VDM_DISALLOWED")); + errorNames.insert(std::make_pair(1287, "ERROR_UNIDENTIFIED_ERROR")); + errorNames.insert(std::make_pair(1288, "ERROR_INVALID_CRUNTIME_PARAMETER")); + errorNames.insert(std::make_pair(1289, "ERROR_BEYOND_VDL")); + errorNames.insert(std::make_pair(1290, "ERROR_INCOMPATIBLE_SERVICE_SID_TYPE")); + errorNames.insert(std::make_pair(1291, "ERROR_DRIVER_PROCESS_TERMINATED")); + errorNames.insert(std::make_pair(1292, "ERROR_IMPLEMENTATION_LIMIT")); + errorNames.insert(std::make_pair(1293, "ERROR_PROCESS_IS_PROTECTED")); + errorNames.insert(std::make_pair(1294, "ERROR_SERVICE_NOTIFY_CLIENT_LAGGING")); + errorNames.insert(std::make_pair(1295, "ERROR_DISK_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1296, "ERROR_CONTENT_BLOCKED")); + errorNames.insert(std::make_pair(1297, "ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE")); + errorNames.insert(std::make_pair(1298, "ERROR_APP_HANG")); + errorNames.insert(std::make_pair(1299, "ERROR_INVALID_LABEL")); + errorNames.insert(std::make_pair(1300, "ERROR_NOT_ALL_ASSIGNED")); + errorNames.insert(std::make_pair(1301, "ERROR_SOME_NOT_MAPPED")); + errorNames.insert(std::make_pair(1302, "ERROR_NO_QUOTAS_FOR_ACCOUNT")); + errorNames.insert(std::make_pair(1303, "ERROR_LOCAL_USER_SESSION_KEY")); + errorNames.insert(std::make_pair(1304, "ERROR_NULL_LM_PASSWORD")); + errorNames.insert(std::make_pair(1305, "ERROR_UNKNOWN_REVISION")); + errorNames.insert(std::make_pair(1306, "ERROR_REVISION_MISMATCH")); + errorNames.insert(std::make_pair(1307, "ERROR_INVALID_OWNER")); + errorNames.insert(std::make_pair(1308, "ERROR_INVALID_PRIMARY_GROUP")); + errorNames.insert(std::make_pair(1309, "ERROR_NO_IMPERSONATION_TOKEN")); + errorNames.insert(std::make_pair(1310, "ERROR_CANT_DISABLE_MANDATORY")); + errorNames.insert(std::make_pair(1311, "ERROR_NO_LOGON_SERVERS")); + errorNames.insert(std::make_pair(1312, "ERROR_NO_SUCH_LOGON_SESSION")); + errorNames.insert(std::make_pair(1313, "ERROR_NO_SUCH_PRIVILEGE")); + errorNames.insert(std::make_pair(1314, "ERROR_PRIVILEGE_NOT_HELD")); + errorNames.insert(std::make_pair(1315, "ERROR_INVALID_ACCOUNT_NAME")); + errorNames.insert(std::make_pair(1316, "ERROR_USER_EXISTS")); + errorNames.insert(std::make_pair(1317, "ERROR_NO_SUCH_USER")); + errorNames.insert(std::make_pair(1318, "ERROR_GROUP_EXISTS")); + errorNames.insert(std::make_pair(1319, "ERROR_NO_SUCH_GROUP")); + errorNames.insert(std::make_pair(1320, "ERROR_MEMBER_IN_GROUP")); + errorNames.insert(std::make_pair(1321, "ERROR_MEMBER_NOT_IN_GROUP")); + errorNames.insert(std::make_pair(1322, "ERROR_LAST_ADMIN")); + errorNames.insert(std::make_pair(1323, "ERROR_WRONG_PASSWORD")); + errorNames.insert(std::make_pair(1324, "ERROR_ILL_FORMED_PASSWORD")); + errorNames.insert(std::make_pair(1325, "ERROR_PASSWORD_RESTRICTION")); + errorNames.insert(std::make_pair(1326, "ERROR_LOGON_FAILURE")); + errorNames.insert(std::make_pair(1327, "ERROR_ACCOUNT_RESTRICTION")); + errorNames.insert(std::make_pair(1328, "ERROR_INVALID_LOGON_HOURS")); + errorNames.insert(std::make_pair(1329, "ERROR_INVALID_WORKSTATION")); + errorNames.insert(std::make_pair(1330, "ERROR_PASSWORD_EXPIRED")); + errorNames.insert(std::make_pair(1331, "ERROR_ACCOUNT_DISABLED")); + errorNames.insert(std::make_pair(1332, "ERROR_NONE_MAPPED")); + errorNames.insert(std::make_pair(1333, "ERROR_TOO_MANY_LUIDS_REQUESTED")); + errorNames.insert(std::make_pair(1334, "ERROR_LUIDS_EXHAUSTED")); + errorNames.insert(std::make_pair(1335, "ERROR_INVALID_SUB_AUTHORITY")); + errorNames.insert(std::make_pair(1336, "ERROR_INVALID_ACL")); + errorNames.insert(std::make_pair(1337, "ERROR_INVALID_SID")); + errorNames.insert(std::make_pair(1338, "ERROR_INVALID_SECURITY_DESCR")); + errorNames.insert(std::make_pair(1340, "ERROR_BAD_INHERITANCE_ACL")); + errorNames.insert(std::make_pair(1341, "ERROR_SERVER_DISABLED")); + errorNames.insert(std::make_pair(1342, "ERROR_SERVER_NOT_DISABLED")); + errorNames.insert(std::make_pair(1343, "ERROR_INVALID_ID_AUTHORITY")); + errorNames.insert(std::make_pair(1344, "ERROR_ALLOTTED_SPACE_EXCEEDED")); + errorNames.insert(std::make_pair(1345, "ERROR_INVALID_GROUP_ATTRIBUTES")); + errorNames.insert(std::make_pair(1346, "ERROR_BAD_IMPERSONATION_LEVEL")); + errorNames.insert(std::make_pair(1347, "ERROR_CANT_OPEN_ANONYMOUS")); + errorNames.insert(std::make_pair(1348, "ERROR_BAD_VALIDATION_CLASS")); + errorNames.insert(std::make_pair(1349, "ERROR_BAD_TOKEN_TYPE")); + errorNames.insert(std::make_pair(1350, "ERROR_NO_SECURITY_ON_OBJECT")); + errorNames.insert(std::make_pair(1351, "ERROR_CANT_ACCESS_DOMAIN_INFO")); + errorNames.insert(std::make_pair(1352, "ERROR_INVALID_SERVER_STATE")); + errorNames.insert(std::make_pair(1353, "ERROR_INVALID_DOMAIN_STATE")); + errorNames.insert(std::make_pair(1354, "ERROR_INVALID_DOMAIN_ROLE")); + errorNames.insert(std::make_pair(1355, "ERROR_NO_SUCH_DOMAIN")); + errorNames.insert(std::make_pair(1356, "ERROR_DOMAIN_EXISTS")); + errorNames.insert(std::make_pair(1357, "ERROR_DOMAIN_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(1358, "ERROR_INTERNAL_DB_CORRUPTION")); + errorNames.insert(std::make_pair(1359, "ERROR_INTERNAL_ERROR")); + errorNames.insert(std::make_pair(1360, "ERROR_GENERIC_NOT_MAPPED")); + errorNames.insert(std::make_pair(1361, "ERROR_BAD_DESCRIPTOR_FORMAT")); + errorNames.insert(std::make_pair(1362, "ERROR_NOT_LOGON_PROCESS")); + errorNames.insert(std::make_pair(1363, "ERROR_LOGON_SESSION_EXISTS")); + errorNames.insert(std::make_pair(1364, "ERROR_NO_SUCH_PACKAGE")); + errorNames.insert(std::make_pair(1365, "ERROR_BAD_LOGON_SESSION_STATE")); + errorNames.insert(std::make_pair(1366, "ERROR_LOGON_SESSION_COLLISION")); + errorNames.insert(std::make_pair(1367, "ERROR_INVALID_LOGON_TYPE")); + errorNames.insert(std::make_pair(1368, "ERROR_CANNOT_IMPERSONATE")); + errorNames.insert(std::make_pair(1369, "ERROR_RXACT_INVALID_STATE")); + errorNames.insert(std::make_pair(1370, "ERROR_RXACT_COMMIT_FAILURE")); + errorNames.insert(std::make_pair(1371, "ERROR_SPECIAL_ACCOUNT")); + errorNames.insert(std::make_pair(1372, "ERROR_SPECIAL_GROUP")); + errorNames.insert(std::make_pair(1373, "ERROR_SPECIAL_USER")); + errorNames.insert(std::make_pair(1374, "ERROR_MEMBERS_PRIMARY_GROUP")); + errorNames.insert(std::make_pair(1375, "ERROR_TOKEN_ALREADY_IN_USE")); + errorNames.insert(std::make_pair(1376, "ERROR_NO_SUCH_ALIAS")); + errorNames.insert(std::make_pair(1377, "ERROR_MEMBER_NOT_IN_ALIAS")); + errorNames.insert(std::make_pair(1378, "ERROR_MEMBER_IN_ALIAS")); + errorNames.insert(std::make_pair(1379, "ERROR_ALIAS_EXISTS")); + errorNames.insert(std::make_pair(1380, "ERROR_LOGON_NOT_GRANTED")); + errorNames.insert(std::make_pair(1381, "ERROR_TOO_MANY_SECRETS")); + errorNames.insert(std::make_pair(1382, "ERROR_SECRET_TOO_LONG")); + errorNames.insert(std::make_pair(1383, "ERROR_INTERNAL_DB_ERROR")); + errorNames.insert(std::make_pair(1384, "ERROR_TOO_MANY_CONTEXT_IDS")); + errorNames.insert(std::make_pair(1385, "ERROR_LOGON_TYPE_NOT_GRANTED")); + errorNames.insert(std::make_pair(1386, "ERROR_NT_CROSS_ENCRYPTION_REQUIRED")); + errorNames.insert(std::make_pair(1387, "ERROR_NO_SUCH_MEMBER")); + errorNames.insert(std::make_pair(1388, "ERROR_INVALID_MEMBER")); + errorNames.insert(std::make_pair(1389, "ERROR_TOO_MANY_SIDS")); + errorNames.insert(std::make_pair(1390, "ERROR_LM_CROSS_ENCRYPTION_REQUIRED")); + errorNames.insert(std::make_pair(1391, "ERROR_NO_INHERITANCE")); + errorNames.insert(std::make_pair(1392, "ERROR_FILE_CORRUPT")); + errorNames.insert(std::make_pair(1393, "ERROR_DISK_CORRUPT")); + errorNames.insert(std::make_pair(1394, "ERROR_NO_USER_SESSION_KEY")); + errorNames.insert(std::make_pair(1395, "ERROR_LICENSE_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1396, "ERROR_WRONG_TARGET_NAME")); + errorNames.insert(std::make_pair(1397, "ERROR_MUTUAL_AUTH_FAILED")); + errorNames.insert(std::make_pair(1398, "ERROR_TIME_SKEW")); + errorNames.insert(std::make_pair(1399, "ERROR_CURRENT_DOMAIN_NOT_ALLOWED")); + errorNames.insert(std::make_pair(1400, "ERROR_INVALID_WINDOW_HANDLE")); + errorNames.insert(std::make_pair(1401, "ERROR_INVALID_MENU_HANDLE")); + errorNames.insert(std::make_pair(1402, "ERROR_INVALID_CURSOR_HANDLE")); + errorNames.insert(std::make_pair(1403, "ERROR_INVALID_ACCEL_HANDLE")); + errorNames.insert(std::make_pair(1404, "ERROR_INVALID_HOOK_HANDLE")); + errorNames.insert(std::make_pair(1405, "ERROR_INVALID_DWP_HANDLE")); + errorNames.insert(std::make_pair(1406, "ERROR_TLW_WITH_WSCHILD")); + errorNames.insert(std::make_pair(1407, "ERROR_CANNOT_FIND_WND_CLASS")); + errorNames.insert(std::make_pair(1408, "ERROR_WINDOW_OF_OTHER_THREAD")); + errorNames.insert(std::make_pair(1409, "ERROR_HOTKEY_ALREADY_REGISTERED")); + errorNames.insert(std::make_pair(1410, "ERROR_CLASS_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(1411, "ERROR_CLASS_DOES_NOT_EXIST")); + errorNames.insert(std::make_pair(1412, "ERROR_CLASS_HAS_WINDOWS")); + errorNames.insert(std::make_pair(1413, "ERROR_INVALID_INDEX")); + errorNames.insert(std::make_pair(1414, "ERROR_INVALID_ICON_HANDLE")); + errorNames.insert(std::make_pair(1415, "ERROR_PRIVATE_DIALOG_INDEX")); + errorNames.insert(std::make_pair(1416, "ERROR_LISTBOX_ID_NOT_FOUND")); + errorNames.insert(std::make_pair(1417, "ERROR_NO_WILDCARD_CHARACTERS")); + errorNames.insert(std::make_pair(1418, "ERROR_CLIPBOARD_NOT_OPEN")); + errorNames.insert(std::make_pair(1419, "ERROR_HOTKEY_NOT_REGISTERED")); + errorNames.insert(std::make_pair(1420, "ERROR_WINDOW_NOT_DIALOG")); + errorNames.insert(std::make_pair(1421, "ERROR_CONTROL_ID_NOT_FOUND")); + errorNames.insert(std::make_pair(1422, "ERROR_INVALID_COMBOBOX_MESSAGE")); + errorNames.insert(std::make_pair(1423, "ERROR_WINDOW_NOT_COMBOBOX")); + errorNames.insert(std::make_pair(1424, "ERROR_INVALID_EDIT_HEIGHT")); + errorNames.insert(std::make_pair(1425, "ERROR_DC_NOT_FOUND")); + errorNames.insert(std::make_pair(1426, "ERROR_INVALID_HOOK_FILTER")); + errorNames.insert(std::make_pair(1427, "ERROR_INVALID_FILTER_PROC")); + errorNames.insert(std::make_pair(1428, "ERROR_HOOK_NEEDS_HMOD")); + errorNames.insert(std::make_pair(1429, "ERROR_GLOBAL_ONLY_HOOK")); + errorNames.insert(std::make_pair(1430, "ERROR_JOURNAL_HOOK_SET")); + errorNames.insert(std::make_pair(1431, "ERROR_HOOK_NOT_INSTALLED")); + errorNames.insert(std::make_pair(1432, "ERROR_INVALID_LB_MESSAGE")); + errorNames.insert(std::make_pair(1433, "ERROR_SETCOUNT_ON_BAD_LB")); + errorNames.insert(std::make_pair(1434, "ERROR_LB_WITHOUT_TABSTOPS")); + errorNames.insert(std::make_pair(1435, "ERROR_DESTROY_OBJECT_OF_OTHER_THREAD")); + errorNames.insert(std::make_pair(1436, "ERROR_CHILD_WINDOW_MENU")); + errorNames.insert(std::make_pair(1437, "ERROR_NO_SYSTEM_MENU")); + errorNames.insert(std::make_pair(1438, "ERROR_INVALID_MSGBOX_STYLE")); + errorNames.insert(std::make_pair(1439, "ERROR_INVALID_SPI_VALUE")); + errorNames.insert(std::make_pair(1440, "ERROR_SCREEN_ALREADY_LOCKED")); + errorNames.insert(std::make_pair(1441, "ERROR_HWNDS_HAVE_DIFF_PARENT")); + errorNames.insert(std::make_pair(1442, "ERROR_NOT_CHILD_WINDOW")); + errorNames.insert(std::make_pair(1443, "ERROR_INVALID_GW_COMMAND")); + errorNames.insert(std::make_pair(1444, "ERROR_INVALID_THREAD_ID")); + errorNames.insert(std::make_pair(1445, "ERROR_NON_MDICHILD_WINDOW")); + errorNames.insert(std::make_pair(1446, "ERROR_POPUP_ALREADY_ACTIVE")); + errorNames.insert(std::make_pair(1447, "ERROR_NO_SCROLLBARS")); + errorNames.insert(std::make_pair(1448, "ERROR_INVALID_SCROLLBAR_RANGE")); + errorNames.insert(std::make_pair(1449, "ERROR_INVALID_SHOWWIN_COMMAND")); + errorNames.insert(std::make_pair(1450, "ERROR_NO_SYSTEM_RESOURCES")); + errorNames.insert(std::make_pair(1451, "ERROR_NONPAGED_SYSTEM_RESOURCES")); + errorNames.insert(std::make_pair(1452, "ERROR_PAGED_SYSTEM_RESOURCES")); + errorNames.insert(std::make_pair(1453, "ERROR_WORKING_SET_QUOTA")); + errorNames.insert(std::make_pair(1454, "ERROR_PAGEFILE_QUOTA")); + errorNames.insert(std::make_pair(1455, "ERROR_COMMITMENT_LIMIT")); + errorNames.insert(std::make_pair(1456, "ERROR_MENU_ITEM_NOT_FOUND")); + errorNames.insert(std::make_pair(1457, "ERROR_INVALID_KEYBOARD_HANDLE")); + errorNames.insert(std::make_pair(1458, "ERROR_HOOK_TYPE_NOT_ALLOWED")); + errorNames.insert(std::make_pair(1459, "ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION")); + errorNames.insert(std::make_pair(1460, "ERROR_TIMEOUT")); + errorNames.insert(std::make_pair(1461, "ERROR_INVALID_MONITOR_HANDLE")); + errorNames.insert(std::make_pair(1462, "ERROR_INCORRECT_SIZE")); + errorNames.insert(std::make_pair(1463, "ERROR_SYMLINK_CLASS_DISABLED")); + errorNames.insert(std::make_pair(1464, "ERROR_SYMLINK_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(1465, "ERROR_XML_PARSE_ERROR")); + errorNames.insert(std::make_pair(1466, "ERROR_XMLDSIG_ERROR")); + errorNames.insert(std::make_pair(1467, "ERROR_RESTART_APPLICATION")); + errorNames.insert(std::make_pair(1468, "ERROR_WRONG_COMPARTMENT")); + errorNames.insert(std::make_pair(1469, "ERROR_AUTHIP_FAILURE")); + errorNames.insert(std::make_pair(1470, "ERROR_NO_NVRAM_RESOURCES")); + errorNames.insert(std::make_pair(1500, "ERROR_EVENTLOG_FILE_CORRUPT")); + errorNames.insert(std::make_pair(1501, "ERROR_EVENTLOG_CANT_START")); + errorNames.insert(std::make_pair(1502, "ERROR_LOG_FILE_FULL")); + errorNames.insert(std::make_pair(1503, "ERROR_EVENTLOG_FILE_CHANGED")); + errorNames.insert(std::make_pair(1550, "ERROR_INVALID_TASK_NAME")); + errorNames.insert(std::make_pair(1551, "ERROR_INVALID_TASK_INDEX")); + errorNames.insert(std::make_pair(1552, "ERROR_THREAD_ALREADY_IN_TASK")); + errorNames.insert(std::make_pair(1601, "ERROR_INSTALL_SERVICE_FAILURE")); + errorNames.insert(std::make_pair(1602, "ERROR_INSTALL_USEREXIT")); + errorNames.insert(std::make_pair(1603, "ERROR_INSTALL_FAILURE")); + errorNames.insert(std::make_pair(1604, "ERROR_INSTALL_SUSPEND")); + errorNames.insert(std::make_pair(1605, "ERROR_UNKNOWN_PRODUCT")); + errorNames.insert(std::make_pair(1606, "ERROR_UNKNOWN_FEATURE")); + errorNames.insert(std::make_pair(1607, "ERROR_UNKNOWN_COMPONENT")); + errorNames.insert(std::make_pair(1608, "ERROR_UNKNOWN_PROPERTY")); + errorNames.insert(std::make_pair(1609, "ERROR_INVALID_HANDLE_STATE")); + errorNames.insert(std::make_pair(1610, "ERROR_BAD_CONFIGURATION")); + errorNames.insert(std::make_pair(1611, "ERROR_INDEX_ABSENT")); + errorNames.insert(std::make_pair(1612, "ERROR_INSTALL_SOURCE_ABSENT")); + errorNames.insert(std::make_pair(1613, "ERROR_INSTALL_PACKAGE_VERSION")); + errorNames.insert(std::make_pair(1614, "ERROR_PRODUCT_UNINSTALLED")); + errorNames.insert(std::make_pair(1615, "ERROR_BAD_QUERY_SYNTAX")); + errorNames.insert(std::make_pair(1616, "ERROR_INVALID_FIELD")); + errorNames.insert(std::make_pair(1617, "ERROR_DEVICE_REMOVED")); + errorNames.insert(std::make_pair(1618, "ERROR_INSTALL_ALREADY_RUNNING")); + errorNames.insert(std::make_pair(1619, "ERROR_INSTALL_PACKAGE_OPEN_FAILED")); + errorNames.insert(std::make_pair(1620, "ERROR_INSTALL_PACKAGE_INVALID")); + errorNames.insert(std::make_pair(1621, "ERROR_INSTALL_UI_FAILURE")); + errorNames.insert(std::make_pair(1622, "ERROR_INSTALL_LOG_FAILURE")); + errorNames.insert(std::make_pair(1623, "ERROR_INSTALL_LANGUAGE_UNSUPPORTED")); + errorNames.insert(std::make_pair(1624, "ERROR_INSTALL_TRANSFORM_FAILURE")); + errorNames.insert(std::make_pair(1625, "ERROR_INSTALL_PACKAGE_REJECTED")); + errorNames.insert(std::make_pair(1626, "ERROR_FUNCTION_NOT_CALLED")); + errorNames.insert(std::make_pair(1627, "ERROR_FUNCTION_FAILED")); + errorNames.insert(std::make_pair(1628, "ERROR_INVALID_TABLE")); + errorNames.insert(std::make_pair(1629, "ERROR_DATATYPE_MISMATCH")); + errorNames.insert(std::make_pair(1630, "ERROR_UNSUPPORTED_TYPE")); + errorNames.insert(std::make_pair(1631, "ERROR_CREATE_FAILED")); + errorNames.insert(std::make_pair(1632, "ERROR_INSTALL_TEMP_UNWRITABLE")); + errorNames.insert(std::make_pair(1633, "ERROR_INSTALL_PLATFORM_UNSUPPORTED")); + errorNames.insert(std::make_pair(1634, "ERROR_INSTALL_NOTUSED")); + errorNames.insert(std::make_pair(1635, "ERROR_PATCH_PACKAGE_OPEN_FAILED")); + errorNames.insert(std::make_pair(1636, "ERROR_PATCH_PACKAGE_INVALID")); + errorNames.insert(std::make_pair(1637, "ERROR_PATCH_PACKAGE_UNSUPPORTED")); + errorNames.insert(std::make_pair(1638, "ERROR_PRODUCT_VERSION")); + errorNames.insert(std::make_pair(1639, "ERROR_INVALID_COMMAND_LINE")); + errorNames.insert(std::make_pair(1640, "ERROR_INSTALL_REMOTE_DISALLOWED")); + errorNames.insert(std::make_pair(1641, "ERROR_SUCCESS_REBOOT_INITIATED")); + errorNames.insert(std::make_pair(1642, "ERROR_PATCH_TARGET_NOT_FOUND")); + errorNames.insert(std::make_pair(1643, "ERROR_PATCH_PACKAGE_REJECTED")); + errorNames.insert(std::make_pair(1644, "ERROR_INSTALL_TRANSFORM_REJECTED")); + errorNames.insert(std::make_pair(1645, "ERROR_INSTALL_REMOTE_PROHIBITED")); + errorNames.insert(std::make_pair(1646, "ERROR_PATCH_REMOVAL_UNSUPPORTED")); + errorNames.insert(std::make_pair(1647, "ERROR_UNKNOWN_PATCH")); + errorNames.insert(std::make_pair(1648, "ERROR_PATCH_NO_SEQUENCE")); + errorNames.insert(std::make_pair(1649, "ERROR_PATCH_REMOVAL_DISALLOWED")); + errorNames.insert(std::make_pair(1650, "ERROR_INVALID_PATCH_XML")); + errorNames.insert(std::make_pair(1651, "ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT")); + errorNames.insert(std::make_pair(1652, "ERROR_INSTALL_SERVICE_SAFEBOOT")); + errorNames.insert(std::make_pair(1653, "ERROR_FAIL_FAST_EXCEPTION")); + errorNames.insert(std::make_pair(1784, "ERROR_INVALID_USER_BUFFER")); + errorNames.insert(std::make_pair(1785, "ERROR_UNRECOGNIZED_MEDIA")); + errorNames.insert(std::make_pair(1786, "ERROR_NO_TRUST_LSA_SECRET")); + errorNames.insert(std::make_pair(1787, "ERROR_NO_TRUST_SAM_ACCOUNT")); + errorNames.insert(std::make_pair(1788, "ERROR_TRUSTED_DOMAIN_FAILURE")); + errorNames.insert(std::make_pair(1789, "ERROR_TRUSTED_RELATIONSHIP_FAILURE")); + errorNames.insert(std::make_pair(1790, "ERROR_TRUST_FAILURE")); + errorNames.insert(std::make_pair(1792, "ERROR_NETLOGON_NOT_STARTED")); + errorNames.insert(std::make_pair(1793, "ERROR_ACCOUNT_EXPIRED")); + errorNames.insert(std::make_pair(1794, "ERROR_REDIRECTOR_HAS_OPEN_HANDLES")); + errorNames.insert(std::make_pair(1795, "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(1796, "ERROR_UNKNOWN_PORT")); + errorNames.insert(std::make_pair(1797, "ERROR_UNKNOWN_PRINTER_DRIVER")); + errorNames.insert(std::make_pair(1798, "ERROR_UNKNOWN_PRINTPROCESSOR")); + errorNames.insert(std::make_pair(1799, "ERROR_INVALID_SEPARATOR_FILE")); + errorNames.insert(std::make_pair(1800, "ERROR_INVALID_PRIORITY")); + errorNames.insert(std::make_pair(1801, "ERROR_INVALID_PRINTER_NAME")); + errorNames.insert(std::make_pair(1802, "ERROR_PRINTER_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(1803, "ERROR_INVALID_PRINTER_COMMAND")); + errorNames.insert(std::make_pair(1804, "ERROR_INVALID_DATATYPE")); + errorNames.insert(std::make_pair(1805, "ERROR_INVALID_ENVIRONMENT")); + errorNames.insert(std::make_pair(1807, "ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT")); + errorNames.insert(std::make_pair(1808, "ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT")); + errorNames.insert(std::make_pair(1809, "ERROR_NOLOGON_SERVER_TRUST_ACCOUNT")); + errorNames.insert(std::make_pair(1810, "ERROR_DOMAIN_TRUST_INCONSISTENT")); + errorNames.insert(std::make_pair(1811, "ERROR_SERVER_HAS_OPEN_HANDLES")); + errorNames.insert(std::make_pair(1812, "ERROR_RESOURCE_DATA_NOT_FOUND")); + errorNames.insert(std::make_pair(1813, "ERROR_RESOURCE_TYPE_NOT_FOUND")); + errorNames.insert(std::make_pair(1814, "ERROR_RESOURCE_NAME_NOT_FOUND")); + errorNames.insert(std::make_pair(1815, "ERROR_RESOURCE_LANG_NOT_FOUND")); + errorNames.insert(std::make_pair(1816, "ERROR_NOT_ENOUGH_QUOTA")); + errorNames.insert(std::make_pair(1901, "ERROR_INVALID_TIME")); + errorNames.insert(std::make_pair(1902, "ERROR_INVALID_FORM_NAME")); + errorNames.insert(std::make_pair(1903, "ERROR_INVALID_FORM_SIZE")); + errorNames.insert(std::make_pair(1904, "ERROR_ALREADY_WAITING")); + errorNames.insert(std::make_pair(1905, "ERROR_PRINTER_DELETED")); + errorNames.insert(std::make_pair(1906, "ERROR_INVALID_PRINTER_STATE")); + errorNames.insert(std::make_pair(1907, "ERROR_PASSWORD_MUST_CHANGE")); + errorNames.insert(std::make_pair(1908, "ERROR_DOMAIN_CONTROLLER_NOT_FOUND")); + errorNames.insert(std::make_pair(1909, "ERROR_ACCOUNT_LOCKED_OUT")); + errorNames.insert(std::make_pair(1919, "ERROR_NO_SITENAME")); + errorNames.insert(std::make_pair(1920, "ERROR_CANT_ACCESS_FILE")); + errorNames.insert(std::make_pair(1921, "ERROR_CANT_RESOLVE_FILENAME")); + errorNames.insert(std::make_pair(1930, "ERROR_KM_DRIVER_BLOCKED")); + errorNames.insert(std::make_pair(1931, "ERROR_CONTEXT_EXPIRED")); + errorNames.insert(std::make_pair(1932, "ERROR_PER_USER_TRUST_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1933, "ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1934, "ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(1935, "ERROR_AUTHENTICATION_FIREWALL_FAILED")); + errorNames.insert(std::make_pair(1936, "ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED")); + errorNames.insert(std::make_pair(1937, "ERROR_NTLM_BLOCKED")); + errorNames.insert(std::make_pair(2000, "ERROR_INVALID_PIXEL_FORMAT")); + errorNames.insert(std::make_pair(2001, "ERROR_BAD_DRIVER")); + errorNames.insert(std::make_pair(2002, "ERROR_INVALID_WINDOW_STYLE")); + errorNames.insert(std::make_pair(2003, "ERROR_METAFILE_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(2004, "ERROR_TRANSFORM_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(2005, "ERROR_CLIPPING_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(2010, "ERROR_INVALID_CMM")); + errorNames.insert(std::make_pair(2011, "ERROR_INVALID_PROFILE")); + errorNames.insert(std::make_pair(2012, "ERROR_TAG_NOT_FOUND")); + errorNames.insert(std::make_pair(2013, "ERROR_TAG_NOT_PRESENT")); + errorNames.insert(std::make_pair(2014, "ERROR_DUPLICATE_TAG")); + errorNames.insert(std::make_pair(2015, "ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE")); + errorNames.insert(std::make_pair(2016, "ERROR_PROFILE_NOT_FOUND")); + errorNames.insert(std::make_pair(2017, "ERROR_INVALID_COLORSPACE")); + errorNames.insert(std::make_pair(2018, "ERROR_ICM_NOT_ENABLED")); + errorNames.insert(std::make_pair(2019, "ERROR_DELETING_ICM_XFORM")); + errorNames.insert(std::make_pair(2020, "ERROR_INVALID_TRANSFORM")); + errorNames.insert(std::make_pair(2021, "ERROR_COLORSPACE_MISMATCH")); + errorNames.insert(std::make_pair(2022, "ERROR_INVALID_COLORINDEX")); + errorNames.insert(std::make_pair(2023, "ERROR_PROFILE_DOES_NOT_MATCH_DEVICE")); + errorNames.insert(std::make_pair(2108, "ERROR_CONNECTED_OTHER_PASSWORD")); + errorNames.insert(std::make_pair(2109, "ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT")); + errorNames.insert(std::make_pair(2202, "ERROR_BAD_USERNAME")); + errorNames.insert(std::make_pair(2250, "ERROR_NOT_CONNECTED")); + errorNames.insert(std::make_pair(2401, "ERROR_OPEN_FILES")); + errorNames.insert(std::make_pair(2402, "ERROR_ACTIVE_CONNECTIONS")); + errorNames.insert(std::make_pair(2404, "ERROR_DEVICE_IN_USE")); + errorNames.insert(std::make_pair(3000, "ERROR_UNKNOWN_PRINT_MONITOR")); + errorNames.insert(std::make_pair(3001, "ERROR_PRINTER_DRIVER_IN_USE")); + errorNames.insert(std::make_pair(3002, "ERROR_SPOOL_FILE_NOT_FOUND")); + errorNames.insert(std::make_pair(3003, "ERROR_SPL_NO_STARTDOC")); + errorNames.insert(std::make_pair(3004, "ERROR_SPL_NO_ADDJOB")); + errorNames.insert(std::make_pair(3005, "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(3006, "ERROR_PRINT_MONITOR_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(3007, "ERROR_INVALID_PRINT_MONITOR")); + errorNames.insert(std::make_pair(3008, "ERROR_PRINT_MONITOR_IN_USE")); + errorNames.insert(std::make_pair(3009, "ERROR_PRINTER_HAS_JOBS_QUEUED")); + errorNames.insert(std::make_pair(3010, "ERROR_SUCCESS_REBOOT_REQUIRED")); + errorNames.insert(std::make_pair(3011, "ERROR_SUCCESS_RESTART_REQUIRED")); + errorNames.insert(std::make_pair(3012, "ERROR_PRINTER_NOT_FOUND")); + errorNames.insert(std::make_pair(3013, "ERROR_PRINTER_DRIVER_WARNED")); + errorNames.insert(std::make_pair(3014, "ERROR_PRINTER_DRIVER_BLOCKED")); + errorNames.insert(std::make_pair(3015, "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE")); + errorNames.insert(std::make_pair(3016, "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND")); + errorNames.insert(std::make_pair(3017, "ERROR_FAIL_REBOOT_REQUIRED")); + errorNames.insert(std::make_pair(3018, "ERROR_FAIL_REBOOT_INITIATED")); + errorNames.insert(std::make_pair(3019, "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED")); + errorNames.insert(std::make_pair(3020, "ERROR_PRINT_JOB_RESTART_REQUIRED")); + errorNames.insert(std::make_pair(3950, "ERROR_IO_REISSUE_AS_CACHED")); + errorNames.insert(std::make_pair(4000, "ERROR_WINS_INTERNAL")); + errorNames.insert(std::make_pair(4001, "ERROR_CAN_NOT_DEL_LOCAL_WINS")); + errorNames.insert(std::make_pair(4002, "ERROR_STATIC_INIT")); + errorNames.insert(std::make_pair(4003, "ERROR_INC_BACKUP")); + errorNames.insert(std::make_pair(4004, "ERROR_FULL_BACKUP")); + errorNames.insert(std::make_pair(4005, "ERROR_REC_NON_EXISTENT")); + errorNames.insert(std::make_pair(4006, "ERROR_RPL_NOT_ALLOWED")); + errorNames.insert(std::make_pair(4100, "ERROR_DHCP_ADDRESS_CONFLICT")); + errorNames.insert(std::make_pair(4200, "ERROR_WMI_GUID_NOT_FOUND")); + errorNames.insert(std::make_pair(4201, "ERROR_WMI_INSTANCE_NOT_FOUND")); + errorNames.insert(std::make_pair(4202, "ERROR_WMI_ITEMID_NOT_FOUND")); + errorNames.insert(std::make_pair(4203, "ERROR_WMI_TRY_AGAIN")); + errorNames.insert(std::make_pair(4204, "ERROR_WMI_DP_NOT_FOUND")); + errorNames.insert(std::make_pair(4205, "ERROR_WMI_UNRESOLVED_INSTANCE_REF")); + errorNames.insert(std::make_pair(4206, "ERROR_WMI_ALREADY_ENABLED")); + errorNames.insert(std::make_pair(4207, "ERROR_WMI_GUID_DISCONNECTED")); + errorNames.insert(std::make_pair(4208, "ERROR_WMI_SERVER_UNAVAILABLE")); + errorNames.insert(std::make_pair(4209, "ERROR_WMI_DP_FAILED")); + errorNames.insert(std::make_pair(4210, "ERROR_WMI_INVALID_MOF")); + errorNames.insert(std::make_pair(4211, "ERROR_WMI_INVALID_REGINFO")); + errorNames.insert(std::make_pair(4212, "ERROR_WMI_ALREADY_DISABLED")); + errorNames.insert(std::make_pair(4213, "ERROR_WMI_READ_ONLY")); + errorNames.insert(std::make_pair(4214, "ERROR_WMI_SET_FAILURE")); + errorNames.insert(std::make_pair(4300, "ERROR_INVALID_MEDIA")); + errorNames.insert(std::make_pair(4301, "ERROR_INVALID_LIBRARY")); + errorNames.insert(std::make_pair(4302, "ERROR_INVALID_MEDIA_POOL")); + errorNames.insert(std::make_pair(4303, "ERROR_DRIVE_MEDIA_MISMATCH")); + errorNames.insert(std::make_pair(4304, "ERROR_MEDIA_OFFLINE")); + errorNames.insert(std::make_pair(4305, "ERROR_LIBRARY_OFFLINE")); + errorNames.insert(std::make_pair(4306, "ERROR_EMPTY")); + errorNames.insert(std::make_pair(4307, "ERROR_NOT_EMPTY")); + errorNames.insert(std::make_pair(4308, "ERROR_MEDIA_UNAVAILABLE")); + errorNames.insert(std::make_pair(4309, "ERROR_RESOURCE_DISABLED")); + errorNames.insert(std::make_pair(4310, "ERROR_INVALID_CLEANER")); + errorNames.insert(std::make_pair(4311, "ERROR_UNABLE_TO_CLEAN")); + errorNames.insert(std::make_pair(4312, "ERROR_OBJECT_NOT_FOUND")); + errorNames.insert(std::make_pair(4313, "ERROR_DATABASE_FAILURE")); + errorNames.insert(std::make_pair(4314, "ERROR_DATABASE_FULL")); + errorNames.insert(std::make_pair(4315, "ERROR_MEDIA_INCOMPATIBLE")); + errorNames.insert(std::make_pair(4316, "ERROR_RESOURCE_NOT_PRESENT")); + errorNames.insert(std::make_pair(4317, "ERROR_INVALID_OPERATION")); + errorNames.insert(std::make_pair(4318, "ERROR_MEDIA_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(4319, "ERROR_DEVICE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(4320, "ERROR_REQUEST_REFUSED")); + errorNames.insert(std::make_pair(4321, "ERROR_INVALID_DRIVE_OBJECT")); + errorNames.insert(std::make_pair(4322, "ERROR_LIBRARY_FULL")); + errorNames.insert(std::make_pair(4323, "ERROR_MEDIUM_NOT_ACCESSIBLE")); + errorNames.insert(std::make_pair(4324, "ERROR_UNABLE_TO_LOAD_MEDIUM")); + errorNames.insert(std::make_pair(4325, "ERROR_UNABLE_TO_INVENTORY_DRIVE")); + errorNames.insert(std::make_pair(4326, "ERROR_UNABLE_TO_INVENTORY_SLOT")); + errorNames.insert(std::make_pair(4327, "ERROR_UNABLE_TO_INVENTORY_TRANSPORT")); + errorNames.insert(std::make_pair(4328, "ERROR_TRANSPORT_FULL")); + errorNames.insert(std::make_pair(4329, "ERROR_CONTROLLING_IEPORT")); + errorNames.insert(std::make_pair(4330, "ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA")); + errorNames.insert(std::make_pair(4331, "ERROR_CLEANER_SLOT_SET")); + errorNames.insert(std::make_pair(4332, "ERROR_CLEANER_SLOT_NOT_SET")); + errorNames.insert(std::make_pair(4333, "ERROR_CLEANER_CARTRIDGE_SPENT")); + errorNames.insert(std::make_pair(4334, "ERROR_UNEXPECTED_OMID")); + errorNames.insert(std::make_pair(4335, "ERROR_CANT_DELETE_LAST_ITEM")); + errorNames.insert(std::make_pair(4336, "ERROR_MESSAGE_EXCEEDS_MAX_SIZE")); + errorNames.insert(std::make_pair(4337, "ERROR_VOLUME_CONTAINS_SYS_FILES")); + errorNames.insert(std::make_pair(4338, "ERROR_INDIGENOUS_TYPE")); + errorNames.insert(std::make_pair(4339, "ERROR_NO_SUPPORTING_DRIVES")); + errorNames.insert(std::make_pair(4340, "ERROR_CLEANER_CARTRIDGE_INSTALLED")); + errorNames.insert(std::make_pair(4341, "ERROR_IEPORT_FULL")); + errorNames.insert(std::make_pair(4350, "ERROR_FILE_OFFLINE")); + errorNames.insert(std::make_pair(4351, "ERROR_REMOTE_STORAGE_NOT_ACTIVE")); + errorNames.insert(std::make_pair(4352, "ERROR_REMOTE_STORAGE_MEDIA_ERROR")); + errorNames.insert(std::make_pair(4390, "ERROR_NOT_A_REPARSE_POINT")); + errorNames.insert(std::make_pair(4391, "ERROR_REPARSE_ATTRIBUTE_CONFLICT")); + errorNames.insert(std::make_pair(4392, "ERROR_INVALID_REPARSE_DATA")); + errorNames.insert(std::make_pair(4393, "ERROR_REPARSE_TAG_INVALID")); + errorNames.insert(std::make_pair(4394, "ERROR_REPARSE_TAG_MISMATCH")); + errorNames.insert(std::make_pair(4500, "ERROR_VOLUME_NOT_SIS_ENABLED")); + errorNames.insert(std::make_pair(5001, "ERROR_DEPENDENT_RESOURCE_EXISTS")); + errorNames.insert(std::make_pair(5002, "ERROR_DEPENDENCY_NOT_FOUND")); + errorNames.insert(std::make_pair(5003, "ERROR_DEPENDENCY_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(5004, "ERROR_RESOURCE_NOT_ONLINE")); + errorNames.insert(std::make_pair(5005, "ERROR_HOST_NODE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5006, "ERROR_RESOURCE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5007, "ERROR_RESOURCE_NOT_FOUND")); + errorNames.insert(std::make_pair(5008, "ERROR_SHUTDOWN_CLUSTER")); + errorNames.insert(std::make_pair(5009, "ERROR_CANT_EVICT_ACTIVE_NODE")); + errorNames.insert(std::make_pair(5010, "ERROR_OBJECT_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(5011, "ERROR_OBJECT_IN_LIST")); + errorNames.insert(std::make_pair(5012, "ERROR_GROUP_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5013, "ERROR_GROUP_NOT_FOUND")); + errorNames.insert(std::make_pair(5014, "ERROR_GROUP_NOT_ONLINE")); + errorNames.insert(std::make_pair(5015, "ERROR_HOST_NODE_NOT_RESOURCE_OWNER")); + errorNames.insert(std::make_pair(5016, "ERROR_HOST_NODE_NOT_GROUP_OWNER")); + errorNames.insert(std::make_pair(5017, "ERROR_RESMON_CREATE_FAILED")); + errorNames.insert(std::make_pair(5018, "ERROR_RESMON_ONLINE_FAILED")); + errorNames.insert(std::make_pair(5019, "ERROR_RESOURCE_ONLINE")); + errorNames.insert(std::make_pair(5020, "ERROR_QUORUM_RESOURCE")); + errorNames.insert(std::make_pair(5021, "ERROR_NOT_QUORUM_CAPABLE")); + errorNames.insert(std::make_pair(5022, "ERROR_CLUSTER_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(5023, "ERROR_INVALID_STATE")); + errorNames.insert(std::make_pair(5024, "ERROR_RESOURCE_PROPERTIES_STORED")); + errorNames.insert(std::make_pair(5025, "ERROR_NOT_QUORUM_CLASS")); + errorNames.insert(std::make_pair(5026, "ERROR_CORE_RESOURCE")); + errorNames.insert(std::make_pair(5027, "ERROR_QUORUM_RESOURCE_ONLINE_FAILED")); + errorNames.insert(std::make_pair(5028, "ERROR_QUORUMLOG_OPEN_FAILED")); + errorNames.insert(std::make_pair(5029, "ERROR_CLUSTERLOG_CORRUPT")); + errorNames.insert(std::make_pair(5030, "ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE")); + errorNames.insert(std::make_pair(5031, "ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE")); + errorNames.insert(std::make_pair(5032, "ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND")); + errorNames.insert(std::make_pair(5033, "ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE")); + errorNames.insert(std::make_pair(5034, "ERROR_QUORUM_OWNER_ALIVE")); + errorNames.insert(std::make_pair(5035, "ERROR_NETWORK_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5036, "ERROR_NODE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5037, "ERROR_ALL_NODES_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(5038, "ERROR_RESOURCE_FAILED")); + errorNames.insert(std::make_pair(5039, "ERROR_CLUSTER_INVALID_NODE")); + errorNames.insert(std::make_pair(5040, "ERROR_CLUSTER_NODE_EXISTS")); + errorNames.insert(std::make_pair(5041, "ERROR_CLUSTER_JOIN_IN_PROGRESS")); + errorNames.insert(std::make_pair(5042, "ERROR_CLUSTER_NODE_NOT_FOUND")); + errorNames.insert(std::make_pair(5043, "ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND")); + errorNames.insert(std::make_pair(5044, "ERROR_CLUSTER_NETWORK_EXISTS")); + errorNames.insert(std::make_pair(5045, "ERROR_CLUSTER_NETWORK_NOT_FOUND")); + errorNames.insert(std::make_pair(5046, "ERROR_CLUSTER_NETINTERFACE_EXISTS")); + errorNames.insert(std::make_pair(5047, "ERROR_CLUSTER_NETINTERFACE_NOT_FOUND")); + errorNames.insert(std::make_pair(5048, "ERROR_CLUSTER_INVALID_REQUEST")); + errorNames.insert(std::make_pair(5049, "ERROR_CLUSTER_INVALID_NETWORK_PROVIDER")); + errorNames.insert(std::make_pair(5050, "ERROR_CLUSTER_NODE_DOWN")); + errorNames.insert(std::make_pair(5051, "ERROR_CLUSTER_NODE_UNREACHABLE")); + errorNames.insert(std::make_pair(5052, "ERROR_CLUSTER_NODE_NOT_MEMBER")); + errorNames.insert(std::make_pair(5053, "ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS")); + errorNames.insert(std::make_pair(5054, "ERROR_CLUSTER_INVALID_NETWORK")); + errorNames.insert(std::make_pair(5056, "ERROR_CLUSTER_NODE_UP")); + errorNames.insert(std::make_pair(5057, "ERROR_CLUSTER_IPADDR_IN_USE")); + errorNames.insert(std::make_pair(5058, "ERROR_CLUSTER_NODE_NOT_PAUSED")); + errorNames.insert(std::make_pair(5059, "ERROR_CLUSTER_NO_SECURITY_CONTEXT")); + errorNames.insert(std::make_pair(5060, "ERROR_CLUSTER_NETWORK_NOT_INTERNAL")); + errorNames.insert(std::make_pair(5061, "ERROR_CLUSTER_NODE_ALREADY_UP")); + errorNames.insert(std::make_pair(5062, "ERROR_CLUSTER_NODE_ALREADY_DOWN")); + errorNames.insert(std::make_pair(5063, "ERROR_CLUSTER_NETWORK_ALREADY_ONLINE")); + errorNames.insert(std::make_pair(5064, "ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE")); + errorNames.insert(std::make_pair(5065, "ERROR_CLUSTER_NODE_ALREADY_MEMBER")); + errorNames.insert(std::make_pair(5066, "ERROR_CLUSTER_LAST_INTERNAL_NETWORK")); + errorNames.insert(std::make_pair(5067, "ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS")); + errorNames.insert(std::make_pair(5068, "ERROR_INVALID_OPERATION_ON_QUORUM")); + errorNames.insert(std::make_pair(5069, "ERROR_DEPENDENCY_NOT_ALLOWED")); + errorNames.insert(std::make_pair(5070, "ERROR_CLUSTER_NODE_PAUSED")); + errorNames.insert(std::make_pair(5071, "ERROR_NODE_CANT_HOST_RESOURCE")); + errorNames.insert(std::make_pair(5072, "ERROR_CLUSTER_NODE_NOT_READY")); + errorNames.insert(std::make_pair(5073, "ERROR_CLUSTER_NODE_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(5074, "ERROR_CLUSTER_JOIN_ABORTED")); + errorNames.insert(std::make_pair(5075, "ERROR_CLUSTER_INCOMPATIBLE_VERSIONS")); + errorNames.insert(std::make_pair(5076, "ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED")); + errorNames.insert(std::make_pair(5077, "ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED")); + errorNames.insert(std::make_pair(5078, "ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND")); + errorNames.insert(std::make_pair(5079, "ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(5080, "ERROR_CLUSTER_RESNAME_NOT_FOUND")); + errorNames.insert(std::make_pair(5081, "ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED")); + errorNames.insert(std::make_pair(5082, "ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST")); + errorNames.insert(std::make_pair(5083, "ERROR_CLUSTER_DATABASE_SEQMISMATCH")); + errorNames.insert(std::make_pair(5084, "ERROR_RESMON_INVALID_STATE")); + errorNames.insert(std::make_pair(5085, "ERROR_CLUSTER_GUM_NOT_LOCKER")); + errorNames.insert(std::make_pair(5086, "ERROR_QUORUM_DISK_NOT_FOUND")); + errorNames.insert(std::make_pair(5087, "ERROR_DATABASE_BACKUP_CORRUPT")); + errorNames.insert(std::make_pair(5088, "ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT")); + errorNames.insert(std::make_pair(5089, "ERROR_RESOURCE_PROPERTY_UNCHANGEABLE")); + errorNames.insert(std::make_pair(5890, "ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE")); + errorNames.insert(std::make_pair(5891, "ERROR_CLUSTER_QUORUMLOG_NOT_FOUND")); + errorNames.insert(std::make_pair(5892, "ERROR_CLUSTER_MEMBERSHIP_HALT")); + errorNames.insert(std::make_pair(5893, "ERROR_CLUSTER_INSTANCE_ID_MISMATCH")); + errorNames.insert(std::make_pair(5894, "ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP")); + errorNames.insert(std::make_pair(5895, "ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH")); + errorNames.insert(std::make_pair(5896, "ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP")); + errorNames.insert(std::make_pair(5897, "ERROR_CLUSTER_PARAMETER_MISMATCH")); + errorNames.insert(std::make_pair(5898, "ERROR_NODE_CANNOT_BE_CLUSTERED")); + errorNames.insert(std::make_pair(5899, "ERROR_CLUSTER_WRONG_OS_VERSION")); + errorNames.insert(std::make_pair(5900, "ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME")); + errorNames.insert(std::make_pair(5901, "ERROR_CLUSCFG_ALREADY_COMMITTED")); + errorNames.insert(std::make_pair(5902, "ERROR_CLUSCFG_ROLLBACK_FAILED")); + errorNames.insert(std::make_pair(5903, "ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT")); + errorNames.insert(std::make_pair(5904, "ERROR_CLUSTER_OLD_VERSION")); + errorNames.insert(std::make_pair(5905, "ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME")); + errorNames.insert(std::make_pair(5906, "ERROR_CLUSTER_NO_NET_ADAPTERS")); + errorNames.insert(std::make_pair(5907, "ERROR_CLUSTER_POISONED")); + errorNames.insert(std::make_pair(5908, "ERROR_CLUSTER_GROUP_MOVING")); + errorNames.insert(std::make_pair(5909, "ERROR_CLUSTER_RESOURCE_TYPE_BUSY")); + errorNames.insert(std::make_pair(5910, "ERROR_RESOURCE_CALL_TIMED_OUT")); + errorNames.insert(std::make_pair(5911, "ERROR_INVALID_CLUSTER_IPV6_ADDRESS")); + errorNames.insert(std::make_pair(5912, "ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION")); + errorNames.insert(std::make_pair(5913, "ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS")); + errorNames.insert(std::make_pair(5914, "ERROR_CLUSTER_PARTIAL_SEND")); + errorNames.insert(std::make_pair(5915, "ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION")); + errorNames.insert(std::make_pair(5916, "ERROR_CLUSTER_INVALID_STRING_TERMINATION")); + errorNames.insert(std::make_pair(5917, "ERROR_CLUSTER_INVALID_STRING_FORMAT")); + errorNames.insert(std::make_pair(5918, "ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS")); + errorNames.insert(std::make_pair(5919, "ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS")); + errorNames.insert(std::make_pair(5920, "ERROR_CLUSTER_NULL_DATA")); + errorNames.insert(std::make_pair(5921, "ERROR_CLUSTER_PARTIAL_READ")); + errorNames.insert(std::make_pair(5922, "ERROR_CLUSTER_PARTIAL_WRITE")); + errorNames.insert(std::make_pair(5923, "ERROR_CLUSTER_CANT_DESERIALIZE_DATA")); + errorNames.insert(std::make_pair(5924, "ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT")); + errorNames.insert(std::make_pair(5925, "ERROR_CLUSTER_NO_QUORUM")); + errorNames.insert(std::make_pair(5926, "ERROR_CLUSTER_INVALID_IPV6_NETWORK")); + errorNames.insert(std::make_pair(5927, "ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK")); + errorNames.insert(std::make_pair(5928, "ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP")); + errorNames.insert(std::make_pair(5929, "ERROR_DEPENDENCY_TREE_TOO_COMPLEX")); + errorNames.insert(std::make_pair(5930, "ERROR_EXCEPTION_IN_RESOURCE_CALL")); + errorNames.insert(std::make_pair(5931, "ERROR_CLUSTER_RHS_FAILED_INITIALIZATION")); + errorNames.insert(std::make_pair(5932, "ERROR_CLUSTER_NOT_INSTALLED")); + errorNames.insert(std::make_pair(5933, "ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE")); + errorNames.insert(std::make_pair(5934, "ERROR_CLUSTER_MAX_NODES_IN_CLUSTER")); + errorNames.insert(std::make_pair(5935, "ERROR_CLUSTER_TOO_MANY_NODES")); + errorNames.insert(std::make_pair(5936, "ERROR_CLUSTER_OBJECT_ALREADY_USED")); + errorNames.insert(std::make_pair(5937, "ERROR_NONCORE_GROUPS_FOUND")); + errorNames.insert(std::make_pair(5938, "ERROR_FILE_SHARE_RESOURCE_CONFLICT")); + errorNames.insert(std::make_pair(5939, "ERROR_CLUSTER_EVICT_INVALID_REQUEST")); + errorNames.insert(std::make_pair(5940, "ERROR_CLUSTER_SINGLETON_RESOURCE")); + errorNames.insert(std::make_pair(5941, "ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE")); + errorNames.insert(std::make_pair(5942, "ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED")); + errorNames.insert(std::make_pair(5943, "ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR")); + errorNames.insert(std::make_pair(5944, "ERROR_CLUSTER_GROUP_BUSY")); + errorNames.insert(std::make_pair(5945, "ERROR_CLUSTER_NOT_SHARED_VOLUME")); + errorNames.insert(std::make_pair(5946, "ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR")); + errorNames.insert(std::make_pair(5947, "ERROR_CLUSTER_SHARED_VOLUMES_IN_USE")); + errorNames.insert(std::make_pair(5948, "ERROR_CLUSTER_USE_SHARED_VOLUMES_API")); + errorNames.insert(std::make_pair(5949, "ERROR_CLUSTER_BACKUP_IN_PROGRESS")); + errorNames.insert(std::make_pair(5950, "ERROR_NON_CSV_PATH")); + errorNames.insert(std::make_pair(5951, "ERROR_CSV_VOLUME_NOT_LOCAL")); + errorNames.insert(std::make_pair(5952, "ERROR_CLUSTER_WATCHDOG_TERMINATING")); + errorNames.insert(std::make_pair(6000, "ERROR_ENCRYPTION_FAILED")); + errorNames.insert(std::make_pair(6001, "ERROR_DECRYPTION_FAILED")); + errorNames.insert(std::make_pair(6002, "ERROR_FILE_ENCRYPTED")); + errorNames.insert(std::make_pair(6003, "ERROR_NO_RECOVERY_POLICY")); + errorNames.insert(std::make_pair(6004, "ERROR_NO_EFS")); + errorNames.insert(std::make_pair(6005, "ERROR_WRONG_EFS")); + errorNames.insert(std::make_pair(6006, "ERROR_NO_USER_KEYS")); + errorNames.insert(std::make_pair(6007, "ERROR_FILE_NOT_ENCRYPTED")); + errorNames.insert(std::make_pair(6008, "ERROR_NOT_EXPORT_FORMAT")); + errorNames.insert(std::make_pair(6009, "ERROR_FILE_READ_ONLY")); + errorNames.insert(std::make_pair(6010, "ERROR_DIR_EFS_DISALLOWED")); + errorNames.insert(std::make_pair(6011, "ERROR_EFS_SERVER_NOT_TRUSTED")); + errorNames.insert(std::make_pair(6012, "ERROR_BAD_RECOVERY_POLICY")); + errorNames.insert(std::make_pair(6013, "ERROR_EFS_ALG_BLOB_TOO_BIG")); + errorNames.insert(std::make_pair(6014, "ERROR_VOLUME_NOT_SUPPORT_EFS")); + errorNames.insert(std::make_pair(6015, "ERROR_EFS_DISABLED")); + errorNames.insert(std::make_pair(6016, "ERROR_EFS_VERSION_NOT_SUPPORT")); + errorNames.insert(std::make_pair(6017, "ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE")); + errorNames.insert(std::make_pair(6018, "ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER")); + errorNames.insert(std::make_pair(6019, "ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE")); + errorNames.insert(std::make_pair(6020, "ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE")); + errorNames.insert(std::make_pair(6021, "ERROR_CS_ENCRYPTION_FILE_NOT_CSE")); + errorNames.insert(std::make_pair(6022, "ERROR_ENCRYPTION_POLICY_DENIES_OPERATION")); + errorNames.insert(std::make_pair(6118, "ERROR_NO_BROWSER_SERVERS_FOUND")); + errorNames.insert(std::make_pair(6600, "ERROR_LOG_SECTOR_INVALID")); + errorNames.insert(std::make_pair(6601, "ERROR_LOG_SECTOR_PARITY_INVALID")); + errorNames.insert(std::make_pair(6602, "ERROR_LOG_SECTOR_REMAPPED")); + errorNames.insert(std::make_pair(6603, "ERROR_LOG_BLOCK_INCOMPLETE")); + errorNames.insert(std::make_pair(6604, "ERROR_LOG_INVALID_RANGE")); + errorNames.insert(std::make_pair(6605, "ERROR_LOG_BLOCKS_EXHAUSTED")); + errorNames.insert(std::make_pair(6606, "ERROR_LOG_READ_CONTEXT_INVALID")); + errorNames.insert(std::make_pair(6607, "ERROR_LOG_RESTART_INVALID")); + errorNames.insert(std::make_pair(6608, "ERROR_LOG_BLOCK_VERSION")); + errorNames.insert(std::make_pair(6609, "ERROR_LOG_BLOCK_INVALID")); + errorNames.insert(std::make_pair(6610, "ERROR_LOG_READ_MODE_INVALID")); + errorNames.insert(std::make_pair(6611, "ERROR_LOG_NO_RESTART")); + errorNames.insert(std::make_pair(6612, "ERROR_LOG_METADATA_CORRUPT")); + errorNames.insert(std::make_pair(6613, "ERROR_LOG_METADATA_INVALID")); + errorNames.insert(std::make_pair(6614, "ERROR_LOG_METADATA_INCONSISTENT")); + errorNames.insert(std::make_pair(6615, "ERROR_LOG_RESERVATION_INVALID")); + errorNames.insert(std::make_pair(6616, "ERROR_LOG_CANT_DELETE")); + errorNames.insert(std::make_pair(6617, "ERROR_LOG_CONTAINER_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(6618, "ERROR_LOG_START_OF_LOG")); + errorNames.insert(std::make_pair(6619, "ERROR_LOG_POLICY_ALREADY_INSTALLED")); + errorNames.insert(std::make_pair(6620, "ERROR_LOG_POLICY_NOT_INSTALLED")); + errorNames.insert(std::make_pair(6621, "ERROR_LOG_POLICY_INVALID")); + errorNames.insert(std::make_pair(6622, "ERROR_LOG_POLICY_CONFLICT")); + errorNames.insert(std::make_pair(6623, "ERROR_LOG_PINNED_ARCHIVE_TAIL")); + errorNames.insert(std::make_pair(6624, "ERROR_LOG_RECORD_NONEXISTENT")); + errorNames.insert(std::make_pair(6625, "ERROR_LOG_RECORDS_RESERVED_INVALID")); + errorNames.insert(std::make_pair(6626, "ERROR_LOG_SPACE_RESERVED_INVALID")); + errorNames.insert(std::make_pair(6627, "ERROR_LOG_TAIL_INVALID")); + errorNames.insert(std::make_pair(6628, "ERROR_LOG_FULL")); + errorNames.insert(std::make_pair(6629, "ERROR_COULD_NOT_RESIZE_LOG")); + errorNames.insert(std::make_pair(6630, "ERROR_LOG_MULTIPLEXED")); + errorNames.insert(std::make_pair(6631, "ERROR_LOG_DEDICATED")); + errorNames.insert(std::make_pair(6632, "ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS")); + errorNames.insert(std::make_pair(6633, "ERROR_LOG_ARCHIVE_IN_PROGRESS")); + errorNames.insert(std::make_pair(6634, "ERROR_LOG_EPHEMERAL")); + errorNames.insert(std::make_pair(6635, "ERROR_LOG_NOT_ENOUGH_CONTAINERS")); + errorNames.insert(std::make_pair(6636, "ERROR_LOG_CLIENT_ALREADY_REGISTERED")); + errorNames.insert(std::make_pair(6637, "ERROR_LOG_CLIENT_NOT_REGISTERED")); + errorNames.insert(std::make_pair(6638, "ERROR_LOG_FULL_HANDLER_IN_PROGRESS")); + errorNames.insert(std::make_pair(6639, "ERROR_LOG_CONTAINER_READ_FAILED")); + errorNames.insert(std::make_pair(6640, "ERROR_LOG_CONTAINER_WRITE_FAILED")); + errorNames.insert(std::make_pair(6641, "ERROR_LOG_CONTAINER_OPEN_FAILED")); + errorNames.insert(std::make_pair(6642, "ERROR_LOG_CONTAINER_STATE_INVALID")); + errorNames.insert(std::make_pair(6643, "ERROR_LOG_STATE_INVALID")); + errorNames.insert(std::make_pair(6644, "ERROR_LOG_PINNED")); + errorNames.insert(std::make_pair(6645, "ERROR_LOG_METADATA_FLUSH_FAILED")); + errorNames.insert(std::make_pair(6646, "ERROR_LOG_INCONSISTENT_SECURITY")); + errorNames.insert(std::make_pair(6647, "ERROR_LOG_APPENDED_FLUSH_FAILED")); + errorNames.insert(std::make_pair(6648, "ERROR_LOG_PINNED_RESERVATION")); + errorNames.insert(std::make_pair(6700, "ERROR_INVALID_TRANSACTION")); + errorNames.insert(std::make_pair(6701, "ERROR_TRANSACTION_NOT_ACTIVE")); + errorNames.insert(std::make_pair(6702, "ERROR_TRANSACTION_REQUEST_NOT_VALID")); + errorNames.insert(std::make_pair(6703, "ERROR_TRANSACTION_NOT_REQUESTED")); + errorNames.insert(std::make_pair(6704, "ERROR_TRANSACTION_ALREADY_ABORTED")); + errorNames.insert(std::make_pair(6705, "ERROR_TRANSACTION_ALREADY_COMMITTED")); + errorNames.insert(std::make_pair(6706, "ERROR_TM_INITIALIZATION_FAILED")); + errorNames.insert(std::make_pair(6707, "ERROR_RESOURCEMANAGER_READ_ONLY")); + errorNames.insert(std::make_pair(6708, "ERROR_TRANSACTION_NOT_JOINED")); + errorNames.insert(std::make_pair(6709, "ERROR_TRANSACTION_SUPERIOR_EXISTS")); + errorNames.insert(std::make_pair(6710, "ERROR_CRM_PROTOCOL_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(6711, "ERROR_TRANSACTION_PROPAGATION_FAILED")); + errorNames.insert(std::make_pair(6712, "ERROR_CRM_PROTOCOL_NOT_FOUND")); + errorNames.insert(std::make_pair(6713, "ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER")); + errorNames.insert(std::make_pair(6714, "ERROR_CURRENT_TRANSACTION_NOT_VALID")); + errorNames.insert(std::make_pair(6715, "ERROR_TRANSACTION_NOT_FOUND")); + errorNames.insert(std::make_pair(6716, "ERROR_RESOURCEMANAGER_NOT_FOUND")); + errorNames.insert(std::make_pair(6717, "ERROR_ENLISTMENT_NOT_FOUND")); + errorNames.insert(std::make_pair(6718, "ERROR_TRANSACTIONMANAGER_NOT_FOUND")); + errorNames.insert(std::make_pair(6719, "ERROR_TRANSACTIONMANAGER_NOT_ONLINE")); + errorNames.insert(std::make_pair(6720, "ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION")); + errorNames.insert(std::make_pair(6721, "ERROR_TRANSACTION_NOT_ROOT")); + errorNames.insert(std::make_pair(6722, "ERROR_TRANSACTION_OBJECT_EXPIRED")); + errorNames.insert(std::make_pair(6723, "ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED")); + errorNames.insert(std::make_pair(6724, "ERROR_TRANSACTION_RECORD_TOO_LONG")); + errorNames.insert(std::make_pair(6725, "ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(6726, "ERROR_TRANSACTION_INTEGRITY_VIOLATED")); + errorNames.insert(std::make_pair(6727, "ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH")); + errorNames.insert(std::make_pair(6728, "ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT")); + errorNames.insert(std::make_pair(6729, "ERROR_TRANSACTION_MUST_WRITETHROUGH")); + errorNames.insert(std::make_pair(6730, "ERROR_TRANSACTION_NO_SUPERIOR")); + errorNames.insert(std::make_pair(6731, "ERROR_HEURISTIC_DAMAGE_POSSIBLE")); + errorNames.insert(std::make_pair(6800, "ERROR_TRANSACTIONAL_CONFLICT")); + errorNames.insert(std::make_pair(6801, "ERROR_RM_NOT_ACTIVE")); + errorNames.insert(std::make_pair(6802, "ERROR_RM_METADATA_CORRUPT")); + errorNames.insert(std::make_pair(6803, "ERROR_DIRECTORY_NOT_RM")); + errorNames.insert(std::make_pair(6805, "ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE")); + errorNames.insert(std::make_pair(6806, "ERROR_LOG_RESIZE_INVALID_SIZE")); + errorNames.insert(std::make_pair(6807, "ERROR_OBJECT_NO_LONGER_EXISTS")); + errorNames.insert(std::make_pair(6808, "ERROR_STREAM_MINIVERSION_NOT_FOUND")); + errorNames.insert(std::make_pair(6809, "ERROR_STREAM_MINIVERSION_NOT_VALID")); + errorNames.insert(std::make_pair(6810, "ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION")); + errorNames.insert(std::make_pair(6811, "ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT")); + errorNames.insert(std::make_pair(6812, "ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS")); + errorNames.insert(std::make_pair(6814, "ERROR_REMOTE_FILE_VERSION_MISMATCH")); + errorNames.insert(std::make_pair(6815, "ERROR_HANDLE_NO_LONGER_VALID")); + errorNames.insert(std::make_pair(6816, "ERROR_NO_TXF_METADATA")); + errorNames.insert(std::make_pair(6817, "ERROR_LOG_CORRUPTION_DETECTED")); + errorNames.insert(std::make_pair(6818, "ERROR_CANT_RECOVER_WITH_HANDLE_OPEN")); + errorNames.insert(std::make_pair(6819, "ERROR_RM_DISCONNECTED")); + errorNames.insert(std::make_pair(6820, "ERROR_ENLISTMENT_NOT_SUPERIOR")); + errorNames.insert(std::make_pair(6821, "ERROR_RECOVERY_NOT_NEEDED")); + errorNames.insert(std::make_pair(6822, "ERROR_RM_ALREADY_STARTED")); + errorNames.insert(std::make_pair(6823, "ERROR_FILE_IDENTITY_NOT_PERSISTENT")); + errorNames.insert(std::make_pair(6824, "ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY")); + errorNames.insert(std::make_pair(6825, "ERROR_CANT_CROSS_RM_BOUNDARY")); + errorNames.insert(std::make_pair(6826, "ERROR_TXF_DIR_NOT_EMPTY")); + errorNames.insert(std::make_pair(6827, "ERROR_INDOUBT_TRANSACTIONS_EXIST")); + errorNames.insert(std::make_pair(6828, "ERROR_TM_VOLATILE")); + errorNames.insert(std::make_pair(6829, "ERROR_ROLLBACK_TIMER_EXPIRED")); + errorNames.insert(std::make_pair(6830, "ERROR_TXF_ATTRIBUTE_CORRUPT")); + errorNames.insert(std::make_pair(6831, "ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6832, "ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED")); + errorNames.insert(std::make_pair(6833, "ERROR_LOG_GROWTH_FAILED")); + errorNames.insert(std::make_pair(6834, "ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE")); + errorNames.insert(std::make_pair(6835, "ERROR_TXF_METADATA_ALREADY_PRESENT")); + errorNames.insert(std::make_pair(6836, "ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET")); + errorNames.insert(std::make_pair(6837, "ERROR_TRANSACTION_REQUIRED_PROMOTION")); + errorNames.insert(std::make_pair(6838, "ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6839, "ERROR_TRANSACTIONS_NOT_FROZEN")); + errorNames.insert(std::make_pair(6840, "ERROR_TRANSACTION_FREEZE_IN_PROGRESS")); + errorNames.insert(std::make_pair(6841, "ERROR_NOT_SNAPSHOT_VOLUME")); + errorNames.insert(std::make_pair(6842, "ERROR_NO_SAVEPOINT_WITH_OPEN_FILES")); + errorNames.insert(std::make_pair(6843, "ERROR_DATA_LOST_REPAIR")); + errorNames.insert(std::make_pair(6844, "ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6845, "ERROR_TM_IDENTITY_MISMATCH")); + errorNames.insert(std::make_pair(6846, "ERROR_FLOATED_SECTION")); + errorNames.insert(std::make_pair(6847, "ERROR_CANNOT_ACCEPT_TRANSACTED_WORK")); + errorNames.insert(std::make_pair(6848, "ERROR_CANNOT_ABORT_TRANSACTIONS")); + errorNames.insert(std::make_pair(6849, "ERROR_BAD_CLUSTERS")); + errorNames.insert(std::make_pair(6850, "ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6851, "ERROR_VOLUME_DIRTY")); + errorNames.insert(std::make_pair(6852, "ERROR_NO_LINK_TRACKING_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6853, "ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION")); + errorNames.insert(std::make_pair(6854, "ERROR_EXPIRED_HANDLE")); + errorNames.insert(std::make_pair(6855, "ERROR_TRANSACTION_NOT_ENLISTED")); + errorNames.insert(std::make_pair(7001, "ERROR_CTX_WINSTATION_NAME_INVALID")); + errorNames.insert(std::make_pair(7002, "ERROR_CTX_INVALID_PD")); + errorNames.insert(std::make_pair(7003, "ERROR_CTX_PD_NOT_FOUND")); + errorNames.insert(std::make_pair(7004, "ERROR_CTX_WD_NOT_FOUND")); + errorNames.insert(std::make_pair(7005, "ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY")); + errorNames.insert(std::make_pair(7006, "ERROR_CTX_SERVICE_NAME_COLLISION")); + errorNames.insert(std::make_pair(7007, "ERROR_CTX_CLOSE_PENDING")); + errorNames.insert(std::make_pair(7008, "ERROR_CTX_NO_OUTBUF")); + errorNames.insert(std::make_pair(7009, "ERROR_CTX_MODEM_INF_NOT_FOUND")); + errorNames.insert(std::make_pair(7010, "ERROR_CTX_INVALID_MODEMNAME")); + errorNames.insert(std::make_pair(7011, "ERROR_CTX_MODEM_RESPONSE_ERROR")); + errorNames.insert(std::make_pair(7012, "ERROR_CTX_MODEM_RESPONSE_TIMEOUT")); + errorNames.insert(std::make_pair(7013, "ERROR_CTX_MODEM_RESPONSE_NO_CARRIER")); + errorNames.insert(std::make_pair(7014, "ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE")); + errorNames.insert(std::make_pair(7015, "ERROR_CTX_MODEM_RESPONSE_BUSY")); + errorNames.insert(std::make_pair(7016, "ERROR_CTX_MODEM_RESPONSE_VOICE")); + errorNames.insert(std::make_pair(7017, "ERROR_CTX_TD_ERROR")); + errorNames.insert(std::make_pair(7022, "ERROR_CTX_WINSTATION_NOT_FOUND")); + errorNames.insert(std::make_pair(7023, "ERROR_CTX_WINSTATION_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(7024, "ERROR_CTX_WINSTATION_BUSY")); + errorNames.insert(std::make_pair(7025, "ERROR_CTX_BAD_VIDEO_MODE")); + errorNames.insert(std::make_pair(7035, "ERROR_CTX_GRAPHICS_INVALID")); + errorNames.insert(std::make_pair(7037, "ERROR_CTX_LOGON_DISABLED")); + errorNames.insert(std::make_pair(7038, "ERROR_CTX_NOT_CONSOLE")); + errorNames.insert(std::make_pair(7040, "ERROR_CTX_CLIENT_QUERY_TIMEOUT")); + errorNames.insert(std::make_pair(7041, "ERROR_CTX_CONSOLE_DISCONNECT")); + errorNames.insert(std::make_pair(7042, "ERROR_CTX_CONSOLE_CONNECT")); + errorNames.insert(std::make_pair(7044, "ERROR_CTX_SHADOW_DENIED")); + errorNames.insert(std::make_pair(7045, "ERROR_CTX_WINSTATION_ACCESS_DENIED")); + errorNames.insert(std::make_pair(7049, "ERROR_CTX_INVALID_WD")); + errorNames.insert(std::make_pair(7050, "ERROR_CTX_SHADOW_INVALID")); + errorNames.insert(std::make_pair(7051, "ERROR_CTX_SHADOW_DISABLED")); + errorNames.insert(std::make_pair(7052, "ERROR_CTX_CLIENT_LICENSE_IN_USE")); + errorNames.insert(std::make_pair(7053, "ERROR_CTX_CLIENT_LICENSE_NOT_SET")); + errorNames.insert(std::make_pair(7054, "ERROR_CTX_LICENSE_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(7055, "ERROR_CTX_LICENSE_CLIENT_INVALID")); + errorNames.insert(std::make_pair(7056, "ERROR_CTX_LICENSE_EXPIRED")); + errorNames.insert(std::make_pair(7057, "ERROR_CTX_SHADOW_NOT_RUNNING")); + errorNames.insert(std::make_pair(7058, "ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE")); + errorNames.insert(std::make_pair(7059, "ERROR_ACTIVATION_COUNT_EXCEEDED")); + errorNames.insert(std::make_pair(7060, "ERROR_CTX_WINSTATIONS_DISABLED")); + errorNames.insert(std::make_pair(7061, "ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED")); + errorNames.insert(std::make_pair(7062, "ERROR_CTX_SESSION_IN_USE")); + errorNames.insert(std::make_pair(7063, "ERROR_CTX_NO_FORCE_LOGOFF")); + errorNames.insert(std::make_pair(7064, "ERROR_CTX_ACCOUNT_RESTRICTION")); + errorNames.insert(std::make_pair(7065, "ERROR_RDP_PROTOCOL_ERROR")); + errorNames.insert(std::make_pair(7066, "ERROR_CTX_CDM_CONNECT")); + errorNames.insert(std::make_pair(7067, "ERROR_CTX_CDM_DISCONNECT")); + errorNames.insert(std::make_pair(7068, "ERROR_CTX_SECURITY_LAYER_ERROR")); + errorNames.insert(std::make_pair(7069, "ERROR_TS_INCOMPATIBLE_SESSIONS")); + errorNames.insert(std::make_pair(7070, "ERROR_TS_VIDEO_SUBSYSTEM_ERROR")); + errorNames.insert(std::make_pair(8200, "ERROR_DS_NOT_INSTALLED")); + errorNames.insert(std::make_pair(8201, "ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY")); + errorNames.insert(std::make_pair(8202, "ERROR_DS_NO_ATTRIBUTE_OR_VALUE")); + errorNames.insert(std::make_pair(8203, "ERROR_DS_INVALID_ATTRIBUTE_SYNTAX")); + errorNames.insert(std::make_pair(8204, "ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED")); + errorNames.insert(std::make_pair(8205, "ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS")); + errorNames.insert(std::make_pair(8206, "ERROR_DS_BUSY")); + errorNames.insert(std::make_pair(8207, "ERROR_DS_UNAVAILABLE")); + errorNames.insert(std::make_pair(8208, "ERROR_DS_NO_RIDS_ALLOCATED")); + errorNames.insert(std::make_pair(8209, "ERROR_DS_NO_MORE_RIDS")); + errorNames.insert(std::make_pair(8210, "ERROR_DS_INCORRECT_ROLE_OWNER")); + errorNames.insert(std::make_pair(8211, "ERROR_DS_RIDMGR_INIT_ERROR")); + errorNames.insert(std::make_pair(8212, "ERROR_DS_OBJ_CLASS_VIOLATION")); + errorNames.insert(std::make_pair(8213, "ERROR_DS_CANT_ON_NON_LEAF")); + errorNames.insert(std::make_pair(8214, "ERROR_DS_CANT_ON_RDN")); + errorNames.insert(std::make_pair(8215, "ERROR_DS_CANT_MOD_OBJ_CLASS")); + errorNames.insert(std::make_pair(8216, "ERROR_DS_CROSS_DOM_MOVE_ERROR")); + errorNames.insert(std::make_pair(8217, "ERROR_DS_GC_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(8218, "ERROR_SHARED_POLICY")); + errorNames.insert(std::make_pair(8219, "ERROR_POLICY_OBJECT_NOT_FOUND")); + errorNames.insert(std::make_pair(8220, "ERROR_POLICY_ONLY_IN_DS")); + errorNames.insert(std::make_pair(8221, "ERROR_PROMOTION_ACTIVE")); + errorNames.insert(std::make_pair(8222, "ERROR_NO_PROMOTION_ACTIVE")); + errorNames.insert(std::make_pair(8224, "ERROR_DS_OPERATIONS_ERROR")); + errorNames.insert(std::make_pair(8225, "ERROR_DS_PROTOCOL_ERROR")); + errorNames.insert(std::make_pair(8226, "ERROR_DS_TIMELIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8227, "ERROR_DS_SIZELIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8228, "ERROR_DS_ADMIN_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8229, "ERROR_DS_COMPARE_FALSE")); + errorNames.insert(std::make_pair(8230, "ERROR_DS_COMPARE_TRUE")); + errorNames.insert(std::make_pair(8231, "ERROR_DS_AUTH_METHOD_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(8232, "ERROR_DS_STRONG_AUTH_REQUIRED")); + errorNames.insert(std::make_pair(8233, "ERROR_DS_INAPPROPRIATE_AUTH")); + errorNames.insert(std::make_pair(8234, "ERROR_DS_AUTH_UNKNOWN")); + errorNames.insert(std::make_pair(8235, "ERROR_DS_REFERRAL")); + errorNames.insert(std::make_pair(8236, "ERROR_DS_UNAVAILABLE_CRIT_EXTENSION")); + errorNames.insert(std::make_pair(8237, "ERROR_DS_CONFIDENTIALITY_REQUIRED")); + errorNames.insert(std::make_pair(8238, "ERROR_DS_INAPPROPRIATE_MATCHING")); + errorNames.insert(std::make_pair(8239, "ERROR_DS_CONSTRAINT_VIOLATION")); + errorNames.insert(std::make_pair(8240, "ERROR_DS_NO_SUCH_OBJECT")); + errorNames.insert(std::make_pair(8241, "ERROR_DS_ALIAS_PROBLEM")); + errorNames.insert(std::make_pair(8242, "ERROR_DS_INVALID_DN_SYNTAX")); + errorNames.insert(std::make_pair(8243, "ERROR_DS_IS_LEAF")); + errorNames.insert(std::make_pair(8244, "ERROR_DS_ALIAS_DEREF_PROBLEM")); + errorNames.insert(std::make_pair(8245, "ERROR_DS_UNWILLING_TO_PERFORM")); + errorNames.insert(std::make_pair(8246, "ERROR_DS_LOOP_DETECT")); + errorNames.insert(std::make_pair(8247, "ERROR_DS_NAMING_VIOLATION")); + errorNames.insert(std::make_pair(8248, "ERROR_DS_OBJECT_RESULTS_TOO_LARGE")); + errorNames.insert(std::make_pair(8249, "ERROR_DS_AFFECTS_MULTIPLE_DSAS")); + errorNames.insert(std::make_pair(8250, "ERROR_DS_SERVER_DOWN")); + errorNames.insert(std::make_pair(8251, "ERROR_DS_LOCAL_ERROR")); + errorNames.insert(std::make_pair(8252, "ERROR_DS_ENCODING_ERROR")); + errorNames.insert(std::make_pair(8253, "ERROR_DS_DECODING_ERROR")); + errorNames.insert(std::make_pair(8254, "ERROR_DS_FILTER_UNKNOWN")); + errorNames.insert(std::make_pair(8255, "ERROR_DS_PARAM_ERROR")); + errorNames.insert(std::make_pair(8256, "ERROR_DS_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(8257, "ERROR_DS_NO_RESULTS_RETURNED")); + errorNames.insert(std::make_pair(8258, "ERROR_DS_CONTROL_NOT_FOUND")); + errorNames.insert(std::make_pair(8259, "ERROR_DS_CLIENT_LOOP")); + errorNames.insert(std::make_pair(8260, "ERROR_DS_REFERRAL_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8261, "ERROR_DS_SORT_CONTROL_MISSING")); + errorNames.insert(std::make_pair(8262, "ERROR_DS_OFFSET_RANGE_ERROR")); + errorNames.insert(std::make_pair(8301, "ERROR_DS_ROOT_MUST_BE_NC")); + errorNames.insert(std::make_pair(8302, "ERROR_DS_ADD_REPLICA_INHIBITED")); + errorNames.insert(std::make_pair(8303, "ERROR_DS_ATT_NOT_DEF_IN_SCHEMA")); + errorNames.insert(std::make_pair(8304, "ERROR_DS_MAX_OBJ_SIZE_EXCEEDED")); + errorNames.insert(std::make_pair(8305, "ERROR_DS_OBJ_STRING_NAME_EXISTS")); + errorNames.insert(std::make_pair(8306, "ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA")); + errorNames.insert(std::make_pair(8307, "ERROR_DS_RDN_DOESNT_MATCH_SCHEMA")); + errorNames.insert(std::make_pair(8308, "ERROR_DS_NO_REQUESTED_ATTS_FOUND")); + errorNames.insert(std::make_pair(8309, "ERROR_DS_USER_BUFFER_TO_SMALL")); + errorNames.insert(std::make_pair(8310, "ERROR_DS_ATT_IS_NOT_ON_OBJ")); + errorNames.insert(std::make_pair(8311, "ERROR_DS_ILLEGAL_MOD_OPERATION")); + errorNames.insert(std::make_pair(8312, "ERROR_DS_OBJ_TOO_LARGE")); + errorNames.insert(std::make_pair(8313, "ERROR_DS_BAD_INSTANCE_TYPE")); + errorNames.insert(std::make_pair(8314, "ERROR_DS_MASTERDSA_REQUIRED")); + errorNames.insert(std::make_pair(8315, "ERROR_DS_OBJECT_CLASS_REQUIRED")); + errorNames.insert(std::make_pair(8316, "ERROR_DS_MISSING_REQUIRED_ATT")); + errorNames.insert(std::make_pair(8317, "ERROR_DS_ATT_NOT_DEF_FOR_CLASS")); + errorNames.insert(std::make_pair(8318, "ERROR_DS_ATT_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(8320, "ERROR_DS_CANT_ADD_ATT_VALUES")); + errorNames.insert(std::make_pair(8321, "ERROR_DS_SINGLE_VALUE_CONSTRAINT")); + errorNames.insert(std::make_pair(8322, "ERROR_DS_RANGE_CONSTRAINT")); + errorNames.insert(std::make_pair(8323, "ERROR_DS_ATT_VAL_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(8324, "ERROR_DS_CANT_REM_MISSING_ATT")); + errorNames.insert(std::make_pair(8325, "ERROR_DS_CANT_REM_MISSING_ATT_VAL")); + errorNames.insert(std::make_pair(8326, "ERROR_DS_ROOT_CANT_BE_SUBREF")); + errorNames.insert(std::make_pair(8327, "ERROR_DS_NO_CHAINING")); + errorNames.insert(std::make_pair(8328, "ERROR_DS_NO_CHAINED_EVAL")); + errorNames.insert(std::make_pair(8329, "ERROR_DS_NO_PARENT_OBJECT")); + errorNames.insert(std::make_pair(8330, "ERROR_DS_PARENT_IS_AN_ALIAS")); + errorNames.insert(std::make_pair(8331, "ERROR_DS_CANT_MIX_MASTER_AND_REPS")); + errorNames.insert(std::make_pair(8332, "ERROR_DS_CHILDREN_EXIST")); + errorNames.insert(std::make_pair(8333, "ERROR_DS_OBJ_NOT_FOUND")); + errorNames.insert(std::make_pair(8334, "ERROR_DS_ALIASED_OBJ_MISSING")); + errorNames.insert(std::make_pair(8335, "ERROR_DS_BAD_NAME_SYNTAX")); + errorNames.insert(std::make_pair(8336, "ERROR_DS_ALIAS_POINTS_TO_ALIAS")); + errorNames.insert(std::make_pair(8337, "ERROR_DS_CANT_DEREF_ALIAS")); + errorNames.insert(std::make_pair(8338, "ERROR_DS_OUT_OF_SCOPE")); + errorNames.insert(std::make_pair(8339, "ERROR_DS_OBJECT_BEING_REMOVED")); + errorNames.insert(std::make_pair(8340, "ERROR_DS_CANT_DELETE_DSA_OBJ")); + errorNames.insert(std::make_pair(8341, "ERROR_DS_GENERIC_ERROR")); + errorNames.insert(std::make_pair(8342, "ERROR_DS_DSA_MUST_BE_INT_MASTER")); + errorNames.insert(std::make_pair(8343, "ERROR_DS_CLASS_NOT_DSA")); + errorNames.insert(std::make_pair(8344, "ERROR_DS_INSUFF_ACCESS_RIGHTS")); + errorNames.insert(std::make_pair(8345, "ERROR_DS_ILLEGAL_SUPERIOR")); + errorNames.insert(std::make_pair(8346, "ERROR_DS_ATTRIBUTE_OWNED_BY_SAM")); + errorNames.insert(std::make_pair(8347, "ERROR_DS_NAME_TOO_MANY_PARTS")); + errorNames.insert(std::make_pair(8348, "ERROR_DS_NAME_TOO_LONG")); + errorNames.insert(std::make_pair(8349, "ERROR_DS_NAME_VALUE_TOO_LONG")); + errorNames.insert(std::make_pair(8350, "ERROR_DS_NAME_UNPARSEABLE")); + errorNames.insert(std::make_pair(8351, "ERROR_DS_NAME_TYPE_UNKNOWN")); + errorNames.insert(std::make_pair(8352, "ERROR_DS_NOT_AN_OBJECT")); + errorNames.insert(std::make_pair(8353, "ERROR_DS_SEC_DESC_TOO_SHORT")); + errorNames.insert(std::make_pair(8354, "ERROR_DS_SEC_DESC_INVALID")); + errorNames.insert(std::make_pair(8355, "ERROR_DS_NO_DELETED_NAME")); + errorNames.insert(std::make_pair(8356, "ERROR_DS_SUBREF_MUST_HAVE_PARENT")); + errorNames.insert(std::make_pair(8357, "ERROR_DS_NCNAME_MUST_BE_NC")); + errorNames.insert(std::make_pair(8358, "ERROR_DS_CANT_ADD_SYSTEM_ONLY")); + errorNames.insert(std::make_pair(8359, "ERROR_DS_CLASS_MUST_BE_CONCRETE")); + errorNames.insert(std::make_pair(8360, "ERROR_DS_INVALID_DMD")); + errorNames.insert(std::make_pair(8361, "ERROR_DS_OBJ_GUID_EXISTS")); + errorNames.insert(std::make_pair(8362, "ERROR_DS_NOT_ON_BACKLINK")); + errorNames.insert(std::make_pair(8363, "ERROR_DS_NO_CROSSREF_FOR_NC")); + errorNames.insert(std::make_pair(8364, "ERROR_DS_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(8365, "ERROR_DS_UNKNOWN_OPERATION")); + errorNames.insert(std::make_pair(8366, "ERROR_DS_INVALID_ROLE_OWNER")); + errorNames.insert(std::make_pair(8367, "ERROR_DS_COULDNT_CONTACT_FSMO")); + errorNames.insert(std::make_pair(8368, "ERROR_DS_CROSS_NC_DN_RENAME")); + errorNames.insert(std::make_pair(8369, "ERROR_DS_CANT_MOD_SYSTEM_ONLY")); + errorNames.insert(std::make_pair(8370, "ERROR_DS_REPLICATOR_ONLY")); + errorNames.insert(std::make_pair(8371, "ERROR_DS_OBJ_CLASS_NOT_DEFINED")); + errorNames.insert(std::make_pair(8372, "ERROR_DS_OBJ_CLASS_NOT_SUBCLASS")); + errorNames.insert(std::make_pair(8373, "ERROR_DS_NAME_REFERENCE_INVALID")); + errorNames.insert(std::make_pair(8374, "ERROR_DS_CROSS_REF_EXISTS")); + errorNames.insert(std::make_pair(8375, "ERROR_DS_CANT_DEL_MASTER_CROSSREF")); + errorNames.insert(std::make_pair(8376, "ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD")); + errorNames.insert(std::make_pair(8377, "ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX")); + errorNames.insert(std::make_pair(8378, "ERROR_DS_DUP_RDN")); + errorNames.insert(std::make_pair(8379, "ERROR_DS_DUP_OID")); + errorNames.insert(std::make_pair(8380, "ERROR_DS_DUP_MAPI_ID")); + errorNames.insert(std::make_pair(8381, "ERROR_DS_DUP_SCHEMA_ID_GUID")); + errorNames.insert(std::make_pair(8382, "ERROR_DS_DUP_LDAP_DISPLAY_NAME")); + errorNames.insert(std::make_pair(8383, "ERROR_DS_SEMANTIC_ATT_TEST")); + errorNames.insert(std::make_pair(8384, "ERROR_DS_SYNTAX_MISMATCH")); + errorNames.insert(std::make_pair(8385, "ERROR_DS_EXISTS_IN_MUST_HAVE")); + errorNames.insert(std::make_pair(8386, "ERROR_DS_EXISTS_IN_MAY_HAVE")); + errorNames.insert(std::make_pair(8387, "ERROR_DS_NONEXISTENT_MAY_HAVE")); + errorNames.insert(std::make_pair(8388, "ERROR_DS_NONEXISTENT_MUST_HAVE")); + errorNames.insert(std::make_pair(8389, "ERROR_DS_AUX_CLS_TEST_FAIL")); + errorNames.insert(std::make_pair(8390, "ERROR_DS_NONEXISTENT_POSS_SUP")); + errorNames.insert(std::make_pair(8391, "ERROR_DS_SUB_CLS_TEST_FAIL")); + errorNames.insert(std::make_pair(8392, "ERROR_DS_BAD_RDN_ATT_ID_SYNTAX")); + errorNames.insert(std::make_pair(8393, "ERROR_DS_EXISTS_IN_AUX_CLS")); + errorNames.insert(std::make_pair(8394, "ERROR_DS_EXISTS_IN_SUB_CLS")); + errorNames.insert(std::make_pair(8395, "ERROR_DS_EXISTS_IN_POSS_SUP")); + errorNames.insert(std::make_pair(8396, "ERROR_DS_RECALCSCHEMA_FAILED")); + errorNames.insert(std::make_pair(8397, "ERROR_DS_TREE_DELETE_NOT_FINISHED")); + errorNames.insert(std::make_pair(8398, "ERROR_DS_CANT_DELETE")); + errorNames.insert(std::make_pair(8399, "ERROR_DS_ATT_SCHEMA_REQ_ID")); + errorNames.insert(std::make_pair(8400, "ERROR_DS_BAD_ATT_SCHEMA_SYNTAX")); + errorNames.insert(std::make_pair(8401, "ERROR_DS_CANT_CACHE_ATT")); + errorNames.insert(std::make_pair(8402, "ERROR_DS_CANT_CACHE_CLASS")); + errorNames.insert(std::make_pair(8403, "ERROR_DS_CANT_REMOVE_ATT_CACHE")); + errorNames.insert(std::make_pair(8404, "ERROR_DS_CANT_REMOVE_CLASS_CACHE")); + errorNames.insert(std::make_pair(8405, "ERROR_DS_CANT_RETRIEVE_DN")); + errorNames.insert(std::make_pair(8406, "ERROR_DS_MISSING_SUPREF")); + errorNames.insert(std::make_pair(8407, "ERROR_DS_CANT_RETRIEVE_INSTANCE")); + errorNames.insert(std::make_pair(8408, "ERROR_DS_CODE_INCONSISTENCY")); + errorNames.insert(std::make_pair(8409, "ERROR_DS_DATABASE_ERROR")); + errorNames.insert(std::make_pair(8410, "ERROR_DS_GOVERNSID_MISSING")); + errorNames.insert(std::make_pair(8411, "ERROR_DS_MISSING_EXPECTED_ATT")); + errorNames.insert(std::make_pair(8412, "ERROR_DS_NCNAME_MISSING_CR_REF")); + errorNames.insert(std::make_pair(8413, "ERROR_DS_SECURITY_CHECKING_ERROR")); + errorNames.insert(std::make_pair(8414, "ERROR_DS_SCHEMA_NOT_LOADED")); + errorNames.insert(std::make_pair(8415, "ERROR_DS_SCHEMA_ALLOC_FAILED")); + errorNames.insert(std::make_pair(8416, "ERROR_DS_ATT_SCHEMA_REQ_SYNTAX")); + errorNames.insert(std::make_pair(8417, "ERROR_DS_GCVERIFY_ERROR")); + errorNames.insert(std::make_pair(8418, "ERROR_DS_DRA_SCHEMA_MISMATCH")); + errorNames.insert(std::make_pair(8419, "ERROR_DS_CANT_FIND_DSA_OBJ")); + errorNames.insert(std::make_pair(8420, "ERROR_DS_CANT_FIND_EXPECTED_NC")); + errorNames.insert(std::make_pair(8421, "ERROR_DS_CANT_FIND_NC_IN_CACHE")); + errorNames.insert(std::make_pair(8422, "ERROR_DS_CANT_RETRIEVE_CHILD")); + errorNames.insert(std::make_pair(8423, "ERROR_DS_SECURITY_ILLEGAL_MODIFY")); + errorNames.insert(std::make_pair(8424, "ERROR_DS_CANT_REPLACE_HIDDEN_REC")); + errorNames.insert(std::make_pair(8425, "ERROR_DS_BAD_HIERARCHY_FILE")); + errorNames.insert(std::make_pair(8426, "ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED")); + errorNames.insert(std::make_pair(8427, "ERROR_DS_CONFIG_PARAM_MISSING")); + errorNames.insert(std::make_pair(8428, "ERROR_DS_COUNTING_AB_INDICES_FAILED")); + errorNames.insert(std::make_pair(8429, "ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED")); + errorNames.insert(std::make_pair(8430, "ERROR_DS_INTERNAL_FAILURE")); + errorNames.insert(std::make_pair(8431, "ERROR_DS_UNKNOWN_ERROR")); + errorNames.insert(std::make_pair(8432, "ERROR_DS_ROOT_REQUIRES_CLASS_TOP")); + errorNames.insert(std::make_pair(8433, "ERROR_DS_REFUSING_FSMO_ROLES")); + errorNames.insert(std::make_pair(8434, "ERROR_DS_MISSING_FSMO_SETTINGS")); + errorNames.insert(std::make_pair(8435, "ERROR_DS_UNABLE_TO_SURRENDER_ROLES")); + errorNames.insert(std::make_pair(8436, "ERROR_DS_DRA_GENERIC")); + errorNames.insert(std::make_pair(8437, "ERROR_DS_DRA_INVALID_PARAMETER")); + errorNames.insert(std::make_pair(8438, "ERROR_DS_DRA_BUSY")); + errorNames.insert(std::make_pair(8439, "ERROR_DS_DRA_BAD_DN")); + errorNames.insert(std::make_pair(8440, "ERROR_DS_DRA_BAD_NC")); + errorNames.insert(std::make_pair(8441, "ERROR_DS_DRA_DN_EXISTS")); + errorNames.insert(std::make_pair(8442, "ERROR_DS_DRA_INTERNAL_ERROR")); + errorNames.insert(std::make_pair(8443, "ERROR_DS_DRA_INCONSISTENT_DIT")); + errorNames.insert(std::make_pair(8444, "ERROR_DS_DRA_CONNECTION_FAILED")); + errorNames.insert(std::make_pair(8445, "ERROR_DS_DRA_BAD_INSTANCE_TYPE")); + errorNames.insert(std::make_pair(8446, "ERROR_DS_DRA_OUT_OF_MEM")); + errorNames.insert(std::make_pair(8447, "ERROR_DS_DRA_MAIL_PROBLEM")); + errorNames.insert(std::make_pair(8448, "ERROR_DS_DRA_REF_ALREADY_EXISTS")); + errorNames.insert(std::make_pair(8449, "ERROR_DS_DRA_REF_NOT_FOUND")); + errorNames.insert(std::make_pair(8450, "ERROR_DS_DRA_OBJ_IS_REP_SOURCE")); + errorNames.insert(std::make_pair(8451, "ERROR_DS_DRA_DB_ERROR")); + errorNames.insert(std::make_pair(8452, "ERROR_DS_DRA_NO_REPLICA")); + errorNames.insert(std::make_pair(8453, "ERROR_DS_DRA_ACCESS_DENIED")); + errorNames.insert(std::make_pair(8454, "ERROR_DS_DRA_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(8455, "ERROR_DS_DRA_RPC_CANCELLED")); + errorNames.insert(std::make_pair(8456, "ERROR_DS_DRA_SOURCE_DISABLED")); + errorNames.insert(std::make_pair(8457, "ERROR_DS_DRA_SINK_DISABLED")); + errorNames.insert(std::make_pair(8458, "ERROR_DS_DRA_NAME_COLLISION")); + errorNames.insert(std::make_pair(8459, "ERROR_DS_DRA_SOURCE_REINSTALLED")); + errorNames.insert(std::make_pair(8460, "ERROR_DS_DRA_MISSING_PARENT")); + errorNames.insert(std::make_pair(8461, "ERROR_DS_DRA_PREEMPTED")); + errorNames.insert(std::make_pair(8462, "ERROR_DS_DRA_ABANDON_SYNC")); + errorNames.insert(std::make_pair(8463, "ERROR_DS_DRA_SHUTDOWN")); + errorNames.insert(std::make_pair(8464, "ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET")); + errorNames.insert(std::make_pair(8465, "ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA")); + errorNames.insert(std::make_pair(8466, "ERROR_DS_DRA_EXTN_CONNECTION_FAILED")); + errorNames.insert(std::make_pair(8467, "ERROR_DS_INSTALL_SCHEMA_MISMATCH")); + errorNames.insert(std::make_pair(8468, "ERROR_DS_DUP_LINK_ID")); + errorNames.insert(std::make_pair(8469, "ERROR_DS_NAME_ERROR_RESOLVING")); + errorNames.insert(std::make_pair(8470, "ERROR_DS_NAME_ERROR_NOT_FOUND")); + errorNames.insert(std::make_pair(8471, "ERROR_DS_NAME_ERROR_NOT_UNIQUE")); + errorNames.insert(std::make_pair(8472, "ERROR_DS_NAME_ERROR_NO_MAPPING")); + errorNames.insert(std::make_pair(8473, "ERROR_DS_NAME_ERROR_DOMAIN_ONLY")); + errorNames.insert(std::make_pair(8474, "ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING")); + errorNames.insert(std::make_pair(8475, "ERROR_DS_CONSTRUCTED_ATT_MOD")); + errorNames.insert(std::make_pair(8476, "ERROR_DS_WRONG_OM_OBJ_CLASS")); + errorNames.insert(std::make_pair(8477, "ERROR_DS_DRA_REPL_PENDING")); + errorNames.insert(std::make_pair(8478, "ERROR_DS_DS_REQUIRED")); + errorNames.insert(std::make_pair(8479, "ERROR_DS_INVALID_LDAP_DISPLAY_NAME")); + errorNames.insert(std::make_pair(8480, "ERROR_DS_NON_BASE_SEARCH")); + errorNames.insert(std::make_pair(8481, "ERROR_DS_CANT_RETRIEVE_ATTS")); + errorNames.insert(std::make_pair(8482, "ERROR_DS_BACKLINK_WITHOUT_LINK")); + errorNames.insert(std::make_pair(8483, "ERROR_DS_EPOCH_MISMATCH")); + errorNames.insert(std::make_pair(8484, "ERROR_DS_SRC_NAME_MISMATCH")); + errorNames.insert(std::make_pair(8485, "ERROR_DS_SRC_AND_DST_NC_IDENTICAL")); + errorNames.insert(std::make_pair(8486, "ERROR_DS_DST_NC_MISMATCH")); + errorNames.insert(std::make_pair(8487, "ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC")); + errorNames.insert(std::make_pair(8488, "ERROR_DS_SRC_GUID_MISMATCH")); + errorNames.insert(std::make_pair(8489, "ERROR_DS_CANT_MOVE_DELETED_OBJECT")); + errorNames.insert(std::make_pair(8490, "ERROR_DS_PDC_OPERATION_IN_PROGRESS")); + errorNames.insert(std::make_pair(8491, "ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD")); + errorNames.insert(std::make_pair(8492, "ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION")); + errorNames.insert(std::make_pair(8493, "ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS")); + errorNames.insert(std::make_pair(8494, "ERROR_DS_NC_MUST_HAVE_NC_PARENT")); + errorNames.insert(std::make_pair(8495, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE")); + errorNames.insert(std::make_pair(8496, "ERROR_DS_DST_DOMAIN_NOT_NATIVE")); + errorNames.insert(std::make_pair(8497, "ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER")); + errorNames.insert(std::make_pair(8498, "ERROR_DS_CANT_MOVE_ACCOUNT_GROUP")); + errorNames.insert(std::make_pair(8499, "ERROR_DS_CANT_MOVE_RESOURCE_GROUP")); + errorNames.insert(std::make_pair(8500, "ERROR_DS_INVALID_SEARCH_FLAG")); + errorNames.insert(std::make_pair(8501, "ERROR_DS_NO_TREE_DELETE_ABOVE_NC")); + errorNames.insert(std::make_pair(8502, "ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE")); + errorNames.insert(std::make_pair(8503, "ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE")); + errorNames.insert(std::make_pair(8504, "ERROR_DS_SAM_INIT_FAILURE")); + errorNames.insert(std::make_pair(8505, "ERROR_DS_SENSITIVE_GROUP_VIOLATION")); + errorNames.insert(std::make_pair(8506, "ERROR_DS_CANT_MOD_PRIMARYGROUPID")); + errorNames.insert(std::make_pair(8507, "ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD")); + errorNames.insert(std::make_pair(8508, "ERROR_DS_NONSAFE_SCHEMA_CHANGE")); + errorNames.insert(std::make_pair(8509, "ERROR_DS_SCHEMA_UPDATE_DISALLOWED")); + errorNames.insert(std::make_pair(8510, "ERROR_DS_CANT_CREATE_UNDER_SCHEMA")); + errorNames.insert(std::make_pair(8511, "ERROR_DS_INSTALL_NO_SRC_SCH_VERSION")); + errorNames.insert(std::make_pair(8512, "ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE")); + errorNames.insert(std::make_pair(8513, "ERROR_DS_INVALID_GROUP_TYPE")); + errorNames.insert(std::make_pair(8514, "ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN")); + errorNames.insert(std::make_pair(8515, "ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN")); + errorNames.insert(std::make_pair(8516, "ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER")); + errorNames.insert(std::make_pair(8517, "ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER")); + errorNames.insert(std::make_pair(8518, "ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER")); + errorNames.insert(std::make_pair(8519, "ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER")); + errorNames.insert(std::make_pair(8520, "ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER")); + errorNames.insert(std::make_pair(8521, "ERROR_DS_HAVE_PRIMARY_MEMBERS")); + errorNames.insert(std::make_pair(8522, "ERROR_DS_STRING_SD_CONVERSION_FAILED")); + errorNames.insert(std::make_pair(8523, "ERROR_DS_NAMING_MASTER_GC")); + errorNames.insert(std::make_pair(8524, "ERROR_DS_DNS_LOOKUP_FAILURE")); + errorNames.insert(std::make_pair(8525, "ERROR_DS_COULDNT_UPDATE_SPNS")); + errorNames.insert(std::make_pair(8526, "ERROR_DS_CANT_RETRIEVE_SD")); + errorNames.insert(std::make_pair(8527, "ERROR_DS_KEY_NOT_UNIQUE")); + errorNames.insert(std::make_pair(8528, "ERROR_DS_WRONG_LINKED_ATT_SYNTAX")); + errorNames.insert(std::make_pair(8529, "ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD")); + errorNames.insert(std::make_pair(8530, "ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY")); + errorNames.insert(std::make_pair(8531, "ERROR_DS_CANT_START")); + errorNames.insert(std::make_pair(8532, "ERROR_DS_INIT_FAILURE")); + errorNames.insert(std::make_pair(8533, "ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION")); + errorNames.insert(std::make_pair(8534, "ERROR_DS_SOURCE_DOMAIN_IN_FOREST")); + errorNames.insert(std::make_pair(8535, "ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST")); + errorNames.insert(std::make_pair(8536, "ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED")); + errorNames.insert(std::make_pair(8537, "ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN")); + errorNames.insert(std::make_pair(8538, "ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER")); + errorNames.insert(std::make_pair(8539, "ERROR_DS_SRC_SID_EXISTS_IN_FOREST")); + errorNames.insert(std::make_pair(8540, "ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH")); + errorNames.insert(std::make_pair(8541, "ERROR_SAM_INIT_FAILURE")); + errorNames.insert(std::make_pair(8542, "ERROR_DS_DRA_SCHEMA_INFO_SHIP")); + errorNames.insert(std::make_pair(8543, "ERROR_DS_DRA_SCHEMA_CONFLICT")); + errorNames.insert(std::make_pair(8544, "ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT")); + errorNames.insert(std::make_pair(8545, "ERROR_DS_DRA_OBJ_NC_MISMATCH")); + errorNames.insert(std::make_pair(8546, "ERROR_DS_NC_STILL_HAS_DSAS")); + errorNames.insert(std::make_pair(8547, "ERROR_DS_GC_REQUIRED")); + errorNames.insert(std::make_pair(8548, "ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY")); + errorNames.insert(std::make_pair(8549, "ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS")); + errorNames.insert(std::make_pair(8550, "ERROR_DS_CANT_ADD_TO_GC")); + errorNames.insert(std::make_pair(8551, "ERROR_DS_NO_CHECKPOINT_WITH_PDC")); + errorNames.insert(std::make_pair(8552, "ERROR_DS_SOURCE_AUDITING_NOT_ENABLED")); + errorNames.insert(std::make_pair(8553, "ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC")); + errorNames.insert(std::make_pair(8554, "ERROR_DS_INVALID_NAME_FOR_SPN")); + errorNames.insert(std::make_pair(8555, "ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS")); + errorNames.insert(std::make_pair(8556, "ERROR_DS_UNICODEPWD_NOT_IN_QUOTES")); + errorNames.insert(std::make_pair(8557, "ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED")); + errorNames.insert(std::make_pair(8558, "ERROR_DS_MUST_BE_RUN_ON_DST_DC")); + errorNames.insert(std::make_pair(8559, "ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER")); + errorNames.insert(std::make_pair(8560, "ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ")); + errorNames.insert(std::make_pair(8561, "ERROR_DS_INIT_FAILURE_CONSOLE")); + errorNames.insert(std::make_pair(8562, "ERROR_DS_SAM_INIT_FAILURE_CONSOLE")); + errorNames.insert(std::make_pair(8563, "ERROR_DS_FOREST_VERSION_TOO_HIGH")); + errorNames.insert(std::make_pair(8564, "ERROR_DS_DOMAIN_VERSION_TOO_HIGH")); + errorNames.insert(std::make_pair(8565, "ERROR_DS_FOREST_VERSION_TOO_LOW")); + errorNames.insert(std::make_pair(8566, "ERROR_DS_DOMAIN_VERSION_TOO_LOW")); + errorNames.insert(std::make_pair(8567, "ERROR_DS_INCOMPATIBLE_VERSION")); + errorNames.insert(std::make_pair(8568, "ERROR_DS_LOW_DSA_VERSION")); + errorNames.insert(std::make_pair(8569, "ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN")); + errorNames.insert(std::make_pair(8570, "ERROR_DS_NOT_SUPPORTED_SORT_ORDER")); + errorNames.insert(std::make_pair(8571, "ERROR_DS_NAME_NOT_UNIQUE")); + errorNames.insert(std::make_pair(8572, "ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4")); + errorNames.insert(std::make_pair(8573, "ERROR_DS_OUT_OF_VERSION_STORE")); + errorNames.insert(std::make_pair(8574, "ERROR_DS_INCOMPATIBLE_CONTROLS_USED")); + errorNames.insert(std::make_pair(8575, "ERROR_DS_NO_REF_DOMAIN")); + errorNames.insert(std::make_pair(8576, "ERROR_DS_RESERVED_LINK_ID")); + errorNames.insert(std::make_pair(8577, "ERROR_DS_LINK_ID_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(8578, "ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER")); + errorNames.insert(std::make_pair(8579, "ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE")); + errorNames.insert(std::make_pair(8580, "ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC")); + errorNames.insert(std::make_pair(8581, "ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG")); + errorNames.insert(std::make_pair(8582, "ERROR_DS_MODIFYDN_WRONG_GRANDPARENT")); + errorNames.insert(std::make_pair(8583, "ERROR_DS_NAME_ERROR_TRUST_REFERRAL")); + errorNames.insert(std::make_pair(8584, "ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER")); + errorNames.insert(std::make_pair(8585, "ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD")); + errorNames.insert(std::make_pair(8586, "ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2")); + errorNames.insert(std::make_pair(8587, "ERROR_DS_THREAD_LIMIT_EXCEEDED")); + errorNames.insert(std::make_pair(8588, "ERROR_DS_NOT_CLOSEST")); + errorNames.insert(std::make_pair(8589, "ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF")); + errorNames.insert(std::make_pair(8590, "ERROR_DS_SINGLE_USER_MODE_FAILED")); + errorNames.insert(std::make_pair(8591, "ERROR_DS_NTDSCRIPT_SYNTAX_ERROR")); + errorNames.insert(std::make_pair(8592, "ERROR_DS_NTDSCRIPT_PROCESS_ERROR")); + errorNames.insert(std::make_pair(8593, "ERROR_DS_DIFFERENT_REPL_EPOCHS")); + errorNames.insert(std::make_pair(8594, "ERROR_DS_DRS_EXTENSIONS_CHANGED")); + errorNames.insert(std::make_pair(8595, "ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR")); + errorNames.insert(std::make_pair(8596, "ERROR_DS_NO_MSDS_INTID")); + errorNames.insert(std::make_pair(8597, "ERROR_DS_DUP_MSDS_INTID")); + errorNames.insert(std::make_pair(8598, "ERROR_DS_EXISTS_IN_RDNATTID")); + errorNames.insert(std::make_pair(8599, "ERROR_DS_AUTHORIZATION_FAILED")); + errorNames.insert(std::make_pair(8600, "ERROR_DS_INVALID_SCRIPT")); + errorNames.insert(std::make_pair(8601, "ERROR_DS_REMOTE_CROSSREF_OP_FAILED")); + errorNames.insert(std::make_pair(8602, "ERROR_DS_CROSS_REF_BUSY")); + errorNames.insert(std::make_pair(8603, "ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN")); + errorNames.insert(std::make_pair(8604, "ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC")); + errorNames.insert(std::make_pair(8605, "ERROR_DS_DUPLICATE_ID_FOUND")); + errorNames.insert(std::make_pair(8606, "ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT")); + errorNames.insert(std::make_pair(8607, "ERROR_DS_GROUP_CONVERSION_ERROR")); + errorNames.insert(std::make_pair(8608, "ERROR_DS_CANT_MOVE_APP_BASIC_GROUP")); + errorNames.insert(std::make_pair(8609, "ERROR_DS_CANT_MOVE_APP_QUERY_GROUP")); + errorNames.insert(std::make_pair(8610, "ERROR_DS_ROLE_NOT_VERIFIED")); + errorNames.insert(std::make_pair(8611, "ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL")); + errorNames.insert(std::make_pair(8612, "ERROR_DS_DOMAIN_RENAME_IN_PROGRESS")); + errorNames.insert(std::make_pair(8613, "ERROR_DS_EXISTING_AD_CHILD_NC")); + errorNames.insert(std::make_pair(8614, "ERROR_DS_REPL_LIFETIME_EXCEEDED")); + errorNames.insert(std::make_pair(8615, "ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER")); + errorNames.insert(std::make_pair(8616, "ERROR_DS_LDAP_SEND_QUEUE_FULL")); + errorNames.insert(std::make_pair(8617, "ERROR_DS_DRA_OUT_SCHEDULE_WINDOW")); + errorNames.insert(std::make_pair(8618, "ERROR_DS_POLICY_NOT_KNOWN")); + errorNames.insert(std::make_pair(8619, "ERROR_NO_SITE_SETTINGS_OBJECT")); + errorNames.insert(std::make_pair(8620, "ERROR_NO_SECRETS")); + errorNames.insert(std::make_pair(8621, "ERROR_NO_WRITABLE_DC_FOUND")); + errorNames.insert(std::make_pair(8622, "ERROR_DS_NO_SERVER_OBJECT")); + errorNames.insert(std::make_pair(8623, "ERROR_DS_NO_NTDSA_OBJECT")); + errorNames.insert(std::make_pair(8624, "ERROR_DS_NON_ASQ_SEARCH")); + errorNames.insert(std::make_pair(8625, "ERROR_DS_AUDIT_FAILURE")); + errorNames.insert(std::make_pair(8626, "ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE")); + errorNames.insert(std::make_pair(8627, "ERROR_DS_INVALID_SEARCH_FLAG_TUPLE")); + errorNames.insert(std::make_pair(8628, "ERROR_DS_HIERARCHY_TABLE_TOO_DEEP")); + errorNames.insert(std::make_pair(8629, "ERROR_DS_DRA_CORRUPT_UTD_VECTOR")); + errorNames.insert(std::make_pair(8630, "ERROR_DS_DRA_SECRETS_DENIED")); + errorNames.insert(std::make_pair(8631, "ERROR_DS_RESERVED_MAPI_ID")); + errorNames.insert(std::make_pair(8632, "ERROR_DS_MAPI_ID_NOT_AVAILABLE")); + errorNames.insert(std::make_pair(8633, "ERROR_DS_DRA_MISSING_KRBTGT_SECRET")); + errorNames.insert(std::make_pair(8634, "ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST")); + errorNames.insert(std::make_pair(8635, "ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST")); + errorNames.insert(std::make_pair(8636, "ERROR_INVALID_USER_PRINCIPAL_NAME")); + errorNames.insert(std::make_pair(8637, "ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS")); + errorNames.insert(std::make_pair(8638, "ERROR_DS_OID_NOT_FOUND")); + errorNames.insert(std::make_pair(8639, "ERROR_DS_DRA_RECYCLED_TARGET")); + errorNames.insert(std::make_pair(13000, "ERROR_IPSEC_QM_POLICY_EXISTS")); + errorNames.insert(std::make_pair(13001, "ERROR_IPSEC_QM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13002, "ERROR_IPSEC_QM_POLICY_IN_USE")); + errorNames.insert(std::make_pair(13003, "ERROR_IPSEC_MM_POLICY_EXISTS")); + errorNames.insert(std::make_pair(13004, "ERROR_IPSEC_MM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13005, "ERROR_IPSEC_MM_POLICY_IN_USE")); + errorNames.insert(std::make_pair(13006, "ERROR_IPSEC_MM_FILTER_EXISTS")); + errorNames.insert(std::make_pair(13007, "ERROR_IPSEC_MM_FILTER_NOT_FOUND")); + errorNames.insert(std::make_pair(13008, "ERROR_IPSEC_TRANSPORT_FILTER_EXISTS")); + errorNames.insert(std::make_pair(13009, "ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND")); + errorNames.insert(std::make_pair(13010, "ERROR_IPSEC_MM_AUTH_EXISTS")); + errorNames.insert(std::make_pair(13011, "ERROR_IPSEC_MM_AUTH_NOT_FOUND")); + errorNames.insert(std::make_pair(13012, "ERROR_IPSEC_MM_AUTH_IN_USE")); + errorNames.insert(std::make_pair(13013, "ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13014, "ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND")); + errorNames.insert(std::make_pair(13015, "ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND")); + errorNames.insert(std::make_pair(13016, "ERROR_IPSEC_TUNNEL_FILTER_EXISTS")); + errorNames.insert(std::make_pair(13017, "ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND")); + errorNames.insert(std::make_pair(13018, "ERROR_IPSEC_MM_FILTER_PENDING_DELETION")); + errorNames.insert(std::make_pair(13019, "ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION")); + errorNames.insert(std::make_pair(13020, "ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION")); + errorNames.insert(std::make_pair(13021, "ERROR_IPSEC_MM_POLICY_PENDING_DELETION")); + errorNames.insert(std::make_pair(13022, "ERROR_IPSEC_MM_AUTH_PENDING_DELETION")); + errorNames.insert(std::make_pair(13023, "ERROR_IPSEC_QM_POLICY_PENDING_DELETION")); + errorNames.insert(std::make_pair(13800, "ERROR_IPSEC_IKE_NEG_STATUS_BEGIN")); + errorNames.insert(std::make_pair(13801, "ERROR_IPSEC_IKE_AUTH_FAIL")); + errorNames.insert(std::make_pair(13802, "ERROR_IPSEC_IKE_ATTRIB_FAIL")); + errorNames.insert(std::make_pair(13803, "ERROR_IPSEC_IKE_NEGOTIATION_PENDING")); + errorNames.insert(std::make_pair(13804, "ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR")); + errorNames.insert(std::make_pair(13805, "ERROR_IPSEC_IKE_TIMED_OUT")); + errorNames.insert(std::make_pair(13806, "ERROR_IPSEC_IKE_NO_CERT")); + errorNames.insert(std::make_pair(13807, "ERROR_IPSEC_IKE_SA_DELETED")); + errorNames.insert(std::make_pair(13808, "ERROR_IPSEC_IKE_SA_REAPED")); + errorNames.insert(std::make_pair(13809, "ERROR_IPSEC_IKE_MM_ACQUIRE_DROP")); + errorNames.insert(std::make_pair(13810, "ERROR_IPSEC_IKE_QM_ACQUIRE_DROP")); + errorNames.insert(std::make_pair(13811, "ERROR_IPSEC_IKE_QUEUE_DROP_MM")); + errorNames.insert(std::make_pair(13812, "ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM")); + errorNames.insert(std::make_pair(13813, "ERROR_IPSEC_IKE_DROP_NO_RESPONSE")); + errorNames.insert(std::make_pair(13814, "ERROR_IPSEC_IKE_MM_DELAY_DROP")); + errorNames.insert(std::make_pair(13815, "ERROR_IPSEC_IKE_QM_DELAY_DROP")); + errorNames.insert(std::make_pair(13816, "ERROR_IPSEC_IKE_ERROR")); + errorNames.insert(std::make_pair(13817, "ERROR_IPSEC_IKE_CRL_FAILED")); + errorNames.insert(std::make_pair(13818, "ERROR_IPSEC_IKE_INVALID_KEY_USAGE")); + errorNames.insert(std::make_pair(13819, "ERROR_IPSEC_IKE_INVALID_CERT_TYPE")); + errorNames.insert(std::make_pair(13820, "ERROR_IPSEC_IKE_NO_PRIVATE_KEY")); + errorNames.insert(std::make_pair(13821, "ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY")); + errorNames.insert(std::make_pair(13822, "ERROR_IPSEC_IKE_DH_FAIL")); + errorNames.insert(std::make_pair(13823, "ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED")); + errorNames.insert(std::make_pair(13824, "ERROR_IPSEC_IKE_INVALID_HEADER")); + errorNames.insert(std::make_pair(13825, "ERROR_IPSEC_IKE_NO_POLICY")); + errorNames.insert(std::make_pair(13826, "ERROR_IPSEC_IKE_INVALID_SIGNATURE")); + errorNames.insert(std::make_pair(13827, "ERROR_IPSEC_IKE_KERBEROS_ERROR")); + errorNames.insert(std::make_pair(13828, "ERROR_IPSEC_IKE_NO_PUBLIC_KEY")); + errorNames.insert(std::make_pair(13829, "ERROR_IPSEC_IKE_PROCESS_ERR")); + errorNames.insert(std::make_pair(13830, "ERROR_IPSEC_IKE_PROCESS_ERR_SA")); + errorNames.insert(std::make_pair(13831, "ERROR_IPSEC_IKE_PROCESS_ERR_PROP")); + errorNames.insert(std::make_pair(13832, "ERROR_IPSEC_IKE_PROCESS_ERR_TRANS")); + errorNames.insert(std::make_pair(13833, "ERROR_IPSEC_IKE_PROCESS_ERR_KE")); + errorNames.insert(std::make_pair(13834, "ERROR_IPSEC_IKE_PROCESS_ERR_ID")); + errorNames.insert(std::make_pair(13835, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT")); + errorNames.insert(std::make_pair(13836, "ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ")); + errorNames.insert(std::make_pair(13837, "ERROR_IPSEC_IKE_PROCESS_ERR_HASH")); + errorNames.insert(std::make_pair(13838, "ERROR_IPSEC_IKE_PROCESS_ERR_SIG")); + errorNames.insert(std::make_pair(13839, "ERROR_IPSEC_IKE_PROCESS_ERR_NONCE")); + errorNames.insert(std::make_pair(13840, "ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY")); + errorNames.insert(std::make_pair(13841, "ERROR_IPSEC_IKE_PROCESS_ERR_DELETE")); + errorNames.insert(std::make_pair(13842, "ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR")); + errorNames.insert(std::make_pair(13843, "ERROR_IPSEC_IKE_INVALID_PAYLOAD")); + errorNames.insert(std::make_pair(13844, "ERROR_IPSEC_IKE_LOAD_SOFT_SA")); + errorNames.insert(std::make_pair(13845, "ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN")); + errorNames.insert(std::make_pair(13846, "ERROR_IPSEC_IKE_INVALID_COOKIE")); + errorNames.insert(std::make_pair(13847, "ERROR_IPSEC_IKE_NO_PEER_CERT")); + errorNames.insert(std::make_pair(13848, "ERROR_IPSEC_IKE_PEER_CRL_FAILED")); + errorNames.insert(std::make_pair(13849, "ERROR_IPSEC_IKE_POLICY_CHANGE")); + errorNames.insert(std::make_pair(13850, "ERROR_IPSEC_IKE_NO_MM_POLICY")); + errorNames.insert(std::make_pair(13851, "ERROR_IPSEC_IKE_NOTCBPRIV")); + errorNames.insert(std::make_pair(13852, "ERROR_IPSEC_IKE_SECLOADFAIL")); + errorNames.insert(std::make_pair(13853, "ERROR_IPSEC_IKE_FAILSSPINIT")); + errorNames.insert(std::make_pair(13854, "ERROR_IPSEC_IKE_FAILQUERYSSP")); + errorNames.insert(std::make_pair(13855, "ERROR_IPSEC_IKE_SRVACQFAIL")); + errorNames.insert(std::make_pair(13856, "ERROR_IPSEC_IKE_SRVQUERYCRED")); + errorNames.insert(std::make_pair(13857, "ERROR_IPSEC_IKE_GETSPIFAIL")); + errorNames.insert(std::make_pair(13858, "ERROR_IPSEC_IKE_INVALID_FILTER")); + errorNames.insert(std::make_pair(13859, "ERROR_IPSEC_IKE_OUT_OF_MEMORY")); + errorNames.insert(std::make_pair(13860, "ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED")); + errorNames.insert(std::make_pair(13861, "ERROR_IPSEC_IKE_INVALID_POLICY")); + errorNames.insert(std::make_pair(13862, "ERROR_IPSEC_IKE_UNKNOWN_DOI")); + errorNames.insert(std::make_pair(13863, "ERROR_IPSEC_IKE_INVALID_SITUATION")); + errorNames.insert(std::make_pair(13864, "ERROR_IPSEC_IKE_DH_FAILURE")); + errorNames.insert(std::make_pair(13865, "ERROR_IPSEC_IKE_INVALID_GROUP")); + errorNames.insert(std::make_pair(13866, "ERROR_IPSEC_IKE_ENCRYPT")); + errorNames.insert(std::make_pair(13867, "ERROR_IPSEC_IKE_DECRYPT")); + errorNames.insert(std::make_pair(13868, "ERROR_IPSEC_IKE_POLICY_MATCH")); + errorNames.insert(std::make_pair(13869, "ERROR_IPSEC_IKE_UNSUPPORTED_ID")); + errorNames.insert(std::make_pair(13870, "ERROR_IPSEC_IKE_INVALID_HASH")); + errorNames.insert(std::make_pair(13871, "ERROR_IPSEC_IKE_INVALID_HASH_ALG")); + errorNames.insert(std::make_pair(13872, "ERROR_IPSEC_IKE_INVALID_HASH_SIZE")); + errorNames.insert(std::make_pair(13873, "ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG")); + errorNames.insert(std::make_pair(13874, "ERROR_IPSEC_IKE_INVALID_AUTH_ALG")); + errorNames.insert(std::make_pair(13875, "ERROR_IPSEC_IKE_INVALID_SIG")); + errorNames.insert(std::make_pair(13876, "ERROR_IPSEC_IKE_LOAD_FAILED")); + errorNames.insert(std::make_pair(13877, "ERROR_IPSEC_IKE_RPC_DELETE")); + errorNames.insert(std::make_pair(13878, "ERROR_IPSEC_IKE_BENIGN_REINIT")); + errorNames.insert(std::make_pair(13879, "ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY")); + errorNames.insert(std::make_pair(13880, "ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION")); + errorNames.insert(std::make_pair(13881, "ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN")); + errorNames.insert(std::make_pair(13882, "ERROR_IPSEC_IKE_MM_LIMIT")); + errorNames.insert(std::make_pair(13883, "ERROR_IPSEC_IKE_NEGOTIATION_DISABLED")); + errorNames.insert(std::make_pair(13884, "ERROR_IPSEC_IKE_QM_LIMIT")); + errorNames.insert(std::make_pair(13885, "ERROR_IPSEC_IKE_MM_EXPIRED")); + errorNames.insert(std::make_pair(13886, "ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID")); + errorNames.insert(std::make_pair(13887, "ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH")); + errorNames.insert(std::make_pair(13888, "ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID")); + errorNames.insert(std::make_pair(13889, "ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD")); + errorNames.insert(std::make_pair(13890, "ERROR_IPSEC_IKE_DOS_COOKIE_SENT")); + errorNames.insert(std::make_pair(13891, "ERROR_IPSEC_IKE_SHUTTING_DOWN")); + errorNames.insert(std::make_pair(13892, "ERROR_IPSEC_IKE_CGA_AUTH_FAILED")); + errorNames.insert(std::make_pair(13893, "ERROR_IPSEC_IKE_PROCESS_ERR_NATOA")); + errorNames.insert(std::make_pair(13894, "ERROR_IPSEC_IKE_INVALID_MM_FOR_QM")); + errorNames.insert(std::make_pair(13895, "ERROR_IPSEC_IKE_QM_EXPIRED")); + errorNames.insert(std::make_pair(13896, "ERROR_IPSEC_IKE_TOO_MANY_FILTERS")); + errorNames.insert(std::make_pair(13897, "ERROR_IPSEC_IKE_NEG_STATUS_END")); + errorNames.insert(std::make_pair(13898, "ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL")); + errorNames.insert(std::make_pair(13899, "ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE")); + errorNames.insert(std::make_pair(13900, "ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING")); + errorNames.insert(std::make_pair(13901, "ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING")); + errorNames.insert(std::make_pair(13902, "ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS")); + errorNames.insert(std::make_pair(13903, "ERROR_IPSEC_IKE_RATELIMIT_DROP")); + errorNames.insert(std::make_pair(13904, "ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE")); + errorNames.insert(std::make_pair(13905, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE")); + errorNames.insert(std::make_pair(13906, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE")); + errorNames.insert(std::make_pair(13907, "ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY")); + errorNames.insert(std::make_pair(13908, "ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE")); + errorNames.insert(std::make_pair(13909, "ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END")); + errorNames.insert(std::make_pair(13910, "ERROR_IPSEC_BAD_SPI")); + errorNames.insert(std::make_pair(13911, "ERROR_IPSEC_SA_LIFETIME_EXPIRED")); + errorNames.insert(std::make_pair(13912, "ERROR_IPSEC_WRONG_SA")); + errorNames.insert(std::make_pair(13913, "ERROR_IPSEC_REPLAY_CHECK_FAILED")); + errorNames.insert(std::make_pair(13914, "ERROR_IPSEC_INVALID_PACKET")); + errorNames.insert(std::make_pair(13915, "ERROR_IPSEC_INTEGRITY_CHECK_FAILED")); + errorNames.insert(std::make_pair(13916, "ERROR_IPSEC_CLEAR_TEXT_DROP")); + errorNames.insert(std::make_pair(13917, "ERROR_IPSEC_AUTH_FIREWALL_DROP")); + errorNames.insert(std::make_pair(13918, "ERROR_IPSEC_THROTTLE_DROP")); + errorNames.insert(std::make_pair(13925, "ERROR_IPSEC_DOSP_BLOCK")); + errorNames.insert(std::make_pair(13926, "ERROR_IPSEC_DOSP_RECEIVED_MULTICAST")); + errorNames.insert(std::make_pair(13927, "ERROR_IPSEC_DOSP_INVALID_PACKET")); + errorNames.insert(std::make_pair(13928, "ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED")); + errorNames.insert(std::make_pair(13929, "ERROR_IPSEC_DOSP_MAX_ENTRIES")); + errorNames.insert(std::make_pair(13930, "ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED")); + errorNames.insert(std::make_pair(13931, "ERROR_IPSEC_DOSP_NOT_INSTALLED")); + errorNames.insert(std::make_pair(13932, "ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES")); + errorNames.insert(std::make_pair(14000, "ERROR_SXS_SECTION_NOT_FOUND")); + errorNames.insert(std::make_pair(14001, "ERROR_SXS_CANT_GEN_ACTCTX")); + errorNames.insert(std::make_pair(14002, "ERROR_SXS_INVALID_ACTCTXDATA_FORMAT")); + errorNames.insert(std::make_pair(14003, "ERROR_SXS_ASSEMBLY_NOT_FOUND")); + errorNames.insert(std::make_pair(14004, "ERROR_SXS_MANIFEST_FORMAT_ERROR")); + errorNames.insert(std::make_pair(14005, "ERROR_SXS_MANIFEST_PARSE_ERROR")); + errorNames.insert(std::make_pair(14006, "ERROR_SXS_ACTIVATION_CONTEXT_DISABLED")); + errorNames.insert(std::make_pair(14007, "ERROR_SXS_KEY_NOT_FOUND")); + errorNames.insert(std::make_pair(14008, "ERROR_SXS_VERSION_CONFLICT")); + errorNames.insert(std::make_pair(14009, "ERROR_SXS_WRONG_SECTION_TYPE")); + errorNames.insert(std::make_pair(14010, "ERROR_SXS_THREAD_QUERIES_DISABLED")); + errorNames.insert(std::make_pair(14011, "ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET")); + errorNames.insert(std::make_pair(14012, "ERROR_SXS_UNKNOWN_ENCODING_GROUP")); + errorNames.insert(std::make_pair(14013, "ERROR_SXS_UNKNOWN_ENCODING")); + errorNames.insert(std::make_pair(14014, "ERROR_SXS_INVALID_XML_NAMESPACE_URI")); + errorNames.insert(std::make_pair(14015, "ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED")); + errorNames.insert(std::make_pair(14016, "ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED")); + errorNames.insert(std::make_pair(14017, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE")); + errorNames.insert(std::make_pair(14018, "ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE")); + errorNames.insert(std::make_pair(14019, "ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE")); + errorNames.insert(std::make_pair(14020, "ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT")); + errorNames.insert(std::make_pair(14021, "ERROR_SXS_DUPLICATE_DLL_NAME")); + errorNames.insert(std::make_pair(14022, "ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME")); + errorNames.insert(std::make_pair(14023, "ERROR_SXS_DUPLICATE_CLSID")); + errorNames.insert(std::make_pair(14024, "ERROR_SXS_DUPLICATE_IID")); + errorNames.insert(std::make_pair(14025, "ERROR_SXS_DUPLICATE_TLBID")); + errorNames.insert(std::make_pair(14026, "ERROR_SXS_DUPLICATE_PROGID")); + errorNames.insert(std::make_pair(14027, "ERROR_SXS_DUPLICATE_ASSEMBLY_NAME")); + errorNames.insert(std::make_pair(14028, "ERROR_SXS_FILE_HASH_MISMATCH")); + errorNames.insert(std::make_pair(14029, "ERROR_SXS_POLICY_PARSE_ERROR")); + errorNames.insert(std::make_pair(14030, "ERROR_SXS_XML_E_MISSINGQUOTE")); + errorNames.insert(std::make_pair(14031, "ERROR_SXS_XML_E_COMMENTSYNTAX")); + errorNames.insert(std::make_pair(14032, "ERROR_SXS_XML_E_BADSTARTNAMECHAR")); + errorNames.insert(std::make_pair(14033, "ERROR_SXS_XML_E_BADNAMECHAR")); + errorNames.insert(std::make_pair(14034, "ERROR_SXS_XML_E_BADCHARINSTRING")); + errorNames.insert(std::make_pair(14035, "ERROR_SXS_XML_E_XMLDECLSYNTAX")); + errorNames.insert(std::make_pair(14036, "ERROR_SXS_XML_E_BADCHARDATA")); + errorNames.insert(std::make_pair(14037, "ERROR_SXS_XML_E_MISSINGWHITESPACE")); + errorNames.insert(std::make_pair(14038, "ERROR_SXS_XML_E_EXPECTINGTAGEND")); + errorNames.insert(std::make_pair(14039, "ERROR_SXS_XML_E_MISSINGSEMICOLON")); + errorNames.insert(std::make_pair(14040, "ERROR_SXS_XML_E_UNBALANCEDPAREN")); + errorNames.insert(std::make_pair(14041, "ERROR_SXS_XML_E_INTERNALERROR")); + errorNames.insert(std::make_pair(14042, "ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE")); + errorNames.insert(std::make_pair(14043, "ERROR_SXS_XML_E_INCOMPLETE_ENCODING")); + errorNames.insert(std::make_pair(14044, "ERROR_SXS_XML_E_MISSING_PAREN")); + errorNames.insert(std::make_pair(14045, "ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE")); + errorNames.insert(std::make_pair(14046, "ERROR_SXS_XML_E_MULTIPLE_COLONS")); + errorNames.insert(std::make_pair(14047, "ERROR_SXS_XML_E_INVALID_DECIMAL")); + errorNames.insert(std::make_pair(14048, "ERROR_SXS_XML_E_INVALID_HEXIDECIMAL")); + errorNames.insert(std::make_pair(14049, "ERROR_SXS_XML_E_INVALID_UNICODE")); + errorNames.insert(std::make_pair(14050, "ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK")); + errorNames.insert(std::make_pair(14051, "ERROR_SXS_XML_E_UNEXPECTEDENDTAG")); + errorNames.insert(std::make_pair(14052, "ERROR_SXS_XML_E_UNCLOSEDTAG")); + errorNames.insert(std::make_pair(14053, "ERROR_SXS_XML_E_DUPLICATEATTRIBUTE")); + errorNames.insert(std::make_pair(14054, "ERROR_SXS_XML_E_MULTIPLEROOTS")); + errorNames.insert(std::make_pair(14055, "ERROR_SXS_XML_E_INVALIDATROOTLEVEL")); + errorNames.insert(std::make_pair(14056, "ERROR_SXS_XML_E_BADXMLDECL")); + errorNames.insert(std::make_pair(14057, "ERROR_SXS_XML_E_MISSINGROOT")); + errorNames.insert(std::make_pair(14058, "ERROR_SXS_XML_E_UNEXPECTEDEOF")); + errorNames.insert(std::make_pair(14059, "ERROR_SXS_XML_E_BADPEREFINSUBSET")); + errorNames.insert(std::make_pair(14060, "ERROR_SXS_XML_E_UNCLOSEDSTARTTAG")); + errorNames.insert(std::make_pair(14061, "ERROR_SXS_XML_E_UNCLOSEDENDTAG")); + errorNames.insert(std::make_pair(14062, "ERROR_SXS_XML_E_UNCLOSEDSTRING")); + errorNames.insert(std::make_pair(14063, "ERROR_SXS_XML_E_UNCLOSEDCOMMENT")); + errorNames.insert(std::make_pair(14064, "ERROR_SXS_XML_E_UNCLOSEDDECL")); + errorNames.insert(std::make_pair(14065, "ERROR_SXS_XML_E_UNCLOSEDCDATA")); + errorNames.insert(std::make_pair(14066, "ERROR_SXS_XML_E_RESERVEDNAMESPACE")); + errorNames.insert(std::make_pair(14067, "ERROR_SXS_XML_E_INVALIDENCODING")); + errorNames.insert(std::make_pair(14068, "ERROR_SXS_XML_E_INVALIDSWITCH")); + errorNames.insert(std::make_pair(14069, "ERROR_SXS_XML_E_BADXMLCASE")); + errorNames.insert(std::make_pair(14070, "ERROR_SXS_XML_E_INVALID_STANDALONE")); + errorNames.insert(std::make_pair(14071, "ERROR_SXS_XML_E_UNEXPECTED_STANDALONE")); + errorNames.insert(std::make_pair(14072, "ERROR_SXS_XML_E_INVALID_VERSION")); + errorNames.insert(std::make_pair(14073, "ERROR_SXS_XML_E_MISSINGEQUALS")); + errorNames.insert(std::make_pair(14074, "ERROR_SXS_PROTECTION_RECOVERY_FAILED")); + errorNames.insert(std::make_pair(14075, "ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT")); + errorNames.insert(std::make_pair(14076, "ERROR_SXS_PROTECTION_CATALOG_NOT_VALID")); + errorNames.insert(std::make_pair(14077, "ERROR_SXS_UNTRANSLATABLE_HRESULT")); + errorNames.insert(std::make_pair(14078, "ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING")); + errorNames.insert(std::make_pair(14079, "ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE")); + errorNames.insert(std::make_pair(14080, "ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME")); + errorNames.insert(std::make_pair(14081, "ERROR_SXS_ASSEMBLY_MISSING")); + errorNames.insert(std::make_pair(14082, "ERROR_SXS_CORRUPT_ACTIVATION_STACK")); + errorNames.insert(std::make_pair(14083, "ERROR_SXS_CORRUPTION")); + errorNames.insert(std::make_pair(14084, "ERROR_SXS_EARLY_DEACTIVATION")); + errorNames.insert(std::make_pair(14085, "ERROR_SXS_INVALID_DEACTIVATION")); + errorNames.insert(std::make_pair(14086, "ERROR_SXS_MULTIPLE_DEACTIVATION")); + errorNames.insert(std::make_pair(14087, "ERROR_SXS_PROCESS_TERMINATION_REQUESTED")); + errorNames.insert(std::make_pair(14088, "ERROR_SXS_RELEASE_ACTIVATION_CONTEXT")); + errorNames.insert(std::make_pair(14089, "ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY")); + errorNames.insert(std::make_pair(14090, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE")); + errorNames.insert(std::make_pair(14091, "ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME")); + errorNames.insert(std::make_pair(14092, "ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE")); + errorNames.insert(std::make_pair(14093, "ERROR_SXS_IDENTITY_PARSE_ERROR")); + errorNames.insert(std::make_pair(14094, "ERROR_MALFORMED_SUBSTITUTION_STRING")); + errorNames.insert(std::make_pair(14095, "ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN")); + errorNames.insert(std::make_pair(14096, "ERROR_UNMAPPED_SUBSTITUTION_STRING")); + errorNames.insert(std::make_pair(14097, "ERROR_SXS_ASSEMBLY_NOT_LOCKED")); + errorNames.insert(std::make_pair(14098, "ERROR_SXS_COMPONENT_STORE_CORRUPT")); + errorNames.insert(std::make_pair(14099, "ERROR_ADVANCED_INSTALLER_FAILED")); + errorNames.insert(std::make_pair(14100, "ERROR_XML_ENCODING_MISMATCH")); + errorNames.insert(std::make_pair(14101, "ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT")); + errorNames.insert(std::make_pair(14102, "ERROR_SXS_IDENTITIES_DIFFERENT")); + errorNames.insert(std::make_pair(14103, "ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT")); + errorNames.insert(std::make_pair(14104, "ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY")); + errorNames.insert(std::make_pair(14105, "ERROR_SXS_MANIFEST_TOO_BIG")); + errorNames.insert(std::make_pair(14106, "ERROR_SXS_SETTING_NOT_REGISTERED")); + errorNames.insert(std::make_pair(14107, "ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE")); + errorNames.insert(std::make_pair(14108, "ERROR_SMI_PRIMITIVE_INSTALLER_FAILED")); + errorNames.insert(std::make_pair(14109, "ERROR_GENERIC_COMMAND_FAILED")); + errorNames.insert(std::make_pair(14110, "ERROR_SXS_FILE_HASH_MISSING")); + errorNames.insert(std::make_pair(15000, "ERROR_EVT_INVALID_CHANNEL_PATH")); + errorNames.insert(std::make_pair(15001, "ERROR_EVT_INVALID_QUERY")); + errorNames.insert(std::make_pair(15002, "ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND")); + errorNames.insert(std::make_pair(15003, "ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND")); + errorNames.insert(std::make_pair(15004, "ERROR_EVT_INVALID_PUBLISHER_NAME")); + errorNames.insert(std::make_pair(15005, "ERROR_EVT_INVALID_EVENT_DATA")); + errorNames.insert(std::make_pair(15007, "ERROR_EVT_CHANNEL_NOT_FOUND")); + errorNames.insert(std::make_pair(15008, "ERROR_EVT_MALFORMED_XML_TEXT")); + errorNames.insert(std::make_pair(15009, "ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL")); + errorNames.insert(std::make_pair(15010, "ERROR_EVT_CONFIGURATION_ERROR")); + errorNames.insert(std::make_pair(15011, "ERROR_EVT_QUERY_RESULT_STALE")); + errorNames.insert(std::make_pair(15012, "ERROR_EVT_QUERY_RESULT_INVALID_POSITION")); + errorNames.insert(std::make_pair(15013, "ERROR_EVT_NON_VALIDATING_MSXML")); + errorNames.insert(std::make_pair(15014, "ERROR_EVT_FILTER_ALREADYSCOPED")); + errorNames.insert(std::make_pair(15015, "ERROR_EVT_FILTER_NOTELTSET")); + errorNames.insert(std::make_pair(15016, "ERROR_EVT_FILTER_INVARG")); + errorNames.insert(std::make_pair(15017, "ERROR_EVT_FILTER_INVTEST")); + errorNames.insert(std::make_pair(15018, "ERROR_EVT_FILTER_INVTYPE")); + errorNames.insert(std::make_pair(15019, "ERROR_EVT_FILTER_PARSEERR")); + errorNames.insert(std::make_pair(15020, "ERROR_EVT_FILTER_UNSUPPORTEDOP")); + errorNames.insert(std::make_pair(15021, "ERROR_EVT_FILTER_UNEXPECTEDTOKEN")); + errorNames.insert(std::make_pair(15022, "ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL")); + errorNames.insert(std::make_pair(15023, "ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE")); + errorNames.insert(std::make_pair(15024, "ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE")); + errorNames.insert(std::make_pair(15025, "ERROR_EVT_CHANNEL_CANNOT_ACTIVATE")); + errorNames.insert(std::make_pair(15026, "ERROR_EVT_FILTER_TOO_COMPLEX")); + errorNames.insert(std::make_pair(15027, "ERROR_EVT_MESSAGE_NOT_FOUND")); + errorNames.insert(std::make_pair(15028, "ERROR_EVT_MESSAGE_ID_NOT_FOUND")); + errorNames.insert(std::make_pair(15029, "ERROR_EVT_UNRESOLVED_VALUE_INSERT")); + errorNames.insert(std::make_pair(15030, "ERROR_EVT_UNRESOLVED_PARAMETER_INSERT")); + errorNames.insert(std::make_pair(15031, "ERROR_EVT_MAX_INSERTS_REACHED")); + errorNames.insert(std::make_pair(15032, "ERROR_EVT_EVENT_DEFINITION_NOT_FOUND")); + errorNames.insert(std::make_pair(15033, "ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND")); + errorNames.insert(std::make_pair(15034, "ERROR_EVT_VERSION_TOO_OLD")); + errorNames.insert(std::make_pair(15035, "ERROR_EVT_VERSION_TOO_NEW")); + errorNames.insert(std::make_pair(15036, "ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY")); + errorNames.insert(std::make_pair(15037, "ERROR_EVT_PUBLISHER_DISABLED")); + errorNames.insert(std::make_pair(15038, "ERROR_EVT_FILTER_OUT_OF_RANGE")); + errorNames.insert(std::make_pair(15080, "ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE")); + errorNames.insert(std::make_pair(15081, "ERROR_EC_LOG_DISABLED")); + errorNames.insert(std::make_pair(15082, "ERROR_EC_CIRCULAR_FORWARDING")); + errorNames.insert(std::make_pair(15083, "ERROR_EC_CREDSTORE_FULL")); + errorNames.insert(std::make_pair(15084, "ERROR_EC_CRED_NOT_FOUND")); + errorNames.insert(std::make_pair(15085, "ERROR_EC_NO_ACTIVE_CHANNEL")); + errorNames.insert(std::make_pair(15100, "ERROR_MUI_FILE_NOT_FOUND")); + errorNames.insert(std::make_pair(15101, "ERROR_MUI_INVALID_FILE")); + errorNames.insert(std::make_pair(15102, "ERROR_MUI_INVALID_RC_CONFIG")); + errorNames.insert(std::make_pair(15103, "ERROR_MUI_INVALID_LOCALE_NAME")); + errorNames.insert(std::make_pair(15104, "ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME")); + errorNames.insert(std::make_pair(15105, "ERROR_MUI_FILE_NOT_LOADED")); + errorNames.insert(std::make_pair(15106, "ERROR_RESOURCE_ENUM_USER_STOP")); + errorNames.insert(std::make_pair(15107, "ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED")); + errorNames.insert(std::make_pair(15108, "ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME")); + errorNames.insert(std::make_pair(15200, "ERROR_MCA_INVALID_CAPABILITIES_STRING")); + errorNames.insert(std::make_pair(15201, "ERROR_MCA_INVALID_VCP_VERSION")); + errorNames.insert(std::make_pair(15202, "ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION")); + errorNames.insert(std::make_pair(15203, "ERROR_MCA_MCCS_VERSION_MISMATCH")); + errorNames.insert(std::make_pair(15204, "ERROR_MCA_UNSUPPORTED_MCCS_VERSION")); + errorNames.insert(std::make_pair(15205, "ERROR_MCA_INTERNAL_ERROR")); + errorNames.insert(std::make_pair(15206, "ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED")); + errorNames.insert(std::make_pair(15207, "ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE")); + errorNames.insert(std::make_pair(15250, "ERROR_AMBIGUOUS_SYSTEM_DEVICE")); + errorNames.insert(std::make_pair(15299, "ERROR_SYSTEM_DEVICE_NOT_FOUND")); + errorNames.insert(std::make_pair(15300, "ERROR_HASH_NOT_SUPPORTED")); + errorNames.insert(std::make_pair(15301, "ERROR_HASH_NOT_PRESENT")); } -const char* ErrorCodeToName(unsigned int ErrorCode) +const char* errornamefromcode(unsigned int ErrorCode) { - if(!ErrorNames.count(ErrorCode)) - return nullptr; - - return ErrorNames[ErrorCode]; + if(!errorNames.count(ErrorCode)) + return 0; + return errorNames[ErrorCode]; } \ No newline at end of file diff --git a/x64_dbg_dbg/error.h b/x64_dbg_dbg/error.h index 65985171..7b4eeac1 100644 --- a/x64_dbg_dbg/error.h +++ b/x64_dbg_dbg/error.h @@ -1,4 +1,7 @@ -#pragma once +#ifndef _ERROR_H +#define _ERROR_H -void ErrorCodeInit(); -const char* ErrorCodeToName(unsigned int ErrorCode); \ No newline at end of file +void errorinit(); +const char* errornamefromcode(unsigned int ErrorCode); + +#endif //_ERROR_H \ No newline at end of file diff --git a/x64_dbg_dbg/exception.cpp b/x64_dbg_dbg/exception.cpp index dda1b38e..8e000e6b 100644 --- a/x64_dbg_dbg/exception.cpp +++ b/x64_dbg_dbg/exception.cpp @@ -1,79 +1,77 @@ #include "exception.h" -#include +#include -std::unordered_map ExceptionNames; +static std::map exceptionNames; -void ExceptionCodeInit() +void exceptioninit() { - ExceptionNames.clear(); - ExceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); - ExceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); - ExceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); - ExceptionNames.insert(std::make_pair(0x4000001D, "STATUS_WX86_CONTINUE")); - ExceptionNames.insert(std::make_pair(0x4000001E, "STATUS_WX86_SINGLE_STEP")); - ExceptionNames.insert(std::make_pair(0x4000001F, "STATUS_WX86_BREAKPOINT")); - ExceptionNames.insert(std::make_pair(0x40000020, "STATUS_WX86_EXCEPTION_CONTINUE")); - ExceptionNames.insert(std::make_pair(0x40000021, "STATUS_WX86_EXCEPTION_LASTCHANCE")); - ExceptionNames.insert(std::make_pair(0x40000022, "STATUS_WX86_EXCEPTION_CHAIN")); - ExceptionNames.insert(std::make_pair(0x40000028, "STATUS_WX86_CREATEWX86TIB")); - ExceptionNames.insert(std::make_pair(0x40010003, "DBG_TERMINATE_THREAD")); - ExceptionNames.insert(std::make_pair(0x40010004, "DBG_TERMINATE_PROCESS")); - ExceptionNames.insert(std::make_pair(0x40010005, "DBG_CONTROL_C")); - ExceptionNames.insert(std::make_pair(0x40010006, "DBG_PRINTEXCEPTION_C")); - ExceptionNames.insert(std::make_pair(0x40010007, "DBG_RIPEXCEPTION")); - ExceptionNames.insert(std::make_pair(0x40010008, "DBG_CONTROL_BREAK")); - ExceptionNames.insert(std::make_pair(0x40010009, "DBG_COMMAND_EXCEPTION")); - ExceptionNames.insert(std::make_pair(0x406D1388, "MS_VC_EXCEPTION")); - ExceptionNames.insert(std::make_pair(0x80000001, "EXCEPTION_GUARD_PAGE")); - ExceptionNames.insert(std::make_pair(0x80000002, "EXCEPTION_DATATYPE_MISALIGNMENT")); - ExceptionNames.insert(std::make_pair(0x80000003, "EXCEPTION_BREAKPOINT")); - ExceptionNames.insert(std::make_pair(0x80000004, "EXCEPTION_SINGLE_STEP")); - ExceptionNames.insert(std::make_pair(0x80000026, "STATUS_LONGJUMP")); - ExceptionNames.insert(std::make_pair(0x80000029, "STATUS_UNWIND_CONSOLIDATE")); - ExceptionNames.insert(std::make_pair(0x80010001, "DBG_EXCEPTION_NOT_HANDLED")); - ExceptionNames.insert(std::make_pair(0xC0000005, "EXCEPTION_ACCESS_VIOLATION")); - ExceptionNames.insert(std::make_pair(0xC0000006, "EXCEPTION_IN_PAGE_ERROR")); - ExceptionNames.insert(std::make_pair(0xC0000008, "EXCEPTION_INVALID_HANDLE")); - ExceptionNames.insert(std::make_pair(0xC000000D, "STATUS_INVALID_PARAMETER")); - ExceptionNames.insert(std::make_pair(0xC0000017, "STATUS_NO_MEMORY")); - ExceptionNames.insert(std::make_pair(0xC000001D, "EXCEPTION_ILLEGAL_INSTRUCTION")); - ExceptionNames.insert(std::make_pair(0xC0000025, "EXCEPTION_NONCONTINUABLE_EXCEPTION")); - ExceptionNames.insert(std::make_pair(0xC0000026, "EXCEPTION_INVALID_DISPOSITION")); - ExceptionNames.insert(std::make_pair(0xC000008C, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED")); - ExceptionNames.insert(std::make_pair(0xC000008D, "EXCEPTION_FLT_DENORMAL_OPERAND")); - ExceptionNames.insert(std::make_pair(0xC000008E, "EXCEPTION_FLT_DIVIDE_BY_ZERO")); - ExceptionNames.insert(std::make_pair(0xC000008F, "EXCEPTION_FLT_INEXACT_RESULT")); - ExceptionNames.insert(std::make_pair(0xC0000090, "EXCEPTION_FLT_INVALID_OPERATION")); - ExceptionNames.insert(std::make_pair(0xC0000091, "EXCEPTION_FLT_OVERFLOW")); - ExceptionNames.insert(std::make_pair(0xC0000092, "EXCEPTION_FLT_STACK_CHECK")); - ExceptionNames.insert(std::make_pair(0xC0000093, "EXCEPTION_FLT_UNDERFLOW")); - ExceptionNames.insert(std::make_pair(0xC0000094, "EXCEPTION_INT_DIVIDE_BY_ZERO")); - ExceptionNames.insert(std::make_pair(0xC0000095, "EXCEPTION_INT_OVERFLOW")); - ExceptionNames.insert(std::make_pair(0xC0000096, "EXCEPTION_PRIV_INSTRUCTION")); - ExceptionNames.insert(std::make_pair(0xC00000FD, "EXCEPTION_STACK_OVERFLOW")); - ExceptionNames.insert(std::make_pair(0xC0000135, "STATUS_DLL_NOT_FOUND")); - ExceptionNames.insert(std::make_pair(0xC0000138, "STATUS_ORDINAL_NOT_FOUND")); - ExceptionNames.insert(std::make_pair(0xC0000139, "STATUS_ENTRYPOINT_NOT_FOUND")); - ExceptionNames.insert(std::make_pair(0xC000013A, "STATUS_CONTROL_C_EXIT")); - ExceptionNames.insert(std::make_pair(0xC0000142, "STATUS_DLL_INIT_FAILED")); - ExceptionNames.insert(std::make_pair(0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT")); - ExceptionNames.insert(std::make_pair(0xC0000194, "EXCEPTION_POSSIBLE_DEADLOCK")); - ExceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); - ExceptionNames.insert(std::make_pair(0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS")); - ExceptionNames.insert(std::make_pair(0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS")); - ExceptionNames.insert(std::make_pair(0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR")); - ExceptionNames.insert(std::make_pair(0xC00002C9, "STATUS_REG_NAT_CONSUMPTION")); - ExceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN")); - ExceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER")); - ExceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE")); - ExceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); - ExceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); + exceptionNames.insert(std::make_pair(0x40000005, "STATUS_SEGMENT_NOTIFICATION")); + exceptionNames.insert(std::make_pair(0x4000001C, "STATUS_WX86_UNSIMULATE")); + exceptionNames.insert(std::make_pair(0x4000001D, "STATUS_WX86_CONTINUE")); + exceptionNames.insert(std::make_pair(0x4000001E, "STATUS_WX86_SINGLE_STEP")); + exceptionNames.insert(std::make_pair(0x4000001F, "STATUS_WX86_BREAKPOINT")); + exceptionNames.insert(std::make_pair(0x40000020, "STATUS_WX86_EXCEPTION_CONTINUE")); + exceptionNames.insert(std::make_pair(0x40000021, "STATUS_WX86_EXCEPTION_LASTCHANCE")); + exceptionNames.insert(std::make_pair(0x40000022, "STATUS_WX86_EXCEPTION_CHAIN")); + exceptionNames.insert(std::make_pair(0x40000028, "STATUS_WX86_CREATEWX86TIB")); + exceptionNames.insert(std::make_pair(0x40010003, "DBG_TERMINATE_THREAD")); + exceptionNames.insert(std::make_pair(0x40010004, "DBG_TERMINATE_PROCESS")); + exceptionNames.insert(std::make_pair(0x40010005, "DBG_CONTROL_C")); + exceptionNames.insert(std::make_pair(0x40010006, "DBG_PRINTEXCEPTION_C")); + exceptionNames.insert(std::make_pair(0x40010007, "DBG_RIPEXCEPTION")); + exceptionNames.insert(std::make_pair(0x40010008, "DBG_CONTROL_BREAK")); + exceptionNames.insert(std::make_pair(0x40010009, "DBG_COMMAND_EXCEPTION")); + exceptionNames.insert(std::make_pair(0x80000001, "EXCEPTION_GUARD_PAGE")); + exceptionNames.insert(std::make_pair(0x80000002, "EXCEPTION_DATATYPE_MISALIGNMENT")); + exceptionNames.insert(std::make_pair(0x80000003, "EXCEPTION_BREAKPOINT")); + exceptionNames.insert(std::make_pair(0x80000004, "EXCEPTION_SINGLE_STEP")); + exceptionNames.insert(std::make_pair(0x80000026, "STATUS_LONGJUMP")); + exceptionNames.insert(std::make_pair(0x80000029, "STATUS_UNWIND_CONSOLIDATE")); + exceptionNames.insert(std::make_pair(0x80010001, "DBG_EXCEPTION_NOT_HANDLED")); + exceptionNames.insert(std::make_pair(0xC0000005, "EXCEPTION_ACCESS_VIOLATION")); + exceptionNames.insert(std::make_pair(0xC0000006, "EXCEPTION_IN_PAGE_ERROR")); + exceptionNames.insert(std::make_pair(0xC0000008, "EXCEPTION_INVALID_HANDLE")); + exceptionNames.insert(std::make_pair(0xC000000D, "STATUS_INVALID_PARAMETER")); + exceptionNames.insert(std::make_pair(0xC0000017, "STATUS_NO_MEMORY")); + exceptionNames.insert(std::make_pair(0xC000001D, "EXCEPTION_ILLEGAL_INSTRUCTION")); + exceptionNames.insert(std::make_pair(0xC0000025, "EXCEPTION_NONCONTINUABLE_EXCEPTION")); + exceptionNames.insert(std::make_pair(0xC0000026, "EXCEPTION_INVALID_DISPOSITION")); + exceptionNames.insert(std::make_pair(0xC000008C, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED")); + exceptionNames.insert(std::make_pair(0xC000008D, "EXCEPTION_FLT_DENORMAL_OPERAND")); + exceptionNames.insert(std::make_pair(0xC000008E, "EXCEPTION_FLT_DIVIDE_BY_ZERO")); + exceptionNames.insert(std::make_pair(0xC000008F, "EXCEPTION_FLT_INEXACT_RESULT")); + exceptionNames.insert(std::make_pair(0xC0000090, "EXCEPTION_FLT_INVALID_OPERATION")); + exceptionNames.insert(std::make_pair(0xC0000091, "EXCEPTION_FLT_OVERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000092, "EXCEPTION_FLT_STACK_CHECK")); + exceptionNames.insert(std::make_pair(0xC0000093, "EXCEPTION_FLT_UNDERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000094, "EXCEPTION_INT_DIVIDE_BY_ZERO")); + exceptionNames.insert(std::make_pair(0xC0000095, "EXCEPTION_INT_OVERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000096, "EXCEPTION_PRIV_INSTRUCTION")); + exceptionNames.insert(std::make_pair(0xC00000FD, "EXCEPTION_STACK_OVERFLOW")); + exceptionNames.insert(std::make_pair(0xC0000135, "STATUS_DLL_NOT_FOUND")); + exceptionNames.insert(std::make_pair(0xC0000138, "STATUS_ORDINAL_NOT_FOUND")); + exceptionNames.insert(std::make_pair(0xC0000139, "STATUS_ENTRYPOINT_NOT_FOUND")); + exceptionNames.insert(std::make_pair(0xC000013A, "STATUS_CONTROL_C_EXIT")); + exceptionNames.insert(std::make_pair(0xC0000142, "STATUS_DLL_INIT_FAILED")); + exceptionNames.insert(std::make_pair(0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT")); + exceptionNames.insert(std::make_pair(0xC0000194, "EXCEPTION_POSSIBLE_DEADLOCK")); + exceptionNames.insert(std::make_pair(0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS")); + exceptionNames.insert(std::make_pair(0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS")); + exceptionNames.insert(std::make_pair(0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR")); + exceptionNames.insert(std::make_pair(0xC00002C9, "STATUS_REG_NAT_CONSUMPTION")); + exceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN")); + exceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER")); + exceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE")); + exceptionNames.insert(std::make_pair(0x04242420, "CLRDBG_NOTIFICATION_EXCEPTION_CODE")); + exceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION")); + exceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION")); + exceptionNames.insert(std::make_pair(0x406D1388, "MS_VC_EXCEPTION")); + exceptionNames.insert(std::make_pair(0xC00001A5, "STATUS_INVALID_EXCEPTION_HANDLER")); } -const char* ExceptionCodeToName(unsigned int ExceptionCode) +const char* exceptionnamefromcode(unsigned int ExceptionCode) { - if(!ExceptionNames.count(ExceptionCode)) - return nullptr; - - return ExceptionNames[ExceptionCode]; + if(!exceptionNames.count(ExceptionCode)) + return 0; + return exceptionNames[ExceptionCode]; } \ No newline at end of file diff --git a/x64_dbg_dbg/exception.h b/x64_dbg_dbg/exception.h index 39043631..df0ea2a3 100644 --- a/x64_dbg_dbg/exception.h +++ b/x64_dbg_dbg/exception.h @@ -1,4 +1,7 @@ -#pragma once +#ifndef _EXCEPTION_H +#define _EXCEPTION_H -void ExceptionCodeInit(); -const char* ExceptionCodeToName(unsigned int ExceptionCode); \ No newline at end of file +void exceptioninit(); +const char* exceptionnamefromcode(unsigned int ExceptionCode); + +#endif //_EXCEPTIONS_H \ No newline at end of file diff --git a/x64_dbg_dbg/function.cpp b/x64_dbg_dbg/function.cpp index 48059ad1..cc5406d6 100644 --- a/x64_dbg_dbg/function.cpp +++ b/x64_dbg_dbg/function.cpp @@ -8,257 +8,185 @@ typedef std::map FunctionsInfo; static FunctionsInfo functions; -bool FunctionAdd(uint Start, uint End, bool Manual) +bool functionadd(uint start, uint end, bool manual) { - // CHECK: Export/Command function - if(!DbgIsDebugging()) + if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) return false; - - // Make sure memory is readable - if(!MemIsValidReadPtr(Start)) + const uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same module return false; - - // Fail if boundary exceeds module size - const uint moduleBase = ModBaseFromAddr(Start); - - if(moduleBase != ModBaseFromAddr(End)) + if(functionoverlaps(start, end)) return false; - - // Fail if 'Start' and 'End' are incompatible - if(Start > End || FunctionOverlaps(Start, End)) - return false; - FUNCTIONSINFO function; - ModNameFromAddr(Start, function.mod, true); - function.start = Start - moduleBase; - function.end = End - moduleBase; - function.manual = Manual; - - // Insert to global table - EXCLUSIVE_ACQUIRE(LockFunctions); - - functions.insert(std::make_pair(ModuleRange(ModHashFromAddr(moduleBase), Range(function.start, function.end)), function)); + modnamefromaddr(start, function.mod, true); + function.start = start - modbase; + function.end = end - modbase; + function.manual = manual; + CriticalSectionLocker locker(LockFunctions); + functions.insert(std::make_pair(ModuleRange(modhashfromva(modbase), Range(function.start, function.end)), function)); return true; } -bool FunctionGet(uint Address, uint* Start, uint* End) +bool functionget(uint addr, uint* start, uint* end) { - // CHECK: Exported function if(!DbgIsDebugging()) return false; - - const uint modbase = ModBaseFromAddr(Address); - - // Lookup by module hash, then function range - SHARED_ACQUIRE(LockFunctions); - - auto found = functions.find(ModuleRange(ModHashFromAddr(modbase), Range(Address - modbase, Address - modbase))); - - // Was this range found? - if(found == functions.end()) + uint modbase = modbasefromaddr(addr); + CriticalSectionLocker locker(LockFunctions); + const FunctionsInfo::iterator found = functions.find(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))); + if(found == functions.end()) //not found return false; - - if(Start) - *Start = found->second.start + modbase; - - if(End) - *End = found->second.end + modbase; - + if(start) + *start = found->second.start + modbase; + if(end) + *end = found->second.end + modbase; return true; } -bool FunctionOverlaps(uint Start, uint End) +bool functionoverlaps(uint start, uint end) { - // CHECK: Exported function - if(!DbgIsDebugging()) + if(!DbgIsDebugging() or end < start) return false; - - // A function can't end before it begins - if(Start > End) - return false; - - const uint moduleBase = ModBaseFromAddr(Start); - - SHARED_ACQUIRE(LockFunctions); - return (functions.count(ModuleRange(ModHashFromAddr(moduleBase), Range(Start - moduleBase, End - moduleBase))) > 0); + const uint modbase = modbasefromaddr(start); + CriticalSectionLocker locker(LockFunctions); + return (functions.count(ModuleRange(modhashfromva(modbase), Range(start - modbase, end - modbase))) > 0); } -bool FunctionDelete(uint Address) +bool functiondel(uint addr) { - // CHECK: Exported function if(!DbgIsDebugging()) return false; - - const uint moduleBase = ModBaseFromAddr(Address); - - EXCLUSIVE_ACQUIRE(LockFunctions); - return (functions.erase(ModuleRange(ModHashFromAddr(moduleBase), Range(Address - moduleBase, Address - moduleBase))) > 0); + const uint modbase = modbasefromaddr(addr); + CriticalSectionLocker locker(LockFunctions); + return (functions.erase(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))) > 0); } -void FunctionDelRange(uint Start, uint End) +void functiondelrange(uint start, uint end) { - // CHECK: Exported function if(!DbgIsDebugging()) return; - - // Should all functions be deleted? - // 0x00000000 - 0xFFFFFFFF - if(Start == 0 && End == ~0) + bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) + return; + start -= modbase; + end -= modbase; + CriticalSectionLocker locker(LockFunctions); + FunctionsInfo::iterator i = functions.begin(); + while(i != functions.end()) { - EXCLUSIVE_ACQUIRE(LockFunctions); - functions.clear(); - } - else - { - // The start and end address must be in the same module - uint moduleBase = ModBaseFromAddr(Start); - - if(moduleBase != ModBaseFromAddr(End)) - return; - - // Convert these to a relative offset - Start -= moduleBase; - End -= moduleBase; - - EXCLUSIVE_ACQUIRE(LockFunctions); - for(auto itr = functions.begin(); itr != functions.end();) + if(i->second.manual) //ignore manual { - // Ignore manually set entries - if(itr->second.manual) - { - itr++; - continue; - } - - // [Start, End] - if(itr->second.end >= Start && itr->second.start <= End) - itr = functions.erase(itr); - else - itr++; + i++; + continue; } - } -} - -void FunctionCacheSave(JSON Root) -{ - EXCLUSIVE_ACQUIRE(LockFunctions); - - // Allocate JSON object array - const JSON jsonFunctions = json_array(); - const JSON jsonAutoFunctions = json_array(); - - for(auto & i : functions) - { - JSON currentFunction = json_object(); - - json_object_set_new(currentFunction, "module", json_string(i.second.mod)); - json_object_set_new(currentFunction, "start", json_hex(i.second.start)); - json_object_set_new(currentFunction, "end", json_hex(i.second.end)); - - if(i.second.manual) - json_array_append_new(jsonFunctions, currentFunction); + if(bDelAll or !(i->second.start <= end and i->second.end >= start)) + functions.erase(i++); else - json_array_append_new(jsonAutoFunctions, currentFunction); + i++; } - - if(json_array_size(jsonFunctions)) - json_object_set(Root, "functions", jsonFunctions); - - if(json_array_size(jsonAutoFunctions)) - json_object_set(Root, "autofunctions", jsonAutoFunctions); - - // Decrease reference count to avoid leaking memory - json_decref(jsonFunctions); - json_decref(jsonAutoFunctions); } -void FunctionCacheLoad(JSON Root) +void functioncachesave(JSON root) { - EXCLUSIVE_ACQUIRE(LockFunctions); + CriticalSectionLocker locker(LockFunctions); + const JSON jsonfunctions = json_array(); + const JSON jsonautofunctions = json_array(); + for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i) + { + const FUNCTIONSINFO curFunction = i->second; + JSON curjsonfunction = json_object(); + json_object_set_new(curjsonfunction, "module", json_string(curFunction.mod)); + json_object_set_new(curjsonfunction, "start", json_hex(curFunction.start)); + json_object_set_new(curjsonfunction, "end", json_hex(curFunction.end)); + if(curFunction.manual) + json_array_append_new(jsonfunctions, curjsonfunction); + else + json_array_append_new(jsonautofunctions, curjsonfunction); + } + if(json_array_size(jsonfunctions)) + json_object_set(root, "functions", jsonfunctions); + json_decref(jsonfunctions); + if(json_array_size(jsonautofunctions)) + json_object_set(root, "autofunctions", jsonautofunctions); + json_decref(jsonautofunctions); +} - // Delete existing entries +void functioncacheload(JSON root) +{ + CriticalSectionLocker locker(LockFunctions); functions.clear(); - - // Inline lambda to enumerate all JSON array indices - auto InsertFunctions = [](const JSON Object, bool Manual) + const JSON jsonfunctions = json_object_get(root, "functions"); + if(jsonfunctions) { size_t i; JSON value; - json_array_foreach(Object, i, value) + json_array_foreach(jsonfunctions, i, value) { - FUNCTIONSINFO function; - - // Copy module name + FUNCTIONSINFO curFunction; const char* mod = json_string_value(json_object_get(value, "module")); - if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) - strcpy_s(function.mod, mod); + strcpy_s(curFunction.mod, mod); else - function.mod[0] = '\0'; - - // Function address - function.start = (uint)json_hex_value(json_object_get(value, "start")); - function.end = (uint)json_hex_value(json_object_get(value, "end")); - function.manual = Manual; - - // Sanity check - if(function.end < function.start) - continue; - - const uint key = ModHashFromName(function.mod); - functions.insert(std::make_pair(ModuleRange(ModHashFromName(function.mod), Range(function.start, function.end)), function)); + *curFunction.mod = '\0'; + curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); + curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); + if(curFunction.end < curFunction.start) + continue; //invalid function + curFunction.manual = true; + const uint key = modhashfromname(curFunction.mod); + functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); } - }; - - const JSON jsonFunctions = json_object_get(Root, "functions"); - const JSON jsonAutoFunctions = json_object_get(Root, "autofunctions"); - - if(jsonFunctions) - InsertFunctions(jsonFunctions, true); - - if(jsonAutoFunctions) - InsertFunctions(jsonAutoFunctions, false); + } + JSON jsonautofunctions = json_object_get(root, "autofunctions"); + if(jsonautofunctions) + { + size_t i; + JSON value; + json_array_foreach(jsonautofunctions, i, value) + { + FUNCTIONSINFO curFunction; + const char* mod = json_string_value(json_object_get(value, "module")); + if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE) + strcpy_s(curFunction.mod, mod); + else + *curFunction.mod = '\0'; + curFunction.start = (uint)json_hex_value(json_object_get(value, "start")); + curFunction.end = (uint)json_hex_value(json_object_get(value, "end")); + if(curFunction.end < curFunction.start) + continue; //invalid function + curFunction.manual = true; + const uint key = modhashfromname(curFunction.mod); + functions.insert(std::make_pair(ModuleRange(modhashfromname(curFunction.mod), Range(curFunction.start, curFunction.end)), curFunction)); + } + } } -bool FunctionEnum(FUNCTIONSINFO* List, size_t* Size) +bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize) { - // CHECK: Exported function if(!DbgIsDebugging()) return false; - - // If a list isn't passed and the size not requested, fail - if(!List && !Size) + if(!functionlist && !cbsize) return false; - - SHARED_ACQUIRE(LockFunctions); - - // Did the caller request the buffer size needed? - if(Size) + CriticalSectionLocker locker(LockFunctions); + if(!functionlist && cbsize) { - *Size = functions.size() * sizeof(FUNCTIONSINFO); - - if(!List) - return true; + *cbsize = functions.size() * sizeof(FUNCTIONSINFO); + return true; } - - // Fill out the buffer - for(auto & itr : functions) + int j = 0; + for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i, j++) { - // Adjust for relative to virtual addresses - uint moduleBase = ModBaseFromName(itr.second.mod); - - *List = itr.second; - List->start += moduleBase; - List->end += moduleBase; - - List++; + functionlist[j] = i->second; + uint modbase = modbasefromname(functionlist[j].mod); + functionlist[j].start += modbase; + functionlist[j].end += modbase; } - return true; } -void FunctionClear() +void functionclear() { - EXCLUSIVE_ACQUIRE(LockFunctions); - functions.clear(); + CriticalSectionLocker locker(LockFunctions); + FunctionsInfo().swap(functions); } \ No newline at end of file diff --git a/x64_dbg_dbg/function.h b/x64_dbg_dbg/function.h index 41afb223..53f4adda 100644 --- a/x64_dbg_dbg/function.h +++ b/x64_dbg_dbg/function.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _FUNCTION_H +#define _FUNCTION_H #include "addrinfo.h" @@ -10,12 +11,14 @@ struct FUNCTIONSINFO bool manual; }; -bool FunctionAdd(uint Start, uint End, bool Manual); -bool FunctionGet(uint Address, uint* Start, uint* End); -bool FunctionOverlaps(uint Start, uint End); -bool FunctionDelete(uint Address); -void FunctionDelRange(uint Start, uint End); -void FunctionCacheSave(JSON Root); -void FunctionCacheLoad(JSON Root); -bool FunctionEnum(FUNCTIONSINFO* List, size_t* Size); -void FunctionClear(); \ No newline at end of file +bool functionadd(uint start, uint end, bool manual); +bool functionget(uint addr, uint* start, uint* end); +bool functionoverlaps(uint start, uint end); +bool functiondel(uint addr); +void functiondelrange(uint start, uint end); +void functioncachesave(JSON root); +void functioncacheload(JSON root); +bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize); +void functionclear(); + +#endif //_FUNCTION_H \ No newline at end of file diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index 6e0ee4ec..f9cba729 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -158,7 +158,7 @@ CMDRESULT cbInstrMov(int argc, char* argv[]) } //Check the destination uint dest; - if(!valfromstring(argv[1], &dest) || !MemIsValidReadPtr(dest)) + if(!valfromstring(argv[1], &dest) || !memisvalidreadptr(fdProcessInfo->hProcess, dest)) { dprintf("invalid destination \"%s\"\n", argv[1]); return STATUS_ERROR; @@ -175,7 +175,7 @@ CMDRESULT cbInstrMov(int argc, char* argv[]) data[j] = res; } //Move data to destination - if(!MemWrite((void*)dest, data, data.size(), 0)) + if(!memwrite(fdProcessInfo->hProcess, (void*)dest, data, data.size(), 0)) { dprintf("failed to write to "fhex"\n", dest); return STATUS_ERROR; @@ -294,7 +294,7 @@ CMDRESULT cbInstrCmt(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!CommentSet(addr, argv[2], true)) + if(!commentset(addr, argv[2], true)) { dputs("error setting comment"); return STATUS_ERROR; @@ -312,7 +312,7 @@ CMDRESULT cbInstrCmtdel(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!CommentDelete(addr)) + if(!commentdel(addr)) { dputs("error deleting comment"); return STATUS_ERROR; @@ -368,7 +368,7 @@ CMDRESULT cbInstrBookmarkSet(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!BookmarkSet(addr, true)) + if(!bookmarkset(addr, true)) { dputs("failed to set bookmark!"); return STATUS_ERROR; @@ -387,7 +387,7 @@ CMDRESULT cbInstrBookmarkDel(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!BookmarkDelete(addr)) + if(!bookmarkdel(addr)) { dputs("failed to delete bookmark!"); return STATUS_ERROR; @@ -454,7 +454,7 @@ CMDRESULT cbFunctionAdd(int argc, char* argv[]) uint end = 0; if(!valfromstring(argv[1], &start, false) or !valfromstring(argv[2], &end, false)) return STATUS_ERROR; - if(!FunctionAdd(start, end, true)) + if(!functionadd(start, end, true)) { dputs("failed to add function"); return STATUS_ERROR; @@ -474,7 +474,7 @@ CMDRESULT cbFunctionDel(int argc, char* argv[]) uint addr = 0; if(!valfromstring(argv[1], &addr, false)) return STATUS_ERROR; - if(!FunctionDelete(addr)) + if(!functiondel(addr)) { dputs("failed to delete function"); return STATUS_ERROR; @@ -1053,7 +1053,7 @@ CMDRESULT cbInstrCopystr(int argc, char* argv[]) dprintf("invalid address \"%s\"!\n", argv[1]); return STATUS_ERROR; } - if(!MemPatch((void*)addr, string, strlen(string), 0)) + if(!mempatch(fdProcessInfo->hProcess, (void*)addr, string, strlen(string), 0)) { dputs("memwrite failed!"); return STATUS_ERROR; @@ -1084,14 +1084,14 @@ CMDRESULT cbInstrFind(int argc, char* argv[]) if(pattern[len - 1] == '#') pattern[len - 1] = '\0'; uint size = 0; - uint base = MemFindBaseAddr(addr, &size, true); + uint base = memfindbaseaddr(addr, &size, true); if(!base) { dprintf("invalid memory address "fhex"!\n", addr); return STATUS_ERROR; } Memory data(size, "cbInstrFind:data"); - if(!MemRead((void*)base, data, size, 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)base, data, size, 0)) { dputs("failed to read memory!"); return STATUS_ERROR; @@ -1136,14 +1136,14 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[]) if(pattern[len - 1] == '#') pattern[len - 1] = '\0'; uint size = 0; - uint base = MemFindBaseAddr(addr, &size, true); + uint base = memfindbaseaddr(addr, &size, true); if(!base) { dprintf("invalid memory address "fhex"!\n", addr); return STATUS_ERROR; } Memory data(size, "cbInstrFindAll:data"); - if(!MemRead((void*)base, data, size, 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)base, data, size, 0)) { dputs("failed to read memory!"); return STATUS_ERROR; @@ -1192,7 +1192,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[]) if(findData) { Memory printData(patternsize, "cbInstrFindAll:printData"); - MemRead((void*)result, printData, patternsize, 0); + memread(fdProcessInfo->hProcess, (const void*)result, printData, patternsize, 0); for(int j = 0, k = 0; j < patternsize; j++) { if(j) @@ -1270,14 +1270,14 @@ CMDRESULT cbInstrCommentList(int argc, char* argv[]) GuiReferenceAddColumn(0, "Comment"); GuiReferenceReloadData(); size_t cbsize; - CommentEnum(0, &cbsize); + commentenum(0, &cbsize); if(!cbsize) { dputs("no comments"); return STATUS_CONTINUE; } Memory comments(cbsize, "cbInstrCommentList:comments"); - CommentEnum(comments, 0); + commentenum(comments, 0); int count = (int)(cbsize / sizeof(COMMENTSINFO)); for(int i = 0; i < count; i++) { @@ -1339,14 +1339,14 @@ CMDRESULT cbInstrBookmarkList(int argc, char* argv[]) GuiReferenceAddColumn(0, "Disassembly"); GuiReferenceReloadData(); size_t cbsize; - BookmarkEnum(0, &cbsize); + bookmarkenum(0, &cbsize); if(!cbsize) { dputs("no bookmarks"); return STATUS_CONTINUE; } Memory bookmarks(cbsize, "cbInstrBookmarkList:bookmarks"); - BookmarkEnum(bookmarks, 0); + bookmarkenum(bookmarks, 0); int count = (int)(cbsize / sizeof(BOOKMARKSINFO)); for(int i = 0; i < count; i++) { @@ -1374,14 +1374,14 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[]) GuiReferenceAddColumn(0, "Label/Comment"); GuiReferenceReloadData(); size_t cbsize; - FunctionEnum(0, &cbsize); + functionenum(0, &cbsize); if(!cbsize) { dputs("no functions"); return STATUS_CONTINUE; } Memory functions(cbsize, "cbInstrFunctionList:functions"); - FunctionEnum(functions, 0); + functionenum(functions, 0); int count = (int)(cbsize / sizeof(FUNCTIONSINFO)); for(int i = 0; i < count; i++) { @@ -1400,7 +1400,7 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[]) else { char comment[MAX_COMMENT_SIZE] = ""; - if(CommentGet(functions[i].start, comment)) + if(commentget(functions[i].start, comment)) GuiReferenceSetCellContent(i, 3, comment); } } @@ -1446,7 +1446,7 @@ CMDRESULT cbInstrLoopList(int argc, char* argv[]) else { char comment[MAX_COMMENT_SIZE] = ""; - if(CommentGet(loops[i].start, comment)) + if(commentget(loops[i].start, comment)) GuiReferenceSetCellContent(i, 3, comment); } } diff --git a/x64_dbg_dbg/label.cpp b/x64_dbg_dbg/label.cpp index 56d7d745..9421ef7f 100644 --- a/x64_dbg_dbg/label.cpp +++ b/x64_dbg_dbg/label.cpp @@ -4,13 +4,13 @@ #include "memory.h" #include "debugger.h" -typedef std::unordered_map LabelsInfo; +typedef std::map LabelsInfo; static LabelsInfo labels; bool labelset(uint addr, const char* text, bool manual) { - if(!DbgIsDebugging() or !MemIsValidReadPtr(addr) or !text or strlen(text) >= MAX_LABEL_SIZE - 1 or strstr(text, "&")) + if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text) >= MAX_LABEL_SIZE - 1 or strstr(text, "&")) return false; if(!*text) //NOTE: delete when there is no text { @@ -20,11 +20,11 @@ bool labelset(uint addr, const char* text, bool manual) LABELSINFO label; label.manual = manual; strcpy_s(label.text, text); - ModNameFromAddr(addr, label.mod, true); - label.addr = addr - ModBaseFromAddr(addr); - uint key = ModHashFromAddr(addr); + modnamefromaddr(addr, label.mod, true); + label.addr = addr - modbasefromaddr(addr); + uint key = modhashfromva(addr); CriticalSectionLocker locker(LockLabels); - if(!labels.insert(std::make_pair(ModHashFromAddr(key), label)).second) //already present + if(!labels.insert(std::make_pair(modhashfromva(key), label)).second) //already present labels[key] = label; return true; } @@ -39,7 +39,7 @@ bool labelfromstring(const char* text, uint* addr) if(!strcmp(i->second.text, text)) { if(addr) - *addr = i->second.addr + ModBaseFromName(i->second.mod); + *addr = i->second.addr + modbasefromname(i->second.mod); return true; } } @@ -51,7 +51,7 @@ bool labelget(uint addr, char* text) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockLabels); - const LabelsInfo::iterator found = labels.find(ModHashFromAddr(addr)); + const LabelsInfo::iterator found = labels.find(modhashfromva(addr)); if(found == labels.end()) //not found return false; if(text) @@ -64,7 +64,7 @@ bool labeldel(uint addr) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockLabels); - return (labels.erase(ModHashFromAddr(addr)) > 0); + return (labels.erase(modhashfromva(addr)) > 0); } void labeldelrange(uint start, uint end) @@ -72,8 +72,8 @@ void labeldelrange(uint start, uint end) if(!DbgIsDebugging()) return; bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = ModBaseFromAddr(start); - if(modbase != ModBaseFromAddr(end)) + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) return; start -= modbase; end -= modbase; @@ -146,7 +146,7 @@ void labelcacheload(JSON root) for(int i = 0; i < len; i++) if(curLabel.text[i] == '&') curLabel.text[i] = ' '; - const uint key = ModHashFromName(curLabel.mod) + curLabel.addr; + const uint key = modhashfromname(curLabel.mod) + curLabel.addr; labels.insert(std::make_pair(key, curLabel)); } } @@ -170,7 +170,7 @@ void labelcacheload(JSON root) strcpy_s(curLabel.text, text); else continue; //skip - const uint key = ModHashFromName(curLabel.mod) + curLabel.addr; + const uint key = modhashfromname(curLabel.mod) + curLabel.addr; labels.insert(std::make_pair(key, curLabel)); } } @@ -192,7 +192,7 @@ bool labelenum(LABELSINFO* labellist, size_t* cbsize) for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i, j++) { labellist[j] = i->second; - labellist[j].addr += ModBaseFromName(labellist[j].mod); + labellist[j].addr += modbasefromname(labellist[j].mod); } return true; } diff --git a/x64_dbg_dbg/loop.cpp b/x64_dbg_dbg/loop.cpp index 50c42327..a390513d 100644 --- a/x64_dbg_dbg/loop.cpp +++ b/x64_dbg_dbg/loop.cpp @@ -10,16 +10,16 @@ static LoopsInfo loops; bool loopadd(uint start, uint end, bool manual) { - if(!DbgIsDebugging() or end < start or !MemIsValidReadPtr(start)) + if(!DbgIsDebugging() or end < start or !memisvalidreadptr(fdProcessInfo->hProcess, start)) return false; - const uint modbase = ModBaseFromAddr(start); - if(modbase != ModBaseFromAddr(end)) //the function boundaries are not in the same mem page + const uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) //the function boundaries are not in the same mem page return false; int finaldepth; if(loopoverlaps(0, start, end, &finaldepth)) //loop cannot overlap another loop return false; LOOPSINFO loop; - ModNameFromAddr(start, loop.mod, true); + modnamefromaddr(start, loop.mod, true); loop.start = start - modbase; loop.end = end - modbase; loop.depth = finaldepth; @@ -29,7 +29,7 @@ bool loopadd(uint start, uint end, bool manual) loop.parent = 0; loop.manual = manual; CriticalSectionLocker locker(LockLoops); - loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(ModHashFromAddr(modbase), Range(loop.start, loop.end))), loop)); + loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(modhashfromva(modbase), Range(loop.start, loop.end))), loop)); return true; } @@ -38,9 +38,9 @@ bool loopget(int depth, uint addr, uint* start, uint* end) { if(!DbgIsDebugging()) return false; - const uint modbase = ModBaseFromAddr(addr); + const uint modbase = modbasefromaddr(addr); CriticalSectionLocker locker(LockLoops); - LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(ModHashFromAddr(modbase), Range(addr - modbase, addr - modbase)))); + LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase)))); if(found == loops.end()) //not found return false; if(start) @@ -56,10 +56,10 @@ bool loopoverlaps(int depth, uint start, uint end, int* finaldepth) if(!DbgIsDebugging()) return false; - const uint modbase = ModBaseFromAddr(start); + const uint modbase = modbasefromaddr(start); uint curStart = start - modbase; uint curEnd = end - modbase; - const uint key = ModHashFromAddr(modbase); + const uint key = modhashfromva(modbase); CriticalSectionLocker locker(LockLoops); @@ -145,7 +145,7 @@ void loopcacheload(JSON root) if(curLoop.end < curLoop.start) continue; //invalid loop curLoop.manual = true; - loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(ModHashFromName(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); + loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); } } JSON jsonautoloops = json_object_get(root, "autoloops"); @@ -168,45 +168,36 @@ void loopcacheload(JSON root) if(curLoop.end < curLoop.start) continue; //invalid loop curLoop.manual = false; - loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(ModHashFromName(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); + loops.insert(std::make_pair(DepthModuleRange(curLoop.depth, ModuleRange(modhashfromname(curLoop.mod), Range(curLoop.start, curLoop.end))), curLoop)); } } } -bool loopenum(LOOPSINFO* List, size_t* Size) +bool loopenum(LOOPSINFO* looplist, size_t* cbsize) { - // If looplist or size is not requested, fail - if(!List && !Size) + if(!DbgIsDebugging()) return false; - - SHARED_ACQUIRE(LockLoops); - - // See if the caller requested an output size - if(Size) + if(!looplist && !cbsize) + return false; + CriticalSectionLocker locker(LockLoops); + if(!looplist && cbsize) { - *Size = loops.size() * sizeof(LOOPSINFO); - - if(!List) - return true; + *cbsize = loops.size() * sizeof(LOOPSINFO); + return true; } - - for(auto itr = loops.begin(); itr != loops.end(); itr++) + int j = 0; + for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i, j++) { - *List = itr->second; - - // Adjust the offset to a real virtual address - uint modbase = ModBaseFromName(List->mod); - List->start += modbase; - List->end += modbase; - - List++; + looplist[j] = i->second; + uint modbase = modbasefromname(looplist[j].mod); + looplist[j].start += modbase; + looplist[j].end += modbase; } - return true; } void loopclear() { - EXCLUSIVE_ACQUIRE(LockLoops); - loops.clear(); + CriticalSectionLocker locker(LockLoops); + LoopsInfo().swap(loops); } \ No newline at end of file diff --git a/x64_dbg_dbg/math.cpp b/x64_dbg_dbg/math.cpp index 85914657..5d1759b9 100644 --- a/x64_dbg_dbg/math.cpp +++ b/x64_dbg_dbg/math.cpp @@ -1,19 +1,12 @@ #include "math.h" #include "value.h" -enum BRACKET_TYPE -{ - BRACKET_FREE, - BRACKET_OPEN, - BRACKET_CLOSE, -}; - struct BRACKET_PAIR { int openpos; int closepos; int layer; - BRACKET_TYPE isset; + int isset; //0=free, 1=open, 2=close }; struct EXPRESSION @@ -25,8 +18,7 @@ struct EXPRESSION /* operator precedence -0 (INVALID/NONE) -1 ( ) (PARENTHESIS) +1 ( ) 2 ~ (NOT) 3 * / % (MUL DIV) 4 + - (ADD SUB) @@ -35,21 +27,18 @@ operator precedence 7 ^ (XOR) 8 | (OR) */ + int mathisoperator(char ch) { - // - // The lower the number, the higher the priority. - // Zero indicates no operator was found. - // - if(ch == '(' || ch == ')') + if(ch == '(' or ch == ')') return 1; else if(ch == '~') return 2; - else if(ch == '*' || ch == '`' || ch == '/' || ch == '%') + else if(ch == '*' or ch == '`' or ch == '/' or ch == '%') return 3; - else if(ch == '+' || ch == '-') + else if(ch == '+' or ch == '-') return 4; - else if(ch == '<' || ch == '>') + else if(ch == '<' or ch == '>') return 5; else if(ch == '&') return 6; @@ -57,7 +46,6 @@ int mathisoperator(char ch) return 7; else if(ch == '|') return 8; - return 0; } @@ -69,13 +57,10 @@ void mathformat(char* text) { int len = (int)strlen(text); Memory temp(len + 1, "mathformat:temp"); - - for (int i = 0, j = 0; i < len; i++) - { - if (mathisoperator(text[i]) < 3 || text[i] != text[i + 1]) - j += sprintf(temp + j, "%c", text[i]); - } - + memset(temp, 0, len + 1); + for(int i = 0, j = 0; i < len; i++) + if(mathisoperator(text[i]) < 3 or text[i] != text[i + 1]) + j += sprintf(temp + j, "%c", text[i]); strcpy(text, temp); } @@ -84,138 +69,172 @@ void mathformat(char* text) */ bool mathcontains(const char* text) { - // Skip negative values - if(*text == '-') + if(*text == '-') //ignore negative values text++; - - // Search the entire string looking for a math operator - for (; text[0] != '\0'; text++) - { - if (mathisoperator(text[0])) - return true; - } - + int len = (int)strlen(text); + for(int i = 0; i < len; i++) + if(mathisoperator(text[i])) + return true; return false; } #ifdef __MINGW64__ -inline unsigned long long umulhi(unsigned long long x, unsigned long long y) +static inline unsigned long long umulhi(unsigned long long x, unsigned long long y) { return (unsigned long long)(((__uint128_t)x * y) >> 64); } -inline long long mulhi(long long x, long long y) +static inline long long mulhi(long long x, long long y) { return (long long)(((__int128_t)x * y) >> 64); } #elif _WIN64 #include -inline unsigned long long umulhi(unsigned long long x, unsigned long long y) +static inline unsigned long long umulhi(unsigned long long x, unsigned long long y) { unsigned __int64 res; _umul128(x, y, &res); return res; } -inline long long mulhi(long long x, long long y) +static inline long long mulhi(long long x, long long y) { __int64 res; _mul128(x, y, &res); return res; } #else -inline unsigned int umulhi(unsigned int x, unsigned int y) +static inline unsigned int umulhi(unsigned int x, unsigned int y) { return (unsigned int)(((unsigned long long)x * y) >> 32); } -inline int mulhi(int x, int y) +static inline int mulhi(int x, int y) { return (int)(((long long)x * y) >> 32); } #endif //__MINGW64__ -template -bool MathDoOperation(char op, T left, T right, T* result) -{ - switch (op) - { - case '*': - *result = left * right; - return true; - case '`': - *result = umulhi(left, right); - return true; - case '/': - if (right) - { - *result = left / right; - return true; - } - return false; - case '%': - if (right) - { - *result = left % right; - return true; - } - return false; - case '+': - *result = left + right; - return true; - case '-': - *result = left - right; - return true; - case '<': - *result = left << right; - return true; - case '>': - *result = left >> right; - return true; - case '&': - *result = left & right; - return true; - case '^': - *result = left ^ right; - return true; - case '|': - *result = left | right; - return true; - } - return false; -} - bool mathdounsignedoperation(char op, uint left, uint right, uint* result) { - return MathDoOperation(op, left, right, result); + switch(op) + { + case '*': + *result = left * right; + return true; + case '`': + *result = umulhi(left, right); + return true; + case '/': + if(right) + { + *result = left / right; + return true; + } + return false; + case '%': + if(right) + { + *result = left % right; + return true; + } + return false; + case '+': + *result = left + right; + return true; + case '-': + *result = left - right; + return true; + case '<': + *result = left << right; + return true; + case '>': + *result = left >> right; + return true; + case '&': + *result = left & right; + return true; + case '^': + *result = left ^ right; + return true; + case '|': + *result = left | right; + return true; + } + return false; } bool mathdosignedoperation(char op, sint left, sint right, sint* result) { - return MathDoOperation(op, left, right, result); + switch(op) + { + case '*': + *result = left * right; + return true; + case '`': + *result = mulhi(left, right); + return true; + case '/': + if(right) + { + *result = left / right; + return true; + } + return false; + case '%': + if(right) + { + *result = left % right; + return true; + } + return false; + case '+': + *result = left + right; + return true; + case '-': + *result = left - right; + return true; + case '<': + *result = left << right; + return true; + case '>': + *result = left >> right; + return true; + case '&': + *result = left & right; + return true; + case '^': + *result = left ^ right; + return true; + case '|': + *result = left | right; + return true; + } + return false; } -void fillpair(EXPRESSION* expstruct, int pos, int layer) +static void fillpair(EXPRESSION* expstruct, int pos, int layer) { for(int i = 0; i < expstruct->total_pairs; i++) { - if(expstruct->pairs[i].isset == BRACKET_FREE) + if(!expstruct->pairs[i].isset) { - expstruct->pairs[i].layer = layer; - expstruct->pairs[i].openpos = pos; - expstruct->pairs[i].isset = BRACKET_OPEN; + expstruct->pairs[i].layer = layer; + expstruct->pairs[i].openpos = pos; + expstruct->pairs[i].isset = 1; break; } - else if(expstruct->pairs[i].layer == layer && expstruct->pairs[i].isset == BRACKET_OPEN) + else if(expstruct->pairs[i].layer == layer and expstruct->pairs[i].isset == 1) { - expstruct->pairs[i].closepos = pos; - expstruct->pairs[i].isset = BRACKET_CLOSE; + expstruct->pairs[i].closepos = pos; + expstruct->pairs[i].isset = 2; break; } } } -int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer) + +static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer) { int layer = endlayer; int len = (int)strlen(expression); @@ -243,7 +262,7 @@ int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer) return 0; } -int expressionformat(char* exp) +static int expressionformat(char* exp) { int len = (int)strlen(exp); int open = 0; @@ -266,36 +285,35 @@ int expressionformat(char* exp) return open; } -void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int new_len) +static void adjustpairs(EXPRESSION* exps, int cur_open, int cur_close, int cur_len, int new_len) { for(int i = 0; i < exps->total_pairs; i++) { if(exps->pairs[i].openpos > cur_open) exps->pairs[i].openpos += new_len - cur_len; - if(exps->pairs[i].closepos > cur_close) exps->pairs[i].closepos += new_len - cur_len; } } -bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly) +static bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseonly) { for(int i = 0; i < exps->total_pairs; i++) { if(exps->pairs[i].layer == layer) { - int open = exps->pairs[i].openpos; - int close = exps->pairs[i].closepos; - int len = close - open; + char temp[256] = ""; + char backup[256] = ""; - char temp[256]; + int open = exps->pairs[i].openpos; + int close = exps->pairs[i].closepos; + int len = close - open; strncpy(temp, exp + open + 1, len - 1); - char backup[256]; strcpy_s(backup, exp + open + len + 1); uint value; - if(!mathfromstring(temp, &value, silent, baseonly, nullptr, nullptr)) + if(!mathfromstring(temp, &value, silent, baseonly, 0, 0)) return false; adjustpairs(exps, open, close, len + 1, sprintf(exp + open, "%"fext"X", value)); @@ -305,41 +323,32 @@ bool printlayer(char* exp, EXPRESSION* exps, int layer, bool silent, bool baseon } } - return true; } bool mathhandlebrackets(char* expression, bool silent, bool baseonly) { - int totalPairs = expressionformat(expression); - - if(totalPairs == -1) + EXPRESSION expstruct; + expstruct.expression = expression; + int total_pairs = expressionformat(expression); + if(total_pairs == -1) return false; - else if(!totalPairs) + else if(!total_pairs) return true; + expstruct.total_pairs = total_pairs; - Memory pairs(totalPairs * sizeof(BRACKET_PAIR), "mathhandlebrackets:pairs"); - - EXPRESSION expStruct; - expStruct.expression = expression; - expStruct.total_pairs = totalPairs; - expStruct.pairs = pairs; - - matchpairs(&expStruct, expression, 0); - + Memory pairs(expstruct.total_pairs * sizeof(BRACKET_PAIR), "mathhandlebrackets:expstruct.pairs"); + expstruct.pairs = pairs; + memset(expstruct.pairs, 0, expstruct.total_pairs * sizeof(BRACKET_PAIR)); + matchpairs(&expstruct, expression, 0); int deepest = 0; - for (int i = 0; i < expStruct.total_pairs; i++) - { - if (expStruct.pairs[i].layer > deepest) - deepest = expStruct.pairs[i].layer; - } - - for (int i = deepest; i > 0; i--) - { - if (!printlayer(expression, &expStruct, i, silent, baseonly)) - return false; - } + for(int i = 0; i < expstruct.total_pairs; i++) + if(expstruct.pairs[i].layer > deepest) + deepest = expstruct.pairs[i].layer; + for(int i = deepest; i > 0; i--) + if(!printlayer(expression, &expstruct, i, silent, baseonly)) + return false; return true; } @@ -370,6 +379,8 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, return valfromstring(string, value, silent, baseonly, value_size, isvar, 0); Memory strleft(len + 1 + negative, "mathfromstring:strleft"); Memory strright(len + 1, "mathfromstring:strright"); + memset(strleft, 0, len + 1); + memset(strright, 0, len + 1); strncpy(strleft, string - negative, highestop_pos + negative); strcpy(strright, string + highestop_pos + 1); strcpy(strleft, StringUtils::Trim(strleft).c_str()); diff --git a/x64_dbg_dbg/math.h b/x64_dbg_dbg/math.h index d6ea8867..97fa745c 100644 --- a/x64_dbg_dbg/math.h +++ b/x64_dbg_dbg/math.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _MATH_H +#define _MATH_H #include "_global.h" @@ -8,4 +9,6 @@ bool mathcontains(const char* text); bool mathhandlebrackets(char* expression, bool silent, bool baseonly); bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly, int* value_size, bool* isvar); bool mathdounsignedoperation(char op, uint left, uint right, uint* result); -bool mathdosignedoperation(char op, sint left, sint right, sint* result); \ No newline at end of file +bool mathdosignedoperation(char op, sint left, sint right, sint* result); + +#endif // _MATH_H diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 22f331e7..03074db3 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -5,16 +5,10 @@ #include "threading.h" #include "module.h" -#define PAGE_SHIFT (12) -#define PAGE_SIZE (4096) -#define PAGE_ALIGN(Va) ((ULONG_PTR)((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1))) -#define BYTES_TO_PAGES(Size) (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) -#define ROUND_TO_PAGES(Size) (((ULONG_PTR)(Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) - MemoryMap memoryPages; bool bListAllPages = false; -void MemUpdateMap(HANDLE hProcess) +void memupdatemap(HANDLE hProcess) { CriticalSectionLocker locker(LockMemoryPages); MEMORY_BASIC_INFORMATION mbi; @@ -33,7 +27,7 @@ void MemUpdateMap(HANDLE hProcess) curAllocationBase = (uint)mbi.AllocationBase; MEMPAGE curPage; *curPage.info = 0; - ModNameFromAddr(MyAddress, curPage.info, true); + modnamefromaddr(MyAddress, curPage.info, true); memcpy(&curPage.mbi, &mbi, sizeof(mbi)); pageVector.push_back(curPage); } @@ -56,11 +50,11 @@ void MemUpdateMap(HANDLE hProcess) if(!pageVector.at(i).info[0] || (scmp(curMod, pageVector.at(i).info) && !bListAllPages)) //there is a module continue; //skip non-modules strcpy(curMod, pageVector.at(i).info); - uint base = ModBaseFromName(pageVector.at(i).info); + uint base = modbasefromname(pageVector.at(i).info); if(!base) continue; std::vector sections; - if(!ModSectionsFromAddr(base, §ions)) + if(!modsectionsfromaddr(base, §ions)) continue; int SectionNumber = (int)sections.size(); if(!SectionNumber) //no sections = skip @@ -129,187 +123,102 @@ void MemUpdateMap(HANDLE hProcess) } } -uint MemFindBaseAddr(uint addr, uint* Size, bool refresh) +uint memfindbaseaddr(uint addr, uint* size, bool refresh) { - // Update the memory map if needed if(refresh) - MemUpdateMap(fdProcessInfo->hProcess); - - SHARED_ACQUIRE(LockMemoryPages); - - // Search for the memory page address - auto found = memoryPages.find(std::make_pair(addr, addr)); - + memupdatemap(fdProcessInfo->hProcess); //update memory map + CriticalSectionLocker locker(LockMemoryPages); + MemoryMap::iterator found = memoryPages.find(std::make_pair(addr, addr)); if(found == memoryPages.end()) return 0; - - // Return the allocation region size when requested - if(Size) - *Size = found->second.mbi.RegionSize; - + if(size) + *size = found->second.mbi.RegionSize; return found->first.first; } -bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesRead) +bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead) { - // Fast fail if address is invalid - if (!MemIsCanonicalAddress((uint)BaseAddress)) - return false; - - // Buffer must be supplied and size must be greater than 0 - if (!Buffer || Size <= 0) - return false; - - // If the 'bytes read' parameter is null, use a temp - SIZE_T bytesReadTemp = 0; - - if (!NumberOfBytesRead) - NumberOfBytesRead = &bytesReadTemp; - - // Normal single-call read - bool ret = MemoryReadSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesRead); - - if (ret && *NumberOfBytesRead == Size) - return true; - - // Read page-by-page (Skip if only 1 page exists) - // If (SIZE > PAGE_SIZE) or (ADDRESS exceeds boundary), multiple reads will be needed - SIZE_T pageCount = BYTES_TO_PAGES(Size); - - if (pageCount > 1) - { - // Determine the number of bytes between ADDRESS and the next page - uint offset = 0; - uint readBase = (uint)BaseAddress; - uint readSize = ROUND_TO_PAGES(readBase) - readBase; - - // Reset the bytes read count - *NumberOfBytesRead = 0; - - for (SIZE_T i = 0; i < pageCount; i++) - { - SIZE_T bytesRead = 0; - - if (MemoryReadSafe(fdProcessInfo->hProcess, (PVOID)readBase, ((PBYTE)Buffer + offset), readSize, &bytesRead)) - *NumberOfBytesRead += bytesRead; - - offset += readSize; - readBase += readSize; - - Size -= readSize; - readSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; - } - } - - SetLastError(ERROR_PARTIAL_COPY); - return (*NumberOfBytesRead > 0); -} - -bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) -{ - // Fast fail if address is invalid - if (!MemIsCanonicalAddress((uint)BaseAddress)) - return false; - - // Buffer must be supplied and size must be greater than 0 - if(!Buffer || Size <= 0) + if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures return false; - - // If the 'bytes written' parameter is null, use a temp - SIZE_T bytesWrittenTemp = 0; - - if(!NumberOfBytesWritten) - NumberOfBytesWritten = &bytesWrittenTemp; - - // Try a regular WriteProcessMemory call - bool ret = MemoryWriteSafe(fdProcessInfo->hProcess, BaseAddress, Buffer, Size, NumberOfBytesWritten); - - if(ret && * NumberOfBytesWritten == Size) - return true; - - // Write page-by-page (Skip if only 1 page exists) - // See: MemRead - SIZE_T pageCount = BYTES_TO_PAGES(Size); - - if (pageCount > 1) - { - // Determine the number of bytes between ADDRESS and the next page - uint offset = 0; - uint writeBase = (uint)BaseAddress; - uint writeSize = ROUND_TO_PAGES(writeBase) - writeBase; - - // Reset the bytes read count - *NumberOfBytesWritten = 0; - - for (SIZE_T i = 0; i < pageCount; i++) - { - SIZE_T bytesWritten = 0; - - if (MemoryWriteSafe(fdProcessInfo->hProcess, (PVOID)writeBase, ((PBYTE)Buffer + offset), writeSize, &bytesWritten)) - *NumberOfBytesWritten += bytesWritten; - - offset += writeSize; - writeBase += writeSize; - - Size -= writeSize; - writeSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; - } - } - - SetLastError(ERROR_PARTIAL_COPY); - return (*NumberOfBytesWritten > 0); -} - -bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) -{ - // Buffer and size must be valid - if(!Buffer || Size <= 0) - return false; - - // Allocate the memory - Memory oldData(Size, "mempatch:oldData"); - - if(!MemRead(BaseAddress, oldData, Size, nullptr)) + SIZE_T read = 0; + DWORD oldprotect = 0; + bool ret = MemoryReadSafe(hProcess, (void*)lpBaseAddress, lpBuffer, nSize, &read); //try 'normal' RPM + if(ret and read == nSize) //'normal' RPM worked! { - // If no memory can be read, no memory can be written. Fail out - // of this function. - return false; + if(lpNumberOfBytesRead) + *lpNumberOfBytesRead = read; + return true; } - - for(SIZE_T i = 0; i < Size; i++) - patchset((uint)BaseAddress + i, oldData[i], ((unsigned char*)Buffer)[i]); - - return MemWrite(BaseAddress, Buffer, Size, NumberOfBytesWritten); + for(uint i = 0; i < nSize; i++) //read byte-per-byte + { + unsigned char* curaddr = (unsigned char*)lpBaseAddress + i; + unsigned char* curbuf = (unsigned char*)lpBuffer + i; + ret = MemoryReadSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' RPM + if(!ret) //we failed + { + if(lpNumberOfBytesRead) + *lpNumberOfBytesRead = i; + SetLastError(ERROR_PARTIAL_COPY); + return false; + } + } + return true; } -bool MemIsValidReadPtr(uint Address) +bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten) +{ + if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures + return false; + SIZE_T written = 0; + DWORD oldprotect = 0; + bool ret = MemoryWriteSafe(hProcess, lpBaseAddress, lpBuffer, nSize, &written); + if(ret and written == nSize) //'normal' WPM worked! + { + if(lpNumberOfBytesWritten) + *lpNumberOfBytesWritten = written; + return true; + } + for(uint i = 0; i < nSize; i++) //write byte-per-byte + { + unsigned char* curaddr = (unsigned char*)lpBaseAddress + i; + unsigned char* curbuf = (unsigned char*)lpBuffer + i; + ret = MemoryWriteSafe(hProcess, curaddr, curbuf, 1, 0); //try 'normal' WPM + if(!ret) //we failed + { + if(lpNumberOfBytesWritten) + *lpNumberOfBytesWritten = i; + SetLastError(ERROR_PARTIAL_COPY); + return false; + } + } + return true; +} + +bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten) +{ + if(!hProcess or !lpBaseAddress or !lpBuffer or !nSize) //generic failures + return false; + Memory olddata(nSize, "mempatch:olddata"); + if(!memread(hProcess, lpBaseAddress, olddata, nSize, 0)) + return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten); + unsigned char* newdata = (unsigned char*)lpBuffer; + for(uint i = 0; i < nSize; i++) + patchset((uint)lpBaseAddress + i, olddata[i], newdata[i]); + return memwrite(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten); +} + +bool memisvalidreadptr(HANDLE hProcess, uint addr) { unsigned char a = 0; - return MemRead((void*)Address, &a, 1, nullptr); + return memread(hProcess, (void*)addr, &a, 1, 0); } -bool MemIsCanonicalAddress(uint Address) +void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect) { -#ifndef _WIN64 - // 32-bit mode only supports 4GB max, so limits are - // not an issue - return true; -#else - // The most-significant 16 bits must be all 1 or all 0. - // (64 - 16) = 48bit linear address range. - // - // 0xFFFF800000000000 = Significant 16 bits set - // 0x0000800000000000 = 48th bit set - return (((Address & 0xFFFF800000000000) + 0x800000000000) & ~0x800000000000) == 0; -#endif // _WIN64 + return VirtualAllocEx(hProcess, (void*)addr, size, MEM_RESERVE | MEM_COMMIT, fdProtect); } -void* MemAllocRemote(uint Address, SIZE_T Size, DWORD Protect) +void memfree(HANDLE hProcess, uint addr) { - return VirtualAllocEx(fdProcessInfo->hProcess, (void*)Address, Size, MEM_RESERVE | MEM_COMMIT, Protect); -} - -void MemFreeRemote(uint Address) -{ - VirtualFreeEx(fdProcessInfo->hProcess, (void*)Address, 0, MEM_RELEASE); + VirtualFreeEx(hProcess, (void*)addr, 0, MEM_RELEASE); } \ No newline at end of file diff --git a/x64_dbg_dbg/memory.h b/x64_dbg_dbg/memory.h index 4fd833f1..c17c6f18 100644 --- a/x64_dbg_dbg/memory.h +++ b/x64_dbg_dbg/memory.h @@ -1,3 +1,6 @@ +#ifndef _MEMORY_H +#define _MEMORY_H + #include "_global.h" #include "addrinfo.h" @@ -6,12 +9,13 @@ typedef std::map MemoryMap; extern MemoryMap memoryPages; extern bool bListAllPages; -void MemUpdateMap(HANDLE hProcess); -uint MemFindBaseAddr(uint addr, uint* Size, bool refresh = false); -bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesRead); -bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); -bool MemPatch(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); -bool MemIsValidReadPtr(uint Address); -bool MemIsCanonicalAddress(uint Address); -void* MemAllocRemote(uint Address, SIZE_T Size, DWORD Protect); -void MemFreeRemote(uint Address); \ No newline at end of file +void memupdatemap(HANDLE hProcess); +uint memfindbaseaddr(uint addr, uint* size, bool refresh = false); +bool memread(HANDLE hProcess, const void* lpBaseAddress, void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead); +bool memwrite(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten); +bool mempatch(HANDLE hProcess, void* lpBaseAddress, const void* lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten); +bool memisvalidreadptr(HANDLE hProcess, uint addr); +void* memalloc(HANDLE hProcess, uint addr, SIZE_T size, DWORD fdProtect); +void memfree(HANDLE hProcess, uint addr); + +#endif // _MEMORY_H diff --git a/x64_dbg_dbg/module.cpp b/x64_dbg_dbg/module.cpp index 3ec8edb0..3d4c91cf 100644 --- a/x64_dbg_dbg/module.cpp +++ b/x64_dbg_dbg/module.cpp @@ -6,262 +6,194 @@ static ModulesInfo modinfo; -bool ModLoad(uint Base, uint Size, const char* FullPath) +///module functions +bool modload(uint base, uint size, const char* fullpath) { - // - // Handle a new module being loaded - // - // TODO: Do loaded modules always require a path? - if(!Base || !Size || !FullPath) + if(!base or !size or !fullpath) return false; + char name[deflen] = ""; + int len = (int)strlen(fullpath); + while(fullpath[len] != '\\' and len) + len--; + if(len) + len++; + strcpy_s(name, fullpath + len); + _strlwr(name); + len = (int)strlen(name); + name[MAX_MODULE_SIZE - 1] = 0; //ignore later characters + while(name[len] != '.' and len) + len--; MODINFO info; - - // Break the module path into a directory and file name - char dir[deflen]; - char* file; - - if(GetFullPathNameA(FullPath, ARRAYSIZE(dir), dir, &file) == 0) - return false; - - // Make everything lowercase - _strlwr(dir); - - // Copy the extension into the module struct - { - char* extensionPos = strrchr(file, '.'); - - if(extensionPos) - { - strcpy_s(info.extension, extensionPos); - extensionPos[0] = '\0'; - } - } - - // Copy the name to the module struct - strcpy_s(info.name, file); - - // Module base address/size/hash index - info.hash = ModHashFromName(info.name); - info.base = Base; - info.size = Size; - - // Process module sections + memset(&info, 0, sizeof(MODINFO)); info.sections.clear(); - - WString wszFullPath = StringUtils::Utf8ToUtf16(FullPath); - if(StaticFileLoadW(wszFullPath.c_str(), UE_ACCESS_READ, false, &info.Handle, &info.FileMapSize, &info.MapHandle, &info.FileMapVA)) + info.hash = modhashfromname(name); + if(len) { - // Get the entry point - info.entry = GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_OEP) + info.base; + strcpy_s(info.extension, name + len); + name[len] = 0; //remove extension + } + info.base = base; + info.size = size; + strcpy_s(info.name, name); - // Enumerate all PE sections - int sectionCount = (int)GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_SECTIONNUMBER); - - for(int i = 0; i < sectionCount; i++) + //process module sections + HANDLE FileHandle; + DWORD LoadedSize; + HANDLE FileMap; + ULONG_PTR FileMapVA; + WString wszFullPath = StringUtils::Utf8ToUtf16(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); + if(SectionCount > 0) { - MODSECTIONINFO curSection; - - curSection.addr = GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONVIRTUALOFFSET) + info.base; - curSection.size = GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONVIRTUALSIZE); - const char* sectionName = (const char*)GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONNAME); - - // Escape section name when needed - strcpy_s(curSection.name, StringUtils::Escape(sectionName).c_str()); - - // Add entry to the vector - info.sections.push_back(curSection); + for(int i = 0; i < SectionCount; i++) + { + MODSECTIONINFO curSection; + curSection.addr = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALOFFSET) + base; + curSection.size = GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONVIRTUALSIZE); + const char* SectionName = (const char*)GetPE32DataFromMappedFile(FileMapVA, i, UE_SECTIONNAME); + //escape section name when needed + int len = (int)strlen(SectionName); + int escape_count = 0; + for(int k = 0; k < len; k++) + if(SectionName[k] == '\\' or SectionName[k] == '\"' or !isprint(SectionName[k])) + escape_count++; + strcpy_s(curSection.name, StringUtils::Escape(SectionName).c_str()); + info.sections.push_back(curSection); + } } + StaticFileUnloadW(wszFullPath.c_str(), false, FileHandle, LoadedSize, FileMap, FileMapVA); } - // Add module to list - EXCLUSIVE_ACQUIRE(LockModules); - modinfo.insert(std::make_pair(Range(Base, Base + Size - 1), info)); - EXCLUSIVE_RELEASE(); - - SymUpdateModuleList(); + //add module to list + CriticalSectionLocker locker(LockModules); + modinfo.insert(std::make_pair(Range(base, base + size - 1), info)); + symupdatemodulelist(); return true; } -bool ModUnload(uint Base) +bool modunload(uint base) { - EXCLUSIVE_ACQUIRE(LockModules); - - // Find the iterator index - const auto found = modinfo.find(Range(Base, Base)); - - if(found == modinfo.end()) + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(base, base)); + if(found == modinfo.end()) //not found return false; - - // Remove it from the list modinfo.erase(found); - - // Unload everything from TitanEngine - StaticFileUnloadW(nullptr, false, found->second.Handle, found->second.FileMapSize, found->second.MapHandle, found->second.FileMapVA); - EXCLUSIVE_RELEASE(); - - // Update symbols - SymUpdateModuleList(); + symupdatemodulelist(); return true; } -void ModClear() +void modclear() { - EXCLUSIVE_ACQUIRE(LockModules); - modinfo.clear(); - EXCLUSIVE_RELEASE(); - - // Tell the symbol updater - SymUpdateModuleList(); + CriticalSectionLocker locker(LockModules); + ModulesInfo().swap(modinfo); + symupdatemodulelist(); } -MODINFO* ModInfoFromAddr(uint Address) +bool modnamefromaddr(uint addr, char* modname, bool extension) { - // - // NOTE: THIS DOES _NOT_ USE LOCKS - // - auto found = modinfo.find(Range(Address, Address)); - - // Was the module found with this address? - if(found == modinfo.end()) - return nullptr; - - return &found->second; -} - -bool ModNameFromAddr(uint Address, char* Name, bool Extension) -{ - if(!Name) + if(!modname) return false; - - SHARED_ACQUIRE(LockModules); - - // Get a pointer to module information - auto module = ModInfoFromAddr(Address); - - if(!module) + *modname = '\0'; + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found return false; - - // Copy initial module name - strcpy_s(Name, MAX_MODULE_SIZE, module->name); - - if(Extension) - strcat_s(Name, MAX_MODULE_SIZE, module->extension); - + String mod = found->second.name; + if(extension) + mod += found->second.extension; + strcpy_s(modname, MAX_MODULE_SIZE, mod.c_str()); return true; } -uint ModBaseFromAddr(uint Address) +uint modbasefromaddr(uint addr) { - SHARED_ACQUIRE(LockModules); - - auto module = ModInfoFromAddr(Address); - - if(!module) + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found return 0; - - return module->base; + return found->second.base; } -uint ModHashFromAddr(uint Address) +uint modhashfromva(uint va) //return a unique hash from a VA { - // - // Returns a unique hash from a virtual address - // - SHARED_ACQUIRE(LockModules); - - auto module = ModInfoFromAddr(Address); - - if(!module) - return Address; - - return module->hash + (Address - module->base); + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(va, va)); + if(found == modinfo.end()) //not found + return va; + return found->second.hash + (va - found->second.base); } -uint ModHashFromName(const char* Module) +uint modhashfromname(const char* mod) //return MODINFO.hash { - // - // return MODINFO.hash (based on the name) - // - if(!Module || Module[0] == '\0') + if(!mod or !*mod) return 0; - - return murmurhash(Module, (int)strlen(Module)); + int len = (int)strlen(mod); + return murmurhash(mod, len); } -uint ModBaseFromName(const char* Module) +uint modbasefromname(const char* modname) { - if(!Module || strlen(Module) >= MAX_MODULE_SIZE) + if(!modname or strlen(modname) >= MAX_MODULE_SIZE) return 0; - - SHARED_ACQUIRE(LockModules); - - for(auto itr = modinfo.begin(); itr != modinfo.end(); itr++) + CriticalSectionLocker locker(LockModules); + for(ModulesInfo::iterator i = modinfo.begin(); i != modinfo.end(); ++i) { - char currentModule[MAX_MODULE_SIZE]; - strcpy_s(currentModule, itr->second.name); - strcat_s(currentModule, itr->second.extension); - - // Test with and without extension - if(!_stricmp(currentModule, Module) || !_stricmp(itr->second.name, Module)) - return itr->second.base; + MODINFO* curMod = &i->second; + char curmodname[MAX_MODULE_SIZE] = ""; + sprintf(curmodname, "%s%s", curMod->name, curMod->extension); + if(!_stricmp(curmodname, modname)) //with extension + return curMod->base; + if(!_stricmp(curMod->name, modname)) //without extension + return curMod->base; } - return 0; } -uint ModSizeFromAddr(uint Address) +uint modsizefromaddr(uint addr) { - SHARED_ACQUIRE(LockModules); - - auto module = ModInfoFromAddr(Address); - - if(!module) + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found return 0; - - return module->size; + return found->second.size; } -bool ModSectionsFromAddr(uint Address, std::vector* Sections) +bool modsectionsfromaddr(uint addr, std::vector* sections) { - SHARED_ACQUIRE(LockModules); - - auto module = ModInfoFromAddr(Address); - - if(!module) + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found return false; - - // Copy vector <-> vector - *Sections = module->sections; + *sections = found->second.sections; return true; } -uint ModEntryFromAddr(uint Address) +uint modentryfromaddr(uint addr) { - SHARED_ACQUIRE(LockModules); - - auto module = ModInfoFromAddr(Address); - - if(!module) + CriticalSectionLocker locker(LockModules); + const ModulesInfo::iterator found = modinfo.find(Range(addr, addr)); + if(found == modinfo.end()) //not found return 0; - - return module->entry; + return found->second.entry; } -int ModPathFromAddr(duint Address, char* Path, int Size) +int modpathfromaddr(duint addr, char* path, int size) { - SHARED_ACQUIRE(LockModules); - - auto module = ModInfoFromAddr(Address); - - if(!module) + Memory wszModPath(size * sizeof(wchar_t), "modpathfromaddr:wszModPath"); + if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), wszModPath, size)) + { + *path = '\0'; return 0; - - strcpy_s(Path, Size, module->path); - return (int)strlen(Path); + } + strcpy_s(path, size, StringUtils::Utf16ToUtf8(wszModPath()).c_str()); + return (int)strlen(path); } -int ModPathFromName(const char* Module, char* Path, int Size) +int modpathfromname(const char* modname, char* path, int size) { - return ModPathFromAddr(ModBaseFromName(Module), Path, Size); -} \ No newline at end of file + return modpathfromaddr(modbasefromname(modname), path, size); +} diff --git a/x64_dbg_dbg/module.h b/x64_dbg_dbg/module.h index 656cc310..95edba18 100644 --- a/x64_dbg_dbg/module.h +++ b/x64_dbg_dbg/module.h @@ -1,47 +1,40 @@ -#pragma once +#ifndef _MODULE_H +#define _MODULE_H #include "_global.h" #include "addrinfo.h" struct MODSECTIONINFO { - uint addr; // Virtual address - uint size; // Virtual size - char name[50]; // Escaped section name + uint addr; //va + uint size; //virtual size + char name[50]; }; struct MODINFO { - uint base; // Module base - uint size; // Module size - uint hash; // Full module name hash - uint entry; // Entry point - - char name[MAX_MODULE_SIZE]; // Module name (without extension) - char extension[MAX_MODULE_SIZE]; // File extension - char path[MAX_PATH]; // File path (in UTF8) - - HANDLE Handle; // Handle to the file opened by TitanEngine - HANDLE MapHandle; // Handle to the memory map - ULONG_PTR FileMapVA; // File map virtual address (Debugger local) - DWORD FileMapSize; // File map virtual size - + uint base; //module base + uint size; //module size + uint hash; //full module name hash + uint entry; //entry point + char name[MAX_MODULE_SIZE]; //module name (without extension) + char extension[MAX_MODULE_SIZE]; //file extension std::vector sections; }; - typedef std::map ModulesInfo; -bool ModLoad(uint Base, uint Size, const char* FullPath); -bool ModUnload(uint Base); -void ModClear(); -MODINFO* ModInfoFromAddr(uint Address); -bool ModNameFromAddr(uint Address, char* Name, bool Extension); -uint ModBaseFromAddr(uint Address); -uint ModHashFromAddr(uint Address); -uint ModHashFromName(const char* Module); -uint ModBaseFromName(const char* Module); -uint ModSizeFromAddr(uint Address); -bool ModSectionsFromAddr(uint Address, std::vector* Sections); -uint ModEntryFromAddr(uint Address); -int ModPathFromAddr(duint Address, char* Path, int Size); -int ModPathFromName(const char* Module, char* Path, int Size); \ No newline at end of file +bool modload(uint base, uint size, const char* fullpath); +bool modunload(uint base); +void modclear(); +bool modnamefromaddr(uint addr, char* modname, bool extension); +uint modbasefromaddr(uint addr); +uint modhashfromva(uint va); +uint modhashfromname(const char* mod); +uint modbasefromname(const char* modname); +uint modsizefromaddr(uint addr); +bool modsectionsfromaddr(uint addr, std::vector* sections); +uint modentryfromaddr(uint addr); +int modpathfromaddr(duint addr, char* path, int size); +int modpathfromname(const char* modname, char* path, int size); + +#endif //_MODULE_H \ No newline at end of file diff --git a/x64_dbg_dbg/patches.cpp b/x64_dbg_dbg/patches.cpp index a15a29b6..c567aec7 100644 --- a/x64_dbg_dbg/patches.cpp +++ b/x64_dbg_dbg/patches.cpp @@ -10,16 +10,16 @@ static PatchesInfo patches; bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte) { - if(!DbgIsDebugging() || !MemIsValidReadPtr(addr)) + if(!DbgIsDebugging() || !memisvalidreadptr(fdProcessInfo->hProcess, addr)) return false; if(oldbyte == newbyte) return true; //no need to make a patch for a byte that is equal to itself PATCHINFO newPatch; - newPatch.addr = addr - ModBaseFromAddr(addr); - ModNameFromAddr(addr, newPatch.mod, true); + newPatch.addr = addr - modbasefromaddr(addr); + modnamefromaddr(addr, newPatch.mod, true); newPatch.oldbyte = oldbyte; newPatch.newbyte = newbyte; - uint key = ModHashFromAddr(addr); + uint key = modhashfromva(addr); CriticalSectionLocker locker(LockPatches); PatchesInfo::iterator found = patches.find(key); if(found != patches.end()) //we found a patch on the specified address @@ -45,13 +45,13 @@ bool patchget(uint addr, PATCHINFO* patch) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockPatches); - PatchesInfo::iterator found = patches.find(ModHashFromAddr(addr)); + PatchesInfo::iterator found = patches.find(modhashfromva(addr)); if(found == patches.end()) //not found return false; if(patch) { *patch = found->second; - patch->addr += ModBaseFromAddr(addr); + patch->addr += modbasefromaddr(addr); return true; } return (found->second.oldbyte != found->second.newbyte); @@ -62,11 +62,11 @@ bool patchdel(uint addr, bool restore) if(!DbgIsDebugging()) return false; CriticalSectionLocker locker(LockPatches); - PatchesInfo::iterator found = patches.find(ModHashFromAddr(addr)); + PatchesInfo::iterator found = patches.find(modhashfromva(addr)); if(found == patches.end()) //not found return false; if(restore) - MemWrite((void*)(found->second.addr + ModBaseFromAddr(addr)), &found->second.oldbyte, sizeof(char), 0); + memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr + modbasefromaddr(addr)), &found->second.oldbyte, sizeof(char), 0); patches.erase(found); return true; } @@ -76,8 +76,8 @@ void patchdelrange(uint start, uint end, bool restore) if(!DbgIsDebugging()) return; bool bDelAll = (start == 0 && end == ~0); //0x00000000-0xFFFFFFFF - uint modbase = ModBaseFromAddr(start); - if(modbase != ModBaseFromAddr(end)) + uint modbase = modbasefromaddr(start); + if(modbase != modbasefromaddr(end)) return; start -= modbase; end -= modbase; @@ -88,7 +88,7 @@ void patchdelrange(uint start, uint end, bool restore) if(bDelAll || (i->second.addr >= start && i->second.addr < end)) { if(restore) - MemWrite((void*)(i->second.addr + modbase), &i->second.oldbyte, sizeof(char), 0); + memwrite(fdProcessInfo->hProcess, (void*)(i->second.addr + modbase), &i->second.oldbyte, sizeof(char), 0); patches.erase(i++); } else @@ -130,7 +130,7 @@ bool patchenum(PATCHINFO* patcheslist, size_t* cbsize) for(PatchesInfo::iterator i = patches.begin(); i != patches.end(); ++i, j++) { patcheslist[j] = i->second; - uint modbase = ModBaseFromName(patcheslist[j].mod); + uint modbase = modbasefromname(patcheslist[j].mod); patcheslist[j].addr += modbase; } return true; @@ -154,7 +154,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha sprintf(error, "not all patches are in module %s", modname); return -1; } - uint modbase = ModBaseFromName(modname); + uint modbase = modbasefromname(modname); if(!modbase) //module not loaded { if(error) diff --git a/x64_dbg_dbg/plugin_loader.cpp b/x64_dbg_dbg/plugin_loader.cpp index 43bf1653..1e8fc555 100644 --- a/x64_dbg_dbg/plugin_loader.cpp +++ b/x64_dbg_dbg/plugin_loader.cpp @@ -303,7 +303,7 @@ void plugincbcall(CBTYPE cbType, void* callbackInfo) if(pluginCallbackList.at(i).cbType == cbType) { CBPLUGIN cbPlugin = pluginCallbackList.at(i).cbPlugin; - if(!IsBadReadPtr((const void*)cbPlugin, sizeof(uint))) + if(memisvalidreadptr(GetCurrentProcess(), (uint)cbPlugin)) cbPlugin(cbType, callbackInfo); } } diff --git a/x64_dbg_dbg/reference.cpp b/x64_dbg_dbg/reference.cpp index 5bd33a2f..0f7e3ccd 100644 --- a/x64_dbg_dbg/reference.cpp +++ b/x64_dbg_dbg/reference.cpp @@ -10,7 +10,7 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent, cons uint start_size; uint base; uint base_size; - base = MemFindBaseAddr(addr, &base_size, true); + base = memfindbaseaddr(addr, &base_size, true); if(!base or !base_size) { if(!silent) @@ -33,7 +33,7 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent, cons start_size = maxsize; } Memory data(start_size, "reffind:data"); - if(!MemRead((void*)start_addr, data, start_size, 0)) + if(!memread(fdProcessInfo->hProcess, (const void*)start_addr, data, start_size, 0)) { if(!silent) dputs("error reading memory"); @@ -53,7 +53,7 @@ int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent, cons refinfo.userinfo = userinfo; char fullName[deflen] = ""; char modname[MAX_MODULE_SIZE] = ""; - if(ModNameFromAddr(start_addr, modname, true)) + if(modnamefromaddr(start_addr, modname, true)) sprintf_s(fullName, "%s (%s)", name, modname); else sprintf_s(fullName, "%s (%p)", name, start_addr); diff --git a/x64_dbg_dbg/stackinfo.cpp b/x64_dbg_dbg/stackinfo.cpp index 1b484e1b..89ebb514 100644 --- a/x64_dbg_dbg/stackinfo.cpp +++ b/x64_dbg_dbg/stackinfo.cpp @@ -12,17 +12,17 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) { uint data = 0; memset(comment, 0, sizeof(STACK_COMMENT)); - MemRead((void*)addr, &data, sizeof(uint), 0); - if(!MemIsValidReadPtr(data)) //the stack value is no pointer + memread(fdProcessInfo->hProcess, (const void*)addr, &data, sizeof(uint), 0); + if(!memisvalidreadptr(fdProcessInfo->hProcess, data)) //the stack value is no pointer return false; uint size = 0; - uint base = MemFindBaseAddr(data, &size); + uint base = memfindbaseaddr(data, &size); uint readStart = data - 16 * 4; if(readStart < base) readStart = base; unsigned char disasmData[256]; - MemRead((void*)readStart, disasmData, sizeof(disasmData), 0); + memread(fdProcessInfo->hProcess, (const void*)readStart, disasmData, sizeof(disasmData), 0); uint prev = disasmback(disasmData, 0, sizeof(disasmData), data - readStart, 1); uint previousInstr = readStart + prev; @@ -44,7 +44,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; - ModNameFromAddr(data, module, false); + modnamefromaddr(data, module, false); char returnToAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnToAddr, "%s.", module); @@ -60,7 +60,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); *module = 0; - ModNameFromAddr(data, module, false); + modnamefromaddr(data, module, false); char returnFromAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnFromAddr, "%s.", module); @@ -94,7 +94,7 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; - ModNameFromAddr(data, module, false); + modnamefromaddr(data, module, false); char addrInfo[MAX_COMMENT_SIZE] = ""; if(*module) //module { @@ -118,12 +118,12 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) callstack->total = 0; if(!DbgIsDebugging() or csp % sizeof(uint)) //alignment problem return; - if(!MemIsValidReadPtr(csp)) + if(!memisvalidreadptr(fdProcessInfo->hProcess, csp)) return; std::vector callstackVector; DWORD ticks = GetTickCount(); uint stacksize = 0; - uint stackbase = MemFindBaseAddr(csp, &stacksize, false); + uint stackbase = memfindbaseaddr(csp, &stacksize, false); if(!stackbase) //super-fail (invalid stack address) return; //walk up the stack @@ -131,16 +131,16 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) while(i != stackbase + stacksize) { uint data = 0; - MemRead((void*)i, &data, sizeof(uint), 0); - if(MemIsValidReadPtr(data)) //the stack value is a pointer + memread(fdProcessInfo->hProcess, (const void*)i, &data, sizeof(uint), 0); + if(memisvalidreadptr(fdProcessInfo->hProcess, data)) //the stack value is a pointer { uint size = 0; - uint base = MemFindBaseAddr(data, &size); + uint base = memfindbaseaddr(data, &size); uint readStart = data - 16 * 4; if(readStart < base) readStart = base; unsigned char disasmData[256]; - MemRead((void*)readStart, disasmData, sizeof(disasmData), 0); + memread(fdProcessInfo->hProcess, (const void*)readStart, disasmData, sizeof(disasmData), 0); uint prev = disasmback(disasmData, 0, sizeof(disasmData), data - readStart, 1); uint previousInstr = readStart + prev; BASIC_INSTRUCTION_INFO basicinfo; @@ -153,7 +153,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); char module[MAX_MODULE_SIZE] = ""; - ModNameFromAddr(data, module, false); + modnamefromaddr(data, module, false); char returnToAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnToAddr, "%s.", module); @@ -176,7 +176,7 @@ void stackgetcallstack(uint csp, CALLSTACK* callstack) if(_dbg_addrinfoget(data, SEG_DEFAULT, &addrinfo)) strcpy_s(label, addrinfo.label); *module = 0; - ModNameFromAddr(data, module, false); + modnamefromaddr(data, module, false); char returnFromAddr[MAX_COMMENT_SIZE] = ""; if(*module) sprintf(returnFromAddr, "%s.", module); diff --git a/x64_dbg_dbg/symbolinfo.cpp b/x64_dbg_dbg/symbolinfo.cpp index 0e58fb9d..e1e05ab7 100644 --- a/x64_dbg_dbg/symbolinfo.cpp +++ b/x64_dbg_dbg/symbolinfo.cpp @@ -11,234 +11,166 @@ struct SYMBOLCBDATA void* user; }; -static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO SymInfo, ULONG SymbolSize, PVOID UserContext) +static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext) { + int len = (int)strlen(pSymInfo->Name); SYMBOLINFO curSymbol; memset(&curSymbol, 0, sizeof(SYMBOLINFO)); - - curSymbol.addr = (duint)SymInfo->Address; - curSymbol.decoratedSymbol = (char*)BridgeAlloc(strlen(SymInfo->Name) + 1); + curSymbol.addr = (duint)pSymInfo->Address; + curSymbol.decoratedSymbol = (char*)BridgeAlloc(len + 1); + strcpy_s(curSymbol.decoratedSymbol, len + 1, pSymInfo->Name); curSymbol.undecoratedSymbol = (char*)BridgeAlloc(MAX_SYM_NAME); - strcpy_s(curSymbol.decoratedSymbol, strlen(SymInfo->Name) + 1, SymInfo->Name); - - // Skip bad ordinals - if(strstr(SymInfo->Name, "Ordinal")) + if(strstr(pSymInfo->Name, "Ordinal")) { - // Does the symbol point to the module base? - if(SymInfo->Address == SymInfo->ModBase) + //skip bad ordinals + if(pSymInfo->Address == pSymInfo->ModBase) return TRUE; } - - // Convert a mangled/decorated C++ name to a readable format - if(!SafeUnDecorateSymbolName(SymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) + if(!SafeUnDecorateSymbolName(pSymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE)) { BridgeFree(curSymbol.undecoratedSymbol); - curSymbol.undecoratedSymbol = nullptr; + curSymbol.undecoratedSymbol = 0; } else if(!strcmp(curSymbol.decoratedSymbol, curSymbol.undecoratedSymbol)) { BridgeFree(curSymbol.undecoratedSymbol); - curSymbol.undecoratedSymbol = nullptr; + curSymbol.undecoratedSymbol = 0; } - SYMBOLCBDATA* cbData = (SYMBOLCBDATA*)UserContext; cbData->cbSymbolEnum(&curSymbol, cbData->user); return TRUE; } -void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData) +void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user) { SYMBOLCBDATA symbolCbData; - symbolCbData.cbSymbolEnum = EnumCallback; - symbolCbData.user = UserData; - - // Enumerate every single symbol for the module in 'base' - if(!SafeSymEnumSymbols(fdProcessInfo->hProcess, Base, "*", EnumSymbols, &symbolCbData)) - dputs("SymEnumSymbols failed!"); + symbolCbData.cbSymbolEnum = cbSymbolEnum; + symbolCbData.user = user; + char mask[] = "*"; + SafeSymEnumSymbols(fdProcessInfo->hProcess, base, mask, EnumSymbols, &symbolCbData); } -bool SymGetModuleList(std::vector* List) +#ifdef _WIN64 +static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) +#else +static BOOL CALLBACK EnumModules(LPCTSTR ModuleName, ULONG BaseOfDll, PVOID UserContext) +#endif //_WIN64 { - // - // Inline lambda enum - // - auto EnumModules = [](LPCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) -> BOOL - { - SYMBOLMODULEINFO curModule; - curModule.base = (duint)BaseOfDll; - - // Terminate module name if one isn't found - if(!ModNameFromAddr(curModule.base, curModule.name, true)) - curModule.name[0] = '\0'; - - ((std::vector*)UserContext)->push_back(curModule); - return TRUE; - }; - - // Execute the symbol enumerator (Force cast to STDCALL) - if(!SafeSymEnumerateModules64(fdProcessInfo->hProcess, EnumModules, List)) - { - dputs("SymEnumerateModules64 failed!"); - return false; - } - - return true; + SYMBOLMODULEINFO curModule; + memset(&curModule, 0, sizeof(SYMBOLMODULEINFO)); + curModule.base = BaseOfDll; + modnamefromaddr(BaseOfDll, curModule.name, true); + ((std::vector*)UserContext)->push_back(curModule); + return TRUE; } -void SymUpdateModuleList() +void symupdatemodulelist() { - // Build the vector of modules std::vector modList; - - if(!SymGetModuleList(&modList)) - return; - - // Create a new array to be sent to the GUI thread - size_t moduleCount = modList.size(); - SYMBOLMODULEINFO *data = (SYMBOLMODULEINFO *)BridgeAlloc(moduleCount * sizeof(SYMBOLMODULEINFO)); - - // Direct copy from std::vector data - memcpy(data, modList.data(), moduleCount * sizeof(SYMBOLMODULEINFO)); - - // Send the module data to the GUI for updating - GuiSymbolUpdateModuleList((int)moduleCount, data); + modList.clear(); + SafeSymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); + int modcount = (int)modList.size(); + SYMBOLMODULEINFO* modListBridge = (SYMBOLMODULEINFO*)BridgeAlloc(sizeof(SYMBOLMODULEINFO) * modcount); + for(int i = 0; i < modcount; i++) + memcpy(&modListBridge[i], &modList.at(i), sizeof(SYMBOLMODULEINFO)); + GuiSymbolUpdateModuleList(modcount, modListBridge); } -void SymDownloadAllSymbols(const char* SymbolStore) +void symdownloadallsymbols(const char* szSymbolStore) { - // Default to Microsoft's symbol server - if(!SymbolStore) - SymbolStore = "http://msdl.microsoft.com/download/symbols"; - - // Build the vector of modules + if(!szSymbolStore) + szSymbolStore = "http://msdl.microsoft.com/download/symbols"; std::vector modList; - - if(!SymGetModuleList(&modList)) + modList.clear(); + SafeSymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList); + int modcount = (int)modList.size(); + if(!modcount) return; - - // Skip loading if there aren't any found modules - if(modList.size() <= 0) - return; - - // Backup the current symbol search path - char oldSearchPath[MAX_PATH]; - - if(!SafeSymGetSearchPath(fdProcessInfo->hProcess, oldSearchPath, MAX_PATH)) + char szOldSearchPath[MAX_PATH] = ""; + if(!SafeSymGetSearchPath(fdProcessInfo->hProcess, szOldSearchPath, MAX_PATH)) //backup current path { dputs("SymGetSearchPath failed!"); return; } - - // Use the custom server path and directory - char customSearchPath[MAX_PATH * 2]; - sprintf_s(customSearchPath, "SRV*%s*%s", szSymbolCachePath, SymbolStore); - - if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, customSearchPath)) + char szServerSearchPath[MAX_PATH * 2] = ""; + sprintf_s(szServerSearchPath, "SRV*%s*%s", szSymbolCachePath, szSymbolStore); + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, szServerSearchPath)) //update search path { dputs("SymSetSearchPath (1) failed!"); return; } - - // Reload - for(auto & module : modList) + for(int i = 0; i < modcount; i++) //reload all modules { - dprintf("Downloading symbols for %s...\n", module.name); - - wchar_t modulePath[MAX_PATH]; - if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)module.base, modulePath, MAX_PATH)) + dprintf("downloading symbols for %s...\n", modList.at(i).name); + uint modbase = modList.at(i).base; + wchar_t szModulePath[MAX_PATH] = L""; + if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModulePath, MAX_PATH)) { - dprintf("GetModuleFileNameExW("fhex") failed!\n", module.base); + dprintf("GetModuleFileNameExW("fhex") failed!\n", modbase); continue; } - - if(!SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)module.base)) + if(!SafeSymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase)) { - dprintf("SymUnloadModule64("fhex") failed!\n", module.base); + dprintf("SymUnloadModule64("fhex") failed!\n", modbase); continue; } - - if(!SafeSymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(modulePath).c_str(), 0, (DWORD64)module.base, 0, 0, 0)) + if(!SafeSymLoadModuleEx(fdProcessInfo->hProcess, 0, StringUtils::Utf16ToUtf8(szModulePath).c_str(), 0, (DWORD64)modbase, 0, 0, 0)) { - dprintf("SymLoadModuleEx("fhex") failed!\n", module.base); + dprintf("SymLoadModuleEx("fhex") failed!\n", modbase); continue; } } - - // Restore the old search path - if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, oldSearchPath)) + if(!SafeSymSetSearchPath(fdProcessInfo->hProcess, szOldSearchPath)) //restore search path + { dputs("SymSetSearchPath (2) failed!"); + } } -bool SymAddrFromName(const char* Name, uint* Address) +bool symfromname(const char* name, uint* addr) { - if(!Name || Name[0] == '\0') + if(!name or !strlen(name) or !addr or !_strnicmp(name, "ordinal", 7)) //skip 'OrdinalXXX' return false; - - if(!Address) - return false; - - // Skip 'OrdinalXXX' - if(!_strnicmp(Name, "Ordinal", 7)) - return false; - - // According to MSDN: - // Note that the total size of the data is the SizeOfStruct + (MaxNameLen - 1) * sizeof(TCHAR) char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)]; - - PSYMBOL_INFO symbol = (PSYMBOL_INFO)&buffer; - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - symbol->MaxNameLen = MAX_LABEL_SIZE; - - if(!SafeSymFromName(fdProcessInfo->hProcess, Name, symbol)) + PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; + pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); + pSymbol->MaxNameLen = MAX_LABEL_SIZE; + if(!SafeSymFromName(fdProcessInfo->hProcess, name, pSymbol)) return false; - - *Address = (uint)symbol->Address; + *addr = (uint)pSymbol->Address; return true; } -const char* SymGetSymbolicName(uint Address) +const char* symgetsymbolicname(uint addr) { - // - // This resolves an address to a module and symbol: - // [modname.]symbolname - // - char label[MAX_SYM_NAME]; - - // User labels have priority, but if one wasn't found, - // default to a symbol lookup - if(!labelget(Address, label)) + //[modname.]symbolname + static char symbolicname[MAX_MODULE_SIZE + MAX_SYM_NAME] = ""; + char label[MAX_SYM_NAME] = ""; + bool retval = false; + if(labelget(addr, label)) //user labels have priority + retval = true; + else //no user labels { - char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)]; - - PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - symbol->MaxNameLen = MAX_LABEL_SIZE; - - // Perform a symbol lookup DWORD64 displacement = 0; - - if(!SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)Address, &displacement, symbol)) - return nullptr; - - // If the symbol wasn't at offset 0 (start from the beginning) ignore it - if(displacement != 0) - return nullptr; - - // Terminate the string for sanity - symbol->Name[symbol->MaxNameLen - 1] = '\0'; - - if(!bUndecorateSymbolNames || !SafeUnDecorateSymbolName(symbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) - strcpy_s(label, symbol->Name); + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)]; + PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; + pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); + pSymbol->MaxNameLen = MAX_LABEL_SIZE; + if(SafeSymFromAddr(fdProcessInfo->hProcess, (DWORD64)addr, &displacement, pSymbol) and !displacement) + { + pSymbol->Name[pSymbol->MaxNameLen - 1] = '\0'; + if(!bUndecorateSymbolNames or !SafeUnDecorateSymbolName(pSymbol->Name, label, MAX_SYM_NAME, UNDNAME_COMPLETE)) + strcpy_s(label, pSymbol->Name); + retval = true; + } } - - // TODO: FIXME: STATIC VARIABLE - static char symbolicname[MAX_MODULE_SIZE + MAX_SYM_NAME]; - char modname[MAX_MODULE_SIZE]; - - if(ModNameFromAddr(Address, modname, false)) - sprintf_s(symbolicname, "%s.%s", modname, label); - else - sprintf_s(symbolicname, "<%s>", label); - - return symbolicname; + if(retval) + { + char modname[MAX_MODULE_SIZE] = ""; + if(modnamefromaddr(addr, modname, false)) + sprintf(symbolicname, "%s.%s", modname, label); + else + sprintf(symbolicname, "<%s>", label); + return symbolicname; + } + return 0; } diff --git a/x64_dbg_dbg/symbolinfo.h b/x64_dbg_dbg/symbolinfo.h index 2bb57f6b..b5f9eab1 100644 --- a/x64_dbg_dbg/symbolinfo.h +++ b/x64_dbg_dbg/symbolinfo.h @@ -1,10 +1,12 @@ -#pragma once +#ifndef _SYMBOLINFO_H +#define _SYMBOLINFO_H #include "_global.h" -void SymEnum(uint Base, CBSYMBOLENUM EnumCallback, void* UserData); -bool SymGetModuleList(std::vector* List); -void SymUpdateModuleList(); -void SymDownloadAllSymbols(const char* SymbolStore); -bool SymAddrFromName(const char* Name, uint* Address); -const char* SymGetSymbolicName(uint Address); \ No newline at end of file +void symenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user); +void symupdatemodulelist(); +void symdownloadallsymbols(const char* szSymbolStore); +bool symfromname(const char* name, uint* addr); +const char* symgetsymbolicname(uint addr); + +#endif //_SYMBOLINFO_H diff --git a/x64_dbg_dbg/thread.cpp b/x64_dbg_dbg/thread.cpp index d5cf7188..e7063cc0 100644 --- a/x64_dbg_dbg/thread.cpp +++ b/x64_dbg_dbg/thread.cpp @@ -5,251 +5,151 @@ #include "threading.h" static std::vector threadList; +static int threadNum; +static int currentThread; -void ThreadCreate(CREATE_THREAD_DEBUG_INFO* CreateThread) +void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread) { THREADINFO curInfo; - memset(&curInfo, 0, sizeof(THREADINFO)); - - curInfo.ThreadNumber = ThreadGetCount(); - curInfo.Handle = CreateThread->hThread; - curInfo.ThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; - curInfo.ThreadStartAddress = (uint)CreateThread->lpStartAddress; - curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase; - - // The first thread (#0) is always the main program thread - if(curInfo.ThreadNumber <= 0) + curInfo.ThreadNumber = threadNum; + curInfo.hThread = CreateThread->hThread; + curInfo.dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId; + curInfo.ThreadStartAddress = (uint)CreateThread->lpStartAddress; + curInfo.ThreadLocalBase = (uint)CreateThread->lpThreadLocalBase; + *curInfo.threadName = '\0'; + if(!threadNum) strcpy_s(curInfo.threadName, "Main Thread"); - - // Modify global thread list - EXCLUSIVE_ACQUIRE(LockThreads); + CriticalSectionLocker locker(LockThreads); threadList.push_back(curInfo); - EXCLUSIVE_RELEASE(); - - // Notify GUI + threadNum++; + locker.unlock(); //prevent possible deadlocks GuiUpdateThreadView(); } -void ThreadExit(DWORD dwThreadId) +void threadexit(DWORD dwThreadId) { - EXCLUSIVE_ACQUIRE(LockThreads); - - // Don't use a foreach loop here because of the erase() call - for(auto itr = threadList.begin(); itr != threadList.end(); itr++) - { - if(itr->ThreadId == dwThreadId) + CriticalSectionLocker locker(LockThreads); + for(unsigned int i = 0; i < threadList.size(); i++) + if(threadList.at(i).dwThreadId == dwThreadId) { - threadList.erase(itr); + threadList.erase(threadList.begin() + i); break; } - } - - EXCLUSIVE_RELEASE(); + locker.unlock(); //prevent possible deadlocks GuiUpdateThreadView(); } -void ThreadClear() +void threadclear() { - // Clear the current array of threads - EXCLUSIVE_ACQUIRE(LockThreads); - threadList.clear(); - EXCLUSIVE_RELEASE(); - - // Update the GUI's list + threadNum = 0; + CriticalSectionLocker locker(LockThreads); + std::vector().swap(threadList); + locker.unlock(); //prevent possible deadlocks GuiUpdateThreadView(); } -int ThreadGetCount() +static THREADWAITREASON GetThreadWaitReason(DWORD dwThreadId) { - SHARED_ACQUIRE(LockThreads); - return (int)threadList.size(); -} - -void ThreadGetList(THREADLIST* list) -{ - SHARED_ACQUIRE(LockThreads); - - // - // This function converts a C++ std::vector to a C-style THREADLIST[] - // Also assume BridgeAlloc zeros the returned buffer - // - size_t count = threadList.size(); - - if(count <= 0) - return; - - list->count = (int)count; - list->list = (THREADALLINFO*)BridgeAlloc(count * sizeof(THREADALLINFO)); - - // Fill out the list data - for(size_t i = 0; i < count; i++) - { - HANDLE threadHandle = threadList[i].Handle; - - // Get the debugger's current thread index - if(threadHandle == hActiveThread) - list->CurrentThread = (int)i; - - memcpy(&list->list[i].BasicInfo, &threadList[i], sizeof(THREADINFO)); - - list->list[i].ThreadCip = GetContextDataEx(threadHandle, UE_CIP); - list->list[i].SuspendCount = ThreadGetSuspendCount(threadHandle); - list->list[i].Priority = ThreadGetPriority(threadHandle); - list->list[i].WaitReason = ThreadGetWaitReason(threadHandle); - list->list[i].LastError = ThreadGetLastError(list->list[i].BasicInfo.ThreadLocalBase); - } -} - -bool ThreadIsValid(DWORD dwThreadId) -{ - SHARED_ACQUIRE(LockThreads); - - for(auto & entry : threadList) - { - if(entry.ThreadId == dwThreadId) - return true; - } - - return false; -} - -bool ThreadGetTeb(uint TEBAddress, TEB* Teb) -{ - // - // TODO: Keep a cached copy inside the vector - // - memset(Teb, 0, sizeof(TEB)); - - return MemRead((void*)TEBAddress, Teb, sizeof(TEB), nullptr); -} - -int ThreadGetSuspendCount(HANDLE Thread) -{ - // - // Suspend a thread in order to get the previous suspension count - // WARNING: This function is very bad (threads should not be randomly interrupted) - // - int suspendCount = (int)SuspendThread(Thread); - - if(suspendCount == -1) - return 0; - - // Resume the thread's normal execution - ResumeThread(Thread); - - return suspendCount; -} - -THREADPRIORITY ThreadGetPriority(HANDLE Thread) -{ - return (THREADPRIORITY)GetThreadPriority(Thread); -} - -THREADWAITREASON ThreadGetWaitReason(HANDLE Thread) -{ - UNREFERENCED_PARAMETER(Thread); - - // TODO: Implement this + //TODO: implement this return _Executive; } -DWORD ThreadGetLastError(uint tebAddress) +static DWORD GetThreadLastError(uint tebAddress) { TEB teb; - if(!ThreadGetTeb(tebAddress, &teb)) - { - // TODO: Assert (Why would the TEB fail?) + memset(&teb, 0, sizeof(TEB)); + if(!memread(fdProcessInfo->hProcess, (void*)tebAddress, &teb, sizeof(TEB), 0)) return 0; - } - return teb.LastErrorValue; } -bool ThreadSetName(DWORD dwThreadId, const char* name) +void threadgetlist(THREADLIST* list) { - EXCLUSIVE_ACQUIRE(LockThreads); - - // Modifies a variable (name), so an exclusive lock is required - for(auto & entry : threadList) + CriticalSectionLocker locker(LockThreads); + int count = (int)threadList.size(); + list->count = count; + if(!count) + return; + list->list = (THREADALLINFO*)BridgeAlloc(count * sizeof(THREADALLINFO)); + for(int i = 0; i < count; i++) { - if(entry.ThreadId == dwThreadId) - { - if(!name) - name = ""; - - strcpy_s(entry.threadName, name); - return true; - } + if(hActiveThread == threadList.at(i).hThread) + currentThread = i; + memset(&list->list[i], 0, sizeof(THREADALLINFO)); + memcpy(&list->list[i].BasicInfo, &threadList.at(i), sizeof(THREADINFO)); + HANDLE hThread = list->list[i].BasicInfo.hThread; + list->list[i].ThreadCip = GetContextDataEx(hThread, UE_CIP); + list->list[i].SuspendCount = SuspendThread(hThread); + ResumeThread(hThread); + list->list[i].Priority = (THREADPRIORITY)GetThreadPriority(list->list[i].BasicInfo.hThread); + list->list[i].WaitReason = GetThreadWaitReason(list->list[i].BasicInfo.dwThreadId); + list->list[i].LastError = GetThreadLastError(list->list[i].BasicInfo.ThreadLocalBase); } + list->CurrentThread = currentThread; +} +bool threadisvalid(DWORD dwThreadId) +{ + CriticalSectionLocker locker(LockThreads); + for(unsigned int i = 0; i < threadList.size(); i++) + if(threadList.at(i).dwThreadId == dwThreadId) + return true; return false; } -HANDLE ThreadGetHandle(DWORD dwThreadId) +bool threadsetname(DWORD dwThreadId, const char* name) { - SHARED_ACQUIRE(LockThreads); + CriticalSectionLocker locker(LockThreads); + for(unsigned int i = 0; i < threadList.size(); i++) + if(threadList.at(i).dwThreadId == dwThreadId) + { + if(name) + strcpy_s(threadList.at(i).threadName, name); + else + *threadList.at(i).threadName = '\0'; + } + return false; +} - for(auto & entry : threadList) - { - if(entry.ThreadId == dwThreadId) - return entry.Handle; - } - - // TODO: Set an assert if the handle is never found, - // using a bad handle causes random/silent issues everywhere +HANDLE threadgethandle(DWORD dwThreadId) +{ + CriticalSectionLocker locker(LockThreads); + for(unsigned int i = 0; i < threadList.size(); i++) + if(threadList.at(i).dwThreadId == dwThreadId) + return threadList.at(i).hThread; return 0; } -DWORD ThreadGetId(HANDLE hThread) +DWORD threadgetid(HANDLE hThread) { - SHARED_ACQUIRE(LockThreads); - - // Search for the ID in the local list - for(auto & entry : threadList) - { - if(entry.Handle == hThread) - return entry.ThreadId; - } - - // Wasn't found, check with Windows - // NOTE: Requires VISTA+ - DWORD id = GetThreadId(hThread); - - // Returns 0 on error; - // TODO: Same problem with ThreadGetHandle() - return id; + CriticalSectionLocker locker(LockThreads); + for(unsigned int i = 0; i < threadList.size(); i++) + if(threadList.at(i).hThread == hThread) + return threadList.at(i).dwThreadId; + return 0; } -int ThreadSuspendAll() +int threadgetcount() { - // - // SuspendThread does not modify any internal variables - // - SHARED_ACQUIRE(LockThreads); + return (int)threadList.size(); +} +int threadsuspendall() +{ + CriticalSectionLocker locker(LockThreads); int count = 0; - for(auto & entry : threadList) - { - if(SuspendThread(entry.Handle) != -1) + for(unsigned int i = 0; i < threadList.size(); i++) + if(SuspendThread(threadList.at(i).hThread) != -1) count++; - } - return count; } -int ThreadResumeAll() +int threadresumeall() { - // - // ResumeThread does not modify any internal variables - // - SHARED_ACQUIRE(LockThreads); - + CriticalSectionLocker locker(LockThreads); int count = 0; - for(auto & entry : threadList) - { - if(ResumeThread(entry.Handle) != -1) + for(unsigned int i = 0; i < threadList.size(); i++) + if(ResumeThread(threadList.at(i).hThread) != -1) count++; - } - return count; } \ No newline at end of file diff --git a/x64_dbg_dbg/thread.h b/x64_dbg_dbg/thread.h index 5eb62bd2..eaacbaef 100644 --- a/x64_dbg_dbg/thread.h +++ b/x64_dbg_dbg/thread.h @@ -1,22 +1,20 @@ -#pragma once +#ifndef _THREAD_H +#define _THREAD_H #include "_global.h" #include "debugger.h" -void ThreadCreate(CREATE_THREAD_DEBUG_INFO* CreateThread); -void ThreadExit(DWORD dwThreadId); -void ThreadClear(); -int ThreadGetCount(); -void ThreadGetList(THREADLIST* list); -bool ThreadIsValid(DWORD dwThreadId); -bool ThreadSetName(DWORD dwTHreadId, const char* name); -bool ThreadGetTeb(uint TEBAddress, TEB* Teb); -int ThreadGetSuspendCount(HANDLE Thread); -THREADPRIORITY ThreadGetPriority(HANDLE Thread); -THREADWAITREASON ThreadGetWaitReason(HANDLE Thread); -DWORD ThreadGetLastError(uint tebAddress); -bool ThreadSetName(DWORD dwThreadId, const char* name); -HANDLE ThreadGetHandle(DWORD dwThreadId); -DWORD ThreadGetId(HANDLE hThread); -int ThreadSuspendAll(); -int ThreadResumeAll(); \ No newline at end of file +//functions +void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread); +void threadexit(DWORD dwThreadId); +void threadclear(); +void threadgetlist(THREADLIST* list); +bool threadisvalid(DWORD dwThreadId); +bool threadsetname(DWORD dwTHreadId, const char* name); +HANDLE threadgethandle(DWORD dwThreadId); +DWORD threadgetid(HANDLE hThread); +int threadgetcount(); +int threadsuspendall(); +int threadresumeall(); + +#endif //_THREAD_H diff --git a/x64_dbg_dbg/threading.cpp b/x64_dbg_dbg/threading.cpp index dfeb9089..0ef8a16d 100644 --- a/x64_dbg_dbg/threading.cpp +++ b/x64_dbg_dbg/threading.cpp @@ -28,37 +28,53 @@ bool waitislocked(WAIT_ID id) return waitarray[id]; } -bool SectionLockerGlobal::m_Initialized = false; -SRWLOCK SectionLockerGlobal::m_Locks[SectionLock::LockLast]; +CRITICAL_SECTION CriticalSectionLocker::locks[LockLast] = {}; +bool CriticalSectionLocker::bInitDone = false; -void SectionLockerGlobal::Initialize() +void CriticalSectionLocker::Initialize() { - if(m_Initialized) + if(bInitDone) return; - - // Destroy previous data if any existed - memset(m_Locks, 0, sizeof(m_Locks)); - - for(int i = 0; i < ARRAYSIZE(m_Locks); i++) - InitializeSRWLock(&m_Locks[i]); - - m_Initialized = true; + for(int i = 0; i < LockLast; i++) + InitializeCriticalSection(&locks[i]); + bInitDone = true; } -void SectionLockerGlobal::Deinitialize() +void CriticalSectionLocker::Deinitialize() { - if(!m_Initialized) + if(!bInitDone) return; - - for(int i = 0; i < ARRAYSIZE(m_Locks); i++) + for(int i = 0; i < LockLast; i++) { - // Wait for the lock's ownership to be released - AcquireSRWLockExclusive(&m_Locks[i]); - ReleaseSRWLockExclusive(&m_Locks[i]); - - // Invalidate data - memset(&m_Locks[i], 0, sizeof(SRWLOCK)); + EnterCriticalSection(&locks[i]); //obtain ownership + DeleteCriticalSection(&locks[i]); } + bInitDone = false; +} - m_Initialized = false; +CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock) +{ + Initialize(); //initialize critical sections + gLock = lock; + + EnterCriticalSection(&locks[gLock]); + Locked = true; +} + +CriticalSectionLocker::~CriticalSectionLocker() +{ + if(Locked) + LeaveCriticalSection(&locks[gLock]); +} + +void CriticalSectionLocker::unlock() +{ + Locked = false; + LeaveCriticalSection(&locks[gLock]); +} + +void CriticalSectionLocker::relock() +{ + EnterCriticalSection(&locks[gLock]); + Locked = true; } \ No newline at end of file diff --git a/x64_dbg_dbg/threading.h b/x64_dbg_dbg/threading.h index 7d092b54..6d6800ad 100644 --- a/x64_dbg_dbg/threading.h +++ b/x64_dbg_dbg/threading.h @@ -1,7 +1,9 @@ -#pragma once +#ifndef _THREADING_H +#define _THREADING_H #include "_global.h" +//enums enum WAIT_ID { WAITID_RUN, @@ -16,22 +18,7 @@ void lock(WAIT_ID id); void unlock(WAIT_ID id); bool waitislocked(WAIT_ID id); -// -// THREAD SYNCHRONIZATION -// -// Better, but requires VISTA+ -// https://msdn.microsoft.com/en-us/library/windows/desktop/aa904937%28v=vs.85%29.aspx -// -#define CriticalSectionLocker -#define locker(x) EXCLUSIVE_ACQUIRE(x) - -#define EXCLUSIVE_ACQUIRE(Index) SectionLocker __ThreadLock; -#define EXCLUSIVE_RELEASE() __ThreadLock.Unlock(); - -#define SHARED_ACQUIRE(Index) SectionLocker __SThreadLock; -#define SHARED_RELEASE() __SThreadLock.Unlock(); - -enum SectionLock +enum CriticalSectionLock { LockMemoryPages, LockVariables, @@ -45,75 +32,26 @@ enum SectionLock LockPatches, LockThreads, LockDprintf, - LockSym, - - // This is defined because of a bug in the Windows 8.1 kernel; - // Calling VirtualQuery/VirtualProtect/ReadProcessMemory can and will cause - // a deadlock. - // https://bitbucket.org/mrexodia/x64_dbg/issue/247/x64-dbg-bug-string-references-function - LockWin8Workaround, - - LockLast, + LockSym, + LockLast }; -class SectionLockerGlobal +class CriticalSectionLocker { - template friend class SectionLocker; - public: - static void Initialize(); static void Deinitialize(); + CriticalSectionLocker(CriticalSectionLock lock); + ~CriticalSectionLocker(); + void unlock(); + void relock(); private: - static bool m_Initialized; - static SRWLOCK m_Locks[SectionLock::LockLast]; + static void Initialize(); + static bool bInitDone; + static CRITICAL_SECTION locks[LockLast]; + + CriticalSectionLock gLock; + bool Locked; }; -template -class SectionLocker -{ -public: - SectionLocker() - { - m_LockCount = 0; - Lock(); - } - - ~SectionLocker() - { - if(m_LockCount > 0) - Unlock(); - -#ifdef _DEBUG - // TODO: Assert that the lock count is zero on destructor - if (m_LockCount > 0) - __debugbreak(); -#endif - } - - inline void Lock() - { - if(Shared) - AcquireSRWLockShared(&Internal::m_Locks[LockIndex]); - else - AcquireSRWLockExclusive(&Internal::m_Locks[LockIndex]); - - m_LockCount++; - } - - inline void Unlock() - { - m_LockCount--; - - if(Shared) - ReleaseSRWLockShared(&Internal::m_Locks[LockIndex]); - else - ReleaseSRWLockExclusive(&Internal::m_Locks[LockIndex]); - } - -private: - using Internal = SectionLockerGlobal; - -protected: - BYTE m_LockCount; -}; \ No newline at end of file +#endif // _THREADING_H diff --git a/x64_dbg_dbg/value.cpp b/x64_dbg_dbg/value.cpp index f440f6e9..055a8e41 100644 --- a/x64_dbg_dbg/value.cpp +++ b/x64_dbg_dbg/value.cpp @@ -1189,7 +1189,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print SELECTIONDATA seldata; memset(&seldata, 0, sizeof(seldata)); GuiSelectionGet(GUI_DISASSEMBLY, &seldata); - if(!ModNameFromAddr(seldata.start, modname, true)) + if(!modnamefromaddr(seldata.start, modname, true)) return false; } else @@ -1200,7 +1200,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print apiname++; if(!strlen(apiname)) return false; - uint modbase = ModBaseFromName(modname); + uint modbase = modbasefromname(modname); wchar_t szModName[MAX_PATH] = L""; if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModName, MAX_PATH)) { @@ -1477,7 +1477,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, return false; uint addr = *value; *value = 0; - if(!MemRead((void*)addr, value, read_size, 0)) + if(!memread(fdProcessInfo->hProcess, (void*)addr, value, read_size, 0)) { if(!silent) dputs("failed to read memory"); @@ -1559,7 +1559,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly, return true; else if(labelfromstring(string, value)) //then come labels return true; - else if(SymAddrFromName(string, value)) //then come symbols + else if(symfromname(string, value)) //then come symbols return true; else if(varget(string, value, value_size, 0)) //finally variables { @@ -2025,7 +2025,7 @@ bool valtostring(const char* string, uint* value, bool silent) { return false; } - if(!MemPatch((void*)temp, value, read_size, 0)) + if(!mempatch(fdProcessInfo->hProcess, (void*)temp, value, read_size, 0)) { if(!silent) dputs("failed to write memory"); @@ -2094,7 +2094,7 @@ bool valtostring(const char* string, uint* value, bool silent) uint valfileoffsettova(const char* modname, uint offset) { char modpath[MAX_PATH] = ""; - if(ModPathFromName(modname, modpath, MAX_PATH)) + if(modpathfromname(modname, modpath, MAX_PATH)) { HANDLE FileHandle; DWORD LoadedSize; @@ -2106,7 +2106,7 @@ uint valfileoffsettova(const char* modname, uint offset) FileMapVA + (ULONG_PTR)offset, //Offset inside FileMapVA false); //Return without ImageBase StaticFileUnloadW(StringUtils::Utf8ToUtf16(modpath).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA); - return offset < LoadedSize ? (duint)rva + ModBaseFromName(modname) : 0; + return offset < LoadedSize ? (duint)rva + modbasefromname(modname) : 0; } } return 0; @@ -2115,7 +2115,7 @@ uint valfileoffsettova(const char* modname, uint offset) uint valvatofileoffset(uint va) { char modpath[MAX_PATH] = ""; - if(ModPathFromAddr(va, modpath, MAX_PATH)) + if(modpathfromaddr(va, modpath, MAX_PATH)) { HANDLE FileHandle; DWORD LoadedSize; @@ -2123,7 +2123,7 @@ uint valvatofileoffset(uint va) ULONG_PTR FileMapVA; if(StaticFileLoadW(StringUtils::Utf8ToUtf16(modpath).c_str(), UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA)) { - ULONGLONG offset = ConvertVAtoFileOffsetEx(FileMapVA, LoadedSize, 0, va - ModBaseFromAddr(va), true, false); + ULONGLONG offset = ConvertVAtoFileOffsetEx(FileMapVA, LoadedSize, 0, va - modbasefromaddr(va), true, false); StaticFileUnloadW(StringUtils::Utf8ToUtf16(modpath).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA); return (duint)offset; } diff --git a/x64_dbg_dbg/variable.cpp b/x64_dbg_dbg/variable.cpp index 2b84c077..f71905a0 100644 --- a/x64_dbg_dbg/variable.cpp +++ b/x64_dbg_dbg/variable.cpp @@ -6,36 +6,30 @@ static VAR* vars; static void varsetvalue(VAR* var, VAR_VALUE* value) { - // VAR_STRING needs to be freed before destroying it - if(var->value.type == VAR_STRING) + switch(var->value.type) { + case VAR_STRING: var->value.u.data->clear(); delete var->value.u.data; + break; + default: + break; } - - // Replace all information in the struct memcpy(&var->value, value, sizeof(VAR_VALUE)); } static bool varset(const char* name, VAR_VALUE* value, bool setreadonly) { - EXCLUSIVE_ACQUIRE(LockVariables); - + CriticalSectionLocker locker(LockVariables); String name_; if(*name != '$') name_ = "$"; name_ += name; VariableMap::iterator found = variables.find(name_); - if(found == variables.end()) //not found + if(found == variables.end()) //not found return false; if(found->second.alias.length()) - { - // Release the lock (potential deadlock here) - EXCLUSIVE_RELEASE(); - return varset(found->second.alias.c_str(), value, setreadonly); - } - if(!setreadonly && (found->second.type == VAR_READONLY || found->second.type == VAR_HIDDEN)) return false; varsetvalue(&found->second, value); @@ -45,55 +39,39 @@ static bool varset(const char* name, VAR_VALUE* value, bool setreadonly) void varinit() { varfree(); - - // General variables + //General variables varnew("$result\1$res", 0, VAR_SYSTEM); varnew("$result1\1$res1", 0, VAR_SYSTEM); varnew("$result2\1$res2", 0, VAR_SYSTEM); varnew("$result3\1$res3", 0, VAR_SYSTEM); varnew("$result4\1$res4", 0, VAR_SYSTEM); - - // InitDebug variables - varnew("$hProcess\1$hp", 0, VAR_READONLY); // Process handle - varnew("$pid", 0, VAR_READONLY); // Process ID - - // Hidden variables + //InitDebug variables + varnew("$hProcess\1$hp", 0, VAR_READONLY); + varnew("$pid", 0, VAR_READONLY); + //hidden variables varnew("$ans\1$an", 0, VAR_HIDDEN); - - // Read-only variables - varnew("$lastalloc", 0, VAR_READONLY); // Last memory allocation - varnew("$_EZ_FLAG", 0, VAR_READONLY); // Equal/zero flag for internal use (1=equal, 0=unequal) - varnew("$_BS_FLAG", 0, VAR_READONLY); // Bigger/smaller flag for internal use (1=bigger, 0=smaller) + //read-only variables + varnew("$lastalloc", 0, VAR_READONLY); + varnew("$_EZ_FLAG", 0, VAR_READONLY); //equal/zero flag for internal use (1=equal, 0=unequal) + varnew("$_BS_FLAG", 0, VAR_READONLY); //bigger/smaller flag for internal use (1=bigger, 0=smaller) } void varfree() { - EXCLUSIVE_ACQUIRE(LockVariables); - - // Each variable must be deleted manually; strings especially - // because there are sub-allocations - VAR_VALUE emptyValue; - - for (auto& itr : variables) - varsetvalue(&itr.second, &emptyValue); - - // Now clear all vector elements + CriticalSectionLocker locker(LockVariables); variables.clear(); } VAR* vargetptr() { - // TODO: Implement this? Or remove it - return nullptr; + return 0; } bool varnew(const char* name, uint value, VAR_TYPE type) { + CriticalSectionLocker locker(LockVariables); if(!name) return false; - - CriticalSectionLocker locker(LockVariables); - std::vector names = StringUtils::Split(name, '\1'); String firstName; for(int i = 0; i < (int)names.size(); i++) @@ -122,8 +100,7 @@ bool varnew(const char* name, uint value, VAR_TYPE type) static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type) { - SHARED_ACQUIRE(LockVariables); - + CriticalSectionLocker locker(LockVariables); String name_; if(*name != '$') name_ = "$"; @@ -132,12 +109,7 @@ static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type if(found == variables.end()) //not found return false; if(found->second.alias.length()) - { - // Release the lock (potential deadlock here) - SHARED_RELEASE(); - return varget(found->second.alias.c_str(), value, size, type); - } if(type) *type = found->second.type; if(size) @@ -212,8 +184,7 @@ bool varset(const char* name, const char* string, bool setreadonly) bool vardel(const char* name, bool delsystem) { - EXCLUSIVE_ACQUIRE(LockVariables); - + CriticalSectionLocker locker(LockVariables); String name_; if(*name != '$') name_ = "$"; @@ -222,13 +193,7 @@ bool vardel(const char* name, bool delsystem) if(found == variables.end()) //not found return false; if(found->second.alias.length()) - { - // Release the lock (potential deadlock here) - EXCLUSIVE_RELEASE(); - return vardel(found->second.alias.c_str(), delsystem); - } - if(!delsystem && found->second.type != VAR_USER) return false; found = variables.begin(); @@ -244,8 +209,7 @@ bool vardel(const char* name, bool delsystem) bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype) { - SHARED_ACQUIRE(LockVariables); - + CriticalSectionLocker locker(LockVariables); String name_; if(*name != '$') name_ = "$"; @@ -262,29 +226,18 @@ bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype) return true; } -bool varenum(VAR* List, size_t* Size) +bool varenum(VAR* entries, size_t* cbsize) { - // A list or size must be requested - if(!List && !Size) + CriticalSectionLocker locker(LockVariables); + if(!entries && !cbsize || !variables.size()) return false; - - SHARED_ACQUIRE(LockVariables); - - if(Size) + if(!entries && cbsize) { - // Size requested, so return it - *Size = variables.size() * sizeof(VAR); - - if(!List) - return true; + *cbsize = variables.size() * sizeof(VAR); + return true; } - - // Fill out all list entries - for(auto & itr : variables) - { - *List = itr.second; - List++; - } - + int j = 0; + for(VariableMap::iterator i = variables.begin(); i != variables.end(); ++i, j++) + entries[j] = i->second; return true; } \ No newline at end of file diff --git a/x64_dbg_dbg/x64_dbg.cpp b/x64_dbg_dbg/x64_dbg.cpp index eea09dde..ff2b7dba 100644 --- a/x64_dbg_dbg/x64_dbg.cpp +++ b/x64_dbg_dbg/x64_dbg.cpp @@ -236,7 +236,6 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit() return "Invalid TITAN_ENGINE_CONTEXT_t alignment!"; if(sizeof(TITAN_ENGINE_CONTEXT_t) != sizeof(REGISTERCONTEXT)) return "Invalid REGISTERCONTEXT alignment!"; - SectionLockerGlobal::Initialize(); dbginit(); dbgfunctionsinit(); json_set_alloc_funcs(emalloc_json, efree_json); @@ -315,8 +314,7 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal() } else DeleteFileA(alloctrace); - - SectionLockerGlobal::Deinitialize(); + CriticalSectionLocker::Deinitialize(); } extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd) diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index 8fb7b44e..c544ed20 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -1,14 +1,6 @@  - - Debug - Win32 - - - Debug - x64 - Release Win32 @@ -132,22 +124,10 @@ DynamicLibrary false - v120 - - - DynamicLibrary - false - v120 DynamicLibrary false - v120 - - - DynamicLibrary - false - v120 @@ -155,15 +135,9 @@ - - - - - - false @@ -171,37 +145,17 @@ $(Platform)\$(Configuration)\ x32_dbg - - false - $(SolutionDir)bin\x32\ - $(Platform)\$(Configuration)\ - x32_dbg - false $(SolutionDir)bin\x64\ x64_dbg - - false - $(SolutionDir)bin\x64\ - x64_dbg - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase - true - MultiFile - true - true - AVXI - None - None - true - Speed MachineX86 @@ -212,45 +166,12 @@ lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) - - - WIN32;_DEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - Level3 - ProgramDatabase - true - NoIPO - false - true - Disabled - - - MachineX86 - true - Windows - false - false - lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) - - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase - true - MultiFile - true - true - AVXI - None - None - true - Speed - AVXI - false - None true @@ -260,29 +181,6 @@ lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) - - - WIN32;_DEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;BUILD_DBG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - Level3 - ProgramDatabase - true - NoIPO - false - false - Disabled - Rw - None - true - - - true - Windows - false - false - lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) - - diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 1b220994..4974409f 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -9,6 +9,10 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + {44fd9eb7-2017-49b8-8d9a-dec680632343} diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user index bdb12b67..b72054fc 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.user @@ -5,19 +5,9 @@ WindowsLocalDebugger $(OutDir) - - $(OutDir)\x32_dbg.exe - WindowsLocalDebugger - $(OutDir) - $(OutDir)\x64_dbg.exe WindowsLocalDebugger $(OutDir) - - $(OutDir)\x64_dbg.exe - WindowsLocalDebugger - $(OutDir) - \ No newline at end of file diff --git a/x64_dbg_exe/x64_dbg_exe.vcxproj b/x64_dbg_exe/x64_dbg_exe.vcxproj index 0750ddb4..4e831d7c 100644 --- a/x64_dbg_exe/x64_dbg_exe.vcxproj +++ b/x64_dbg_exe/x64_dbg_exe.vcxproj @@ -1,14 +1,6 @@  - - Debug - Win32 - - - Debug - x64 - Release Win32 @@ -31,9 +23,6 @@ - - - {3A22175E-6B72-FDCC-1603-C4A2163C7900} Win32Proj @@ -42,22 +31,10 @@ Application false - v120 - - - Application - false - v120 Application false - v120 - - - Application - false - v120 @@ -65,15 +42,9 @@ - - - - - - false @@ -82,25 +53,12 @@ x32_dbg false - - false - $(SolutionDir)bin\x32\ - $(Platform)\$(Configuration)\ - x32_dbg - false - false $(SolutionDir)bin\x64\ x64_dbg false - - false - $(SolutionDir)bin\x64\ - x64_dbg - false - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -120,25 +78,6 @@ - - - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - - - MachineX86 - true - Windows - true - true - $(SolutionDir)bin\x32\x32_bridge.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(TargetDir)$(TargetName)_exe.pdb - - - - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -157,24 +96,6 @@ - - - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - - - true - Windows - true - true - $(SolutionDir)bin\x64\x64_bridge.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(TargetDir)$(TargetName)_exe.pdb - - - - diff --git a/x64_dbg_exe/x64_dbg_exe.vcxproj.filters b/x64_dbg_exe/x64_dbg_exe.vcxproj.filters index 26d9b663..c37e6d1a 100644 --- a/x64_dbg_exe/x64_dbg_exe.vcxproj.filters +++ b/x64_dbg_exe/x64_dbg_exe.vcxproj.filters @@ -35,7 +35,4 @@ - - - \ No newline at end of file diff --git a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp index 4fa6df51..96715382 100644 --- a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp @@ -32,7 +32,6 @@ AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(pare setVerticalScrollBar(new AbstractTableScrollBar(verticalScrollBar())); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); memset(&mScrollBarAttributes, 0, sizeof(mScrollBarAttributes)); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); horizontalScrollBar()->setRange(0, 0); horizontalScrollBar()->setPageStep(650); mMouseWheelScrollDelta = 4; diff --git a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h index cfdbcb3d..e72958eb 100644 --- a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h +++ b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.h @@ -8,7 +8,6 @@ #include #include #include "NewTypes.h" -#include "StringUtil.h" //Hacky class that fixes a really annoying cursor problem class AbstractTableScrollBar : public QScrollBar diff --git a/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp b/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp index 60d05ff7..c24b8dca 100644 --- a/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp @@ -1480,7 +1480,7 @@ QString Disassembly::getAddrText(int_t cur_addr, char label[MAX_LABEL_SIZE]) #endif //_WIN64 } } - addrText += AddressToString(cur_addr); + addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); char label_[MAX_LABEL_SIZE] = ""; if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label_)) //has label { diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index c4a2d714..7f05567f 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -404,7 +404,7 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i #endif //_WIN64 } } - addrText += AddressToString(cur_addr); + addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label { char module[MAX_MODULE_SIZE] = ""; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp b/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp index 6cde593b..7d033177 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp @@ -184,7 +184,7 @@ void CPUInfoBox::disasmSelectionChanged(int_t parVA) char section[MAX_SECTION_SIZE] = ""; if(DbgFunctions()->SectionFromAddr(parVA, section)) info += "\"" + QString(section) + "\":"; - info += AddressToString(parVA); + info += QString("%1").arg(parVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); char label[MAX_LABEL_SIZE] = ""; if(DbgGetLabelAt(parVA, SEG_DEFAULT, label)) info += " <" + QString(label) + ">"; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp index d7d795ac..3041bd4d 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUStack.cpp @@ -224,7 +224,7 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset, #endif //_WIN64 } } - addrText += AddressToString(cur_addr); + addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label { char module[MAX_MODULE_SIZE] = ""; diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp index 44e27f6d..9abd93d1 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp @@ -123,12 +123,12 @@ void HexEditDialog::dataChangedSlot() ui->lineEditUnicode->setText(unicode); } -void HexEditDialog::on_lineEditAscii_textEdited(const QString & arg1) +void HexEditDialog::on_lineEditAscii_textEdited(const QString &arg1) { on_btnAscii2Hex_clicked(); } -void HexEditDialog::on_lineEditUnicode_textEdited(const QString & arg1) +void HexEditDialog::on_lineEditUnicode_textEdited(const QString &arg1) { on_btnUnicode2Hex_clicked(); } diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h index 8616abf3..13dd455f 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h @@ -28,8 +28,8 @@ private slots: void on_btnUnicode2Hex_clicked(); void on_chkKeepSize_toggled(bool checked); void dataChangedSlot(); - void on_lineEditAscii_textEdited(const QString & arg1); - void on_lineEditUnicode_textEdited(const QString & arg1); + void on_lineEditAscii_textEdited(const QString &arg1); + void on_lineEditUnicode_textEdited(const QString &arg1); private: Ui::HexEditDialog* ui; diff --git a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp index 66328826..92ca43f2 100644 --- a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp @@ -20,7 +20,6 @@ MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent) connect(Bridge::getBridge(), SIGNAL(updateMemory()), this, SLOT(refreshMap())); connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(stateChangedSlot(DBGSTATE))); connect(this, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(contextMenuSlot(QPoint))); - connect(this, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot())); setupContextMenu(); } @@ -147,11 +146,6 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos) wMenu->exec(mapToGlobal(pos)); //execute context menu } -void MemoryMapView::doubleClickedSlot() -{ - followDisassemblerSlot(); -} - QString MemoryMapView::getProtectionString(DWORD Protect) { #define RIGHTS_STRING (sizeof("ERWCG") + 1) diff --git a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h index 7c0847d6..1d7e4e37 100644 --- a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h +++ b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h @@ -28,7 +28,6 @@ public slots: void memoryRemoveSlot(); void memoryExecuteSingleshootToggleSlot(); void contextMenuSlot(const QPoint & pos); - void doubleClickedSlot(); void switchView(); void pageMemoryRights(); void refreshMap(); diff --git a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp index 85edc9b3..8e96cb3e 100644 --- a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp @@ -199,10 +199,6 @@ void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules) mModuleList->setCellContent(i, 1, modules[i].name); } mModuleList->reloadData(); - - // This BridgeFree call must remain here because of how arguments - // are passed; they are thread-thread delayed so passing a stack - // variable can not work. if(modules) BridgeFree(modules); } diff --git a/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp b/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp index 236b1c10..4266b420 100644 --- a/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ThreadView.cpp @@ -223,7 +223,7 @@ void ThreadView::updateThreadList() setCellContent(i, 0, "Main"); else setCellContent(i, 0, QString("%1").arg(threadList.list[i].BasicInfo.ThreadNumber, 0, 10)); - setCellContent(i, 1, QString("%1").arg(threadList.list[i].BasicInfo.ThreadId, 0, 16).toUpper()); + setCellContent(i, 1, QString("%1").arg(threadList.list[i].BasicInfo.dwThreadId, 0, 16).toUpper()); setCellContent(i, 2, QString("%1").arg(threadList.list[i].BasicInfo.ThreadStartAddress, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); setCellContent(i, 3, QString("%1").arg(threadList.list[i].BasicInfo.ThreadLocalBase, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); setCellContent(i, 4, QString("%1").arg(threadList.list[i].ThreadCip, sizeof(int_t) * 2, 16, QChar('0')).toUpper()); diff --git a/x64_dbg_gui/Project/Src/Utils/StringUtil.h b/x64_dbg_gui/Project/Src/Utils/StringUtil.h deleted file mode 100644 index 6f27817d..00000000 --- a/x64_dbg_gui/Project/Src/Utils/StringUtil.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef STRINGUTIL_H -#define STRINGUTIL_H - -#include -#include "NewTypes.h" - -static QString AddressToString(int_t Address) -{ - // - // This function exists because of how QT handles - // variables in strings. - // - // QString::arg(): - // ((int32)0xFFFF0000) == 0xFFFFFFFFFFFF0000 with sign extension - // - char temp[32]; - -#ifdef _WIN64 - sprintf_s(temp, "%016llX", Address); -#else - sprintf_s(temp, "%08X", Address); -#endif // _WIN64 - - return QString(temp); -} - -#endif // STRINGUTIL_H diff --git a/x64_dbg_gui/Project/x64_dbg.pro b/x64_dbg_gui/Project/x64_dbg.pro index 314862a3..1af66de0 100644 --- a/x64_dbg_gui/Project/x64_dbg.pro +++ b/x64_dbg_gui/Project/x64_dbg.pro @@ -151,8 +151,7 @@ HEADERS += \ Src/Gui/PageMemoryRights.h \ Src/Gui/SelectFields.h \ Src/Gui/ReferenceManager.h \ - Src/Bridge/BridgeResult.h \ - Src/Utils/StringUtil.h + Src/Bridge/BridgeResult.h INCLUDEPATH += \ diff --git a/x64_dbg_launcher/x64_dbg_launcher.vcxproj b/x64_dbg_launcher/x64_dbg_launcher.vcxproj index b239d668..d64cf9bd 100644 --- a/x64_dbg_launcher/x64_dbg_launcher.vcxproj +++ b/x64_dbg_launcher/x64_dbg_launcher.vcxproj @@ -1,10 +1,6 @@  - - Debug - Win32 - Release Win32 @@ -27,12 +23,6 @@ Application false - v120 - - - Application - false - v120 @@ -40,9 +30,6 @@ - - - false @@ -51,13 +38,6 @@ x96_dbg false - - false - $(SolutionDir)bin\ - $(Platform)\$(Configuration)\ - x96_dbg - false - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -77,25 +57,6 @@ - - - WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - - - MachineX86 - true - Windows - true - true - shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(TargetDir)$(TargetName).pdb - - - - From 669190db22c7cfd7152e9ec691735ac47220c261 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 12:29:25 +0200 Subject: [PATCH 098/106] DBG: added yara library --- release.bat | 5 + x64_dbg_dbg/_global.h | 1 + x64_dbg_dbg/instruction.cpp | 5 + x64_dbg_dbg/instruction.h | 1 + x64_dbg_dbg/x64_dbg.cpp | 4 + x64_dbg_dbg/x64_dbg_dbg.vcxproj | 34 +- x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters | 96 +++++ x64_dbg_dbg/yara/yara.h | 28 ++ x64_dbg_dbg/yara/yara/ahocorasick.h | 50 +++ x64_dbg_dbg/yara/yara/arena.h | 151 +++++++ x64_dbg_dbg/yara/yara/atoms.h | 89 ++++ x64_dbg_dbg/yara/yara/compiler.h | 196 +++++++++ x64_dbg_dbg/yara/yara/elf.h | 202 +++++++++ x64_dbg_dbg/yara/yara/error.h | 100 +++++ x64_dbg_dbg/yara/yara/exec.h | 156 +++++++ x64_dbg_dbg/yara/yara/exefiles.h | 30 ++ x64_dbg_dbg/yara/yara/filemap.h | 62 +++ x64_dbg_dbg/yara/yara/globals.h | 23 ++ x64_dbg_dbg/yara/yara/hash.h | 66 +++ x64_dbg_dbg/yara/yara/hex_lexer.h | 98 +++++ x64_dbg_dbg/yara/yara/lexer.h | 130 ++++++ x64_dbg_dbg/yara/yara/libyara.h | 49 +++ x64_dbg_dbg/yara/yara/limits.h | 48 +++ x64_dbg_dbg/yara/yara/mem.h | 63 +++ x64_dbg_dbg/yara/yara/modules.h | 439 ++++++++++++++++++++ x64_dbg_dbg/yara/yara/object.h | 156 +++++++ x64_dbg_dbg/yara/yara/parser.h | 120 ++++++ x64_dbg_dbg/yara/yara/pe.h | 467 +++++++++++++++++++++ x64_dbg_dbg/yara/yara/proc.h | 26 ++ x64_dbg_dbg/yara/yara/re.h | 236 +++++++++++ x64_dbg_dbg/yara/yara/re_lexer.h | 97 +++++ x64_dbg_dbg/yara/yara/rules.h | 127 ++++++ x64_dbg_dbg/yara/yara/scan.h | 35 ++ x64_dbg_dbg/yara/yara/sizedstr.h | 42 ++ x64_dbg_dbg/yara/yara/strutils.h | 77 ++++ x64_dbg_dbg/yara/yara/types.h | 519 ++++++++++++++++++++++++ x64_dbg_dbg/yara/yara/utils.h | 67 +++ x64_dbg_dbg/yara/yara_x64.a | Bin 0 -> 25114 bytes x64_dbg_dbg/yara/yara_x64.lib | Bin 0 -> 8692 bytes x64_dbg_dbg/yara/yara_x86.a | Bin 0 -> 24986 bytes x64_dbg_dbg/yara/yara_x86.lib | Bin 0 -> 8838 bytes 41 files changed, 4093 insertions(+), 2 deletions(-) create mode 100644 x64_dbg_dbg/yara/yara.h create mode 100644 x64_dbg_dbg/yara/yara/ahocorasick.h create mode 100644 x64_dbg_dbg/yara/yara/arena.h create mode 100644 x64_dbg_dbg/yara/yara/atoms.h create mode 100644 x64_dbg_dbg/yara/yara/compiler.h create mode 100644 x64_dbg_dbg/yara/yara/elf.h create mode 100644 x64_dbg_dbg/yara/yara/error.h create mode 100644 x64_dbg_dbg/yara/yara/exec.h create mode 100644 x64_dbg_dbg/yara/yara/exefiles.h create mode 100644 x64_dbg_dbg/yara/yara/filemap.h create mode 100644 x64_dbg_dbg/yara/yara/globals.h create mode 100644 x64_dbg_dbg/yara/yara/hash.h create mode 100644 x64_dbg_dbg/yara/yara/hex_lexer.h create mode 100644 x64_dbg_dbg/yara/yara/lexer.h create mode 100644 x64_dbg_dbg/yara/yara/libyara.h create mode 100644 x64_dbg_dbg/yara/yara/limits.h create mode 100644 x64_dbg_dbg/yara/yara/mem.h create mode 100644 x64_dbg_dbg/yara/yara/modules.h create mode 100644 x64_dbg_dbg/yara/yara/object.h create mode 100644 x64_dbg_dbg/yara/yara/parser.h create mode 100644 x64_dbg_dbg/yara/yara/pe.h create mode 100644 x64_dbg_dbg/yara/yara/proc.h create mode 100644 x64_dbg_dbg/yara/yara/re.h create mode 100644 x64_dbg_dbg/yara/yara/re_lexer.h create mode 100644 x64_dbg_dbg/yara/yara/rules.h create mode 100644 x64_dbg_dbg/yara/yara/scan.h create mode 100644 x64_dbg_dbg/yara/yara/sizedstr.h create mode 100644 x64_dbg_dbg/yara/yara/strutils.h create mode 100644 x64_dbg_dbg/yara/yara/types.h create mode 100644 x64_dbg_dbg/yara/yara/utils.h create mode 100644 x64_dbg_dbg/yara/yara_x64.a create mode 100644 x64_dbg_dbg/yara/yara_x64.lib create mode 100644 x64_dbg_dbg/yara/yara_x86.a create mode 100644 x64_dbg_dbg/yara/yara_x86.lib diff --git a/release.bat b/release.bat index daea1b06..a471eae0 100644 --- a/release.bat +++ b/release.bat @@ -31,6 +31,7 @@ copy bin\x32\jansson.dll %RELEASEDIR%\bin_base\x32\jansson.dll copy bin\x32\lz4.dll %RELEASEDIR%\bin_base\x32\lz4.dll copy bin\x32\TitanEngine.dll %RELEASEDIR%\bin_base\x32\TitanEngine.dll copy bin\x32\XEDParse.dll %RELEASEDIR%\bin_base\x32\XEDParse.dll +copy bin\x32\yara.dll %RELEASEDIR%\bin_base\x32\yara.dll copy bin\x64\BeaEngine.dll %RELEASEDIR%\bin_base\x64\BeaEngine.dll copy bin\x64\dbghelp.dll %RELEASEDIR%\bin_base\x64\dbghelp.dll copy bin\x64\symsrv.dll %RELEASEDIR%\bin_base\x64\symsrv.dll @@ -40,6 +41,7 @@ copy bin\x64\jansson.dll %RELEASEDIR%\bin_base\x64\jansson.dll copy bin\x64\lz4.dll %RELEASEDIR%\bin_base\x64\lz4.dll copy bin\x64\TitanEngine.dll %RELEASEDIR%\bin_base\x64\TitanEngine.dll copy bin\x64\XEDParse.dll %RELEASEDIR%\bin_base\x64\XEDParse.dll +copy bin\x64\yara.dll %RELEASEDIR%\bin_base\x64\yara.dll echo help @@ -57,6 +59,8 @@ mkdir %RELEASEDIR%\pluginsdk\jansson mkdir %RELEASEDIR%\pluginsdk\lz4 mkdir %RELEASEDIR%\pluginsdk\TitanEngine mkdir %RELEASEDIR%\pluginsdk\XEDParse +mkdir %RELEASEDIR%\pluginsdk\yara +mkdir %RELEASEDIR%\pluginsdk\yara\yara xcopy x64_dbg_dbg\BeaEngine %RELEASEDIR%\pluginsdk\BeaEngine /S /Y xcopy x64_dbg_dbg\dbghelp %RELEASEDIR%\pluginsdk\dbghelp /S /Y @@ -66,6 +70,7 @@ xcopy x64_dbg_dbg\lz4 %RELEASEDIR%\pluginsdk\lz4 /S /Y xcopy x64_dbg_dbg\TitanEngine %RELEASEDIR%\pluginsdk\TitanEngine /S /Y del %RELEASEDIR%\pluginsdk\TitanEngine\TitanEngine.txt /F /Q xcopy x64_dbg_dbg\XEDParse %RELEASEDIR%\pluginsdk\XEDParse /S /Y +xcopy x64_dbg_dbg\yara %RELEASEDIR%\pluginsdk\yara /S /Y copy x64_dbg_dbg\_plugin_types.h %RELEASEDIR%\pluginsdk\_plugin_types.h copy x64_dbg_dbg\_plugins.h %RELEASEDIR%\pluginsdk\_plugins.h copy x64_dbg_dbg\_dbgfunctions.h %RELEASEDIR%\pluginsdk\_dbgfunctions.h diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index 60bf68f9..505bf2a1 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -19,6 +19,7 @@ #include #include "..\x64_dbg_bridge\bridgemain.h" #include "jansson\jansson.h" +#include "yara\yara.h" #include "DeviceNameResolver\DeviceNameResolver.h" #include "handle.h" #include "stringutils.h" diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index f9cba729..08aa50fc 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -1530,3 +1530,8 @@ CMDRESULT cbInstrFindAsm(int argc, char* argv[]) varset("$result", found, false); return STATUS_CONTINUE; } + +CMDRESULT cbInstrYara(int argc, char* argv[]) +{ + return STATUS_CONTINUE; +} \ No newline at end of file diff --git a/x64_dbg_dbg/instruction.h b/x64_dbg_dbg/instruction.h index 231f0fc8..510970b5 100644 --- a/x64_dbg_dbg/instruction.h +++ b/x64_dbg_dbg/instruction.h @@ -62,5 +62,6 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[]); CMDRESULT cbInstrLoopList(int argc, char* argv[]); CMDRESULT cbInstrSleep(int argc, char* argv[]); CMDRESULT cbInstrFindAsm(int argc, char* argv[]); +CMDRESULT cbInstrYara(int argc, char* argv[]); #endif // _INSTRUCTIONS_H diff --git a/x64_dbg_dbg/x64_dbg.cpp b/x64_dbg_dbg/x64_dbg.cpp index ff2b7dba..d3b65f98 100644 --- a/x64_dbg_dbg/x64_dbg.cpp +++ b/x64_dbg_dbg/x64_dbg.cpp @@ -189,6 +189,7 @@ static void registercommands() dbgcmdnew("getstr\1strget", cbInstrGetstr, false); //get a string variable dbgcmdnew("copystr\1strcpy", cbInstrCopystr, true); //write a string variable to memory dbgcmdnew("looplist", cbInstrLoopList, true); //list loops + dbgcmdnew("yara", cbInstrYara, true); //yara test command } static bool cbCommandProvider(char* cmd, int maxlen) @@ -239,6 +240,8 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit() dbginit(); dbgfunctionsinit(); json_set_alloc_funcs(emalloc_json, efree_json); + if(yr_initialize() != ERROR_SUCCESS) + return "Failed to initialize Yara!"; wchar_t wszDir[deflen] = L""; if(!GetModuleFileNameW(hInst, wszDir, deflen)) return "GetModuleFileNameW failed!"; @@ -306,6 +309,7 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal() cmdfree(command_list); varfree(); msgfreestack(gMsgStack); + yr_finalize(); if(memleaks()) { char msg[256] = ""; diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj b/x64_dbg_dbg/x64_dbg_dbg.vcxproj index c544ed20..40ae0a77 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj @@ -110,6 +110,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -163,7 +193,7 @@ Windows true true - lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) + yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32_bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) @@ -178,7 +208,7 @@ Windows true true - lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) + yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64_bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies) diff --git a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters index 4974409f..a3697cff 100644 --- a/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters +++ b/x64_dbg_dbg/x64_dbg_dbg.vcxproj.filters @@ -67,6 +67,12 @@ {b006b04c-d7ea-49cb-b097-0cac1388f98e} + + {efe5d058-e77c-49e9-a25b-75b90346dbf2} + + + {f79c5166-e315-44ca-9e93-dabc9f00fa78} + @@ -377,5 +383,95 @@ Header Files\Utilities + + Header Files\Third Party\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + + + Header Files\Third Party\yara\yara + \ No newline at end of file diff --git a/x64_dbg_dbg/yara/yara.h b/x64_dbg_dbg/yara/yara.h new file mode 100644 index 00000000..0a176bbb --- /dev/null +++ b/x64_dbg_dbg/yara/yara.h @@ -0,0 +1,28 @@ +/* +Copyright (c) 2007-2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_YARA_H +#define YR_YARA_H + +#include "yara/utils.h" +#include "yara/filemap.h" +#include "yara/compiler.h" +#include "yara/modules.h" +#include "yara/object.h" +#include "yara/libyara.h" +#include "yara/error.h" + +#endif diff --git a/x64_dbg_dbg/yara/yara/ahocorasick.h b/x64_dbg_dbg/yara/yara/ahocorasick.h new file mode 100644 index 00000000..7d88413d --- /dev/null +++ b/x64_dbg_dbg/yara/yara/ahocorasick.h @@ -0,0 +1,50 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef _AHOCORASICK_H +#define _AHOCORASICK_H + +#include "limits.h" +#include "atoms.h" +#include "types.h" + + +int yr_ac_create_automaton( + YR_ARENA* arena, + YR_AC_AUTOMATON** automaton); + + +int yr_ac_add_string( + YR_ARENA* arena, + YR_AC_AUTOMATON* automaton, + YR_STRING* string, + YR_ATOM_LIST_ITEM* atom); + + +YR_AC_STATE* yr_ac_next_state( + YR_AC_STATE* state, + uint8_t input); + + +int yr_ac_create_failure_links( + YR_ARENA* arena, + YR_AC_AUTOMATON* automaton); + + +void yr_ac_print_automaton( + YR_AC_AUTOMATON* automaton); + +#endif diff --git a/x64_dbg_dbg/yara/yara/arena.h b/x64_dbg_dbg/yara/yara/arena.h new file mode 100644 index 00000000..a6ede1e0 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/arena.h @@ -0,0 +1,151 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_ARENA_H +#define YR_ARENA_H + +#include +#include + + +#define ARENA_FLAGS_FIXED_SIZE 1 +#define ARENA_FLAGS_COALESCED 2 +#define ARENA_FILE_VERSION 6 + +#define EOL ((size_t) -1) + + +typedef struct _YR_RELOC +{ + int32_t offset; + struct _YR_RELOC* next; + +} YR_RELOC; + + +typedef struct _YR_ARENA_PAGE +{ + + uint8_t* new_address; + uint8_t* address; + + size_t size; + size_t used; + + YR_RELOC* reloc_list_head; + YR_RELOC* reloc_list_tail; + + struct _YR_ARENA_PAGE* next; + struct _YR_ARENA_PAGE* prev; + +} YR_ARENA_PAGE; + + +typedef struct _YR_ARENA +{ + int flags; + + YR_ARENA_PAGE* page_list_head; + YR_ARENA_PAGE* current_page; + +} YR_ARENA; + + +int yr_arena_create( + size_t initial_size, + int flags, + YR_ARENA** arena); + + +void yr_arena_destroy( + YR_ARENA* arena); + + +void* yr_arena_base_address( + YR_ARENA* arena); + + +void* yr_arena_next_address( + YR_ARENA* arena, + void* address, + int offset); + + +int yr_arena_coalesce( + YR_ARENA* arena); + + +int yr_arena_reserve_memory( + YR_ARENA* arena, + size_t size); + + +int yr_arena_allocate_memory( + YR_ARENA* arena, + size_t size, + void** allocated_memory); + + +int yr_arena_allocate_struct( + YR_ARENA* arena, + size_t size, + void** allocated_memory, + ...); + + +int yr_arena_make_relocatable( + YR_ARENA* arena, + void* base, + ...); + + +int yr_arena_write_data( + YR_ARENA* arena, + void* data, + size_t size, + void** written_data); + + +int yr_arena_write_string( + YR_ARENA* arena, + const char* string, + char** written_string); + + +int yr_arena_append( + YR_ARENA* target_arena, + YR_ARENA* source_arena); + + +int yr_arena_save( + YR_ARENA* arena, + const char* filename); + + +int yr_arena_load( + const char* filename, + YR_ARENA** arena); + + +int yr_arena_duplicate( + YR_ARENA* arena, + YR_ARENA** duplicated); + + +void yr_arena_print( + YR_ARENA* arena); + +#endif diff --git a/x64_dbg_dbg/yara/yara/atoms.h b/x64_dbg_dbg/yara/yara/atoms.h new file mode 100644 index 00000000..859e4f13 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/atoms.h @@ -0,0 +1,89 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_ATOMS_H +#define YR_ATOMS_H + +#include "limits.h" +#include "re.h" + +#define ATOM_TREE_LEAF 1 +#define ATOM_TREE_AND 2 +#define ATOM_TREE_OR 3 + + +typedef struct _ATOM_TREE_NODE +{ + uint8_t type; + uint8_t atom_length; + uint8_t atom[MAX_ATOM_LENGTH]; + + uint8_t* forward_code; + uint8_t* backward_code; + + RE_NODE* recent_nodes[MAX_ATOM_LENGTH]; + + struct _ATOM_TREE_NODE* children_head; + struct _ATOM_TREE_NODE* children_tail; + struct _ATOM_TREE_NODE* next_sibling; + +} ATOM_TREE_NODE; + + +typedef struct _ATOM_TREE +{ + ATOM_TREE_NODE* current_leaf; + ATOM_TREE_NODE* root_node; + +} ATOM_TREE; + + +typedef struct _YR_ATOM_LIST_ITEM +{ + uint8_t atom_length; + uint8_t atom[MAX_ATOM_LENGTH]; + + uint16_t backtrack; + + uint8_t* forward_code; + uint8_t* backward_code; + + struct _YR_ATOM_LIST_ITEM* next; + +} YR_ATOM_LIST_ITEM; + + +int yr_atoms_extract_from_re( + RE* re, + int flags, + YR_ATOM_LIST_ITEM** atoms); + + +int yr_atoms_extract_from_string( + uint8_t* string, + int string_length, + int flags, + YR_ATOM_LIST_ITEM** atoms); + + +int yr_atoms_min_quality( + YR_ATOM_LIST_ITEM* atom_list); + + +void yr_atoms_list_destroy( + YR_ATOM_LIST_ITEM* list_head); + +#endif diff --git a/x64_dbg_dbg/yara/yara/compiler.h b/x64_dbg_dbg/yara/yara/compiler.h new file mode 100644 index 00000000..232a9782 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/compiler.h @@ -0,0 +1,196 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_COMPILER_H +#define YR_COMPILER_H + +#include +#include + +#include "ahocorasick.h" +#include "arena.h" +#include "hash.h" +#include "utils.h" + + +#define YARA_ERROR_LEVEL_ERROR 0 +#define YARA_ERROR_LEVEL_WARNING 1 + + +typedef void (*YR_COMPILER_CALLBACK_FUNC)( + int error_level, + const char* file_name, + int line_number, + const char* message, + void* user_data); + + +typedef struct _YR_COMPILER +{ + int errors; + int error_line; + int last_error; + int last_error_line; + int last_result; + + jmp_buf error_recovery; + + YR_ARENA* sz_arena; + YR_ARENA* rules_arena; + YR_ARENA* strings_arena; + YR_ARENA* code_arena; + YR_ARENA* re_code_arena; + YR_ARENA* automaton_arena; + YR_ARENA* compiled_rules_arena; + YR_ARENA* externals_arena; + YR_ARENA* namespaces_arena; + YR_ARENA* metas_arena; + + YR_AC_AUTOMATON* automaton; + YR_HASH_TABLE* rules_table; + YR_HASH_TABLE* objects_table; + YR_NAMESPACE* current_namespace; + YR_STRING* current_rule_strings; + + int current_rule_flags; + int namespaces_count; + + int8_t* loop_address[MAX_LOOP_NESTING]; + char* loop_identifier[MAX_LOOP_NESTING]; + int loop_depth; + int loop_for_of_mem_offset; + + int allow_includes; + + char* file_name_stack[MAX_INCLUDE_DEPTH]; + int file_name_stack_ptr; + + FILE* file_stack[MAX_INCLUDE_DEPTH]; + int file_stack_ptr; + + char last_error_extra_info[MAX_COMPILER_ERROR_EXTRA_INFO]; + + char lex_buf[LEX_BUF_SIZE]; + char* lex_buf_ptr; + unsigned short lex_buf_len; + + char include_base_dir[MAX_PATH]; + void* user_data; + + YR_COMPILER_CALLBACK_FUNC callback; + +} YR_COMPILER; + + +#define yr_compiler_set_error_extra_info(compiler, info) \ + strlcpy( \ + compiler->last_error_extra_info, \ + info, \ + sizeof(compiler->last_error_extra_info)); \ + + +#define yr_compiler_set_error_extra_info_fmt(compiler, fmt, ...) \ + snprintf( \ + compiler->last_error_extra_info, \ + sizeof(compiler->last_error_extra_info), \ + fmt, __VA_ARGS__); + + +int _yr_compiler_push_file( + YR_COMPILER* compiler, + FILE* fh); + + +FILE* _yr_compiler_pop_file( + YR_COMPILER* compiler); + + +int _yr_compiler_push_file_name( + YR_COMPILER* compiler, + const char* file_name); + + +void _yr_compiler_pop_file_name( + YR_COMPILER* compiler); + + +YR_API int yr_compiler_create( + YR_COMPILER** compiler); + + +YR_API void yr_compiler_destroy( + YR_COMPILER* compiler); + + +YR_API void yr_compiler_set_callback( + YR_COMPILER* compiler, + YR_COMPILER_CALLBACK_FUNC callback, + void* user_data); + + +YR_API int yr_compiler_add_file( + YR_COMPILER* compiler, + FILE* rules_file, + const char* namespace_, + const char* file_name); + + +YR_API int yr_compiler_add_string( + YR_COMPILER* compiler, + const char* rules_string, + const char* namespace_); + + +YR_API char* yr_compiler_get_error_message( + YR_COMPILER* compiler, + char* buffer, + int buffer_size); + + +YR_API char* yr_compiler_get_current_file_name( + YR_COMPILER* context); + + +YR_API int yr_compiler_define_integer_variable( + YR_COMPILER* compiler, + const char* identifier, + int64_t value); + + +YR_API int yr_compiler_define_boolean_variable( + YR_COMPILER* compiler, + const char* identifier, + int value); + + +YR_API int yr_compiler_define_float_variable( + YR_COMPILER* compiler, + const char* identifier, + double value); + + +YR_API int yr_compiler_define_string_variable( + YR_COMPILER* compiler, + const char* identifier, + const char* value); + + +YR_API int yr_compiler_get_rules( + YR_COMPILER* compiler, + YR_RULES** rules); + + +#endif diff --git a/x64_dbg_dbg/yara/yara/elf.h b/x64_dbg_dbg/yara/yara/elf.h new file mode 100644 index 00000000..5f386589 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/elf.h @@ -0,0 +1,202 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef _ELF_H +#define _ELF_H + +#include + + +// 32-bit ELF base types + +typedef uint32_t elf32_addr_t; +typedef uint16_t elf32_half_t; +typedef uint32_t elf32_off_t; +typedef uint32_t elf32_word_t; + +// 64-bit ELF base types + +typedef uint64_t elf64_addr_t; +typedef uint16_t elf64_half_t; +typedef uint64_t elf64_off_t; +typedef uint32_t elf64_word_t; +typedef uint64_t elf64_xword_t; + +#define ELF_MAGIC 0x464C457F + +#define ELF_ET_NONE 0x0000 // no type +#define ELF_ET_REL 0x0001 // relocatable +#define ELF_ET_EXEC 0x0002 // executeable +#define ELF_ET_DYN 0x0003 // Shared-Object-File +#define ELF_ET_CORE 0x0004 // Corefile +#define ELF_ET_LOPROC 0xFF00 // Processor-specific +#define ELF_ET_HIPROC 0x00FF // Processor-specific + +#define ELF_EM_NONE 0x0000 // no type +#define ELF_EM_M32 0x0001 // AT&T WE 32100 +#define ELF_EM_SPARC 0x0002 // SPARC +#define ELF_EM_386 0x0003 // Intel 80386 +#define ELF_EM_68K 0x0004 // Motorola 68000 +#define ELF_EM_88K 0x0005 // Motorola 88000 +#define ELF_EM_860 0x0007 // Intel 80860 +#define ELF_EM_MIPS 0x0008 // MIPS RS3000 +#define ELF_EM_ARM 0x0032 // ARM +#define ELF_EM_X86_64 0x003E // AMD/Intel x86_64 + +#define ELF_CLASS_NONE 0x0000 +#define ELF_CLASS_32 0x0001 // 32bit file +#define ELF_CLASS_64 0x0002 // 64bit file + +#define ELF_DATA_NONE 0x0000 +#define ELF_DATA_2LSB 0x0001 +#define ELF_DATA_2MSB 0x002 + + +#define ELF_SHT_NULL 0 // Section header table entry unused +#define ELF_SHT_PROGBITS 1 // Program data +#define ELF_SHT_SYMTAB 2 // Symbol table +#define ELF_SHT_STRTAB 3 // String table +#define ELF_SHT_RELA 4 // Relocation entries with addends +#define ELF_SHT_HASH 5 // Symbol hash table +#define ELF_SHT_DYNAMIC 6 // Dynamic linking information +#define ELF_SHT_NOTE 7 // Notes +#define ELF_SHT_NOBITS 8 // Program space with no data (bss) +#define ELF_SHT_REL 9 // Relocation entries, no addends +#define ELF_SHT_SHLIB 10 // Reserved +#define ELF_SHT_DYNSYM 11 // Dynamic linker symbol table +#define ELF_SHT_NUM 12 // Number of defined types + +#define ELF_SHF_WRITE 0x1 // Section is writable +#define ELF_SHF_ALLOC 0x2 // Section is present during execution +#define ELF_SHF_EXECINSTR 0x4 // Section contains executable instructions + +#pragma pack(push,1) + +typedef struct +{ + uint32_t magic; + uint8_t _class; + uint8_t data; + uint8_t version; + uint8_t pad[8]; + uint8_t nident; + +} elf_ident_t; + + +typedef struct +{ + elf_ident_t ident; + elf32_half_t type; + elf32_half_t machine; + elf32_word_t version; + elf32_addr_t entry; + elf32_off_t ph_offset; + elf32_off_t sh_offset; + elf32_word_t flags; + elf32_half_t header_size; + elf32_half_t ph_entry_size; + elf32_half_t ph_entry_count; + elf32_half_t sh_entry_size; + elf32_half_t sh_entry_count; + elf32_half_t sh_str_table_index; + +} elf32_header_t; + + +typedef struct +{ + elf_ident_t ident; + elf64_half_t type; + elf64_half_t machine; + elf64_word_t version; + elf64_addr_t entry; + elf64_off_t ph_offset; + elf64_off_t sh_offset; + elf64_word_t flags; + elf64_half_t header_size; + elf64_half_t ph_entry_size; + elf64_half_t ph_entry_count; + elf64_half_t sh_entry_size; + elf64_half_t sh_entry_count; + elf64_half_t sh_str_table_index; + +} elf64_header_t; + + +typedef struct +{ + elf32_word_t type; + elf32_off_t offset; + elf32_addr_t virt_addr; + elf32_addr_t phys_addr; + elf32_word_t file_size; + elf32_word_t mem_size; + elf32_word_t flags; + elf32_word_t alignment; + +} elf32_program_header_t; + + +typedef struct +{ + elf64_word_t type; + elf64_word_t flags; + elf64_off_t offset; + elf64_addr_t virt_addr; + elf64_addr_t phys_addr; + elf64_xword_t file_size; + elf64_xword_t mem_size; + elf64_xword_t alignment; + +} elf64_program_header_t; + + +typedef struct +{ + elf32_word_t name; + elf32_word_t type; + elf32_word_t flags; + elf32_addr_t addr; + elf32_off_t offset; + elf32_word_t size; + elf32_word_t link; + elf32_word_t info; + elf32_word_t align; + elf32_word_t entry_size; + +} elf32_section_header_t; + + +typedef struct +{ + elf64_word_t name; + elf64_word_t type; + elf64_xword_t flags; + elf64_addr_t addr; + elf64_off_t offset; + elf64_xword_t size; + elf64_word_t link; + elf64_word_t info; + elf64_xword_t align; + elf64_xword_t entry_size; + +} elf64_section_header_t; + + +#pragma pack(pop) + +#endif diff --git a/x64_dbg_dbg/yara/yara/error.h b/x64_dbg_dbg/yara/yara/error.h new file mode 100644 index 00000000..1e2b6f70 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/error.h @@ -0,0 +1,100 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_ERROR_H +#define YR_ERROR_H + +#include + +#ifndef ERROR_SUCCESS +#define ERROR_SUCCESS 0 +#endif + +#define ERROR_INSUFICIENT_MEMORY 1 +#define ERROR_COULD_NOT_ATTACH_TO_PROCESS 2 +#define ERROR_COULD_NOT_OPEN_FILE 3 +#define ERROR_COULD_NOT_MAP_FILE 4 +#define ERROR_INVALID_FILE 6 +#define ERROR_CORRUPT_FILE 7 +#define ERROR_UNSUPPORTED_FILE_VERSION 8 +#define ERROR_INVALID_REGULAR_EXPRESSION 9 +#define ERROR_INVALID_HEX_STRING 10 +#define ERROR_SYNTAX_ERROR 11 +#define ERROR_LOOP_NESTING_LIMIT_EXCEEDED 12 +#define ERROR_DUPLICATED_LOOP_IDENTIFIER 13 +#define ERROR_DUPLICATED_IDENTIFIER 14 +#define ERROR_DUPLICATED_TAG_IDENTIFIER 15 +#define ERROR_DUPLICATED_META_IDENTIFIER 16 +#define ERROR_DUPLICATED_STRING_IDENTIFIER 17 +#define ERROR_UNREFERENCED_STRING 18 +#define ERROR_UNDEFINED_STRING 19 +#define ERROR_UNDEFINED_IDENTIFIER 20 +#define ERROR_MISPLACED_ANONYMOUS_STRING 21 +#define ERROR_INCLUDES_CIRCULAR_REFERENCE 22 +#define ERROR_INCLUDE_DEPTH_EXCEEDED 23 +#define ERROR_WRONG_TYPE 24 +#define ERROR_EXEC_STACK_OVERFLOW 25 +#define ERROR_SCAN_TIMEOUT 26 +#define ERROR_TOO_MANY_SCAN_THREADS 27 +#define ERROR_CALLBACK_ERROR 28 +#define ERROR_INVALID_ARGUMENT 29 +#define ERROR_TOO_MANY_MATCHES 30 +#define ERROR_INTERNAL_FATAL_ERROR 31 +#define ERROR_NESTED_FOR_OF_LOOP 32 +#define ERROR_INVALID_FIELD_NAME 33 +#define ERROR_UNKNOWN_MODULE 34 +#define ERROR_NOT_A_STRUCTURE 35 +#define ERROR_NOT_INDEXABLE 36 +#define ERROR_NOT_A_FUNCTION 37 +#define ERROR_INVALID_FORMAT 38 +#define ERROR_TOO_MANY_ARGUMENTS 39 +#define ERROR_WRONG_ARGUMENTS 40 +#define ERROR_WRONG_RETURN_TYPE 41 +#define ERROR_DUPLICATED_STRUCTURE_MEMBER 42 + + +#define FAIL_ON_ERROR(x) { \ + int result = (x); \ + if (result != ERROR_SUCCESS) \ + return result; \ +} + +#define FAIL_ON_ERROR_WITH_CLEANUP(x, cleanup) { \ + int result = (x); \ + if (result != ERROR_SUCCESS) { \ + cleanup; \ + return result; \ + } \ +} + +#define FAIL_ON_COMPILER_ERROR(x) { \ + compiler->last_result = (x); \ + if (compiler->last_result != ERROR_SUCCESS) \ + return compiler->last_result; \ +} + + +#ifdef NDEBUG +#define assertf(expr, msg) ((void)0) +#else +#define assertf(expr, msg, ...) \ + if(!(expr)) { \ + fprintf(stderr, "%s:%d: " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ + abort(); \ + } +#endif + +#endif diff --git a/x64_dbg_dbg/yara/yara/exec.h b/x64_dbg_dbg/yara/yara/exec.h new file mode 100644 index 00000000..eaf8e02b --- /dev/null +++ b/x64_dbg_dbg/yara/yara/exec.h @@ -0,0 +1,156 @@ +/* +Copyright (c) 2013-2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_EXEC_H +#define YR_EXEC_H + +#include "hash.h" +#include "scan.h" +#include "types.h" +#include "rules.h" + + +#define UNDEFINED 0xFFFABADAFABADAFFLL +#define IS_UNDEFINED(x) ((size_t)(x) == (size_t) UNDEFINED) + +#define OP_ERROR 0 +#define OP_HALT 255 + +#define OP_AND 1 +#define OP_OR 2 +#define OP_NOT 3 +#define OP_BITWISE_NOT 4 +#define OP_BITWISE_AND 5 +#define OP_BITWISE_OR 6 +#define OP_BITWISE_XOR 7 +#define OP_SHL 8 +#define OP_SHR 9 +#define OP_MOD 10 +#define OP_INT_TO_DBL 11 +#define OP_STR_TO_BOOL 12 +#define OP_PUSH 13 +#define OP_POP 14 +#define OP_CALL 15 +#define OP_OBJ_LOAD 16 +#define OP_OBJ_VALUE 17 +#define OP_OBJ_FIELD 18 +#define OP_INDEX_ARRAY 19 +#define OP_COUNT 20 +#define OP_FOUND 21 +#define OP_FOUND_AT 22 +#define OP_FOUND_IN 23 +#define OP_OFFSET 24 +#define OP_OF 25 +#define OP_PUSH_RULE 26 +#define OP_MATCH_RULE 27 +#define OP_INCR_M 28 +#define OP_CLEAR_M 29 +#define OP_ADD_M 30 +#define OP_POP_M 31 +#define OP_PUSH_M 32 +#define OP_SWAPUNDEF 33 +#define OP_JNUNDEF 34 +#define OP_JLE 35 +#define OP_FILESIZE 36 +#define OP_ENTRYPOINT 37 +#define OP_CONTAINS 38 +#define OP_MATCHES 39 +#define OP_IMPORT 40 +#define OP_LOOKUP_DICT 41 + +#define _OP_EQ 0 +#define _OP_NEQ 1 +#define _OP_LT 2 +#define _OP_GT 3 +#define _OP_LE 4 +#define _OP_GE 5 +#define _OP_ADD 6 +#define _OP_SUB 7 +#define _OP_MUL 8 +#define _OP_DIV 9 +#define _OP_MINUS 10 + +#define OP_INT_BEGIN 100 +#define OP_INT_EQ (OP_INT_BEGIN + _OP_EQ) +#define OP_INT_NEQ (OP_INT_BEGIN + _OP_NEQ) +#define OP_INT_LT (OP_INT_BEGIN + _OP_LT) +#define OP_INT_GT (OP_INT_BEGIN + _OP_GT) +#define OP_INT_LE (OP_INT_BEGIN + _OP_LE) +#define OP_INT_GE (OP_INT_BEGIN + _OP_GE) +#define OP_INT_ADD (OP_INT_BEGIN + _OP_ADD) +#define OP_INT_SUB (OP_INT_BEGIN + _OP_SUB) +#define OP_INT_MUL (OP_INT_BEGIN + _OP_MUL) +#define OP_INT_DIV (OP_INT_BEGIN + _OP_DIV) +#define OP_INT_MINUS (OP_INT_BEGIN + _OP_MINUS) +#define OP_INT_END OP_INT_MINUS + +#define OP_DBL_BEGIN 120 +#define OP_DBL_EQ (OP_DBL_BEGIN + _OP_EQ) +#define OP_DBL_NEQ (OP_DBL_BEGIN + _OP_NEQ) +#define OP_DBL_LT (OP_DBL_BEGIN + _OP_LT) +#define OP_DBL_GT (OP_DBL_BEGIN + _OP_GT) +#define OP_DBL_LE (OP_DBL_BEGIN + _OP_LE) +#define OP_DBL_GE (OP_DBL_BEGIN + _OP_GE) +#define OP_DBL_ADD (OP_DBL_BEGIN + _OP_ADD) +#define OP_DBL_SUB (OP_DBL_BEGIN + _OP_SUB) +#define OP_DBL_MUL (OP_DBL_BEGIN + _OP_MUL) +#define OP_DBL_DIV (OP_DBL_BEGIN + _OP_DIV) +#define OP_DBL_MINUS (OP_DBL_BEGIN + _OP_MINUS) +#define OP_DBL_END OP_DBL_MINUS + +#define OP_STR_BEGIN 140 +#define OP_STR_EQ (OP_STR_BEGIN + _OP_EQ) +#define OP_STR_NEQ (OP_STR_BEGIN + _OP_NEQ) +#define OP_STR_LT (OP_STR_BEGIN + _OP_LT) +#define OP_STR_GT (OP_STR_BEGIN + _OP_GT) +#define OP_STR_LE (OP_STR_BEGIN + _OP_LE) +#define OP_STR_GE (OP_STR_BEGIN + _OP_GE) +#define OP_STR_END OP_STR_GE + +#define IS_INT_OP(x) ((x) >= OP_INT_BEGIN && (x) <= OP_INT_END) +#define IS_DBL_OP(x) ((x) >= OP_DBL_BEGIN && (x) <= OP_DBL_END) +#define IS_STR_OP(x) ((x) >= OP_STR_BEGIN && (x) <= OP_STR_END) + +#define OP_READ_INT 240 +#define OP_INT8 (OP_READ_INT + 0) +#define OP_INT16 (OP_READ_INT + 1) +#define OP_INT32 (OP_READ_INT + 2) +#define OP_UINT8 (OP_READ_INT + 3) +#define OP_UINT16 (OP_READ_INT + 4) +#define OP_UINT32 (OP_READ_INT + 5) +#define OP_INT8BE (OP_READ_INT + 6) +#define OP_INT16BE (OP_READ_INT + 7) +#define OP_INT32BE (OP_READ_INT + 8) +#define OP_UINT8BE (OP_READ_INT + 9) +#define OP_UINT16BE (OP_READ_INT + 10) +#define OP_UINT32BE (OP_READ_INT + 11) + + +#define OPERATION(operator, op1, op2) \ + (IS_UNDEFINED(op1) || IS_UNDEFINED(op2)) ? (UNDEFINED) : (op1 operator op2) + + +#define COMPARISON(operator, op1, op2) \ + (IS_UNDEFINED(op1) || IS_UNDEFINED(op2)) ? (0) : (op1 operator op2) + + +int yr_execute_code( + YR_RULES* rules, + YR_SCAN_CONTEXT* context, + int timeout, + time_t start_time); + +#endif diff --git a/x64_dbg_dbg/yara/yara/exefiles.h b/x64_dbg_dbg/yara/yara/exefiles.h new file mode 100644 index 00000000..c52cd932 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/exefiles.h @@ -0,0 +1,30 @@ +/* +Copyright (c) 2007. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_EXEFILES_H +#define YR_EXEFILES_H + +uint64_t yr_get_entry_point_offset( + uint8_t* buffer, + size_t buffer_length); + + +uint64_t yr_get_entry_point_address( + uint8_t* buffer, + size_t buffer_length, + size_t base_address); + +#endif diff --git a/x64_dbg_dbg/yara/yara/filemap.h b/x64_dbg_dbg/yara/yara/filemap.h new file mode 100644 index 00000000..a4198cd8 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/filemap.h @@ -0,0 +1,62 @@ +/* +Copyright (c) 2007-2015. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_FILEMAP_H +#define YR_FILEMAP_H + +#ifdef _WIN32 +#include +#define FILE_DESCRIPTOR HANDLE +#define off_t int64_t +#else +#include +#define FILE_DESCRIPTOR int +#endif + +#include +#include + +#include "utils.h" + + +typedef struct _YR_MAPPED_FILE +{ + FILE_DESCRIPTOR file; + size_t size; + uint8_t* data; + #ifdef _WIN32 + HANDLE mapping; + #endif + +} YR_MAPPED_FILE; + + +YR_API int yr_filemap_map( + const char* file_path, + YR_MAPPED_FILE* pmapped_file); + + +YR_API int yr_filemap_map_ex( + const char* file_path, + off_t offset, + size_t size, + YR_MAPPED_FILE* pmapped_file); + + +YR_API void yr_filemap_unmap( + YR_MAPPED_FILE* pmapped_file); + +#endif diff --git a/x64_dbg_dbg/yara/yara/globals.h b/x64_dbg_dbg/yara/yara/globals.h new file mode 100644 index 00000000..dfeb683d --- /dev/null +++ b/x64_dbg_dbg/yara/yara/globals.h @@ -0,0 +1,23 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_GLOBALS_H +#define YR_GLOBALS_H + +extern char lowercase[256]; +extern char altercase[256]; + +#endif diff --git a/x64_dbg_dbg/yara/yara/hash.h b/x64_dbg_dbg/yara/yara/hash.h new file mode 100644 index 00000000..3731b583 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/hash.h @@ -0,0 +1,66 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_HASH_H +#define YR_HASH_H + + +typedef struct _YR_HASH_TABLE_ENTRY +{ + char* key; + char* ns; + void* value; + + struct _YR_HASH_TABLE_ENTRY* next; + +} YR_HASH_TABLE_ENTRY; + + +typedef struct _YR_HASH_TABLE +{ + int size; + + YR_HASH_TABLE_ENTRY* buckets[1]; + +} YR_HASH_TABLE; + + +typedef int (*YR_HASH_TABLE_FREE_VALUE_FUNC)(void* value); + + +int yr_hash_table_create( + int size, + YR_HASH_TABLE** table); + + +void yr_hash_table_destroy( + YR_HASH_TABLE* table, + YR_HASH_TABLE_FREE_VALUE_FUNC free_value); + + +void* yr_hash_table_lookup( + YR_HASH_TABLE* table, + const char* key, + const char* ns); + + +int yr_hash_table_add( + YR_HASH_TABLE* table, + const char* key, + const char* ns, + void* value); + +#endif diff --git a/x64_dbg_dbg/yara/yara/hex_lexer.h b/x64_dbg_dbg/yara/yara/hex_lexer.h new file mode 100644 index 00000000..3be3d89c --- /dev/null +++ b/x64_dbg_dbg/yara/yara/hex_lexer.h @@ -0,0 +1,98 @@ +/* +Copyright (c) 2007. Victor M. Alvarez [plusvic@gmail.com]. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "re.h" + +#undef yyparse +#undef yylex +#undef yyerror +#undef yyfatal +#undef yychar +#undef yydebug +#undef yynerrs +#undef yyget_extra +#undef yyget_lineno + +#undef YY_FATAL_ERROR +#undef YY_DECL +#undef LEX_ENV + +#define yyparse hex_yyparse +#define yylex hex_yylex +#define yyerror hex_yyerror +#define yyfatal hex_yyfatal +#define yychar hex_yychar +#define yydebug hex_yydebug +#define yynerrs hex_yynerrs +#define yyget_extra hex_yyget_extra +#define yyget_lineno hex_yyget_lineno + + +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +#define YY_EXTRA_TYPE RE* +#define YY_USE_CONST + + +typedef struct _HEX_LEX_ENVIRONMENT +{ + int token_count; + int inside_or; + int last_error_code; + char last_error_message[256]; + +} HEX_LEX_ENVIRONMENT; + + +#define YY_FATAL_ERROR(msg) hex_yyfatal(yyscanner, msg) + +#define LEX_ENV ((HEX_LEX_ENVIRONMENT*) lex_env) + +#include + +#define YY_DECL int hex_yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner, HEX_LEX_ENVIRONMENT* lex_env) + + +YY_EXTRA_TYPE yyget_extra( + yyscan_t yyscanner); + +int yylex( + YYSTYPE* yylval_param, + yyscan_t yyscanner, + HEX_LEX_ENVIRONMENT* lex_env); + +int yyparse( + void *yyscanner, + HEX_LEX_ENVIRONMENT *lex_env); + +void yyerror( + yyscan_t yyscanner, + HEX_LEX_ENVIRONMENT* lex_env, + const char *error_message); + +void yyfatal( + yyscan_t yyscanner, + const char *error_message); + +int yr_parse_hex_string( + const char* hex_string, + int flags, + RE** re, + RE_ERROR* error); diff --git a/x64_dbg_dbg/yara/yara/lexer.h b/x64_dbg_dbg/yara/yara/lexer.h new file mode 100644 index 00000000..510b3e87 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/lexer.h @@ -0,0 +1,130 @@ +/* +Copyright (c) 2007. Victor M. Alvarez [plusvic@gmail.com]. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "compiler.h" + + +#undef yyparse +#undef yylex +#undef yyerror +#undef yyfatal +#undef yychar +#undef yydebug +#undef yynerrs +#undef yyget_extra +#undef yyget_lineno + +#undef YY_DECL +#undef YY_FATAL_ERROR +#undef YY_EXTRA_TYPE + +#define yyparse yara_yyparse +#define yylex yara_yylex +#define yyerror yara_yyerror +#define yyfatal yara_yyfatal +#define yywarning yara_yywarning +#define yychar yara_yychar +#define yydebug yara_yydebug +#define yynerrs yara_yynerrs +#define yyget_extra yara_yyget_extra +#define yyget_lineno yara_yyget_lineno + + +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +#ifndef YY_TYPEDEF_EXPRESSION_T +#define YY_TYPEDEF_EXPRESSION_T + + +// Expression type constants are powers of two because they are used as flags. +// For example: +// CHECK_TYPE(whatever, EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT) +// The expression above is used to ensure that the type of "whatever" is either +// integer or float. + +#define EXPRESSION_TYPE_BOOLEAN 1 +#define EXPRESSION_TYPE_INTEGER 2 +#define EXPRESSION_TYPE_STRING 4 +#define EXPRESSION_TYPE_REGEXP 8 +#define EXPRESSION_TYPE_OBJECT 16 +#define EXPRESSION_TYPE_FLOAT 32 + +typedef struct _EXPRESSION +{ + int type; + + union { + int64_t integer; + YR_OBJECT* object; + } value; + + const char* identifier; + +} EXPRESSION; + +union YYSTYPE; + +#endif + + +#define YY_DECL int yylex( \ + union YYSTYPE* yylval_param, yyscan_t yyscanner, YR_COMPILER* compiler) + + +#define YY_FATAL_ERROR(msg) yara_yyfatal(yyscanner, msg) + + +#define YY_EXTRA_TYPE YR_COMPILER* +#define YY_USE_CONST + + +int yyget_lineno(yyscan_t yyscanner); + +int yylex( + union YYSTYPE* yylval_param, + yyscan_t yyscanner, + YR_COMPILER* compiler); + +int yyparse( + void *yyscanner, + YR_COMPILER* compiler); + +void yyerror( + yyscan_t yyscanner, + YR_COMPILER* compiler, + const char *error_message); + +void yywarning( + yyscan_t yyscanner, + const char *warning_message); + +void yyfatal( + yyscan_t yyscanner, + const char *error_message); + +YY_EXTRA_TYPE yyget_extra( + yyscan_t yyscanner); + +int yr_lex_parse_rules_string( + const char* rules_string, + YR_COMPILER* compiler); + +int yr_lex_parse_rules_file( + FILE* rules_file, + YR_COMPILER* compiler); diff --git a/x64_dbg_dbg/yara/yara/libyara.h b/x64_dbg_dbg/yara/yara/libyara.h new file mode 100644 index 00000000..23a42906 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/libyara.h @@ -0,0 +1,49 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_LIBYARA_H +#define YR_LIBYARA_H + +#include "utils.h" + +#define YR_MAJOR_VERSION 3 +#define YR_MINOR_VERSION 3 +#define YR_MICRO_VERSION 0 + +// Version as a string +#define YR_VERSION "3.3.0" + +// Version as a single 4-byte hex number, e.g. 0x030401 == 3.4.1. +#define YR_VERSION_HEX ((YR_MAJOR_VERSION << 16) | \ + (YR_MINOR_VERSION << 8) | \ + (YR_MICRO_VERSION << 0) + + +YR_API int yr_initialize(void); + + +YR_API int yr_finalize(void); + + +YR_API void yr_finalize_thread(void); + + +YR_API int yr_get_tidx(void); + + +YR_API void yr_set_tidx(int); + +#endif diff --git a/x64_dbg_dbg/yara/yara/limits.h b/x64_dbg_dbg/yara/yara/limits.h new file mode 100644 index 00000000..62ba7d74 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/limits.h @@ -0,0 +1,48 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_LIMITS_H +#define YR_LIMITS_H + + +// MAX_THREADS is the number of threads that can use a YR_RULES +// object simultaneosly. This value is limited by the number of +// bits in tidx_mask. + +#define MAX_THREADS 32 + + +#ifndef MAX_PATH +#define MAX_PATH 1024 +#endif + +#define MAX_COMPILER_ERROR_EXTRA_INFO 256 +#define MAX_ATOM_LENGTH 4 +#define MAX_LOOP_NESTING 4 +#define MAX_ARENA_PAGES 32 +#define MAX_INCLUDE_DEPTH 16 +#define MAX_STRING_MATCHES 1000000 +#define MAX_FUNCTION_ARGS 128 +#define MAX_FAST_HEX_RE_STACK 300 +#define MAX_OVERLOADED_FUNCTIONS 10 +#define MAX_HEX_STRING_TOKENS 10000 + +#define LOOP_LOCAL_VARS 4 +#define STRING_CHAINING_THRESHOLD 200 +#define LEX_BUF_SIZE 1024 + + +#endif diff --git a/x64_dbg_dbg/yara/yara/mem.h b/x64_dbg_dbg/yara/yara/mem.h new file mode 100644 index 00000000..d794f445 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/mem.h @@ -0,0 +1,63 @@ +/* +Copyright (c) 2007. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_MEM_H +#define YR_MEM_H + +#include + +#include "config.h" + +#ifdef DMALLOC + +#define yr_malloc malloc +#define yr_calloc calloc +#define yr_realloc realloc +#define yr_free free +#define yr_strdup strdup +#define yr_strndup strndup + +#include + +#else + +void* yr_calloc( + size_t count, + size_t size); + +void* yr_malloc( + size_t size); + +void* yr_realloc( + void* ptr, + size_t size); + +void yr_free( + void *ptr); + +char* yr_strdup( + const char *str); + +char* yr_strndup( + const char *str, size_t n); + +#endif + +int yr_heap_alloc(); + +int yr_heap_free(); + +#endif diff --git a/x64_dbg_dbg/yara/yara/modules.h b/x64_dbg_dbg/yara/yara/modules.h new file mode 100644 index 00000000..5447c35a --- /dev/null +++ b/x64_dbg_dbg/yara/yara/modules.h @@ -0,0 +1,439 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_MODULES_H +#define YR_MODULES_H + +#include +#include +#include +#include + +#include "utils.h" +#include "limits.h" +#include "error.h" +#include "exec.h" +#include "types.h" +#include "object.h" +#include "libyara.h" + +// Concatenation that macro-expands its arguments. + +#define CONCAT(arg1, arg2) _CONCAT(arg1, arg2) // expands the arguments. +#define _CONCAT(arg1, arg2) arg1 ## arg2 // do the actual concatenation. + + +#define module_declarations CONCAT(MODULE_NAME, __declarations) +#define module_load CONCAT(MODULE_NAME, __load) +#define module_unload CONCAT(MODULE_NAME, __unload) +#define module_initialize CONCAT(MODULE_NAME, __initialize) +#define module_finalize CONCAT(MODULE_NAME, __finalize) + +#define begin_declarations \ + int module_declarations(YR_OBJECT* module) { \ + YR_OBJECT* stack[64]; \ + int stack_top = 0; \ + stack[stack_top] = module; + + +#define end_declarations \ + return ERROR_SUCCESS; } + + +#define begin_struct(name) { \ + YR_OBJECT* structure; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_STRUCTURE, \ + name, \ + stack[stack_top], \ + &structure)); \ + assertf( \ + stack_top < sizeof(stack)/sizeof(stack[0]) - 1, \ + "too many nested structures"); \ + stack[++stack_top] = structure; \ + } + + +#define begin_struct_array(name) { \ + YR_OBJECT* structure; \ + YR_OBJECT* array; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_ARRAY, \ + name, \ + stack[stack_top], \ + &array)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_STRUCTURE, \ + name, \ + array, \ + &structure)); \ + assertf( \ + stack_top < sizeof(stack)/sizeof(stack[0]) - 1, \ + "too many nested structures"); \ + stack[++stack_top] = structure; \ + } + + +#define begin_struct_dictionary(name) { \ + YR_OBJECT* structure; \ + YR_OBJECT* array; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_DICTIONARY, \ + name, \ + stack[stack_top], \ + &array)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_STRUCTURE, \ + name, \ + array, \ + &structure)); \ + assertf( \ + stack_top < sizeof(stack)/sizeof(stack[0]) - 1, \ + "too many nested structures"); \ + stack[++stack_top] = structure; \ + } + + +#define end_struct(name) { \ + assert(stack[stack_top]->type == OBJECT_TYPE_STRUCTURE); \ + assertf( \ + strcmp(stack[stack_top]->identifier, name) == 0, \ + "unbalanced begin_struct/end_struct"); \ + stack_top--; \ + } + + +#define end_struct_array(name) end_struct(name) + + +#define end_struct_dictionary(name) end_struct(name) + + +#define declare_integer(name) { \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_INTEGER, \ + name, \ + stack[stack_top], \ + NULL)); \ + } + + +#define declare_integer_array(name) { \ + YR_OBJECT* array; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_ARRAY, \ + name, \ + stack[stack_top], \ + &array)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_INTEGER, \ + name, \ + array, \ + NULL)); \ + } + + +#define declare_integer_dictionary(name) { \ + YR_OBJECT* dict; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_DICTIONARY, \ + name, \ + stack[stack_top], \ + &dict)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_INTEGER, \ + name, \ + dict, \ + NULL)); \ + } + + +#define declare_float(name) { \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_FLOAT, \ + name, \ + stack[stack_top], \ + NULL)); \ + } + + +#define declare_float_array(name) { \ + YR_OBJECT* array; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_ARRAY, \ + name, \ + stack[stack_top], \ + &array)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_FLOAT, \ + name, \ + array, \ + NULL)); \ + } + + +#define declare_float_dictionary(name) { \ + YR_OBJECT* dict; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_DICTIONARY, \ + name, \ + stack[stack_top], \ + &dict)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_FLOAT, \ + name, \ + dict, \ + NULL)); \ + } + + +#define declare_string(name) { \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_STRING, \ + name, \ + stack[stack_top], \ + NULL)); \ + } + + +#define declare_string_array(name) { \ + YR_OBJECT* array; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_ARRAY, \ + name, \ + stack[stack_top], \ + &array)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_STRING, \ + name, \ + array, \ + NULL)); \ + } + + +#define declare_string_dictionary(name) { \ + YR_OBJECT* dict; \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_DICTIONARY, \ + name, \ + stack[stack_top], \ + &dict)); \ + FAIL_ON_ERROR(yr_object_create( \ + OBJECT_TYPE_STRING, \ + name, \ + dict, \ + NULL)); \ + } + + +#define declare_function(name, args_fmt, ret_fmt, func) { \ + YR_OBJECT* function; \ + FAIL_ON_ERROR(yr_object_function_create( \ + name, \ + args_fmt, \ + ret_fmt, \ + func, \ + stack[stack_top], \ + &function)); \ + } + + +#define define_function(func) \ + int func ( \ + void* __args, \ + YR_SCAN_CONTEXT* __context, \ + YR_OBJECT_FUNCTION* __function_obj) + + +#define sized_string_argument(n) \ + ((SIZED_STRING*)(size_t)((int64_t*) __args)[n-1]) + +#define string_argument(n) \ + (sized_string_argument(n)->c_string) + +#define integer_argument(n) \ + (((int64_t*) __args)[n-1]) + +#define float_argument(n) \ + (((double*) __args)[n-1]) + +#define regexp_argument(n) \ + ((RE_CODE)((int64_t*) __args)[n-1]) + + +#define module() yr_object_get_root((YR_OBJECT*) __function_obj) +#define parent() (__function_obj->parent) +#define scan_context() (__context) + + +#define foreach_memory_block(context, block) \ + for (block = (context)->mem_block; \ + block != NULL; \ + block = block->next) \ + + +#define first_memory_block(context) \ + (context)->mem_block + + +#define is_undefined(object, ...) \ + yr_object_has_undefined_value(object, __VA_ARGS__) + + +#define get_object(object, ...) \ + yr_object_lookup(object, 0, __VA_ARGS__) + + +#define get_integer(object, ...) \ + yr_object_get_integer(object, __VA_ARGS__) + + +#define get_float(object, ...) \ + yr_object_get_float(object, __VA_ARGS__) + + +#define get_string(object, ...) \ + yr_object_get_string(object, __VA_ARGS__) + + +#define set_integer(value, object, ...) \ + yr_object_set_integer(value, object, __VA_ARGS__) + + +#define set_float(value, object, ...) \ + yr_object_set_float(value, object, __VA_ARGS__) + + +#define set_sized_string(value, len, object, ...) \ + yr_object_set_string(value, len, object, __VA_ARGS__) + + +#define set_string(value, object, ...) \ + set_sized_string(value, strlen(value), object, __VA_ARGS__) + + +#define return_integer(integer) { \ + assertf( \ + __function_obj->return_obj->type == OBJECT_TYPE_INTEGER, \ + "return type differs from function declaration"); \ + yr_object_set_integer( \ + (integer), \ + __function_obj->return_obj, \ + NULL); \ + return ERROR_SUCCESS; \ + } + + +#define return_float(double_) { \ + assertf( \ + __function_obj->return_obj->type == OBJECT_TYPE_FLOAT, \ + "return type differs from function declaration"); \ + double d = (double) (double_); \ + yr_object_set_float( \ + (d != (double) UNDEFINED) ? d : NAN, \ + __function_obj->return_obj, \ + NULL); \ + return ERROR_SUCCESS; \ + } + + +#define return_string(string) { \ + assertf( \ + __function_obj->return_obj->type == OBJECT_TYPE_STRING, \ + "return type differs from function declaration"); \ + char* s = (char*) (string); \ + yr_object_set_string( \ + (s != (char*) UNDEFINED) ? s : NULL, \ + (s != (char*) UNDEFINED) ? strlen(s) : 0, \ + __function_obj->return_obj, \ + NULL); \ + return ERROR_SUCCESS; \ + } + + +struct _YR_MODULE; + + +typedef int (*YR_EXT_INITIALIZE_FUNC)( + struct _YR_MODULE* module); + + +typedef int (*YR_EXT_FINALIZE_FUNC)( + struct _YR_MODULE* module); + + +typedef int (*YR_EXT_DECLARATIONS_FUNC)( + YR_OBJECT* module_object); + + +typedef int (*YR_EXT_LOAD_FUNC)( + YR_SCAN_CONTEXT* context, + YR_OBJECT* module_object, + void* module_data, + size_t module_data_size); + + +typedef int (*YR_EXT_UNLOAD_FUNC)( + YR_OBJECT* module_object); + + +typedef struct _YR_MODULE +{ + tidx_mask_t is_loaded; + + char* name; + + YR_EXT_DECLARATIONS_FUNC declarations; + YR_EXT_LOAD_FUNC load; + YR_EXT_UNLOAD_FUNC unload; + YR_EXT_INITIALIZE_FUNC initialize; + YR_EXT_FINALIZE_FUNC finalize; + +} YR_MODULE; + + +typedef struct _YR_MODULE_IMPORT +{ + const char* module_name; + void* module_data; + size_t module_data_size; + +} YR_MODULE_IMPORT; + + +int yr_modules_initialize(void); + + +int yr_modules_finalize(void); + + +int yr_modules_do_declarations( + const char* module_name, + YR_OBJECT* main_structure); + + +int yr_modules_load( + const char* module_name, + YR_SCAN_CONTEXT* context); + + +int yr_modules_unload_all( + YR_SCAN_CONTEXT* context); + + +void yr_modules_print_data( + YR_SCAN_CONTEXT* context); +#endif diff --git a/x64_dbg_dbg/yara/yara/object.h b/x64_dbg_dbg/yara/yara/object.h new file mode 100644 index 00000000..8d6e1521 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/object.h @@ -0,0 +1,156 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_OBJECT_H +#define YR_OBJECT_H + +#ifdef _MSC_VER +#include +#define isnan _isnan +#define INFINITY (DBL_MAX + DBL_MAX) +#define NAN (INFINITY-INFINITY) +#endif + +#include "types.h" + + +#define OBJECT_CREATE 1 + +#define OBJECT_TYPE_INTEGER 1 +#define OBJECT_TYPE_STRING 2 +#define OBJECT_TYPE_STRUCTURE 3 +#define OBJECT_TYPE_ARRAY 4 +#define OBJECT_TYPE_FUNCTION 5 +#define OBJECT_TYPE_REGEXP 6 +#define OBJECT_TYPE_DICTIONARY 7 +#define OBJECT_TYPE_FLOAT 8 + + +int yr_object_create( + int8_t type, + const char* identifier, + YR_OBJECT* parent, + YR_OBJECT** object); + + +int yr_object_function_create( + const char* identifier, + const char* arguments_fmt, + const char* return_fmt, + YR_MODULE_FUNC func, + YR_OBJECT* parent, + YR_OBJECT** function); + + +int yr_object_from_external_variable( + YR_EXTERNAL_VARIABLE* external, + YR_OBJECT** object); + + +void yr_object_destroy( + YR_OBJECT* object); + + +YR_OBJECT* yr_object_lookup_field( + YR_OBJECT* object, + const char* field_name); + + +YR_OBJECT* yr_object_lookup( + YR_OBJECT* root, + int flags, + const char* pattern, + ...); + + +int yr_object_has_undefined_value( + YR_OBJECT* object, + const char* field, + ...); + +int64_t yr_object_get_integer( + YR_OBJECT* object, + const char* field, + ...); + + +SIZED_STRING* yr_object_get_string( + YR_OBJECT* object, + const char* field, + ...); + + +int yr_object_set_integer( + int64_t value, + YR_OBJECT* object, + const char* field, + ...); + + +int yr_object_set_float( + double value, + YR_OBJECT* object, + const char* field, + ...); + + +int yr_object_set_string( + const char* value, + size_t len, + YR_OBJECT* object, + const char* field, + ...); + + +YR_OBJECT* yr_object_array_get_item( + YR_OBJECT* object, + int flags, + int index); + + +int yr_object_array_set_item( + YR_OBJECT* object, + YR_OBJECT* item, + int index); + + +YR_OBJECT* yr_object_dict_get_item( + YR_OBJECT* object, + int flags, + const char* key); + + +int yr_object_dict_set_item( + YR_OBJECT* object, + YR_OBJECT* item, + const char* key); + + +int yr_object_structure_set_member( + YR_OBJECT* object, + YR_OBJECT* member); + + +YR_OBJECT* yr_object_get_root( + YR_OBJECT* object); + + +void yr_object_print_data( + YR_OBJECT* object, + int indent); + + +#endif diff --git a/x64_dbg_dbg/yara/yara/parser.h b/x64_dbg_dbg/yara/yara/parser.h new file mode 100644 index 00000000..b5b3e65e --- /dev/null +++ b/x64_dbg_dbg/yara/yara/parser.h @@ -0,0 +1,120 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_PARSER_H +#define YR_PARSER_H + + +#include "lexer.h" + + +int yr_parser_emit( + yyscan_t yyscanner, + int8_t instruction, + int8_t** instruction_address); + + +int yr_parser_emit_with_arg( + yyscan_t yyscanner, + int8_t instruction, + int64_t argument, + int8_t** instruction_address); + + +int yr_parser_emit_with_arg_double( + yyscan_t yyscanner, + int8_t instruction, + double argument, + int8_t** instruction_address); + + +int yr_parser_emit_with_arg_reloc( + yyscan_t yyscanner, + int8_t instruction, + int64_t argument, + int8_t** instruction_address); + + +int yr_parser_check_types( + YR_COMPILER* compiler, + YR_OBJECT_FUNCTION* function, + const char* actual_args_fmt); + + +YR_STRING* yr_parser_lookup_string( + yyscan_t yyscanner, + const char* identifier); + + +int yr_parser_lookup_loop_variable( + yyscan_t yyscanner, + const char* identifier); + + +int yr_parser_reduce_rule_declaration( + yyscan_t yyscanner, + int flags, + const char* identifier, + char* tags, + YR_STRING* strings, + YR_META* metas); + + +YR_STRING* yr_parser_reduce_string_declaration( + yyscan_t yyscanner, + int flags, + const char* identifier, + SIZED_STRING* str); + + +YR_META* yr_parser_reduce_meta_declaration( + yyscan_t yyscanner, + int32_t type, + const char* identifier, + const char* string, + int32_t integer); + + +int yr_parser_reduce_string_identifier( + yyscan_t yyscanner, + const char* identifier, + int8_t instruction, + uint64_t at_offset); + + +int yr_parser_emit_pushes_for_strings( + yyscan_t yyscanner, + const char* identifier); + + +int yr_parser_reduce_external( + yyscan_t yyscanner, + const char* identifier, + int8_t intruction); + + +int yr_parser_reduce_import( + yyscan_t yyscanner, + SIZED_STRING* module_name); + + +int yr_parser_reduce_operation( + yyscan_t yyscanner, + const char* operation, + EXPRESSION left_operand, + EXPRESSION right_operand); + +#endif diff --git a/x64_dbg_dbg/yara/yara/pe.h b/x64_dbg_dbg/yara/yara/pe.h new file mode 100644 index 00000000..ca6d5871 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/pe.h @@ -0,0 +1,467 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#pragma pack(push, 1) + +#ifdef _WIN32 +#include + +// These definitions are not present in older Windows headers. + +#ifndef IMAGE_FILE_MACHINE_ARMNT +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 +#endif + +#ifndef IMAGE_FILE_MACHINE_ARM64 +#define IMAGE_FILE_MACHINE_ARM64 0xaa64 +#endif + +#else + +#include +#include + +typedef uint8_t BYTE; +typedef uint16_t WORD; +typedef uint32_t DWORD; +typedef int32_t LONG; +typedef uint32_t ULONG; +typedef uint64_t ULONGLONG; + + +#define FIELD_OFFSET(type, field) ((size_t)&(((type *)0)->field)) + +#ifndef _MAC + +#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ +#define IMAGE_OS2_SIGNATURE 0x454E // NE +#define IMAGE_OS2_SIGNATURE_LE 0x454C // LE +#define IMAGE_VXD_SIGNATURE 0x454C // LE +#define IMAGE_NT_SIGNATURE 0x00004550 // PE00 + +#else + +#define IMAGE_DOS_SIGNATURE 0x4D5A // MZ +#define IMAGE_OS2_SIGNATURE 0x4E45 // NE +#define IMAGE_OS2_SIGNATURE_LE 0x4C45 // LE +#define IMAGE_NT_SIGNATURE 0x50450000 // PE00 + +#endif + +#pragma pack(push, 2) + +typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header + WORD e_magic; // Magic number + WORD e_cblp; // Bytes on last page of file + WORD e_cp; // Pages in file + WORD e_crlc; // Relocations + WORD e_cparhdr; // Size of header in paragraphs + WORD e_minalloc; // Minimum extra paragraphs needed + WORD e_maxalloc; // Maximum extra paragraphs needed + WORD e_ss; // Initial (relative) SS value + WORD e_sp; // Initial SP value + WORD e_csum; // Checksum + WORD e_ip; // Initial IP value + WORD e_cs; // Initial (relative) CS value + WORD e_lfarlc; // File address of relocation table + WORD e_ovno; // Overlay number + WORD e_res[4]; // Reserved words + WORD e_oemid; // OEM identifier (for e_oeminfo) + WORD e_oeminfo; // OEM information; e_oemid specific + WORD e_res2[10]; // Reserved words + LONG e_lfanew; // File address of new exe header + } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; + +#pragma pack(pop) + +// +// File header format. +// + +#pragma pack(push,4) + +typedef struct _IMAGE_FILE_HEADER { + WORD Machine; + WORD NumberOfSections; + DWORD TimeDateStamp; + DWORD PointerToSymbolTable; + DWORD NumberOfSymbols; + WORD SizeOfOptionalHeader; + WORD Characteristics; +} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; + + + +#define IMAGE_SIZEOF_FILE_HEADER 20 + + +#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. +#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). +#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. +#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. +#define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010 // Agressively trim working set +#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 // App can handle >2gb addresses +#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. +#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. +#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file +#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 // If Image is on removable media, copy and run from the swap file. +#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800 // If Image is on Net, copy and run from the swap file. +#define IMAGE_FILE_SYSTEM 0x1000 // System File. +#define IMAGE_FILE_DLL 0x2000 // File is a DLL. +#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 // File should only be run on a UP machine +#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. + + +#define IMAGE_FILE_MACHINE_UNKNOWN 0x0000 +#define IMAGE_FILE_MACHINE_AM33 0x01d3 +#define IMAGE_FILE_MACHINE_AMD64 0x8664 +#define IMAGE_FILE_MACHINE_ARM 0x01c0 +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 +#define IMAGE_FILE_MACHINE_ARM64 0xaa64 +#define IMAGE_FILE_MACHINE_EBC 0x0ebc +#define IMAGE_FILE_MACHINE_I386 0x014c +#define IMAGE_FILE_MACHINE_IA64 0x0200 +#define IMAGE_FILE_MACHINE_M32R 0x9041 +#define IMAGE_FILE_MACHINE_MIPS16 0x0266 +#define IMAGE_FILE_MACHINE_MIPSFPU 0x0366 +#define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466 +#define IMAGE_FILE_MACHINE_POWERPC 0x01f0 +#define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1 +#define IMAGE_FILE_MACHINE_R4000 0x0166 +#define IMAGE_FILE_MACHINE_SH3 0x01a2 +#define IMAGE_FILE_MACHINE_SH3DSP 0x01a3 +#define IMAGE_FILE_MACHINE_SH4 0x01a6 +#define IMAGE_FILE_MACHINE_SH5 0x01a8 +#define IMAGE_FILE_MACHINE_THUMB 0x01c2 +#define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169 + +// Section characteristics +#define IMAGE_SCN_CNT_CODE 0x00000020 +#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 +#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 +#define IMAGE_SCN_GPREL 0x00008000 +#define IMAGE_SCN_MEM_16BIT 0x00020000 +#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 +#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 +#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 +#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 +#define IMAGE_SCN_MEM_SHARED 0x10000000 +#define IMAGE_SCN_MEM_EXECUTE 0x20000000 +#define IMAGE_SCN_MEM_READ 0x40000000 +#define IMAGE_SCN_MEM_WRITE 0x80000000 + +// +// Directory format. +// + +typedef struct _IMAGE_DATA_DIRECTORY { + DWORD VirtualAddress; + DWORD Size; +} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; + +#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 + + +#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory +#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory +#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory +#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory +#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory +#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table +#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory +#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // (X86 usage) +#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7 // Architecture Specific Data +#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // RVA of GP +#define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory +#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory +#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 // Bound Import Directory in headers +#define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address Table +#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13 // Delay Load Import Descriptors +#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14 // COM Runtime descriptor + + +// +// Optional header format. +// + +typedef struct _IMAGE_OPTIONAL_HEADER32 { + WORD Magic; + BYTE MajorLinkerVersion; + BYTE MinorLinkerVersion; + DWORD SizeOfCode; + DWORD SizeOfInitializedData; + DWORD SizeOfUninitializedData; + DWORD AddressOfEntryPoint; + DWORD BaseOfCode; + DWORD BaseOfData; + DWORD ImageBase; + DWORD SectionAlignment; + DWORD FileAlignment; + WORD MajorOperatingSystemVersion; + WORD MinorOperatingSystemVersion; + WORD MajorImageVersion; + WORD MinorImageVersion; + WORD MajorSubsystemVersion; + WORD MinorSubsystemVersion; + DWORD Win32VersionValue; + DWORD SizeOfImage; + DWORD SizeOfHeaders; + DWORD CheckSum; + WORD Subsystem; + WORD DllCharacteristics; + DWORD SizeOfStackReserve; + DWORD SizeOfStackCommit; + DWORD SizeOfHeapReserve; + DWORD SizeOfHeapCommit; + DWORD LoaderFlags; + DWORD NumberOfRvaAndSizes; + IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; + +} IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32; + + +typedef struct _IMAGE_OPTIONAL_HEADER64 { + WORD Magic; + BYTE MajorLinkerVersion; + BYTE MinorLinkerVersion; + DWORD SizeOfCode; + DWORD SizeOfInitializedData; + DWORD SizeOfUninitializedData; + DWORD AddressOfEntryPoint; + DWORD BaseOfCode; + ULONGLONG ImageBase; + DWORD SectionAlignment; + DWORD FileAlignment; + WORD MajorOperatingSystemVersion; + WORD MinorOperatingSystemVersion; + WORD MajorImageVersion; + WORD MinorImageVersion; + WORD MajorSubsystemVersion; + WORD MinorSubsystemVersion; + DWORD Win32VersionValue; + DWORD SizeOfImage; + DWORD SizeOfHeaders; + DWORD CheckSum; + WORD Subsystem; + WORD DllCharacteristics; + ULONGLONG SizeOfStackReserve; + ULONGLONG SizeOfStackCommit; + ULONGLONG SizeOfHeapReserve; + ULONGLONG SizeOfHeapCommit; + DWORD LoaderFlags; + DWORD NumberOfRvaAndSizes; + IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; + +} IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64; + + +#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b +#define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b + + +typedef struct _IMAGE_NT_HEADERS32 { + DWORD Signature; + IMAGE_FILE_HEADER FileHeader; + IMAGE_OPTIONAL_HEADER32 OptionalHeader; + +} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32; + + +typedef struct _IMAGE_NT_HEADERS64 { + DWORD Signature; + IMAGE_FILE_HEADER FileHeader; + IMAGE_OPTIONAL_HEADER64 OptionalHeader; + +} IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64; + + +// IMAGE_FIRST_SECTION doesn't need 32/64 versions since the file header is +// the same either way. + +#define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \ + ((BYTE*)ntheader + \ + FIELD_OFFSET( IMAGE_NT_HEADERS32, OptionalHeader ) + \ + ((PIMAGE_NT_HEADERS32)(ntheader))->FileHeader.SizeOfOptionalHeader \ + )) + +// Subsystem Values + +#define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem. +#define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem. +#define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem. +#define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image runs in the Posix character subsystem. +#define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 // image is a native Win9x driver. + +// +// Section header format. +// + +#define IMAGE_SIZEOF_SHORT_NAME 8 + +typedef struct _IMAGE_SECTION_HEADER { + BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; + union { + DWORD PhysicalAddress; + DWORD VirtualSize; + } Misc; + DWORD VirtualAddress; + DWORD SizeOfRawData; + DWORD PointerToRawData; + DWORD PointerToRelocations; + DWORD PointerToLinenumbers; + WORD NumberOfRelocations; + WORD NumberOfLinenumbers; + DWORD Characteristics; + +} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; + +#define IMAGE_SIZEOF_SECTION_HEADER 40 + + +typedef struct _IMAGE_EXPORT_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + DWORD Name; + DWORD Base; + DWORD NumberOfFunctions; + DWORD NumberOfNames; + DWORD AddressOfFunctions; + DWORD AddressOfNames; + DWORD AddressOfNameOrdinals; +} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; + + +typedef struct _IMAGE_IMPORT_DESCRIPTOR { + union { + DWORD Characteristics; + DWORD OriginalFirstThunk; + } ; + DWORD TimeDateStamp; + DWORD ForwarderChain; + DWORD Name; + DWORD FirstThunk; + +} IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR; + + +typedef struct _IMAGE_IMPORT_BY_NAME { + WORD Hint; + BYTE Name[1]; + +} IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; + +typedef struct _IMAGE_THUNK_DATA32 { + union { + DWORD ForwarderString; + DWORD Function; + DWORD Ordinal; + DWORD AddressOfData; + } u1; + +} IMAGE_THUNK_DATA32, *PIMAGE_THUNK_DATA32; + + +#define IMAGE_ORDINAL_FLAG32 0x80000000 +#define IMAGE_ORDINAL_FLAG64 0x8000000000000000L + +typedef struct _IMAGE_THUNK_DATA64 { + union { + ULONGLONG ForwarderString; + ULONGLONG Function; + ULONGLONG Ordinal; + ULONGLONG AddressOfData; + } u1; + +} IMAGE_THUNK_DATA64, *PIMAGE_THUNK_DATA64; + + +typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY { + DWORD Name; + DWORD OffsetToData; +} IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY; + + + typedef struct _IMAGE_RESOURCE_DATA_ENTRY { + DWORD OffsetToData; + DWORD Size; + DWORD CodePage; + DWORD Reserved; + } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY; + + +typedef struct _IMAGE_RESOURCE_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + WORD NumberOfNamedEntries; + WORD NumberOfIdEntries; +} IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY; + +#pragma pack(pop) + +#endif // _WIN32 + +typedef struct _VERSION_INFO { + WORD Length; + WORD ValueLength; + WORD Type; + char Key[0]; +} VERSION_INFO, *PVERSION_INFO; + + +#define WIN_CERT_REVISION_1_0 0x0100 +#define WIN_CERT_REVISION_2_0 0x0200 + +#define WIN_CERT_TYPE_X509 0x0001 +#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002 +#define WIN_CERT_TYPE_RESERVED_1 0x0003 +#define WIN_CERT_TYPE_TS_STACK_SIGNED 0x0004 + +typedef struct _WIN_CERTIFICATE { + DWORD Length; + WORD Revision; + WORD CertificateType; + BYTE Certificate[1]; +} WIN_CERTIFICATE, *PWIN_CERTIFICATE; + + +// +// Rich signature. +// http://www.ntcore.com/files/richsign.htm +// + +typedef struct _RICH_SIGNATURE { + DWORD dans; + DWORD key1; + DWORD key2; + DWORD key3; +} RICH_SIGNATURE, *PRICH_SIGNATURE; + +#define RICH_DANS 0x536e6144 // "DanS" +#define RICH_RICH 0x68636952 // "Rich" + +typedef struct _RICH_DATA { + size_t len; + BYTE* raw_data; + BYTE* clear_data; +} RICH_DATA, *PRICH_DATA; + +#pragma pack(pop) diff --git a/x64_dbg_dbg/yara/yara/proc.h b/x64_dbg_dbg/yara/yara/proc.h new file mode 100644 index 00000000..0e894261 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/proc.h @@ -0,0 +1,26 @@ +/* +Copyright (c) 2007. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_PROC_H +#define YR_PROC_H + +#include "types.h" + +int yr_process_get_memory( + int pid, + YR_MEMORY_BLOCK** first_block); + +#endif diff --git a/x64_dbg_dbg/yara/yara/re.h b/x64_dbg_dbg/yara/yara/re.h new file mode 100644 index 00000000..31b25f66 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/re.h @@ -0,0 +1,236 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_RE_H +#define YR_RE_H + +#include + +#include "arena.h" +#include "sizedstr.h" + +#define RE_NODE_LITERAL 1 +#define RE_NODE_MASKED_LITERAL 2 +#define RE_NODE_ANY 3 +#define RE_NODE_CONCAT 4 +#define RE_NODE_ALT 5 +#define RE_NODE_RANGE 6 +#define RE_NODE_STAR 7 +#define RE_NODE_PLUS 8 +#define RE_NODE_CLASS 9 +#define RE_NODE_WORD_CHAR 10 +#define RE_NODE_NON_WORD_CHAR 11 +#define RE_NODE_SPACE 12 +#define RE_NODE_NON_SPACE 13 +#define RE_NODE_DIGIT 14 +#define RE_NODE_NON_DIGIT 15 +#define RE_NODE_EMPTY 16 +#define RE_NODE_ANCHOR_START 17 +#define RE_NODE_ANCHOR_END 18 +#define RE_NODE_WORD_BOUNDARY 19 +#define RE_NODE_NON_WORD_BOUNDARY 20 + + +#define RE_OPCODE_ANY 0xA0 +#define RE_OPCODE_ANY_EXCEPT_NEW_LINE 0xA1 +#define RE_OPCODE_LITERAL 0xA2 +#define RE_OPCODE_LITERAL_NO_CASE 0xA3 +#define RE_OPCODE_MASKED_LITERAL 0xA4 +#define RE_OPCODE_CLASS 0xA5 +#define RE_OPCODE_CLASS_NO_CASE 0xA6 +#define RE_OPCODE_WORD_CHAR 0xA7 +#define RE_OPCODE_NON_WORD_CHAR 0xA8 +#define RE_OPCODE_SPACE 0xA9 +#define RE_OPCODE_NON_SPACE 0xAA +#define RE_OPCODE_DIGIT 0xAB +#define RE_OPCODE_NON_DIGIT 0xAC +#define RE_OPCODE_MATCH 0xAD + +#define RE_OPCODE_MATCH_AT_END 0xB0 +#define RE_OPCODE_MATCH_AT_START 0xB1 +#define RE_OPCODE_WORD_BOUNDARY 0xB2 +#define RE_OPCODE_NON_WORD_BOUNDARY 0xB3 + +#define RE_OPCODE_SPLIT_A 0xC0 +#define RE_OPCODE_SPLIT_B 0xC1 +#define RE_OPCODE_PUSH 0xC2 +#define RE_OPCODE_POP 0xC3 +#define RE_OPCODE_JNZ 0xC4 +#define RE_OPCODE_JUMP 0xC5 + + +#define RE_FLAGS_FAST_HEX_REGEXP 0x02 +#define RE_FLAGS_BACKWARDS 0x04 +#define RE_FLAGS_EXHAUSTIVE 0x08 +#define RE_FLAGS_WIDE 0x10 +#define RE_FLAGS_NO_CASE 0x20 +#define RE_FLAGS_SCAN 0x40 +#define RE_FLAGS_DOT_ALL 0x80 +#define RE_FLAGS_NOT_AT_START 0x100 + + +typedef struct RE RE; +typedef struct RE_NODE RE_NODE; +typedef struct RE_ERROR RE_ERROR; + +typedef uint8_t* RE_CODE; + +#define CHAR_IN_CLASS(chr, cls) \ + ((cls)[(chr) / 8] & 1 << ((chr) % 8)) + + +#define IS_WORD_CHAR(chr) \ + (isalnum(chr) || (chr) == '_') + + +struct RE_NODE +{ + int type; + + union { + int value; + int count; + int start; + }; + + union { + int mask; + int end; + }; + + int greedy; + + uint8_t* class_vector; + + RE_NODE* left; + RE_NODE* right; + + RE_CODE forward_code; + RE_CODE backward_code; +}; + + +struct RE { + + uint32_t flags; + RE_NODE* root_node; + YR_ARENA* code_arena; + RE_CODE code; +}; + + +struct RE_ERROR { + + char message[512]; + +}; + + +typedef int RE_MATCH_CALLBACK_FUNC( + uint8_t* match, + int match_length, + int flags, + void* args); + + +int yr_re_create( + RE** re); + + +int yr_re_parse( + const char* re_string, + int flags, + RE** re, + RE_ERROR* error); + + +int yr_re_parse_hex( + const char* hex_string, + int flags, + RE** re, + RE_ERROR* error); + + +int yr_re_compile( + const char* re_string, + int flags, + YR_ARENA* code_arena, + RE** re, + RE_ERROR* error); + + +void yr_re_destroy( + RE* re); + + +void yr_re_print( + RE* re); + + +RE_NODE* yr_re_node_create( + int type, + RE_NODE* left, + RE_NODE* right); + + +void yr_re_node_destroy( + RE_NODE* node); + + +SIZED_STRING* yr_re_extract_literal( + RE* re); + + +int yr_re_contains_dot_star( + RE* re); + + +int yr_re_split_at_chaining_point( + RE* re, + RE** result_re, + RE** remainder_re, + int32_t* min_gap, + int32_t* max_gap); + + +int yr_re_emit_code( + RE* re, + YR_ARENA* arena); + + +int yr_re_exec( + RE_CODE re_code, + uint8_t* input, + size_t input_size, + int flags, + RE_MATCH_CALLBACK_FUNC callback, + void* callback_args); + + +int yr_re_match( + RE_CODE re_code, + const char* target); + + +int yr_re_initialize(void); + + +int yr_re_finalize(void); + + +int yr_re_finalize_thread(void); + +#endif diff --git a/x64_dbg_dbg/yara/yara/re_lexer.h b/x64_dbg_dbg/yara/yara/re_lexer.h new file mode 100644 index 00000000..fb897714 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/re_lexer.h @@ -0,0 +1,97 @@ + /* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#undef yyparse +#undef yylex +#undef yyerror +#undef yyfatal +#undef yychar +#undef yydebug +#undef yynerrs +#undef yyget_extra +#undef yyget_lineno + +#undef YY_FATAL_ERROR +#undef YY_DECL +#undef LEX_ENV + + +#define yyparse re_yyparse +#define yylex re_yylex +#define yyerror re_yyerror +#define yyfatal re_yyfatal +#define yychar re_yychar +#define yydebug re_yydebug +#define yynerrs re_yynerrs +#define yyget_extra re_yyget_extra +#define yyget_lineno re_yyget_lineno + + +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +#define YY_EXTRA_TYPE RE* +#define YY_USE_CONST + + +typedef struct _RE_LEX_ENVIRONMENT +{ + int negated_class; + uint8_t class_vector[32]; + int last_error_code; + char last_error_message[256]; + +} RE_LEX_ENVIRONMENT; + + +#define LEX_ENV ((RE_LEX_ENVIRONMENT*) lex_env) + +#define YY_FATAL_ERROR(msg) re_yyfatal(yyscanner, msg) + +#include + +#define YY_DECL int re_yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner, RE_LEX_ENVIRONMENT* lex_env) + + +YY_EXTRA_TYPE yyget_extra( + yyscan_t yyscanner); + +int yylex( + YYSTYPE* yylval_param, + yyscan_t yyscanner, + RE_LEX_ENVIRONMENT* lex_env); + +int yyparse( + void *yyscanner, + RE_LEX_ENVIRONMENT *lex_env); + +void yyerror( + yyscan_t yyscanner, + RE_LEX_ENVIRONMENT* lex_env, + const char *error_message); + +void yyfatal( + yyscan_t yyscanner, + const char *error_message); + +int yr_parse_re_string( + const char* re_string, + int flags, + RE** re, + RE_ERROR* error); diff --git a/x64_dbg_dbg/yara/yara/rules.h b/x64_dbg_dbg/yara/yara/rules.h new file mode 100644 index 00000000..9bab0623 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/rules.h @@ -0,0 +1,127 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + +#ifndef YR_RULES_H +#define YR_RULES_H + +#include "types.h" +#include "utils.h" + + +#define CALLBACK_MSG_RULE_MATCHING 1 +#define CALLBACK_MSG_RULE_NOT_MATCHING 2 +#define CALLBACK_MSG_SCAN_FINISHED 3 +#define CALLBACK_MSG_IMPORT_MODULE 4 + +#define CALLBACK_CONTINUE 0 +#define CALLBACK_ABORT 1 +#define CALLBACK_ERROR 2 + + +#define yr_rule_tags_foreach(rule, tag_name) \ + for (tag_name = rule->tags; \ + tag_name != NULL && *tag_name != '\0'; \ + tag_name += strlen(tag_name) + 1) + + +#define yr_rule_metas_foreach(rule, meta) \ + for (meta = rule->metas; !META_IS_NULL(meta); meta++) + + +#define yr_rule_strings_foreach(rule, string) \ + for (string = rule->strings; !STRING_IS_NULL(string); string++) + + +#define yr_string_matches_foreach(string, match) \ + for (match = STRING_MATCHES(string).head; match != NULL; match = match->next) + + +#define yr_rules_foreach(rules, rule) \ + for (rule = rules->rules_list_head; !RULE_IS_NULL(rule); rule++) + + + +YR_API int yr_rules_scan_mem( + YR_RULES* rules, + uint8_t* buffer, + size_t buffer_size, + int flags, + YR_CALLBACK_FUNC callback, + void* user_data, + int timeout); + + +YR_API int yr_rules_scan_file( + YR_RULES* rules, + const char* filename, + int flags, + YR_CALLBACK_FUNC callback, + void* user_data, + int timeout); + + +YR_API int yr_rules_scan_proc( + YR_RULES* rules, + int pid, + int flags, + YR_CALLBACK_FUNC callback, + void* user_data, + int timeout); + + +YR_API int yr_rules_save( + YR_RULES* rules, + const char* filename); + + +YR_API int yr_rules_load( + const char* filename, + YR_RULES** rules); + + +YR_API int yr_rules_destroy( + YR_RULES* rules); + + +YR_API int yr_rules_define_integer_variable( + YR_RULES* rules, + const char* identifier, + int64_t value); + + +YR_API int yr_rules_define_boolean_variable( + YR_RULES* rules, + const char* identifier, + int value); + + +YR_API int yr_rules_define_float_variable( + YR_RULES* rules, + const char* identifier, + double value); + + +YR_API int yr_rules_define_string_variable( + YR_RULES* rules, + const char* identifier, + const char* value); + + +YR_API void yr_rules_print_profiling_info( + YR_RULES* rules); + +#endif diff --git a/x64_dbg_dbg/yara/yara/scan.h b/x64_dbg_dbg/yara/yara/scan.h new file mode 100644 index 00000000..ece9f766 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/scan.h @@ -0,0 +1,35 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_SCAN_H +#define YR_SCAN_H + +#include "types.h" + +#define SCAN_FLAGS_FAST_MODE 1 +#define SCAN_FLAGS_PROCESS_MEMORY 2 + + +int yr_scan_verify_match( + YR_AC_MATCH* ac_match, + uint8_t* data, + size_t data_size, + size_t data_base, + size_t offset, + YR_ARENA* matches_arena, + int flags); + +#endif diff --git a/x64_dbg_dbg/yara/yara/sizedstr.h b/x64_dbg_dbg/yara/yara/sizedstr.h new file mode 100644 index 00000000..df832e5a --- /dev/null +++ b/x64_dbg_dbg/yara/yara/sizedstr.h @@ -0,0 +1,42 @@ +/* +Copyright (c) 2007-2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef _SIZEDSTR_H +#define _SIZEDSTR_H + +// +// This struct is used to support strings containing null chars. The length of +// the string is stored along the string data. However the string data is also +// terminated with a null char. +// + +#define SIZED_STRING_FLAGS_NO_CASE 1 +#define SIZED_STRING_FLAGS_DOT_ALL 2 + +typedef struct _SIZED_STRING +{ + int length; + int flags; + char c_string[1]; + +} SIZED_STRING; + + +int sized_string_cmp( + SIZED_STRING* s1, + SIZED_STRING* s2); + +#endif diff --git a/x64_dbg_dbg/yara/yara/strutils.h b/x64_dbg_dbg/yara/yara/strutils.h new file mode 100644 index 00000000..3e38bc4e --- /dev/null +++ b/x64_dbg_dbg/yara/yara/strutils.h @@ -0,0 +1,77 @@ +/* +Copyright (c) 2007-2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_STRUTILS_H +#define YR_STRUTILS_H + +#include +#include +#include + +#include "config.h" + +#ifdef _WIN32 +#define snprintf _snprintf +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#endif + + +uint64_t xtoi( + const char* hexstr); + + +#if !HAVE_STRLCPY +size_t strlcpy( + char *dst, + const char *src, + size_t size); +#endif + + +#if !HAVE_STRLCAT +size_t strlcat( + char *dst, + const char *src, + size_t size); +#endif + + +#if !HAVE_MEMMEM +void* memmem( + const void *haystack, + size_t haystack_size, + const void *needle, + size_t needle_size); +#endif + + +int strlen_w( + const char* w_str); + + +int strcmp_w( + const char* w_str, + const char* str); + + +size_t strlcpy_w( + char* dst, + const char* w_src, + size_t n); + +#endif + diff --git a/x64_dbg_dbg/yara/yara/types.h b/x64_dbg_dbg/yara/yara/types.h new file mode 100644 index 00000000..2e902189 --- /dev/null +++ b/x64_dbg_dbg/yara/yara/types.h @@ -0,0 +1,519 @@ +/* +Copyright (c) 2013. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef YR_TYPES_H +#define YR_TYPES_H + + +#include "arena.h" +#include "re.h" +#include "limits.h" +#include "hash.h" + +#ifdef _WIN32 +#include +typedef HANDLE mutex_t; +#else +#include +typedef pthread_mutex_t mutex_t; +#endif + +typedef int32_t tidx_mask_t; + + +#define DECLARE_REFERENCE(type, name) \ + union { type name; int64_t name##_; } + +#pragma pack(push) +#pragma pack(1) + + +#define NAMESPACE_TFLAGS_UNSATISFIED_GLOBAL 0x01 + +#define NAMESPACE_HAS_UNSATISFIED_GLOBAL(x) \ + ((x)->t_flags[yr_get_tidx()] & NAMESPACE_TFLAGS_UNSATISFIED_GLOBAL) + + +typedef struct _YR_NAMESPACE +{ + int32_t t_flags[MAX_THREADS]; // Thread-specific flags + DECLARE_REFERENCE(char*, name); + +} YR_NAMESPACE; + + +#define META_TYPE_NULL 0 +#define META_TYPE_INTEGER 1 +#define META_TYPE_STRING 2 +#define META_TYPE_BOOLEAN 3 + +#define META_IS_NULL(x) \ + ((x) != NULL ? (x)->type == META_TYPE_NULL : TRUE) + + +typedef struct _YR_META +{ + int32_t type; + int32_t integer; + + DECLARE_REFERENCE(const char*, identifier); + DECLARE_REFERENCE(char*, string); + +} YR_META; + + +typedef struct _YR_MATCH +{ + int64_t base; + int64_t offset; + int32_t length; + + union { + uint8_t* data; // Confirmed matches use "data", + int32_t chain_length; // unconfirmed ones use "chain_length" + }; + + struct _YR_MATCH* prev; + struct _YR_MATCH* next; + +} YR_MATCH; + + +typedef struct _YR_MATCHES +{ + int32_t count; + + DECLARE_REFERENCE(YR_MATCH*, head); + DECLARE_REFERENCE(YR_MATCH*, tail); + +} YR_MATCHES; + + +#define STRING_GFLAGS_REFERENCED 0x01 +#define STRING_GFLAGS_HEXADECIMAL 0x02 +#define STRING_GFLAGS_NO_CASE 0x04 +#define STRING_GFLAGS_ASCII 0x08 +#define STRING_GFLAGS_WIDE 0x10 +#define STRING_GFLAGS_REGEXP 0x20 +#define STRING_GFLAGS_FAST_HEX_REGEXP 0x40 +#define STRING_GFLAGS_FULL_WORD 0x80 +#define STRING_GFLAGS_ANONYMOUS 0x100 +#define STRING_GFLAGS_SINGLE_MATCH 0x200 +#define STRING_GFLAGS_LITERAL 0x400 +#define STRING_GFLAGS_FITS_IN_ATOM 0x800 +#define STRING_GFLAGS_NULL 0x1000 +#define STRING_GFLAGS_CHAIN_PART 0x2000 +#define STRING_GFLAGS_CHAIN_TAIL 0x4000 +#define STRING_GFLAGS_FIXED_OFFSET 0x8000 + + +#define STRING_IS_HEX(x) \ + (((x)->g_flags) & STRING_GFLAGS_HEXADECIMAL) + +#define STRING_IS_NO_CASE(x) \ + (((x)->g_flags) & STRING_GFLAGS_NO_CASE) + +#define STRING_IS_ASCII(x) \ + (((x)->g_flags) & STRING_GFLAGS_ASCII) + +#define STRING_IS_WIDE(x) \ + (((x)->g_flags) & STRING_GFLAGS_WIDE) + +#define STRING_IS_REGEXP(x) \ + (((x)->g_flags) & STRING_GFLAGS_REGEXP) + +#define STRING_IS_FULL_WORD(x) \ + (((x)->g_flags) & STRING_GFLAGS_FULL_WORD) + +#define STRING_IS_ANONYMOUS(x) \ + (((x)->g_flags) & STRING_GFLAGS_ANONYMOUS) + +#define STRING_IS_REFERENCED(x) \ + (((x)->g_flags) & STRING_GFLAGS_REFERENCED) + +#define STRING_IS_SINGLE_MATCH(x) \ + (((x)->g_flags) & STRING_GFLAGS_SINGLE_MATCH) + +#define STRING_IS_FIXED_OFFSET(x) \ + (((x)->g_flags) & STRING_GFLAGS_FIXED_OFFSET) + +#define STRING_IS_LITERAL(x) \ + (((x)->g_flags) & STRING_GFLAGS_LITERAL) + +#define STRING_IS_FAST_HEX_REGEXP(x) \ + (((x)->g_flags) & STRING_GFLAGS_FAST_HEX_REGEXP) + +#define STRING_IS_CHAIN_PART(x) \ + (((x)->g_flags) & STRING_GFLAGS_CHAIN_PART) + +#define STRING_IS_CHAIN_TAIL(x) \ + (((x)->g_flags) & STRING_GFLAGS_CHAIN_TAIL) + +#define STRING_IS_NULL(x) \ + ((x) == NULL || ((x)->g_flags) & STRING_GFLAGS_NULL) + +#define STRING_FITS_IN_ATOM(x) \ + (((x)->g_flags) & STRING_GFLAGS_FITS_IN_ATOM) + +#define STRING_FOUND(x) \ + ((x)->matches[yr_get_tidx()].tail != NULL) + +#define STRING_MATCHES(x) \ + ((x)->matches[yr_get_tidx()]) + + +typedef struct _YR_STRING +{ + int32_t g_flags; + int32_t length; + + DECLARE_REFERENCE(char*, identifier); + DECLARE_REFERENCE(uint8_t*, string); + DECLARE_REFERENCE(struct _YR_STRING*, chained_to); + + int32_t chain_gap_min; + int32_t chain_gap_max; + + int64_t fixed_offset; + + YR_MATCHES matches[MAX_THREADS]; + YR_MATCHES unconfirmed_matches[MAX_THREADS]; + + #ifdef PROFILING_ENABLED + uint64_t clock_ticks; + #endif + +} YR_STRING; + + +#define RULE_TFLAGS_MATCH 0x01 + +#define RULE_GFLAGS_PRIVATE 0x01 +#define RULE_GFLAGS_GLOBAL 0x02 +#define RULE_GFLAGS_REQUIRE_EXECUTABLE 0x04 +#define RULE_GFLAGS_REQUIRE_FILE 0x08 +#define RULE_GFLAGS_NULL 0x1000 + +#define RULE_IS_PRIVATE(x) \ + (((x)->g_flags) & RULE_GFLAGS_PRIVATE) + +#define RULE_IS_GLOBAL(x) \ + (((x)->g_flags) & RULE_GFLAGS_GLOBAL) + +#define RULE_IS_NULL(x) \ + (((x)->g_flags) & RULE_GFLAGS_NULL) + +#define RULE_MATCHES(x) \ + ((x)->t_flags[yr_get_tidx()] & RULE_TFLAGS_MATCH) + + +typedef struct _YR_RULE +{ + int32_t g_flags; // Global flags + int32_t t_flags[MAX_THREADS]; // Thread-specific flags + + DECLARE_REFERENCE(const char*, identifier); + DECLARE_REFERENCE(const char*, tags); + DECLARE_REFERENCE(YR_META*, metas); + DECLARE_REFERENCE(YR_STRING*, strings); + DECLARE_REFERENCE(YR_NAMESPACE*, ns); + + #ifdef PROFILING_ENABLED + uint64_t clock_ticks; + #endif + +} YR_RULE; + + +#define EXTERNAL_VARIABLE_TYPE_NULL 0 +#define EXTERNAL_VARIABLE_TYPE_FLOAT 1 +#define EXTERNAL_VARIABLE_TYPE_INTEGER 2 +#define EXTERNAL_VARIABLE_TYPE_BOOLEAN 3 +#define EXTERNAL_VARIABLE_TYPE_STRING 4 +#define EXTERNAL_VARIABLE_TYPE_MALLOC_STRING 5 + + +#define EXTERNAL_VARIABLE_IS_NULL(x) \ + ((x) != NULL ? (x)->type == EXTERNAL_VARIABLE_TYPE_NULL : TRUE) + + +typedef struct _YR_EXTERNAL_VARIABLE +{ + int32_t type; + + union { + int64_t i; + double f; + char* s; + } value; + + DECLARE_REFERENCE(char*, identifier); + +} YR_EXTERNAL_VARIABLE; + + +typedef struct _YR_AC_MATCH +{ + uint16_t backtrack; + + DECLARE_REFERENCE(YR_STRING*, string); + DECLARE_REFERENCE(uint8_t*, forward_code); + DECLARE_REFERENCE(uint8_t*, backward_code); + DECLARE_REFERENCE(struct _YR_AC_MATCH*, next); + +} YR_AC_MATCH; + + +typedef struct _YR_AC_STATE +{ + int8_t depth; + + DECLARE_REFERENCE(struct _YR_AC_STATE*, failure); + DECLARE_REFERENCE(YR_AC_MATCH*, matches); + +} YR_AC_STATE; + + +typedef struct _YR_AC_STATE_TRANSITION +{ + uint8_t input; + + DECLARE_REFERENCE(YR_AC_STATE*, state); + DECLARE_REFERENCE(struct _YR_AC_STATE_TRANSITION*, next); + +} YR_AC_STATE_TRANSITION; + + +typedef struct _YR_AC_TABLE_BASED_STATE +{ + int8_t depth; + + DECLARE_REFERENCE(YR_AC_STATE*, failure); + DECLARE_REFERENCE(YR_AC_MATCH*, matches); + DECLARE_REFERENCE(YR_AC_STATE*, state) transitions[256]; + +} YR_AC_TABLE_BASED_STATE; + + +typedef struct _YR_AC_LIST_BASED_STATE +{ + int8_t depth; + + DECLARE_REFERENCE(YR_AC_STATE*, failure); + DECLARE_REFERENCE(YR_AC_MATCH*, matches); + DECLARE_REFERENCE(YR_AC_STATE_TRANSITION*, transitions); + +} YR_AC_LIST_BASED_STATE; + + +typedef struct _YR_AC_AUTOMATON +{ + DECLARE_REFERENCE(YR_AC_STATE*, root); + +} YR_AC_AUTOMATON; + + +typedef struct _YARA_RULES_FILE_HEADER +{ + uint32_t version; + + DECLARE_REFERENCE(YR_RULE*, rules_list_head); + DECLARE_REFERENCE(YR_EXTERNAL_VARIABLE*, externals_list_head); + DECLARE_REFERENCE(uint8_t*, code_start); + DECLARE_REFERENCE(YR_AC_AUTOMATON*, automaton); + +} YARA_RULES_FILE_HEADER; + + + +#pragma pack(pop) + + +typedef struct _YR_RULES { + + tidx_mask_t tidx_mask; + uint8_t* code_start; + + mutex_t mutex; + + YR_ARENA* arena; + YR_RULE* rules_list_head; + YR_EXTERNAL_VARIABLE* externals_list_head; + YR_AC_AUTOMATON* automaton; + +} YR_RULES; + + +typedef struct _YR_MEMORY_BLOCK +{ + uint8_t* data; + size_t size; + size_t base; + + struct _YR_MEMORY_BLOCK* next; + +} YR_MEMORY_BLOCK; + + +typedef int (*YR_CALLBACK_FUNC)( + int message, + void* message_data, + void* user_data); + + +typedef struct _YR_SCAN_CONTEXT +{ + uint64_t file_size; + uint64_t entry_point; + + int flags; + void* user_data; + + YR_MEMORY_BLOCK* mem_block; + YR_HASH_TABLE* objects_table; + YR_CALLBACK_FUNC callback; + +} YR_SCAN_CONTEXT; + + + +#define OBJECT_COMMON_FIELDS \ + int8_t type; \ + const char* identifier; \ + void* data; \ + struct _YR_OBJECT* parent; + + +typedef struct _YR_OBJECT +{ + OBJECT_COMMON_FIELDS + +} YR_OBJECT; + + +typedef struct _YR_OBJECT_INTEGER +{ + OBJECT_COMMON_FIELDS + int64_t value; + +} YR_OBJECT_INTEGER; + + +typedef struct _YR_OBJECT_DOUBLE +{ + OBJECT_COMMON_FIELDS + double value; + +} YR_OBJECT_DOUBLE; + + +typedef struct _YR_OBJECT_STRING +{ + OBJECT_COMMON_FIELDS + SIZED_STRING* value; + +} YR_OBJECT_STRING; + + +typedef struct _YR_OBJECT_REGEXP +{ + OBJECT_COMMON_FIELDS + RE* value; + +} YR_OBJECT_REGEXP; + + +typedef struct _YR_OBJECT_STRUCTURE +{ + OBJECT_COMMON_FIELDS + struct _YR_STRUCTURE_MEMBER* members; + +} YR_OBJECT_STRUCTURE; + + +typedef struct _YR_OBJECT_ARRAY +{ + OBJECT_COMMON_FIELDS + YR_OBJECT* prototype_item; + struct _YR_ARRAY_ITEMS* items; + +} YR_OBJECT_ARRAY; + + +typedef struct _YR_OBJECT_DICTIONARY +{ + OBJECT_COMMON_FIELDS + YR_OBJECT* prototype_item; + struct _YR_DICTIONARY_ITEMS* items; + +} YR_OBJECT_DICTIONARY; + + +struct _YR_OBJECT_FUNCTION; + + +typedef int (*YR_MODULE_FUNC)( + void* args, + YR_SCAN_CONTEXT* context, + struct _YR_OBJECT_FUNCTION* function_obj); + + +typedef struct _YR_OBJECT_FUNCTION +{ + OBJECT_COMMON_FIELDS + + YR_OBJECT* return_obj; + + struct { + const char* arguments_fmt; + YR_MODULE_FUNC code; + } prototypes[MAX_OVERLOADED_FUNCTIONS]; + +} YR_OBJECT_FUNCTION; + + +typedef struct _YR_STRUCTURE_MEMBER +{ + YR_OBJECT* object; + struct _YR_STRUCTURE_MEMBER* next; + +} YR_STRUCTURE_MEMBER; + + +typedef struct _YR_ARRAY_ITEMS +{ + int count; + YR_OBJECT* objects[1]; + +} YR_ARRAY_ITEMS; + + +typedef struct _YR_DICTIONARY_ITEMS +{ + int used; + int free; + + struct { + + char* key; + YR_OBJECT* obj; + + } objects[1]; + +} YR_DICTIONARY_ITEMS; + + +#endif diff --git a/x64_dbg_dbg/yara/yara/utils.h b/x64_dbg_dbg/yara/yara/utils.h new file mode 100644 index 00000000..6fe4e64d --- /dev/null +++ b/x64_dbg_dbg/yara/yara/utils.h @@ -0,0 +1,67 @@ +/* +Copyright (c) 2014. The YARA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + +#ifndef YR_UTILS_H +#define YR_UTILS_H + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifdef __cplusplus +#define YR_API extern "C" __declspec(dllimport) +#else +#define YR_API +#endif + +#ifndef min +#define min(x, y) ((x < y) ? (x) : (y)) +#endif + +#ifndef max +#define max(x, y) ((x > y) ? (x) : (y)) +#endif + + +#define PTR_TO_UINT64(x) ((uint64_t) (size_t) x) + + +#ifdef NDEBUG + +#define assertf(expr, msg) ((void)0) + +#else + +#include + +#define assertf(expr, msg, ...) \ + if(!(expr)) { \ + fprintf(stderr, "%s:%d: " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ + abort(); \ + } + +#endif + +#endif diff --git a/x64_dbg_dbg/yara/yara_x64.a b/x64_dbg_dbg/yara/yara_x64.a new file mode 100644 index 0000000000000000000000000000000000000000..3eb1a7dd1861df60ccd614492c032157689d2574 GIT binary patch literal 25114 zcmeI4UvDHw5y0EyyIf)}|1Qqm<#K`LxC>EqIJ;hZZ7T^FMTw3-ijDw+z@hQjyS5jv zcdgyM(_Mtn385%L2;Bn@hzA}J4}1p1L&T@Z2SA7qz;i-X_e^(9SBm)oCa&L63ghc=4#qeCX5wZWZWH2LubTMwzm&pw3-U33 z=Z_}7`<_x5zqfAU4{Azb{1H?W{I}NRH2*IKS|Dj4vB&tcDUb_orO%GX`$OQ?>A=q*vRnwYjldixNAcZ0Y^exMCUPj-A-y6y zKTXd|^78N^AhR<#Jc0|GZnl&3dfUm)fs>ZA>3P@~nr`7Fm*=0+84d@-_^>k?C3~dh z?d9;yyo_JM&fVd#(;w?*i;dyPI$N$3E=Nns`iSkQ_S`HdFD-Tr>10t*D2w%v!orxO zP@30I3d{23gpycaDJ+Xg($aRIQ;a1Arx{c>X}43`B%nkx{d4k`)+!Ls&{^$+-NATi zU?0;(&*w(H-fFdKwbivX^LVapEwn#`$0LN=96XWr(OI=L?%W^iXxZIFQZxhL|4r2pYHFrZANo`bD7npr^l_NSn))ik5U8lkTRE%ppv zMxFV*>08#f0h>j<8@R8_sWwp~5`CFG-4i)WGtJMAQ7$|7_ekr!!Y%g8dEGuw>Z1@Q z_w^G4#35+?s@?Ja-Tr||(NyGG8Y_7M-0Idf++zD;o4P>zzqw~dvKG#m#69*UrJmJW zvx!s<4swHR4_PF3RIk^Yb%X6Bd)aCo?BK$+fUn3m2#w8 z3amJAFSe9da{!*5+d|rh1pO(*;P-En!R=;~g zIjG;Va(W5w9fRYvZW8o1Qg6ausI|q_Z;k?L*8{0t*XlV_Isjdio>NJf$Z0rIb@g?i*pP2+1|B4 zikIoTlo=cR8ZE zZyO@@Ivg{4-4p>ayMS$eWb1fs1@c;r6?DrRZ0%fv>t_D)uSY=~{hoHhqR`#^Kf#Dm-wA8*ps6~HFnQ6VC`!uz%FQ+NEi&PV~&cYUX zqzcBfD;1;Iik`(}BY{b?1hX)D*=bFC1Wyg4g+9>&Mw@|*E^|9tjaIMQr~fRY)k}`i z%%xUpTlze9b_i~?debE6ZKO6}Z*6H-WA7cyCd*I#6mKgOoE!)pCw%L+`Qd{O5Dap<Y9RU8LTJtCR; z-HL8U_birsk?Gc3Qq6T^{a6JP4hV0nip~-%>MzEi) zS`~)4dSiwEiPk46t?6$7%l!PmsQWV=r;4k>GFsCblgGcII7^qUYpADfnLqt2zp$IH z#q}lAdLzzzyrR0x%q#x(3xj*Fdc`E@ZKTl6sYmISOF9T3i8867ezR)TxNh$v%R0-d z@h_m>?9WQ^M=ADq(xoOgaMie6b8Bb|vSo@x{bNn;ANwfaZEMS@T|ZY(a%ICw|6=Dd zFg~rlUC2?4lR0_~YN-jnqWe0vxpoKzIgxq`wzTiMT626!p2%)J)C1Py9<-CwkNd^LFJw73zxAOkXBATeolMK_6HJTwZ$p%M+;9!r1A`kkykipdHd5b*z0YvI z_A<+!jLdYX-)oJpi>%fwxbg2SUfsu;R{57o%FK1P!rXEFZjS4p3S9FRkl7aGWWGav zW=+m_HQsQ1_{+=an0Z9j(rsge2yY^klzYRxIOIWo7QzO;2d zFYyO>{!a2r9Fb@ANsf~XehtZ10OQ;W2D7ujLSti%-^p@ztbsOYT5ccnGzb&){F7-= zZkcWKSFv#+IF4_d1ig*a&tRYDSZoCeYgtgHJkMg9kA#p6{v%F14InL9Mhr(6L zY`X(jxLF6wq;ILpYclG=o`;9`)yHN^N&vNJ(|?g?3^Iaw7FjfnM{G O9`=E8`;Fm`n literal 0 HcmV?d00001 diff --git a/x64_dbg_dbg/yara/yara_x64.lib b/x64_dbg_dbg/yara/yara_x64.lib new file mode 100644 index 0000000000000000000000000000000000000000..46dc5f33ad8a2ae76b4d93517f71c0ab7c50529b GIT binary patch literal 8692 zcmb_hOK%iM5H4&3#*o;?@AulW1mr=$tQRar$Ph;g!hmIr#BCVwj_noeU2Au3g&YVc zP7y~=hyzEYAjBc!$caNvC?~`rKY(ArArkp|db)S|HQCvCrE*VKSNGS|UDZ|Hp8npi z=C>|(eV0*xXR~wX7jg^P`Ex4&OjJF)kc~d?bP>@dqV88jz3+(nI*5iIa~jzqVl)gM zqyF0wy+sKc{={kU2@#`#XPgEzsDp+^ISoI69B3fNY4kEtNH0)=Mm}&FUm;>Nc0ZzF zl%VNHoW?$)4w`t*Y5XsP&{OKX=PUfkaC?p3{f zWqYSs3aVZqsMV{Ldt~F8(zT%O<^57=-Ot}ux+o21zfIO}w^|L#b#DW>UfJIclmYA# z=16{_5RRa9mQ1@mG%S`kjUEx(?8D|#-7N(*rAvcr_9z4!#d6>k%k^Lri@N7mi~f2^ z)zBs59BsW)DFuExaWq55Iod|4;@1<$(j=TC@pVfaN*6K5VyhWctCgy^9n@<6rn**U zt2six8u)d!Tf~yG%+$919gk7)Guus#V@U3nAsZLu3`0(nVpStkUA9r!6s_4lhHi!WAbPttN-YoP+YYw9^-?8&H#`iuCVGRTAKNjtLu21!d}flG zXvngSx>K#>HQA7*%ldoqAz4k6z+n)Y9iK;7(rDx^~;FbFF+sAXJwq|{urV+=+QLM zN0iSeh+cy~hjMn3=p`ck66pOD(F|mEP zLI>$M^-wPjP(KY(AC1r`4bvFS&@^Rek|t=JrfBeg_HM_%q>b!ypJWVgF8rDO^y5+v z7@Y}jSJfq5?x@Qd0n(gQgzfar*pQGx=3)-Pjyf~ju*<12$SxDwzXivh^u$6;qfd;< zB9X)qd?U>8Xb=~4#0T?Sw?!P`!r@u(-d9D;wW*4bdq)*9=XMGyZ7(_7b}rQ{r&)L) zI}c49;f;0V12=Pms|TwLt~k`C2};M)nOt3VQcGD&y5e%Pc(+JK+Y5_?u@M#-eHT;_ zz6Eif-H~(&)rIudaKV+8P}~OM!UxQpN=w>e$ywwcVQ+S3@0c^7Calfw2D*T` z=t_UviYo$^Ox!wj01+0EmHkc^g7w|a*_*sZbP*rFiAq#1QqSen#e!e=XK_>J zKO_P4C+P2}-i~sS&b*1_a8u{ME)@TOgdF28Qszw?%5KDP_UjZ%ouIy+!(hA%*@R$E zRM|Uzt(dP?YL$(8=H%+B%<`4%SEF{NIEEUV1tVlD;a3m-9t^((1kjngW15w{C-nJq zTpohN=G8_*+eM;qrdxs&>cvqanJkk*Cz3Mr4G!ZY&5=JgIb(|AT%sQTlN>noIVB_xZt~axrYzLf=FkQkjn)Rr; z3*r^5;Zb;iN?fx9kD8B`C-g|>QSsj*Eeemy3O@7PzeFV}ncV)aZ8PhNB;WCdm3B?V z?IV+6?}^MS3lG^zg)0Dl9ZG0w1oY@Aq||8QNYv0Wz&c<-<1s?Q$d6_%CVL@rG7S%x zAXts6ok&4i)h#z~$NCmn?HZOdw-Ml}eIqB|i`9Mn8t5H%bUlE#j-8 z?pgZ^eJHhNq_LLdDcJ97yTV~=+yspWEV%Aam>SvP3#Xv*pat0(2Gd(pg1--`$XXCgt7A67 zZinMY{Lw%dPkN0Ka7N-d{5hg^oP?8QRKa2YZwX)V#FEJ<*K{_V5CO&vtndY;WxbN( o=(r6_zRd_op=Q(CC9LFxfyf_yTE=pC8jCuU9810?2|cLmUyzJ}jsO4v literal 0 HcmV?d00001 diff --git a/x64_dbg_dbg/yara/yara_x86.a b/x64_dbg_dbg/yara/yara_x86.a new file mode 100644 index 0000000000000000000000000000000000000000..f1d9971cd99f771f6899da5a0c58b0aec703f8d9 GIT binary patch literal 24986 zcmeI4&2Jn<7Qmm|4i4Ugj}S-*0fvz95rKDRY>yq3MHX5Rf`B4G2vFp9d!}vAW;|of zOrj)Ot*q5*#eqYP9QL&5J+1bPIPq7YJt7YL2?%(vs=KPX>h(;u1V$})Nmbob^}2eh z>Q}F;>Q(o1SEFHj_w|K8*0Qd#++4k~T3=dQuGQ)y$qZ|?#+8+pykc_!0M-HKzXw>@ z062L{`iK7mK>pMX=^sB2K>o}((x1BxK>q2|(m(rO0P+_;lm1d2fc#6xrN8_w0Qpz{ zCw=_`0P@Wrq+j_L0Qt3+^soINfc&36mwx>f{F~_CKzZ_S{#*LD_W{Vi`;PSQ{Rlw* z`nS@5_!R*8kH3`u(|Z8qZ(Nps<2!(j@51nIG>pP1?DnI*7{YKjjyg#kgm;JGC?1F7 zZs!grb@%pB+>F8>!&|+06pq?aKinS<+J=~ul9k?z_rk5-pnY@1Ut^{_SLR+K{;R5G1-G#(D_I$|o`klgO};}FHW{hjc3H0(xO z%%APVyqKL&w?B?|;^EYcTsb?ZZ7kAwYCg7(2J3ZX$5oTFsE+6JMKok?me?j z%t(~kammzCn2yyZatOz}LxkFB5hulvX2b+j1kzr#AKvO?m=Vgvi=1Q(NylctNwY{3 zva(E`;!Y^l9_;Po?PbqvN4?%w)V^uR=cJogQq2hXxyy`1`U9FO`@_f(XF6Skg+}!Syo1H7l zuy!n)$V{!;IPHPE$V#T;cILrsCdscfcajO~P)9w29JL5Xok+9-Lrzg_iHM&h$Hh||Q93U|>W}lHeol%rA0~IjvjfG^iS~u< z@$RkuO&KGofZu^zQM-~`s$Z&8?aY2J|Fc7~5Kft-BlRVmdx%g50X&B%*5Eulau>{w z>h=0kU4lDJQ?}~KM5soZa$el%4st=$BBI2sNs7Vg47`Hr*AsT=Q2XsPrP6FvBg=TR z&y4$m)~FdxxrQQFL}v4fCz;JPLz~L_I>0|Tjm%Gy z)}q51kVoj)e zz=@KrV@QPB#b%cQl0^%1*+cQV=E>_aE;b3LHR(UFeWvkx!)WKjC%?_6!|z|Q zO{ekukU`KGCixlU=*<%&+KNJ~pP z&;4mD07d9LtLYR5!J|Xx1fwWV=aMI#O;>kTqtc7&SzlySdPdWkTFOeTKWUspPV3J_ z86m;|uHsSa&$P()EK0|-&-kV%r(|}rX8&KH>X|lsGS?{&bM};@^_+E7S_>vOO^g1W zms6Zxz&w1P@lTkXvL@MbuUuUcHEME8^ZwKYfLn+%+_F{RVw@w!Qr+;S+MQ`tRBP=^ zYvR6CKkiWN>5`2zzqydZ7gtgsvrkzMvmp$*Xq@B*J>-SHP=P7 z^=XG|YmbU({qouwQoEPt`kf5dpKx4TRggoqBgHY@@U@qyzaBCd@Mv`1lm!YHl=HWSIx>1#Es_RmbD zv&jCLM~P0gdArBZ?)nvXXJcIqSN==Kh&Sh)kTYWZopee^F-r>AQc% zF17~MO<{TUwUSkul;c{BUyEqchfQ8f&Z(~^O=&cC9T-t8nZ6dX$_6o!%px|3ha{Qi z+ft?0qP{i=+D1Tcd`)?AjJ1_DylrLG4lV*UZ>Cg)(~~Br$*X#0e%kx);7U17-%eD! zx}5}8qxxFQ8m_ghvg+#fS9&_-uWCQHsPQ~)T4X=>ABa))UMIaEqTXLFHLJe+x%r~&nN(gnt7Cm_TuZKv z>i`>b+Kz;y^8O6Xe|>fALWW;jpb?6qIa8mmNaYX0(c8gNzW=ab+H+6%|wpc zx~~;$#kFF6?m_LQR8v5Q!`w&n7vsLh-d1NH&6t;SR;~WV%c)g>8kWzO+6NtKv!7@v z^C;nYtOs&>l<>BU5Mclx#;@=zK?NyJ9|*e&G*X*%9`(wQn>LLz*Y|5PBr8M&WN&v``Y2E(X?nG zOVcY2USu>q#}RJrM=i7VE3yJtDFojs{XQ+GSn zkk2AOk zq({@|kT>7i;!K8D<4dq5XO=9WIPB8CgL3Oy>bvALw`vN3u>t%ULx)>Y>>O&7G?Uq10Mh7p&;S4c literal 0 HcmV?d00001 diff --git a/x64_dbg_dbg/yara/yara_x86.lib b/x64_dbg_dbg/yara/yara_x86.lib new file mode 100644 index 0000000000000000000000000000000000000000..d0b35fbddf9c8db51140e0ab495e89d4b324ff0b GIT binary patch literal 8838 zcmb_hOK%iM5H8z190S4l{q~w51@dr=*)>?QkjX;|VtL3IiQ6#V9h(*FU2Au3gYq}+1iXCRTUyQh1nU&E~NNVU^lU0vUFcU4z)@7zk*C_TK| z_gzkZF6I|6FE1_UmkT<7A+9biEG&xRgFYgqlx>1rrr{9!Y4r$O+p8w zvpGRiHSj?*i-M+Ch&a8#8#J>oXznTzquiUA%6Nn3o(r1Aw{XJu%`!UACZ>Do*YuP!lx>B=k_TN|6!sL`l5g6*i;47ZFqb2QsJ zN{uLN86720Ni*}?4tD}Z(Jy>$O_n9QTZ6PF8gnd3Q;ye_RHasFRl;iJSMia_s*-^L zafzVy5W^|Qs0PoH*2EIN&K$E#yIYH8pr#s2z|hky!9BO5?O>x?FFg`lh8U04;_1m(Q16mh$3z3OR#RB; zT$*W&tLk8Q1Fi7z^qH4$_gNhK7oX)d>iz*v9i?}=APgFz>@MI7< z!5GoIag_0XJw&uJOw>YsWE8O&G5;CpDa!BBzK^z76X-ulbRX}xEQo`ip`L@{8p?|^ z&@oN)0<@3v)j6U!i0@_4bCloDLLcZn2x$p*Q8yi@UOG)D=p^;gDLO*O=yUpvj?w`2 z(-|73AsVGY8m9>wqe(hTbCjbQng;YNjeKJ79@s{wd4VGX$Qm`(8mrvF+E-Oeyji3; zuqo>GQB%;4tM-S*@P3C)D1{J9e{3aeCv@a1Zb2h#xrMkZxS%|#Qz9lMdL_6#cquH| zV8#WIn7g>`^Sz%4izr0e+TwB3+Zdpy&UdQ)s|GtX7 zJ~5|4d8V!2*nHbDIhmQa{nF%$f%6?*8M5@nq^#Eq9YW^PI7IAqaR^z9qRYf9l4N@P z%oH&^%xvbfuTP2YRp=lc#F3zxX<#zjlitHM7=8m@+hb5k`U56-FTly2Ed+PIjApbu>Uw1Oc{Gv=lb5j%}S|J zZ`LeVnZtzy)=OpT^BU3=gFjxsm5ONGwk`O>=TLC_^zV`=x_#nZUJbT!8 zb(0+JDiQzEhmym`#ZY=AC(mTSASF|1a~K~`pB#>LEaorA zw@J)8y18}y#lH$aNZef3flCOZm)zYlM2v&<)s1)h7ePUo_4F*ZN! zPQ<;j*u{1z931fU>S0R7d5JT_n(@roDI-7X!M3u5gQKfEdfkq{ z#mJ9&(9H})fp=_U1^JhN;YB!_^OLjl%38t6LgtxHS>;}HtnQpuLUz8&o{{46AGw6# zzYJSXh7XKekXybn!#Uvgxo~;nsD`HsS?9Rmv8OM9cf!Qe(swn)j;$!~!Nf%oZf(Te zCJzRmfON&ZPq3?|Q#KMiawsra$U2iM!7)}2*IBrM(nlrEG7_Ql=#uwX$q2AcE3EjG zq+nzr^N3O+O22_3@5Lp?;g0D{jHV8D3Pu((kIA#A;6f5NgkqHvCq}7WnMGEdB~SeS z8aRV7jywgrkD>~?WB*$6 Date: Thu, 2 Apr 2015 13:56:16 +0200 Subject: [PATCH 099/106] DBG: formatting in Yara headers --- x64_dbg_dbg/yara/yara/arena.h | 26 +-- x64_dbg_dbg/yara/yara/atoms.h | 34 ++-- x64_dbg_dbg/yara/yara/compiler.h | 82 +++++----- x64_dbg_dbg/yara/yara/elf.h | 140 ++++++++-------- x64_dbg_dbg/yara/yara/filemap.h | 12 +- x64_dbg_dbg/yara/yara/hash.h | 12 +- x64_dbg_dbg/yara/yara/hex_lexer.h | 24 +-- x64_dbg_dbg/yara/yara/lexer.h | 21 +-- x64_dbg_dbg/yara/yara/mem.h | 6 +- x64_dbg_dbg/yara/yara/modules.h | 22 +-- x64_dbg_dbg/yara/yara/parser.h | 4 +- x64_dbg_dbg/yara/yara/pe.h | 104 +++++++----- x64_dbg_dbg/yara/yara/re.h | 52 +++--- x64_dbg_dbg/yara/yara/re_lexer.h | 28 ++-- x64_dbg_dbg/yara/yara/sizedstr.h | 10 +- x64_dbg_dbg/yara/yara/strutils.h | 12 +- x64_dbg_dbg/yara/yara/types.h | 255 +++++++++++++++--------------- 17 files changed, 439 insertions(+), 405 deletions(-) diff --git a/x64_dbg_dbg/yara/yara/arena.h b/x64_dbg_dbg/yara/yara/arena.h index a6ede1e0..acc7d6f4 100644 --- a/x64_dbg_dbg/yara/yara/arena.h +++ b/x64_dbg_dbg/yara/yara/arena.h @@ -30,8 +30,8 @@ limitations under the License. typedef struct _YR_RELOC { - int32_t offset; - struct _YR_RELOC* next; + int32_t offset; + struct _YR_RELOC* next; } YR_RELOC; @@ -39,27 +39,27 @@ typedef struct _YR_RELOC typedef struct _YR_ARENA_PAGE { - uint8_t* new_address; - uint8_t* address; + uint8_t* new_address; + uint8_t* address; - size_t size; - size_t used; + size_t size; + size_t used; - YR_RELOC* reloc_list_head; - YR_RELOC* reloc_list_tail; + YR_RELOC* reloc_list_head; + YR_RELOC* reloc_list_tail; - struct _YR_ARENA_PAGE* next; - struct _YR_ARENA_PAGE* prev; + struct _YR_ARENA_PAGE* next; + struct _YR_ARENA_PAGE* prev; } YR_ARENA_PAGE; typedef struct _YR_ARENA { - int flags; + int flags; - YR_ARENA_PAGE* page_list_head; - YR_ARENA_PAGE* current_page; + YR_ARENA_PAGE* page_list_head; + YR_ARENA_PAGE* current_page; } YR_ARENA; diff --git a/x64_dbg_dbg/yara/yara/atoms.h b/x64_dbg_dbg/yara/yara/atoms.h index 859e4f13..f0625cec 100644 --- a/x64_dbg_dbg/yara/yara/atoms.h +++ b/x64_dbg_dbg/yara/yara/atoms.h @@ -27,41 +27,41 @@ limitations under the License. typedef struct _ATOM_TREE_NODE { - uint8_t type; - uint8_t atom_length; - uint8_t atom[MAX_ATOM_LENGTH]; + uint8_t type; + uint8_t atom_length; + uint8_t atom[MAX_ATOM_LENGTH]; - uint8_t* forward_code; - uint8_t* backward_code; + uint8_t* forward_code; + uint8_t* backward_code; - RE_NODE* recent_nodes[MAX_ATOM_LENGTH]; + RE_NODE* recent_nodes[MAX_ATOM_LENGTH]; - struct _ATOM_TREE_NODE* children_head; - struct _ATOM_TREE_NODE* children_tail; - struct _ATOM_TREE_NODE* next_sibling; + struct _ATOM_TREE_NODE* children_head; + struct _ATOM_TREE_NODE* children_tail; + struct _ATOM_TREE_NODE* next_sibling; } ATOM_TREE_NODE; typedef struct _ATOM_TREE { - ATOM_TREE_NODE* current_leaf; - ATOM_TREE_NODE* root_node; + ATOM_TREE_NODE* current_leaf; + ATOM_TREE_NODE* root_node; } ATOM_TREE; typedef struct _YR_ATOM_LIST_ITEM { - uint8_t atom_length; - uint8_t atom[MAX_ATOM_LENGTH]; + uint8_t atom_length; + uint8_t atom[MAX_ATOM_LENGTH]; - uint16_t backtrack; + uint16_t backtrack; - uint8_t* forward_code; - uint8_t* backward_code; + uint8_t* forward_code; + uint8_t* backward_code; - struct _YR_ATOM_LIST_ITEM* next; + struct _YR_ATOM_LIST_ITEM* next; } YR_ATOM_LIST_ITEM; diff --git a/x64_dbg_dbg/yara/yara/compiler.h b/x64_dbg_dbg/yara/yara/compiler.h index 232a9782..e7d29f09 100644 --- a/x64_dbg_dbg/yara/yara/compiler.h +++ b/x64_dbg_dbg/yara/yara/compiler.h @@ -40,57 +40,57 @@ typedef void (*YR_COMPILER_CALLBACK_FUNC)( typedef struct _YR_COMPILER { - int errors; - int error_line; - int last_error; - int last_error_line; - int last_result; + int errors; + int error_line; + int last_error; + int last_error_line; + int last_result; - jmp_buf error_recovery; + jmp_buf error_recovery; - YR_ARENA* sz_arena; - YR_ARENA* rules_arena; - YR_ARENA* strings_arena; - YR_ARENA* code_arena; - YR_ARENA* re_code_arena; - YR_ARENA* automaton_arena; - YR_ARENA* compiled_rules_arena; - YR_ARENA* externals_arena; - YR_ARENA* namespaces_arena; - YR_ARENA* metas_arena; + YR_ARENA* sz_arena; + YR_ARENA* rules_arena; + YR_ARENA* strings_arena; + YR_ARENA* code_arena; + YR_ARENA* re_code_arena; + YR_ARENA* automaton_arena; + YR_ARENA* compiled_rules_arena; + YR_ARENA* externals_arena; + YR_ARENA* namespaces_arena; + YR_ARENA* metas_arena; - YR_AC_AUTOMATON* automaton; - YR_HASH_TABLE* rules_table; - YR_HASH_TABLE* objects_table; - YR_NAMESPACE* current_namespace; - YR_STRING* current_rule_strings; + YR_AC_AUTOMATON* automaton; + YR_HASH_TABLE* rules_table; + YR_HASH_TABLE* objects_table; + YR_NAMESPACE* current_namespace; + YR_STRING* current_rule_strings; - int current_rule_flags; - int namespaces_count; + int current_rule_flags; + int namespaces_count; - int8_t* loop_address[MAX_LOOP_NESTING]; - char* loop_identifier[MAX_LOOP_NESTING]; - int loop_depth; - int loop_for_of_mem_offset; + int8_t* loop_address[MAX_LOOP_NESTING]; + char* loop_identifier[MAX_LOOP_NESTING]; + int loop_depth; + int loop_for_of_mem_offset; - int allow_includes; + int allow_includes; - char* file_name_stack[MAX_INCLUDE_DEPTH]; - int file_name_stack_ptr; + char* file_name_stack[MAX_INCLUDE_DEPTH]; + int file_name_stack_ptr; - FILE* file_stack[MAX_INCLUDE_DEPTH]; - int file_stack_ptr; + FILE* file_stack[MAX_INCLUDE_DEPTH]; + int file_stack_ptr; - char last_error_extra_info[MAX_COMPILER_ERROR_EXTRA_INFO]; + char last_error_extra_info[MAX_COMPILER_ERROR_EXTRA_INFO]; - char lex_buf[LEX_BUF_SIZE]; - char* lex_buf_ptr; - unsigned short lex_buf_len; + char lex_buf[LEX_BUF_SIZE]; + char* lex_buf_ptr; + unsigned short lex_buf_len; - char include_base_dir[MAX_PATH]; - void* user_data; + char include_base_dir[MAX_PATH]; + void* user_data; - YR_COMPILER_CALLBACK_FUNC callback; + YR_COMPILER_CALLBACK_FUNC callback; } YR_COMPILER; @@ -100,14 +100,14 @@ typedef struct _YR_COMPILER compiler->last_error_extra_info, \ info, \ sizeof(compiler->last_error_extra_info)); \ - + #define yr_compiler_set_error_extra_info_fmt(compiler, fmt, ...) \ snprintf( \ compiler->last_error_extra_info, \ sizeof(compiler->last_error_extra_info), \ fmt, __VA_ARGS__); - + int _yr_compiler_push_file( YR_COMPILER* compiler, diff --git a/x64_dbg_dbg/yara/yara/elf.h b/x64_dbg_dbg/yara/yara/elf.h index 5f386589..5f6515ea 100644 --- a/x64_dbg_dbg/yara/yara/elf.h +++ b/x64_dbg_dbg/yara/yara/elf.h @@ -87,112 +87,112 @@ typedef uint64_t elf64_xword_t; typedef struct { - uint32_t magic; - uint8_t _class; - uint8_t data; - uint8_t version; - uint8_t pad[8]; - uint8_t nident; + uint32_t magic; + uint8_t _class; + uint8_t data; + uint8_t version; + uint8_t pad[8]; + uint8_t nident; } elf_ident_t; typedef struct { - elf_ident_t ident; - elf32_half_t type; - elf32_half_t machine; - elf32_word_t version; - elf32_addr_t entry; - elf32_off_t ph_offset; - elf32_off_t sh_offset; - elf32_word_t flags; - elf32_half_t header_size; - elf32_half_t ph_entry_size; - elf32_half_t ph_entry_count; - elf32_half_t sh_entry_size; - elf32_half_t sh_entry_count; - elf32_half_t sh_str_table_index; + elf_ident_t ident; + elf32_half_t type; + elf32_half_t machine; + elf32_word_t version; + elf32_addr_t entry; + elf32_off_t ph_offset; + elf32_off_t sh_offset; + elf32_word_t flags; + elf32_half_t header_size; + elf32_half_t ph_entry_size; + elf32_half_t ph_entry_count; + elf32_half_t sh_entry_size; + elf32_half_t sh_entry_count; + elf32_half_t sh_str_table_index; } elf32_header_t; typedef struct { - elf_ident_t ident; - elf64_half_t type; - elf64_half_t machine; - elf64_word_t version; - elf64_addr_t entry; - elf64_off_t ph_offset; - elf64_off_t sh_offset; - elf64_word_t flags; - elf64_half_t header_size; - elf64_half_t ph_entry_size; - elf64_half_t ph_entry_count; - elf64_half_t sh_entry_size; - elf64_half_t sh_entry_count; - elf64_half_t sh_str_table_index; + elf_ident_t ident; + elf64_half_t type; + elf64_half_t machine; + elf64_word_t version; + elf64_addr_t entry; + elf64_off_t ph_offset; + elf64_off_t sh_offset; + elf64_word_t flags; + elf64_half_t header_size; + elf64_half_t ph_entry_size; + elf64_half_t ph_entry_count; + elf64_half_t sh_entry_size; + elf64_half_t sh_entry_count; + elf64_half_t sh_str_table_index; } elf64_header_t; typedef struct { - elf32_word_t type; - elf32_off_t offset; - elf32_addr_t virt_addr; - elf32_addr_t phys_addr; - elf32_word_t file_size; - elf32_word_t mem_size; - elf32_word_t flags; - elf32_word_t alignment; + elf32_word_t type; + elf32_off_t offset; + elf32_addr_t virt_addr; + elf32_addr_t phys_addr; + elf32_word_t file_size; + elf32_word_t mem_size; + elf32_word_t flags; + elf32_word_t alignment; } elf32_program_header_t; typedef struct { - elf64_word_t type; - elf64_word_t flags; - elf64_off_t offset; - elf64_addr_t virt_addr; - elf64_addr_t phys_addr; - elf64_xword_t file_size; - elf64_xword_t mem_size; - elf64_xword_t alignment; + elf64_word_t type; + elf64_word_t flags; + elf64_off_t offset; + elf64_addr_t virt_addr; + elf64_addr_t phys_addr; + elf64_xword_t file_size; + elf64_xword_t mem_size; + elf64_xword_t alignment; } elf64_program_header_t; typedef struct { - elf32_word_t name; - elf32_word_t type; - elf32_word_t flags; - elf32_addr_t addr; - elf32_off_t offset; - elf32_word_t size; - elf32_word_t link; - elf32_word_t info; - elf32_word_t align; - elf32_word_t entry_size; + elf32_word_t name; + elf32_word_t type; + elf32_word_t flags; + elf32_addr_t addr; + elf32_off_t offset; + elf32_word_t size; + elf32_word_t link; + elf32_word_t info; + elf32_word_t align; + elf32_word_t entry_size; } elf32_section_header_t; typedef struct { - elf64_word_t name; - elf64_word_t type; - elf64_xword_t flags; - elf64_addr_t addr; - elf64_off_t offset; - elf64_xword_t size; - elf64_word_t link; - elf64_word_t info; - elf64_xword_t align; - elf64_xword_t entry_size; + elf64_word_t name; + elf64_word_t type; + elf64_xword_t flags; + elf64_addr_t addr; + elf64_off_t offset; + elf64_xword_t size; + elf64_word_t link; + elf64_word_t info; + elf64_xword_t align; + elf64_xword_t entry_size; } elf64_section_header_t; diff --git a/x64_dbg_dbg/yara/yara/filemap.h b/x64_dbg_dbg/yara/yara/filemap.h index a4198cd8..7ea4318b 100644 --- a/x64_dbg_dbg/yara/yara/filemap.h +++ b/x64_dbg_dbg/yara/yara/filemap.h @@ -34,12 +34,12 @@ limitations under the License. typedef struct _YR_MAPPED_FILE { - FILE_DESCRIPTOR file; - size_t size; - uint8_t* data; - #ifdef _WIN32 - HANDLE mapping; - #endif + FILE_DESCRIPTOR file; + size_t size; + uint8_t* data; +#ifdef _WIN32 + HANDLE mapping; +#endif } YR_MAPPED_FILE; diff --git a/x64_dbg_dbg/yara/yara/hash.h b/x64_dbg_dbg/yara/yara/hash.h index 3731b583..957afa09 100644 --- a/x64_dbg_dbg/yara/yara/hash.h +++ b/x64_dbg_dbg/yara/yara/hash.h @@ -20,20 +20,20 @@ limitations under the License. typedef struct _YR_HASH_TABLE_ENTRY { - char* key; - char* ns; - void* value; + char* key; + char* ns; + void* value; - struct _YR_HASH_TABLE_ENTRY* next; + struct _YR_HASH_TABLE_ENTRY* next; } YR_HASH_TABLE_ENTRY; typedef struct _YR_HASH_TABLE { - int size; + int size; - YR_HASH_TABLE_ENTRY* buckets[1]; + YR_HASH_TABLE_ENTRY* buckets[1]; } YR_HASH_TABLE; diff --git a/x64_dbg_dbg/yara/yara/hex_lexer.h b/x64_dbg_dbg/yara/yara/hex_lexer.h index 3be3d89c..27f1e332 100644 --- a/x64_dbg_dbg/yara/yara/hex_lexer.h +++ b/x64_dbg_dbg/yara/yara/hex_lexer.h @@ -52,10 +52,10 @@ typedef void* yyscan_t; typedef struct _HEX_LEX_ENVIRONMENT { - int token_count; - int inside_or; - int last_error_code; - char last_error_message[256]; + int token_count; + int inside_or; + int last_error_code; + char last_error_message[256]; } HEX_LEX_ENVIRONMENT; @@ -79,20 +79,20 @@ int yylex( HEX_LEX_ENVIRONMENT* lex_env); int yyparse( - void *yyscanner, - HEX_LEX_ENVIRONMENT *lex_env); + void* yyscanner, + HEX_LEX_ENVIRONMENT* lex_env); void yyerror( yyscan_t yyscanner, HEX_LEX_ENVIRONMENT* lex_env, - const char *error_message); + const char* error_message); void yyfatal( yyscan_t yyscanner, - const char *error_message); + const char* error_message); int yr_parse_hex_string( - const char* hex_string, - int flags, - RE** re, - RE_ERROR* error); + const char* hex_string, + int flags, + RE** re, + RE_ERROR* error); diff --git a/x64_dbg_dbg/yara/yara/lexer.h b/x64_dbg_dbg/yara/yara/lexer.h index 510b3e87..9e440327 100644 --- a/x64_dbg_dbg/yara/yara/lexer.h +++ b/x64_dbg_dbg/yara/yara/lexer.h @@ -67,14 +67,15 @@ typedef void* yyscan_t; typedef struct _EXPRESSION { - int type; + int type; - union { - int64_t integer; - YR_OBJECT* object; - } value; + union + { + int64_t integer; + YR_OBJECT* object; + } value; - const char* identifier; + const char* identifier; } EXPRESSION; @@ -102,21 +103,21 @@ int yylex( YR_COMPILER* compiler); int yyparse( - void *yyscanner, + void* yyscanner, YR_COMPILER* compiler); void yyerror( yyscan_t yyscanner, YR_COMPILER* compiler, - const char *error_message); + const char* error_message); void yywarning( yyscan_t yyscanner, - const char *warning_message); + const char* warning_message); void yyfatal( yyscan_t yyscanner, - const char *error_message); + const char* error_message); YY_EXTRA_TYPE yyget_extra( yyscan_t yyscanner); diff --git a/x64_dbg_dbg/yara/yara/mem.h b/x64_dbg_dbg/yara/yara/mem.h index d794f445..bbbc6075 100644 --- a/x64_dbg_dbg/yara/yara/mem.h +++ b/x64_dbg_dbg/yara/yara/mem.h @@ -46,13 +46,13 @@ void* yr_realloc( size_t size); void yr_free( - void *ptr); + void* ptr); char* yr_strdup( - const char *str); + const char* str); char* yr_strndup( - const char *str, size_t n); + const char* str, size_t n); #endif diff --git a/x64_dbg_dbg/yara/yara/modules.h b/x64_dbg_dbg/yara/yara/modules.h index 5447c35a..8ecc89a8 100644 --- a/x64_dbg_dbg/yara/yara/modules.h +++ b/x64_dbg_dbg/yara/yara/modules.h @@ -283,7 +283,7 @@ limitations under the License. for (block = (context)->mem_block; \ block != NULL; \ block = block->next) \ - + #define first_memory_block(context) \ (context)->mem_block @@ -392,24 +392,24 @@ typedef int (*YR_EXT_UNLOAD_FUNC)( typedef struct _YR_MODULE { - tidx_mask_t is_loaded; + tidx_mask_t is_loaded; - char* name; + char* name; - YR_EXT_DECLARATIONS_FUNC declarations; - YR_EXT_LOAD_FUNC load; - YR_EXT_UNLOAD_FUNC unload; - YR_EXT_INITIALIZE_FUNC initialize; - YR_EXT_FINALIZE_FUNC finalize; + YR_EXT_DECLARATIONS_FUNC declarations; + YR_EXT_LOAD_FUNC load; + YR_EXT_UNLOAD_FUNC unload; + YR_EXT_INITIALIZE_FUNC initialize; + YR_EXT_FINALIZE_FUNC finalize; } YR_MODULE; typedef struct _YR_MODULE_IMPORT { - const char* module_name; - void* module_data; - size_t module_data_size; + const char* module_name; + void* module_data; + size_t module_data_size; } YR_MODULE_IMPORT; diff --git a/x64_dbg_dbg/yara/yara/parser.h b/x64_dbg_dbg/yara/yara/parser.h index b5b3e65e..41904be7 100644 --- a/x64_dbg_dbg/yara/yara/parser.h +++ b/x64_dbg_dbg/yara/yara/parser.h @@ -55,8 +55,8 @@ int yr_parser_check_types( YR_STRING* yr_parser_lookup_string( - yyscan_t yyscanner, - const char* identifier); + yyscan_t yyscanner, + const char* identifier); int yr_parser_lookup_loop_variable( diff --git a/x64_dbg_dbg/yara/yara/pe.h b/x64_dbg_dbg/yara/yara/pe.h index ca6d5871..f8518324 100644 --- a/x64_dbg_dbg/yara/yara/pe.h +++ b/x64_dbg_dbg/yara/yara/pe.h @@ -63,7 +63,8 @@ typedef uint64_t ULONGLONG; #pragma pack(push, 2) -typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header +typedef struct _IMAGE_DOS_HEADER // DOS .EXE header +{ WORD e_magic; // Magic number WORD e_cblp; // Bytes on last page of file WORD e_cp; // Pages in file @@ -83,7 +84,7 @@ typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header WORD e_oeminfo; // OEM information; e_oemid specific WORD e_res2[10]; // Reserved words LONG e_lfanew; // File address of new exe header - } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; +} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; #pragma pack(pop) @@ -93,7 +94,8 @@ typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header #pragma pack(push,4) -typedef struct _IMAGE_FILE_HEADER { +typedef struct _IMAGE_FILE_HEADER +{ WORD Machine; WORD NumberOfSections; DWORD TimeDateStamp; @@ -167,7 +169,8 @@ typedef struct _IMAGE_FILE_HEADER { // Directory format. // -typedef struct _IMAGE_DATA_DIRECTORY { +typedef struct _IMAGE_DATA_DIRECTORY +{ DWORD VirtualAddress; DWORD Size; } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; @@ -197,7 +200,8 @@ typedef struct _IMAGE_DATA_DIRECTORY { // Optional header format. // -typedef struct _IMAGE_OPTIONAL_HEADER32 { +typedef struct _IMAGE_OPTIONAL_HEADER32 +{ WORD Magic; BYTE MajorLinkerVersion; BYTE MinorLinkerVersion; @@ -233,7 +237,8 @@ typedef struct _IMAGE_OPTIONAL_HEADER32 { } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32; -typedef struct _IMAGE_OPTIONAL_HEADER64 { +typedef struct _IMAGE_OPTIONAL_HEADER64 +{ WORD Magic; BYTE MajorLinkerVersion; BYTE MinorLinkerVersion; @@ -272,7 +277,8 @@ typedef struct _IMAGE_OPTIONAL_HEADER64 { #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b -typedef struct _IMAGE_NT_HEADERS32 { +typedef struct _IMAGE_NT_HEADERS32 +{ DWORD Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; @@ -280,7 +286,8 @@ typedef struct _IMAGE_NT_HEADERS32 { } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32; -typedef struct _IMAGE_NT_HEADERS64 { +typedef struct _IMAGE_NT_HEADERS64 +{ DWORD Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER64 OptionalHeader; @@ -313,11 +320,13 @@ typedef struct _IMAGE_NT_HEADERS64 { #define IMAGE_SIZEOF_SHORT_NAME 8 -typedef struct _IMAGE_SECTION_HEADER { +typedef struct _IMAGE_SECTION_HEADER +{ BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; - union { - DWORD PhysicalAddress; - DWORD VirtualSize; + union + { + DWORD PhysicalAddress; + DWORD VirtualSize; } Misc; DWORD VirtualAddress; DWORD SizeOfRawData; @@ -333,7 +342,8 @@ typedef struct _IMAGE_SECTION_HEADER { #define IMAGE_SIZEOF_SECTION_HEADER 40 -typedef struct _IMAGE_EXPORT_DIRECTORY { +typedef struct _IMAGE_EXPORT_DIRECTORY +{ DWORD Characteristics; DWORD TimeDateStamp; WORD MajorVersion; @@ -348,8 +358,10 @@ typedef struct _IMAGE_EXPORT_DIRECTORY { } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; -typedef struct _IMAGE_IMPORT_DESCRIPTOR { - union { +typedef struct _IMAGE_IMPORT_DESCRIPTOR +{ + union + { DWORD Characteristics; DWORD OriginalFirstThunk; } ; @@ -361,19 +373,22 @@ typedef struct _IMAGE_IMPORT_DESCRIPTOR { } IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR; -typedef struct _IMAGE_IMPORT_BY_NAME { - WORD Hint; - BYTE Name[1]; +typedef struct _IMAGE_IMPORT_BY_NAME +{ + WORD Hint; + BYTE Name[1]; } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; -typedef struct _IMAGE_THUNK_DATA32 { - union { - DWORD ForwarderString; - DWORD Function; - DWORD Ordinal; - DWORD AddressOfData; - } u1; +typedef struct _IMAGE_THUNK_DATA32 +{ + union + { + DWORD ForwarderString; + DWORD Function; + DWORD Ordinal; + DWORD AddressOfData; + } u1; } IMAGE_THUNK_DATA32, *PIMAGE_THUNK_DATA32; @@ -381,32 +396,37 @@ typedef struct _IMAGE_THUNK_DATA32 { #define IMAGE_ORDINAL_FLAG32 0x80000000 #define IMAGE_ORDINAL_FLAG64 0x8000000000000000L -typedef struct _IMAGE_THUNK_DATA64 { - union { - ULONGLONG ForwarderString; - ULONGLONG Function; - ULONGLONG Ordinal; - ULONGLONG AddressOfData; - } u1; +typedef struct _IMAGE_THUNK_DATA64 +{ + union + { + ULONGLONG ForwarderString; + ULONGLONG Function; + ULONGLONG Ordinal; + ULONGLONG AddressOfData; + } u1; } IMAGE_THUNK_DATA64, *PIMAGE_THUNK_DATA64; -typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY { +typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY +{ DWORD Name; DWORD OffsetToData; } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY; - typedef struct _IMAGE_RESOURCE_DATA_ENTRY { +typedef struct _IMAGE_RESOURCE_DATA_ENTRY +{ DWORD OffsetToData; DWORD Size; DWORD CodePage; DWORD Reserved; - } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY; +} IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY; -typedef struct _IMAGE_RESOURCE_DIRECTORY { +typedef struct _IMAGE_RESOURCE_DIRECTORY +{ DWORD Characteristics; DWORD TimeDateStamp; WORD MajorVersion; @@ -419,7 +439,8 @@ typedef struct _IMAGE_RESOURCE_DIRECTORY { #endif // _WIN32 -typedef struct _VERSION_INFO { +typedef struct _VERSION_INFO +{ WORD Length; WORD ValueLength; WORD Type; @@ -435,7 +456,8 @@ typedef struct _VERSION_INFO { #define WIN_CERT_TYPE_RESERVED_1 0x0003 #define WIN_CERT_TYPE_TS_STACK_SIGNED 0x0004 -typedef struct _WIN_CERTIFICATE { +typedef struct _WIN_CERTIFICATE +{ DWORD Length; WORD Revision; WORD CertificateType; @@ -448,7 +470,8 @@ typedef struct _WIN_CERTIFICATE { // http://www.ntcore.com/files/richsign.htm // -typedef struct _RICH_SIGNATURE { +typedef struct _RICH_SIGNATURE +{ DWORD dans; DWORD key1; DWORD key2; @@ -458,7 +481,8 @@ typedef struct _RICH_SIGNATURE { #define RICH_DANS 0x536e6144 // "DanS" #define RICH_RICH 0x68636952 // "Rich" -typedef struct _RICH_DATA { +typedef struct _RICH_DATA +{ size_t len; BYTE* raw_data; BYTE* clear_data; diff --git a/x64_dbg_dbg/yara/yara/re.h b/x64_dbg_dbg/yara/yara/re.h index 31b25f66..b6e1ff78 100644 --- a/x64_dbg_dbg/yara/yara/re.h +++ b/x64_dbg_dbg/yara/yara/re.h @@ -98,43 +98,47 @@ typedef uint8_t* RE_CODE; struct RE_NODE { - int type; + int type; - union { - int value; - int count; - int start; - }; + union + { + int value; + int count; + int start; + }; - union { - int mask; - int end; - }; + union + { + int mask; + int end; + }; - int greedy; + int greedy; - uint8_t* class_vector; + uint8_t* class_vector; - RE_NODE* left; - RE_NODE* right; + RE_NODE* left; + RE_NODE* right; - RE_CODE forward_code; - RE_CODE backward_code; + RE_CODE forward_code; + RE_CODE backward_code; }; -struct RE { +struct RE +{ - uint32_t flags; - RE_NODE* root_node; - YR_ARENA* code_arena; - RE_CODE code; + uint32_t flags; + RE_NODE* root_node; + YR_ARENA* code_arena; + RE_CODE code; }; -struct RE_ERROR { +struct RE_ERROR +{ - char message[512]; + char message[512]; }; @@ -187,7 +191,7 @@ RE_NODE* yr_re_node_create( void yr_re_node_destroy( - RE_NODE* node); + RE_NODE* node); SIZED_STRING* yr_re_extract_literal( diff --git a/x64_dbg_dbg/yara/yara/re_lexer.h b/x64_dbg_dbg/yara/yara/re_lexer.h index fb897714..1bf7aa30 100644 --- a/x64_dbg_dbg/yara/yara/re_lexer.h +++ b/x64_dbg_dbg/yara/yara/re_lexer.h @@ -1,11 +1,11 @@ - /* +/* Copyright (c) 2013. The YARA Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -51,10 +51,10 @@ typedef void* yyscan_t; typedef struct _RE_LEX_ENVIRONMENT { - int negated_class; - uint8_t class_vector[32]; - int last_error_code; - char last_error_message[256]; + int negated_class; + uint8_t class_vector[32]; + int last_error_code; + char last_error_message[256]; } RE_LEX_ENVIRONMENT; @@ -78,20 +78,20 @@ int yylex( RE_LEX_ENVIRONMENT* lex_env); int yyparse( - void *yyscanner, - RE_LEX_ENVIRONMENT *lex_env); + void* yyscanner, + RE_LEX_ENVIRONMENT* lex_env); void yyerror( yyscan_t yyscanner, RE_LEX_ENVIRONMENT* lex_env, - const char *error_message); + const char* error_message); void yyfatal( yyscan_t yyscanner, - const char *error_message); + const char* error_message); int yr_parse_re_string( - const char* re_string, - int flags, - RE** re, - RE_ERROR* error); + const char* re_string, + int flags, + RE** re, + RE_ERROR* error); diff --git a/x64_dbg_dbg/yara/yara/sizedstr.h b/x64_dbg_dbg/yara/yara/sizedstr.h index df832e5a..fe8a2833 100644 --- a/x64_dbg_dbg/yara/yara/sizedstr.h +++ b/x64_dbg_dbg/yara/yara/sizedstr.h @@ -28,15 +28,15 @@ limitations under the License. typedef struct _SIZED_STRING { - int length; - int flags; - char c_string[1]; + int length; + int flags; + char c_string[1]; } SIZED_STRING; int sized_string_cmp( - SIZED_STRING* s1, - SIZED_STRING* s2); + SIZED_STRING* s1, + SIZED_STRING* s2); #endif diff --git a/x64_dbg_dbg/yara/yara/strutils.h b/x64_dbg_dbg/yara/yara/strutils.h index 3e38bc4e..9ad7aa4e 100644 --- a/x64_dbg_dbg/yara/yara/strutils.h +++ b/x64_dbg_dbg/yara/yara/strutils.h @@ -36,25 +36,25 @@ uint64_t xtoi( #if !HAVE_STRLCPY size_t strlcpy( - char *dst, - const char *src, + char* dst, + const char* src, size_t size); #endif #if !HAVE_STRLCAT size_t strlcat( - char *dst, - const char *src, + char* dst, + const char* src, size_t size); #endif #if !HAVE_MEMMEM void* memmem( - const void *haystack, + const void* haystack, size_t haystack_size, - const void *needle, + const void* needle, size_t needle_size); #endif diff --git a/x64_dbg_dbg/yara/yara/types.h b/x64_dbg_dbg/yara/yara/types.h index 2e902189..6c13aa80 100644 --- a/x64_dbg_dbg/yara/yara/types.h +++ b/x64_dbg_dbg/yara/yara/types.h @@ -49,8 +49,8 @@ typedef int32_t tidx_mask_t; typedef struct _YR_NAMESPACE { - int32_t t_flags[MAX_THREADS]; // Thread-specific flags - DECLARE_REFERENCE(char*, name); + int32_t t_flags[MAX_THREADS]; // Thread-specific flags + DECLARE_REFERENCE(char*, name); } YR_NAMESPACE; @@ -66,38 +66,39 @@ typedef struct _YR_NAMESPACE typedef struct _YR_META { - int32_t type; - int32_t integer; + int32_t type; + int32_t integer; - DECLARE_REFERENCE(const char*, identifier); - DECLARE_REFERENCE(char*, string); + DECLARE_REFERENCE(const char*, identifier); + DECLARE_REFERENCE(char*, string); } YR_META; typedef struct _YR_MATCH { - int64_t base; - int64_t offset; - int32_t length; + int64_t base; + int64_t offset; + int32_t length; - union { - uint8_t* data; // Confirmed matches use "data", - int32_t chain_length; // unconfirmed ones use "chain_length" - }; + union + { + uint8_t* data; // Confirmed matches use "data", + int32_t chain_length; // unconfirmed ones use "chain_length" + }; - struct _YR_MATCH* prev; - struct _YR_MATCH* next; + struct _YR_MATCH* prev; + struct _YR_MATCH* next; } YR_MATCH; typedef struct _YR_MATCHES { - int32_t count; + int32_t count; - DECLARE_REFERENCE(YR_MATCH*, head); - DECLARE_REFERENCE(YR_MATCH*, tail); + DECLARE_REFERENCE(YR_MATCH*, head); + DECLARE_REFERENCE(YR_MATCH*, tail); } YR_MATCHES; @@ -177,24 +178,24 @@ typedef struct _YR_MATCHES typedef struct _YR_STRING { - int32_t g_flags; - int32_t length; + int32_t g_flags; + int32_t length; - DECLARE_REFERENCE(char*, identifier); - DECLARE_REFERENCE(uint8_t*, string); - DECLARE_REFERENCE(struct _YR_STRING*, chained_to); + DECLARE_REFERENCE(char*, identifier); + DECLARE_REFERENCE(uint8_t*, string); + DECLARE_REFERENCE(struct _YR_STRING*, chained_to); - int32_t chain_gap_min; - int32_t chain_gap_max; + int32_t chain_gap_min; + int32_t chain_gap_max; - int64_t fixed_offset; + int64_t fixed_offset; - YR_MATCHES matches[MAX_THREADS]; - YR_MATCHES unconfirmed_matches[MAX_THREADS]; + YR_MATCHES matches[MAX_THREADS]; + YR_MATCHES unconfirmed_matches[MAX_THREADS]; - #ifdef PROFILING_ENABLED - uint64_t clock_ticks; - #endif +#ifdef PROFILING_ENABLED + uint64_t clock_ticks; +#endif } YR_STRING; @@ -222,18 +223,18 @@ typedef struct _YR_STRING typedef struct _YR_RULE { - int32_t g_flags; // Global flags - int32_t t_flags[MAX_THREADS]; // Thread-specific flags + int32_t g_flags; // Global flags + int32_t t_flags[MAX_THREADS]; // Thread-specific flags - DECLARE_REFERENCE(const char*, identifier); - DECLARE_REFERENCE(const char*, tags); - DECLARE_REFERENCE(YR_META*, metas); - DECLARE_REFERENCE(YR_STRING*, strings); - DECLARE_REFERENCE(YR_NAMESPACE*, ns); + DECLARE_REFERENCE(const char*, identifier); + DECLARE_REFERENCE(const char*, tags); + DECLARE_REFERENCE(YR_META*, metas); + DECLARE_REFERENCE(YR_STRING*, strings); + DECLARE_REFERENCE(YR_NAMESPACE*, ns); - #ifdef PROFILING_ENABLED - uint64_t clock_ticks; - #endif +#ifdef PROFILING_ENABLED + uint64_t clock_ticks; +#endif } YR_RULE; @@ -252,88 +253,89 @@ typedef struct _YR_RULE typedef struct _YR_EXTERNAL_VARIABLE { - int32_t type; + int32_t type; - union { - int64_t i; - double f; - char* s; - } value; + union + { + int64_t i; + double f; + char* s; + } value; - DECLARE_REFERENCE(char*, identifier); + DECLARE_REFERENCE(char*, identifier); } YR_EXTERNAL_VARIABLE; typedef struct _YR_AC_MATCH { - uint16_t backtrack; + uint16_t backtrack; - DECLARE_REFERENCE(YR_STRING*, string); - DECLARE_REFERENCE(uint8_t*, forward_code); - DECLARE_REFERENCE(uint8_t*, backward_code); - DECLARE_REFERENCE(struct _YR_AC_MATCH*, next); + DECLARE_REFERENCE(YR_STRING*, string); + DECLARE_REFERENCE(uint8_t*, forward_code); + DECLARE_REFERENCE(uint8_t*, backward_code); + DECLARE_REFERENCE(struct _YR_AC_MATCH*, next); } YR_AC_MATCH; typedef struct _YR_AC_STATE { - int8_t depth; + int8_t depth; - DECLARE_REFERENCE(struct _YR_AC_STATE*, failure); - DECLARE_REFERENCE(YR_AC_MATCH*, matches); + DECLARE_REFERENCE(struct _YR_AC_STATE*, failure); + DECLARE_REFERENCE(YR_AC_MATCH*, matches); } YR_AC_STATE; typedef struct _YR_AC_STATE_TRANSITION { - uint8_t input; + uint8_t input; - DECLARE_REFERENCE(YR_AC_STATE*, state); - DECLARE_REFERENCE(struct _YR_AC_STATE_TRANSITION*, next); + DECLARE_REFERENCE(YR_AC_STATE*, state); + DECLARE_REFERENCE(struct _YR_AC_STATE_TRANSITION*, next); } YR_AC_STATE_TRANSITION; typedef struct _YR_AC_TABLE_BASED_STATE { - int8_t depth; + int8_t depth; - DECLARE_REFERENCE(YR_AC_STATE*, failure); - DECLARE_REFERENCE(YR_AC_MATCH*, matches); - DECLARE_REFERENCE(YR_AC_STATE*, state) transitions[256]; + DECLARE_REFERENCE(YR_AC_STATE*, failure); + DECLARE_REFERENCE(YR_AC_MATCH*, matches); + DECLARE_REFERENCE(YR_AC_STATE*, state) transitions[256]; } YR_AC_TABLE_BASED_STATE; typedef struct _YR_AC_LIST_BASED_STATE { - int8_t depth; + int8_t depth; - DECLARE_REFERENCE(YR_AC_STATE*, failure); - DECLARE_REFERENCE(YR_AC_MATCH*, matches); - DECLARE_REFERENCE(YR_AC_STATE_TRANSITION*, transitions); + DECLARE_REFERENCE(YR_AC_STATE*, failure); + DECLARE_REFERENCE(YR_AC_MATCH*, matches); + DECLARE_REFERENCE(YR_AC_STATE_TRANSITION*, transitions); } YR_AC_LIST_BASED_STATE; typedef struct _YR_AC_AUTOMATON { - DECLARE_REFERENCE(YR_AC_STATE*, root); + DECLARE_REFERENCE(YR_AC_STATE*, root); } YR_AC_AUTOMATON; typedef struct _YARA_RULES_FILE_HEADER { - uint32_t version; + uint32_t version; - DECLARE_REFERENCE(YR_RULE*, rules_list_head); - DECLARE_REFERENCE(YR_EXTERNAL_VARIABLE*, externals_list_head); - DECLARE_REFERENCE(uint8_t*, code_start); - DECLARE_REFERENCE(YR_AC_AUTOMATON*, automaton); + DECLARE_REFERENCE(YR_RULE*, rules_list_head); + DECLARE_REFERENCE(YR_EXTERNAL_VARIABLE*, externals_list_head); + DECLARE_REFERENCE(uint8_t*, code_start); + DECLARE_REFERENCE(YR_AC_AUTOMATON*, automaton); } YARA_RULES_FILE_HEADER; @@ -342,28 +344,29 @@ typedef struct _YARA_RULES_FILE_HEADER #pragma pack(pop) -typedef struct _YR_RULES { +typedef struct _YR_RULES +{ - tidx_mask_t tidx_mask; - uint8_t* code_start; + tidx_mask_t tidx_mask; + uint8_t* code_start; - mutex_t mutex; + mutex_t mutex; - YR_ARENA* arena; - YR_RULE* rules_list_head; - YR_EXTERNAL_VARIABLE* externals_list_head; - YR_AC_AUTOMATON* automaton; + YR_ARENA* arena; + YR_RULE* rules_list_head; + YR_EXTERNAL_VARIABLE* externals_list_head; + YR_AC_AUTOMATON* automaton; } YR_RULES; typedef struct _YR_MEMORY_BLOCK { - uint8_t* data; - size_t size; - size_t base; + uint8_t* data; + size_t size; + size_t base; - struct _YR_MEMORY_BLOCK* next; + struct _YR_MEMORY_BLOCK* next; } YR_MEMORY_BLOCK; @@ -376,15 +379,15 @@ typedef int (*YR_CALLBACK_FUNC)( typedef struct _YR_SCAN_CONTEXT { - uint64_t file_size; - uint64_t entry_point; + uint64_t file_size; + uint64_t entry_point; - int flags; - void* user_data; + int flags; + void* user_data; - YR_MEMORY_BLOCK* mem_block; - YR_HASH_TABLE* objects_table; - YR_CALLBACK_FUNC callback; + YR_MEMORY_BLOCK* mem_block; + YR_HASH_TABLE* objects_table; + YR_CALLBACK_FUNC callback; } YR_SCAN_CONTEXT; @@ -399,65 +402,65 @@ typedef struct _YR_SCAN_CONTEXT typedef struct _YR_OBJECT { - OBJECT_COMMON_FIELDS + OBJECT_COMMON_FIELDS } YR_OBJECT; typedef struct _YR_OBJECT_INTEGER { - OBJECT_COMMON_FIELDS - int64_t value; + OBJECT_COMMON_FIELDS + int64_t value; } YR_OBJECT_INTEGER; typedef struct _YR_OBJECT_DOUBLE { - OBJECT_COMMON_FIELDS - double value; + OBJECT_COMMON_FIELDS + double value; } YR_OBJECT_DOUBLE; typedef struct _YR_OBJECT_STRING { - OBJECT_COMMON_FIELDS - SIZED_STRING* value; + OBJECT_COMMON_FIELDS + SIZED_STRING* value; } YR_OBJECT_STRING; typedef struct _YR_OBJECT_REGEXP { - OBJECT_COMMON_FIELDS - RE* value; + OBJECT_COMMON_FIELDS + RE* value; } YR_OBJECT_REGEXP; typedef struct _YR_OBJECT_STRUCTURE { - OBJECT_COMMON_FIELDS - struct _YR_STRUCTURE_MEMBER* members; + OBJECT_COMMON_FIELDS + struct _YR_STRUCTURE_MEMBER* members; } YR_OBJECT_STRUCTURE; typedef struct _YR_OBJECT_ARRAY { - OBJECT_COMMON_FIELDS - YR_OBJECT* prototype_item; - struct _YR_ARRAY_ITEMS* items; + OBJECT_COMMON_FIELDS + YR_OBJECT* prototype_item; + struct _YR_ARRAY_ITEMS* items; } YR_OBJECT_ARRAY; typedef struct _YR_OBJECT_DICTIONARY { - OBJECT_COMMON_FIELDS - YR_OBJECT* prototype_item; - struct _YR_DICTIONARY_ITEMS* items; + OBJECT_COMMON_FIELDS + YR_OBJECT* prototype_item; + struct _YR_DICTIONARY_ITEMS* items; } YR_OBJECT_DICTIONARY; @@ -473,45 +476,47 @@ typedef int (*YR_MODULE_FUNC)( typedef struct _YR_OBJECT_FUNCTION { - OBJECT_COMMON_FIELDS + OBJECT_COMMON_FIELDS - YR_OBJECT* return_obj; + YR_OBJECT* return_obj; - struct { - const char* arguments_fmt; - YR_MODULE_FUNC code; - } prototypes[MAX_OVERLOADED_FUNCTIONS]; + struct + { + const char* arguments_fmt; + YR_MODULE_FUNC code; + } prototypes[MAX_OVERLOADED_FUNCTIONS]; } YR_OBJECT_FUNCTION; typedef struct _YR_STRUCTURE_MEMBER { - YR_OBJECT* object; - struct _YR_STRUCTURE_MEMBER* next; + YR_OBJECT* object; + struct _YR_STRUCTURE_MEMBER* next; } YR_STRUCTURE_MEMBER; typedef struct _YR_ARRAY_ITEMS { - int count; - YR_OBJECT* objects[1]; + int count; + YR_OBJECT* objects[1]; } YR_ARRAY_ITEMS; typedef struct _YR_DICTIONARY_ITEMS { - int used; - int free; + int used; + int free; - struct { + struct + { - char* key; - YR_OBJECT* obj; + char* key; + YR_OBJECT* obj; - } objects[1]; + } objects[1]; } YR_DICTIONARY_ITEMS; From 905e94c66acf40931d5a8b7cdb9186b5eebe5ae0 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 13:56:37 +0200 Subject: [PATCH 100/106] DBg+GUI: generic formatting --- x64_dbg_dbg/dbghelp_safe.cpp | 60 +++++++++---------- x64_dbg_dbg/dbghelp_safe.h | 60 +++++++++---------- x64_dbg_dbg/debugger.cpp | 2 +- x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp | 4 +- x64_dbg_gui/Project/Src/Gui/HexEditDialog.h | 4 +- 5 files changed, 65 insertions(+), 65 deletions(-) diff --git a/x64_dbg_dbg/dbghelp_safe.cpp b/x64_dbg_dbg/dbghelp_safe.cpp index 46bb5ffa..0e6488c2 100644 --- a/x64_dbg_dbg/dbghelp_safe.cpp +++ b/x64_dbg_dbg/dbghelp_safe.cpp @@ -3,64 +3,64 @@ #include "threading.h" DWORD - SafeUnDecorateSymbolName( +SafeUnDecorateSymbolName( __in PCSTR name, __out_ecount(maxStringLength) PSTR outputString, __in DWORD maxStringLength, __in DWORD flags - ) +) { CriticalSectionLocker locker(LockSym); return UnDecorateSymbolName(name, outputString, maxStringLength, flags); } BOOL - SafeSymUnloadModule64( +SafeSymUnloadModule64( __in HANDLE hProcess, __in DWORD64 BaseOfDll - ) +) { CriticalSectionLocker locker(LockSym); return SymUnloadModule64(hProcess, BaseOfDll); } BOOL - SafeSymSetSearchPath( +SafeSymSetSearchPath( __in HANDLE hProcess, __in_opt PCSTR SearchPath - ) +) { CriticalSectionLocker locker(LockSym); return SymSetSearchPath(hProcess, SearchPath); } DWORD - SafeSymSetOptions( +SafeSymSetOptions( __in DWORD SymOptions - ) +) { CriticalSectionLocker locker(LockSym); return SymSetOptions(SymOptions); } BOOL - SafeSymInitialize( +SafeSymInitialize( __in HANDLE hProcess, __in_opt PCSTR UserSearchPath, __in BOOL fInvadeProcess - ) +) { CriticalSectionLocker locker(LockSym); return SymInitialize(hProcess, UserSearchPath, fInvadeProcess); } BOOL - SafeSymRegisterCallback64( +SafeSymRegisterCallback64( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, __in ULONG64 UserContext - ) +) { CriticalSectionLocker locker(LockSym); return SymRegisterCallback64(hProcess, CallbackFunction, UserContext); } DWORD64 - SafeSymLoadModuleEx( +SafeSymLoadModuleEx( __in HANDLE hProcess, __in_opt HANDLE hFile, __in_opt PCSTR ImageName, @@ -69,89 +69,89 @@ DWORD64 __in DWORD DllSize, __in_opt PMODLOAD_DATA Data, __in_opt DWORD Flags - ) +) { CriticalSectionLocker locker(LockSym); return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll, DllSize, Data, Flags); } BOOL - SafeSymGetModuleInfo64( +SafeSymGetModuleInfo64( __in HANDLE hProcess, __in DWORD64 qwAddr, __out PIMAGEHLP_MODULE64 ModuleInfo - ) +) { CriticalSectionLocker locker(LockSym); return SymGetModuleInfo64(hProcess, qwAddr, ModuleInfo); } BOOL - SafeSymGetSearchPath( +SafeSymGetSearchPath( __in HANDLE hProcess, __out_ecount(SearchPathLength) PSTR SearchPath, __in DWORD SearchPathLength - ) +) { CriticalSectionLocker locker(LockSym); return SymGetSearchPath(hProcess, SearchPath, SearchPathLength); } BOOL - SafeSymEnumSymbols( +SafeSymEnumSymbols( __in HANDLE hProcess, __in ULONG64 BaseOfDll, __in_opt PCSTR Mask, __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, __in_opt PVOID UserContext - ) +) { CriticalSectionLocker locker(LockSym); return SymEnumSymbols(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext); } BOOL - SafeSymEnumerateModules( +SafeSymEnumerateModules( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, __in_opt PVOID UserContext - ) +) { CriticalSectionLocker locker(LockSym); return SymEnumerateModules(hProcess, EnumModulesCallback, UserContext); } BOOL - SafeSymGetLineFromAddr64( +SafeSymGetLineFromAddr64( __in HANDLE hProcess, __in DWORD64 qwAddr, __out PDWORD pdwDisplacement, __out PIMAGEHLP_LINE64 Line64 - ) +) { CriticalSectionLocker locker(LockSym); return SymGetLineFromAddr64(hProcess, qwAddr, pdwDisplacement, Line64); } BOOL - SafeSymFromName( +SafeSymFromName( __in HANDLE hProcess, __in PCSTR Name, __inout PSYMBOL_INFO Symbol - ) +) { CriticalSectionLocker locker(LockSym); return SymFromName(hProcess, Name, Symbol); } BOOL - SafeSymFromAddr( +SafeSymFromAddr( __in HANDLE hProcess, __in DWORD64 Address, __out_opt PDWORD64 Displacement, __inout PSYMBOL_INFO Symbol - ) +) { CriticalSectionLocker locker(LockSym); return SymFromAddr(hProcess, Address, Displacement, Symbol); } BOOL - SafeSymCleanup( +SafeSymCleanup( __in HANDLE hProcess - ) +) { CriticalSectionLocker locker(LockSym); return SymCleanup(hProcess); diff --git a/x64_dbg_dbg/dbghelp_safe.h b/x64_dbg_dbg/dbghelp_safe.h index b6364f33..20293018 100644 --- a/x64_dbg_dbg/dbghelp_safe.h +++ b/x64_dbg_dbg/dbghelp_safe.h @@ -8,40 +8,40 @@ #endif //__GNUC__ DWORD - SafeUnDecorateSymbolName( +SafeUnDecorateSymbolName( __in PCSTR name, __out_ecount(maxStringLength) PSTR outputString, __in DWORD maxStringLength, __in DWORD flags - ); +); BOOL - SafeSymUnloadModule64( +SafeSymUnloadModule64( __in HANDLE hProcess, __in DWORD64 BaseOfDll - ); +); BOOL - SafeSymSetSearchPath( +SafeSymSetSearchPath( __in HANDLE hProcess, __in_opt PCSTR SearchPath - ); +); DWORD - SafeSymSetOptions( +SafeSymSetOptions( __in DWORD SymOptions - ); +); BOOL - SafeSymInitialize( +SafeSymInitialize( __in HANDLE hProcess, __in_opt PCSTR UserSearchPath, __in BOOL fInvadeProcess - ); +); BOOL - SafeSymRegisterCallback64( +SafeSymRegisterCallback64( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, __in ULONG64 UserContext - ); +); DWORD64 - SafeSymLoadModuleEx( +SafeSymLoadModuleEx( __in HANDLE hProcess, __in_opt HANDLE hFile, __in_opt PCSTR ImageName, @@ -50,56 +50,56 @@ DWORD64 __in DWORD DllSize, __in_opt PMODLOAD_DATA Data, __in_opt DWORD Flags - ); +); BOOL - SafeSymGetModuleInfo64( +SafeSymGetModuleInfo64( __in HANDLE hProcess, __in DWORD64 qwAddr, __out PIMAGEHLP_MODULE64 ModuleInfo - ); +); BOOL - SafeSymGetSearchPath( +SafeSymGetSearchPath( __in HANDLE hProcess, __out_ecount(SearchPathLength) PSTR SearchPath, __in DWORD SearchPathLength - ); +); BOOL - SafeSymEnumSymbols( +SafeSymEnumSymbols( __in HANDLE hProcess, __in ULONG64 BaseOfDll, __in_opt PCSTR Mask, __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, __in_opt PVOID UserContext - ); +); BOOL - SafeSymEnumerateModules( +SafeSymEnumerateModules( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, __in_opt PVOID UserContext - ); +); BOOL - SafeSymGetLineFromAddr64( +SafeSymGetLineFromAddr64( __in HANDLE hProcess, __in DWORD64 qwAddr, __out PDWORD pdwDisplacement, __out PIMAGEHLP_LINE64 Line64 - ); +); BOOL - SafeSymFromName( +SafeSymFromName( __in HANDLE hProcess, __in PCSTR Name, __inout PSYMBOL_INFO Symbol - ); +); BOOL - SafeSymFromAddr( +SafeSymFromAddr( __in HANDLE hProcess, __in DWORD64 Address, __out_opt PDWORD64 Displacement, __inout PSYMBOL_INFO Symbol - ); +); BOOL - SafeSymCleanup( +SafeSymCleanup( __in HANDLE hProcess - ); +); #endif //_DBGHELP_SAFE_H \ No newline at end of file diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index f9cf4054..a095c745 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -605,7 +605,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) dprintf("Process Started: "fhex" %s\n", base, DebugFileName); memupdatemap(fdProcessInfo->hProcess); - GuiDumpAt(memfindbaseaddr(GetContextData(UE_CIP), 0)+PAGE_SIZE); //dump somewhere + GuiDumpAt(memfindbaseaddr(GetContextData(UE_CIP), 0) + PAGE_SIZE); //dump somewhere //init program database int len = (int)strlen(szFileName); diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp index 9abd93d1..44e27f6d 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.cpp @@ -123,12 +123,12 @@ void HexEditDialog::dataChangedSlot() ui->lineEditUnicode->setText(unicode); } -void HexEditDialog::on_lineEditAscii_textEdited(const QString &arg1) +void HexEditDialog::on_lineEditAscii_textEdited(const QString & arg1) { on_btnAscii2Hex_clicked(); } -void HexEditDialog::on_lineEditUnicode_textEdited(const QString &arg1) +void HexEditDialog::on_lineEditUnicode_textEdited(const QString & arg1) { on_btnUnicode2Hex_clicked(); } diff --git a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h index 13dd455f..8616abf3 100644 --- a/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/HexEditDialog.h @@ -28,8 +28,8 @@ private slots: void on_btnUnicode2Hex_clicked(); void on_chkKeepSize_toggled(bool checked); void dataChangedSlot(); - void on_lineEditAscii_textEdited(const QString &arg1); - void on_lineEditUnicode_textEdited(const QString &arg1); + void on_lineEditAscii_textEdited(const QString & arg1); + void on_lineEditUnicode_textEdited(const QString & arg1); private: Ui::HexEditDialog* ui; From 4e22157e424bc3f94860ccb0d99e6a98284bebc0 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 14:11:53 +0200 Subject: [PATCH 101/106] DBG: working yara command (code still ugly though) --- x64_dbg_dbg/instruction.cpp | 204 +++++++++++++++++++++++++++++++++++- 1 file changed, 203 insertions(+), 1 deletion(-) diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index 08aa50fc..e9c25d53 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -18,6 +18,7 @@ #include "function.h" #include "loop.h" #include "patternfind.h" +#include "module.h" static bool bRefinit = false; @@ -1531,7 +1532,208 @@ CMDRESULT cbInstrFindAsm(int argc, char* argv[]) return STATUS_CONTINUE; } +static void yaraCompilerCallback(int error_level, const char* file_name, int line_number, const char* message, void* user_data) +{ + switch(error_level) + { + case YARA_ERROR_LEVEL_ERROR: + dprintf("[YARA ERROR] "); + break; + case YARA_ERROR_LEVEL_WARNING: + dprintf("[YARA WARNING] "); + break; + } + dprintf("File: \"%s\", Line: %d, Message: \"%s\"\n", file_name, line_number, message); +} + +static String yara_print_string(const uint8_t* data, int length) +{ + String result = "\""; + const char* str = (const char*)data; + for(int i = 0; i < length; i++) + { + char cur[16] = ""; + if(str[i] >= 32 && str[i] <= 126) + sprintf_s(cur, "%c", str[i]); + else + sprintf_s(cur, "\\x%02X", (uint8_t) str[i]); + result += cur; + } + result += "\""; + return result; +} + +static String yara_print_hex_string(const uint8_t* data, int length) +{ + String result = ""; + for(int i = 0; i < length; i++) + { + if(i) + result += " "; + char cur[16] = ""; + sprintf_s(cur, "%02X", (uint8_t) data[i]); + result += cur; + } + return result; +} + +struct YaraScanInfo +{ + uint base; + int index; +}; + +static int yaraScanCallback(int message, void* message_data, void* user_data) +{ + YaraScanInfo* scanInfo = (YaraScanInfo*)user_data; + switch(message) + { + case CALLBACK_MSG_RULE_MATCHING: + { + uint base = scanInfo->base; + YR_RULE* yrRule = (YR_RULE*)message_data; + dprintf("[YARA] Rule \"%s\" matched:\n", yrRule->identifier); + YR_STRING* string; + yr_rule_strings_foreach(yrRule, string) + { + YR_MATCH* match; + yr_string_matches_foreach(string, match) + { + String pattern; + if(STRING_IS_HEX(string)) + pattern = yara_print_hex_string(match->data, match->length); + else + pattern = yara_print_string(match->data, match->length); + uint addr = (uint)(base + match->base + match->offset); + //dprintf("[YARA] String \"%s\" : %s on 0x%"fext"X\n", string->identifier, pattern.c_str(), addr); + + //update references + int index = scanInfo->index; + GuiReferenceSetRowCount(index + 1); + scanInfo->index++; + char addr_text[deflen] = ""; + sprintf(addr_text, fhex, addr); + GuiReferenceSetCellContent(index, 0, addr_text); //Address + String ruleFullName = ""; + ruleFullName += yrRule->identifier; + ruleFullName += "."; + ruleFullName += string->identifier; + GuiReferenceSetCellContent(index, 1, ruleFullName.c_str()); //Rule + GuiReferenceSetCellContent(index, 2, pattern.c_str()); //Data + } + } + } + break; + + case CALLBACK_MSG_RULE_NOT_MATCHING: + { + YR_RULE* yrRule = (YR_RULE*)message_data; + dprintf("[YARA] Rule \"%s\" did not match!\n", yrRule->identifier); + } + break; + + case CALLBACK_MSG_SCAN_FINISHED: + { + dputs("[YARA] Scan finished!"); + } + break; + + case CALLBACK_MSG_IMPORT_MODULE: + { + YR_MODULE_IMPORT* yrModuleImport = (YR_MODULE_IMPORT*)message_data; + dprintf("[YARA] Imported module \"%s\"!\n", yrModuleImport->module_name); + } + break; + } + return ERROR_SUCCESS; //nicely undocumented what this should be +} + CMDRESULT cbInstrYara(int argc, char* argv[]) { - return STATUS_CONTINUE; + if(argc < 2) //yara rulesFile, addr_of_mempage + { + dputs("not enough arguments!"); + return STATUS_ERROR; + } + uint addr = 0; + if(argc < 3 || !valfromstring(argv[2], &addr)) + addr = GetContextDataEx(hActiveThread, UE_CIP); + uint size = 0; + uint base = memfindbaseaddr(addr, &size); + Memory data(size); + if(!memread(fdProcessInfo->hProcess, (const void*)base, data(), size, 0)) + { + dprintf("failed to read memory page %p[%X]!\n", base, size); + return STATUS_ERROR; + } + + FILE* rulesFile = 0; + if(_wfopen_s(&rulesFile, StringUtils::Utf8ToUtf16(argv[1]).c_str(), L"rb")) + { + dputs("failed to open yara rules file!"); + return STATUS_ERROR; + } + + bool bSuccess = false; + YR_COMPILER* yrCompiler; + if(yr_compiler_create(&yrCompiler) == ERROR_SUCCESS) + { + yr_compiler_set_callback(yrCompiler, yaraCompilerCallback, 0); + if(yr_compiler_add_file(yrCompiler, rulesFile, NULL, argv[1]) == 0) //no errors found + { + fclose(rulesFile); + YR_RULES* yrRules; + if(yr_compiler_get_rules(yrCompiler, &yrRules) == ERROR_SUCCESS) + { + //initialize new reference tab + char modname[MAX_MODULE_SIZE] = ""; + if(!modnamefromaddr(base, modname, true)) + sprintf_s(modname, "%p", base); + String fullName; + const char* fileName=strrchr(argv[1], '\\'); + if(fileName) + fullName=fileName+1; + else + fullName=argv[1]; + fullName+=" ("; + fullName+=modname; + fullName+=")"; //nanana, very ugly code (long live open source) + GuiReferenceInitialize(fullName.c_str()); + GuiReferenceAddColumn(sizeof(uint) * 2, "Address"); + GuiReferenceAddColumn(48, "Rule"); + GuiReferenceAddColumn(0, "Data"); + GuiReferenceSetRowCount(0); + GuiReferenceReloadData(); + YaraScanInfo scanInfo; + scanInfo.base = base; + scanInfo.index = 0; + uint ticks = GetTickCount(); + dputs("[YARA] Scan started..."); + int err = yr_rules_scan_mem(yrRules, data(), size, 0, yaraScanCallback, &scanInfo, 0); + GuiReferenceReloadData(); + switch(err) + { + case ERROR_SUCCESS: + dprintf("%u scan results in %ums...\n", scanInfo.index, GetTickCount()-ticks); + bSuccess = true; + break; + case ERROR_TOO_MANY_MATCHES: + dputs("too many matches!"); + break; + default: + dputs("error while scanning memory!"); + break; + } + yr_rules_destroy(yrRules); + } + else + dputs("error while getting the rules!"); + } + else + dputs("errors in the rules file!"); + yr_compiler_destroy(yrCompiler); + } + else + dputs("yr_compiler_create failed!"); + return bSuccess ? STATUS_CONTINUE : STATUS_ERROR; } \ No newline at end of file From 245d920490fc21b72de9954a578a27ca1a2bc3d1 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 14:54:31 +0200 Subject: [PATCH 102/106] DBG: yaramod command working (but very ugly) --- x64_dbg_dbg/instruction.cpp | 206 ++++++++++++++++++++++++++++++++++-- x64_dbg_dbg/instruction.h | 1 + x64_dbg_dbg/x64_dbg.cpp | 1 + 3 files changed, 201 insertions(+), 7 deletions(-) diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index e9c25d53..90db7e2d 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -1690,14 +1690,14 @@ CMDRESULT cbInstrYara(int argc, char* argv[]) if(!modnamefromaddr(base, modname, true)) sprintf_s(modname, "%p", base); String fullName; - const char* fileName=strrchr(argv[1], '\\'); + const char* fileName = strrchr(argv[1], '\\'); if(fileName) - fullName=fileName+1; + fullName = fileName + 1; else - fullName=argv[1]; - fullName+=" ("; - fullName+=modname; - fullName+=")"; //nanana, very ugly code (long live open source) + fullName = argv[1]; + fullName += " ("; + fullName += modname; + fullName += ")"; //nanana, very ugly code (long live open source) GuiReferenceInitialize(fullName.c_str()); GuiReferenceAddColumn(sizeof(uint) * 2, "Address"); GuiReferenceAddColumn(48, "Rule"); @@ -1714,7 +1714,7 @@ CMDRESULT cbInstrYara(int argc, char* argv[]) switch(err) { case ERROR_SUCCESS: - dprintf("%u scan results in %ums...\n", scanInfo.index, GetTickCount()-ticks); + dprintf("%u scan results in %ums...\n", scanInfo.index, GetTickCount() - ticks); bSuccess = true; break; case ERROR_TOO_MANY_MATCHES: @@ -1736,4 +1736,196 @@ CMDRESULT cbInstrYara(int argc, char* argv[]) else dputs("yr_compiler_create failed!"); return bSuccess ? STATUS_CONTINUE : STATUS_ERROR; +} + +struct ScanResult +{ + int64_t addr; + String ruleId; + String patternId; + String data; + + ScanResult(int64_t addr, const char* ruleId, const char* patternId, String data) //no c++11 + { + this->addr = addr; + this->ruleId = String(ruleId); + this->patternId = String(patternId); + this->data = data; + } +}; + +class ScanVector +{ +public: + ScanVector() + { + InitializeCriticalSection(&cr); + } + + ~ScanVector() + { + DeleteCriticalSection(&cr); + } + + void add(const ScanResult & r) + { + EnterCriticalSection(&cr); + v.push_back(r); + LeaveCriticalSection(&cr); + } + + void clear() + { + EnterCriticalSection(&cr); + v.clear(); + LeaveCriticalSection(&cr); + } + + const std::vector & getVector() + { + return v; + } + +private: + CRITICAL_SECTION cr; + std::vector v; +}; + +static int yaraScanCallbackVector(int message, void* message_data, void* user_data) +{ + if(message == CALLBACK_MSG_RULE_MATCHING) + { + YR_RULE* rule = (YR_RULE*)message_data; + YR_STRING* string; + yr_rule_strings_foreach(rule, string) + { + YR_MATCH* match; + yr_string_matches_foreach(string, match) + { + String pattern; + if(STRING_IS_HEX(string)) + pattern = yara_print_hex_string(match->data, match->length); + else + pattern = yara_print_string(match->data, match->length); + ((ScanVector*)user_data)->add(ScanResult(match->base + match->offset, rule->identifier, string->identifier, pattern)); + } + } + } + return ERROR_SUCCESS; +} + +CMDRESULT cbInstrYaramod(int argc, char* argv[]) +{ + if(argc < 3) + { + dputs("not enough arguments!"); + return STATUS_ERROR; + } + uint base = modbasefromname(argv[2]); + if(!base) + { + dprintf("invalid module \"%s\"!\n", argv[2]); + return STATUS_ERROR; + } + std::vector sections; + if(!modsectionsfromaddr(base, §ions)) + { + dprintf("could not get sections for module \"%s\"!\n", argv[2]); + } + + FILE* rulesFile = 0; + if(_wfopen_s(&rulesFile, StringUtils::Utf8ToUtf16(argv[1]).c_str(), L"rb")) + { + dputs("failed to open yara rules file!"); + return STATUS_ERROR; + } + + bool bSuccess = false; + YR_COMPILER* yrCompiler; + if(yr_compiler_create(&yrCompiler) == ERROR_SUCCESS) + { + yr_compiler_set_callback(yrCompiler, yaraCompilerCallback, 0); + if(yr_compiler_add_file(yrCompiler, rulesFile, NULL, argv[1]) == 0) //no errors found + { + fclose(rulesFile); + YR_RULES* yrRules; + if(yr_compiler_get_rules(yrCompiler, &yrRules) == ERROR_SUCCESS) + { + //initialize new reference tab + char modname[MAX_MODULE_SIZE] = ""; + if(!modnamefromaddr(base, modname, true)) + sprintf_s(modname, "%p", base); + String fullName; + const char* fileName = strrchr(argv[1], '\\'); + if(fileName) + fullName = fileName + 1; + else + fullName = argv[1]; + fullName += " ("; + fullName += modname; + fullName += ")"; //nanana, very ugly code (long live open source) + GuiReferenceInitialize(fullName.c_str()); + GuiReferenceAddColumn(sizeof(uint) * 2, "Address"); + GuiReferenceAddColumn(48, "Rule"); + GuiReferenceAddColumn(0, "Data"); + GuiReferenceSetRowCount(0); + GuiReferenceReloadData(); + int refindex=0; + YaraScanInfo scanInfo; + scanInfo.index = 0; + uint ticks = GetTickCount(); + int len=sections.size(); + bSuccess=true; + ScanVector scanResults; + for(int i=0; i data(size); + if(!memread(fdProcessInfo->hProcess, (const void*)addr, data(), size, 0)) + { + dprintf("failed to read memory for section \"%s\"!\n", sections.at(i).name); + continue; + } + if(yr_rules_scan_mem(yrRules, data(), size, 0, yaraScanCallbackVector, &scanResults, 0) != ERROR_SUCCESS) + bSuccess=false; + else //dump current results and clear vector + { + for(std::vector::const_iterator j=scanResults.getVector().begin(); + j!=scanResults.getVector().end(); ++j) + { + int index = refindex; + GuiReferenceSetRowCount(index + 1); + refindex++; + char addr_text[deflen] = ""; + sprintf(addr_text, fhex, j->addr+addr); + GuiReferenceSetCellContent(index, 0, addr_text); //Address + String ruleFullName = ""; + ruleFullName += j->ruleId; + ruleFullName += "."; + ruleFullName += j->patternId; + GuiReferenceSetCellContent(index, 1, ruleFullName.c_str()); //Rule + GuiReferenceSetCellContent(index, 2, j->data.c_str()); //Data + } + GuiReferenceReloadData(); + double percent = (double)i / (double)len; + GuiReferenceSetProgress((int)(percent * 100)); + scanResults.clear(); + } + } + GuiReferenceSetProgress(100); + if(bSuccess) + dprintf("%u scan results in %ums...\n", refindex, GetTickCount() - ticks); + yr_rules_destroy(yrRules); + } + else + dputs("error while getting the rules!"); + } + else + dputs("errors in the rules file!"); + yr_compiler_destroy(yrCompiler); + } + else + dputs("yr_compiler_create failed!"); + return bSuccess ? STATUS_CONTINUE : STATUS_ERROR; } \ No newline at end of file diff --git a/x64_dbg_dbg/instruction.h b/x64_dbg_dbg/instruction.h index 510970b5..c490cac2 100644 --- a/x64_dbg_dbg/instruction.h +++ b/x64_dbg_dbg/instruction.h @@ -63,5 +63,6 @@ CMDRESULT cbInstrLoopList(int argc, char* argv[]); CMDRESULT cbInstrSleep(int argc, char* argv[]); CMDRESULT cbInstrFindAsm(int argc, char* argv[]); CMDRESULT cbInstrYara(int argc, char* argv[]); +CMDRESULT cbInstrYaramod(int argc, char* argv[]); #endif // _INSTRUCTIONS_H diff --git a/x64_dbg_dbg/x64_dbg.cpp b/x64_dbg_dbg/x64_dbg.cpp index d3b65f98..efa50929 100644 --- a/x64_dbg_dbg/x64_dbg.cpp +++ b/x64_dbg_dbg/x64_dbg.cpp @@ -190,6 +190,7 @@ static void registercommands() dbgcmdnew("copystr\1strcpy", cbInstrCopystr, true); //write a string variable to memory dbgcmdnew("looplist", cbInstrLoopList, true); //list loops dbgcmdnew("yara", cbInstrYara, true); //yara test command + dbgcmdnew("yaramod", cbInstrYaramod, true); } static bool cbCommandProvider(char* cmd, int maxlen) From 8378383837ce336aef1f98807a2abcc25bb9d96e Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 15:04:04 +0200 Subject: [PATCH 103/106] DBG: fixed yaramod command --- x64_dbg_dbg/instruction.cpp | 191 +++--------------------------------- 1 file changed, 12 insertions(+), 179 deletions(-) diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index 90db7e2d..8a097c97 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -1650,7 +1650,7 @@ static int yaraScanCallback(int message, void* message_data, void* user_data) CMDRESULT cbInstrYara(int argc, char* argv[]) { - if(argc < 2) //yara rulesFile, addr_of_mempage + if(argc < 2) //yara rulesFile, addr_of_mempage, size_of_scan { dputs("not enough arguments!"); return STATUS_ERROR; @@ -1659,7 +1659,13 @@ CMDRESULT cbInstrYara(int argc, char* argv[]) if(argc < 3 || !valfromstring(argv[2], &addr)) addr = GetContextDataEx(hActiveThread, UE_CIP); uint size = 0; - uint base = memfindbaseaddr(addr, &size); + if(argc >= 4) + if(!valfromstring(argv[3], &size)) + size = 0; + if(!size) + addr = memfindbaseaddr(addr, &size); + uint base=addr; + dprintf("%p[%p]\n",base,size); Memory data(size); if(!memread(fdProcessInfo->hProcess, (const void*)base, data(), size, 0)) { @@ -1738,82 +1744,6 @@ CMDRESULT cbInstrYara(int argc, char* argv[]) return bSuccess ? STATUS_CONTINUE : STATUS_ERROR; } -struct ScanResult -{ - int64_t addr; - String ruleId; - String patternId; - String data; - - ScanResult(int64_t addr, const char* ruleId, const char* patternId, String data) //no c++11 - { - this->addr = addr; - this->ruleId = String(ruleId); - this->patternId = String(patternId); - this->data = data; - } -}; - -class ScanVector -{ -public: - ScanVector() - { - InitializeCriticalSection(&cr); - } - - ~ScanVector() - { - DeleteCriticalSection(&cr); - } - - void add(const ScanResult & r) - { - EnterCriticalSection(&cr); - v.push_back(r); - LeaveCriticalSection(&cr); - } - - void clear() - { - EnterCriticalSection(&cr); - v.clear(); - LeaveCriticalSection(&cr); - } - - const std::vector & getVector() - { - return v; - } - -private: - CRITICAL_SECTION cr; - std::vector v; -}; - -static int yaraScanCallbackVector(int message, void* message_data, void* user_data) -{ - if(message == CALLBACK_MSG_RULE_MATCHING) - { - YR_RULE* rule = (YR_RULE*)message_data; - YR_STRING* string; - yr_rule_strings_foreach(rule, string) - { - YR_MATCH* match; - yr_string_matches_foreach(string, match) - { - String pattern; - if(STRING_IS_HEX(string)) - pattern = yara_print_hex_string(match->data, match->length); - else - pattern = yara_print_string(match->data, match->length); - ((ScanVector*)user_data)->add(ScanResult(match->base + match->offset, rule->identifier, string->identifier, pattern)); - } - } - } - return ERROR_SUCCESS; -} - CMDRESULT cbInstrYaramod(int argc, char* argv[]) { if(argc < 3) @@ -1827,105 +1757,8 @@ CMDRESULT cbInstrYaramod(int argc, char* argv[]) dprintf("invalid module \"%s\"!\n", argv[2]); return STATUS_ERROR; } - std::vector sections; - if(!modsectionsfromaddr(base, §ions)) - { - dprintf("could not get sections for module \"%s\"!\n", argv[2]); - } - - FILE* rulesFile = 0; - if(_wfopen_s(&rulesFile, StringUtils::Utf8ToUtf16(argv[1]).c_str(), L"rb")) - { - dputs("failed to open yara rules file!"); - return STATUS_ERROR; - } - - bool bSuccess = false; - YR_COMPILER* yrCompiler; - if(yr_compiler_create(&yrCompiler) == ERROR_SUCCESS) - { - yr_compiler_set_callback(yrCompiler, yaraCompilerCallback, 0); - if(yr_compiler_add_file(yrCompiler, rulesFile, NULL, argv[1]) == 0) //no errors found - { - fclose(rulesFile); - YR_RULES* yrRules; - if(yr_compiler_get_rules(yrCompiler, &yrRules) == ERROR_SUCCESS) - { - //initialize new reference tab - char modname[MAX_MODULE_SIZE] = ""; - if(!modnamefromaddr(base, modname, true)) - sprintf_s(modname, "%p", base); - String fullName; - const char* fileName = strrchr(argv[1], '\\'); - if(fileName) - fullName = fileName + 1; - else - fullName = argv[1]; - fullName += " ("; - fullName += modname; - fullName += ")"; //nanana, very ugly code (long live open source) - GuiReferenceInitialize(fullName.c_str()); - GuiReferenceAddColumn(sizeof(uint) * 2, "Address"); - GuiReferenceAddColumn(48, "Rule"); - GuiReferenceAddColumn(0, "Data"); - GuiReferenceSetRowCount(0); - GuiReferenceReloadData(); - int refindex=0; - YaraScanInfo scanInfo; - scanInfo.index = 0; - uint ticks = GetTickCount(); - int len=sections.size(); - bSuccess=true; - ScanVector scanResults; - for(int i=0; i data(size); - if(!memread(fdProcessInfo->hProcess, (const void*)addr, data(), size, 0)) - { - dprintf("failed to read memory for section \"%s\"!\n", sections.at(i).name); - continue; - } - if(yr_rules_scan_mem(yrRules, data(), size, 0, yaraScanCallbackVector, &scanResults, 0) != ERROR_SUCCESS) - bSuccess=false; - else //dump current results and clear vector - { - for(std::vector::const_iterator j=scanResults.getVector().begin(); - j!=scanResults.getVector().end(); ++j) - { - int index = refindex; - GuiReferenceSetRowCount(index + 1); - refindex++; - char addr_text[deflen] = ""; - sprintf(addr_text, fhex, j->addr+addr); - GuiReferenceSetCellContent(index, 0, addr_text); //Address - String ruleFullName = ""; - ruleFullName += j->ruleId; - ruleFullName += "."; - ruleFullName += j->patternId; - GuiReferenceSetCellContent(index, 1, ruleFullName.c_str()); //Rule - GuiReferenceSetCellContent(index, 2, j->data.c_str()); //Data - } - GuiReferenceReloadData(); - double percent = (double)i / (double)len; - GuiReferenceSetProgress((int)(percent * 100)); - scanResults.clear(); - } - } - GuiReferenceSetProgress(100); - if(bSuccess) - dprintf("%u scan results in %ums...\n", refindex, GetTickCount() - ticks); - yr_rules_destroy(yrRules); - } - else - dputs("error while getting the rules!"); - } - else - dputs("errors in the rules file!"); - yr_compiler_destroy(yrCompiler); - } - else - dputs("yr_compiler_create failed!"); - return bSuccess ? STATUS_CONTINUE : STATUS_ERROR; + uint size = modsizefromaddr(base); + char newcmd[deflen]=""; + sprintf_s(newcmd, "yara \"%s\",%p,%p", argv[1], base, size); + return cmddirectexec(dbggetcommandlist(), newcmd); } \ No newline at end of file From b6fd21f75291ba992b48de454612e9dd2439d80e Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 16:47:42 +0200 Subject: [PATCH 104/106] GUI: added Yara in the Gui of x64_dbg --- .../Project/Src/Gui/CPUDisassembly.cpp | 19 ++++ x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h | 2 + x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 20 ++++ x64_dbg_gui/Project/Src/Gui/CPUDump.h | 2 + x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 2 + x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp | 18 ++++ x64_dbg_gui/Project/Src/Gui/MemoryMapView.h | 3 + x64_dbg_gui/Project/Src/Gui/SymbolView.cpp | 16 +++ x64_dbg_gui/Project/Src/Gui/SymbolView.h | 3 + .../Src/Gui/YaraRuleSelectionDialog.cpp | 75 ++++++++++++++ .../Project/Src/Gui/YaraRuleSelectionDialog.h | 33 ++++++ .../Src/Gui/YaraRuleSelectionDialog.ui | 95 ++++++++++++++++++ .../Project/Src/Utils/Configuration.cpp | 1 + x64_dbg_gui/Project/images/yara.png | Bin 0 -> 8978 bytes x64_dbg_gui/Project/resource.qrc | 1 + x64_dbg_gui/Project/x64_dbg.pro | 9 +- 16 files changed, 296 insertions(+), 3 deletions(-) create mode 100644 x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.cpp create mode 100644 x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.h create mode 100644 x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.ui create mode 100644 x64_dbg_gui/Project/images/yara.png diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp index 20fb9492..789ed713 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp @@ -6,6 +6,7 @@ #include "LineEditDialog.h" #include "WordEditDialog.h" #include "HexEditDialog.h" +#include "YaraRuleSelectionDialog.h" CPUDisassembly::CPUDisassembly(QWidget* parent) : Disassembly(parent) { @@ -248,6 +249,7 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event) wMenu->addAction(mAssemble); wMenu->addAction(mPatchesAction); + wMenu->addAction(mYaraAction); wMenu->addSeparator(); @@ -404,6 +406,11 @@ void CPUDisassembly::setupRightClickContextMenu() mPatchesAction->setShortcutContext(Qt::WidgetShortcut); connect(mPatchesAction, SIGNAL(triggered()), this, SLOT(showPatchesSlot())); + mYaraAction = new QAction(QIcon(":/icons/images/yara.png"), "&Yara...", this); + mYaraAction->setShortcutContext(Qt::WidgetShortcut); + this->addAction(mYaraAction); + connect(mYaraAction, SIGNAL(triggered()), this, SLOT(yaraSlot())); + //-------------------------------------------------------------------- //---------------------- New origin here ----------------------------- @@ -545,6 +552,7 @@ void CPUDisassembly::refreshShortcutsSlot() mAssemble->setShortcut(ConfigShortcut("ActionAssemble")); mToggleInt3BpAction->setShortcut(ConfigShortcut("ActionToggleBreakpoint")); mPatchesAction->setShortcut(ConfigShortcut("ViewPatches")); + mYaraAction->setShortcut(ConfigShortcut("ActionYara")); mSetNewOriginHere->setShortcut(ConfigShortcut("ActionSetNewOriginHere")); mGotoOrigin->setShortcut(ConfigShortcut("ActionGotoOrigin")); mGotoPrevious->setShortcut(ConfigShortcut("ActionGotoPrevious")); @@ -1143,6 +1151,17 @@ void CPUDisassembly::showPatchesSlot() emit showPatches(); } +void CPUDisassembly::yaraSlot() +{ + YaraRuleSelectionDialog yaraDialog(this); + if(yaraDialog.exec() == QDialog::Accepted) + { + QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + DbgCmdExec(QString("yara \"%0\",%1").arg(yaraDialog.getSelectedFile()).arg(addrText).toUtf8().constData()); + emit displayReferencesWidget(); + } +} + void CPUDisassembly::copySelection(bool copyBytes) { QList instBuffer; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h index b9f8f475..612b5d7d 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.h @@ -63,6 +63,7 @@ public slots: void binaryPasteIgnoreSizeSlot(); void undoSelectionSlot(); void showPatchesSlot(); + void yaraSlot(); void copySelection(); void copySelectionNoBytes(); void copyAddress(); @@ -115,6 +116,7 @@ private: QAction* mSearchPattern; QAction* mEnableHighlightingMode; QAction* mPatchesAction; + QAction* mYaraAction; QAction* mCopySelection; QAction* mCopySelectionNoBytes; QAction* mCopyAddress; diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index 7f05567f..d9db978b 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -5,6 +5,7 @@ #include "Bridge.h" #include "LineEditDialog.h" #include "HexEditDialog.h" +#include "YaraRuleSelectionDialog.h" CPUDump::CPUDump(QWidget* parent) : HexDump(parent) { @@ -232,6 +233,12 @@ void CPUDump::setupContextMenu() this->addAction(mFindPatternAction); connect(mFindPatternAction, SIGNAL(triggered()), this, SLOT(findPattern())); + //Yara + mYaraAction = new QAction(QIcon(":/icons/images/yara.png"), "&Yara...", this); + mYaraAction->setShortcutContext(Qt::WidgetShortcut); + this->addAction(mYaraAction); + connect(mYaraAction, SIGNAL(triggered()), this, SLOT(yaraSlot())); + //Find References mFindReferencesAction = new QAction("Find &References", this); mFindReferencesAction->setShortcutContext(Qt::WidgetShortcut); @@ -362,6 +369,7 @@ void CPUDump::refreshShortcutsSlot() mFindPatternAction->setShortcut(ConfigShortcut("ActionFindPattern")); mFindReferencesAction->setShortcut(ConfigShortcut("ActionFindReferences")); mGotoExpression->setShortcut(ConfigShortcut("ActionGotoExpression")); + mYaraAction->setShortcut(ConfigShortcut("ActionYara")); } QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h) @@ -464,6 +472,7 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event) wMenu->addAction(mSetLabelAction); wMenu->addMenu(mBreakpointMenu); wMenu->addAction(mFindPatternAction); + wMenu->addAction(mYaraAction); wMenu->addMenu(mGotoMenu); wMenu->addSeparator(); wMenu->addMenu(mHexMenu); @@ -1322,3 +1331,14 @@ void CPUDump::selectionUpdatedSlot() QString selEnd = QString("%1").arg(rvaToVa(getSelectionEnd()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); GuiAddStatusBarMessage(QString("Dump: " + selStart + " -> " + selEnd + QString().sprintf(" (0x%.8X bytes)\n", getSelectionEnd() - getSelectionStart() + 1)).toUtf8().constData()); } + +void CPUDump::yaraSlot() +{ + YaraRuleSelectionDialog yaraDialog(this); + if(yaraDialog.exec() == QDialog::Accepted) + { + QString addrText = QString("%1").arg(rvaToVa(getInitialSelection()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + DbgCmdExec(QString("yara \"%0\",%1").arg(yaraDialog.getSelectedFile()).arg(addrText).toUtf8().constData()); + emit displayReferencesWidget(); + } +} diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.h b/x64_dbg_gui/Project/Src/Gui/CPUDump.h index 99d58c0d..dc8a837c 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.h @@ -78,6 +78,7 @@ public slots: void findReferencesSlot(); void selectionUpdatedSlot(); + void yaraSlot(); private: QMenu* mBreakpointMenu; @@ -158,6 +159,7 @@ private: QAction* mBinaryPasteIgnoreSizeAction; QAction* mFindPatternAction; QAction* mFindReferencesAction; + QAction* mYaraAction; QAction* mUndoSelection; QMenu* mSpecialMenu; diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 10284053..626ebf4b 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -77,6 +77,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi // Memory Map View mMemMapView = new MemoryMapView(); connect(mMemMapView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget())); + connect(mMemMapView, SIGNAL(showReferences()), this, SLOT(displayReferencesWidget())); mMemMapView->setWindowTitle("Memory Map"); mMemMapView->setWindowIcon(QIcon(":/icons/images/memory-map.png")); mMemMapView->hide(); @@ -168,6 +169,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi connect(ui->actionCpu, SIGNAL(triggered()), this, SLOT(displayCpuWidget())); connect(ui->actionSymbolInfo, SIGNAL(triggered()), this, SLOT(displaySymbolWidget())); connect(mSymbolView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget())); + connect(mSymbolView, SIGNAL(showReferences()), this, SLOT(displayReferencesWidget())); connect(mReferenceManager, SIGNAL(showCpu()), this, SLOT(displayCpuWidget())); connect(ui->actionReferences, SIGNAL(triggered()), this, SLOT(displayReferencesWidget())); connect(ui->actionThreads, SIGNAL(triggered()), this, SLOT(displayThreadsWidget())); diff --git a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp index 92ca43f2..d88122ac 100644 --- a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.cpp @@ -2,6 +2,7 @@ #include "Configuration.h" #include "Bridge.h" #include "PageMemoryRights.h" +#include "YaraRuleSelectionDialog.h" MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent) { @@ -37,6 +38,10 @@ void MemoryMapView::setupContextMenu() connect(mFollowDisassembly, SIGNAL(triggered()), this, SLOT(followDisassemblerSlot())); connect(this, SIGNAL(enterPressedSignal()), this, SLOT(followDisassemblerSlot())); + //Yara + mYara = new QAction(QIcon(":/icons/images/yara.png"), "&Yara...", this); + connect(mYara, SIGNAL(triggered()), this, SLOT(yaraSlot())); + //Set PageMemory Rights mPageMemoryRights = new QAction("Set Page Memory Rights", this); connect(mPageMemoryRights, SIGNAL(triggered()), this, SLOT(pageMemoryRights())); @@ -109,6 +114,7 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos) QMenu* wMenu = new QMenu(this); //create context menu wMenu->addAction(mFollowDisassembly); wMenu->addAction(mFollowDump); + wMenu->addAction(mYara); wMenu->addAction(mSwitchView); wMenu->addSeparator(); wMenu->addAction(mPageMemoryRights); @@ -301,6 +307,18 @@ void MemoryMapView::followDisassemblerSlot() emit showCpu(); } +void MemoryMapView::yaraSlot() +{ + YaraRuleSelectionDialog yaraDialog(this); + if(yaraDialog.exec() == QDialog::Accepted) + { + QString addr_text = getCellContent(getInitialSelection(), 0); + QString size_text = getCellContent(getInitialSelection(), 1); + DbgCmdExec(QString("yara \"%0\",%1,%2").arg(yaraDialog.getSelectedFile()).arg(addr_text).arg(size_text).toUtf8().constData()); + emit showReferences(); + } +} + void MemoryMapView::memoryAccessSingleshootSlot() { QString addr_text = getCellContent(getInitialSelection(), 0); diff --git a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h index 1d7e4e37..2e64c810 100644 --- a/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h +++ b/x64_dbg_gui/Project/Src/Gui/MemoryMapView.h @@ -13,12 +13,14 @@ public: signals: void showCpu(); + void showReferences(); public slots: void refreshShortcutsSlot(); void stateChangedSlot(DBGSTATE state); void followDumpSlot(); void followDisassemblerSlot(); + void yaraSlot(); void memoryAccessSingleshootSlot(); void memoryAccessRestoreSlot(); void memoryWriteSingleshootSlot(); @@ -37,6 +39,7 @@ private: QAction* mFollowDump; QAction* mFollowDisassembly; + QAction* mYara; QAction* mSwitchView; QAction* mPageMemoryRights; diff --git a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp index 8e96cb3e..0fcf3232 100644 --- a/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/SymbolView.cpp @@ -3,6 +3,7 @@ #include #include "Configuration.h" #include "Bridge.h" +#include "YaraRuleSelectionDialog.h" SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView) { @@ -123,6 +124,9 @@ void SymbolView::setupContextMenu() mCopyPathAction = new QAction("Copy File &Path", this); connect(mCopyPathAction, SIGNAL(triggered()), this, SLOT(moduleCopyPath())); + mYaraAction = new QAction(QIcon(":/icons/images/yara.png"), "&Yara...", this); + connect(mYaraAction, SIGNAL(triggered()), this, SLOT(moduleYara())); + //Shortcuts refreshShortcutsSlot(); connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot())); @@ -244,6 +248,7 @@ void SymbolView::moduleContextMenu(const QPoint & pos) char szModPath[MAX_PATH] = ""; if(DbgFunctions()->ModPathFromAddr(modbase, szModPath, _countof(szModPath))) wMenu->addAction(mCopyPathAction); + wMenu->addAction(mYaraAction); QMenu wCopyMenu("&Copy", this); mModuleList->setupCopyMenu(&wCopyMenu); if(wCopyMenu.actions().length()) @@ -274,6 +279,17 @@ void SymbolView::moduleCopyPath() Bridge::CopyToClipboard(szModPath); } +void SymbolView::moduleYara() +{ + QString modname = mModuleList->getCellContent(mModuleList->getInitialSelection(), 1); + YaraRuleSelectionDialog yaraDialog(this); + if(yaraDialog.exec() == QDialog::Accepted) + { + DbgCmdExec(QString("yara \"%0\",\"%1\"").arg(yaraDialog.getSelectedFile()).arg(modname).toUtf8().constData()); + emit showReferences(); + } +} + void SymbolView::moduleDownloadSymbols() { DbgCmdExec(QString("symdownload " + mModuleList->getCellContent(mModuleList->getInitialSelection(), 1)).toUtf8().constData()); diff --git a/x64_dbg_gui/Project/Src/Gui/SymbolView.h b/x64_dbg_gui/Project/Src/Gui/SymbolView.h index b421b14a..02d45fd3 100644 --- a/x64_dbg_gui/Project/Src/Gui/SymbolView.h +++ b/x64_dbg_gui/Project/Src/Gui/SymbolView.h @@ -34,12 +34,14 @@ private slots: void moduleDownloadSymbols(); void moduleDownloadAllSymbols(); void moduleCopyPath(); + void moduleYara(); void toggleBreakpoint(); void toggleBookmark(); void refreshShortcutsSlot(); signals: void showCpu(); + void showReferences(); private: Ui::SymbolView* ui; @@ -58,6 +60,7 @@ private: QAction* mDownloadSymbolsAction; QAction* mDownloadAllSymbolsAction; QAction* mCopyPathAction; + QAction* mYaraAction; static void cbSymbolEnum(SYMBOLINFO* symbol, void* user); }; diff --git a/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.cpp b/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.cpp new file mode 100644 index 00000000..444bcd71 --- /dev/null +++ b/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.cpp @@ -0,0 +1,75 @@ +#include "YaraRuleSelectionDialog.h" +#include "ui_YaraRuleSelectionDialog.h" +#include +#include +#include +#include +#include "Imports.h" + +YaraRuleSelectionDialog::YaraRuleSelectionDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::YaraRuleSelectionDialog) +{ + 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 + + char setting[MAX_SETTING_SIZE]=""; + if(BridgeSettingGet("Misc", "YaraRulesDirectory", setting)) + { + rulesDirectory = QString(setting); + enumRulesDirectory(); + } +} + +YaraRuleSelectionDialog::~YaraRuleSelectionDialog() +{ + delete ui; +} + +QString YaraRuleSelectionDialog::getSelectedFile() +{ + return selectedFile; +} + +void YaraRuleSelectionDialog::on_buttonDirectory_clicked() +{ + QString dir = QFileDialog::getExistingDirectory(this, "Select Yara Rules Directory..."); + if(!dir.length()) + return; + rulesDirectory = QDir::toNativeSeparators(dir); + BridgeSettingSet("Misc", "YaraRulesDirectory", dir.toUtf8().constData()); + enumRulesDirectory(); +} + +void YaraRuleSelectionDialog::on_buttonFile_clicked() +{ + QString file = QFileDialog::getOpenFileName(this, "Select Yara Rule...", rulesDirectory); + if(!file.length()) + return; + selectedFile = QDir::toNativeSeparators(file); + this->accept(); +} + +void YaraRuleSelectionDialog::on_buttonSelect_clicked() +{ + int selectedIndex=ui->listRules->row(ui->listRules->selectedItems().at(0)); + selectedFile = ruleFiles.at(selectedIndex).first; + this->accept(); +} + +void YaraRuleSelectionDialog::enumRulesDirectory() +{ + ruleFiles.clear(); + ui->listRules->clear(); + QDirIterator it(rulesDirectory, QDir::Files, QDirIterator::Subdirectories); + while(it.hasNext()) + { + it.next(); + ruleFiles.append(QPair(QDir::toNativeSeparators(it.filePath()), it.fileName())); + ui->listRules->addItem(it.fileName()); + } + ui->listRules->setCurrentRow(0); +} diff --git a/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.h b/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.h new file mode 100644 index 00000000..7414a393 --- /dev/null +++ b/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.h @@ -0,0 +1,33 @@ +#ifndef YARARULESELECTIONDIALOG_H +#define YARARULESELECTIONDIALOG_H + +#include + +namespace Ui { +class YaraRuleSelectionDialog; +} + +class YaraRuleSelectionDialog : public QDialog +{ + Q_OBJECT + +public: + explicit YaraRuleSelectionDialog(QWidget *parent = 0); + ~YaraRuleSelectionDialog(); + QString getSelectedFile(); + +private slots: + void on_buttonDirectory_clicked(); + void on_buttonFile_clicked(); + void on_buttonSelect_clicked(); + +private: + Ui::YaraRuleSelectionDialog *ui; + QList> ruleFiles; + QString rulesDirectory; + QString selectedFile; + + void enumRulesDirectory(); +}; + +#endif // YARARULESELECTIONDIALOG_H diff --git a/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.ui b/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.ui new file mode 100644 index 00000000..6ecc259b --- /dev/null +++ b/x64_dbg_gui/Project/Src/Gui/YaraRuleSelectionDialog.ui @@ -0,0 +1,95 @@ + + + YaraRuleSelectionDialog + + + + 0 + 0 + 341 + 361 + + + + Yara + + + + :/icons/images/yara.png:/icons/images/Yara.png + + + + + 10 + 10 + 322 + 341 + + + + + + + + + + + + + 0 + 0 + + + + Directory... + + + + + + + &File... + + + + + + + &Select + + + + + + + &Cancel + + + + + + + + + + + + + + buttonCancel + clicked() + YaraRuleSelectionDialog + reject() + + + 341 + 280 + + + 361 + 246 + + + + + diff --git a/x64_dbg_gui/Project/Src/Utils/Configuration.cpp b/x64_dbg_gui/Project/Src/Utils/Configuration.cpp index 8ed1e346..c1365a7e 100644 --- a/x64_dbg_gui/Project/Src/Utils/Configuration.cpp +++ b/x64_dbg_gui/Project/Src/Utils/Configuration.cpp @@ -241,6 +241,7 @@ Configuration::Configuration() : QObject() defaultShortcuts.insert("ActionSetComment", Shortcut(tr("Actions -> Set Comment"), ";")); defaultShortcuts.insert("ActionToggleFunction", Shortcut(tr("Actions -> Toggle Function"), "Shift+F")); defaultShortcuts.insert("ActionAssemble", Shortcut(tr("Actions -> Assemble"), "Space")); + defaultShortcuts.insert("ActionYara", Shortcut(tr("Actions -> Yara"), "Ctrl+Y")); defaultShortcuts.insert("ActionSetNewOriginHere", Shortcut(tr("Actions -> Set New Origin Here"), "Ctrl+*")); defaultShortcuts.insert("ActionGotoOrigin", Shortcut(tr("Actions -> Goto Origin"), "*")); defaultShortcuts.insert("ActionGotoPrevious", Shortcut(tr("Actions -> Goto Previous"), "-")); diff --git a/x64_dbg_gui/Project/images/yara.png b/x64_dbg_gui/Project/images/yara.png new file mode 100644 index 0000000000000000000000000000000000000000..ecac5a43e3eeac8152e00925be30b53bca44f04b GIT binary patch literal 8978 zcmaKQbzEEB(r!p`4HVZDEA9@#okGzi_uTzUviF`m^Q>93X3w5kAJx?qa4^X+0RRAwlA^38;{5aP7abMxTcKB(jX06H z%jvmmIa#}VnYmg4q%57xt-wkSW;RxuR%VtyF8x+w0KhX^TWvjeJ=Iqt7ETTvW`8jp z-VV+PZ2&+_!rR%*!p_PaY;I*^>ju2x#UYT6dQ zb{4{xv=ZWAF>etBfrFL18Q9yw-qB6O8$$aJuL$D$ub7h-{13$44nq4sM(L@lgJqmt zt-$;oyzCZS+}vOR0S<0HegOe)HZTttHxDNl;v>M$%_qVyAi^UE{?|c^7|qqvT0~P; z{$FDu?jW>KcXwwIPEIc`FAgtW4kuR|PHtgg;lCU_JnRSryPJ=ryO}q;qZ{478Dy>8 zEL?4!-EEy5!G9Ue%$+>kA+!if|7Qvg&i|oxbo-Z^5Dw$?Hgo3W=HU7}rGEoeRsa7` z2Z#Tl-P|>;{@33BC$XEhkFyo0rj?tMhpPo*;jHQY4&^K&<7#E*?&PZNu4=h)Z6IhhK(ISYAf%-@39+79I{(j_&`~wftXQ{{O1`HxwM45hKf5 zx!QVKS<1UQIe`C}vWV?}w}t1w^8HKK^1s`{`(JfA5yo)-UD*F?q5myHM9<&L|AZ~# z=0AaN<%o!OS43Dl3rL#+05tEFWTmvd=MS?m47K{M`gRxv>En<)X@Or+WThNF%@itX zj4O|qdh}JyG_OvSetTVJlwC1hT2+6mYfy2!s4nGFVt`VkJk1hWAmW(?Bk)T|qtZ+Kc&4EJcE%|8t0Z;58ECX!>&4(E)<>4n4onZ#Gb%EQ6G2~V z+SC^TGHfjuV1>j)xe+Cahcdp0H%uD2dtuRUR8TTpE&pWnxUCr__8OYhjmVX#SBLhF zE@9WBzaVDUYx4i|VU|Epm6Ca;IER$n<{g0ibmk5juV{^R~y6hlsUl*rZHepnak5-fQi*dg0&(eoajp! z1)k86ziVTs0K-53YG~76j+L^&rDkVXjRw<+l|saCR&BWCZj&|g3qDs@V`OcOey&p? z2$SWyAJ(q=e)1)RIYhEt*~O(sGRlG#Rcdr-En#n%5l0z2yWW{7^#yu2BZyJpgdnL{ zPc>^IRSd0G;;e5|I2o(EO3B|G^^nm0(1+?32>JIw$9ioXw1dQ?@sczFw+RXE{sW*~ zIDzDf1b_hm=*WQ2xD&w3A!DwG$DU1TDum&HgE8@5gXqh6j_S2UtlO>TNNEi{rC9w73yHis?4HlfWo z)RILRj~{Md(`kj194Y5`>}~8(P*W)#q5_eiQp;xnR0EG3rwn92_t&}T2?z4K4Grop z%JMc^x}?Ct!_49V<#<~{-7GkeN;E9Fcms0y<(aNZ63%*Q|G|YCIl)dqA+MsuK;~xVH&VI-12Veq0g3M<7v& zOA5}n%;J-*iEmaG>ivPjkw;rI%#7|dd;EBB7e&NPF zx}$%BB>`ofmzQk{DU8b`Gjhj+c>^cb5&uX@P?yRvEuicm0S5E8#+4vspdLKadR>A{ zZOEOnmkTP6Ur@SR^JNL0{%(Y-T8(^+pJl&jr^QH(xn!a4nbep*Jxf!kqjjE*z3MC3 zhT7T=Y1?48#grVM*xlPKN?V3o=cpKIX1~+VX>Cau{pL05_c2t^p%3^>dQ8Zy-(J9^ zb5Yrsx%wJrj{}+_0zU?L9!DzP6%X|+l8?Wu!xk%P=)WtQ_I#e6=ueH8JE2(zC+PR9 zsbLagLT8)qUHzraCY(PodETe5ES~M53g^tftShfWui+!dS=XQ)_e)q17LH?$rc73t z^betju8>M%!B(HD6{}yGi3;tCVN5BJ3+jKv%%~ji{lE-Uln@Z#U^^`3_Z~h;l1>Aavu3UIOn4Xs&EA0-! z2j9{TKYN?hpVn!{Y+CR30}9i=rgyi#&R)tt-6*5f7DlS8;rhi!l!|JaAbCNX%epf$ z84&yQ=*Op)#(ar~J=oGO!-ez15;pdh(#6FE<1B`wqZo{z*sV!NbTCZFaK{IV%CALSY1GxZ!-VR#Az2(l6XQ zfnDW9teW0qp&1hA4bVVhANC+EGf2e-w8fU{BVUGQ|D`QG5IV{=3 za=6??_w{bCcBw?PjWp`nYtqjK#R-g~^5^p?CSLen;b^9S1$0ZBiOO*py(so9MYRwg zUpil~DTpNfGEx|w5ozufIHmS$x2z6p;(Ke}cj&(L&8xhY6G&VbKNx`>0Yr9-R8}{i z=<`xUoR{bdOikG~Is!z#x zU2+e*;oqYjgn$f8dUd8D>)(``yU9q6G({IO>q&P4Z*)Y@JJQO4|5!D6^S?GI2~TDwq#31MmSTbdu0B-K{QLZ&j&a59@lFm9$jfSiHsp=8+GTzc%i+9L?k;7`1+OE z!1tT&B5%DzO<$GucX+^>Tc~kWwP$P_u~Ta3%8H)Ifz}?}E=^V{K0?22&q7)d;~BevyW(nO;rfm}euFtU#H?(1kv9hh-|$ zMe>kNzOcn9U|v;Zpu#V7vBfGQNtO)-Suwg~pE321U^pJ4oG?y6^x3#|z&G(Id-3IJ zHmF`JEsn$KFpznhbS4zvCC_30lA8_HOtZb$t@+x&YnA(3Q@05C$}-#{Jh<29Wt%bUeIRX~)khk;fc1%4>sgZgQVAEsJYfRS^&I zBS}7c?a1GbJlgg{k?r-d9`|RwR~p#`Kt>!%H%dok}Xpt zu{QwD9KU`RD*yE9gPY!tzwyFq2EA&zBqz_kvJY4zaNUVp2?JwE5={J~f8j1LR34W% z)w8BIccmrtxgs%LsM>58N=QT_$muD=lrwSHD! z){4&39xzH%MT!dK=GCuA?gvW(ICX3&p4RXR@KQXVdv5eYrcl0;zTV3+1$_uVmj0ol zJ+mOceG^UH7+M;oxceq>fPg_0PTYccr7rl!GoQ~iwNDCAwQ`^%7e5QH(*ppJU;xw~ zu@n*ybYJ+7_7enR5|y}c0I#vij5D}!V=M9u+HfR%20YK}e&v;}N&)B&HrRT;;t{lK?;bQ0ve`G{fV`LYH3>9)US?75Knl>U!Lxm?l zJ?C8tI!xL^6a$Qg&E6dwzrqJ;42onRPS1puKysOe19MkW zvhP~AFHv6`G!AS_qwv<4V2)<(_0DMHV)HFfHI&kX6AF>GajqT4Z4;6^iwb#8$v05T zK+h}@)nE+saPu-|y8vG+t&gQhgT>7i0bmf|UnQ(0_zEkkr!?3Q zVA|M%G_}Rz?sl-cOWeSgh|eqSVUZuOctGlWTL`a6QD%o7i>qpsW!W) z>5&2DO<%f%ed>48@|7$qFR5xh4GkAx{B%Lo`!3GTTs}-;sMq26(>#4cuwwZrS%mLo z9~+Wef;~d=p&-3}7!OObx1D7P+Uu$Y2r_!Q#mwNm9 ziqk9J;zs?D?$}5t9ZkYtUU)NtqJ?Nq;PvKbJ`vW7e639MN*3`yV9EtSCXx2sWYRUAX3xi5Dy z%i11mmrO29Vn^+aLp(VV>E6J&d8WkQ_ ze}=Z}P37FPAzgJJtx&x{Xa_BDQ4`If^h+%~g%kb^&s?A+?oU{dF*kVdn--+ENxokT z!qX{EN>_77zZGVamtXyWpV2{R%M!P)Wiv;KtKi6q;mCb=cS6~gu{3Dh?m^qEOKznS zufCQo%f+;ZHK3w{-Ek~y(}nd@MIfx;5Swq zIggV=8`<#?JAPe&>iRMR%QR%23L_OfjH20V{mVmww~|uJpj6i+33D4TMerd(Ns*rAS-dC;nukH=a5^Y*!NGqhm2as{T;EvLH=77LniIpJ&$fp5gUy ztAJ-&K3I>viZDVLC#_h(bW(dQ-tZ-vH|WRy(Cx(}O-eEo?U^5LVPxbx9HwnTB^e08 z!gK{XqM;xXyBzgma3%4N?OTtt+gOaIXlNbHBJp*kuxXh(!7MPYz9 zJzBRvvD(*nc5DyDKpk}WeZy`4bS0R3yt<51VEFsq-jD;S?rR1wJR3z*A1VwQCdx%Cn%l-B<^+=i~RbNcb1tnenQ~n(oLuAg|yUfmjpOC2e?Swb_S4og_NsQO0M%X0SM*fO*`jpBMlx zdQeVB0H_OwB8&uh&$4Ib#q$TbpQkyY*OnNw361YoSwu=_LiJq_5a0(wzbJV21M6S; z63PS;8?}$PI*Ju^*!N*|>Jd{#ePd;|ePulZ zXR4%o$=N(>5W((KS@r$iyf-ug?xwP5mQe8ScR?eO!@{>9!}IGEc4M*QnWKdl{6P{P z1DjS=--z0^PcDx#1b@ApnDBkbf-@xdTP`*S_H7|{J#%y4#xFHL63>)+wBgWtTVEe7 zG{hzjZpCnB1o|I!1_x&fE_-ii&lVSF6m72MkdYaa?TpA9w*=B1%I$c1x%o|$>XZ## z_r?@1l^U|9aMHLOUO(raGMKGS&P974P3e;-h1Ol6=iT^`p?-GZo9KwEsomXmfK624 zNbZWXLA_YSsE*r0Q-GhKOgrAmqVTWOmDxpN|A)(@=8?Cv?}H?~t`6T`Qu%ewe+!5f zcDx*(tnIJ3Uh#AKRY4&**Son=hbNIqLb@8%|G|yu<9wa)pUD9t8Fr)kqPff;JzLA) zAuU}L-eTW-kiU9f?!$zhpIy=BccFx05s{4i;_N^Ykd!jq zlDfMa);tk9scGVSI^3DWqXO~Q3mc?Lk@)VzH?{p(3mq2<5b^aq`M!YdY2ReMTu@M; zF*oc1eJOrTEBKN%@vQK5RA`QP0HY=|yzXS8PlfPsuEv5*&0zQh6>m3|px#l2xu3at zHom3{o2t{}3HD5;!Eu?=;jpPoKkPFW0Y>x1^$Og;n(=nD0ZW7Tr083qN_hQx8n3ng z+ZFDVpr;3Dfa34i>aqAx#@Cs_^*v70g*F?vm&INe2B?#@W|O`BLSnoE5TXIhh&w#$ zkIsKclqkNdk6nc!8#S%Qi94=$>(o^gY;;QaFt(vxz7g@A`WZdlPJu6Ke|Zrro_;On zY0af`du@;Vg|hv4rR621Zk_YmxGLE1`hPDNZ%(R9KkONqCzE*#`)WZ$%3xl%+67Y(SkEQ$&S@ zKmE$_=OKBbp6xScG!ehMn0%}2v}hl?(mq|gvxYhgVSB6eTJhBsb6WF8R=SA8Eyu&o z!Av<>qsgsX*cPy+dl-Ryy$?SH5$XsbZXJ<+LzRWLw&T~A8 zjrL!jHDT|OzCF(?I3J+V9j4}iI_Jg4zBayGdGIw2iZE)q{`5*bVS>hw=>Auxuv_5m z!)CviNz!{25>D?!#rZ$k%YH-Y{C2RW-!q3m;eg)-r-w~$&2pyA9tT$jmnZrSj_hRo zVxC>!AMPSHhV)x6BA&`Tb>&O~Awe?JIht&h8gvSdj=Ps2MZ zugdtvMImBhm|tF{w}!A>=jwqQ4|VVB^uxM@AbOzuzSbb>1=wSL_EJkBHkFuA?)MGO zw_i6Y{9oM%b~d_5c;MoV<~vCIOuo4hqLgmL%ybI6S&NX+eu{CO70#%)Pitcj9F$}^ zL%sfTCG(Wd9e__{;q`D)J1QV>;Y)}a-myIpDRP`yMf?5}*<^Vd9{ct@CN74?>Q^zh zEBh0N3<2Ekwc^JjJ-Umj=>TUVjz6og51Vuf@-b0SqS_{jLLM?PV}-LVw$_KIYZ=2n zN7h8>F;uaSMNzgIIjPI->NRB@q=}r&;C6QW|832RkWt%JU`7+Em${t!nAR*0Y2n`se55mQ3t4st-Fj z1H~6yc3;qDeVAewKOgM;Zsd^&3R;RD0~s3|GjW0AN^_iz-?7Z_+s*iEZb1r`T0CAK zjg?Hw)cX3mQQJFA_n4oYbsKxDf_r2~e7Ya@!Qu*Ds7fW$lX#@J^zp?5za{2`> zcD$MP(X~|GnIFuwSid=oQa$P}`@U9}F@dMKBEOa6d9*)0pLuBCJ6M2rO_E9n;oJv2 z9Q};1-p`7=dH9U&O`Kxv@wpT-(;R z)^oeS$JMoGGyy1Ib64Z|*!cLie1^CIvp+9d&jEIp=6zuB_#o9V&YflaIkzDb**?w^rH%bkxb{d9b~nGxdG8r6$D+Rd8?4h-bAy{~KNM)u z_vx)ZKcA!@!pk5P97yr^HMa`AdiyZuzOup4sV)3c-=*Posp^RD2_AoZe9TTF71*Zu zWjCz`@;LC!i@hlEOvY1cxv2{(kH#JYs7m4e5R0pdV~8`g9&|U-M-2UVu53RVj_ZBB zWYl}e3PR6b%QnUB&C%D9o?{8w!$gJ^Xy)R&j-Fpd$qM`JBddQ zEwRY(rM9uz`SM;rf6l)C*Y;iyRruVwdBpLM*ND%r2j?#qIwoW>$n-_NN>Mr!oV}{@ zM>7xi_b1UA0;;`mn>Vql6Jk`8Zg^}t zZjy9X0mhu4-61{Po$y?FBlhjz&%1)gKo)^kU*h<$iatctZn#+A1k7@*^|3=Xmy27F zt|;{=Ibg#%LG@M#Pa>#j*p!XWhKQ=^&kP#Wru^{Sa1{BX(8m36Qvk}8pOlT(xVidb zX=bC9k8Z6ux$WL720y@PTqphT#ISn|pAk^7#SMLgXLku#D^t!7^!r~Q|Ki0IG+QrP zTC1r!Qx6MfC=t&L=)5_Tc)O8#iAitQNuN{;BT)Du(F0SOZ?mBf49Iue(F%>g5yg>% zR&)O_rOt5UtAcP@{oX{mT|4A5VkcL${=;2Y1x{L1M z1{N7aMm!tix9|}&#;Byxc^c{;*Vx|Og=(I&Qder8dpD0}VGB}-p4;V^TsK9zWwklj zqoIYTr0B{IM|?PK!gBEmDZAD3}Y0KBFLvZoDgJ%CZHxAyO7(KPU++B0eAP-*q_dzUO8m(8s*{%02s%AA zTr2$%y$F?iDGT%~ELP8u!*x}Zt|&i$q*zh>vY~~7R*`X{l>9dnwg=a~b#yAdc@qYx zj}s*P2aVQ|S7LK@{1cCQZN2wwAR}aBp5Oft%JLf%y?|ioULorl;4oSr=yR{F+|vi_ z20y;t0RTYg;m@MN(b;f+QUJyY}bg`bsv=dWuGjll+gnBMy&^5!X*ZY(Sq= VM2O~7`8)t|D9NeGR!Wimages/topmost.png images/close-all-tabs.png images/bug-report.png + images/yara.png diff --git a/x64_dbg_gui/Project/x64_dbg.pro b/x64_dbg_gui/Project/x64_dbg.pro index 1af66de0..e80fa89f 100644 --- a/x64_dbg_gui/Project/x64_dbg.pro +++ b/x64_dbg_gui/Project/x64_dbg.pro @@ -86,7 +86,8 @@ SOURCES += \ Src/Gui/PageMemoryRights.cpp \ Src/Gui/SelectFields.cpp \ Src/Gui/ReferenceManager.cpp \ - Src/Bridge/BridgeResult.cpp + Src/Bridge/BridgeResult.cpp \ + Src/Gui/YaraRuleSelectionDialog.cpp HEADERS += \ @@ -151,7 +152,8 @@ HEADERS += \ Src/Gui/PageMemoryRights.h \ Src/Gui/SelectFields.h \ Src/Gui/ReferenceManager.h \ - Src/Bridge/BridgeResult.h + Src/Bridge/BridgeResult.h \ + Src/Gui/YaraRuleSelectionDialog.h INCLUDEPATH += \ @@ -186,7 +188,8 @@ FORMS += \ Src/Gui/CalculatorDialog.ui \ Src/Gui/AttachDialog.ui \ Src/Gui/PageMemoryRights.ui \ - Src/Gui/SelectFields.ui + Src/Gui/SelectFields.ui \ + Src/Gui/YaraRuleSelectionDialog.ui INCLUDEPATH += $$PWD/Src/Bridge From d64e9a3432dca987ec20220d0032a8c4f6b6fd85 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 17:50:31 +0200 Subject: [PATCH 105/106] GUI: resolved issue #262 (patching toggle now also toggles the bytes) --- x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp b/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp index e9a3dec9..96db5e97 100644 --- a/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/PatchDialog.cpp @@ -180,7 +180,11 @@ void PatchDialog::groupToggle() continue; ui->listPatches->item(i)->setCheckState(checkState); curPatchList[i].second.checked = enabled; + //change the byte to reflect the change for the user (cypherpunk reported this) + unsigned char writebyte = curPatchList[i].second.checked ? curPatchList[i].first.newbyte : curPatchList[i].first.oldbyte; + DbgMemWrite(curPatchList[i].first.addr, &writebyte, sizeof(writebyte)); } + GuiUpdateAllViews(); mIsWorking = false; int_t groupStart = getGroupAddress(curPatchList, group); if(!groupStart) @@ -280,6 +284,9 @@ void PatchDialog::on_listPatches_itemChanged(QListWidgetItem* item) //checkbox c if(patch.second.checked == checked) //check state did not change return; patch.second.checked = checked; + //change the byte to reflect the change for the user (cypherpunk reported this) + unsigned char writebyte = patch.second.checked ? patch.first.newbyte : patch.first.oldbyte; + DbgMemWrite(patch.first.addr, &writebyte, sizeof(writebyte)); //check state changed if((QApplication::keyboardModifiers() & Qt::ControlModifier) != Qt::ControlModifier) { @@ -288,11 +295,16 @@ void PatchDialog::on_listPatches_itemChanged(QListWidgetItem* item) //checkbox c for(int i = 0; i < curPatchList.size(); i++) if(curPatchList.at(i).second.group == patch.second.group) { - curPatchList[i].second.checked = checked; + //change the patch state + curPatchList[i].second.checked = checked; ui->listPatches->item(i)->setCheckState(item->checkState()); + //change the byte to reflect the change for the user (cypherpunk reported this) + unsigned char writebyte = curPatchList[i].second.checked ? curPatchList[i].first.newbyte : curPatchList[i].first.oldbyte; + DbgMemWrite(curPatchList[i].first.addr, &writebyte, sizeof(writebyte)); } mIsWorking = false; } + GuiUpdateAllViews(); int group = mGroupSelector->group(); QString color = isGroupEnabled(curPatchList, group) ? "#00DD00" : "red"; QString addrText = QString("%1").arg(getGroupAddress(curPatchList, group), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); @@ -316,7 +328,10 @@ void PatchDialog::on_btnSelectAll_clicked() { ui->listPatches->item(i)->setCheckState(Qt::Checked); curPatchList[i].second.checked = true; + //change the byte to reflect the change for the user (cypherpunk reported this) + DbgMemWrite(curPatchList[i].first.addr, &curPatchList[i].first.newbyte, sizeof(unsigned char)); } + GuiUpdateAllViews(); mIsWorking = false; } @@ -334,7 +349,10 @@ void PatchDialog::on_btnDeselectAll_clicked() { ui->listPatches->item(i)->setCheckState(Qt::Unchecked); curPatchList[i].second.checked = false; + //change the byte to reflect the change for the user (cypherpunk reported this) + DbgMemWrite(curPatchList[i].first.addr, &curPatchList[i].first.oldbyte, sizeof(unsigned char)); } + GuiUpdateAllViews(); mIsWorking = false; } From 10d6a074138f2d7ef2b3c5da60162f54bcd4dc44 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 2 Apr 2015 17:53:46 +0200 Subject: [PATCH 106/106] GUI: resolved issue #264 (show module name in status when changing selection) --- x64_dbg_gui/Project/Src/Gui/CPUDump.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp index d9db978b..c3639772 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDump.cpp @@ -1329,7 +1329,11 @@ void CPUDump::selectionUpdatedSlot() { QString selStart = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); QString selEnd = QString("%1").arg(rvaToVa(getSelectionEnd()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); - GuiAddStatusBarMessage(QString("Dump: " + selStart + " -> " + selEnd + QString().sprintf(" (0x%.8X bytes)\n", getSelectionEnd() - getSelectionStart() + 1)).toUtf8().constData()); + QString info = "Dump"; + char mod[MAX_MODULE_SIZE] = ""; + if(DbgFunctions()->ModNameFromAddr(rvaToVa(getSelectionStart()), mod, true)) + info = QString(mod) + ""; + GuiAddStatusBarMessage(QString(info + ": " + selStart + " -> " + selEnd + QString().sprintf(" (0x%.8X bytes)\n", getSelectionEnd() - getSelectionStart() + 1)).toUtf8().constData()); } void CPUDump::yaraSlot()