charoriginalBytes_V2[]="\x8B\x4D\x0C\x53\x8D\x9f\x2a\x03\x00\x00\x8D\x1C\x9E\x81\xF9\x76\xc4\x06\x00";//original assembly code of steamclient.dll that we want to hook (V2)
/* ==
movecx,dwordptrss:[ebp+C]//appId of bindings to be switched gets moved into ecx register
pushebx//part of original steam code
leaebx,dwordptrds:[edi+32A]//part of original steam code
leaebx,dwordptrds:[esi+ebx*4]//part of original steam code
cmpecx,6C476//part of original steam code - checks if bindings to be set are steamchord bindings
*/
charmask_V2[]="xxxxxxxxxxxxxxxxxxx";//mask for searching
&¤tBindings!=steamChordBindingsID)//we can grab them here, because bindings switch right after we have injected and the target changes focused window
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//if the current bindings aren't desktop, big picture, or steam-chord bindings
&¤tBindings!=bigPictureBindingsID//they have to be our game bindings
&¤tBindings!=steamChordBindingsID)//we can grab them here, because bindings switch right after we have injected and the target changes focused window
{
enforceBindingsID=currentBindings;
}
if(currentBindings==desktopBindingsID)//if steam wants to set desktop-bindings
{
__asm
{
moveax,enforceBindingsID//move appid of bindings to enforce into eax register
}
}
__asm
{
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
movecx,dwordptrss:[ebp+0xc]//part of original steam code - appId of bindings to be switched gets moved into eax register
movcurrentBindings,ecx//move into "currentBindings" variable
}
if(currentBindings!=desktopBindingsID//if the current bindings aren't desktop, big picture, or steam-chord bindings
&¤tBindings!=bigPictureBindingsID//they have to be our game bindings
&¤tBindings!=steamChordBindingsID)//we can grab them here, because bindings switch right after we have injected and the target changes focused window
{
enforceBindingsID=currentBindings;
}
if(currentBindings==desktopBindingsID)//if steam wants to set desktop-bindings
{
__asm
{
movecx,enforceBindingsID//move appid of bindings to enforce into eax register
}
}
__asm
{
pushebx//part of original steam code
leaebx,dwordptrds:[edi+0x32A]//part of original steam code
leaebx,dwordptrds:[esi+ebx*0x4]//part of original steam code
cmpecx,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