Skip to content

Commit

Permalink
Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
gyroninja committed Aug 21, 2022
1 parent 6e8297b commit 9eee6ac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions OpenVR-SpaceCalibratorDriver/Hooking.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Logging.h"
#include <map>
#include <string>
#include <sys/mman.h>

class IHook
{
Expand Down Expand Up @@ -44,8 +45,8 @@ class Hook : public IHook
// 0xE9 ?? ?? ?? ??
// Address is little endian
uint8_t* targetFuncCode = reinterpret_cast<uint8_t*>(targetFunc);
int startPage = targetFuncCode & 0xFFF;
int endPage = (targetFuncCode + 5) & 0xFFF;
intptr_t startPage = reinterpret_cast<intptr_t >(targetFuncCode) & 0xFFF;
intptr_t endPage = (reinterpret_cast<intptr_t >(targetFuncCode) + 5) & 0xFFF;
mprotect(targetFuncCode, endPage - startPage + 0xFFF, PROT_READ | PROT_WRITE | PROT_EXEC);
unpatched[0] = targetFuncCode[0];
unpatched[1] = targetFuncCode[1];
Expand All @@ -72,8 +73,8 @@ class Hook : public IHook
R OriginalFunc(Args... args)
{
uint8_t* targetFuncCode = reinterpret_cast<uint8_t*>(targetFunc);
int startPage = targetFuncCode & 0xFFF;
int endPage = (targetFuncCode + 5) & 0xFFF;
intptr_t startPage = reinterpret_cast<intptr_t >(targetFuncCode) & 0xFFF;
intptr_t endPage = (reinterpret_cast<intptr_t >(targetFuncCode) + 5) & 0xFFF;
mprotect(targetFuncCode, endPage - startPage + 0xFFF, PROT_READ | PROT_WRITE | PROT_EXEC);
targetFuncCode[0] = unpatched[0];
targetFuncCode[1] = unpatched[1];
Expand Down

0 comments on commit 9eee6ac

Please sign in to comment.