Fix db rawfile access

This commit is contained in:
momo5502 2016-11-05 00:34:09 +01:00
parent f2b965e48c
commit 2d5094e7b4
3 changed files with 26 additions and 4 deletions

View File

@ -19,7 +19,7 @@ namespace Components
FileSystem::FileReader::FileReader(std::string file) : Name(file), Handle(0)
{
this->Size = Game::FS_FOpenFileRead(this->Name.data(), &this->Handle, 0);
this->Size = Game::FS_FOpenFileReadCurrentThread(this->Name.data(), &this->Handle);
}
FileSystem::FileReader::~FileReader()
@ -172,14 +172,16 @@ namespace Components
{
__asm
{
pushad
push esi
call FileSystem::RegisterFolders
pop esi
popad
mov edx, ds:63D0CC0h
mov eax, 48264Dh
jmp eax
push 48264Dh
retn
}
}

View File

@ -81,6 +81,7 @@ namespace Game
FS_FOpenFileAppend_t FS_FOpenFileAppend = (FS_FOpenFileAppend_t)0x410BB0;
FS_FOpenFileAppend_t FS_FOpenFileWrite = (FS_FOpenFileAppend_t)0x4BA530;
FS_FOpenFileRead_t FS_FOpenFileRead = (FS_FOpenFileRead_t)0x46CBF0;
FS_FOpenFileRead_t FS_FOpenFileReadDatabase = (FS_FOpenFileRead_t)0x42ECA0;
FS_FOpenFileReadForThread_t FS_FOpenFileReadForThread = (FS_FOpenFileReadForThread_t)0x643270;
FS_FCloseFile_t FS_FCloseFile = (FS_FCloseFile_t)0x462000;
FS_WriteFile_t FS_WriteFile = (FS_WriteFile_t)0x426450;
@ -521,6 +522,23 @@ namespace Game
}
}
int FS_FOpenFileReadCurrentThread(const char* file, int* fh)
{
if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE7FC))
{
return FS_FOpenFileRead(file, fh);
}
else if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE814))
{
return FS_FOpenFileReadDatabase(file, fh);
}
else
{
*fh = NULL;
return -1;
}
}
void Load_IndexBuffer(void* data, IDirect3DIndexBuffer9** storeHere, int count)
{
if (Components::Dvar::Var("r_loadForRenderer").Get<bool>())

View File

@ -187,7 +187,7 @@ namespace Game
extern FS_FOpenFileAppend_t FS_FOpenFileAppend;
extern FS_FOpenFileAppend_t FS_FOpenFileWrite;
typedef int(__cdecl * FS_FOpenFileRead_t)(const char* file, int* fh, int uniqueFile);
typedef int(__cdecl * FS_FOpenFileRead_t)(const char* file, int* fh/*, int uniqueFile*/);
extern FS_FOpenFileRead_t FS_FOpenFileRead;
typedef int(__cdecl * FS_FOpenFileReadForThread_t)(const char *filename, int *file, int thread);
@ -648,6 +648,8 @@ namespace Game
void IN_KeyUp(kbutton_t* button);
void IN_KeyDown(kbutton_t* button);
int FS_FOpenFileReadCurrentThread(const char* file, int* fh);
void Load_IndexBuffer(void* data, IDirect3DIndexBuffer9** storeHere, int count);
void Load_VertexBuffer(void* data, IDirect3DVertexBuffer9** where, int len);
}