2024-01-07 05:13:41 +01:00
|
|
|
#include "imports.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "driver.h"
|
2024-01-29 17:31:12 +01:00
|
|
|
#include "crypt.h"
|
|
|
|
#include <stdarg.h>
|
2024-01-07 05:13:41 +01:00
|
|
|
|
2024-07-22 12:43:09 +02:00
|
|
|
#include "lib/stdlib.h"
|
|
|
|
|
2024-01-08 04:57:07 +01:00
|
|
|
PVOID
|
2024-01-31 08:32:13 +01:00
|
|
|
ImpResolveNtImport(PDRIVER_OBJECT DriverObject, PCZPSTR ExportName)
|
2024-01-07 05:13:41 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
PVOID image_base = NULL;
|
|
|
|
PIMAGE_DOS_HEADER dos_header = NULL;
|
|
|
|
PLOCAL_NT_HEADER nt_header = NULL;
|
|
|
|
PIMAGE_OPTIONAL_HEADER64 optional_header = NULL;
|
|
|
|
PIMAGE_DATA_DIRECTORY data_dir = NULL;
|
|
|
|
PIMAGE_EXPORT_DIRECTORY export_dir = NULL;
|
|
|
|
PUINT32 export_name_table = NULL;
|
|
|
|
PCHAR name = NULL;
|
|
|
|
PUINT16 ordinals_table = NULL;
|
|
|
|
PUINT32 export_addr_table = NULL;
|
|
|
|
UINT32 ordinal = 0;
|
|
|
|
PVOID target_function_addr = 0;
|
|
|
|
UINT32 export_offset = 0;
|
|
|
|
|
|
|
|
image_base = FindDriverBaseNoApi(DriverObject, L"ntoskrnl.exe");
|
|
|
|
|
|
|
|
if (!image_base) {
|
|
|
|
DEBUG_ERROR("FindDriverBaseNoApi failed with no status");
|
|
|
|
return NULL;
|
|
|
|
}
|
2024-01-07 05:13:41 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
/*
|
|
|
|
* todo: add comment explaining this shit also this ugly af
|
|
|
|
*/
|
|
|
|
dos_header = (PIMAGE_DOS_HEADER)image_base;
|
|
|
|
nt_header = (struct _IMAGE_NT_HEADERS64*)((UINT64)image_base +
|
|
|
|
dos_header->e_lfanew);
|
|
|
|
optional_header = (PIMAGE_OPTIONAL_HEADER64)&nt_header->OptionalHeader;
|
2024-01-07 05:13:41 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
data_dir = (PIMAGE_DATA_DIRECTORY) &
|
|
|
|
(optional_header->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]);
|
|
|
|
export_dir = (PIMAGE_EXPORT_DIRECTORY)((UINT64)image_base +
|
|
|
|
data_dir->VirtualAddress);
|
|
|
|
|
|
|
|
export_name_table =
|
|
|
|
(PUINT32)((UINT64)image_base + export_dir->AddressOfNames);
|
|
|
|
ordinals_table =
|
|
|
|
(PUINT16)((UINT64)image_base + export_dir->AddressOfNameOrdinals);
|
|
|
|
export_addr_table =
|
|
|
|
(PUINT32)((UINT64)image_base + export_dir->AddressOfFunctions);
|
|
|
|
|
|
|
|
for (INT index = 0; index < export_dir->NumberOfNames; index++) {
|
|
|
|
name = (PCHAR)((UINT64)image_base + export_name_table[index]);
|
|
|
|
|
2024-07-22 12:43:09 +02:00
|
|
|
if (IntCompareString(name, ExportName))
|
2024-04-13 10:23:14 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
ordinal = ordinals_table[index];
|
|
|
|
export_offset = export_addr_table[ordinal];
|
|
|
|
target_function_addr = (PVOID)((UINT64)image_base + export_offset);
|
|
|
|
return target_function_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2024-01-07 05:13:41 +01:00
|
|
|
}
|
|
|
|
|
2024-01-31 08:32:13 +01:00
|
|
|
/*
|
2024-04-13 06:40:51 +02:00
|
|
|
* The strings in this array need to be hashed at compile time, then we can use
|
|
|
|
* the same hash function to compare when we walk the export table.
|
2024-01-31 08:32:13 +01:00
|
|
|
*/
|
|
|
|
#define NT_IMPORT_MAX_LENGTH 128
|
|
|
|
#define NT_IMPORT_COUNT 79
|
|
|
|
|
2024-04-13 06:40:51 +02:00
|
|
|
CHAR NT_IMPORTS[NT_IMPORT_COUNT][NT_IMPORT_MAX_LENGTH] = {
|
|
|
|
"ObDereferenceObject",
|
|
|
|
"PsLookupThreadByThreadId",
|
|
|
|
"MmIsAddressValid",
|
|
|
|
"PsSetCreateProcessNotifyRoutine",
|
|
|
|
"PsRemoveCreateThreadNotifyRoutine",
|
|
|
|
"PsGetCurrentThreadId",
|
|
|
|
"PsGetProcessId",
|
|
|
|
"PsLookupProcessByProcessId",
|
|
|
|
"ExEnumHandleTable",
|
|
|
|
"ObGetObjectType",
|
|
|
|
"ExfUnblockPushLock",
|
|
|
|
"PsGetProcessImageFileName",
|
|
|
|
"strstr",
|
|
|
|
"RtlInitUnicodeString",
|
|
|
|
"RtlQueryRegistryValues",
|
|
|
|
"MmGetSystemRoutineAddress",
|
|
|
|
"RtlUnicodeStringToAnsiString",
|
|
|
|
"RtlCopyUnicodeString",
|
|
|
|
"RtlFreeAnsiString",
|
|
|
|
"KeInitializeGuardedMutex",
|
|
|
|
"IoCreateDevice",
|
|
|
|
"IoCreateSymbolicLink",
|
|
|
|
"IoDeleteDevice",
|
|
|
|
"IoDeleteSymbolicLink",
|
|
|
|
"ObRegisterCallbacks",
|
|
|
|
"ObUnRegisterCallbacks",
|
|
|
|
"PsSetCreateThreadNotifyRoutine",
|
|
|
|
"KeRevertToUserAffinityThreadEx",
|
|
|
|
"KeSetSystemAffinityThreadEx",
|
|
|
|
"strnlen",
|
|
|
|
"RtlInitAnsiString",
|
|
|
|
"RtlAnsiStringToUnicodeString",
|
|
|
|
"IoGetCurrentProcess",
|
|
|
|
"RtlGetVersion",
|
|
|
|
"RtlCompareMemory",
|
|
|
|
"ExGetSystemFirmwareTable",
|
|
|
|
"IoAllocateWorkItem",
|
|
|
|
"IoFreeWorkItem",
|
|
|
|
"IoQueueWorkItem",
|
|
|
|
"ZwOpenFile",
|
|
|
|
"ZwClose",
|
|
|
|
"ZwCreateSection",
|
|
|
|
"ZwMapViewOfSection",
|
|
|
|
"ZwUnmapViewOfSection",
|
|
|
|
"MmCopyMemory",
|
|
|
|
"ZwDeviceIoControlFile",
|
|
|
|
"KeStackAttachProcess",
|
|
|
|
"KeUnstackDetachProcess",
|
|
|
|
"KeWaitForSingleObject",
|
|
|
|
"PsCreateSystemThread",
|
|
|
|
"IofCompleteRequest",
|
|
|
|
"ObReferenceObjectByHandle",
|
|
|
|
"KeDelayExecutionThread",
|
|
|
|
"KeRegisterNmiCallback",
|
|
|
|
"KeDeregisterNmiCallback",
|
|
|
|
"KeQueryActiveProcessorCount",
|
|
|
|
"ExAcquirePushLockExclusiveEx",
|
|
|
|
"ExReleasePushLockExclusiveEx",
|
|
|
|
"PsGetThreadId",
|
|
|
|
"RtlCaptureStackBackTrace",
|
|
|
|
"ZwOpenDirectoryObject",
|
|
|
|
"KeInitializeAffinityEx",
|
|
|
|
"KeAddProcessorAffinityEx",
|
|
|
|
"RtlQueryModuleInformation",
|
|
|
|
"KeInitializeApc",
|
|
|
|
"KeInsertQueueApc",
|
|
|
|
"KeGenericCallDpc",
|
|
|
|
"KeSignalCallDpcDone",
|
|
|
|
"MmGetPhysicalMemoryRangesEx2",
|
|
|
|
"MmGetVirtualForPhysical",
|
|
|
|
"ObfReferenceObject",
|
|
|
|
"ExFreePoolWithTag",
|
|
|
|
"ExAllocatePool2",
|
|
|
|
"KeReleaseGuardedMutex",
|
|
|
|
"KeAcquireGuardedMutex",
|
|
|
|
"DbgPrintEx",
|
|
|
|
"RtlCompareUnicodeString",
|
|
|
|
"RtlFreeUnicodeString",
|
|
|
|
"PsGetProcessImageFileName"};
|
2024-01-31 08:32:13 +01:00
|
|
|
|
|
|
|
DRIVER_IMPORTS driver_imports = {0};
|
|
|
|
|
2024-01-07 05:13:41 +01:00
|
|
|
NTSTATUS
|
2024-01-31 08:32:13 +01:00
|
|
|
ImpResolveDynamicImports(_In_ PDRIVER_OBJECT DriverObject)
|
2024-01-07 05:13:41 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
PUINT64 imports_array = (PUINT64)&driver_imports;
|
2024-01-07 06:27:23 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
for (UINT32 index = 0; index < NT_IMPORT_COUNT; index++) {
|
|
|
|
imports_array[index] =
|
|
|
|
ImpResolveNtImport(DriverObject, NT_IMPORTS[index]);
|
2024-01-31 08:32:13 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
if (!imports_array[index])
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
2024-01-07 05:13:41 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
CryptEncryptImportsArray(&driver_imports, IMPORTS_LENGTH);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return STATUS_SUCCESS;
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpObDereferenceObject(_In_ PVOID Object)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pObDereferenceObject impObDereferenceObject =
|
|
|
|
(pObDereferenceObject)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, OB_DEREFERENCE_OBJECT_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impObDereferenceObject(Object);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpPsLookupThreadByThreadId(_In_ HANDLE ThreadId, _Out_ PETHREAD* Thread)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsLookupThreadByThreadId impPsLookupThreadByThreadId =
|
|
|
|
(pPsLookupThreadByThreadId)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
PS_LOOKUP_THREAD_BY_THREAD_ID_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsLookupThreadByThreadId(ThreadId, Thread);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
ImpMmIsAddressValid(_In_ PVOID VirtualAddress)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pMmIsAddressValid impMmIsAddressValid =
|
|
|
|
(pMmIsAddressValid)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, MM_IS_ADDRESS_VALID_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impMmIsAddressValid(VirtualAddress);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpPsSetCreateProcessNotifyRoutine(
|
|
|
|
_In_ PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, _In_ BOOLEAN Remove)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsSetCreateProcessNotifyRoutine impPsSetCreateProcessNotifyRoutine =
|
|
|
|
(pPsSetCreateProcessNotifyRoutine)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
PS_SET_CREATE_PROCESS_NOTIFY_ROUTINE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsSetCreateProcessNotifyRoutine(NotifyRoutine, Remove);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpPsRemoveCreateThreadNotifyRoutine(
|
|
|
|
_In_ PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsRemoveCreateThreadNotifyRoutine impPsRemoveCreateThreadNotifyRoutine =
|
|
|
|
(pPsRemoveCreateThreadNotifyRoutine)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
PS_REMOVE_CREATE_THREAD_NOTIFY_ROUTINE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsRemoveCreateThreadNotifyRoutine(NotifyRoutine);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE
|
|
|
|
ImpPsGetCurrentThreadId()
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsGetCurrentThreadId impPsGetCurrentThreadId =
|
|
|
|
(pPsGetCurrentThreadId)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, PS_GET_CURRENT_THREAD_ID_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsGetCurrentThreadId();
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE
|
|
|
|
ImpPsGetProcessId(_In_ PEPROCESS Process)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsGetProcessId impPsGetProcessId =
|
|
|
|
(pPsGetProcessId)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, PS_GET_PROCESS_ID_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsGetProcessId(Process);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpPsLookupProcessByProcessId(_In_ HANDLE ProcessId, _Out_ PEPROCESS* Process)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsLookupProcessByProcessId impPsLookupProcessByProcessId =
|
|
|
|
(pPsLookupProcessByProcessId)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
PS_LOOKUP_PROCESS_BY_PROCESS_ID_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsLookupProcessByProcessId(ProcessId, Process);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
ImpExEnumHandleTable(_In_ PHANDLE_TABLE HandleTable,
|
|
|
|
_In_ PVOID Callback,
|
|
|
|
_In_opt_ PVOID Context,
|
|
|
|
_Out_opt_ PHANDLE Handle)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pExEnumHandleTable impExEnumHandleTable =
|
|
|
|
(pExEnumHandleTable)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, EX_ENUM_HANDLE_TABLE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impExEnumHandleTable(HandleTable, Callback, Context, Handle);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
POBJECT_TYPE
|
|
|
|
ImpObGetObjectType(_In_ PVOID Object)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pObGetObjectType impObGetObjectType =
|
|
|
|
(pObGetObjectType)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, OB_GET_OBJECT_TYPE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impObGetObjectType(Object);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpExfUnblockPushLock(_In_ PEX_PUSH_LOCK PushLock, _In_ PVOID WaitBlock)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pExfUnblockPushLock impExfUnblockPushLock =
|
|
|
|
(pExfUnblockPushLock)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, EXF_UNBLOCK_PUSH_LOCK_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impExfUnblockPushLock(PushLock, WaitBlock);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LPCSTR
|
|
|
|
ImpPsGetProcessImageFileName(_In_ PEPROCESS Process)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsGetProcessImageFileName impPsGetProcessImageFileName =
|
|
|
|
(pPsGetProcessImageFileName)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
PS_GET_PROCESS_IMAGE_FILE_NAME_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsGetProcessImageFileName(Process);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
INT
|
|
|
|
ImpStrStr(_In_ CHAR* haystack, _In_ CHAR* needle)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pstrstr impStrStr = (pstrstr)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, STRSTR_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impStrStr(haystack, needle);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpRtlInitUnicodeString(_In_ PUNICODE_STRING DestinationString,
|
|
|
|
_In_ PCWSTR SourceString)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlInitUnicodeString impRtlInitUnicodeString =
|
|
|
|
(pRtlInitUnicodeString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_INIT_UNICODE_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impRtlInitUnicodeString(DestinationString, SourceString);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpRtlQueryRegistryValues(_In_ ULONG RelativeTo,
|
|
|
|
_In_ PCWSTR Path,
|
|
|
|
_In_ PRTL_QUERY_REGISTRY_TABLE QueryTable,
|
|
|
|
_In_opt_ void* Context,
|
|
|
|
_In_ void* Environment)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlQueryRegistryValues impRtlQueryRegistryValues =
|
|
|
|
(pRtlQueryRegistryValues)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_QUERY_REGISTRY_VALUES_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlQueryRegistryValues(
|
|
|
|
RelativeTo, Path, QueryTable, Context, Environment);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
ImpMmGetSystemRoutineAddress(_In_ PUNICODE_STRING SystemRoutineName)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pMmGetSystemRoutineAddress impMmGetSystemRoutineAddress =
|
|
|
|
(pMmGetSystemRoutineAddress)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
MM_GET_SYSTEM_ROUTINE_ADDRESS_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impMmGetSystemRoutineAddress(SystemRoutineName);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpRtlUnicodeStringToAnsiString(_In_ PANSI_STRING DestinationString,
|
|
|
|
_In_ PCUNICODE_STRING SourceString,
|
|
|
|
_In_ BOOLEAN AllocateDestinationString)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlUnicodeStringToAnsiString impRtlUnicodeStringToAnsiString =
|
|
|
|
(pRtlUnicodeStringToAnsiString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
RTL_UNICODE_STRING_TO_ANSI_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlUnicodeStringToAnsiString(
|
|
|
|
DestinationString, SourceString, AllocateDestinationString);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpRtlCopyUnicodeString(_In_ PUNICODE_STRING DestinationString,
|
|
|
|
_In_ PCUNICODE_STRING SourceString)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlCopyUnicodeString impRtlCopyUnicodeString =
|
|
|
|
(pRtlCopyUnicodeString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_COPY_UNICODE_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impRtlCopyUnicodeString(DestinationString, SourceString);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpRtlFreeAnsiString(_In_ PANSI_STRING AnsiString)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlFreeAnsiString impRtlFreeAnsiString =
|
|
|
|
(pRtlFreeAnsiString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_FREE_ANSI_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impRtlFreeAnsiString(AnsiString);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeInitializeGuardedMutex(_In_ PKGUARDED_MUTEX GuardedMutex)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeInitializeGuardedMutex impKeInitializeGuardedMutex =
|
|
|
|
(pKeInitializeGuardedMutex)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_INITIALIZE_GUARDED_MUTEX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeInitializeGuardedMutex(GuardedMutex);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpIoCreateDevice(_In_ PDRIVER_OBJECT DriverObject,
|
|
|
|
_In_ ULONG DeviceExtensionSize,
|
|
|
|
_In_opt_ PUNICODE_STRING DeviceName,
|
|
|
|
_In_ DEVICE_TYPE DeviceType,
|
|
|
|
_In_ ULONG DeviceCharacteristics,
|
|
|
|
_In_ BOOLEAN Exclusive,
|
|
|
|
_Out_ PDEVICE_OBJECT* DeviceObject)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoCreateDevice impIoCreateDevice =
|
|
|
|
(pIoCreateDevice)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_CREATE_DEVICE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impIoCreateDevice(DriverObject,
|
|
|
|
DeviceExtensionSize,
|
|
|
|
DeviceName,
|
|
|
|
DeviceType,
|
|
|
|
DeviceCharacteristics,
|
|
|
|
Exclusive,
|
|
|
|
DeviceObject);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpIoCreateSymbolicLink(_In_ PUNICODE_STRING SymbolicLinkName,
|
|
|
|
_In_ PUNICODE_STRING DeviceName)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoCreateSymbolicLink impIoCreateSymbolicLink =
|
|
|
|
(pIoCreateSymbolicLink)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_CREATE_SYMBOLIC_LINK_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impIoCreateSymbolicLink(SymbolicLinkName, DeviceName);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpIoDeleteDevice(_In_ PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoDeleteDevice impIoDeleteDevice =
|
|
|
|
(pIoDeleteDevice)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_DELETE_DEVICE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impIoDeleteDevice(DeviceObject);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpIoDeleteSymbolicLink(_In_ PUNICODE_STRING SymbolicLinkName)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoDeleteSymbolicLink impIoDeleteSymbolicLink =
|
|
|
|
(pIoDeleteSymbolicLink)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_DELETE_SYMBOLIC_LINK_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impIoDeleteSymbolicLink(SymbolicLinkName);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpObRegisterCallbacks(_In_ POB_CALLBACK_REGISTRATION CallbackRegistration,
|
|
|
|
_Out_ PVOID* RegistrationHandle)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pObRegisterCallbacks impObRegisterCallbacks =
|
|
|
|
(pObRegisterCallbacks)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, OB_REGISTER_CALLBACKS_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impObRegisterCallbacks(CallbackRegistration, RegistrationHandle);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpObUnRegisterCallbacks(_In_ PVOID RegistrationHandle)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pObUnRegisterCallbacks impObUnRegisterCallbacks =
|
|
|
|
(pObUnRegisterCallbacks)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, OB_UNREGISTER_CALLBACKS_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impObUnRegisterCallbacks(RegistrationHandle);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpPsSetCreateThreadNotifyRoutine(
|
|
|
|
_In_ PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsSetCreateThreadNotifyRoutine impPsSetCreateThreadNotifyRoutine =
|
|
|
|
(pPsSetCreateThreadNotifyRoutine)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
PS_SET_CREATE_THREAD_NOTIFY_ROUTINE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsSetCreateThreadNotifyRoutine(NotifyRoutine);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeRevertToUserAffinityThreadEx(_In_ KAFFINITY Affinity)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeRevertToUserAffinityThreadEx impKeRevertToUserAffinityThreadEx =
|
|
|
|
(pKeRevertToUserAffinityThreadEx)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
KE_REVERT_TO_USER_AFFINITY_THREAD_EX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeRevertToUserAffinityThreadEx(Affinity);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
KAFFINITY
|
|
|
|
ImpKeSetSystemAffinityThreadEx(_In_ KAFFINITY Affinity)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeSetSystemAffinityThreadEx impKeSetSystemAffinityThreadEx =
|
|
|
|
(pKeSetSystemAffinityThreadEx)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
KE_SET_SYSTEM_AFFINITY_THREAD_EX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impKeSetSystemAffinityThreadEx(Affinity);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SIZE_T
|
|
|
|
ImpStrnlen(_In_ CHAR* str, _In_ SIZE_T maxCount)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pstrnlen impStrnlen = (pstrnlen)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, STRNLEN_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impStrnlen(str, maxCount);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpRtlInitAnsiString(_In_ PANSI_STRING DestinationString,
|
|
|
|
_In_ PCSZ SourceString)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlInitAnsiString impRtlInitAnsiString =
|
|
|
|
(pRtlInitAnsiString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_INIT_ANSI_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impRtlInitAnsiString(DestinationString, SourceString);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpRtlAnsiStringToUnicodeString(_In_ PUNICODE_STRING DestinationString,
|
|
|
|
_In_ PCANSI_STRING SourceString,
|
|
|
|
_In_ BOOLEAN AllocateDestinationString)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlAnsiStringToUnicodeString impRtlAnsiStringToUnicodeString =
|
|
|
|
(pRtlAnsiStringToUnicodeString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
RTL_ANSI_STRING_TO_UNICODE_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlAnsiStringToUnicodeString(
|
|
|
|
DestinationString, SourceString, AllocateDestinationString);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PEPROCESS
|
|
|
|
ImpIoGetCurrentProcess()
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoGetCurrentProcess impIoGetCurrentProcess =
|
|
|
|
(pIoGetCurrentProcess)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_GET_CURRENT_PROCESS_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impIoGetCurrentProcess();
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpRtlGetVersion(_Out_ PRTL_OSVERSIONINFOW lpVersionInformation)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlGetVersion impRtlGetVersion =
|
|
|
|
(pRtlGetVersion)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_GET_VERSION_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlGetVersion(lpVersionInformation);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SIZE_T
|
|
|
|
ImpRtlCompareMemory(_In_ PVOID Source1, _In_ PVOID Source2, _In_ SIZE_T Length)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlCompareMemory impRtlCompareMemory =
|
|
|
|
(pRtlCompareMemory)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_COMPARE_MEMORY_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlCompareMemory(Source1, Source2, Length);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpExGetSystemFirmwareTable(_In_ ULONG FirmwareTableProviderSignature,
|
|
|
|
_In_ ULONG FirmwareTableID,
|
|
|
|
_In_ PVOID pFirmwareTableBuffer,
|
|
|
|
_In_ ULONG BufferLength,
|
|
|
|
_Out_ PULONG ReturnLength)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pExGetSystemFirmwareTable impExGetSystemFirmwareTable =
|
|
|
|
(pExGetSystemFirmwareTable)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
EX_GET_SYSTEM_FIRMWARE_TABLE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impExGetSystemFirmwareTable(FirmwareTableProviderSignature,
|
|
|
|
FirmwareTableID,
|
|
|
|
pFirmwareTableBuffer,
|
|
|
|
BufferLength,
|
|
|
|
ReturnLength);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PIO_WORKITEM
|
|
|
|
ImpIoAllocateWorkItem(_In_ PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoAllocateWorkItem impIoAllocateWorkItem =
|
|
|
|
(pIoAllocateWorkItem)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_ALLOCATE_WORK_ITEM_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impIoAllocateWorkItem(DeviceObject);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpIoFreeWorkItem(_In_ PIO_WORKITEM WorkItem)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoFreeWorkItem impIoFreeWorkItem =
|
|
|
|
(pIoFreeWorkItem)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_FREE_WORK_ITEM_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impIoFreeWorkItem(WorkItem);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpIoQueueWorkItem(_In_ PIO_WORKITEM IoWorkItem,
|
|
|
|
_In_ PIO_WORKITEM_ROUTINE WorkerRoutine,
|
|
|
|
_In_ WORK_QUEUE_TYPE QueueType,
|
|
|
|
_In_opt_ PVOID Context)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIoQueueWorkItem impIoQueueWorkItem =
|
|
|
|
(pIoQueueWorkItem)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IO_QUEUE_WORK_ITEM_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impIoQueueWorkItem(IoWorkItem, WorkerRoutine, QueueType, Context);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpZwOpenFile(_Out_ PHANDLE FileHandle,
|
|
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
|
|
_In_ POBJECT_ATTRIBUTES ObjectAttributes,
|
|
|
|
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
|
|
|
|
_In_ ULONG ShareAccess,
|
|
|
|
_In_ ULONG OpenOptions)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pZwOpenFile impZwOpenFile = (pZwOpenFile)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, ZW_OPEN_FILE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impZwOpenFile(FileHandle,
|
|
|
|
DesiredAccess,
|
|
|
|
ObjectAttributes,
|
|
|
|
IoStatusBlock,
|
|
|
|
ShareAccess,
|
|
|
|
OpenOptions);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpZwClose(_In_ HANDLE Handle)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pZwClose impZwClose = (pZwClose)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, ZW_CLOSE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impZwClose(Handle);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpZwCreateSection(_Out_ PHANDLE SectionHandle,
|
|
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
|
|
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
|
|
|
|
_In_opt_ PLARGE_INTEGER MaximumSize,
|
|
|
|
_In_ ULONG SectionPageProtection,
|
|
|
|
_In_ ULONG AllocationAttributes,
|
|
|
|
_In_opt_ HANDLE FileHandle)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pZwCreateSection impZwCreateSection =
|
|
|
|
(pZwCreateSection)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, ZW_CREATE_SECTION_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impZwCreateSection(SectionHandle,
|
|
|
|
DesiredAccess,
|
|
|
|
ObjectAttributes,
|
|
|
|
MaximumSize,
|
|
|
|
SectionPageProtection,
|
|
|
|
AllocationAttributes,
|
|
|
|
FileHandle);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpZwMapViewOfSection(_In_ HANDLE SectionHandle,
|
|
|
|
_In_ HANDLE ProcessHandle,
|
|
|
|
_Inout_ PVOID* BaseAddress,
|
|
|
|
_In_ ULONG_PTR ZeroBits,
|
|
|
|
_In_ SIZE_T CommitSize,
|
|
|
|
_Inout_opt_ PLARGE_INTEGER SectionOffset,
|
|
|
|
_Inout_ PSIZE_T ViewSize,
|
|
|
|
_In_ SECTION_INHERIT InheritDisposition,
|
|
|
|
_In_ ULONG AllocationType,
|
|
|
|
_In_ ULONG Win32Protect)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pZwMapViewOfSection impZwMapViewOfSection =
|
|
|
|
(pZwMapViewOfSection)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, ZW_MAP_VIEW_OF_SECTION_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impZwMapViewOfSection(SectionHandle,
|
|
|
|
ProcessHandle,
|
|
|
|
BaseAddress,
|
|
|
|
ZeroBits,
|
|
|
|
CommitSize,
|
|
|
|
SectionOffset,
|
|
|
|
ViewSize,
|
|
|
|
InheritDisposition,
|
|
|
|
AllocationType,
|
|
|
|
Win32Protect);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpZwUnmapViewOfSection(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pZwUnmapViewOfSection impZwUnmapViewOfSection =
|
|
|
|
(pZwUnmapViewOfSection)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, ZW_UNMAP_VIEW_OF_SECTION_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impZwUnmapViewOfSection(ProcessHandle, BaseAddress);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpMmCopyMemory(_In_ PVOID TargetAddress,
|
|
|
|
_In_ MM_COPY_ADDRESS SourceAddress,
|
|
|
|
_In_ SIZE_T NumberOfBytes,
|
|
|
|
_In_ ULONG Flags,
|
|
|
|
_Out_ PSIZE_T NumberOfBytesTransferred)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pMmCopyMemory impMmCopyMemory =
|
|
|
|
(pMmCopyMemory)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, MM_COPY_MEMORY_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impMmCopyMemory(TargetAddress,
|
|
|
|
SourceAddress,
|
|
|
|
NumberOfBytes,
|
|
|
|
Flags,
|
|
|
|
NumberOfBytesTransferred);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpZwDeviceIoControlFile(_In_ HANDLE FileHandle,
|
|
|
|
_In_opt_ HANDLE Event,
|
|
|
|
_In_opt_ PIO_APC_ROUTINE ApcRoutine,
|
|
|
|
_In_opt_ PVOID ApcContext,
|
|
|
|
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
|
|
|
|
_In_ ULONG IoControlCode,
|
|
|
|
_In_opt_ PVOID InputBuffer,
|
|
|
|
_In_ ULONG InputBufferLength,
|
|
|
|
_Out_opt_ PVOID OutputBuffer,
|
|
|
|
_In_ ULONG OutputBufferLength)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pZwDeviceIoControlFile impZwDeviceIoControlFile =
|
|
|
|
(pZwDeviceIoControlFile)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, ZW_DEVICE_IO_CONTROL_FILE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impZwDeviceIoControlFile(FileHandle,
|
|
|
|
Event,
|
|
|
|
ApcRoutine,
|
|
|
|
ApcContext,
|
|
|
|
IoStatusBlock,
|
|
|
|
IoControlCode,
|
|
|
|
InputBuffer,
|
|
|
|
InputBufferLength,
|
|
|
|
OutputBuffer,
|
|
|
|
OutputBufferLength);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeStackAttachProcess(_In_ PRKPROCESS Process, _Out_ PKAPC_STATE ApcState)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeStackAttachProcess impKeStackAttachProcess =
|
|
|
|
(pKeStackAttachProcess)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_STACK_ATTACH_PROCESS_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeStackAttachProcess(Process, ApcState);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeUnstackDetachProcess(_In_ PKAPC_STATE ApcState)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeUnstackDetachProcess impKeUnstackDetachProcess =
|
|
|
|
(pKeUnstackDetachProcess)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_UNSTACK_DETACH_PROCESS_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeUnstackDetachProcess(ApcState);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpKeWaitForSingleObject(_In_ PVOID Object,
|
|
|
|
_In_ KWAIT_REASON WaitReason,
|
|
|
|
_In_ KPROCESSOR_MODE WaitMode,
|
|
|
|
_In_ BOOLEAN Alertable,
|
|
|
|
_In_ PLARGE_INTEGER Timeout)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeWaitForSingleObject impKeWaitForSingleObject =
|
|
|
|
(pKeWaitForSingleObject)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_WAIT_FOR_SINGLE_OBJECT_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impKeWaitForSingleObject(
|
|
|
|
Object, WaitReason, WaitMode, Alertable, Timeout);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpPsCreateSystemThread(_Out_ PHANDLE ThreadHandle,
|
|
|
|
_In_ ULONG DesiredAccess,
|
|
|
|
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
|
|
|
|
_In_opt_ HANDLE ProcessHandle,
|
|
|
|
_Out_opt_ PCLIENT_ID ClientId,
|
|
|
|
_In_ PKSTART_ROUTINE StartRoutine,
|
|
|
|
_In_opt_ PVOID StartContext)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsCreateSystemThread impPsCreateSystemThread =
|
|
|
|
(pPsCreateSystemThread)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, PS_CREATE_SYSTEM_THREAD_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsCreateSystemThread(ThreadHandle,
|
|
|
|
DesiredAccess,
|
|
|
|
ObjectAttributes,
|
|
|
|
ProcessHandle,
|
|
|
|
ClientId,
|
|
|
|
StartRoutine,
|
|
|
|
StartContext);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpIofCompleteRequest(_In_ PIRP Irp, _In_ CCHAR PriorityBoost)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pIofCompleteRequest impIofCompleteRequest =
|
|
|
|
(pIofCompleteRequest)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, IOF_COMPLETE_REQUEST_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impIofCompleteRequest(Irp, PriorityBoost);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpObReferenceObjectByHandle(_In_ HANDLE Handle,
|
|
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
|
|
_In_opt_ POBJECT_TYPE ObjectType,
|
|
|
|
_In_ KPROCESSOR_MODE AccessMode,
|
|
|
|
_Out_ PVOID* Object,
|
|
|
|
_Out_opt_ POBJECT_HANDLE_INFORMATION
|
|
|
|
HandleInformation)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pObReferenceObjectByHandle impObReferenceObjectByHandle =
|
|
|
|
(pObReferenceObjectByHandle)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
OB_REFERENCE_OBJECT_BY_HANDLE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impObReferenceObjectByHandle(Handle,
|
|
|
|
DesiredAccess,
|
|
|
|
ObjectType,
|
|
|
|
AccessMode,
|
|
|
|
Object,
|
|
|
|
HandleInformation);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpKeDelayExecutionThread(_In_ KPROCESSOR_MODE WaitMode,
|
|
|
|
_In_ BOOLEAN Alertable,
|
|
|
|
_In_ PLARGE_INTEGER Interval)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeDelayExecutionThread impKeDelayExecutionThread =
|
|
|
|
(pKeDelayExecutionThread)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_DELAY_EXECUTION_THREAD_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impKeDelayExecutionThread(WaitMode, Alertable, Interval);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
ImpKeRegisterNmiCallback(_In_ PVOID CallbackRoutine, _In_opt_ PVOID Context)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeRegisterNmiCallback impKeRegisterNmiCallback =
|
|
|
|
(pKeRegisterNmiCallback)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_REGISTER_NMI_CALLBACK_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impKeRegisterNmiCallback(CallbackRoutine, Context);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpKeDeregisterNmiCallback(_In_ PVOID Handle)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeDeregisterNmiCallback impKeDeregisterNmiCallback =
|
|
|
|
(pKeDeregisterNmiCallback)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_DEREGISTER_NMI_CALLBACK_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impKeDeregisterNmiCallback(Handle);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ULONG
|
|
|
|
ImpKeQueryActiveProcessorCount(_In_ PKAFFINITY ActiveProcessors)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeQueryActiveProcessorCount impKeQueryActiveProcessorCount =
|
|
|
|
(pKeQueryActiveProcessorCount)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
KE_QUERY_ACTIVE_PROCESSOR_COUNT_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impKeQueryActiveProcessorCount(ActiveProcessors);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpExAcquirePushLockExclusiveEx(_Inout_ PEX_PUSH_LOCK PushLock,
|
|
|
|
_In_ ULONG Flags)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pExAcquirePushLockExclusiveEx impExAcquirePushLockExclusiveEx =
|
|
|
|
(pExAcquirePushLockExclusiveEx)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
EX_ACQUIRE_PUSH_LOCK_EXCLUSIVE_EX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impExAcquirePushLockExclusiveEx(PushLock, Flags);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpExReleasePushLockExclusiveEx(_Inout_ PEX_PUSH_LOCK PushLock,
|
|
|
|
_In_ ULONG Flags)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pExReleasePushLockExclusiveEx impExReleasePushLockExclusiveEx =
|
|
|
|
(pExReleasePushLockExclusiveEx)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
EX_RELEASE_PUSH_LOCK_EXCLUSIVE_EX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impExReleasePushLockExclusiveEx(PushLock, Flags);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE
|
|
|
|
ImpPsGetThreadId(_In_ PETHREAD Thread)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pPsGetThreadId impPsGetThreadId =
|
|
|
|
(pPsGetThreadId)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, PS_GET_THREAD_ID_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impPsGetThreadId(Thread);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
USHORT
|
|
|
|
ImpRtlCaptureStackBackTrace(_In_ ULONG FramesToSkip,
|
|
|
|
_In_ ULONG FramesToCapture,
|
|
|
|
_Out_ PVOID* BackTrace,
|
|
|
|
_Out_opt_ PULONG BackTraceHash)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlCaptureStackBackTrace impRtlCaptureStackBackTrace =
|
|
|
|
(pRtlCaptureStackBackTrace)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
RTL_CAPTURE_STACK_BACK_TRACE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlCaptureStackBackTrace(
|
|
|
|
FramesToSkip, FramesToCapture, BackTrace, BackTraceHash);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpZwOpenDirectoryObject(_Out_ PHANDLE DirectoryHandle,
|
|
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
|
|
_In_ POBJECT_ATTRIBUTES ObjectAttributes)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pZwOpenDirectoryObject impZwOpenDirectoryObject =
|
|
|
|
(pZwOpenDirectoryObject)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, ZW_OPEN_DIRECTORY_OBJECT_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impZwOpenDirectoryObject(
|
|
|
|
DirectoryHandle, DesiredAccess, ObjectAttributes);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeInitializeAffinityEx(_In_ PKAFFINITY_EX AffinityMask)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeInitializeAffinityEx impKeInitializeAffinityEx =
|
|
|
|
(pKeInitializeAffinityEx)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_INITIALIZE_AFFINITY_EX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeInitializeAffinityEx(AffinityMask);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeAddProcessorAffinityEx(_In_ PKAFFINITY_EX Affinity, _In_ INT CoreNumber)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeAddProcessorAffinityEx impKeAddProcessorAffinityEx =
|
|
|
|
(pKeAddProcessorAffinityEx)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
KE_ADD_PROCESSOR_AFFINITY_EX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeAddProcessorAffinityEx(Affinity, CoreNumber);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ImpRtlQueryModuleInformation(_Inout_ ULONG* InformationLength,
|
|
|
|
_In_ ULONG SizePerModule,
|
|
|
|
_In_ PVOID InformationBuffer)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlQueryModuleInformation impRtlQueryModuleInformation =
|
|
|
|
(pRtlQueryModuleInformation)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
RTL_QUERY_MODULE_INFORMATION_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlQueryModuleInformation(
|
|
|
|
InformationLength, SizePerModule, InformationBuffer);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeInitializeApc(_In_ PKAPC Apc,
|
|
|
|
_In_ PKTHREAD Thread,
|
|
|
|
_In_ KAPC_ENVIRONMENT Environment,
|
|
|
|
_In_ PKKERNEL_ROUTINE KernelRoutine,
|
|
|
|
_In_ PKRUNDOWN_ROUTINE RundownRoutine,
|
|
|
|
_In_ PKNORMAL_ROUTINE NormalRoutine,
|
|
|
|
_In_ KPROCESSOR_MODE ApcMode,
|
|
|
|
_In_ PVOID NormalContext)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeInitializeApc impKeInitializeApc =
|
|
|
|
(pKeInitializeApc)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_INITIALIZE_APC_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeInitializeApc(Apc,
|
|
|
|
Thread,
|
|
|
|
Environment,
|
|
|
|
KernelRoutine,
|
|
|
|
RundownRoutine,
|
|
|
|
NormalRoutine,
|
|
|
|
ApcMode,
|
|
|
|
NormalContext);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
ImpKeInsertQueueApc(_In_ PKAPC Apc,
|
|
|
|
_In_ PVOID SystemArgument1,
|
|
|
|
_In_ PVOID SystemArgument2,
|
|
|
|
_In_ KPRIORITY Increment)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeInsertQueueApc impKeInsertQueueApc =
|
|
|
|
(pKeInsertQueueApc)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_INSERT_QUEUE_APC_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impKeInsertQueueApc(
|
|
|
|
Apc, SystemArgument1, SystemArgument2, Increment);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeGenericCallDpc(_In_ PKDEFERRED_ROUTINE DpcRoutine, _In_ PVOID Context)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeGenericCallDpc impKeGenericCallDpc =
|
|
|
|
(pKeGenericCallDpc)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_GENERIC_CALL_DPC_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeGenericCallDpc(DpcRoutine, Context);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeSignalCallDpcDone(_In_ PVOID SystemArgument1)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeSignalCallDpcDone impKeSignalCallDpcDone =
|
|
|
|
(pKeSignalCallDpcDone)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_SIGNAL_CALL_DPC_DONE_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeSignalCallDpcDone(SystemArgument1);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PPHYSICAL_MEMORY_RANGE
|
|
|
|
ImpMmGetPhysicalMemoryRangesEx2(_In_ PVOID PartitionObject, _In_ ULONG Flags)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pMmGetPhysicalMemoryRangesEx2 impMmGetPhysicalMemoryRangesEx2 =
|
|
|
|
(pMmGetPhysicalMemoryRangesEx2)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports,
|
|
|
|
IMPORTS_LENGTH,
|
|
|
|
MM_GET_PHYSICAL_MEMORY_RANGES_EX2_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impMmGetPhysicalMemoryRangesEx2(PartitionObject, Flags);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
ImpMmGetVirtualForPhysical(_In_ PHYSICAL_ADDRESS PhysicalAddress)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pMmGetVirtualForPhysical impMmGetVirtualForPhysical =
|
|
|
|
(pMmGetVirtualForPhysical)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, MM_GET_VIRTUAL_FOR_PHYSICAL_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impMmGetVirtualForPhysical(PhysicalAddress);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LONG_PTR
|
|
|
|
ImpObfReferenceObject(_In_ PVOID Object)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pObfReferenceObject impObfReferenceObject =
|
|
|
|
(pObfReferenceObject)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, OBF_REFERENCE_OBJECT_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impObfReferenceObject(Object);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpExFreePoolWithTag(_In_ PVOID P, _In_ ULONG Tag)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pExFreePoolWithTag impExFreePoolWithTag =
|
|
|
|
(pExFreePoolWithTag)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, EX_FREE_POOL_WITH_TAG_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impExFreePoolWithTag(P, Tag);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PVOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ImpExAllocatePool2(_In_ POOL_FLAGS Flags,
|
|
|
|
_In_ SIZE_T NumberOfBytes,
|
|
|
|
_In_ ULONG Tag)
|
2024-01-29 17:31:12 +01:00
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pExAllocatePool2 impExAllocatePool2 =
|
|
|
|
(pExAllocatePool2)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, EX_ALLOCATE_POOL2_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impExAllocatePool2(Flags, NumberOfBytes, Tag);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeReleaseGuardedMutex(_In_ PKGUARDED_MUTEX GuardedMutex)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeReleaseGuardedMutex impKeReleaseGuardedMutex =
|
|
|
|
(pKeReleaseGuardedMutex)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_RELEASE_GUARDED_MUTEX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeReleaseGuardedMutex(GuardedMutex);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpKeAcquireGuardedMutex(_In_ PKGUARDED_MUTEX GuardedMutex)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pKeAcquireGuardedMutex impKeAcquireGuardedMutex =
|
|
|
|
(pKeAcquireGuardedMutex)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, KE_ACQUIRE_GUARDED_MUTEX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impKeAcquireGuardedMutex(GuardedMutex);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ULONG
|
|
|
|
ImpDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_ PCSTR Format, ...)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pDbgPrintEx impDbgPrintEx = (pDbgPrintEx)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, DBG_PRINT_EX_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
va_list args;
|
|
|
|
va_start(args, Format);
|
|
|
|
ULONG result = impDbgPrintEx(ComponentId, Level, Format, args);
|
|
|
|
va_end(args);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return result;
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LONG
|
|
|
|
ImpRtlCompareUnicodeString(_In_ PCUNICODE_STRING String1,
|
|
|
|
_In_ PCUNICODE_STRING String2,
|
|
|
|
_In_ BOOLEAN CaseInSensitive)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlCompareUnicodeString impRtlCompareUnicodeString =
|
|
|
|
(pRtlCompareUnicodeString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_COMPARE_UNICODE_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
return impRtlCompareUnicodeString(String1, String2, CaseInSensitive);
|
2024-01-29 17:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImpRtlFreeUnicodeString(_In_ PUNICODE_STRING UnicodeString)
|
|
|
|
{
|
2024-04-13 10:23:14 +02:00
|
|
|
pRtlFreeUnicodeString impRtlFreeUnicodeString =
|
|
|
|
(pRtlFreeUnicodeString)CryptDecryptImportsArrayEntry(
|
|
|
|
&driver_imports, IMPORTS_LENGTH, RTL_FREE_UNICODE_STRING_INDEX);
|
2024-01-29 17:31:12 +01:00
|
|
|
|
2024-04-13 10:23:14 +02:00
|
|
|
impRtlFreeUnicodeString(UnicodeString);
|
2024-01-07 05:13:41 +01:00
|
|
|
}
|