2019-10-25 06:07:08 +08:00
|
|
|
extern "C" int CheckInventoryFullHandler(void* player, void* item) {
|
2019-10-13 13:30:52 +08:00
|
|
|
for (DLL* dll: modDLLs) {
|
2019-10-14 19:55:20 +08:00
|
|
|
if (dll->HandleCheckInventoryFull) {
|
|
|
|
if ( int result = ((int(*)(void*, void*))dll->HandleCheckInventoryFull)(player, item) ){
|
2019-10-13 13:30:52 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-25 06:07:08 +08:00
|
|
|
GETTER_VAR(void*, ASMCheckInventoryFullHandler_jmpback);
|
|
|
|
GETTER_VAR(void*, ASMCheckInventoryFullHandler_retn);
|
|
|
|
__attribute__((naked)) void ASMCheckInventoryFullHandler() {
|
|
|
|
asm(".intel_syntax \n"
|
|
|
|
PUSH_ALL
|
2019-10-13 13:30:52 +08:00
|
|
|
|
|
|
|
PREPARE_STACK
|
2019-10-25 06:07:08 +08:00
|
|
|
"call CheckInventoryFullHandler \n"
|
2019-10-13 13:30:52 +08:00
|
|
|
|
|
|
|
RESTORE_STACK
|
|
|
|
|
|
|
|
// Did the handler return 1? true
|
|
|
|
"cmp eax, 1 \n"
|
|
|
|
"je 1f \n"
|
|
|
|
|
|
|
|
// Did the handler return 2? false
|
|
|
|
"cmp eax, 2 \n"
|
|
|
|
"je 2f \n"
|
|
|
|
|
|
|
|
// Otherwise? Do nothing
|
|
|
|
POP_ALL
|
|
|
|
|
|
|
|
// original code
|
|
|
|
"mov [rsp+0x20], rbp \n"
|
|
|
|
"push r12 \n"
|
|
|
|
"push r14 \n"
|
|
|
|
"push r15 \n"
|
|
|
|
"sub rsp, 0x20 \n"
|
2019-10-25 06:07:08 +08:00
|
|
|
DEREF_JMP(ASMCheckInventoryFullHandler_jmpback)
|
2019-10-13 13:30:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
"1: \n" //full
|
|
|
|
POP_ALL
|
|
|
|
"xor al,al \n"
|
2019-10-25 06:07:08 +08:00
|
|
|
DEREF_JMP(ASMCheckInventoryFullHandler_retn)
|
2019-10-13 13:30:52 +08:00
|
|
|
|
|
|
|
"2: \n" //not
|
|
|
|
POP_ALL
|
|
|
|
"mov al,1 \n"
|
2019-10-25 06:07:08 +08:00
|
|
|
DEREF_JMP(ASMCheckInventoryFullHandler_retn)
|
2019-10-13 13:30:52 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
void SetupCheckInventoryFullHandler() {
|
2019-10-25 06:07:08 +08:00
|
|
|
WriteFarJMP(Offset(base, 0x50670), (void*)&ASMCheckInventoryFullHandler);
|
|
|
|
ASMCheckInventoryFullHandler_jmpback = Offset(base, 0x5067F);
|
|
|
|
ASMCheckInventoryFullHandler_retn = Offset(base, 0x507A0);
|
2019-10-13 13:30:52 +08:00
|
|
|
}
|