HyperDbg Debugger
|
This file shows the functions to map memory to reserved system ranges. More...
#include "pch.h"
Functions | |
_Use_decl_annotations_ UINT64 | MemoryMapperGetIndex (PAGING_LEVEL Level, UINT64 Va) |
Get Index of VA on PMLx. | |
_Use_decl_annotations_ UINT32 | MemoryMapperGetOffset (PAGING_LEVEL Level, UINT64 Va) |
Get page offset. | |
_Use_decl_annotations_ PVOID | MemoryMapperGetPteVa (PVOID Va, PAGING_LEVEL Level) |
This function gets virtual address and returns its PTE of the virtual address. | |
_Use_decl_annotations_ PVOID | MemoryMapperGetPteVaByCr3 (PVOID Va, PAGING_LEVEL Level, CR3_TYPE TargetCr3) |
This function gets virtual address and returns its PTE of the virtual address based on the specific cr3. | |
_Use_decl_annotations_ PVOID | MemoryMapperGetPteVaOnTargetProcess (PVOID Va, PAGING_LEVEL Level) |
This function gets virtual address and returns its PTE of the virtual address based on the target virtual address. | |
BOOLEAN | MemoryMapperCheckPteIsPresentOnTargetProcess (PVOID Va, PAGING_LEVEL Level) |
This function checks whether the virtual address is present in the RAM or not. | |
_Use_decl_annotations_ PVOID | MemoryMapperSetExecuteDisableToPteOnTargetProcess (PVOID Va, BOOLEAN Set) |
This function gets virtual address and returns its PTE of the virtual address based on the target virtual address. | |
_Use_decl_annotations_ PVOID | MemoryMapperGetPteVaWithoutSwitchingByCr3 (PVOID Va, PAGING_LEVEL Level, CR3_TYPE TargetCr3) |
This function gets virtual address and returns its PTE of the virtual address based on the specific cr3 but without switching to the target address. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperCheckIfPageIsPresentByCr3 (PVOID Va, CR3_TYPE TargetCr3) |
This function checks if the page is mapped or not. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperCheckIfPageIsNxBitSetByCr3 (PVOID Va, CR3_TYPE TargetCr3) |
This function checks if the page has NX bit or not. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperCheckIfPageIsNxBitSetOnTargetProcess (PVOID Va) |
This function checks target process to see if the page has NX bit or not. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperCheckIfPdeIsLargePageOnTargetProcess (PVOID Va) |
This function checks target process to see if the PDE is a large page or not. | |
_Use_decl_annotations_ PVOID | MemoryMapperMapReservedPageRange (SIZE_T Size) |
This function reserve memory from system range (without physically allocating them) | |
_Use_decl_annotations_ VOID | MemoryMapperUnmapReservedPageRange (PVOID VirtualAddress) |
This function frees the memory that was previously allocated from system range (without physically allocating them) | |
_Use_decl_annotations_ PVOID | MemoryMapperGetPte (PVOID VirtualAddress) |
This function gets virtual address and returns its PTE (Pml4e) virtual address. | |
_Use_decl_annotations_ PVOID | MemoryMapperGetPteByCr3 (PVOID VirtualAddress, CR3_TYPE TargetCr3) |
This function gets virtual address and returns its PTE (Pml4e) virtual address based on a specific Cr3. | |
_Use_decl_annotations_ PVOID | MemoryMapperMapPageAndGetPte (PUINT64 PteAddress) |
This function MAPs one resreved page (4096) and returns its virtual adrresss and also PTE virtual address in PteAddress. | |
VOID | MemoryMapperInitialize () |
Initialize the Memory Mapper. | |
VOID | MemoryMapperUninitialize () |
uninitialize the Memory Mapper | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperReadMemorySafeByPte (PHYSICAL_ADDRESS PaAddressToRead, PVOID BufferToSaveMemory, SIZE_T SizeToRead, UINT64 PteVaAddress, UINT64 MappingVa, BOOLEAN InvalidateVpids) |
Read memory safely by mapping the buffer using PTE. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperWriteMemorySafeByPte (PVOID SourceVA, PHYSICAL_ADDRESS PaAddressToWrite, SIZE_T SizeToWrite, UINT64 PteVaAddress, UINT64 MappingVa, BOOLEAN InvalidateVpids) |
Write memory safely by mapping the buffer using PTE. | |
_Use_decl_annotations_ UINT64 | MemoryMapperReadMemorySafeByPhysicalAddressWrapperAddressMaker (MEMORY_MAPPER_WRAPPER_FOR_MEMORY_READ TypeOfRead, UINT64 AddressToRead) |
Wrapper to read the memory safely by mapping the buffer by physical address (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperReadMemorySafeByPhysicalAddressWrapper (MEMORY_MAPPER_WRAPPER_FOR_MEMORY_READ TypeOfRead, UINT64 AddressToRead, UINT64 BufferToSaveMemory, SIZE_T SizeToRead) |
Wrapper to read the memory safely by mapping the buffer by physical address (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperReadMemorySafeByPhysicalAddress (UINT64 PaAddressToRead, UINT64 BufferToSaveMemory, SIZE_T SizeToRead) |
Read memory safely by mapping the buffer by physical address (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperReadMemorySafe (UINT64 VaAddressToRead, PVOID BufferToSaveMemory, SIZE_T SizeToRead) |
Read memory safely by mapping the buffer (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperReadMemorySafeOnTargetProcess (UINT64 VaAddressToRead, PVOID BufferToSaveMemory, SIZE_T SizeToRead) |
Read memory safely by mapping the buffer on the target process memory (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperWriteMemorySafeOnTargetProcess (UINT64 Destination, PVOID Source, SIZE_T Size) |
Write memory safely by mapping the buffer on the target process memory (It's a wrapper) | |
_Use_decl_annotations_ UINT64 | MemoryMapperWriteMemorySafeWrapperAddressMaker (MEMORY_MAPPER_WRAPPER_FOR_MEMORY_WRITE TypeOfWrite, UINT64 DestinationAddr, PCR3_TYPE TargetProcessCr3, UINT32 TargetProcessId) |
Decides about making the address and converting the address to physical address based on the passed parameters. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperWriteMemorySafeWrapper (MEMORY_MAPPER_WRAPPER_FOR_MEMORY_WRITE TypeOfWrite, UINT64 DestinationAddr, UINT64 Source, SIZE_T SizeToWrite, PCR3_TYPE TargetProcessCr3, UINT32 TargetProcessId) |
Write memory safely by mapping the buffer (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperWriteMemorySafe (UINT64 Destination, PVOID Source, SIZE_T SizeToWrite, CR3_TYPE TargetProcessCr3) |
Write memory by mapping the buffer (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperWriteMemoryUnsafe (UINT64 Destination, PVOID Source, SIZE_T SizeToWrite, UINT32 TargetProcessId) |
Write memory safely by mapping the buffer (It's a wrapper) | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperWriteMemorySafeByPhysicalAddress (UINT64 DestinationPa, UINT64 Source, SIZE_T SizeToWrite) |
Write memory safely by mapping the buffer. | |
_Use_decl_annotations_ UINT64 | MemoryMapperReserveUsermodeAddressOnTargetProcess (UINT32 ProcessId, BOOLEAN Allocate) |
Reserve user mode address (not allocated) in the target user mode application. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperFreeMemoryOnTargetProcess (UINT32 ProcessId, PVOID BaseAddress) |
Deallocates a previously reserved user mode address in the target user mode application. | |
_Use_decl_annotations_ VOID | MemoryMapperMapPhysicalAddressToPte (PHYSICAL_ADDRESS PhysicalAddress, PVOID TargetProcessVirtualAddress, CR3_TYPE TargetProcessKernelCr3) |
Maps a physical address to a PTE. | |
_Use_decl_annotations_ BOOLEAN | MemoryMapperSetSupervisorBitWithoutSwitchingByCr3 (PVOID Va, BOOLEAN Set, PAGING_LEVEL Level, CR3_TYPE TargetCr3) |
This function the Supervisor bit of the target PTE based on the specific cr3. | |
This file shows the functions to map memory to reserved system ranges.
This file shows the header functions to map memory to reserved system ranges.
also some of the functions derived from hvpp
also some of the functions derived from hvpp
_Use_decl_annotations_ BOOLEAN MemoryMapperCheckIfPageIsNxBitSetByCr3 | ( | PVOID | Va, |
CR3_TYPE | TargetCr3 ) |
This function checks if the page has NX bit or not.
Va | Virtual Address |
TargetCr3 | kernel cr3 of target process |
_Use_decl_annotations_ BOOLEAN MemoryMapperCheckIfPageIsNxBitSetOnTargetProcess | ( | PVOID | Va | ) |
This function checks target process to see if the page has NX bit or not.
Va | Virtual Address |
TargetCr3 | kernel cr3 of target process |
_Use_decl_annotations_ BOOLEAN MemoryMapperCheckIfPageIsPresentByCr3 | ( | PVOID | Va, |
CR3_TYPE | TargetCr3 ) |
This function checks if the page is mapped or not.
this function checks for PRESENT Bit of the page table
Va | Virtual Address |
TargetCr3 | kernel cr3 of target process |
_Use_decl_annotations_ BOOLEAN MemoryMapperCheckIfPdeIsLargePageOnTargetProcess | ( | PVOID | Va | ) |
This function checks target process to see if the PDE is a large page or not.
Va | Virtual Address |
TargetCr3 | kernel cr3 of target process |
BOOLEAN MemoryMapperCheckPteIsPresentOnTargetProcess | ( | PVOID | Va, |
PAGING_LEVEL | Level ) |
This function checks whether the virtual address is present in the RAM or not.
Va | Virtual Address |
Level | PMLx |
_Use_decl_annotations_ BOOLEAN MemoryMapperFreeMemoryOnTargetProcess | ( | UINT32 | ProcessId, |
PVOID | BaseAddress ) |
Deallocates a previously reserved user mode address in the target user mode application.
this function should be called from vmx non-root mode
ProcessId | Target Process Id |
BaseAddress | Previously allocated base address |
_Use_decl_annotations_ UINT64 MemoryMapperGetIndex | ( | PAGING_LEVEL | Level, |
UINT64 | Va ) |
_Use_decl_annotations_ UINT32 MemoryMapperGetOffset | ( | PAGING_LEVEL | Level, |
UINT64 | Va ) |
Get page offset.
Level | PMLx |
Va | Virtual Address |
_Use_decl_annotations_ PVOID MemoryMapperGetPte | ( | PVOID | VirtualAddress | ) |
This function gets virtual address and returns its PTE (Pml4e) virtual address.
VirtualAddress | Virtual Address |
_Use_decl_annotations_ PVOID MemoryMapperGetPteByCr3 | ( | PVOID | VirtualAddress, |
CR3_TYPE | TargetCr3 ) |
This function gets virtual address and returns its PTE (Pml4e) virtual address based on a specific Cr3.
VirtualAddress | Virtual Address |
TargetCr3 | Target process cr3 |
_Use_decl_annotations_ PVOID MemoryMapperGetPteVa | ( | PVOID | Va, |
PAGING_LEVEL | Level ) |
_Use_decl_annotations_ PVOID MemoryMapperGetPteVaByCr3 | ( | PVOID | Va, |
PAGING_LEVEL | Level, | ||
CR3_TYPE | TargetCr3 ) |
This function gets virtual address and returns its PTE of the virtual address based on the specific cr3.
the TargetCr3 should be kernel cr3 as we will use it to translate kernel addresses so the kernel functions to translate addresses should be mapped; thus, don't pass a KPTI meltdown user cr3 to this function
Va | Virtual Address |
Level | PMLx |
TargetCr3 | kernel cr3 of target process |
_Use_decl_annotations_ PVOID MemoryMapperGetPteVaOnTargetProcess | ( | PVOID | Va, |
PAGING_LEVEL | Level ) |
This function gets virtual address and returns its PTE of the virtual address based on the target virtual address.
Va | Virtual Address |
Level | PMLx |
_Use_decl_annotations_ PVOID MemoryMapperGetPteVaWithoutSwitchingByCr3 | ( | PVOID | Va, |
PAGING_LEVEL | Level, | ||
CR3_TYPE | TargetCr3 ) |
This function gets virtual address and returns its PTE of the virtual address based on the specific cr3 but without switching to the target address.
the TargetCr3 should be kernel cr3 as we will use it to translate kernel addresses so the kernel functions to translate addresses should be mapped; thus, don't pass a KPTI meltdown user cr3 to this function
Va | Virtual Address |
Level | PMLx |
TargetCr3 | kernel cr3 of target process |
VOID MemoryMapperInitialize | ( | ) |
Initialize the Memory Mapper.
This function should be called in vmx non-root in a IRQL <= APC_LEVEL
_Use_decl_annotations_ PVOID MemoryMapperMapPageAndGetPte | ( | PUINT64 | PteAddress | ) |
This function MAPs one resreved page (4096) and returns its virtual adrresss and also PTE virtual address in PteAddress.
PteAddress | Address of Page Table Entry |
_Use_decl_annotations_ VOID MemoryMapperMapPhysicalAddressToPte | ( | PHYSICAL_ADDRESS | PhysicalAddress, |
PVOID | TargetProcessVirtualAddress, | ||
CR3_TYPE | TargetProcessKernelCr3 ) |
Maps a physical address to a PTE.
Find the PTE from MemoryMapperGetPteVaByCr3
PhysicalAddress | Physical Address to be mapped |
TargetProcessVirtualAddress | Virtual Address of target process |
TargetProcessKernelCr3 | Target process cr3 |
_Use_decl_annotations_ PVOID MemoryMapperMapReservedPageRange | ( | SIZE_T | Size | ) |
This function reserve memory from system range (without physically allocating them)
Size | Size of reserving buffers |
_Use_decl_annotations_ BOOLEAN MemoryMapperReadMemorySafe | ( | UINT64 | VaAddressToRead, |
PVOID | BufferToSaveMemory, | ||
SIZE_T | SizeToRead ) |
Read memory safely by mapping the buffer (It's a wrapper)
VaAddressToRead | Virtual Address to read |
BufferToSaveMemory | Destination to save |
SizeToRead | Size |
_Use_decl_annotations_ BOOLEAN MemoryMapperReadMemorySafeByPhysicalAddress | ( | UINT64 | PaAddressToRead, |
UINT64 | BufferToSaveMemory, | ||
SIZE_T | SizeToRead ) |
Read memory safely by mapping the buffer by physical address (It's a wrapper)
PaAddressToRead | Physical Address to read |
BufferToSaveMemory | Destination to save |
SizeToRead | Size |
_Use_decl_annotations_ BOOLEAN MemoryMapperReadMemorySafeByPhysicalAddressWrapper | ( | MEMORY_MAPPER_WRAPPER_FOR_MEMORY_READ | TypeOfRead, |
UINT64 | AddressToRead, | ||
UINT64 | BufferToSaveMemory, | ||
SIZE_T | SizeToRead ) |
Wrapper to read the memory safely by mapping the buffer by physical address (It's a wrapper)
TypeOfRead | Type of read |
AddressToRead | Address to read |
BufferToSaveMemory | Destination to save |
SizeToRead | Size |
_Use_decl_annotations_ UINT64 MemoryMapperReadMemorySafeByPhysicalAddressWrapperAddressMaker | ( | MEMORY_MAPPER_WRAPPER_FOR_MEMORY_READ | TypeOfRead, |
UINT64 | AddressToRead ) |
Wrapper to read the memory safely by mapping the buffer by physical address (It's a wrapper)
TypeOfRead | Type of read |
AddressToRead | Physical Address to read |
_Use_decl_annotations_ BOOLEAN MemoryMapperReadMemorySafeByPte | ( | PHYSICAL_ADDRESS | PaAddressToRead, |
PVOID | BufferToSaveMemory, | ||
SIZE_T | SizeToRead, | ||
UINT64 | PteVaAddress, | ||
UINT64 | MappingVa, | ||
BOOLEAN | InvalidateVpids ) |
Read memory safely by mapping the buffer using PTE.
PaAddressToRead | Physical address to read |
BufferToSaveMemory | buffer to save the memory |
SizeToRead | Size |
PteVaAddress | Virtual Address of PTE |
MappingVa | Mapping virtual address |
InvalidateVpids | whether invalidate based on VPIDs or not |
_Use_decl_annotations_ BOOLEAN MemoryMapperReadMemorySafeOnTargetProcess | ( | UINT64 | VaAddressToRead, |
PVOID | BufferToSaveMemory, | ||
SIZE_T | SizeToRead ) |
Read memory safely by mapping the buffer on the target process memory (It's a wrapper)
VaAddressToRead | Virtual Address to read |
BufferToSaveMemory | Destination to save |
SizeToRead | Size |
_Use_decl_annotations_ UINT64 MemoryMapperReserveUsermodeAddressOnTargetProcess | ( | UINT32 | ProcessId, |
BOOLEAN | Allocate ) |
Reserve user mode address (not allocated) in the target user mode application.
this function should be called from vmx non-root mode
ProcessId | Target Process Id |
Allocate | Whether allocate or just reserve |
_Use_decl_annotations_ PVOID MemoryMapperSetExecuteDisableToPteOnTargetProcess | ( | PVOID | Va, |
BOOLEAN | Set ) |
This function gets virtual address and returns its PTE of the virtual address based on the target virtual address.
the TargetCr3 should be kernel cr3 as we will use it to translate kernel addresses so the kernel functions to translate addresses should be mapped; thus, don't pass a KPTI meltdown user cr3 to this function
Va | Virtual Address |
Set |
_Use_decl_annotations_ BOOLEAN MemoryMapperSetSupervisorBitWithoutSwitchingByCr3 | ( | PVOID | Va, |
BOOLEAN | Set, | ||
PAGING_LEVEL | Level, | ||
CR3_TYPE | TargetCr3 ) |
This function the Supervisor bit of the target PTE based on the specific cr3.
Va | Virtual Address |
Set | Set it to 1 or 0 |
Level | PMLx |
TargetCr3 | kernel cr3 of target process |
VOID MemoryMapperUninitialize | ( | ) |
uninitialize the Memory Mapper
This function should be called in vmx non-root in a IRQL <= APC_LEVEL
_Use_decl_annotations_ VOID MemoryMapperUnmapReservedPageRange | ( | PVOID | VirtualAddress | ) |
This function frees the memory that was previously allocated from system range (without physically allocating them)
VirtualAddress | Virtual Address |
_Use_decl_annotations_ BOOLEAN MemoryMapperWriteMemorySafe | ( | UINT64 | Destination, |
PVOID | Source, | ||
SIZE_T | SizeToWrite, | ||
CR3_TYPE | TargetProcessCr3 ) |
Write memory by mapping the buffer (It's a wrapper)
this function CAN be called from vmx-root mode
Destination | Destination Virtual Address |
Source | Source Virtual Address |
SizeToWrite | Size |
TargetProcessCr3 | CR3 of target process |
_Use_decl_annotations_ BOOLEAN MemoryMapperWriteMemorySafeByPhysicalAddress | ( | UINT64 | DestinationPa, |
UINT64 | Source, | ||
SIZE_T | SizeToWrite ) |
Write memory safely by mapping the buffer.
DestinationPa | Destination Physical Address |
Source | Source Address |
SizeToWrite | Size |
_Use_decl_annotations_ BOOLEAN MemoryMapperWriteMemorySafeByPte | ( | PVOID | SourceVA, |
PHYSICAL_ADDRESS | PaAddressToWrite, | ||
SIZE_T | SizeToWrite, | ||
UINT64 | PteVaAddress, | ||
UINT64 | MappingVa, | ||
BOOLEAN | InvalidateVpids ) |
Write memory safely by mapping the buffer using PTE.
SourceVA | Source virtual address |
PaAddressToWrite | Destination physical address |
SizeToWrite | Size |
PteVaAddress | PTE of target virtual address |
MappingVa | Mapping Virtual Address |
InvalidateVpids | Invalidate VPIDs or not |
_Use_decl_annotations_ BOOLEAN MemoryMapperWriteMemorySafeOnTargetProcess | ( | UINT64 | Destination, |
PVOID | Source, | ||
SIZE_T | Size ) |
Write memory safely by mapping the buffer on the target process memory (It's a wrapper)
Destination | Virtual Address to write |
Source | value to write |
Size | Size |
_Use_decl_annotations_ BOOLEAN MemoryMapperWriteMemorySafeWrapper | ( | MEMORY_MAPPER_WRAPPER_FOR_MEMORY_WRITE | TypeOfWrite, |
UINT64 | DestinationAddr, | ||
UINT64 | Source, | ||
SIZE_T | SizeToWrite, | ||
PCR3_TYPE | TargetProcessCr3, | ||
UINT32 | TargetProcessId ) |
Write memory safely by mapping the buffer (It's a wrapper)
TypeOfWrite | Type of memory write |
DestinationAddr | Destination Address |
Source | Source Address |
SizeToWrite | Size |
TargetProcessCr3 | The process CR3 (might be null) |
TargetProcessId | The process PID (might be null) |
_Use_decl_annotations_ UINT64 MemoryMapperWriteMemorySafeWrapperAddressMaker | ( | MEMORY_MAPPER_WRAPPER_FOR_MEMORY_WRITE | TypeOfWrite, |
UINT64 | DestinationAddr, | ||
PCR3_TYPE | TargetProcessCr3, | ||
UINT32 | TargetProcessId ) |
Decides about making the address and converting the address to physical address based on the passed parameters.
TypeOfWrite | Type of memory write |
DestinationAddr | Destination Address |
TargetProcessCr3 | The process CR3 (might be null) |
TargetProcessId | The process PID (might be null) |
_Use_decl_annotations_ BOOLEAN MemoryMapperWriteMemoryUnsafe | ( | UINT64 | Destination, |
PVOID | Source, | ||
SIZE_T | SizeToWrite, | ||
UINT32 | TargetProcessId ) |
Write memory safely by mapping the buffer (It's a wrapper)
this function should not be called from vmx-root mode
Destination | Destination Virtual Address |
Source | Source Virtual Address |
SizeToWrite | Size |
TargetProcessId | Target Process Id |