This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for re-calling internal value functions
- Loading branch information
Showing
5 changed files
with
80 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#include <windows.h> | ||
|
||
// Generic function definitions | ||
typedef void (__fastcall GenericClassFunc)(PVOID ecx, PVOID edx); | ||
typedef void (GenericFunc)(); | ||
|
||
struct FuncInfo | ||
{ | ||
LPCSTR moduleName; | ||
DWORD fileOffset; | ||
}; | ||
|
||
struct ClassFuncInfo | ||
{ | ||
LPCSTR moduleName; | ||
DWORD fileOffset; | ||
DWORD thisPtr; | ||
}; | ||
|
||
// This function is used to effectively re-set some internal values in the Freelancer binaries | ||
// We use this because otherwise some patches may have no effect due to memory being read before FLPatch is loaded | ||
// Thanks to this function, the patched values will actually be used | ||
void SetInternalValues(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "internal.h" | ||
|
||
LPCSTR flModule = "freelancer.exe"; | ||
LPCSTR commonModule = "common.dll"; | ||
|
||
void SetInternalValues() | ||
{ | ||
int i; | ||
|
||
const FuncInfo funcs[] = | ||
{ | ||
{ flModule, 0x10100 }, // Poly flipping distance #1 | ||
{ flModule, 0x10120 }, // Poly flipping distance #2 | ||
{ flModule, 0x11B2D0 }, // Poly flipping distance #3 | ||
{ commonModule, 0x62E40 }, // Maximum docking initiation distance | ||
}; | ||
|
||
const ClassFuncInfo classFuncs[] = | ||
{ | ||
{ flModule, 0x1628E0, 0x67ADC4 } // Filter out incompatible builds on server by default | ||
}; | ||
|
||
for (i = 0; i < sizeof(funcs) / sizeof(FuncInfo); ++i) | ||
{ | ||
DWORD module = (DWORD) GetModuleHandleA(funcs[i].moduleName); | ||
|
||
if (!module) | ||
continue; | ||
|
||
GenericFunc* func = (GenericFunc*) (module + funcs[i].fileOffset); | ||
(func)(); | ||
} | ||
|
||
for (i = 0; i < sizeof(classFuncs) / sizeof(ClassFuncInfo); ++i) | ||
{ | ||
DWORD module = (DWORD) GetModuleHandleA(classFuncs[i].moduleName); | ||
|
||
if (!module) | ||
continue; | ||
|
||
GenericClassFunc* classFunc = (GenericClassFunc*) (module + classFuncs[i].fileOffset); | ||
|
||
(classFunc)((PVOID) classFuncs[i].thisPtr, NULL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters