2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_NT_MEMORY_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_NT_MEMORY_H_
|
2020-11-25 16:19:00 +00:00
|
|
|
#include "libc/nt/struct/memorybasicinformation.h"
|
|
|
|
#include "libc/nt/struct/memoryrangeentry.h"
|
|
|
|
#include "libc/nt/struct/securityattributes.h"
|
2020-08-25 11:23:25 +00:00
|
|
|
#include "libc/nt/thunk/msabi.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
/* ░░░░
|
|
|
|
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
|
|
|
|
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
|
|
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
|
|
|
|
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
|
|
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
|
|
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
|
|
|
|
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
|
|
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
|
|
|
|
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
|
|
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
|
|
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
|
|
|
|
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
|
|
|
|
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
|
|
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
|
|
|
|
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
|
|
|
|
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
|
|
|
|
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
|
|
|
|
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
|
|
|
|
│ cosmopolitan § new technology » memory ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
2021-01-17 03:18:37 +00:00
|
|
|
#define kNtNumaNoPreferredNode 0xffffffffu
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
2021-06-24 19:31:26 +00:00
|
|
|
void *LocalFree(void *hMem);
|
|
|
|
|
2022-03-23 15:09:01 +00:00
|
|
|
int64_t CreateFileMapping(
|
|
|
|
int64_t opt_hFile,
|
|
|
|
const struct NtSecurityAttributes *opt_lpFileMappingAttributes,
|
|
|
|
uint32_t flProtect, uint32_t dwMaximumSizeHigh, uint32_t dwMaximumSizeLow,
|
|
|
|
const char16_t *opt_lpName);
|
2020-06-15 14:18:57 +00:00
|
|
|
int64_t CreateFileMappingNuma(
|
2022-03-23 15:09:01 +00:00
|
|
|
int64_t opt_hFile,
|
2020-06-15 14:18:57 +00:00
|
|
|
const struct NtSecurityAttributes *opt_lpFileMappingAttributes,
|
|
|
|
uint32_t flProtect, uint32_t dwMaximumSizeHigh, uint32_t dwMaximumSizeLow,
|
|
|
|
const char16_t *opt_lpName, uint32_t nndDesiredNumaNode);
|
2020-11-09 23:41:11 +00:00
|
|
|
|
2022-03-23 15:09:01 +00:00
|
|
|
void *MapViewOfFileEx(int64_t hFileMappingObject, uint32_t dwDesiredAccess,
|
|
|
|
uint32_t dwFileOffsetHigh, uint32_t dwFileOffsetLow,
|
|
|
|
size_t dwNumberOfBytesToMap,
|
|
|
|
void *opt_lpDesiredBaseAddress);
|
|
|
|
void *MapViewOfFileExNuma(int64_t hFileMappingObject, uint32_t dwDesiredAccess,
|
|
|
|
uint32_t dwFileOffsetHigh, uint32_t dwFileOffsetLow,
|
|
|
|
size_t dwNumberOfBytesToMap,
|
|
|
|
void *opt_lpDesiredBaseAddress,
|
|
|
|
uint32_t nndDesiredNumaNode);
|
2020-11-09 23:41:11 +00:00
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
bool32 UnmapViewOfFile(const void *lpBaseAddress);
|
|
|
|
bool32 FlushViewOfFile(const void *lpBaseAddress,
|
|
|
|
size_t dwNumberOfBytesToFlush);
|
|
|
|
|
|
|
|
void *VirtualAlloc(void *opt_lpAddress, uint64_t dwSize,
|
|
|
|
uint32_t flAllocationType, uint32_t flProtect);
|
|
|
|
bool32 VirtualFree(void *lpAddress, uint64_t dwSize, uint32_t dwFreeType);
|
|
|
|
bool32 VirtualProtect(void *lpAddress, uint64_t dwSize, uint32_t flNewProtect,
|
|
|
|
uint32_t *lpflOldProtect) paramsnonnull();
|
2023-09-02 03:49:13 +00:00
|
|
|
bool32 VirtualLock(const void *lpAddress, size_t dwSize);
|
|
|
|
bool32 VirtualUnlock(const void *lpAddress, size_t dwSize);
|
2020-06-15 14:18:57 +00:00
|
|
|
uint64_t VirtualQuery(const void *lpAddress,
|
|
|
|
struct NtMemoryBasicInformation *lpBuffer,
|
|
|
|
uint64_t dwLength);
|
|
|
|
void *VirtualAllocEx(int64_t hProcess, void *lpAddress, uint64_t dwSize,
|
|
|
|
uint32_t flAllocationType, uint32_t flProtect);
|
|
|
|
|
2022-03-20 15:01:14 +00:00
|
|
|
int64_t GetProcessHeap(void);
|
2023-09-06 10:54:42 +00:00
|
|
|
void *HeapAlloc(int64_t hHeap, uint32_t dwFlags, size_t dwBytes) __wur;
|
2022-03-20 15:01:14 +00:00
|
|
|
bool32 HeapFree(int64_t hHeap, uint32_t dwFlags, void *opt_lpMem);
|
|
|
|
void *HeapReAlloc(int64_t hHeap, uint32_t dwFlags, void *lpMem,
|
2023-09-06 10:54:42 +00:00
|
|
|
size_t dwBytes) __wur;
|
2022-03-20 15:01:14 +00:00
|
|
|
|
2023-09-06 10:54:42 +00:00
|
|
|
void *GlobalAlloc(uint32_t uFlags, uint64_t dwBytes) __wur;
|
2021-09-04 20:20:47 +00:00
|
|
|
void *GlobalFree(void *hMem);
|
|
|
|
|
2020-08-25 11:23:25 +00:00
|
|
|
#if ShouldUseMsabiAttribute()
|
|
|
|
#include "libc/nt/thunk/memory.inc"
|
|
|
|
#endif /* ShouldUseMsabiAttribute() */
|
2020-06-15 14:18:57 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_NT_MEMORY_H_ */
|