Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for read-only memory? #29

Open
GerbenAbbink opened this issue Jul 30, 2022 · 2 comments
Open

Support for read-only memory? #29

GerbenAbbink opened this issue Jul 30, 2022 · 2 comments

Comments

@GerbenAbbink
Copy link

Is it possible to allocate memory with FastMM5 and make part of that memory read-only?

@pleriche
Copy link
Owner

Hi Gerben,

Unfortunately PC hardware only supports memory protection at the page level, which is 4096 bytes. You could allocate a block via FastMM and then call VirtualProtect to change the page the block is in to read-only mode, but you'll run into trouble if the adjacent blocks are written to by your application.

Alternatively you could allocate a 4K page via VirtualAlloc yourself, and then you can control the protection flags on that page without risk to adjacent blocks.

Best regards,
Pierre

@GerbenAbbink
Copy link
Author

GerbenAbbink commented Aug 2, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants