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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
use crate::ntioapi::PIO_STATUS_BLOCK;
use winapi::shared::ntdef::{HANDLE, LOGICAL, LONG, NTSTATUS, PLARGE_INTEGER, PVOID};
use winapi::um::winnt::{
PRTL_CRITICAL_SECTION, PTP_CALLBACK_ENVIRON, PTP_CALLBACK_INSTANCE, PTP_CLEANUP_GROUP, PTP_IO,
PTP_POOL, PTP_POOL_STACK_INFORMATION, PTP_SIMPLE_CALLBACK, PTP_TIMER, PTP_TIMER_CALLBACK,
PTP_WAIT, PTP_WAIT_CALLBACK, PTP_WORK, PTP_WORK_CALLBACK,
};
#[repr(C)]
pub struct TP_ALPC([u8; 0]);
pub type PTP_ALPC = *mut TP_ALPC;
FN!{stdcall PTP_ALPC_CALLBACK(
Instance: PTP_CALLBACK_INSTANCE,
Context: PVOID,
Alpc: PTP_ALPC,
) -> ()}
FN!{stdcall PTP_ALPC_CALLBACK_EX(
Instanc: PTP_CALLBACK_INSTANCE,
Contex: PVOID,
Alp: PTP_ALPC,
ApcContext: PVOID,
) -> ()}
EXTERN!{extern "system" {
fn TpAllocPool(
PoolReturn: *mut PTP_POOL,
Reserved: PVOID,
) -> NTSTATUS;
fn TpReleasePool(
Pool: PTP_POOL,
);
fn TpSetPoolMaxThreads(
Pool: PTP_POOL,
MaxThreads: LONG,
);
fn TpSetPoolMinThreads(
Pool: PTP_POOL,
MinThreads: LONG,
) -> NTSTATUS;
fn TpQueryPoolStackInformation(
Pool: PTP_POOL,
PoolStackInformation: PTP_POOL_STACK_INFORMATION,
) -> NTSTATUS;
fn TpSetPoolStackInformation(
Pool: PTP_POOL,
PoolStackInformation: PTP_POOL_STACK_INFORMATION,
) -> NTSTATUS;
fn TpAllocCleanupGroup(
CleanupGroupReturn: *mut PTP_CLEANUP_GROUP,
) -> NTSTATUS;
fn TpReleaseCleanupGroup(
CleanupGroup: PTP_CLEANUP_GROUP,
);
fn TpReleaseCleanupGroupMembers(
CleanupGroup: PTP_CLEANUP_GROUP,
CancelPendingCallbacks: LOGICAL,
CleanupParameter: PVOID,
);
fn TpCallbackSetEventOnCompletion(
Instance: PTP_CALLBACK_INSTANCE,
Event: HANDLE,
);
fn TpCallbackReleaseSemaphoreOnCompletion(
Instance: PTP_CALLBACK_INSTANCE,
Semaphore: HANDLE,
ReleaseCount: LONG,
);
fn TpCallbackReleaseMutexOnCompletion(
Instance: PTP_CALLBACK_INSTANCE,
Mutex: HANDLE,
);
fn TpCallbackLeaveCriticalSectionOnCompletion(
Instance: PTP_CALLBACK_INSTANCE,
CriticalSection: PRTL_CRITICAL_SECTION,
);
fn TpCallbackUnloadDllOnCompletion(
Instance: PTP_CALLBACK_INSTANCE,
DllHandle: PVOID,
);
fn TpCallbackMayRunLong(
Instance: PTP_CALLBACK_INSTANCE,
) -> NTSTATUS;
fn TpDisassociateCallback(
Instance: PTP_CALLBACK_INSTANCE,
);
fn TpSimpleTryPost(
Callback: PTP_SIMPLE_CALLBACK,
Context: PVOID,
CallbackEnviron: PTP_CALLBACK_ENVIRON,
) -> NTSTATUS;
fn TpAllocWork(
WorkReturn: *mut PTP_WORK,
Callback: PTP_WORK_CALLBACK,
Context: PVOID,
CallbackEnviron: PTP_CALLBACK_ENVIRON,
) -> NTSTATUS;
fn TpReleaseWork(
Work: PTP_WORK,
);
fn TpPostWork(
Work: PTP_WORK,
);
fn TpWaitForWork(
Work: PTP_WORK,
CancelPendingCallbacks: LOGICAL,
);
fn TpAllocTimer(
Timer: *mut PTP_TIMER,
Callback: PTP_TIMER_CALLBACK,
Context: PVOID,
CallbackEnviron: PTP_CALLBACK_ENVIRON,
) -> NTSTATUS;
fn TpReleaseTimer(
Timer: PTP_TIMER,
);
fn TpSetTimer(
Timer: PTP_TIMER,
DueTime: PLARGE_INTEGER,
Period: LONG,
WindowLength: LONG,
);
fn TpIsTimerSet(
Timer: PTP_TIMER,
) -> LOGICAL;
fn TpWaitForTimer(
Timer: PTP_TIMER,
CancelPendingCallbacks: LOGICAL,
);
fn TpAllocWait(
WaitReturn: *mut PTP_WAIT,
Callback: PTP_WAIT_CALLBACK,
Context: PVOID,
CallbackEnviron: PTP_CALLBACK_ENVIRON,
) -> NTSTATUS;
fn TpReleaseWait(
Wait: PTP_WAIT,
);
fn TpSetWait(
Wait: PTP_WAIT,
Handle: HANDLE,
Timeout: PLARGE_INTEGER,
);
fn TpWaitForWait(
Wait: PTP_WAIT,
CancelPendingCallbacks: LOGICAL,
);
}}
FN!{stdcall PTP_IO_CALLBACK(
Instance: PTP_CALLBACK_INSTANCE,
Context: PVOID,
ApcContext: PVOID,
IoSB: PIO_STATUS_BLOCK,
Io: PTP_IO,
) -> ()}
EXTERN!{extern "system" {
fn TpAllocIoCompletion(
IoReturn: *mut PTP_IO,
File: HANDLE,
Callback: PTP_IO_CALLBACK,
Context: PVOID,
CallbackEnviron: PTP_CALLBACK_ENVIRON,
) -> NTSTATUS;
fn TpReleaseIoCompletion(
Io: PTP_IO,
);
fn TpStartAsyncIoOperation(
Io: PTP_IO,
);
fn TpCancelAsyncIoOperation(
Io: PTP_IO,
);
fn TpWaitForIoCompletion(
Io: PTP_IO,
CancelPendingCallbacks: LOGICAL,
);
fn TpAllocAlpcCompletion(
AlpcReturn: *mut PTP_ALPC,
AlpcPort: HANDLE,
Callback: PTP_ALPC_CALLBACK,
Context: PVOID,
CallbackEnviron: PTP_CALLBACK_ENVIRON,
) -> NTSTATUS;
fn TpAllocAlpcCompletionEx(
AlpcReturn: *mut PTP_ALPC,
AlpcPort: HANDLE,
Callback: PTP_ALPC_CALLBACK_EX,
Context: PVOID,
CallbackEnviron: PTP_CALLBACK_ENVIRON,
) -> NTSTATUS;
fn TpReleaseAlpcCompletion(
Alpc: PTP_ALPC,
);
fn TpWaitForAlpcCompletion(
Alpc: PTP_ALPC,
);
}}
ENUM!{enum TP_TRACE_TYPE {
TpTraceThreadPriority = 1,
TpTraceThreadAffinity = 2,
MaxTpTraceType = 3,
}}
EXTERN!{extern "system" {
fn TpCaptureCaller(
Type: TP_TRACE_TYPE,
);
fn TpCheckTerminateWorker(
Thread: HANDLE,
);
}}
|