Skip to content

Commit

Permalink
Update sh_memory.h (tidy up things)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelaSavia authored and psychonic committed Dec 19, 2023
1 parent f2d9d3e commit bc36e07
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/sourcehook/sh_memory.h
Expand Up @@ -265,21 +265,21 @@ namespace SourceHook
unsigned long lower = reinterpret_cast<unsigned long>(addr);
unsigned long upper = lower + len;

bool bFound = false;
FILE *pF = fopen("/proc/self/maps", "r");
if (pF)
{
// Linux /proc/self/maps -> parse
// Format:
// lower upper prot stuff path
// 08048000-0804c000 r-xp 00000000 03:03 1010107 /bin/cat
unsigned long rlower, rupper;
bool bFound = false;

char *buffer = NULL;
size_t bufsize = 0;
while (getline(&buffer, &bufsize, pF) != -1) {
char *addr_split;
rlower = strtoul(buffer, &addr_split, 16);
rupper = strtoul(&addr_split[1], NULL, 16);
unsigned long rlower = strtoul(buffer, &addr_split, 16);
unsigned long rupper = strtoul(&addr_split[1], NULL, 16);
// Check whether we're IN THERE!
if (lower >= rlower && upper <= rupper)
{
Expand Down

0 comments on commit bc36e07

Please sign in to comment.