Skip to content

Commit 529012b

Browse files
committed
thcrap: Fix asm inject stub
It's a miracle that this ever worked like this
1 parent 1d8350c commit 529012b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

thcrap/src/inject_func.asm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ _inject_LoadLibraryExWptr:
9393
push esp /* Reset directory to the original one of the process */
9494
call esi /* Call SetCurrentDirectoryW */
9595
add esp, ebx /* Deallocate buffer from the stack */
96+
SkipDirectoryBS2:
9697
_inject_ExitThreadptr:
9798
mov esi, 0xDEADBEEF
98-
SkipDirectoryBS2:
9999
test edi, edi /* Check whether LoadLibraryEx was successful */
100100
jz ThrowError1
101101
_inject_funcnameptr:
@@ -114,34 +114,35 @@ _inject_funcparamptr:
114114
If we get here, [func_name] has been called,
115115
so it's time to close this thread and optionally unload the DLL.
116116
*/
117-
118-
push 0 /* Exit code */
117+
119118
mov eax, esi
120119
pop edi
121120
pop esi
122121
pop ebp
123122
pop ebx
123+
push 0 /* Exit code */
124124
call eax /* Call ExitThread */
125125

126126
.balign 16, 0xCC
127127

128128
ThrowError1:
129-
push 1 /* Exit code */
130129
mov eax, esi
131130
pop edi
132131
pop esi
133132
pop ebp
134133
pop ebx
134+
push 1 /* Exit code */
135135
call eax /* Call ExitThread */
136136
.balign 16, 0xCC
137137

138138
ThrowError2:
139-
push 2 /* Exit code */
140-
push edi /* Push the injected DLL's module handle */
139+
mov edx, edi
141140
pop edi
142141
pop esi
143142
pop ebp
144143
pop ebx
144+
push 2 /* Exit code */
145+
push edx /* Push the injected DLL's module handle */
145146
_inject_FreeLibraryAndExitThreadptr:
146147
mov eax, 0xDEADBEEF
147148
call eax /* Call FreeLibraryAndExitThread */

0 commit comments

Comments
 (0)