From 36bdc7465174125fcb550268dff6fc0d693aeeb4 Mon Sep 17 00:00:00 2001 From: CrabJounrnal <59743349+CrabJounrnal@users.noreply.github.com> Date: Wed, 12 May 2021 00:21:00 +0700 Subject: [PATCH 1/4] Update InGameFunctions.h --- NFSUExtraOptions/InGameFunctions.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NFSUExtraOptions/InGameFunctions.h b/NFSUExtraOptions/InGameFunctions.h index 440b2ec..4010f66 100644 --- a/NFSUExtraOptions/InGameFunctions.h +++ b/NFSUExtraOptions/InGameFunctions.h @@ -46,4 +46,5 @@ int(*FEngSetScript)(char const* EAX_pkg, char const* EDX_obj_name, char const* s int(*PreRaceStatsScreen_SetVisibility)(DWORD* PreRaceStatsScreen, bool EAX_visible) = (int(*)(DWORD*, bool))0x4959D0; bool(*FEngIsScriptRunning)(char const* EAX_pkg, int EDI_hash, char const* script) = (bool(*)(char const*, int, char const*))0x4F6C80; int(*FEngSetVisible)(char const* EDI_pkg,char const* EDX_obj) = (int(*)(char const*, char const*))0x414A60; -DWORD QRModeSelectScreen_MaybeMakeGameModeAvailable = 0x4B6FE0; \ No newline at end of file +DWORD QRModeSelectScreen_MaybeMakeGameModeAvailable = 0x4B6FE0; +void(_stdcall* SetInputMode)(void* EAX_Player, InputMode stack_mode) = (void(_stdcall*)(void*, InputMode))0x42D520; From 22b982bdad986c6370cd08ff3c6c5dee20306fb0 Mon Sep 17 00:00:00 2001 From: CrabJounrnal <59743349+CrabJounrnal@users.noreply.github.com> Date: Wed, 12 May 2021 00:23:30 +0700 Subject: [PATCH 2/4] Update GlobalVariables.h --- NFSUExtraOptions/GlobalVariables.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NFSUExtraOptions/GlobalVariables.h b/NFSUExtraOptions/GlobalVariables.h index 58aea7c..81d1392 100644 --- a/NFSUExtraOptions/GlobalVariables.h +++ b/NFSUExtraOptions/GlobalVariables.h @@ -28,3 +28,10 @@ #define _PlayersByNumber 0x7361B4 #define _pCurrentRace 0x73619C #define _Camera_StopUpdating 0x735F5C + +enum InputMode :DWORD { + IM_menu = 1, + IM_game = 2, + //... + IM_unk_mb_last = 8 +}; From b93dd6447da14bb3c2f1964a597343d249f86291 Mon Sep 17 00:00:00 2001 From: CrabJounrnal <59743349+CrabJounrnal@users.noreply.github.com> Date: Wed, 12 May 2021 00:27:44 +0700 Subject: [PATCH 3/4] Update HotkeyStuff.h --- NFSUExtraOptions/HotkeyStuff.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/NFSUExtraOptions/HotkeyStuff.h b/NFSUExtraOptions/HotkeyStuff.h index aa31848..48fad4e 100644 --- a/NFSUExtraOptions/HotkeyStuff.h +++ b/NFSUExtraOptions/HotkeyStuff.h @@ -100,6 +100,16 @@ void Thing() else { MakeUserCall(Player_AutoPilotOff, 1, edi, PlayerThing); + // can't use MakeUserCall because ChangeInputMode is stdcall like function as most functions in game + //MakeUserCall(SetInputMode, 2, eax, *(void**)_PlayersByIndex, esp, InputMode::IM_game); + _asm + { + mov ebx, _PlayersByIndex + mov ebx, [ebx] + mov eax, ebx + push IM_game + call SetInputMode + } } } } @@ -121,4 +131,4 @@ void Thing() } _asm popad; -} \ No newline at end of file +} From 6752a25842b8fa5e7a15246eeb79e901a491de57 Mon Sep 17 00:00:00 2001 From: CrabJounrnal <59743349+CrabJounrnal@users.noreply.github.com> Date: Wed, 12 May 2021 08:51:29 +0700 Subject: [PATCH 4/4] Update UserCalls.h --- NFSUExtraOptions/UserCalls.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NFSUExtraOptions/UserCalls.h b/NFSUExtraOptions/UserCalls.h index 729187f..13ce51a 100644 --- a/NFSUExtraOptions/UserCalls.h +++ b/NFSUExtraOptions/UserCalls.h @@ -89,9 +89,6 @@ R MakeUserCall(R _func, int _numArgs, ...) va_end(ap); - // get stack difference - int _stack = _pushArgs.size() * 4; - // move args to the register struct for (FuncArg i : _args) { @@ -120,6 +117,9 @@ R MakeUserCall(R _func, int _numArgs, ...) // push args in reverse order reverse(_pushArgs.begin(), _pushArgs.end()); + + DWORD esp_target; + _asm mov [esp_target], esp for (FuncArg s : _pushArgs) { @@ -138,7 +138,7 @@ R MakeUserCall(R _func, int _numArgs, ...) // invoke the call call _func; - add esp, _stack; + mov esp, [esp_target] mov _retval, eax; }