Implementation of $peb pseudo-register.
160{
161#ifdef SCRIPT_ENGINE_USER_MODE
162
163
164
165 struct PROCESS_BASIC_INFORMATION
166 {
167 PVOID Reserved1;
168 PVOID PebBaseAddress;
169 PVOID Reserved2[2];
170 ULONG_PTR UniqueProcessId;
171 PVOID Reserved3;
172 };
173
175 {
177 PVOID Reserved2[3];
178 LIST_ENTRY InMemoryOrderModuleList;
179 };
180
182 {
186 PVOID Reserved3[2];
188 PVOID ProcessParameters;
190 PVOID Reserved5[52];
191 PVOID PostProcessInitRoutine;
193 PVOID Reserved7[1];
195 };
196
198 {
201 PWSTR Buffer;
202 };
203
204 struct LDR_MODULE
205 {
206 LIST_ENTRY InLoadOrderModuleList;
207 LIST_ENTRY InMemoryOrderModuleList;
208 LIST_ENTRY InInitializationOrderModuleList;
209 PVOID BaseAddress;
210 PVOID EntryPoint;
215 SHORT LoadCount;
216 SHORT TlsIndex;
217 LIST_ENTRY HashTableEntry;
219 };
220
221 enum PROCESSINFOCLASS
222 {
223 ProcessBasicInformation = 0,
224 ProcessDebugPort = 7,
225 ProcessWow64Information = 26,
226 ProcessImageFileName = 27
227 };
228
229 LPCWSTR NTDLL_NAME = L"ntdll.dll";
230 LPCSTR NTQUERYINFO_NAME = "NtQueryInformationProcess";
231
232 HMODULE NtdllMod;
233 HANDLE ThisProcess;
234 NTSTATUS NtCallRet;
236
237
238
239
240 NTSTATUS(WINAPI * QueryInfoProcPtr)
241 (HANDLE,
enum PROCESSINFOCLASS, PVOID,
ULONG, PULONG);
242
243 struct PROCESS_BASIC_INFORMATION BasicInfo;
245
246
247 ThisProcess = GetCurrentProcess();
248
249
250
251
252 NtdllMod = LoadLibraryW(NTDLL_NAME);
253
254
255
256
257 QueryInfoProcPtr =
258 (NTSTATUS(WINAPI *)(HANDLE,
enum PROCESSINFOCLASS, PVOID,
ULONG, PULONG))GetProcAddress(NtdllMod, NTQUERYINFO_NAME);
259
260
261
262
263 NtCallRet = QueryInfoProcPtr(ThisProcess, ProcessBasicInformation, &BasicInfo, sizeof(BasicInfo), &BytesReturned);
264
265
266
267
268 PebPtr = (
struct PEB *)BasicInfo.PebBaseAddress;
269
271
272#endif
273
274#ifdef SCRIPT_ENGINE_KERNEL_MODE
275
276
277
278
280#endif
281}
unsigned char BYTE
Definition BasicTypes.h:24
unsigned short USHORT
Definition BasicTypes.h:36
#define NULL64_ZERO
Definition BasicTypes.h:52
unsigned long ULONG
Definition BasicTypes.h:37
PEB LDR Data.
Definition UserAccess.h:23
PEB 64-bit.
Definition UserAccess.h:55
Definition casting.cpp:25