HyperDbg Debugger
Loading...
Searching...
No Matches
Environment.h
Go to the documentation of this file.
1
12#pragma once
13
15// Definitions //
17
18//
19// Check for platform
20//
21#if defined(_WIN32) || defined(_WIN64)
22# define HYPERDBG_ENV_WINDOWS
23#elif defined(__linux__)
24// # error "This code cannot compile on Linux yet"
25# define HYPERDBG_ENV_LINUX
26#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
27# error "This code cannot compile on BSD yet"
28# define HYPERDBG_ENV_BSD
29#else
30# error "This code cannot compile on non-Windows, non-Linux, and non-BSD platforms"
31#endif
32
33#ifdef HYPERDBG_ENV_LINUX
34
35// SAL annotations
36# define _In_
37# define _Out_
38# define _Inout_
39# define _In_opt_
40# define _Out_opt_
41# define _In_z_
42# define _Outptr_
43# define _In_reads_bytes_(x)
44# define _Out_writes_bytes_(x)
45# define _Inout_updates_bytes_all_(x)
46
47// wchar_t is a C++ built-in but needs this header in C
48# include <wchar.h>
49
50// POSIX sleep primitives (usleep) backing the Win32 Sleep() shim below
51# include <unistd.h>
52
53// Windows string/char types
54typedef char TCHAR;
55typedef char * LPTSTR;
56typedef const char * LPCTSTR;
57typedef const char * LPCSTR;
58typedef char * LPSTR;
59typedef const char * PCSTR;
60typedef char * PSTR;
61typedef short * PWCHAR;
62
63// Windows socket type (Linux sockets are plain int)
64typedef int SOCKET;
65# define INVALID_SOCKET ((SOCKET)(-1))
66# define SOCKET_ERROR (-1)
67
68// Windows calling convention (no-op on Linux)
69# define WINAPI
70
71// Windows module handle (equivalent to dlopen's void * on Linux)
72typedef void * HMODULE;
73
74// Misc Windows macros
75# define UNREFERENCED_PARAMETER(P) ((void)(P))
76
77// Win32 wait/event constants (used by the cross-platform sync wrappers)
78# define INFINITE 0xFFFFFFFF
79# define WAIT_OBJECT_0 0x00000000
80
81// Win32 invalid handle sentinel (returned by the cross-platform file/serial wrappers)
82# define INVALID_HANDLE_VALUE ((HANDLE)(SIZE_T)-1)
83
84// Win32 console-control event codes (kept at their Windows values so the
85// shared BreakController() switch compiles unchanged). On Linux these are
86// produced by the platform-signal layer from POSIX signals.
87# define CTRL_C_EVENT 0
88# define CTRL_BREAK_EVENT 1
89# define CTRL_CLOSE_EVENT 2
90# define CTRL_LOGOFF_EVENT 5
91# define CTRL_SHUTDOWN_EVENT 6
92
93// Win32 Sleep(milliseconds) -> POSIX usleep(microseconds)
94# define Sleep(Milliseconds) usleep((useconds_t)(Milliseconds) * 1000)
95
96#endif // HYPERDBG_ENV_LINUX