Last active
April 18, 2023 14:04
-
-
Save hfiref0x/75b8c5093e19511e2248fbda4c4af2f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void __fastcall Func007( | |
int IoControlCode, | |
MEMOP *InputBuffer, | |
__int64 InputBufferLength, | |
MEMOP *OutputBuffer, | |
int OutputBufferLength, | |
_DWORD *StatusInformation) | |
{ | |
PHYSICAL_ADDRESS PhysicalAddress; | |
PMDL MemoryDescriptorList; | |
PVOID BaseAddress; | |
PVOID MappedSystemVa; | |
*StatusInformation = OutputBufferLength; | |
if ( IoControlCode == 0x81000000 ) | |
{ | |
MemoryDescriptorList = IoAllocateMdl(InputBuffer->VirtualAddress, InputBuffer->Length, 0, 1u, 0i64); | |
if ( MemoryDescriptorList ) | |
{ | |
MmProbeAndLockPages(MemoryDescriptorList, 1, IoReadAccess); | |
if ( (MemoryDescriptorList->MdlFlags & 5) != 0 ) | |
MappedSystemVa = MemoryDescriptorList->MappedSystemVa; | |
else | |
MappedSystemVa = MmMapLockedPagesSpecifyCache(MemoryDescriptorList, 0, MmCached, 0i64, 0, 0x10u); | |
if ( MappedSystemVa ) | |
{ | |
if ( (PhysicalAddress = MmGetPhysicalAddress(InputBuffer->BaseAddress) | |
&& PhysicalAddress.LowPart | |
|| PhysicalAddress.HighPart > 0 ) | |
{ | |
BaseAddress = MmMapIoSpace(PhysicalAddress, LODWORD(InputBuffer->Length), MmNonCached); | |
if ( BaseAddress ) | |
{ | |
qmemcpy(BaseAddress, MappedSystemVa, LODWORD(InputBuffer->Length)); | |
MmUnmapIoSpace(BaseAddress, LODWORD(InputBuffer->Length)); | |
} | |
} | |
} | |
MmUnlockPages(MemoryDescriptorList); | |
IoFreeMdl(MemoryDescriptorList); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment