From f75d8cee183c33f11b264d07ccccececa0cda515 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 13 Nov 2016 15:04:34 +0100 Subject: [PATCH] [FileSystem] Revert back to the initial implementation, but without hunk --- src/Components/Modules/FileSystem.cpp | 10 ++++++++-- src/Components/Modules/FileSystem.hpp | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/FileSystem.cpp b/src/Components/Modules/FileSystem.cpp index 7657a771..e77279fb 100644 --- a/src/Components/Modules/FileSystem.cpp +++ b/src/Components/Modules/FileSystem.cpp @@ -172,7 +172,7 @@ namespace Components int size = reader.GetSize(); if (reader.Exists() && size >= 0) { - *buffer = FileSystem::MemAllocator.AllocateArray(size + 1); + *buffer = FileSystem::AllocateFile(size + 1); if (reader.Read(*buffer, size)) return size; FileSystem::FreeFile(*buffer); @@ -182,6 +182,11 @@ namespace Components return -1; } + char* FileSystem::AllocateFile(int size) + { + return FileSystem::MemAllocator.AllocateArray(size); + } + void FileSystem::FreeFile(void* buffer) { FileSystem::MemAllocator.Free(buffer); @@ -235,7 +240,8 @@ namespace Components FileSystem::MemAllocator.Clear(); // Thread safe file system interaction - Utils::Hook(Game::FS_ReadFile, FileSystem::ReadFile, HOOK_JUMP).Install()->Quick(); + Utils::Hook(0x4F4BFF, FileSystem::AllocateFile, HOOK_CALL).Install()->Quick(); + //Utils::Hook(Game::FS_ReadFile, FileSystem::ReadFile, HOOK_JUMP).Install()->Quick(); Utils::Hook(Game::FS_FreeFile, FileSystem::FreeFile, HOOK_JUMP).Install()->Quick(); // Filesystem config checks diff --git a/src/Components/Modules/FileSystem.hpp b/src/Components/Modules/FileSystem.hpp index 8999b5b5..ee3e6d5c 100644 --- a/src/Components/Modules/FileSystem.hpp +++ b/src/Components/Modules/FileSystem.hpp @@ -73,6 +73,7 @@ namespace Components static Utils::Memory::Allocator MemAllocator; static int ReadFile(const char* path, char** buffer); + static char* AllocateFile(int size); static void FreeFile(void* buffer); static void RegisterFolder(const char* folder);