[FileSystem] Revert back to the initial implementation, but without hunk

This commit is contained in:
momo5502 2016-11-13 15:04:34 +01:00
parent d52d316cd2
commit f75d8cee18
2 changed files with 9 additions and 2 deletions

View File

@ -172,7 +172,7 @@ namespace Components
int size = reader.GetSize();
if (reader.Exists() && size >= 0)
{
*buffer = FileSystem::MemAllocator.AllocateArray<char>(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<char>(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

View File

@ -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);