26 #define UNPACK_STATE_NONE 0x00 27 #define UNPACK_STATE_DIRTY 0x01 28 #define UNPACK_STATE_EXEC 0x02 69 list = gUnpckPages.
Flink;
70 while (list != &gUnpckPages)
105 if (NULL != Page->WriteHook)
110 ERROR(
"[ERROR] IntHookGvaRemoveHook failed: 0x%08x\n", status);
114 if (NULL != Page->ExecHook)
119 ERROR(
"[ERROR] IntHookGvaRemoveHook failed: 0x%08x\n", status);
185 ERROR(
"[ERROR] IntDecDecodeInstructionAtRip failed: 0x%08x\n", status);
187 memset(&instrux, 0,
sizeof(instrux));
204 status = cbk(cr3, va, &instrux, cbkCtxt);
207 ERROR(
"[ERROR] Unpacker callback failed: 0x%08x\n", status);
285 ERROR(
"[ERROR] IntHookGvaRemoveHook failed: 0x%08x\n", status);
300 ERROR(
"[ERROR] IntHookGvaSetHook failed: 0x%08x\n", status);
302 goto cleanup_and_exit;
375 ERROR(
"[ERROR] IntHookGvaSetHook failed: 0x%08x\n", status);
377 goto cleanup_and_exit;
412 list = gUnpckPages.
Flink;
413 while (list != &gUnpckPages)
423 ERROR(
"[ERROR] IntUnpUnWatchPageInternal failed: 0x%08x, page 0x%016llx/0x%016llx\n",
452 list = gUnpckPages.
Flink;
453 while (list != &gUnpckPages)
458 if (pPage->
Cr3 == Cr3)
463 ERROR(
"[ERROR] IntUnpUnWatchPageInternal failed: 0x%08x, page 0x%016llx/0x%016llx\n",
486 list = gUnpckPages.
Flink;
487 while (list != &gUnpckPages)
495 ERROR(
"[ERROR] IntUnpUnWatchPageInternal failed: 0x%08x, page 0x%016llx/0x%016llx\n",
void * CallbackContext
Optional context, passed to the callbacks.
#define CONTAINING_RECORD(List, Type, Member)
IG_ARCH_REGS Regs
The current state of the guest registers.
DWORD Index
The VCPU number.
#define INT_STATUS_SUCCESS
struct _LIST_ENTRY * Flink
void * ExecHook
Exec hook handle.
INTSTATUS IntUnpUnWatchVaSpacePages(QWORD Cr3)
Stop monitoring all pages belonging to a virtual address space.
#define INT_SUCCESS(Status)
INTSTATUS(* PFUNC_PageUnpackedCallback)(QWORD Cr3, QWORD VirtualAddress, PINSTRUX Instrux, void *Context)
Called when a page is considered to be "unpacked".
QWORD VirtualAddress
Page virtual address.
INTSTATUS IntDecDecodeInstructionAtRip(DWORD CpuNumber, IG_ARCH_REGS *Registers, IG_SEG_REGS *Segments, INSTRUX *Instrux)
Decode an instruction at current RIP on the provided VCPU.
#define HpAllocWithTag(Len, Tag)
int INTSTATUS
The status data type.
static INTSTATUS IntUnpPageWriteCallback(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
Handle writes inside a monitored page.
WORD WriteCount
Number of times the page has been written.
LIST_ENTRY Link
List entry link.
static INTSTATUS IntUnpUnWatchPageInternal(PUNPACK_PAGE Page)
Remove monitor from the indicated page.
INTSTATUS IntHookGvaSetHook(QWORD Cr3, QWORD Gva, DWORD Length, BYTE Type, void *Callback, void *Context, void *ParentHook, DWORD Flags, HOOK_GVA **GvaHook)
Set a read, write, execute or swap hook on a guest virtual address.
static INTSTATUS IntUnpPageExecuteCallback(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
Handle executions from a monitored page.
static BOOLEAN RemoveEntryList(LIST_ENTRY *Entry)
void * WriteHook
Write hook handle.
#define INT_STATUS_INVALID_PARAMETER_4
#define HpFreeAndNullWithTag(Add, Tag)
#define INT_STATUS_INVALID_PARAMETER_5
PFUNC_PageIsWriteValid WriteCheckCallback
Write callback, called when the page is written.
static void InsertTailList(LIST_ENTRY *ListHead, LIST_ENTRY *Entry)
INTSTATUS IntHookGvaRemoveHook(HOOK_GVA **Hook, DWORD Flags)
Remove a GVA hook.
#define UNREFERENCED_PARAMETER(P)
void IntUnpUninit(void)
Uninit the unpacker. This will stop the monitor on all pages.
enum _INTRO_ACTION INTRO_ACTION
Event actions.
#define UNPACK_STATE_EXEC
The page contains code that has been fetched for execution.
INTSTATUS IntUnpUnWatchPage(QWORD Cr3, QWORD VirtualAddress)
Stop monitoring the indicated page.
struct _UNPACK_PAGE UNPACK_PAGE
#define UNPACK_STATE_DIRTY
The page was written.
BOOLEAN(* PFUNC_PageIsWriteValid)(QWORD Cr3, QWORD VirtualAddress, void *Context)
Called when a page is written.
static PUNPACK_PAGE IntUnpFindPage(QWORD Cr3, QWORD VirtualAddress)
Finds a monitored page.
QWORD Cr3
Virtual address space this page belongs to.
#define LIST_HEAD_INIT(Name)
#define INT_STATUS_INVALID_PARAMETER_1
VCPU_STATE * gVcpu
The state of the current VCPU.
VE_CACHE_LINE * Page
Mapped page inside Introspection virtual address space.
INTSTATUS IntUnpRemovePages(void)
Stop monitoring all pages.
static LIST_HEAD gUnpckPages
PFUNC_PageUnpackedCallback UnpackCallback
Unpack callback, called as soon as the page has been unpacked.
#define UNPACK_STATE_NONE
Initial state.
BYTE State
Page state - check UNPACK_STATE*.
INTSTATUS IntUnpWatchPage(QWORD Cr3, QWORD VirtualAddress, PFUNC_PageUnpackedCallback UnpackCallback, PFUNC_PageIsWriteValid WriteCheckCallback, void *CallbackContext)
Monitor a page against unpacking.
struct _UNPACK_PAGE * PUNPACK_PAGE
#define INT_STATUS_INSUFFICIENT_RESOURCES