Increase pmem size
This commit is contained in:
parent
756a4cc0ce
commit
145f2d81d8
@ -8,6 +8,7 @@
|
||||
#include "component/console.hpp"
|
||||
#include "component/scripting.hpp"
|
||||
#include "component/fastfiles.hpp"
|
||||
#include "component/memory.hpp"
|
||||
|
||||
#include "script_loading.hpp"
|
||||
|
||||
@ -33,7 +34,7 @@ namespace gsc
|
||||
{
|
||||
char* buf = nullptr;
|
||||
char* pos = nullptr;
|
||||
unsigned int size = 0x1000000;
|
||||
unsigned int size = memory::custom_script_mem_size;
|
||||
} script_memory;
|
||||
|
||||
char* allocate_buffer(size_t size)
|
||||
@ -350,27 +351,6 @@ namespace gsc
|
||||
utils::hook::invoke<void>(0x1405BFBF0);
|
||||
}
|
||||
|
||||
void pmem_init_stub()
|
||||
{
|
||||
utils::hook::invoke<void>(0x14061EC80);
|
||||
|
||||
const auto type_0 = &game::g_scriptmem[0];
|
||||
const auto type_1 = &game::g_scriptmem[1];
|
||||
|
||||
const auto size_0 = 0x200000; // default size
|
||||
const auto size_1 = 0x200000 + script_memory.size;
|
||||
|
||||
const auto block = reinterpret_cast<char*>(VirtualAlloc(NULL, size_0 + size_1, MEM_RESERVE, PAGE_READWRITE));
|
||||
|
||||
type_0->buf = block;
|
||||
type_0->size = size_0;
|
||||
|
||||
type_1->buf = block + size_0;
|
||||
type_1->size = size_1;
|
||||
|
||||
utils::hook::set<uint32_t>(0x14061EC72, size_0 + size_1);
|
||||
}
|
||||
|
||||
void add_function_name(const std::string& name, const std::uint16_t id)
|
||||
{
|
||||
const std::string_view name_ = utils::memory::get_allocator()->duplicate_string(name);
|
||||
@ -427,9 +407,6 @@ namespace gsc
|
||||
utils::hook::call(0x1404C8F71, g_load_structs_stub);
|
||||
utils::hook::call(0x1404C8F80, scr_load_level_stub);
|
||||
|
||||
// increase script memory
|
||||
utils::hook::call(0x1405A4798, pmem_init_stub);
|
||||
|
||||
add_function_name("isusinghdr", 0x242);
|
||||
add_function_name("tablegetrowcount", 0x2A6);
|
||||
|
||||
|
104
src/client/component/memory.cpp
Normal file
104
src/client/component/memory.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "memory.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/flags.hpp>
|
||||
|
||||
namespace memory
|
||||
{
|
||||
namespace
|
||||
{
|
||||
constexpr auto mem_low_size = 0x80000000ull * 2; // default: 0x80000000
|
||||
constexpr auto mem_high_size = 0x80000000ull * 2; // default: 0x80000000
|
||||
|
||||
constexpr auto script_mem_low_size = 0x200000ull; // default: 0x200000
|
||||
constexpr auto script_mem_high_size = 0x200000ull + custom_script_mem_size; // default: 0x200000
|
||||
|
||||
constexpr auto phys_mem_low_size = 0x400000000ull * 2; // default: 0x400000000
|
||||
constexpr auto phys_mem_high_size = 0x400000000ull * 2; // default: 0x400000000
|
||||
|
||||
constexpr auto pmem_alloc_size =
|
||||
mem_low_size +
|
||||
mem_high_size +
|
||||
script_mem_low_size +
|
||||
script_mem_high_size +
|
||||
phys_mem_low_size +
|
||||
phys_mem_high_size;
|
||||
|
||||
constexpr auto mem_low_buf = 0;
|
||||
constexpr auto mem_high_buf = mem_low_buf + mem_low_size;
|
||||
|
||||
constexpr auto script_mem_low_buf = mem_high_buf + mem_high_size;
|
||||
constexpr auto script_mem_high_buf = script_mem_low_buf + script_mem_low_size;
|
||||
|
||||
constexpr auto phys_mem_low_buf = script_mem_high_buf + script_mem_high_size;
|
||||
constexpr auto phys_mem_high_buf = phys_mem_low_buf + phys_mem_low_size;
|
||||
|
||||
constexpr auto stream_mem_size = 0x2000000ull;
|
||||
|
||||
void pmem_init()
|
||||
{
|
||||
const auto size = pmem_alloc_size;
|
||||
const auto allocated_buffer = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_READWRITE);
|
||||
auto buffer = reinterpret_cast<unsigned char*>(allocated_buffer);
|
||||
*game::pmem_size = size;
|
||||
*game::pmem_buffer = buffer;
|
||||
|
||||
std::memset(game::g_mem, 0, sizeof(*game::g_mem));
|
||||
|
||||
game::g_mem->prim[game::PHYS_ALLOC_LOW].buf = buffer + mem_low_buf;
|
||||
game::g_mem->prim[game::PHYS_ALLOC_LOW].pos = mem_low_size;
|
||||
game::g_mem->prim[game::PHYS_ALLOC_HIGH].buf = buffer + mem_high_buf;
|
||||
game::g_mem->prim[game::PHYS_ALLOC_HIGH].pos = mem_high_size;
|
||||
|
||||
game::g_mem->prim[game::PHYS_ALLOC_LOW].unk1 = 0;
|
||||
game::g_mem->prim[game::PHYS_ALLOC_HIGH].unk1 = 0;
|
||||
|
||||
std::memset(game::g_scriptmem, 0, sizeof(*game::g_scriptmem));
|
||||
|
||||
game::g_scriptmem->prim[game::PHYS_ALLOC_LOW].buf = buffer + script_mem_low_buf;
|
||||
game::g_scriptmem->prim[game::PHYS_ALLOC_LOW].pos = script_mem_low_size;
|
||||
game::g_scriptmem->prim[game::PHYS_ALLOC_HIGH].buf = buffer + script_mem_high_buf;
|
||||
game::g_scriptmem->prim[game::PHYS_ALLOC_HIGH].pos = script_mem_high_size;
|
||||
|
||||
game::g_scriptmem->prim[game::PHYS_ALLOC_LOW].unk1 = 0;
|
||||
game::g_scriptmem->prim[game::PHYS_ALLOC_HIGH].unk1 = 0;
|
||||
|
||||
std::memset(game::g_physmem, 0, sizeof(*game::g_physmem));
|
||||
|
||||
game::g_physmem->prim[game::PHYS_ALLOC_LOW].buf = buffer + phys_mem_low_buf;
|
||||
game::g_physmem->prim[game::PHYS_ALLOC_LOW].pos = phys_mem_low_size;
|
||||
game::g_physmem->prim[game::PHYS_ALLOC_HIGH].buf = buffer + phys_mem_high_buf;
|
||||
game::g_physmem->prim[game::PHYS_ALLOC_HIGH].pos = phys_mem_high_size;
|
||||
|
||||
game::g_physmem->prim[game::PHYS_ALLOC_LOW].unk1 = 2;
|
||||
game::g_physmem->prim[game::PHYS_ALLOC_HIGH].unk1 = 2;
|
||||
|
||||
*game::stream_size = stream_mem_size;
|
||||
*game::stream_buffer = reinterpret_cast<unsigned char*>(VirtualAlloc(NULL, *game::stream_size, MEM_COMMIT, PAGE_READWRITE));
|
||||
}
|
||||
|
||||
void pmem_init_stub()
|
||||
{
|
||||
pmem_init();
|
||||
const auto script_mem_size = script_mem_low_size + script_mem_high_size;
|
||||
utils::hook::set<uint32_t>(0x14061EC72, static_cast<uint32_t>(script_mem_size));
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void post_unpack() override
|
||||
{
|
||||
// patch PMem_Init, so we can use whatever memory size we want
|
||||
utils::hook::call(0x1405A4798, pmem_init_stub);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(memory::component)
|
6
src/client/component/memory.hpp
Normal file
6
src/client/component/memory.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace memory
|
||||
{
|
||||
constexpr auto custom_script_mem_size = 0x1000000ull;
|
||||
}
|
@ -2844,6 +2844,13 @@ namespace game
|
||||
int vertAlign;
|
||||
};
|
||||
|
||||
enum PMem_Direction
|
||||
{
|
||||
PHYS_ALLOC_LOW = 0x0,
|
||||
PHYS_ALLOC_HIGH = 0x1,
|
||||
PHYS_ALLOC_COUNT = 0x2,
|
||||
};
|
||||
|
||||
enum PMem_Source
|
||||
{
|
||||
PMEM_SOURCE_EXTERNAL = 0x0,
|
||||
@ -2852,19 +2859,38 @@ namespace game
|
||||
PMEM_SOURCE_DEFAULT_HIGH = 0x3,
|
||||
PMEM_SOURCE_MOVIE = 0x4,
|
||||
PMEM_SOURCE_SCRIPT = 0x5,
|
||||
PMEM_SOURCE_UNK5 = 0x5,
|
||||
PMEM_SOURCE_UNK6 = 0x6,
|
||||
PMEM_SOURCE_UNK7 = 0x7,
|
||||
PMEM_SOURCE_UNK8 = 0x8,
|
||||
PMEM_SOURCE_CUSTOMIZATION = 0x9,
|
||||
};
|
||||
|
||||
struct physical_memory
|
||||
struct PhysicalMemoryAllocation
|
||||
{
|
||||
char __pad0[0x10];
|
||||
char* buf;
|
||||
char __pad1[0x8];
|
||||
int unk1;
|
||||
size_t size;
|
||||
char __pad2[0x500];
|
||||
};
|
||||
const char* name;
|
||||
char __pad0[16];
|
||||
unsigned __int64 pos;
|
||||
char __pad1[8];
|
||||
}; static_assert(sizeof(PhysicalMemoryAllocation) == 40);
|
||||
|
||||
static_assert(sizeof(physical_memory) == 0x530);
|
||||
struct PhysicalMemoryPrim
|
||||
{
|
||||
const char* name;
|
||||
unsigned int allocListCount;
|
||||
char __pad0[4];
|
||||
unsigned char* buf;
|
||||
char __pad1[8];
|
||||
int unk1;
|
||||
char __pad2[4];
|
||||
unsigned __int64 pos;
|
||||
PhysicalMemoryAllocation allocList[32];
|
||||
}; static_assert(sizeof(PhysicalMemoryPrim) == 1328);
|
||||
|
||||
struct PhysicalMemory
|
||||
{
|
||||
PhysicalMemoryPrim prim[2];
|
||||
}; static_assert(sizeof(PhysicalMemory) == 0xA60);
|
||||
|
||||
union GamerProfileDataUnion
|
||||
{
|
||||
|
@ -271,7 +271,15 @@ namespace game
|
||||
WEAK symbol<jmp_buf> g_script_error{0x14BA9CD40};
|
||||
WEAK symbol<scr_classStruct_t> g_classMap{0x140BF95C0};
|
||||
|
||||
WEAK symbol<physical_memory> g_scriptmem{0x14CC9FEC0};
|
||||
WEAK game::symbol<unsigned __int64> pmem_size{0x14CC9F458};
|
||||
WEAK game::symbol<unsigned char*> pmem_buffer{0x14CC9F450};
|
||||
|
||||
WEAK game::symbol<PhysicalMemory> g_mem{0x14CC9F460};
|
||||
WEAK game::symbol<PhysicalMemory> g_scriptmem{0x14CC9FEC0};
|
||||
WEAK game::symbol<PhysicalMemory> g_physmem{0x14CCA0920};
|
||||
|
||||
WEAK game::symbol<unsigned __int64> stream_size{0x141865C90};
|
||||
WEAK game::symbol<unsigned char*> stream_buffer{0x141865C88};
|
||||
|
||||
WEAK symbol<scrVarGlob_t> scr_VarGlob{0x14B617C00};
|
||||
WEAK symbol<scrVmPub_t> scr_VmPub{0x14BA9EE40};
|
||||
|
Loading…
Reference in New Issue
Block a user