charoriginalBytes[]="\x8B\x45\x0c\x57\x8B\x7D\x08\x3D\x76\xC4\x06\x00";//original assembly code of steamclient.dll that we want to hook
charmask[]="xxxxxxxx????";//mask for searching
__declspec(naked)voidenforceBindingsHookFn()
{
__asm
{
moveax,dwordptrss:[ebp+0xc]
movcurrentBindings,eax
moveax,dwordptrss:[ebp+0xc]//part of original steam code - appId of bindings to be switched gets moved into eax register
movcurrentBindings,eax//move into "currentBindings" variable
}
if(currentBindings!=desktopBindingsID
&¤tBindings!=bigPictureBindingsID
&¤tBindings!=steamChordBindingsID)
if(currentBindings!=desktopBindingsID//ifthe current bindings aren't desktop, big picture, or steam-chord bindings
&¤tBindings!=bigPictureBindingsID//theyhave to be our game bindings
&¤tBindings!=steamChordBindingsID)//we can grab theme here, because bindings switch, after we have injected and the target changes focuses window
{
enforceBindingsID=currentBindings;
}
if(currentBindings==desktopBindingsID)
if(currentBindings==desktopBindingsID)//if steam wants to set desktop-bindings
{
__asm
{
moveax,enforceBindingsID
moveax,enforceBindingsID//move appid of bindings to enforce into eax register
}
}
__asm
{
pushedi
movedi,dwordptrss:[ebp+0x8]
jmp[JMPBack]
}
pushedi//part of original steam code
movedi,dwordptrss:[ebp+0x8]//part of original steam code
cmpeax,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