Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
hook_trace.hpp File Reference
#include <Windows.h>
#include <winternl.h>

Go to the source code of this file.

Macros

#define HOOK_PROVIDER_NAME   "Panoptes.Hook"
#define HOOK_KEYWORD_DETECTION   0x1

Functions

VOID HookTraceInit ()
 Registers the provider. Call before placing the hooks.
VOID HookTraceUninit ()
 Unregisters the provider. Call after removing the hooks.
BOOL HookLoggingEnabled ()
 Whether the Log_* functions should write. FALSE on the thread running a Detours transaction (so the hooks do not report Detours patching ntdll), and while a second instance of this DLL loaded in the process does the logging instead. Defined in hook.cpp.
VOID Log_PEWritten (HANDLE ProcessHandle, BOOL CurrentProcess, PVOID BaseAddress, BOOL Executable)
 NtWriteVirtualMemory wrote a PE image. Event "PEWritten".
VOID Log_PEBWritten (HANDLE ProcessHandle, BOOL CurrentProcess, SIZE_T Size, ULONG_PTR PebOffset)
 NtWriteVirtualMemory wrote to a process's PEB. Event "PEBWritten".
VOID Log_EntryPointWritten (HANDLE ProcessHandle, BOOL CurrentProcess, PVOID BaseAddress, SIZE_T Size, PVOID EntryPoint, BOOL CodeWritten, BOOL FieldWritten)
 NtWriteVirtualMemory wrote over the entry point of a process's main image (the image PEB.ImageBaseAddress points at): the first byte of the entry point code, the AddressOfEntryPoint field of its headers, or both. Event "EntryPointWritten".
VOID Log_PEBRead (HANDLE ProcessHandle, BOOL CurrentProcess, SIZE_T Size, ULONG_PTR PebOffset)
 NtReadVirtualMemory read from a process's PEB. Event "PEBRead".
VOID Log_ProtectionSetAttempt (HANDLE ProcessHandle, BOOL CurrentProcess, NTSTATUS Status)
 NtSetInformationProcess was called to set a process's protection level (ProcessProtectionInformation). Only the kernel may do this, so the call is expected to fail; the attempt itself is the signal. Event "ProtectionSetAttempt".
VOID Log_ApcQueued (HANDLE ThreadHandle, BOOL CurrentProcess, const char *Api, PVOID ApcRoutine, ULONG ApcFlags)
 NtQueueApcThread or NtQueueApcThreadEx2 queued an APC to a thread. Event "ApcQueued". TargetProcessId is the process that owns the thread; the event also carries TargetThreadId. Both are 0 when the handle lacks THREAD_QUERY_LIMITED_INFORMATION; the thread is still known to be remote, because local threads are matched by object rather than by ID.
VOID Log_RemoteThreadCreated (HANDLE ProcessHandle, PVOID StartRoutine, ULONG CreateFlags)
 NtCreateThreadEx created a thread in another process. Event "RemoteThreadCreated".
VOID Log_ExecutableAllocated (HANDLE ProcessHandle, BOOL CurrentProcess, const char *Api, PVOID BaseAddress, SIZE_T RegionSize, ULONG AllocationType, ULONG Protection)
 NtAllocateVirtualMemory or NtAllocateVirtualMemoryEx allocated executable memory. Event "ExecutableAllocated".
VOID Log_ExecutableUnmapped (HANDLE ProcessHandle, BOOL CurrentProcess, const char *Api, PVOID BaseAddress, BOOL IsImage)
 NtUnmapViewOfSection or NtUnmapViewOfSectionEx unmapped a view with executable pages. Unmapping an image from another process is the first step of process hollowing. Event "ExecutableUnmapped".
VOID Log_RemoteViewMapped (HANDLE ProcessHandle, const char *Api, PVOID BaseAddress, SIZE_T ViewSize, ULONG Protection, BOOL Executable, BOOL IsImage)
 NtMapViewOfSection or NtMapViewOfSectionEx mapped a view into another process. Mapping a shared section into a target is a way to inject code without NtWriteVirtualMemory. Event "RemoteViewMapped".
VOID Log_PEMadeExecutable (HANDLE ProcessHandle, BOOL CurrentProcess, PVOID BaseAddress, ULONG OldProtection, ULONG NewProtection)
 NtProtectVirtualMemory made a region starting with a PE image executable. Event "PEMadeExecutable".

Macro Definition Documentation

◆ HOOK_KEYWORD_DETECTION

◆ HOOK_PROVIDER_NAME

#define HOOK_PROVIDER_NAME   "Panoptes.Hook"

Definition at line 21 of file hook_trace.hpp.

Referenced by TRACELOGGING_DEFINE_PROVIDER().

Function Documentation

◆ HookLoggingEnabled()

BOOL HookLoggingEnabled ( )

Whether the Log_* functions should write. FALSE on the thread running a Detours transaction (so the hooks do not report Detours patching ntdll), and while a second instance of this DLL loaded in the process does the logging instead. Defined in hook.cpp.

Definition at line 860 of file hook.cpp.

861{
862 return g_Silenced == 0 && GetCurrentThreadId() != g_TransactionThreadId;
863}

Referenced by Log_ApcQueued(), Log_EntryPointWritten(), Log_ExecutableAllocated(), Log_ExecutableUnmapped(), Log_PEBRead(), Log_PEBWritten(), Log_PEMadeExecutable(), Log_PEWritten(), Log_ProtectionSetAttempt(), Log_RemoteThreadCreated(), and Log_RemoteViewMapped().

◆ HookTraceInit()

VOID HookTraceInit ( )

Registers the provider. Call before placing the hooks.

Definition at line 13 of file hook_trace.cpp.

14{
15 TraceLoggingRegister(g_hHookProvider);
16}

Referenced by DllMain().

◆ HookTraceUninit()

VOID HookTraceUninit ( )

Unregisters the provider. Call after removing the hooks.

Definition at line 18 of file hook_trace.cpp.

19{
20 TraceLoggingUnregister(g_hHookProvider);
21}

Referenced by DllMain().

◆ Log_ApcQueued()

VOID Log_ApcQueued ( HANDLE ThreadHandle,
BOOL CurrentProcess,
const char * Api,
PVOID ApcRoutine,
ULONG ApcFlags )

NtQueueApcThread or NtQueueApcThreadEx2 queued an APC to a thread. Event "ApcQueued". TargetProcessId is the process that owns the thread; the event also carries TargetThreadId. Both are 0 when the handle lacks THREAD_QUERY_LIMITED_INFORMATION; the thread is still known to be remote, because local threads are matched by object rather than by ID.

Parameters
ThreadHandleThe thread the APC was queued to.
CurrentProcessWhether the thread is in the current process.
ApiThe name of the hooked function.
ApcRoutineThe routine the APC runs.
ApcFlagsThe QUEUE_USER_APC_FLAGS_* values (0x1 for a special user APC, which runs without the thread entering an alertable wait); always 0 for NtQueueApcThread.

Definition at line 202 of file hook_trace.cpp.

