mirror of https://github.com/Thracky/GlosSI
Enforce non desktop bindings:
done by mid function hooking a function in steamclient.dll the function appears to be setting the appId of the new controller bindings inject/hook right after the target launched switch focus -> binding gets changed to shortcut bindings -> hook function grabs appid hook function replaces desktop-config appid with the one grabbed everytime steam tries to active desktop-config glosc_gamelauncher unloads dll when the target closes; unloading dll patches steamclient.dll back to originalUWP_Overlay
parent
616486fd7d
commit
7947d6faac
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Quelldateien">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Headerdateien">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Ressourcendateien">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EnforceBindings.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="EnforceBindings.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
Copyright 2016 Peter Repukat - FlatspotSoftware
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#include "EnforceBindings.h"
|
||||
|
||||
//stuff for finding the function as well as the injected code
|
||||
//should probably be moved somewhere else
|
||||
DWORD address = 0x381FA91B;
|
||||
DWORD JMPBack;
|
||||
int32_t currentBindings;
|
||||
const int32_t desktopBindingsID = 413080; //desktop_config appid
|
||||
const int32_t bigPictureBindingsID = 413090; //desktop_config appid
|
||||
const int32_t steamChordBindingsID = 443510; //desktop_config appid
|
||||
int32_t enforceBindingsID = 413080; //0x80000009;
|
||||
char originalBytes[] = "\x8B\x45\x0c\x57\x8B\x7D\x08";
|
||||
|
||||
__declspec(naked) void enforceBindingsHookFn()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, dword ptr ss : [ebp + 0xc]
|
||||
mov currentBindings, eax
|
||||
}
|
||||
|
||||
if (currentBindings != desktopBindingsID
|
||||
&& currentBindings != bigPictureBindingsID
|
||||
&& currentBindings != steamChordBindingsID)
|
||||
{
|
||||
enforceBindingsID = currentBindings;
|
||||
}
|
||||
|
||||
if (currentBindings == desktopBindingsID)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, enforceBindingsID
|
||||
}
|
||||
}
|
||||
|
||||
__asm
|
||||
{
|
||||
push edi
|
||||
mov edi, dword ptr ss : [ebp + 0x8]
|
||||
jmp[JMPBack]
|
||||
}
|
||||
}
|
||||
//\\\
|
||||
|
||||
|
||||
void EnforceBindings::patchBytes()
|
||||
{
|
||||
address = FindPattern("steamclient.dll", originalBytes, "xxxxxxx");
|
||||
JMPBack = address + 0x7; //7 size of pattern/mask == patched instructions
|
||||
PlaceJMP((BYTE*)address, (DWORD)enforceBindingsHookFn, 7);
|
||||
}
|
||||
|
||||
void EnforceBindings::Unpatch()
|
||||
{
|
||||
RestoreBytes((BYTE*)address, (BYTE*)originalBytes, 7);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void EnforceBindings::PlaceJMP(BYTE * Address, DWORD jumpTo, DWORD lenght)
|
||||
{
|
||||
DWORD dwOldProtect, dwBkup, dwReloadAddr;
|
||||
VirtualProtect(Address, lenght, PAGE_EXECUTE_READWRITE, &dwOldProtect);
|
||||
dwReloadAddr = (jumpTo - (DWORD)Address) - 5; //5 == lenght of jump instruction (1byte + 4byte address)
|
||||
*Address = 0xE9; //jmp instrcution
|
||||
*((DWORD*)(Address + 0x1)) = dwReloadAddr;
|
||||
|
||||
for (DWORD x = 5; x < lenght; x++)
|
||||
*(Address + x) = 0x90; //nop the rest
|
||||
|
||||
VirtualProtect(Address, lenght, dwOldProtect, &dwBkup);
|
||||
}
|
||||
|
||||
void EnforceBindings::RestoreBytes(BYTE * Address, BYTE * original, DWORD lenght)
|
||||
{
|
||||
DWORD dwOldProtect, dwBkup, dwReloadAddr;
|
||||
VirtualProtect(Address, lenght, PAGE_EXECUTE_READWRITE, &dwOldProtect);
|
||||
|
||||
|
||||
for (DWORD x = 0; x < lenght; x++)
|
||||
{
|
||||
*(Address + x) = *(original + x);
|
||||
}
|
||||
|
||||
VirtualProtect(Address, lenght, dwOldProtect, &dwBkup);
|
||||
}
|
||||
|
||||
MODULEINFO EnforceBindings::GetModInfo(char * szModule)
|
||||
{
|
||||
MODULEINFO ret = { NULL };
|
||||
HMODULE mod = GetModuleHandleA(szModule);
|
||||
|
||||
if (mod != 0)
|
||||
GetModuleInformation(GetCurrentProcess(), mod, &ret, sizeof(MODULEINFO));
|
||||
return ret;
|
||||
}
|
||||
|
||||
DWORD EnforceBindings::FindPattern(char * module, char * pattern, char * mask)
|
||||
{
|
||||
MODULEINFO mInfo = GetModInfo(module);
|
||||
DWORD baseAddr = (DWORD)mInfo.lpBaseOfDll;
|
||||
DWORD size = mInfo.SizeOfImage;
|
||||
|
||||
DWORD patLenght = strlen(mask);
|
||||
|
||||
for (DWORD i = 0; i < size - patLenght; i++) //bad for loop btw...
|
||||
{
|
||||
bool found = true;
|
||||
for (DWORD j = 0; j < patLenght; j++)
|
||||
found &= mask[j] == '?' || pattern[j] == *(char*)(baseAddr + j + i);
|
||||
|
||||
if (found)
|
||||
return baseAddr + i;
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright 2016 Peter Repukat - FlatspotSoftware
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <psapi.h>
|
||||
|
||||
|
||||
class EnforceBindings
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
static void patchBytes();
|
||||
static void Unpatch();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static void PlaceJMP(BYTE * Address, DWORD jumpTo, DWORD lenght);
|
||||
static void RestoreBytes(BYTE *Address, BYTE *original, DWORD lenght);
|
||||
static MODULEINFO GetModInfo(char *szModule);
|
||||
static DWORD FindPattern(char *module, char *pattern, char *mask);
|
||||
};
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2016 Peter Repukat - FlatspotSoftware
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#include <Windows.h>
|
||||
#include "EnforceBindings.h"
|
||||
|
||||
HANDLE hThread;
|
||||
|
||||
void WINAPI Run()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
int WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved)
|
||||
{
|
||||
if (reason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
EnforceBindings::patchBytes();
|
||||
//hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Run, 0, 0, 0);
|
||||
} else if (reason == DLL_PROCESS_DETACH) {
|
||||
EnforceBindings::Unpatch();
|
||||
//TerminateThread(hThread, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue