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.
Added GetMouseWorldPos & SetInvertMidMouseButton(RutreD & KionX)
- Loading branch information
KionX
committed
Aug 22, 2022
1 parent
cb74e52
commit 88dc4dd
Showing
3 changed files
with
53 additions
and
9 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,22 @@ | ||
#include "include/LuaAPI.h" | ||
|
||
int SetInvertMidMouseButton(lua_State *L) | ||
{ | ||
auto ptr = GetProcAddress(GetModuleHandle("KERNEL32"), "VirtualProtect"); | ||
auto VirtualProtect = reinterpret_cast<bool (__stdcall *)(void*, size_t, uint32_t, uint32_t*)>(ptr); | ||
|
||
if (lua_gettop(L) != 1) | ||
WarningF("%s\n expected %d args, but got %d", __FUNCTION__, 1, lua_gettop(L)); | ||
if (!lua_isboolean(L, 1)) | ||
WarningF("%s\n invalid argument %d, use as boolean", __FUNCTION__, 1); | ||
|
||
bool status = lua_toboolean(L, 1); | ||
|
||
uint32_t oldProt; | ||
VirtualProtect(reinterpret_cast<void *>(0x0086E01F), 9, 0x40, &oldProt); | ||
*reinterpret_cast<uint8_t*>(0x0086E01F) = status ? 0x29 : 0x01; // asm sub or add | ||
*reinterpret_cast<uint8_t*>(0x0086E027) = status ? 0x29 : 0x01; // asm sub or add | ||
VirtualProtect(reinterpret_cast<void *>(0x0086E027), 9, oldProt, &oldProt); | ||
|
||
return 0; | ||
} |
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