Skip to content

Commit

Permalink
thcrap: Fix asm inject stub
Browse files Browse the repository at this point in the history
It's a miracle that this ever worked like this
  • Loading branch information
zero318 committed May 23, 2024
1 parent 1d8350c commit 529012b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions thcrap/src/inject_func.asm
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ _inject_LoadLibraryExWptr:
push esp /* Reset directory to the original one of the process */
call esi /* Call SetCurrentDirectoryW */
add esp, ebx /* Deallocate buffer from the stack */
SkipDirectoryBS2:
_inject_ExitThreadptr:
mov esi, 0xDEADBEEF
SkipDirectoryBS2:
test edi, edi /* Check whether LoadLibraryEx was successful */
jz ThrowError1
_inject_funcnameptr:
Expand All @@ -114,34 +114,35 @@ _inject_funcparamptr:
If we get here, [func_name] has been called,
so it's time to close this thread and optionally unload the DLL.
*/

push 0 /* Exit code */
mov eax, esi
pop edi
pop esi
pop ebp
pop ebx
push 0 /* Exit code */
call eax /* Call ExitThread */

.balign 16, 0xCC

ThrowError1:
push 1 /* Exit code */
mov eax, esi
pop edi
pop esi
pop ebp
pop ebx
push 1 /* Exit code */
call eax /* Call ExitThread */
.balign 16, 0xCC

ThrowError2:
push 2 /* Exit code */
push edi /* Push the injected DLL's module handle */
mov edx, edi
pop edi
pop esi
pop ebp
pop ebx
push 2 /* Exit code */
push edx /* Push the injected DLL's module handle */
_inject_FreeLibraryAndExitThreadptr:
mov eax, 0xDEADBEEF
call eax /* Call FreeLibraryAndExitThread */
Expand Down

0 comments on commit 529012b

Please sign in to comment.