-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathntdll_undoc.cpp
102 lines (96 loc) · 2.61 KB
/
ntdll_undoc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "ntdll_undoc.h"
NTSTATUS (NTAPI *NtCreateProcessEx)
(
OUT PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN HANDLE ParentProcess,
IN ULONG Flags,
IN HANDLE SectionHandle OPTIONAL,
IN HANDLE DebugPort OPTIONAL,
IN HANDLE ExceptionPort OPTIONAL,
IN BOOLEAN InJob
) = NULL;
NTSTATUS (NTAPI *RtlCreateProcessParametersEx)(
_Out_ PRTL_USER_PROCESS_PARAMETERS *pProcessParameters,
_In_ PUNICODE_STRING ImagePathName,
_In_opt_ PUNICODE_STRING DllPath,
_In_opt_ PUNICODE_STRING CurrentDirectory,
_In_opt_ PUNICODE_STRING CommandLine,
_In_opt_ PVOID Environment,
_In_opt_ PUNICODE_STRING WindowTitle,
_In_opt_ PUNICODE_STRING DesktopInfo,
_In_opt_ PUNICODE_STRING ShellInfo,
_In_opt_ PUNICODE_STRING RuntimeData,
_In_ ULONG Flags // pass RTL_USER_PROC_PARAMS_NORMALIZED to keep parameters normalized
) = NULL;
NTSTATUS (NTAPI *NtCreateThreadEx) (
OUT PHANDLE ThreadHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN HANDLE ProcessHandle,
IN PVOID StartRoutine,
IN PVOID Argument OPTIONAL,
IN ULONG CreateFlags,
IN ULONG_PTR ZeroBits,
IN SIZE_T StackSize OPTIONAL,
IN SIZE_T MaximumStackSize OPTIONAL,
IN PVOID AttributeList OPTIONAL
) = NULL;
bool init_ntdll_func()
{
HMODULE lib = LoadLibraryA("ntdll.dll");
if (lib == nullptr) {
return false;
}
FARPROC proc = GetProcAddress(lib, "NtCreateProcessEx");
if (proc == nullptr) {
return false;
}
NtCreateProcessEx = (NTSTATUS (NTAPI *)(
PHANDLE,
ACCESS_MASK,
POBJECT_ATTRIBUTES,
HANDLE,
ULONG,
HANDLE,
HANDLE,
HANDLE,
BOOLEAN
)) proc;
proc = GetProcAddress(lib, "RtlCreateProcessParametersEx");
if (proc == nullptr) {
return false;
}
RtlCreateProcessParametersEx = (NTSTATUS (NTAPI *)(
PRTL_USER_PROCESS_PARAMETERS*,
PUNICODE_STRING,
PUNICODE_STRING,
PUNICODE_STRING,
PUNICODE_STRING,
PVOID,
PUNICODE_STRING,
PUNICODE_STRING,
PUNICODE_STRING,
PUNICODE_STRING,
ULONG
)) proc;
proc = GetProcAddress(lib, "NtCreateThreadEx");
if (proc == nullptr) {
return false;
}
NtCreateThreadEx = (NTSTATUS (NTAPI *)(
PHANDLE,
ACCESS_MASK,
POBJECT_ATTRIBUTES,
HANDLE,
PVOID,
PVOID,
ULONG,
ULONG_PTR,
SIZE_T,
SIZE_T,
PVOID
)) proc;
return true;
}