From 22ef15abdaa2b100cdb95f39cf88f5e259a6f1b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 12 May 2024 15:53:22 +0900 Subject: [PATCH] add user-mode platform environment --- hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj | 1 + .../hprdbgctrl/hprdbgctrl.vcxproj.filters | 9 +++++++ hyperdbg/hprdbgctrl/pch.h | 22 +++++++++------- hyperdbg/hyperdbg-cli/hyperdbg-cli.cpp | 6 +++++ hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj | 3 +++ .../hyperdbg-cli/hyperdbg-cli.vcxproj.filters | 11 ++++++++ hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj | 1 + .../hyperdbg-test.vcxproj.filters | 6 +++++ hyperdbg/hyperdbg-test/pch.h | 5 ++++ .../SDK/Examples/hyperdbg_app/header/pch.h | 4 +-- .../Examples/hyperdbg_app/hprdbgrev.vcxproj | 1 + .../hyperdbg_app/hprdbgrev.vcxproj.filters | 6 +++++ .../include/platform/user/header/.gitkeep | 0 .../platform/user/header/Environment.h | 26 +++++++++++++++++++ hyperdbg/script-engine/pch.h | 5 ++++ hyperdbg/script-engine/script-engine.vcxproj | 1 + .../script-engine.vcxproj.filters | 6 +++++ hyperdbg/symbol-parser/pch.h | 5 ++++ hyperdbg/symbol-parser/symbol-parser.vcxproj | 1 + .../symbol-parser.vcxproj.filters | 6 +++++ 20 files changed, 114 insertions(+), 11 deletions(-) delete mode 100644 hyperdbg/include/platform/user/header/.gitkeep create mode 100644 hyperdbg/include/platform/user/header/Environment.h diff --git a/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj b/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj index 34c460dc..570b0e00 100644 --- a/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj +++ b/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj @@ -124,6 +124,7 @@ + diff --git a/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj.filters b/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj.filters index 5eeede46..4881aeea 100644 --- a/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj.filters +++ b/hyperdbg/hprdbgctrl/hprdbgctrl.vcxproj.filters @@ -69,6 +69,12 @@ {4d49c742-e10d-4d2b-9178-e65c665c99a0} + + {0467199d-cfbb-4020-a550-48df489d65e0} + + + {81ab704c-2463-4499-867a-f259a77bd2ab} + @@ -134,6 +140,9 @@ header + + header\platform + diff --git a/hyperdbg/hprdbgctrl/pch.h b/hyperdbg/hprdbgctrl/pch.h index 6eed2c9a..294d3560 100644 --- a/hyperdbg/hprdbgctrl/pch.h +++ b/hyperdbg/hprdbgctrl/pch.h @@ -12,13 +12,13 @@ #pragma once // -// add headers that you want to pre-compile here +// Environment headers // +#include "platform/user/header/Environment.h" // // Windows SDK headers // - #define WIN32_LEAN_AND_MEAN // @@ -161,25 +161,29 @@ typedef const wchar_t *LPCWCHAR, *PCWCHAR; // Libraries // -#pragma comment(lib, "ntdll.lib") +#ifdef ENV_WINDOWS + +# pragma comment(lib, "ntdll.lib") // // For path combine // -#pragma comment(lib, "Shlwapi.lib") +# pragma comment(lib, "Shlwapi.lib") // // Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib // for tcpclient.cpp and tcpserver.cpp // -#pragma comment(lib, "Ws2_32.lib") -#pragma comment(lib, "Mswsock.lib") -#pragma comment(lib, "AdvApi32.lib") +# pragma comment(lib, "Ws2_32.lib") +# pragma comment(lib, "Mswsock.lib") +# pragma comment(lib, "AdvApi32.lib") // // For GetModuleFileNameExA on script-engine for user-mode // Kernel32.lib is not needed, but seems that it's the library // for Windows 7 // -#pragma comment(lib, "Psapi.lib") -#pragma comment(lib, "Kernel32.lib") +# pragma comment(lib, "Psapi.lib") +# pragma comment(lib, "Kernel32.lib") + +#endif // ENV_WINDOWS diff --git a/hyperdbg/hyperdbg-cli/hyperdbg-cli.cpp b/hyperdbg/hyperdbg-cli/hyperdbg-cli.cpp index 76482f90..3b964980 100644 --- a/hyperdbg/hyperdbg-cli/hyperdbg-cli.cpp +++ b/hyperdbg/hyperdbg-cli/hyperdbg-cli.cpp @@ -9,6 +9,12 @@ * @copyright This project is released under the GNU Public License v3. * */ + +// +// Environment headers +// +#include "platform/user/header/Environment.h" + #include #include #include diff --git a/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj b/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj index a83669d7..42672f90 100644 --- a/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj +++ b/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj @@ -150,6 +150,9 @@ copy "$(OutDir)hprdbghv.dll" "$(OutDir)SDK\Libraries\hprdbghv.dll" + + + diff --git a/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj.filters b/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj.filters index ef78236e..a9a66de5 100644 --- a/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj.filters +++ b/hyperdbg/hyperdbg-cli/hyperdbg-cli.vcxproj.filters @@ -5,10 +5,21 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + {3eacd448-7ca9-42c0-b5a1-2848161f69a2} + + + {8eb27fe0-dacb-404f-abef-ee81eda88a6e} + code + + + header\platform + + \ No newline at end of file diff --git a/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj b/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj index e028175c..c73dc4da 100644 --- a/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj +++ b/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj @@ -109,6 +109,7 @@ + diff --git a/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj.filters b/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj.filters index a64f1561..9a0c6ebe 100644 --- a/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj.filters +++ b/hyperdbg/hyperdbg-test/hyperdbg-test.vcxproj.filters @@ -15,6 +15,9 @@ {0dd2fc9a-1efe-43ae-963c-f3e04a9d5f33} + + {3b15cfee-d573-4538-aa01-0bac669f0360} + @@ -46,6 +49,9 @@ header + + header\platform + diff --git a/hyperdbg/hyperdbg-test/pch.h b/hyperdbg/hyperdbg-test/pch.h index 8b856ad6..57a71587 100644 --- a/hyperdbg/hyperdbg-test/pch.h +++ b/hyperdbg/hyperdbg-test/pch.h @@ -11,6 +11,11 @@ */ #pragma once +// +// Environment headers +// +#include "platform/user/header/Environment.h" + // // General Headers // diff --git a/hyperdbg/include/SDK/Examples/hyperdbg_app/header/pch.h b/hyperdbg/include/SDK/Examples/hyperdbg_app/header/pch.h index 80114722..0360f9f7 100644 --- a/hyperdbg/include/SDK/Examples/hyperdbg_app/header/pch.h +++ b/hyperdbg/include/SDK/Examples/hyperdbg_app/header/pch.h @@ -13,13 +13,13 @@ #pragma once // -// add headers that you want to pre-compile here +// Environment headers // +#include "platform/user/header/Environment.h" // // Windows SDK headers // - #define WIN32_LEAN_AND_MEAN // diff --git a/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj b/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj index 7a781963..1237404a 100644 --- a/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj +++ b/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj @@ -19,6 +19,7 @@ + diff --git a/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj.filters b/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj.filters index e6fb0974..6e0f241b 100644 --- a/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj.filters +++ b/hyperdbg/include/SDK/Examples/hyperdbg_app/hprdbgrev.vcxproj.filters @@ -7,11 +7,17 @@ {c40916c8-414b-486b-bfd1-13bcbafd8fa1} + + {14cb7f22-aa90-410e-a333-f05e0ec7981f} + header + + header\platform + diff --git a/hyperdbg/include/platform/user/header/.gitkeep b/hyperdbg/include/platform/user/header/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/hyperdbg/include/platform/user/header/Environment.h b/hyperdbg/include/platform/user/header/Environment.h new file mode 100644 index 00000000..13a28ee1 --- /dev/null +++ b/hyperdbg/include/platform/user/header/Environment.h @@ -0,0 +1,26 @@ +/** + * @file Environment.h + * @author Behrooz Abbassi (BehroozAbbassi@hyperdbg.org) + * @brief The running environment of HyperDbg + * @details + * @version 0.1 + * @date 2022-01-17 + * + * @copyright This project is released under the GNU Public License v3. + * + */ +#pragma once + +////////////////////////////////////////////////// +// Definitions // +////////////////////////////////////////////////// + +// +// Check for platform +// + +#if defined(_WIN32) || defined(_WIN64) +# define ENV_WINDOWS +#else +# error "This code cannot compile on non windows platforms" +#endif diff --git a/hyperdbg/script-engine/pch.h b/hyperdbg/script-engine/pch.h index 66276290..77bd8539 100644 --- a/hyperdbg/script-engine/pch.h +++ b/hyperdbg/script-engine/pch.h @@ -11,6 +11,11 @@ */ #pragma once +// +// Environment headers +// +#include "platform/user/header/Environment.h" + // // Exclude rarely-used stuff from Windows headers // diff --git a/hyperdbg/script-engine/script-engine.vcxproj b/hyperdbg/script-engine/script-engine.vcxproj index 46bbecb5..37bbfb18 100644 --- a/hyperdbg/script-engine/script-engine.vcxproj +++ b/hyperdbg/script-engine/script-engine.vcxproj @@ -107,6 +107,7 @@ + diff --git a/hyperdbg/script-engine/script-engine.vcxproj.filters b/hyperdbg/script-engine/script-engine.vcxproj.filters index 6f89306c..cd8dc72d 100644 --- a/hyperdbg/script-engine/script-engine.vcxproj.filters +++ b/hyperdbg/script-engine/script-engine.vcxproj.filters @@ -9,6 +9,9 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx + + {53ae7bcb-e612-4a1a-89db-de1e77f2d730} + @@ -32,6 +35,9 @@ header + + header\platform + diff --git a/hyperdbg/symbol-parser/pch.h b/hyperdbg/symbol-parser/pch.h index 57e1a20e..ad00b799 100644 --- a/hyperdbg/symbol-parser/pch.h +++ b/hyperdbg/symbol-parser/pch.h @@ -11,6 +11,11 @@ */ #pragma once +// +// Environment headers +// +#include "platform/user/header/Environment.h" + #include #include #include diff --git a/hyperdbg/symbol-parser/symbol-parser.vcxproj b/hyperdbg/symbol-parser/symbol-parser.vcxproj index ed0ebc30..43b29374 100644 --- a/hyperdbg/symbol-parser/symbol-parser.vcxproj +++ b/hyperdbg/symbol-parser/symbol-parser.vcxproj @@ -105,6 +105,7 @@ + diff --git a/hyperdbg/symbol-parser/symbol-parser.vcxproj.filters b/hyperdbg/symbol-parser/symbol-parser.vcxproj.filters index 3cf8e830..6aa34925 100644 --- a/hyperdbg/symbol-parser/symbol-parser.vcxproj.filters +++ b/hyperdbg/symbol-parser/symbol-parser.vcxproj.filters @@ -9,6 +9,9 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + {7884782a-2386-47f5-aeed-fabdefcc888d} + @@ -34,5 +37,8 @@ header + + header\platform + \ No newline at end of file