Skip to content

Add NtAllocateVirtualMemory & NtFreeVirtualMemory to std.os.windows / std.os.windows.ntdll + missing memory constants #23095

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

Closed
wants to merge 0 commits into from

Conversation

ziggoon
Copy link
Contributor

@ziggoon ziggoon commented Mar 4, 2025

This commit adds two new NTDLL functions: NtAllocateVirtualMemory and NtFreeVirtualMemory to the standard library. Additionally, two constants used for memory allocations were added: MEM_RESERVE_PLACEHOLDER and MEM_PRESERVE_PLACEHOLDER.

Relevant issue: #22846

@ziggoon ziggoon changed the title Add NtAllocateVirtualMemory & NtFreeVirtualMemory to std.os.windows / std.os.windows.ntdll Add NtAllocateVirtualMemory & NtFreeVirtualMemory to std.os.windows / std.os.windows.ntdll + missing memory constants Mar 4, 2025
@andrewrk
Copy link
Member

andrewrk commented Mar 4, 2025

Good first step. Do they work?

@ziggoon
Copy link
Contributor Author

ziggoon commented Mar 4, 2025

Good first step. Do they work?

I have some initial tests for the page allocator changes working locally. Working on establishing some solid benchmarks between the proposed changes and previous implementation which will be provided in the original issue. See relevant test logs below:

C:\Users\ziggoon\Downloads>".\page_allocator_test(1).exe"
Testing PageAllocator on Windows
Allocated 4096 bytes at address u8@16ba8480000
Memory initialized with 0xAA
Memory verification: SUCCESS
Allocated 8192 bytes at aligned address u8@16ba8490000
Address is aligned to 16 bytes: true
Directly allocated 16384 bytes at address u8@16ba84a0000
Direct allocation address is aligned to 64 bytes: true
Allocated resizable memory of 4096 bytes at u8@16ba84b0000
Resized to 8192 bytes at u8@16ba84c0000
Original data preserved after resize: SUCCESS
All tests completed!

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

Successfully merging this pull request may close these issues.

2 participants