Make some new Windows 10 memory APIs available

This commit is contained in:
Justine Tunney 2024-07-19 22:26:49 -07:00
parent f6ba270ff3
commit 101fb3d9b3
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
5 changed files with 30 additions and 4 deletions

View file

@ -1,5 +1,5 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_MapViewOfFile3,MapViewOfFile3
.imp API-MS-Win-Core-Memory-l1-1-6,__imp_MapViewOfFile3,MapViewOfFile3
.text.windows
.ftrace1

View file

@ -1,5 +1,5 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_VirtualAlloc2,VirtualAlloc2
.imp API-MS-Win-Core-Memory-l1-1-6,__imp_VirtualAlloc2,VirtualAlloc2
.text.windows
.ftrace1

View file

@ -158,6 +158,27 @@ $(LIBC_NT_SYNCHRONIZATION_A).pkg: \
#───────────────────────────────────────────────────────────────────────────────
LIBC_NT_ARTIFACTS += LIBC_NT_MEMORY_A
LIBC_NT_MEMORY = $(LIBC_NT_MEMORY_A_DEPS) $(LIBC_NT_MEMORY_A)
LIBC_NT_MEMORY_A = o/$(MODE)/libc/nt/memory.a
LIBC_NT_MEMORY_A_SRCS := $(wildcard libc/nt/API-MS-Win-Core-Memory-l1-1-6/*.S)
LIBC_NT_MEMORY_A_OBJS = $(LIBC_NT_MEMORY_A_SRCS:%.S=o/$(MODE)/%.o)
LIBC_NT_MEMORY_A_CHECKS = $(LIBC_NT_MEMORY_A).pkg
LIBC_NT_MEMORY_A_DIRECTDEPS = LIBC_NT_KERNEL32
LIBC_NT_MEMORY_A_DEPS := \
$(call uniq,$(foreach x,$(LIBC_NT_MEMORY_A_DIRECTDEPS),$($(x))))
$(LIBC_NT_MEMORY_A): \
libc/nt/API-MS-Win-Core-Memory-l1-1-6/ \
$(LIBC_NT_MEMORY_A).pkg \
$(LIBC_NT_MEMORY_A_OBJS)
$(LIBC_NT_MEMORY_A).pkg: \
$(LIBC_NT_MEMORY_A_OBJS) \
$(foreach x,$(LIBC_NT_MEMORY_A_DIRECTDEPS),$($(x)_A).pkg)
#───────────────────────────────────────────────────────────────────────────────
LIBC_NT_ARTIFACTS += LIBC_NT_USER32_A
LIBC_NT_USER32 = $(LIBC_NT_USER32_A_DEPS) $(LIBC_NT_USER32_A)
LIBC_NT_USER32_A = o/$(MODE)/libc/nt/user32.a

View file

@ -16,6 +16,7 @@
#define kNtMemLargePages 0x20000000
#define kNtMem4mbPages 0x80000000
#define kNtMemReservePlaceholder 0x00040000
#define kNtMemReplacePlaceholder 0x00004000
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_MEMFLAGS_H_ */

View file

@ -205,7 +205,6 @@ imp 'LoadResource' LoadResource kernel32 2
imp 'LocalFree' LocalFree kernel32 1
imp 'LockFile' LockFile kernel32 5
imp 'LockResource' LockResource kernel32 1
imp 'MapViewOfFile3' MapViewOfFile3 kernel32 9
imp 'MoveFile' MoveFileW kernel32 2
imp 'MultiByteToWideChar' MultiByteToWideChar kernel32 6
imp 'OfferVirtualMemory' OfferVirtualMemory kernel32 3
@ -296,7 +295,6 @@ 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
@ -629,6 +627,12 @@ imp 'WaitOnAddress' WaitOnAddress API-MS-Win-Core-Synch-l1-2-0 4
imp 'WakeByAddressAll' WakeByAddressAll API-MS-Win-Core-Synch-l1-2-0 1
imp 'WakeByAddressSingle' WakeByAddressSingle API-MS-Win-Core-Synch-l1-2-0 1
# API-MS-Win-Core-Memory-l1-1-6.dll (Windows 10+)
#
# Name Actual DLL Arity
imp 'MapViewOfFile3' MapViewOfFile3 API-MS-Win-Core-Memory-l1-1-6 9
imp 'VirtualAlloc2' VirtualAlloc2 API-MS-Win-Core-Memory-l1-1-6 7
# NTDLL.DLL
# BEYOND THE PALE
#