Skip to content

Commit 06d916b

Browse files
committed
Add VirtualAlloc2 WIN32 API
1 parent 9ea6472 commit 06d916b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

libc/nt/kernel32/VirtualAlloc2.S

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "libc/nt/codegen.h"
2+
.imp kernel32,__imp_VirtualAlloc2,VirtualAlloc2
3+
4+
.text.windows
5+
.ftrace1
6+
VirtualAlloc2:
7+
.ftrace2
8+
#ifdef __x86_64__
9+
push %rbp
10+
mov %rsp,%rbp
11+
mov __imp_VirtualAlloc2(%rip),%rax
12+
jmp __sysv2nt8
13+
#elif defined(__aarch64__)
14+
mov x0,#0
15+
ret
16+
#endif
17+
.endfn VirtualAlloc2,globl
18+
.previous

libc/nt/master.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ imp 'UnmapViewOfFile2' UnmapViewOfFile2 kernel32 2
296296
imp 'UnmapViewOfFileEx' UnmapViewOfFileEx kernel32 3
297297
imp 'UpdateProcThreadAttribute' UpdateProcThreadAttribute kernel32 7
298298
imp 'VirtualAlloc' VirtualAlloc kernel32 4
299+
imp 'VirtualAlloc2' VirtualAlloc2 kernel32 7
299300
imp 'VirtualAllocEx' VirtualAllocEx kernel32 5
300301
imp 'VirtualFree' VirtualFree kernel32 3
301302
imp 'VirtualLock' VirtualLock kernel32 2

libc/nt/memory.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ void *MapViewOfFile3(
9696
struct NtMemExtendedParameter *in_out_opt_ExtendedParameters,
9797
unsigned ParameterCount);
9898

99+
void *VirtualAlloc2(
100+
intptr_t opt_Process, void *opt_BaseAddress, size_t Size,
101+
unsigned AllocationType, unsigned PageProtection,
102+
struct NtMemExtendedParameter *in_out_opt_ExtendedParameters,
103+
unsigned ParameterCount);
104+
99105
#if ShouldUseMsabiAttribute()
100106
#include "libc/nt/thunk/memory.inc"
101107
#endif /* ShouldUseMsabiAttribute() */

0 commit comments

Comments
 (0)