UnleashedRecomp icon indicating copy to clipboard operation
UnleashedRecomp copied to clipboard

Possible access violation for low host addresses

Open Jujstme opened this issue 9 months ago • 1 comments

The function IsInMemoryRange checks the validity of a certain memory address by verifying if it falls under the allocated host space, however it doesn't correctly check for the first 4096 bytes, which are protected by VirtualProtect

Although I haven't seen a real scenario so far, this erroneous check can wrongly pass if the target address falls into the protected memory region, and as such any subsequent attempt to use the resulting pointer can end up into a segfault.

So far the function is used only twice in the code: here and here

Jujstme avatar Mar 14 '25 15:03 Jujstme

That wasn't really the intent of this function, I came up with it while making the mod loader to ensure I didn't accidentally allocate memory in the host when I meant to do it in the guest memory range instead. It will crash immediately after anyway if an access in the protected region happens.

blueskythlikesclouds avatar Mar 14 '25 16:03 blueskythlikesclouds