forked from winnerspiros/UnleashedRecomp_Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.h
More file actions
63 lines (50 loc) · 1.5 KB
/
Copy pathmemory.h
File metadata and controls
63 lines (50 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <cstdint>
#include <cassert>
#include <cstddef>
#ifndef _WIN32
#define MEM_COMMIT 0x00001000
#define MEM_RESERVE 0x00002000
#endif
struct Memory
{
uint8_t* base{};
Memory();
bool IsInMemoryRange(const void* host) const noexcept
{
return host >= base && host < (base + PPC_MEMORY_SIZE);
}
void* Translate(size_t offset) const noexcept
{
if (offset)
assert(offset < PPC_MEMORY_SIZE);
return base + offset;
}
uint32_t MapVirtual(const void* host) const noexcept
{
if (host)
assert(IsInMemoryRange(host));
return static_cast<uint32_t>(static_cast<const uint8_t*>(host) - base);
}
PPCFunc* FindFunction(uint32_t guest) const noexcept
{
return PPC_LOOKUP_FUNC(base, guest);
}
void InsertFunction(uint32_t guest, PPCFunc* host)
{
PPC_LOOKUP_FUNC(base, guest) = host;
}
};
extern "C" void* MmGetHostAddress(uint32_t ptr);
extern Memory g_memory;
void MmFreePhysicalMemory(uint32_t type, uint32_t guestAddress);
uint32_t MmGetPhysicalAddress(uint32_t address);
uint32_t MmAllocatePhysicalMemoryEx(uint32_t flags, uint32_t size, uint32_t protect, uint32_t minAddress, uint32_t maxAddress, uint32_t alignment);
uint32_t MmQueryAddressProtect(uint32_t guestAddress);
void MmQueryAllocationSize();
void NtQueryVirtualMemory();
void MmQueryStatistics();
void ExFreePool();
void NtAllocateVirtualMemory();
void NtFreeVirtualMemory();
void ExAllocatePoolTypeWithTag();