Page 1 of 1

Replace malloc() by mmap() in Voodoo Graphics.

Posted: Tue 27 Nov, 2018 1:45 am
by Martin_Riarte
For the 3Dfx graphics (Voddoo 1/2, etc.), malloc is used to locate memory and then mprotect to change the permissions.

Reasons why malloc is not recommended as a tool:

- Permits only set with the granularity page, but the memory obtained by malloc is unlikely to be the page aligned, and
therefore the permission setting in the adjacent memory will also be terminated, possibly breaking things or denying
permissions of access.
- If you do not reset the previous permissions before calling the free, you can break the inside of malloc.

Solution:

- Replace malloc () with mmap ().
- Replace free () with munmap ().

In my GNU / Linux system in particular (my dear CentOS Linux 6.7), the application is dropped with a message
"mprotect: permission denied.", It drove me crazy ehh ! :cry: .

I solved it with these replacements in a patch and until now, it works (and I already did several tests, ehh!) :lol: .

If any of you have this problem, use it! :D

Re: Replace malloc() by mmap() in Voodoo Graphics.

Posted: Tue 23 Apr, 2019 8:28 pm
by SarahWalker
Merged at rev 1224.