mirror of
https://github.com/Thracky/GlosSI.git
synced 2024-11-15 06:12:54 +00:00
fix function signature / cleanup
This commit is contained in:
parent
56edf5bad4
commit
4d2c8a544a
@ -17,58 +17,60 @@ limitations under the License.
|
|||||||
|
|
||||||
//stuff for finding the function as well as the injected code
|
//stuff for finding the function as well as the injected code
|
||||||
//should probably be moved somewhere else
|
//should probably be moved somewhere else
|
||||||
DWORD address = 0x381FA91B;
|
DWORD address;
|
||||||
DWORD JMPBack;
|
DWORD JMPBack;
|
||||||
int32_t currentBindings;
|
int32_t currentBindings;
|
||||||
const int32_t desktopBindingsID = 413080; //desktop_config appid
|
const int32_t desktopBindingsID = 413080; //desktop_config appid
|
||||||
const int32_t bigPictureBindingsID = 413090; //desktop_config appid
|
const int32_t bigPictureBindingsID = 413090; //big_picture_config appid
|
||||||
const int32_t steamChordBindingsID = 443510; //desktop_config appid
|
const int32_t steamChordBindingsID = 443510; //steam_chord_config appid
|
||||||
int32_t enforceBindingsID = 413080; //0x80000009;
|
int32_t enforceBindingsID = 413080;
|
||||||
char originalBytes[] = "\x8B\x45\x0c\x57\x8B\x7D\x08";
|
char originalBytes[] = "\x8B\x45\x0c\x57\x8B\x7D\x08\x3D\x76\xC4\x06\x00"; //original assembly code of steamclient.dll that we want to hook
|
||||||
|
char mask[] = "xxxxxxxx????"; //mask for searching
|
||||||
|
|
||||||
__declspec(naked) void enforceBindingsHookFn()
|
__declspec(naked) void enforceBindingsHookFn()
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov eax, dword ptr ss : [ebp + 0xc]
|
mov eax, dword ptr ss : [ebp + 0xc] //part of original steam code - appId of bindings to be switched gets moved into eax register
|
||||||
mov currentBindings, eax
|
mov currentBindings, eax //move into "currentBindings" variable
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentBindings != desktopBindingsID
|
if (currentBindings != desktopBindingsID //if the current bindings aren't desktop, big picture, or steam-chord bindings
|
||||||
&& currentBindings != bigPictureBindingsID
|
&& currentBindings != bigPictureBindingsID //they have to be our game bindings
|
||||||
&& currentBindings != steamChordBindingsID)
|
&& currentBindings != steamChordBindingsID) //we can grab theme here, because bindings switch, after we have injected and the target changes focuses window
|
||||||
{
|
{
|
||||||
enforceBindingsID = currentBindings;
|
enforceBindingsID = currentBindings;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentBindings == desktopBindingsID)
|
if (currentBindings == desktopBindingsID) //if steam wants to set desktop-bindings
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov eax, enforceBindingsID
|
mov eax, enforceBindingsID //move appid of bindings to enforce into eax register
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push edi
|
push edi //part of original steam code
|
||||||
mov edi, dword ptr ss : [ebp + 0x8]
|
mov edi, dword ptr ss : [ebp + 0x8] //part of original steam code
|
||||||
jmp[JMPBack]
|
cmp eax, 0x6C476 //part of original steam code - checks if bindings to be set are steamchord bindings
|
||||||
}
|
jmp[JMPBack] //jump back and continiue with original steam function
|
||||||
|
} //note: zero flag doesn't get altered by jmp instruction, previous compare still works fine
|
||||||
}
|
}
|
||||||
//\\\
|
//\\\
|
||||||
|
|
||||||
|
|
||||||
void EnforceBindings::patchBytes()
|
void EnforceBindings::patchBytes()
|
||||||
{
|
{
|
||||||
address = FindPattern("steamclient.dll", originalBytes, "xxxxxxx");
|
address = FindPattern("steamclient.dll", originalBytes, mask);
|
||||||
JMPBack = address + 0x7; //7 size of pattern/mask == patched instructions
|
JMPBack = address + 12; //12 size of pattern/mask == patched instructions
|
||||||
PlaceJMP((BYTE*)address, (DWORD)enforceBindingsHookFn, 7);
|
PlaceJMP((BYTE*)address, (DWORD)enforceBindingsHookFn, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnforceBindings::Unpatch()
|
void EnforceBindings::Unpatch()
|
||||||
{
|
{
|
||||||
RestoreBytes((BYTE*)address, (BYTE*)originalBytes, 7);
|
RestoreBytes((BYTE*)address, (BYTE*)originalBytes, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,8 +79,10 @@ void EnforceBindings::Unpatch()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//places a jmp instruction to a __declspec(naked) function on a given adress
|
||||||
void EnforceBindings::PlaceJMP(BYTE * Address, DWORD jumpTo, DWORD lenght)
|
//nops the rest of bytes to don't break any instructions
|
||||||
|
//part of patched code may has to be executed in the hook function
|
||||||
|
void EnforceBindings::PlaceJMP(BYTE * Address, DWORD jumpTo, DWORD lenght)
|
||||||
{
|
{
|
||||||
DWORD dwOldProtect, dwBkup, dwReloadAddr;
|
DWORD dwOldProtect, dwBkup, dwReloadAddr;
|
||||||
VirtualProtect(Address, lenght, PAGE_EXECUTE_READWRITE, &dwOldProtect);
|
VirtualProtect(Address, lenght, PAGE_EXECUTE_READWRITE, &dwOldProtect);
|
||||||
@ -116,6 +120,7 @@ MODULEINFO EnforceBindings::GetModInfo(char * szModule)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//returns memory address of given pattern ind given module
|
||||||
DWORD EnforceBindings::FindPattern(char * module, char * pattern, char * mask)
|
DWORD EnforceBindings::FindPattern(char * module, char * pattern, char * mask)
|
||||||
{
|
{
|
||||||
MODULEINFO mInfo = GetModInfo(module);
|
MODULEINFO mInfo = GetModInfo(module);
|
||||||
|
Loading…
Reference in New Issue
Block a user