HyperDbg Debugger
Toggle main menu visibility
Loading...
Searching...
No Matches
platform-lib-calls.h
Go to the documentation of this file.
1
12
#pragma once
13
14
#if defined(__linux__)
15
# include "
../../../../include/SDK/HyperDbgSdk.h
"
16
#endif
// defined(__linux__)
17
18
#include <stdarg.h>
19
#include <stddef.h>
20
21
//
22
// VSNPRINTF
23
//
24
INT
25
PlatformVsnprintf
(
char
* Buffer, SIZE_T BufferSize,
const
char
* Format, va_list ArgList);
26
27
//
28
// STRDUP
29
//
30
char
*
31
PlatformStrDup
(
const
char
* Str);
32
33
//
34
// SET MEMORY TO ZERO
35
//
36
VOID
37
PlatformZeroMemory
(
PVOID
Buffer, SIZE_T Size);
38
39
//
40
// SPRINTF
41
//
42
INT
43
PlatformSprintf
(
char
* Buffer, SIZE_T BufferSize,
const
char
* Format, ...);
44
45
//
46
// HIGH-RESOLUTION PERFORMANCE COUNTER
47
//
48
BOOLEAN
49
PlatformQueryPerformanceFrequency
(LARGE_INTEGER * Frequency);
50
51
BOOLEAN
52
PlatformQueryPerformanceCounter
(LARGE_INTEGER * Count);
53
54
//
55
// EVENT / SYNCHRONIZATION OBJECTS
56
//
57
HANDLE
58
PlatformCreateEvent
(
BOOLEAN
ManualReset,
BOOLEAN
InitialState);
59
60
BOOLEAN
61
PlatformSetEvent
(HANDLE EventHandle);
62
63
BOOLEAN
64
PlatformResetEvent
(HANDLE EventHandle);
65
66
DWORD
67
PlatformWaitForSingleObject
(HANDLE Handle,
DWORD
TimeoutMilliseconds);
68
69
BOOLEAN
70
PlatformCloseHandle
(HANDLE Handle);
71
72
//
73
// LAST OS ERROR
74
//
75
// TODO (linux, correctness): the wrappers below only unify the success/failure
76
// *boolean* convention. The actual error semantics still differ across platforms
77
// and must be reconciled later:
78
// - PlatformGetLastError returns raw Linux errno (EACCES=13, ...) which does NOT
79
// match the Win32 ERROR_* code space (ERROR_ACCESS_DENIED=5, ...). Code that
80
// merely logs/checks-nonzero is fine; code that compares against ERROR_* needs
81
// an errno -> ERROR_* mapping here.
82
// - Failure sentinels are not uniform across the Win32 calls we wrap: file opens
83
// fail with INVALID_HANDLE_VALUE (not NULL), most other handle calls fail with
84
// NULL. Callers must test the right one.
85
// For now: getting the project to compile is step 1; correctness comes next.
86
//
87
DWORD
88
PlatformGetLastError
(VOID);
89
90
//
91
// CONSOLE OUTPUT (raw bytes to stdout)
92
//
93
BOOLEAN
94
PlatformWriteConsole
(
const
VOID * Buffer,
DWORD
NumberOfBytes
);
95
96
//
97
// FILE I/O
98
//
99
HANDLE
100
PlatformOpenFileForWriting
(
const
WCHAR * Path);
101
102
BOOLEAN
103
PlatformWriteFile
(HANDLE
FileHandle
,
const
VOID * Buffer,
DWORD
NumberOfBytes
);
104
105
BOOLEAN
106
PlatformCloseFile
(HANDLE
FileHandle
);
107
108
//
109
// READ-ONLY FILE MAPPING
110
//
111
// PlatformMapFileReadOnly also hands back the still-open file handle in
112
// *OutFileHandle, so callers can issue supplementary raw reads via
113
// PlatformReadFileAtOffset; release everything with PlatformUnmapFile.
114
//
115
VOID *
116
PlatformMapFileReadOnly
(
const
WCHAR * Path, PSIZE_T OutFileSize, PHANDLE OutFileHandle);
117
118
BOOLEAN
119
PlatformReadFileAtOffset
(HANDLE
FileHandle
, UINT64 Offset, VOID * Buffer,
DWORD
NumberOfBytes
, LPDWORD BytesRead);
120
121
VOID
122
PlatformUnmapFile
(VOID * BaseAddress, SIZE_T FileSize, HANDLE
FileHandle
);
123
124
//
125
// PROCESS / THREAD IDENTITY
126
//
127
UINT32
128
PlatformGetCurrentThreadId
(VOID);
129
130
UINT32
131
PlatformGetCurrentProcessorNumber
(VOID);
132
133
UINT32
134
PlatformGetCurrentProcessId
(VOID);
135
136
CHAR
*
137
PlatformGetCurrentProcessName
(VOID);
NumberOfBytes
POOL_TYPE SIZE_T NumberOfBytes
Definition
Hooks.h:88
FileHandle
PHANDLE FileHandle
Definition
SyscallFootprints.h:133
BOOLEAN
UCHAR BOOLEAN
Definition
BasicTypes.h:35
PVOID
void * PVOID
Definition
BasicTypes.h:56
INT
int INT
Definition
BasicTypes.h:43
DWORD
unsigned long DWORD
Definition
BasicTypes.h:38
UINT32
unsigned int UINT32
Definition
BasicTypes.h:54
CHAR
char CHAR
Definition
BasicTypes.h:33
HyperDbgSdk.h
PlatformCloseHandle
BOOLEAN PlatformCloseHandle(HANDLE Handle)
Platform independent wrapper for CloseHandle.
Definition
platform-lib-calls.c:334
PlatformResetEvent
BOOLEAN PlatformResetEvent(HANDLE EventHandle)
Platform independent wrapper for ResetEvent.
Definition
platform-lib-calls.c:295
PlatformQueryPerformanceCounter
BOOLEAN PlatformQueryPerformanceCounter(LARGE_INTEGER *Count)
Platform independent wrapper for QueryPerformanceCounter.
Definition
platform-lib-calls.c:106
PlatformWriteFile
BOOLEAN PlatformWriteFile(HANDLE FileHandle, const VOID *Buffer, DWORD NumberOfBytes)
Platform independent wrapper to write a buffer to an open file.
Definition
platform-lib-calls.c:420
PlatformSetEvent
BOOLEAN PlatformSetEvent(HANDLE EventHandle)
Platform independent wrapper for SetEvent.
Definition
platform-lib-calls.c:279
PlatformOpenFileForWriting
HANDLE PlatformOpenFileForWriting(const WCHAR *Path)
Platform independent wrapper to create/open a file for writing.
Definition
platform-lib-calls.c:392
PlatformGetCurrentProcessorNumber
UINT32 PlatformGetCurrentProcessorNumber(VOID)
Platform independent wrapper for GetCurrentProcessorNumber / sched_getcpu.
Definition
platform-lib-calls.c:168
PlatformGetCurrentThreadId
UINT32 PlatformGetCurrentThreadId(VOID)
Platform independent wrapper for GetCurrentThreadId / gettid.
Definition
platform-lib-calls.c:151
PlatformMapFileReadOnly
VOID * PlatformMapFileReadOnly(const WCHAR *Path, PSIZE_T OutFileSize, PHANDLE OutFileHandle)
Platform independent wrapper to map an entire file read-only into memory.
Definition
platform-lib-calls.c:463
PlatformStrDup
char * PlatformStrDup(const char *Str)
Platform independent wrapper for _strdup / strdup.
Definition
platform-lib-calls.c:51
PlatformSprintf
INT PlatformSprintf(char *Buffer, SIZE_T BufferSize, const char *Format,...)
Platform independent wrapper for sprintf_s / snprintf.
Definition
PlatformMem.c:29
PlatformReadFileAtOffset
BOOLEAN PlatformReadFileAtOffset(HANDLE FileHandle, UINT64 Offset, VOID *Buffer, DWORD NumberOfBytes, LPDWORD BytesRead)
Platform independent wrapper for a positioned (seek + read) file read.
Definition
platform-lib-calls.c:549
PlatformCloseFile
BOOLEAN PlatformCloseFile(HANDLE FileHandle)
Platform independent wrapper to close a file opened by PlatformOpenFileForWriting.
Definition
platform-lib-calls.c:440
PlatformZeroMemory
VOID PlatformZeroMemory(PVOID Buffer, SIZE_T Size)
Zeros a memory block.
Definition
PlatformMem.c:155
PlatformQueryPerformanceFrequency
BOOLEAN PlatformQueryPerformanceFrequency(LARGE_INTEGER *Frequency)
Platform independent wrapper for QueryPerformanceFrequency.
Definition
platform-lib-calls.c:87
PlatformGetLastError
DWORD PlatformGetLastError(VOID)
Platform independent wrapper for GetLastError.
Definition
platform-lib-calls.c:350
PlatformCreateEvent
HANDLE PlatformCreateEvent(BOOLEAN ManualReset, BOOLEAN InitialState)
Platform independent wrapper for CreateEvent.
Definition
platform-lib-calls.c:257
PlatformVsnprintf
INT PlatformVsnprintf(char *Buffer, SIZE_T BufferSize, const char *Format, va_list ArgList)
Platform independent wrapper for vsprintf_s / vsnprintf.
Definition
platform-lib-calls.c:33
PlatformWriteConsole
BOOLEAN PlatformWriteConsole(const VOID *Buffer, DWORD NumberOfBytes)
Platform independent wrapper to write raw bytes to the console.
Definition
platform-lib-calls.c:374
PlatformWaitForSingleObject
DWORD PlatformWaitForSingleObject(HANDLE Handle, DWORD TimeoutMilliseconds)
Platform independent wrapper for WaitForSingleObject.
Definition
platform-lib-calls.c:313
PlatformGetCurrentProcessName
CHAR * PlatformGetCurrentProcessName(VOID)
Platform independent wrapper to get the current process name.
Definition
platform-lib-calls.c:202
PlatformGetCurrentProcessId
UINT32 PlatformGetCurrentProcessId(VOID)
Platform independent wrapper for GetCurrentProcessId / getpid.
Definition
platform-lib-calls.c:185
PlatformUnmapFile
VOID PlatformUnmapFile(VOID *BaseAddress, SIZE_T FileSize, HANDLE FileHandle)
Platform independent wrapper to release a mapping from PlatformMapFileReadOnly.
Definition
platform-lib-calls.c:589
hyperdbg
include
platform
user
header
platform-lib-calls.h
Generated by
1.17.0