mirror of
https://github.com/HyperDbg/HyperDbg.git
synced 2026-07-09 17:19:26 +00:00
signal handler platform independent API
This commit is contained in:
parent
240feadc0c
commit
2d3941a43e
7 changed files with 33 additions and 2 deletions
|
|
@ -74,7 +74,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
|||
add_subdirectory(script-engine)
|
||||
link_directories(libraries/zydis/user libraries/keystone/release-lib)
|
||||
add_subdirectory(libhyperdbg)
|
||||
target_link_libraries(libhyperdbg Zycore Zydis script-engine keystone)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(libhyperdbg Zycore Zydis script-engine keystone Threads::Threads)
|
||||
|
||||
add_subdirectory(hyperdbg-cli)
|
||||
target_link_libraries(hyperdbg-cli libhyperdbg)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@
|
|||
// wchar_t is a C++ built-in but needs this header in C
|
||||
# include <wchar.h>
|
||||
|
||||
// POSIX sleep primitives (usleep) backing the Win32 Sleep() shim below
|
||||
# include <unistd.h>
|
||||
|
||||
// Windows string/char types
|
||||
typedef char TCHAR;
|
||||
typedef char * LPTSTR;
|
||||
|
|
@ -78,4 +81,16 @@ typedef void * HMODULE;
|
|||
// Win32 invalid handle sentinel (returned by the cross-platform file/serial wrappers)
|
||||
# define INVALID_HANDLE_VALUE ((HANDLE)(SIZE_T)-1)
|
||||
|
||||
// Win32 console-control event codes (kept at their Windows values so the
|
||||
// shared BreakController() switch compiles unchanged). On Linux these are
|
||||
// produced by the platform-signal layer from POSIX signals.
|
||||
# define CTRL_C_EVENT 0
|
||||
# define CTRL_BREAK_EVENT 1
|
||||
# define CTRL_CLOSE_EVENT 2
|
||||
# define CTRL_LOGOFF_EVENT 5
|
||||
# define CTRL_SHUTDOWN_EVENT 6
|
||||
|
||||
// Win32 Sleep(milliseconds) -> POSIX usleep(microseconds)
|
||||
# define Sleep(Milliseconds) usleep((useconds_t)(Milliseconds) * 1000)
|
||||
|
||||
#endif // HYPERDBG_ENV_LINUX
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ set(SourceFiles
|
|||
"../include/platform/user/code/platform-lib-calls.c"
|
||||
"../include/platform/user/code/platform-serial.c"
|
||||
"../include/platform/user/code/platform-ioctl.c"
|
||||
"../include/platform/user/code/platform-signal.c"
|
||||
"../script-eval/code/Functions.c"
|
||||
"../script-eval/code/Keywords.c"
|
||||
"../script-eval/code/PseudoRegisters.c"
|
||||
|
|
@ -175,6 +176,7 @@ set_source_files_properties(
|
|||
"../include/platform/user/code/platform-lib-calls.c"
|
||||
"../include/platform/user/code/platform-serial.c"
|
||||
"../include/platform/user/code/platform-ioctl.c"
|
||||
"../include/platform/user/code/platform-signal.c"
|
||||
"../script-eval/code/Functions.c"
|
||||
"../script-eval/code/Keywords.c"
|
||||
"../script-eval/code/PseudoRegisters.c"
|
||||
|
|
|
|||
|
|
@ -1300,7 +1300,7 @@ InitializeDebugger()
|
|||
//
|
||||
// Register the CTRL+C and CTRL+BREAK Signals handler
|
||||
//
|
||||
if (!SetConsoleCtrlHandler(BreakController, TRUE))
|
||||
if (!PlatformInstallCtrlHandler(BreakController))
|
||||
{
|
||||
ShowMessages("err, when registering CTRL+C and CTRL+BREAK Signals "
|
||||
"handler\n");
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ msbuild "$(SolutionDir)dependencies\zydis\msvc\Zydis.sln" /m /p:Configuration="R
|
|||
<ClInclude Include="..\include\platform\user\header\platform-lib-calls.h" />
|
||||
<ClInclude Include="..\include\platform\user\header\platform-serial.h" />
|
||||
<ClInclude Include="..\include\platform\user\header\platform-ioctl.h" />
|
||||
<ClInclude Include="..\include\platform\user\header\platform-signal.h" />
|
||||
<ClInclude Include="..\include\platform\user\header\windows-only\windows-privilege.h" />
|
||||
<ClInclude Include="..\include\platform\user\header\Windows.h" />
|
||||
<ClInclude Include="header\assembler.h" />
|
||||
|
|
@ -175,6 +176,7 @@ msbuild "$(SolutionDir)dependencies\zydis\msvc\Zydis.sln" /m /p:Configuration="R
|
|||
<ClCompile Include="..\include\platform\user\code\platform-lib-calls.c" />
|
||||
<ClCompile Include="..\include\platform\user\code\platform-serial.c" />
|
||||
<ClCompile Include="..\include\platform\user\code\platform-ioctl.c" />
|
||||
<ClCompile Include="..\include\platform\user\code\platform-signal.c" />
|
||||
<ClCompile Include="..\include\platform\user\code\windows-only\windows-privilege.c" />
|
||||
<ClCompile Include="..\script-eval\code\Functions.c" />
|
||||
<ClCompile Include="..\script-eval\code\Keywords.c" />
|
||||
|
|
|
|||
|
|
@ -203,6 +203,9 @@
|
|||
<ClInclude Include="..\include\platform\user\header\platform-ioctl.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\platform\user\header\platform-signal.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\messaging.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -658,6 +661,9 @@
|
|||
<ClCompile Include="..\include\platform\user\code\platform-ioctl.c">
|
||||
<Filter>code\platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\include\platform\user\code\platform-signal.c">
|
||||
<Filter>code\platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="code\app\messaging.cpp">
|
||||
<Filter>code\app</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -166,6 +166,11 @@ typedef const wchar_t *LPCWCHAR, *PCWCHAR;
|
|||
//
|
||||
#include "platform/user/header/platform-ioctl.h"
|
||||
|
||||
//
|
||||
// Platform signal (cross-platform console-control / CTRL+C handler registration)
|
||||
//
|
||||
#include "platform/user/header/platform-signal.h"
|
||||
|
||||
//
|
||||
// Platform-specific intrinsics
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue