forked from kyx0r/FA-Binary-Patches
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent
unit:SetStat()
from crashing the game (#21)
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "../define.h" | ||
asm( | ||
".section h0; .set h0,0x6CCA2A;" | ||
"jmp "QU(SetStatCheck)";" | ||
"nop;" | ||
"nop;" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "include/moho.h" | ||
|
||
void PushTrue() | ||
{ | ||
register lua_State *l asm("eax"); | ||
lua_pushboolean(l, true); | ||
} | ||
|
||
void SetStatCheck() | ||
{ | ||
asm( | ||
// mov ebx, eax //pointer to our stat in other thread | ||
"mov eax, [edi];" // pointer to lua state | ||
"cmp ebx, 0;" | ||
"je SetStatCheck_invalid;" // go to return 1 | ||
"mov esi, 3;" | ||
"jmp 0x6CCA31;" // get back into normal function flow | ||
"SetStatCheck_invalid:" | ||
"call %[PushTrue];" | ||
"mov eax, 1;" | ||
"pop edi;" | ||
"pop esi;" | ||
"pop ebx;" | ||
"mov esp, ebp;" | ||
"pop ebp;" | ||
"ret;" | ||
: | ||
: [PushTrue] "i"(PushTrue) | ||
: | ||
); | ||
} |