mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 21:37:58 +03:00
Place function table after the executable.
This commit is contained in:
parent
0e8dbe797b
commit
27a541b7a3
5 changed files with 12 additions and 9 deletions
|
@ -1679,7 +1679,8 @@ static uint32_t CreateDevice(uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4,
|
|||
auto device = g_userHeap.AllocPhysical<GuestDevice>();
|
||||
memset(device, 0, sizeof(*device));
|
||||
|
||||
uint32_t functionOffset = 0x443344; // D3D
|
||||
// Append render state functions to the end of guest function table.
|
||||
uint32_t functionOffset = PPC_CODE_BASE + PPC_CODE_SIZE;
|
||||
g_memory.InsertFunction(functionOffset, HostToGuestFunction<SetRenderStateUnimplemented>);
|
||||
|
||||
for (size_t i = 0; i < std::size(device->setRenderStateFunctions); i++)
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
Memory::Memory()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
base = (uint8_t*)VirtualAlloc((void*)0x100000000ull, PPC_MEMORY_SIZE + PPC_FUNC_TABLE_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
base = (uint8_t*)VirtualAlloc((void*)0x100000000ull, PPC_MEMORY_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
|
||||
if (base == nullptr)
|
||||
base = (uint8_t*)VirtualAlloc(nullptr, PPC_MEMORY_SIZE + PPC_FUNC_TABLE_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
base = (uint8_t*)VirtualAlloc(nullptr, PPC_MEMORY_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
|
||||
DWORD oldProtect;
|
||||
VirtualProtect(base, 4096, PAGE_NOACCESS, &oldProtect);
|
||||
#else
|
||||
base = (uint8_t*)mmap((void*)0x100000000ull, PPC_MEMORY_SIZE + PPC_FUNC_TABLE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
base = (uint8_t*)mmap((void*)0x100000000ull, PPC_MEMORY_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
|
||||
if (base == (uint8_t*)MAP_FAILED)
|
||||
base = (uint8_t*)mmap(NULL, PPC_MEMORY_SIZE + PPC_FUNC_TABLE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
base = (uint8_t*)mmap(NULL, PPC_MEMORY_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
|
||||
mprotect(base, 4096, PROT_NONE);
|
||||
#endif
|
||||
|
|
|
@ -34,12 +34,12 @@ struct Memory
|
|||
|
||||
PPCFunc* FindFunction(uint32_t guest) const noexcept
|
||||
{
|
||||
return *reinterpret_cast<PPCFunc**>(base + PPC_FUNC_TABLE_OFFSET + (uint64_t(guest) * 2));
|
||||
return PPC_LOOKUP_FUNC(base, guest);
|
||||
}
|
||||
|
||||
void InsertFunction(uint32_t guest, PPCFunc* host)
|
||||
{
|
||||
*reinterpret_cast<PPCFunc**>(base + PPC_FUNC_TABLE_OFFSET + (uint64_t(guest) * 2)) = host;
|
||||
PPC_LOOKUP_FUNC(base, guest) = host;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ else()
|
|||
add_compile_options(-ffp-model=strict)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(PowerRecomp PRIVATE CONFIG_FILE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/config/SWA.toml\")
|
||||
target_compile_definitions(PowerRecomp PRIVATE
|
||||
CONFIG_FILE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/config/SWA.toml\"
|
||||
HEADER_FILE_PATH=\"${SWA_TOOLS_ROOT}/PowerRecomp/PowerUtils/ppc_context.h\")
|
||||
|
||||
set(SWA_PPC_RECOMPILED_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ppc/ppc_config.h"
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit de2840970ffc3161a4cb8743b10ddd4da93bdc9f
|
||||
Subproject commit 7fb8af1bad9ecb22d5fa9c1b72555cdf7c22db02
|
Loading…
Add table
Add a link
Reference in a new issue