-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUnserializedIO.h
37 lines (30 loc) · 1017 Bytes
/
UnserializedIO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include "SafeWrite.h"
#include <xutil.h>
namespace UnserializedIO
{
namespace ToReplace
{
constexpr static UInt32 fseekAddr = 0x85207B;
constexpr static UInt32 freadAddr[] = { 0x851EE3, 0x85210F, 0x85212F };
constexpr static UInt32 fwriteAddr[] = { 0x851F2D, 0x8521E1 };
}
namespace FunctionsAddr
{
constexpr static UInt32 fseek = 0xC63400;
constexpr static UInt32 fread = 0xC62A6D;
constexpr static UInt32 fwrite = 0xC62686;
}
// Undoes Obsidian's serialization of the I/O functions by replacing them with the original ones
// Technically we patched this in GECK.exe itself - this serves as a documentation
void InitHooks()
{
// Remove the initializator for the serialized I/O functions
XUtil::PatchMemoryNop(0x8532CA, 5);
WriteRelCall(ToReplace::fseekAddr, FunctionsAddr::fseek);
for (UInt32 addr : ToReplace::freadAddr)
WriteRelCall(addr, FunctionsAddr::fread);
for (UInt32 addr : ToReplace::fwriteAddr)
WriteRelCall(addr, FunctionsAddr::fwrite);
}
}