Skip to content

Commit

Permalink
Add support for v1.0.0.61a
Browse files Browse the repository at this point in the history
  • Loading branch information
usernameak committed Feb 16, 2023
1 parent 9333593 commit 9e97af8
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions osi_extender/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,32 @@ class CFakeOsiris : public COsiris {
}
};

void initialize(DWORD major, DWORD minor, DWORD patch, DWORD build) {

if (major == 1 && minor == 0 && patch == 0 && build == 62) {
// 1.0.0.62
DWORD oldProtect;
VirtualProtect((void *)(uintptr_t)0x517000, 0x1000, PAGE_EXECUTE_READWRITE, &oldProtect);
void patchFakeLoad(uintptr_t insn_addr) {
DWORD oldProtect;
VirtualProtect((void *)(uintptr_t)(insn_addr / 0x1000 * 0x1000), 0x1000, PAGE_EXECUTE_READWRITE, &oldProtect);

// some extremely dangerous shit
uintptr_t fakeLoad;
__asm {
// some extremely dangerous shit
uintptr_t fakeLoad;
__asm {
mov eax, dword ptr CFakeOsiris::FakeLoad
mov fakeLoad, eax
}
;
const uintptr_t INSN_ADDR = 0x5170E1;
*((uint8_t *)(INSN_ADDR)) = 0x90;
*((uint8_t *)(INSN_ADDR + 1)) = 0xE8;
*((uintptr_t *)(INSN_ADDR + 2)) = fakeLoad - INSN_ADDR - 0x6;
}
*((uint8_t *)(insn_addr)) = 0x90;
*((uint8_t *)(insn_addr + 1)) = 0xE8;
*((uintptr_t *)(insn_addr + 2)) = fakeLoad - insn_addr - 0x6;
}

void initialize(DWORD major, DWORD minor, DWORD patch, DWORD build) {
if (major == 1 && minor == 0 && patch == 0 && build == 62) {
// 1.0.0.62
patchFakeLoad(0x5170E1);
} else if (major == 1 && minor == 0 && patch == 0 && build == 61) {
// 1.0.0.61
patchFakeLoad(0x512E90);
} else if (major == 1 && minor == 2 && patch == 0 && build == 0) {
// ConfigTool, ignore it
} else {
MessageBoxW(NULL, L"Borderless Mod: Unsupported Divine Divinity version", L"div_slashopt", MB_OK);
MessageBoxW(NULL, L"Osiris Extender: Unsupported Divine Divinity version", L"Osiris Extender", MB_OK);
}
}

Expand Down

0 comments on commit 9e97af8

Please sign in to comment.