Skip to content

Commit be56727

Browse files
committed
Fix GetKeyState()
In GetKeyState() we masked 0x81 instead of 0x8001; this caused key combinations like CTRL+1 to stop working Also: Create individual scripts for 32-bit and 64-bit build
1 parent 20146ad commit be56727

File tree

7 files changed

+34
-22
lines changed

7 files changed

+34
-22
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/detours
1+
/detours32
2+
/detours64
23
*.exe
34
*.obj
45
*.pdb

build.bat

Lines changed: 0 additions & 7 deletions
This file was deleted.

build32.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rc /fofix_scrollbug.res fix_scrollbug.rc
2+
cl /nologo /MT /W4 /WX /Od /Idetours32 /c fix_scrollbug.cpp
3+
cl /nologo /MT /W4 /WX /Idetours32 /LD /Od /Fefix_scrollbug32.dll fix_scrollbug.obj fix_scrollbug.res /link /release /incremental:no /profile /nodefaultlib:oldnames.lib /subsystem:console /export:DetourFinishHelperProcess,@1,NONAME detours32\detours.lib kernel32.lib user32.lib
4+
5+
rc /fodll_inject.res dll_inject.rc
6+
cl /nologo /MT /W4 /WX /Od /Idetours32 /c dll_inject.cpp
7+
cl /nologo /MT /W4 /WX /Od /Idetours32 /Fedll_inject32.exe dll_inject.obj dll_inject.res /link /release /incremental:no /profile /nodefaultlib:oldnames.lib /subsystem:console detours32\detours.lib kernel32.lib

build64.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rc /fofix_scrollbug.res fix_scrollbug.rc
2+
cl /nologo /MT /W4 /WX /Od /Idetours32 /c fix_scrollbug.cpp
3+
cl /nologo /MT /W4 /WX /Idetours32 /LD /Od /Fefix_scrollbug64.dll fix_scrollbug.obj fix_scrollbug.res /link /release /incremental:no /profile /nodefaultlib:oldnames.lib /subsystem:console /export:DetourFinishHelperProcess,@1,NONAME detours64\detours.lib kernel32.lib user32.lib
4+
5+
rc /fodll_inject.res dll_inject.rc
6+
cl /nologo /MT /W4 /WX /Od /Idetours32 /c dll_inject.cpp
7+
cl /nologo /MT /W4 /WX /Od /Idetours32 /Fedll_inject64.exe dll_inject.obj dll_inject.res /link /release /incremental:no /profile /nodefaultlib:oldnames.lib /subsystem:console detours64\detours.lib kernel32.lib

dll_inject.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1 VERSIONINFO
2-
FILEVERSION 1, 3, 3, 7
3-
PRODUCTVERSION 1, 3, 3, 7
2+
FILEVERSION 1, 4, 0, 0
3+
PRODUCTVERSION 1, 4, 0, 0
44
FILEFLAGSMASK 0
55
FILEOS 0x40000
66
FILETYPE 1
@@ -12,12 +12,12 @@ FILETYPE 1
1212
{
1313
VALUE "CompanyName", "SFT Technologies"
1414
VALUE "FileDescription", "Detours fix DLL injector"
15-
VALUE "FileVersion", "1.3.3.7"
15+
VALUE "FileVersion", "1.4.0.0"
1616
VALUE "InternalName", "fucking_detours_injector"
1717
VALUE "LegalCopyright", "2019 SFT Tech, https://openage.sft.mx"
1818
VALUE "OriginalFilename", "dll_inject.exe"
1919
VALUE "ProductName", "Detours fix DLL injector"
20-
VALUE "ProductVersion", "1.3.3.7"
20+
VALUE "ProductVersion", "1.4.0.0"
2121
VALUE "author", "eblig"
2222
VALUE "bestAoEclone", "openage"
2323
VALUE "openageURL", "https://openage.sft.mx"

fix_scrollbug.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define WIN32
33
#define NT
44

5-
#define DBG_TRACE 0
5+
#define DEBUG 0
66

77
#include <windows.h>
88
#include <stdio.h>
@@ -103,15 +103,15 @@ static SHORT (WINAPI * Real_GetKeyState)(int nVirtKey) = GetKeyState;
103103
SHORT WINAPI Mine_GetKeyState(int nVirtKey)
104104
{
105105
SHORT ret;
106-
ret = Real_GetKeyState(nVirtKey) & 0xff;
106+
ret = Real_GetKeyState(nVirtKey);
107107
#ifdef DEBUG
108-
printf("getkeystate(%d) - detoured - result 0x%02x\r\n", nVirtKey, ret & 0xff);
108+
printf("getkeystate(%d) - detoured - result 0x%04x\r\n", nVirtKey, ret);
109109
#endif
110-
if (ret & ~0x81) {
110+
if (ret & ~0x8001) {
111111
#ifdef DEBUG
112-
printf("bad flags are set in GetKeyState(%d): 0x%02x, fixing them for you to save you!!!111111111111111111111\r\n", nVirtKey, ret & 0xff);
112+
printf("bad flags are set in GetKeyState(%d): 0x%04x, fixing them for you to save you!!!111111111111111111111\r\n", nVirtKey, ret);
113113
#endif
114-
ret &= 0x81;
114+
ret &= 0x8001;
115115
}
116116
return ret;
117117
}
@@ -184,6 +184,8 @@ LONG AttachDetours(VOID)
184184
DetourTransactionBegin();
185185
DetourUpdateThread(GetCurrentThread());
186186

187+
printf("attaching detours [%lld]\n", (long long int) GetCurrentThread());
188+
187189
ATTACH(CreateProcessW);
188190

189191
ATTACH(GetKeyboardState);
@@ -199,6 +201,8 @@ LONG DetachDetours(VOID)
199201
DetourTransactionBegin();
200202
DetourUpdateThread(GetCurrentThread());
201203

204+
printf("detaching detours [%lld]\n", (long long int) GetCurrentThread());
205+
202206
DETACH(CreateProcessW);
203207

204208
DETACH(GetKeyboardState);

fix_scrollbug.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1 VERSIONINFO
2-
FILEVERSION 1, 3, 3, 7
3-
PRODUCTVERSION 1, 3, 3, 7
2+
FILEVERSION 1, 4, 0, 0
3+
PRODUCTVERSION 1, 4, 0, 0
44
FILEFLAGSMASK 0
55
FILEOS 0x40000
66
FILETYPE 1
@@ -12,12 +12,12 @@ FILETYPE 1
1212
{
1313
VALUE "CompanyName", "SFT Technologies"
1414
VALUE "FileDescription", "Make AoE Great Again!"
15-
VALUE "FileVersion", "1.3.3.7"
15+
VALUE "FileVersion", "1.4.0.0"
1616
VALUE "InternalName", "fix_for_the_fucking_scrollbug"
1717
VALUE "LegalCopyright", "2019 SFT Tech, https://openage.sft.mx"
1818
VALUE "OriginalFilename", "fix_scrollbug32.dll"
1919
VALUE "ProductName", "ScrollBugFix"
20-
VALUE "ProductVersion", "1.3.3.7"
20+
VALUE "ProductVersion", "1.4.0.0"
2121
VALUE "author", "eblig"
2222
VALUE "betterEngine", "openage"
2323
VALUE "openageURL", "https://openage.sft.mx"

0 commit comments

Comments
 (0)