203{
204 if (!HookLoggingEnabled())
205 {
206 return;
207 }
208
209 DWORD targetProcessId = 0;
210 DWORD targetThreadId = 0;
211 TargetThreadIdsOf(ThreadHandle, &targetProcessId, &targetThreadId);
212
213 TraceLoggingWrite(g_hHookProvider, "ApcQueued",
214 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
215 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
216 TraceLoggingString(Api, "Api"),
217 TraceLoggingUInt32(targetProcessId, "TargetProcessId"),
218 TraceLoggingBool(!CurrentProcess, "Remote"),
219 TraceLoggingUInt32(targetThreadId, "TargetThreadId"),
220 TraceLoggingPointer(ApcRoutine, "ApcRoutine"),
221 TraceLoggingHexUInt32(ApcFlags, "ApcFlags"));
222
223 DebugMessage("[Panoptes] %s: APC queued to a thread in the %s process, routine %p, flags 0x%lx\n",
224 Api, CurrentProcess ? "current" : "remote", ApcRoutine, ApcFlags);
225}
BOOL HookLoggingEnabled()
Whether the Log_* functions should write. FALSE on the thread running a Detours transaction (so the h...
Definition hook.cpp:860
#define HOOK_KEYWORD_DETECTION

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtQueueApcThread(), and Hooked_NtQueueApcThreadEx2().

◆ Log_EntryPointWritten()

VOID Log_EntryPointWritten ( HANDLE ProcessHandle,
BOOL CurrentProcess,
PVOID BaseAddress,
SIZE_T Size,
PVOID EntryPoint,
BOOL CodeWritten,
BOOL FieldWritten )

NtWriteVirtualMemory wrote over the entry point of a process's main image (the image PEB.ImageBaseAddress points at): the first byte of the entry point code, the AddressOfEntryPoint field of its headers, or both. Event "EntryPointWritten".

Parameters
ProcessHandleThe process written to.
CurrentProcessWhether ProcessHandle is the current process.
BaseAddressWhere the write started.
SizeThe number of bytes written.
EntryPointThe entry point address after the write, or NULL if AddressOfEntryPoint is 0.
CodeWrittenWhether the write covered the entry point code.
FieldWrittenWhether the write covered the AddressOfEntryPoint field.

Definition at line 135 of file hook_trace.cpp.

137{
138 if (!HookLoggingEnabled())
139 {
140 return;
141 }
142
143 TraceLoggingWrite(g_hHookProvider, "EntryPointWritten",
144 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
145 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
146 TraceLoggingString("NtWriteVirtualMemory", "Api"),
147 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
148 TraceLoggingBool(!CurrentProcess, "Remote"),
149 TraceLoggingPointer(BaseAddress, "BaseAddress"),
150 TraceLoggingUInt64((UINT64)Size, "Size"),
151 TraceLoggingPointer(EntryPoint, "EntryPoint"),
152 TraceLoggingBool(CodeWritten, "CodeWritten"),
153 TraceLoggingBool(FieldWritten, "FieldWritten"));
154
155 const char* what = (CodeWritten && FieldWritten) ? "entry point code and AddressOfEntryPoint field"
156 : CodeWritten ? "entry point code" : "AddressOfEntryPoint field";
157 DebugMessage("[Panoptes] NtWriteVirtualMemory: %Iu bytes written over the main image's %s in the %s process, entry point %p\n",
158 Size, what, CurrentProcess ? "current" : "remote", EntryPoint);
159}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtWriteVirtualMemory().

◆ Log_ExecutableAllocated()

VOID Log_ExecutableAllocated ( HANDLE ProcessHandle,
BOOL CurrentProcess,
const char * Api,
PVOID BaseAddress,
SIZE_T RegionSize,
ULONG AllocationType,
ULONG Protection )

NtAllocateVirtualMemory or NtAllocateVirtualMemoryEx allocated executable memory. Event "ExecutableAllocated".

Parameters
ProcessHandleThe process the memory was allocated in.
CurrentProcessWhether ProcessHandle is the current process.
ApiThe name of the hooked function.
BaseAddressThe base of the allocation, as returned by the kernel.
RegionSizeThe size of the allocation, rounded up to whole pages.
AllocationTypeThe MEM_* allocation flags.
ProtectionThe PAGE_* protection.

Definition at line 247 of file hook_trace.cpp.

249{
250 if (!HookLoggingEnabled())
251 {
252 return;
253 }
254
255 TraceLoggingWrite(g_hHookProvider, "ExecutableAllocated",
256 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
257 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
258 TraceLoggingString(Api, "Api"),
259 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
260 TraceLoggingBool(!CurrentProcess, "Remote"),
261 TraceLoggingPointer(BaseAddress, "BaseAddress"),
262 TraceLoggingUInt64((UINT64)RegionSize, "RegionSize"),
263 TraceLoggingHexUInt32(AllocationType, "AllocationType"),
264 TraceLoggingHexUInt32(Protection, "Protection"));
265
266 DebugMessage("[Panoptes] %s: %Iu executable bytes allocated at %p in the %s process (protection 0x%lx)\n",
267 Api, RegionSize, BaseAddress, CurrentProcess ? "current" : "remote", Protection);
268}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtAllocateVirtualMemory(), and Hooked_NtAllocateVirtualMemoryEx().

◆ Log_ExecutableUnmapped()

VOID Log_ExecutableUnmapped ( HANDLE ProcessHandle,
BOOL CurrentProcess,
const char * Api,
PVOID BaseAddress,
BOOL IsImage )

NtUnmapViewOfSection or NtUnmapViewOfSectionEx unmapped a view with executable pages. Unmapping an image from another process is the first step of process hollowing. Event "ExecutableUnmapped".

Parameters
ProcessHandleThe process the view was unmapped from.
CurrentProcessWhether ProcessHandle is the current process.
ApiThe name of the hooked function.
BaseAddressThe address passed to the unmap call.
IsImageWhether the view was a mapped image (MEM_IMAGE). Logged as "IsImage", since the service fills in "Image" with the process's image path.

Definition at line 270 of file hook_trace.cpp.

272{
273 if (!HookLoggingEnabled())
274 {
275 return;
276 }
277
278 TraceLoggingWrite(g_hHookProvider, "ExecutableUnmapped",
279 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
280 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
281 TraceLoggingString(Api, "Api"),
282 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
283 TraceLoggingBool(!CurrentProcess, "Remote"),
284 TraceLoggingPointer(BaseAddress, "BaseAddress"),
285 TraceLoggingBool(IsImage, "IsImage"));
286
287 DebugMessage("[Panoptes] %s: executable %s at %p unmapped from the %s process\n",
288 Api, IsImage ? "image" : "view", BaseAddress, CurrentProcess ? "current" : "remote");
289}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtUnmapViewOfSection(), and Hooked_NtUnmapViewOfSectionEx().

◆ Log_PEBRead()

VOID Log_PEBRead ( HANDLE ProcessHandle,
BOOL CurrentProcess,
SIZE_T Size,
ULONG_PTR PebOffset )

NtReadVirtualMemory read from a process's PEB. Event "PEBRead".

Parameters
ProcessHandleThe process read from.
CurrentProcessWhether ProcessHandle is the current process.
SizeThe number of bytes read.
PebOffsetThe offset of the read from the start of the PEB.

Definition at line 161 of file hook_trace.cpp.

162{
163 if (!HookLoggingEnabled())
164 {
165 return;
166 }
167
168 // Debuggers, Task Manager and Process Explorer read other processes' PEBs routinely, so this
169 // is informational rather than a warning
170 TraceLoggingWrite(g_hHookProvider, "PEBRead",
171 TraceLoggingLevel(WINEVENT_LEVEL_INFO),
172 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
173 TraceLoggingString("NtReadVirtualMemory", "Api"),
174 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
175 TraceLoggingBool(!CurrentProcess, "Remote"),
176 TraceLoggingUInt64((UINT64)Size, "Size"),
177 TraceLoggingHexUInt64((UINT64)PebOffset, "PebOffset"));
178
179 DebugMessage("[Panoptes] NtReadVirtualMemory: %Iu bytes read from the PEB of the %s process at offset 0x%Ix\n",
180 Size, CurrentProcess ? "current" : "remote", PebOffset);
181}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtReadVirtualMemory().

◆ Log_PEBWritten()

VOID Log_PEBWritten ( HANDLE ProcessHandle,
BOOL CurrentProcess,
SIZE_T Size,
ULONG_PTR PebOffset )

NtWriteVirtualMemory wrote to a process's PEB. Event "PEBWritten".

Parameters
ProcessHandleThe process written to.
CurrentProcessWhether ProcessHandle is the current process.
SizeThe number of bytes written.
PebOffsetThe offset of the write from the start of the PEB.

Definition at line 115 of file hook_trace.cpp.

116{
117 if (!HookLoggingEnabled())
118 {
119 return;
120 }
121
122 TraceLoggingWrite(g_hHookProvider, "PEBWritten",
123 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
124 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
125 TraceLoggingString("NtWriteVirtualMemory", "Api"),
126 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
127 TraceLoggingBool(!CurrentProcess, "Remote"),
128 TraceLoggingUInt64((UINT64)Size, "Size"),
129 TraceLoggingHexUInt64((UINT64)PebOffset, "PebOffset"));
130
131 DebugMessage("[Panoptes] NtWriteVirtualMemory: %Iu bytes written to the PEB of the %s process at offset 0x%Ix\n",
132 Size, CurrentProcess ? "current" : "remote", PebOffset);
133}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtWriteVirtualMemory().

◆ Log_PEMadeExecutable()

VOID Log_PEMadeExecutable ( HANDLE ProcessHandle,
BOOL CurrentProcess,
PVOID BaseAddress,
ULONG OldProtection,
ULONG NewProtection )

NtProtectVirtualMemory made a region starting with a PE image executable. Event "PEMadeExecutable".

Parameters
ProcessHandleThe process whose memory was reprotected.
CurrentProcessWhether ProcessHandle is the current process.
BaseAddressThe start of the region.
OldProtectionThe previous protection, or 0 if the caller did not ask for it.
NewProtectionThe new protection.

Definition at line 316 of file hook_trace.cpp.

318{
319 if (!HookLoggingEnabled())
320 {
321 return;
322 }
323
324 TraceLoggingWrite(g_hHookProvider, "PEMadeExecutable",
325 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
326 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
327 TraceLoggingString("NtProtectVirtualMemory", "Api"),
328 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
329 TraceLoggingBool(!CurrentProcess, "Remote"),
330 TraceLoggingPointer(BaseAddress, "BaseAddress"),
331 TraceLoggingHexUInt32(OldProtection, "OldProtection"),
332 TraceLoggingHexUInt32(NewProtection, "NewProtection"));
333
334 DebugMessage("[Panoptes] NtProtectVirtualMemory: PE image at %p in the %s process made executable (0x%lx -> 0x%lx)\n",
335 BaseAddress, CurrentProcess ? "current" : "remote", OldProtection, NewProtection);
336}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtProtectVirtualMemory().

◆ Log_PEWritten()

VOID Log_PEWritten ( HANDLE ProcessHandle,
BOOL CurrentProcess,
PVOID BaseAddress,
BOOL Executable )

NtWriteVirtualMemory wrote a PE image. Event "PEWritten".

Parameters
ProcessHandleThe process written to.
CurrentProcessWhether ProcessHandle is the current process.
BaseAddressWhere the image was written.
ExecutableWhether the destination memory is executable.

Definition at line 95 of file hook_trace.cpp.

96{
97 if (!HookLoggingEnabled())
98 {
99 return;
100 }
101
102 TraceLoggingWrite(g_hHookProvider, "PEWritten",
103 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
104 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
105 TraceLoggingString("NtWriteVirtualMemory", "Api"),
106 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
107 TraceLoggingBool(!CurrentProcess, "Remote"),
108 TraceLoggingPointer(BaseAddress, "BaseAddress"),
109 TraceLoggingBool(Executable, "Executable"));
110
111 DebugMessage("[Panoptes] NtWriteVirtualMemory: PE image written to %p in the %s process, destination %s\n",
112 BaseAddress, CurrentProcess ? "current" : "remote", Executable ? "executable" : "not executable");
113}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtWriteVirtualMemory().

◆ Log_ProtectionSetAttempt()

VOID Log_ProtectionSetAttempt ( HANDLE ProcessHandle,
BOOL CurrentProcess,
NTSTATUS Status )

NtSetInformationProcess was called to set a process's protection level (ProcessProtectionInformation). Only the kernel may do this, so the call is expected to fail; the attempt itself is the signal. Event "ProtectionSetAttempt".

Parameters
ProcessHandleThe process whose protection was to be set.
CurrentProcessWhether ProcessHandle is the current process.
StatusThe NTSTATUS the call returned.

Definition at line 183 of file hook_trace.cpp.

184{
185 if (!HookLoggingEnabled())
186 {
187 return;
188 }
189
190 TraceLoggingWrite(g_hHookProvider, "ProtectionSetAttempt",
191 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
192 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
193 TraceLoggingString("NtSetInformationProcess", "Api"),
194 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
195 TraceLoggingBool(!CurrentProcess, "Remote"),
196 TraceLoggingNTStatus(Status, "Status"));
197
198 DebugMessage("[Panoptes] NtSetInformationProcess: attempt to set the protection of the %s process, status 0x%08lx\n",
199 CurrentProcess ? "current" : "remote", (ULONG)Status);
200}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtSetInformationProcess().

◆ Log_RemoteThreadCreated()

VOID Log_RemoteThreadCreated ( HANDLE ProcessHandle,
PVOID StartRoutine,
ULONG CreateFlags )

NtCreateThreadEx created a thread in another process. Event "RemoteThreadCreated".

Parameters
ProcessHandleThe process the thread was created in.
StartRoutineThe address the thread starts executing at.
CreateFlagsThe THREAD_CREATE_FLAGS_* values, e.g. 0x1 for a suspended thread.

Definition at line 227 of file hook_trace.cpp.

228{
229 if (!HookLoggingEnabled())
230 {
231 return;
232 }
233
234 TraceLoggingWrite(g_hHookProvider, "RemoteThreadCreated",
235 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
236 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
237 TraceLoggingString("NtCreateThreadEx", "Api"),
238 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
239 TraceLoggingBool(TRUE, "Remote"),
240 TraceLoggingPointer(StartRoutine, "StartRoutine"),
241 TraceLoggingHexUInt32(CreateFlags, "CreateFlags"));
242
243 DebugMessage("[Panoptes] NtCreateThreadEx: thread created in a remote process, start %p, flags 0x%lx\n",
244 StartRoutine, CreateFlags);
245}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtCreateThreadEx().

◆ Log_RemoteViewMapped()

VOID Log_RemoteViewMapped ( HANDLE ProcessHandle,
const char * Api,
PVOID BaseAddress,
SIZE_T ViewSize,
ULONG Protection,
BOOL Executable,
BOOL IsImage )

NtMapViewOfSection or NtMapViewOfSectionEx mapped a view into another process. Mapping a shared section into a target is a way to inject code without NtWriteVirtualMemory. Event "RemoteViewMapped".

Parameters
ProcessHandleThe process the view was mapped into.
ApiThe name of the hooked function.
BaseAddressThe base of the view, as returned by the kernel.
ViewSizeThe size of the view, as returned by the kernel.
ProtectionThe protection the caller requested.
ExecutableWhether any committed page of the view is executable.
IsImageWhether the view is a mapped image (MEM_IMAGE). Logged as "IsImage".

Definition at line 291 of file hook_trace.cpp.

293{
294 if (!HookLoggingEnabled())
295 {
296 return;
297 }
298
299 TraceLoggingWrite(g_hHookProvider, "RemoteViewMapped",
300 TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
301 TraceLoggingKeyword(HOOK_KEYWORD_DETECTION),
302 TraceLoggingString(Api, "Api"),
303 TraceLoggingUInt32(TargetProcessIdOf(ProcessHandle), "TargetProcessId"),
304 TraceLoggingBool(TRUE, "Remote"),
305 TraceLoggingPointer(BaseAddress, "BaseAddress"),
306 TraceLoggingUInt64((UINT64)ViewSize, "ViewSize"),
307 TraceLoggingHexUInt32(Protection, "Protection"),
308 TraceLoggingBool(Executable, "Executable"),
309 TraceLoggingBool(IsImage, "IsImage"));
310
311 DebugMessage("[Panoptes] %s: %Iu-byte %s mapped into a remote process at %p (protection 0x%lx, %s)\n",
312 Api, ViewSize, IsImage ? "image" : "view", BaseAddress, Protection,
313 Executable ? "executable" : "not executable");
314}

References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().

Referenced by Hooked_NtMapViewOfSection(), and Hooked_NtMapViewOfSectionEx().