From 771103c27a6a2edde18a87a8ab14e3f467a6e927 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Sat, 29 Apr 2017 19:45:34 +0200 Subject: [PATCH] DBG: include refactor --- src/dbg/TraceRecord.h | 1 + src/dbg/_exports.cpp | 1 + src/dbg/_global.cpp | 2 ++ src/dbg/_global.h | 27 ++----------------- src/dbg/_plugin_types.h | 2 ++ src/dbg/addrinfo.h | 2 ++ src/dbg/analysis/linearanalysis.cpp | 1 + src/dbg/breakpoint.h | 1 + src/dbg/commandline.h | 1 + src/dbg/commands/cmd-analysis.cpp | 1 + .../cmd-conditional-breakpoint-control.cpp | 1 + src/dbg/commands/cmd-debug-control.cpp | 1 + src/dbg/datainst_helper.cpp | 1 + src/dbg/debugger.cpp | 3 +++ src/dbg/debugger.h | 2 ++ src/dbg/encodemap.h | 2 ++ src/dbg/exception.cpp | 1 + src/dbg/expressionfunctions.h | 1 + src/dbg/formatfunctions.h | 1 + src/dbg/handles.cpp | 1 + src/dbg/historycontext.cpp | 1 + src/dbg/jansson/jansson_x64dbg.h | 4 +++ src/dbg/mnemonichelp.cpp | 1 + src/dbg/module.cpp | 1 + src/dbg/plugin_loader.cpp | 2 ++ src/dbg/serializablemap.h | 3 ++- src/dbg/stackinfo.cpp | 1 + src/dbg/symbolinfo.cpp | 1 + src/dbg/types.cpp | 2 ++ src/dbg/value.cpp | 2 +- src/dbg/variable.cpp | 1 + src/dbg/watch.h | 2 ++ src/dbg/x64dbg.cpp | 1 + src/dbg/xrefs.h | 1 + 34 files changed, 49 insertions(+), 27 deletions(-) diff --git a/src/dbg/TraceRecord.h b/src/dbg/TraceRecord.h index e738e2d3..e3131989 100644 --- a/src/dbg/TraceRecord.h +++ b/src/dbg/TraceRecord.h @@ -2,6 +2,7 @@ #define TRACERECORD_H #include "_global.h" #include "_dbgfunctions.h" +#include "jansson/jansson_x64dbg.h" class TraceRecordManager { diff --git a/src/dbg/_exports.cpp b/src/dbg/_exports.cpp index f67c7779..f62cb790 100644 --- a/src/dbg/_exports.cpp +++ b/src/dbg/_exports.cpp @@ -34,6 +34,7 @@ #include "animate.h" #include "TraceRecord.h" #include "recursiveanalysis.h" +#include "dbghelp_safe.h" static bool bOnlyCipAutoComments = false; static bool bNoSourceLineAutoComments = false; diff --git a/src/dbg/_global.cpp b/src/dbg/_global.cpp index e4bd73f3..e793f17b 100644 --- a/src/dbg/_global.cpp +++ b/src/dbg/_global.cpp @@ -6,6 +6,8 @@ #include "_global.h" #include #include +#include +#include "DeviceNameResolver/DeviceNameResolver.h" /** \brief x64dbg library instance. diff --git a/src/dbg/_global.h b/src/dbg/_global.h index 686cda54..e86eeb62 100644 --- a/src/dbg/_global.h +++ b/src/dbg/_global.h @@ -1,5 +1,4 @@ -#ifndef _GLOBAL_H -#define _GLOBAL_H +#pragma once #define _WIN32_WINNT 0x0501 @@ -10,30 +9,10 @@ #define _WIN32_IE 0x0500 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "../dbg_types.h" #include "../dbg_assert.h" -#include "../bridge\bridgemain.h" -#include "jansson/jansson.h" -#include "jansson/jansson_x64dbg.h" -#include "DeviceNameResolver/DeviceNameResolver.h" -#include "handle.h" +#include "../bridge/bridgemain.h" #include "stringutils.h" -#include "dbghelp_safe.h" #ifndef DLL_EXPORT #define DLL_EXPORT __declspec(dllexport) @@ -98,5 +77,3 @@ void WaitForMultipleThreadsTermination(const HANDLE* hThread, int count, DWORD t #endif //_WIN64 #include "dynamicmem.h" - -#endif // _GLOBAL_H diff --git a/src/dbg/_plugin_types.h b/src/dbg/_plugin_types.h index 4d626698..55bcfcaf 100644 --- a/src/dbg/_plugin_types.h +++ b/src/dbg/_plugin_types.h @@ -4,6 +4,8 @@ #ifdef BUILD_DBG #include "_global.h" +#include "jansson/jansson.h" +#include #else diff --git a/src/dbg/addrinfo.h b/src/dbg/addrinfo.h index 3de16f00..081dafe9 100644 --- a/src/dbg/addrinfo.h +++ b/src/dbg/addrinfo.h @@ -3,6 +3,8 @@ #include "_global.h" #include +#include +#include //ranges typedef std::pair Range; diff --git a/src/dbg/analysis/linearanalysis.cpp b/src/dbg/analysis/linearanalysis.cpp index 43253de8..a633fd06 100644 --- a/src/dbg/analysis/linearanalysis.cpp +++ b/src/dbg/analysis/linearanalysis.cpp @@ -2,6 +2,7 @@ #include "console.h" #include "memory.h" #include "function.h" +#include LinearAnalysis::LinearAnalysis(duint base, duint size) : Analysis(base, size) { diff --git a/src/dbg/breakpoint.h b/src/dbg/breakpoint.h index 1bc9cd9a..34f274fb 100644 --- a/src/dbg/breakpoint.h +++ b/src/dbg/breakpoint.h @@ -2,6 +2,7 @@ #define _BREAKPOINT_H #include "_global.h" +#include "jansson/jansson_x64dbg.h" #define TITANSETDRX(titantype, drx) titantype &= 0x0FF; titantype |= (drx<<8) #define TITANGETDRX(titantype) (titantype >> 8) & 0xF diff --git a/src/dbg/commandline.h b/src/dbg/commandline.h index 34af452c..be11ef3d 100644 --- a/src/dbg/commandline.h +++ b/src/dbg/commandline.h @@ -3,6 +3,7 @@ #include "_global.h" #include "command.h" +#include "jansson/jansson_x64dbg.h" typedef enum { diff --git a/src/dbg/commands/cmd-analysis.cpp b/src/dbg/commands/cmd-analysis.cpp index 58b01b69..2d88ab98 100644 --- a/src/dbg/commands/cmd-analysis.cpp +++ b/src/dbg/commands/cmd-analysis.cpp @@ -14,6 +14,7 @@ #include "symbolinfo.h" #include "exception.h" #include "TraceRecord.h" +#include "dbghelp_safe.h" bool cbInstrAnalyse(int argc, char* argv[]) { diff --git a/src/dbg/commands/cmd-conditional-breakpoint-control.cpp b/src/dbg/commands/cmd-conditional-breakpoint-control.cpp index 3c3ca9e7..c3c290b5 100644 --- a/src/dbg/commands/cmd-conditional-breakpoint-control.cpp +++ b/src/dbg/commands/cmd-conditional-breakpoint-control.cpp @@ -4,6 +4,7 @@ #include "console.h" #include "variable.h" #include "value.h" +#include static bool cbDebugSetBPXTextCommon(BP_TYPE Type, int argc, char* argv[], const String & description, const std::function & setFunction) { diff --git a/src/dbg/commands/cmd-debug-control.cpp b/src/dbg/commands/cmd-debug-control.cpp index 7b79b339..56140674 100644 --- a/src/dbg/commands/cmd-debug-control.cpp +++ b/src/dbg/commands/cmd-debug-control.cpp @@ -9,6 +9,7 @@ #include "plugin_loader.h" #include "value.h" #include "TraceRecord.h" +#include "handle.h" static bool skipInt3Stepping(int argc, char* argv[]) { diff --git a/src/dbg/datainst_helper.cpp b/src/dbg/datainst_helper.cpp index 79b01b62..20d27ab8 100644 --- a/src/dbg/datainst_helper.cpp +++ b/src/dbg/datainst_helper.cpp @@ -3,6 +3,7 @@ #include "stringutils.h" #include "value.h" #include +#include std::unordered_map disasmMap; std::unordered_map assembleMap; diff --git a/src/dbg/debugger.cpp b/src/dbg/debugger.cpp index 279dbf20..5c7b10a0 100644 --- a/src/dbg/debugger.cpp +++ b/src/dbg/debugger.cpp @@ -31,6 +31,9 @@ #include "cmd-watch-control.h" #include "filemap.h" #include "jit.h" +#include "handle.h" +#include "dbghelp_safe.h" + /** \brief Conditional tracing structures */ diff --git a/src/dbg/debugger.h b/src/dbg/debugger.h index 3836a176..05e3a07c 100644 --- a/src/dbg/debugger.h +++ b/src/dbg/debugger.h @@ -7,6 +7,8 @@ #include "breakpoint.h" #include "_plugins.h" #include "commandline.h" +#include +#include //structures struct INIT_STRUCT diff --git a/src/dbg/encodemap.h b/src/dbg/encodemap.h index 7061c395..c90013d9 100644 --- a/src/dbg/encodemap.h +++ b/src/dbg/encodemap.h @@ -1,5 +1,7 @@ #pragma once + #include "_global.h" +#include "jansson/jansson_x64dbg.h" void* EncodeMapGetBuffer(duint addr, duint* size, bool create = false); void EncodeMapReleaseBuffer(void* buffer); diff --git a/src/dbg/exception.cpp b/src/dbg/exception.cpp index 92385a65..3ef4d0cf 100644 --- a/src/dbg/exception.cpp +++ b/src/dbg/exception.cpp @@ -1,4 +1,5 @@ #include +#include #include "exception.h" #include "filehelper.h" #include "value.h" diff --git a/src/dbg/expressionfunctions.h b/src/dbg/expressionfunctions.h index dcf6208c..5b0aa3db 100644 --- a/src/dbg/expressionfunctions.h +++ b/src/dbg/expressionfunctions.h @@ -1,6 +1,7 @@ #pragma once #include "_global.h" +#include class ExpressionFunctions { diff --git a/src/dbg/formatfunctions.h b/src/dbg/formatfunctions.h index d04b66c1..a3a4954f 100644 --- a/src/dbg/formatfunctions.h +++ b/src/dbg/formatfunctions.h @@ -2,6 +2,7 @@ #include "_global.h" #include "_plugins.h" +#include class FormatFunctions { diff --git a/src/dbg/handles.cpp b/src/dbg/handles.cpp index df7c26d1..36720edb 100644 --- a/src/dbg/handles.cpp +++ b/src/dbg/handles.cpp @@ -2,6 +2,7 @@ #include "undocumented.h" #include "exception.h" #include "debugger.h" +#include typedef struct _OBJECT_NAME_INFORMATION { diff --git a/src/dbg/historycontext.cpp b/src/dbg/historycontext.cpp index 73a3bbcc..2c2257bc 100644 --- a/src/dbg/historycontext.cpp +++ b/src/dbg/historycontext.cpp @@ -6,6 +6,7 @@ #include "threading.h" #include "cmd-watch-control.h" #include "debugger.h" +#include static const duint HistoryMaxCount = 4096; static std::deque history; diff --git a/src/dbg/jansson/jansson_x64dbg.h b/src/dbg/jansson/jansson_x64dbg.h index 1951ae7d..99fea19c 100644 --- a/src/dbg/jansson/jansson_x64dbg.h +++ b/src/dbg/jansson/jansson_x64dbg.h @@ -1,3 +1,7 @@ +#pragma once + +#include "jansson.h" + typedef json_t* JSON; static JSON_INLINE diff --git a/src/dbg/mnemonichelp.cpp b/src/dbg/mnemonichelp.cpp index 0faacc0b..747d7464 100644 --- a/src/dbg/mnemonichelp.cpp +++ b/src/dbg/mnemonichelp.cpp @@ -1,5 +1,6 @@ #include "mnemonichelp.h" #include "threading.h" +#include "jansson/jansson_x64dbg.h" static std::unordered_map MnemonicMap; static std::unordered_map MnemonicBriefMap; diff --git a/src/dbg/module.cpp b/src/dbg/module.cpp index e7f82fa9..67868eff 100644 --- a/src/dbg/module.cpp +++ b/src/dbg/module.cpp @@ -5,6 +5,7 @@ #include "murmurhash.h" #include "memory.h" #include "label.h" +#include std::map modinfo; std::unordered_map hashNameMap; diff --git a/src/dbg/plugin_loader.cpp b/src/dbg/plugin_loader.cpp index 3ce34e93..540ed0c3 100644 --- a/src/dbg/plugin_loader.cpp +++ b/src/dbg/plugin_loader.cpp @@ -10,6 +10,8 @@ #include "threading.h" #include "expressionfunctions.h" #include "formatfunctions.h" +#include +#include /** \brief List of plugins. diff --git a/src/dbg/serializablemap.h b/src/dbg/serializablemap.h index 2cf062a2..5565cc46 100644 --- a/src/dbg/serializablemap.h +++ b/src/dbg/serializablemap.h @@ -5,6 +5,7 @@ #include "threading.h" #include "module.h" #include "memory.h" +#include "jansson/jansson_x64dbg.h" template class JSONWrapper @@ -300,7 +301,7 @@ struct SerializableModuleHashMap : SerializableUnorderedMap inRange) + void DeleteRangeWhere(duint start, duint end, std::function inRange) { // Are all comments going to be deleted? // 0x00000000 - 0xFFFFFFFF diff --git a/src/dbg/stackinfo.cpp b/src/dbg/stackinfo.cpp index 34393127..9d3160c8 100644 --- a/src/dbg/stackinfo.cpp +++ b/src/dbg/stackinfo.cpp @@ -15,6 +15,7 @@ #include "exhandlerinfo.h" #include "symbolinfo.h" #include "debugger.h" +#include "dbghelp_safe.h" using SehMap = std::unordered_map; static SehMap SehCache; diff --git a/src/dbg/symbolinfo.cpp b/src/dbg/symbolinfo.cpp index a2b435e6..886358f4 100644 --- a/src/dbg/symbolinfo.cpp +++ b/src/dbg/symbolinfo.cpp @@ -9,6 +9,7 @@ #include "console.h" #include "module.h" #include "addrinfo.h" +#include "dbghelp_safe.h" struct SYMBOLCBDATA { diff --git a/src/dbg/types.cpp b/src/dbg/types.cpp index 1b6490a6..acd0d1f7 100644 --- a/src/dbg/types.cpp +++ b/src/dbg/types.cpp @@ -3,6 +3,8 @@ #include "threading.h" #include "filehelper.h" #include "console.h" +#include "jansson/jansson_x64dbg.h" +#include using namespace Types; diff --git a/src/dbg/value.cpp b/src/dbg/value.cpp index d84819a7..7bf5d337 100644 --- a/src/dbg/value.cpp +++ b/src/dbg/value.cpp @@ -1910,7 +1910,7 @@ static bool longEnough(const char* str, size_t min_length) static bool startsWith(const char* pre, const char* str) { size_t lenpre = strlen(pre); - return longEnough(str, lenpre) ? StrNCmpI(str, pre, (int) lenpre) == 0 : false; + return longEnough(str, lenpre) ? _strnicmp(str, pre, (int) lenpre) == 0 : false; } #define MxCsr_PRE_FIELD_STRING "MxCsr_" diff --git a/src/dbg/variable.cpp b/src/dbg/variable.cpp index d9af4fd2..62c5d414 100644 --- a/src/dbg/variable.cpp +++ b/src/dbg/variable.cpp @@ -6,6 +6,7 @@ #include "variable.h" #include "threading.h" +#include /** \brief The container that stores all variables. diff --git a/src/dbg/watch.h b/src/dbg/watch.h index e09371ae..59efe5e6 100644 --- a/src/dbg/watch.h +++ b/src/dbg/watch.h @@ -1,7 +1,9 @@ #pragma once #include "_global.h" +#include "jansson/jansson_x64dbg.h" #include "expressionparser.h" +#include class WatchExpr { diff --git a/src/dbg/x64dbg.cpp b/src/dbg/x64dbg.cpp index 4ee11d66..fd6eef06 100644 --- a/src/dbg/x64dbg.cpp +++ b/src/dbg/x64dbg.cpp @@ -26,6 +26,7 @@ #include "expressionfunctions.h" #include "formatfunctions.h" #include "yara/yara.h" +#include "dbghelp_safe.h" static MESSAGE_STACK* gMsgStack = 0; static HANDLE hCommandLoopThread = 0; diff --git a/src/dbg/xrefs.h b/src/dbg/xrefs.h index edd650d3..c95634a1 100644 --- a/src/dbg/xrefs.h +++ b/src/dbg/xrefs.h @@ -2,6 +2,7 @@ #define _XREFS_H #include "_global.h" +#include "jansson/jansson_x64dbg.h" bool XrefAdd(duint Address, duint From); bool XrefGet(duint Address, XREF_INFO* List);