55 #define for_each_slack(_var_name) list_for_each(gSlackAllocations, SLACK_SPACE, _var_name) 105 BYTE *moduleBuffer = NULL;
106 DWORD bufferSize = 0;
118 ERROR(
"[ERROR] IntPeValidateHeader failed with status: 0x%08x\n", status);
139 ERROR(
"[ERROR] Failed reading IMAGE_SECTION_HEADER %d for module 0x%016llx: 0x%08x\n",
140 i, ModuleBase, status);
145 if ((0 != SecHint) && (0 != memcmp(&SecHint, sec.
Name, 8)))
161 if ((memcmp(sec.
Name,
"INITKDBG", 8) == 0))
175 DWORD totalUsedSpace;
185 if ((pSlack->Windows.Section == i) && (pSlack->ModuleBase == ModuleBase))
187 if (pSlack->Windows.SectionOffset > maxOffset)
189 maxOffset = pSlack->Windows.SectionOffset;
191 totalUsedSpace = maxOffset - sec.
Misc.
VirtualSize + pSlack->AllocationSize;
197 if (totalSpace - totalUsedSpace >= Size)
213 ERROR(
"[ERROR] IntKernVirtMemRead failed GVA 0x%016llx: 0x%08x\n", gva, status);
217 for (j = 0; j < Size; j++)
221 ERROR(
"[ERROR] Slack buffer not 0-filled! 0x%016llx\n", gva + j);
236 TRACE(
"[SLACK] Found %d bytes of space, used %d bytes, in section %d, " 237 "at offset %08x in module 0x%016llx\n", totalSpace, totalUsedSpace, i,
250 *Buffer = pSlack->
Gva;
311 ERROR(
"[ERROR] IntVirtMemMap failed for %llx: 0x%08x\n", gva, status);
315 for (
DWORD offset = 0; offset < maxOffset; offset++)
320 while (offset < maxOffset && (p[offset] != 0x90))
329 while ((foundSize < Size) && (p[offset + foundSize] == 0x90))
334 if (foundSize == Size)
343 pSlack->
Gva = gva + offset;
347 TRACE(
"[SLACK] Found %d bytes of space at 0x%016llx\n", foundSize, pSlack->
Gva);
351 *Buffer = pSlack->
Gva;
451 if (pSlack->Gva == Buffer)
#define IMAGE_SCN_MEM_EXECUTE
#define CONTAINING_RECORD(List, Type, Member)
INTSTATUS IntVirtMemUnmap(void **HostPtr)
Unmaps a memory range previously mapped with IntVirtMemMap.
INTSTATUS IntSlackFree(QWORD Buffer)
Free slack space.
WINDOWS_GUEST * gWinGuest
Global variable holding the state of a Windows guest.
QWORD SystemCr3
The Cr3 used to map the kernel.
#define INT_STATUS_SUCCESS
#define PAGE_REMAINING(addr)
DWORD AllocationSize
The number of bytes allocated.
#define IMAGE_SCN_MEM_WRITE
#define INT_SUCCESS(Status)
static BOOLEAN IsListEmpty(const LIST_ENTRY *ListHead)
#define for_each_slack(_var_name)
QWORD SectionOffset
Offset of the first section header.
DWORD SectionOffset
The offset inside the section of the allocation.
#define HpAllocWithTag(Len, Tag)
int INTSTATUS
The status data type.
#define INT_STATUS_NOT_FOUND
void IntSlackUninit(void)
Uninit the slack system. Must be called only during uninit.
INTRO_GUEST_TYPE OSType
The type of the guest.
struct _SLACK_SPACE * PSLACK_SPACE
struct _SLACK_SPACE SLACK_SPACE
QWORD Gva
The guest virtual address of the actual allocation.
static BOOLEAN RemoveEntryList(LIST_ENTRY *Entry)
union _IMAGE_SECTION_HEADER::@209 Misc
#define INT_STATUS_INVALID_PARAMETER_4
QWORD NumberOfSections
Number of sections.
#define HpFreeAndNullWithTag(Add, Tag)
INTSTATUS IntSlackAlloc(QWORD ModuleBase, BOOLEAN Pageable, DWORD Size, QWORD *Buffer, QWORD SecHint)
Allocate slack inside the guest.
QWORD KernelVa
The guest virtual address at which the kernel image.
static void InsertTailList(LIST_ENTRY *ListHead, LIST_ENTRY *Entry)
struct _SLACK_SPACE::@266::@268 Windows
DWORD AllocationOffset
The allocation offset, within the last page of the section.
QWORD ModuleBase
The module base used for the allocation.
DWORD KernelBufferSize
The size of the KernelBuffer.
static LIST_HEAD gSlackAllocations
static INTSTATUS IntSlackAllocLinux(DWORD Size, QWORD *Buffer)
Allocate slack space on Linux.
INTSTATUS IntPeValidateHeader(QWORD ImageBase, BYTE *ImageBaseBuffer, DWORD ImageBaseBufferSize, INTRO_PE_INFO *PeInfo, QWORD Cr3)
Validates a PE header.
DWORD SectionSize
The size of the section.
__must_check INTSTATUS IntVirtMemMap(QWORD Gva, DWORD Length, QWORD Cr3, DWORD Flags, void **HostPtr)
Maps a guest virtual memory range inside Introcore virtual address space.
MM Mm
Guest memory information, such as paging mode, system Cr3 value, etc.
GUEST_STATE gGuest
The current guest state.
#define IMAGE_SCN_MEM_DISCARDABLE
TIMER_FRIENDLY void IntDumpBuffer(void *Buffer, QWORD Gva, DWORD Length, DWORD RowLength, DWORD ElementLength, BOOLEAN LogHeader, BOOLEAN DumpAscii)
This function dumps a given buffer in a user friendly format.
INTSTATUS IntKernVirtMemRead(QWORD KernelGva, DWORD Length, void *Buffer, DWORD *RetLength)
Reads data from a guest kernel virtual memory range.
#define LIST_HEAD_INIT(Name)
BYTE * KernelBuffer
A buffer containing the entire kernel image.
#define INT_STATUS_INVALID_PARAMETER_1
#define INT_STATUS_NOT_SUPPORTED
struct _LIST_ENTRY * Blink
UINT8 Name[IMAGE_SIZEOF_SHORT_NAME]
static INTSTATUS IntSlackAllocWindows(BOOLEAN Pageable, QWORD ModuleBase, DWORD Size, QWORD *Buffer, QWORD SecHint)
Allocate memory inside the guest.
LIST_ENTRY Link
List entry element.
#define IMAGE_SCN_MEM_NOT_PAGED
DWORD Section
The section index (zero based) inside the module.
#define INT_STATUS_INSUFFICIENT_RESOURCES
#define INT_STATUS_INVALID_PARAMETER_3