Skip to content

Commit

Permalink
Add VirtualAlloc2 WIN32 API
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed May 5, 2024
1 parent 9ea6472 commit 06d916b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libc/nt/kernel32/VirtualAlloc2.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_VirtualAlloc2,VirtualAlloc2

.text.windows
.ftrace1
VirtualAlloc2:
.ftrace2
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
mov __imp_VirtualAlloc2(%rip),%rax
jmp __sysv2nt8
#elif defined(__aarch64__)
mov x0,#0
ret
#endif
.endfn VirtualAlloc2,globl
.previous
1 change: 1 addition & 0 deletions libc/nt/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ imp 'UnmapViewOfFile2' UnmapViewOfFile2 kernel32 2
imp 'UnmapViewOfFileEx' UnmapViewOfFileEx kernel32 3
imp 'UpdateProcThreadAttribute' UpdateProcThreadAttribute kernel32 7
imp 'VirtualAlloc' VirtualAlloc kernel32 4
imp 'VirtualAlloc2' VirtualAlloc2 kernel32 7
imp 'VirtualAllocEx' VirtualAllocEx kernel32 5
imp 'VirtualFree' VirtualFree kernel32 3
imp 'VirtualLock' VirtualLock kernel32 2
Expand Down
6 changes: 6 additions & 0 deletions libc/nt/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ void *MapViewOfFile3(
struct NtMemExtendedParameter *in_out_opt_ExtendedParameters,
unsigned ParameterCount);

void *VirtualAlloc2(
intptr_t opt_Process, void *opt_BaseAddress, size_t Size,
unsigned AllocationType, unsigned PageProtection,
struct NtMemExtendedParameter *in_out_opt_ExtendedParameters,
unsigned ParameterCount);

#if ShouldUseMsabiAttribute()
#include "libc/nt/thunk/memory.inc"
#endif /* ShouldUseMsabiAttribute() */
Expand Down

0 comments on commit 06d916b

Please sign in to comment.