145 ULONG FirstPage, LastPage;
169 if (FirstPage == LastPage)
175 for (
i = FirstPage;
i <= LastPage;
i++)
189 ULONG FirstPage, LastPage;
202 if (FirstPage == LastPage)
208 for (
i = FirstPage;
i <= LastPage;
i++)
229 static BYTE StaticBuffer[8192];
231 static ULONG HeapBufferSize = 0;
234 if (
Size <=
sizeof(StaticBuffer))
237 LocalBuffer = StaticBuffer;
239 else if (
Size <= HeapBufferSize)
242 ASSERT(HeapBufferSize > 0 && HeapBuffer !=
NULL);
243 LocalBuffer = HeapBuffer;
249 if (HeapBuffer ==
NULL)
260 HeapBuffer = LocalBuffer;
261 HeapBufferSize =
Size;
289 DPRINT(
"The memory at 0x%08X could not be %s.\n", FaultAddress, Writing ?
"written" :
"read");
292 ASSERT(FaultAddress < MAX_ADDRESS && Hook != NULL && Hook->
hVdd !=
NULL);
311 for (
i = FirstPage;
i <= LastPage;
i++)
344 Hook->
Count += LastPage - FirstPage + 1;
362 for (
i = FirstPage;
i <= LastPage;
i++)
367 if (--Hook->
Count == 0)
491 if (dwCount == 0)
return FALSE;
494 for (
i = FirstPage;
i <= LastPage;
i++)
540 Hook->
Count += LastPage - FirstPage + 1;
569 if (dwCount == 0)
return FALSE;
580 for (
i = FirstPage;
i <= LastPage;
i++)
583 if (Hook ==
NULL)
continue;
587 DPRINT1(
"VDDDeInstallMemoryHook: Page %u owned by someone else.\n",
i);
591 if (--Hook->
Count == 0)
630 for (
i = FirstPage;
i <= LastPage;
i++)
637 DPRINT1(
"VDDAllocMem: Page %u owned by someone else.\n",
i);
678 for (
i = FirstPage;
i <= LastPage;
i++)
685 DPRINT1(
"VDDFreeMem: Page %u owned by someone else.\n",
i);
765 wprintf(
L"FATAL: Failed to commit VDM memory, Status 0x%08lx\n",
Status);
807 DPRINT1(
"NTVDM: Failed to decommit VDM memory, Status 0x%08lx\n",
Status);
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
#define NT_SUCCESS(StatCode)
#define ERROR_INVALID_PARAMETER
#define INVALID_HANDLE_VALUE
#define PHYS_TO_REAL(ptr)
#define REAL_TO_PHYS(ptr)
#define SEG_OFF_TO_PTR(seg, off)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
_Must_inspect_result_ _In_ USHORT NewSize
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define RtlFillMemory(Dest, Length, Fill)
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
PPC_QUAL void __movsd(unsigned long *Destination, const unsigned long *Source, unsigned long Count)
PPC_QUAL void __movsw(unsigned short *Destination, const unsigned short *Source, unsigned long Count)
PPC_QUAL void __movsb(unsigned char *Destination, const unsigned char *Source, unsigned long Count)
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
#define NtCurrentProcess()
#define PAGE_EXECUTE_READWRITE
VOID(WINAPI * PVDD_MEMORY_HANDLER)(PVOID FaultAddress, ULONG RWMode)
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
base of all file and directory entries
struct _LIST_ENTRY * Flink
PVDD_MEMORY_HANDLER VddHandler
PMEMORY_READ_HANDLER FastReadHandler
PMEMORY_WRITE_HANDLER FastWriteHandler
static VOID WritePage(PMEM_HOOK Hook, ULONG Address, PVOID Buffer, ULONG Size)
PBYTE WINAPI Sim32pGetVDMPointer(IN ULONG Address, IN BOOLEAN ProtectedMode)
PVOID WINAPI VdmMapFlat(IN USHORT Segment, IN ULONG Offset, IN VDM_MODE Mode)
BOOL WINAPI VDDFreeMem(IN HANDLE hVdd, IN PVOID Address, IN ULONG Size)
VOID FASTCALL EmulatorCopyMemory(PFAST486_STATE State, ULONG DestAddress, ULONG SrcAddress, ULONG Size)
static PMEM_HOOK PageTable[TOTAL_PAGES]
VOID FASTCALL EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
PBYTE WINAPI MGetVdmPointer(IN ULONG Address, IN ULONG Size, IN BOOLEAN ProtectedMode)
BOOL WINAPI VDDIncludeMem(IN HANDLE hVdd, IN PVOID Address, IN ULONG Size)
BOOLEAN EmulatorGetA20(VOID)
BOOL WINAPI VDDAllocMem(IN HANDLE hVdd, IN PVOID Address, IN ULONG Size)
BOOL WINAPI VdmFlushCache(IN USHORT Segment, IN ULONG Offset, IN ULONG Size, IN VDM_MODE Mode)
VOID EmulatorSetA20(BOOLEAN Enabled)
BOOL WINAPI VDDInstallMemoryHook(IN HANDLE hVdd, IN PVOID pStart, IN DWORD dwCount, IN PVDD_MEMORY_HANDLER MemoryHandler)
static LIST_ENTRY HookList
BOOLEAN MemQueryMemoryZone(ULONG StartAddress, PULONG Length, PBOOLEAN Hooked)
BOOL WINAPI VdmUnmapFlat(IN USHORT Segment, IN ULONG Offset, IN PVOID Buffer, IN VDM_MODE Mode)
static VOID MemFastMoveMemory(OUT VOID UNALIGNED *Destination, IN const VOID UNALIGNED *Source, IN SIZE_T Length)
BOOL WINAPI VDDDeInstallMemoryHook(IN HANDLE hVdd, IN PVOID pStart, IN DWORD dwCount)
BOOLEAN MemInitialize(VOID)
struct _MEM_HOOK * PMEM_HOOK
VOID FASTCALL EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
VOID MemExceptionHandler(ULONG FaultAddress, BOOLEAN Writing)
static VOID ReadPage(PMEM_HOOK Hook, ULONG Address, PVOID Buffer, ULONG Size)
BOOL MemRemoveFastMemoryHook(PVOID Address, ULONG Size)
BOOL MemInstallFastMemoryHook(PVOID Address, ULONG Size, PMEMORY_READ_HANDLER ReadHandler, PMEMORY_WRITE_HANDLER WriteHandler)
BOOL WINAPI VDDExcludeMem(IN HANDLE hVdd, IN PVOID Address, IN ULONG Size)
struct _MEM_HOOK MEM_HOOK
BOOLEAN(FASTCALL * PMEMORY_WRITE_HANDLER)(ULONG Address, PVOID Buffer, ULONG Size)
VOID(FASTCALL * PMEMORY_READ_HANDLER)(ULONG Address, PVOID Buffer, ULONG Size)
static CONST DWORD MemorySize[]
VOID WINAPI MemoryHandler(IN PVOID FaultAddress, IN ULONG RWMode)
#define RtlMoveMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size