ReactOS 0.4.16-dev-1457-g02ea0aa
memory.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "winerror.h"
#include "ddk/wdm.h"
#include "kernelbase.h"
#include "wine/exception.h"
#include "wine/debug.h"
Include dependency graph for memory.c:

Go to the source code of this file.

Classes

struct  rtl_heap_entry
 
struct  kernelbase_global_data
 
struct  mem_entry
 

Macros

#define WIN32_NO_STATUS
 
#define ROUND_ADDR(addr)   ((void *)((UINT_PTR)(addr) & ~page_mask))
 
#define ROUND_SIZE(addr, size)   (((SIZE_T)(size) + ((UINT_PTR)(addr) & page_mask) + page_mask) & ~page_mask)
 
#define RTL_HEAP_ENTRY_BUSY   0x0001
 
#define RTL_HEAP_ENTRY_REGION   0x0002
 
#define RTL_HEAP_ENTRY_BLOCK   0x0010
 
#define RTL_HEAP_ENTRY_UNCOMMITTED   0x1000
 
#define RTL_HEAP_ENTRY_COMMITTED   0x4000
 
#define RTL_HEAP_ENTRY_LFH   0x8000
 
#define HEAP_ADD_USER_INFO   0x00000100
 
#define MEM_FLAG_USED   1
 
#define MEM_FLAG_MOVEABLE   2
 
#define MEM_FLAG_DISCARDABLE   4
 
#define MEM_FLAG_DISCARDED   8
 
#define MEM_FLAG_DDESHARE   0x8000
 
#define MAX_MEM_HANDLES   0x10000
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (heap)
 
 WINE_DECLARE_DEBUG_CHANNEL (virtual)
 
 WINE_DECLARE_DEBUG_CHANNEL (globalmem)
 
static CROSS_PROCESS_WORK_LIST * open_cross_process_connection (HANDLE process)
 
static void close_cross_process_connection (CROSS_PROCESS_WORK_LIST *list)
 
static void send_cross_process_notification (CROSS_PROCESS_WORK_LIST *list, UINT id, const void *addr, SIZE_T size, int nb_args,...)
 
DWORD WINAPI DECLSPEC_HOTPATCH DiscardVirtualMemory (void *addr, SIZE_T size)
 
BOOL WINAPI DECLSPEC_HOTPATCH FlushViewOfFile (const void *base, SIZE_T size)
 
BOOL WINAPI DECLSPEC_HOTPATCH FlushInstructionCache (HANDLE process, LPCVOID addr, SIZE_T size)
 
SIZE_T WINAPI GetLargePageMinimum (void)
 
static void fill_system_info (SYSTEM_INFO *si, const SYSTEM_BASIC_INFORMATION *basic_info, const SYSTEM_CPU_INFORMATION *cpu_info)
 
void WINAPI DECLSPEC_HOTPATCH GetNativeSystemInfo (SYSTEM_INFO *si)
 
void WINAPI DECLSPEC_HOTPATCH GetSystemInfo (SYSTEM_INFO *si)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetSystemFileCacheSize (SIZE_T *mincache, SIZE_T *maxcache, DWORD *flags)
 
UINT WINAPI DECLSPEC_HOTPATCH GetWriteWatch (DWORD flags, void *base, SIZE_T size, void **addresses, ULONG_PTR *count, ULONG *granularity)
 
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile (HANDLE mapping, DWORD access, DWORD offset_high, DWORD offset_low, SIZE_T count)
 
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileEx (HANDLE handle, DWORD access, DWORD offset_high, DWORD offset_low, SIZE_T count, LPVOID addr)
 
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileFromApp (HANDLE handle, ULONG access, ULONG64 offset, SIZE_T size)
 
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile3 (HANDLE handle, HANDLE process, PVOID baseaddr, ULONG64 offset, SIZE_T size, ULONG alloc_type, ULONG protection, MEM_EXTENDED_PARAMETER *params, ULONG params_count)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadProcessMemory (HANDLE process, const void *addr, void *buffer, SIZE_T size, SIZE_T *bytes_read)
 
UINT WINAPI DECLSPEC_HOTPATCH ResetWriteWatch (void *base, SIZE_T size)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetSystemFileCacheSize (SIZE_T mincache, SIZE_T maxcache, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFile (const void *addr)
 
BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFile2 (HANDLE process, void *addr, ULONG flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFileEx (void *addr, ULONG flags)
 
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc (void *addr, SIZE_T size, DWORD type, DWORD protect)
 
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocEx (HANDLE process, void *addr, SIZE_T size, DWORD type, DWORD protect)
 
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc2 (HANDLE process, void *addr, SIZE_T size, DWORD type, DWORD protect, MEM_EXTENDED_PARAMETER *parameters, ULONG count)
 
static BOOL is_exec_prot (DWORD protect)
 
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc2FromApp (HANDLE process, void *addr, SIZE_T size, DWORD type, DWORD protect, MEM_EXTENDED_PARAMETER *parameters, ULONG count)
 
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocFromApp (void *addr, SIZE_T size, DWORD type, DWORD protect)
 
BOOL WINAPI DECLSPEC_HOTPATCH PrefetchVirtualMemory (HANDLE process, ULONG_PTR count, WIN32_MEMORY_RANGE_ENTRY *addresses, ULONG flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH VirtualFree (void *addr, SIZE_T size, DWORD type)
 
BOOL WINAPI DECLSPEC_HOTPATCH VirtualFreeEx (HANDLE process, void *addr, SIZE_T size, DWORD type)
 
BOOL WINAPI DECLSPEC_HOTPATCH VirtualLock (void *addr, SIZE_T size)
 
BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtect (void *addr, SIZE_T size, DWORD new_prot, DWORD *old_prot)
 
BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtectEx (HANDLE process, void *addr, SIZE_T size, DWORD new_prot, DWORD *old_prot)
 
SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQuery (LPCVOID addr, PMEMORY_BASIC_INFORMATION info, SIZE_T len)
 
SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQueryEx (HANDLE process, LPCVOID addr, PMEMORY_BASIC_INFORMATION info, SIZE_T len)
 
BOOL WINAPI DECLSPEC_HOTPATCH VirtualUnlock (void *addr, SIZE_T size)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteProcessMemory (HANDLE process, void *addr, const void *buffer, SIZE_T size, SIZE_T *bytes_written)
 
BOOL WINAPI IsBadStringPtrA (LPCSTR str, UINT_PTR max)
 
BOOL WINAPI IsBadStringPtrW (LPCWSTR str, UINT_PTR max)
 
SIZE_T WINAPI DECLSPEC_HOTPATCH HeapCompact (HANDLE heap, DWORD flags)
 
HANDLE WINAPI DECLSPEC_HOTPATCH HeapCreate (DWORD flags, SIZE_T init_size, SIZE_T max_size)
 
BOOL WINAPI DECLSPEC_HOTPATCH HeapDestroy (HANDLE heap)
 
BOOL WINAPI DECLSPEC_HOTPATCH HeapLock (HANDLE heap)
 
BOOL WINAPI HeapQueryInformation (HANDLE heap, HEAP_INFORMATION_CLASS info_class, PVOID info, SIZE_T size, PSIZE_T size_out)
 
BOOL WINAPI HeapSetInformation (HANDLE heap, HEAP_INFORMATION_CLASS infoclass, PVOID info, SIZE_T size)
 
BOOL WINAPI HeapUnlock (HANDLE heap)
 
BOOL WINAPI DECLSPEC_HOTPATCH HeapValidate (HANDLE heap, DWORD flags, LPCVOID ptr)
 
BOOL WINAPI DECLSPEC_HOTPATCH HeapWalk (HANDLE heap, PROCESS_HEAP_ENTRY *entry)
 
 C_ASSERT (sizeof(struct mem_entry)==2 *sizeof(void *))
 
static struct mem_entryunsafe_mem_from_HLOCAL (HLOCAL handle)
 
static HLOCAL HLOCAL_from_mem (struct mem_entry *mem)
 
static voidunsafe_ptr_from_HLOCAL (HLOCAL handle)
 
void init_global_data (void)
 
void *WINAPI KernelBaseGetGlobalData (void)
 
HGLOBAL WINAPI DECLSPEC_HOTPATCH GlobalAlloc (UINT flags, SIZE_T size)
 
HGLOBAL WINAPI DECLSPEC_HOTPATCH GlobalFree (HLOCAL handle)
 
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalAlloc (UINT flags, SIZE_T size)
 
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalFree (HLOCAL handle)
 
LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock (HLOCAL handle)
 
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc (HLOCAL handle, SIZE_T size, UINT flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH LocalUnlock (HLOCAL handle)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMemoryResourceNotification (MEMORY_RESOURCE_NOTIFICATION_TYPE type)
 
BOOL WINAPI DECLSPEC_HOTPATCH QueryMemoryResourceNotification (HANDLE handle, BOOL *state)
 
BOOL WINAPI DECLSPEC_HOTPATCH AllocateUserPhysicalPages (HANDLE process, ULONG_PTR *pages, ULONG_PTR *userarray)
 
BOOL WINAPI DECLSPEC_HOTPATCH FreeUserPhysicalPages (HANDLE process, ULONG_PTR *pages, ULONG_PTR *userarray)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetPhysicallyInstalledSystemMemory (ULONGLONG *memory)
 
BOOL WINAPI DECLSPEC_HOTPATCH GlobalMemoryStatusEx (MEMORYSTATUSEX *status)
 
BOOL WINAPI DECLSPEC_HOTPATCH MapUserPhysicalPages (void *addr, ULONG_PTR page_count, ULONG_PTR *pages)
 
BOOL WINAPI DECLSPEC_HOTPATCH AllocateUserPhysicalPagesNuma (HANDLE process, ULONG_PTR *pages, ULONG_PTR *userarray, DWORD node)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileMappingNumaW (HANDLE file, LPSECURITY_ATTRIBUTES sa, DWORD protect, DWORD size_high, DWORD size_low, LPCWSTR name, DWORD node)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetLogicalProcessorInformation (SYSTEM_LOGICAL_PROCESSOR_INFORMATION *buffer, DWORD *len)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetLogicalProcessorInformationEx (LOGICAL_PROCESSOR_RELATIONSHIP relationship, SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buffer, DWORD *len)
 
BOOL WINAPI GetSystemCpuSetInformation (SYSTEM_CPU_SET_INFORMATION *info, ULONG buffer_length, ULONG *return_length, HANDLE process, ULONG flags)
 
BOOL WINAPI SetThreadSelectedCpuSets (HANDLE thread, const ULONG *cpu_set_ids, ULONG count)
 
BOOL WINAPI SetProcessDefaultCpuSets (HANDLE process, const ULONG *cpu_set_ids, ULONG count)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetNumaHighestNodeNumber (ULONG *node)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetNumaNodeProcessorMaskEx (USHORT node, GROUP_AFFINITY *mask)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetNumaProximityNodeEx (ULONG proximity_id, USHORT *node)
 
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileExNuma (HANDLE handle, DWORD access, DWORD offset_high, DWORD offset_low, SIZE_T count, LPVOID addr, DWORD node)
 
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocExNuma (HANDLE process, void *addr, SIZE_T size, DWORD type, DWORD protect, DWORD node)
 
BOOL WINAPI DECLSPEC_HOTPATCH QueryVirtualMemoryInformation (HANDLE process, const void *addr, WIN32_MEMORY_INFORMATION_CLASS info_class, void *info, SIZE_T size, SIZE_T *ret_size)
 
BOOL WINAPI InitializeContext2 (void *buffer, DWORD context_flags, CONTEXT **context, DWORD *length, ULONG64 compaction_mask)
 
BOOL WINAPI InitializeContext (void *buffer, DWORD context_flags, CONTEXT **context, DWORD *length)
 
BOOL WINAPI CopyContext (CONTEXT *dst, DWORD context_flags, CONTEXT *src)
 
static UINT get_firmware_table (DWORD provider, SYSTEM_FIRMWARE_TABLE_ACTION action, DWORD id, void *buffer, DWORD size)
 
UINT WINAPI EnumSystemFirmwareTables (DWORD provider, void *buffer, DWORD size)
 
UINT WINAPI GetSystemFirmwareTable (DWORD provider, DWORD id, void *buffer, DWORD size)
 

Variables

static const SIZE_T page_mask = 0xfff
 
static struct mem_entrynext_free_mem
 
static struct kernelbase_global_data global_data = {0}
 

Macro Definition Documentation

◆ HEAP_ADD_USER_INFO

#define HEAP_ADD_USER_INFO   0x00000100

Definition at line 874 of file memory.c.

◆ MAX_MEM_HANDLES

#define MAX_MEM_HANDLES   0x10000

Definition at line 905 of file memory.c.

◆ MEM_FLAG_DDESHARE

#define MEM_FLAG_DDESHARE   0x8000

Definition at line 887 of file memory.c.

◆ MEM_FLAG_DISCARDABLE

#define MEM_FLAG_DISCARDABLE   4

Definition at line 885 of file memory.c.

◆ MEM_FLAG_DISCARDED

#define MEM_FLAG_DISCARDED   8

Definition at line 886 of file memory.c.

◆ MEM_FLAG_MOVEABLE

#define MEM_FLAG_MOVEABLE   2

Definition at line 884 of file memory.c.

◆ MEM_FLAG_USED

#define MEM_FLAG_USED   1

Definition at line 883 of file memory.c.

◆ ROUND_ADDR

#define ROUND_ADDR (   addr)    ((void *)((UINT_PTR)(addr) & ~page_mask))

Definition at line 97 of file memory.c.

◆ ROUND_SIZE

#define ROUND_SIZE (   addr,
  size 
)    (((SIZE_T)(size) + ((UINT_PTR)(addr) & page_mask) + page_mask) & ~page_mask)

Definition at line 98 of file memory.c.

◆ RTL_HEAP_ENTRY_BLOCK

#define RTL_HEAP_ENTRY_BLOCK   0x0010

Definition at line 817 of file memory.c.

◆ RTL_HEAP_ENTRY_BUSY

#define RTL_HEAP_ENTRY_BUSY   0x0001

Definition at line 815 of file memory.c.

◆ RTL_HEAP_ENTRY_COMMITTED

#define RTL_HEAP_ENTRY_COMMITTED   0x4000

Definition at line 819 of file memory.c.

◆ RTL_HEAP_ENTRY_LFH

#define RTL_HEAP_ENTRY_LFH   0x8000

Definition at line 820 of file memory.c.

◆ RTL_HEAP_ENTRY_REGION

#define RTL_HEAP_ENTRY_REGION   0x0002

Definition at line 816 of file memory.c.

◆ RTL_HEAP_ENTRY_UNCOMMITTED

#define RTL_HEAP_ENTRY_UNCOMMITTED   0x1000

Definition at line 818 of file memory.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 28 of file memory.c.

Function Documentation

◆ AllocateUserPhysicalPages()

BOOL WINAPI DECLSPEC_HOTPATCH AllocateUserPhysicalPages ( HANDLE  process,
ULONG_PTR pages,
ULONG_PTR userarray 
)

Definition at line 1289 of file memory.c.

1291{
1292 FIXME( "stub: %p %p %p\n", process, pages, userarray );
1294 return FALSE;
1295}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define FALSE
Definition: types.h:117
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SetLastError(x)
Definition: compat.h:752

Referenced by AllocateUserPhysicalPagesNuma().

◆ AllocateUserPhysicalPagesNuma()

BOOL WINAPI DECLSPEC_HOTPATCH AllocateUserPhysicalPagesNuma ( HANDLE  process,
ULONG_PTR pages,
ULONG_PTR userarray,
DWORD  node 
)

Definition at line 1408 of file memory.c.

1410{
1411 if (node) FIXME( "Ignoring preferred node %lu\n", node );
1412 return AllocateUserPhysicalPages( process, pages, userarray );
1413}
BOOL WINAPI DECLSPEC_HOTPATCH AllocateUserPhysicalPages(HANDLE process, ULONG_PTR *pages, ULONG_PTR *userarray)
Definition: memory.c:1289
Definition: dlist.c:348

◆ C_ASSERT()

C_ASSERT ( sizeof(struct mem_entry = =2 *sizeof(void *))

◆ close_cross_process_connection()

static void close_cross_process_connection ( CROSS_PROCESS_WORK_LIST *  list)
static

Definition at line 60 of file memory.c.

61{
63}
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3483
Definition: list.h:37
#define GetCurrentProcess()
Definition: compat.h:759

Referenced by FlushInstructionCache(), and WriteProcessMemory().

◆ CopyContext()

BOOL WINAPI CopyContext ( CONTEXT dst,
DWORD  context_flags,
CONTEXT src 
)

Definition at line 1633 of file memory.c.

1634{
1635 return set_ntstatus( RtlCopyContext( dst, context_flags, src ));
1636}
static __inline BOOL set_ntstatus(NTSTATUS status)
Definition: security.c:227
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by FileCopyCallback(), FileCopyPage(), MoveFileWithProgressW(), PrepareAndDoCopyThread(), and SetupUpdateMemoryInfo().

◆ CreateFileMappingNumaW()

HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileMappingNumaW ( HANDLE  file,
LPSECURITY_ATTRIBUTES  sa,
DWORD  protect,
DWORD  size_high,
DWORD  size_low,
LPCWSTR  name,
DWORD  node 
)

Definition at line 1419 of file memory.c.

1422{
1423 if (node) FIXME( "Ignoring preferred node %lu\n", node );
1424 return CreateFileMappingW( file, sa, protect, size_high, size_low, name );
1425}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
Definition: fci.c:127
Definition: name.c:39

◆ CreateMemoryResourceNotification()

HANDLE WINAPI DECLSPEC_HOTPATCH CreateMemoryResourceNotification ( MEMORY_RESOURCE_NOTIFICATION_TYPE  type)

Definition at line 1238 of file memory.c.

1239{
1240 HANDLE ret;
1243
1244 switch (type)
1245 {
1246 case LowMemoryResourceNotification:
1247 RtlInitUnicodeString( &nameW, L"\\KernelObjects\\LowMemoryCondition" );
1248 break;
1249 case HighMemoryResourceNotification:
1250 RtlInitUnicodeString( &nameW, L"\\KernelObjects\\HighMemoryCondition" );
1251 break;
1252 default:
1254 return 0;
1255 }
1256
1258 if (!set_ntstatus( NtOpenEvent( &ret, EVENT_ALL_ACCESS, &attr ))) return 0;
1259 return ret;
1260}
static const WCHAR nameW[]
Definition: main.c:49
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtOpenEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: event.c:181
Definition: cookie.c:202

◆ DiscardVirtualMemory()

DWORD WINAPI DECLSPEC_HOTPATCH DiscardVirtualMemory ( void addr,
SIZE_T  size 
)

Definition at line 103 of file memory.c.

104{
106 LPVOID ret = addr;
107
110}
LONG NTSTATUS
Definition: precomp.h:26
GLsizeiptr size
Definition: glext.h:5919
GLenum const GLvoid * addr
Definition: glext.h:9621
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define MEM_RESET
Definition: nt_native.h:1320
#define PAGE_NOACCESS
Definition: nt_native.h:1302
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4452
Definition: ps.c:97

◆ EnumSystemFirmwareTables()

UINT WINAPI EnumSystemFirmwareTables ( DWORD  provider,
void buffer,
DWORD  size 
)

Definition at line 1817 of file memory.c.

1818{
1819 TRACE( "(0x%08lx, %p, %ld)\n", provider, buffer, size );
1820
1822}
static UINT get_firmware_table(DWORD provider, SYSTEM_FIRMWARE_TABLE_ACTION action, DWORD id, void *buffer, DWORD size)
Definition: memory.c:1788
GLuint buffer
Definition: glext.h:5915
@ SystemFirmwareTable_Enumerate
#define TRACE(s)
Definition: solgame.cpp:4

◆ fill_system_info()

static void fill_system_info ( SYSTEM_INFO si,
const SYSTEM_BASIC_INFORMATION basic_info,
const SYSTEM_CPU_INFORMATION cpu_info 
)
static

Definition at line 150 of file memory.c.

152{
153 si->wProcessorArchitecture = cpu_info->ProcessorArchitecture;
154 si->wReserved = 0;
155 si->dwPageSize = basic_info->PageSize;
156 si->lpMinimumApplicationAddress = basic_info->LowestUserAddress;
157 si->lpMaximumApplicationAddress = basic_info->HighestUserAddress;
161 si->wProcessorLevel = cpu_info->ProcessorLevel;
162 si->wProcessorRevision = cpu_info->ProcessorRevision;
163
164 switch (cpu_info->ProcessorArchitecture)
165 {
167 switch (cpu_info->ProcessorLevel)
168 {
169 case 3: si->dwProcessorType = PROCESSOR_INTEL_386; break;
170 case 4: si->dwProcessorType = PROCESSOR_INTEL_486; break;
171 case 5:
172 case 6: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
173 default: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
174 }
175 break;
178 break;
180 switch (cpu_info->ProcessorLevel)
181 {
182 case 4: si->dwProcessorType = PROCESSOR_ARM_7TDMI; break;
183 default: si->dwProcessorType = PROCESSOR_ARM920;
184 }
185 break;
186 case PROCESSOR_ARCHITECTURE_ARM64:
187 si->dwProcessorType = 0;
188 break;
189 default:
190 FIXME( "Unknown processor architecture %x\n", cpu_info->ProcessorArchitecture );
191 si->dwProcessorType = 0;
192 break;
193 }
194}
#define PROCESSOR_ARCHITECTURE_ARM
Definition: ketypes.h:110
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
KAFFINITY ActiveProcessorsAffinityMask
Definition: ntddk_ex.h:167
DWORD dwPageSize
Definition: winbase.h:1214
DWORD_PTR dwActiveProcessorMask
Definition: winbase.h:1217
DWORD dwAllocationGranularity
Definition: winbase.h:1220
DWORD dwNumberOfProcessors
Definition: winbase.h:1218
WORD wProcessorLevel
Definition: winbase.h:1221
DWORD dwProcessorType
Definition: winbase.h:1219
WORD wProcessorRevision
Definition: winbase.h:1222
PVOID lpMinimumApplicationAddress
Definition: winbase.h:1215
WORD wProcessorArchitecture
Definition: winbase.h:1210
WORD wReserved
Definition: winbase.h:1211
PVOID lpMaximumApplicationAddress
Definition: winbase.h:1216
#define PROCESSOR_INTEL_PENTIUM
Definition: winnt_old.h:454
#define PROCESSOR_INTEL_386
Definition: winnt_old.h:452
#define PROCESSOR_ARM920
Definition: winnt_old.h:475
#define PROCESSOR_AMD_X8664
Definition: winnt_old.h:463
#define PROCESSOR_ARM_7TDMI
Definition: winnt_old.h:476
#define PROCESSOR_INTEL_486
Definition: winnt_old.h:453

Referenced by GetNativeSystemInfo(), and GetSystemInfo().

◆ FlushInstructionCache()

BOOL WINAPI DECLSPEC_HOTPATCH FlushInstructionCache ( HANDLE  process,
LPCVOID  addr,
SIZE_T  size 
)

Definition at line 128 of file memory.c.

129{
130 CROSS_PROCESS_WORK_LIST *list;
131
133 {
134 send_cross_process_notification( list, CrossProcessFlushCache, addr, size, 0 );
136 }
138}
static void close_cross_process_connection(CROSS_PROCESS_WORK_LIST *list)
Definition: memory.c:60
static void send_cross_process_notification(CROSS_PROCESS_WORK_LIST *list, UINT id, const void *addr, SIZE_T size, int nb_args,...)
Definition: memory.c:65
static CROSS_PROCESS_WORK_LIST * open_cross_process_connection(HANDLE process)
Definition: memory.c:46
NTSTATUS NTAPI NtFlushInstructionCache(_In_ HANDLE ProcessHandle, _In_opt_ PVOID BaseAddress, _In_ SIZE_T FlushSize)
Definition: virtual.c:3004
#define list
Definition: rosglue.h:35

◆ FlushViewOfFile()

BOOL WINAPI DECLSPEC_HOTPATCH FlushViewOfFile ( const void base,
SIZE_T  size 
)

Definition at line 116 of file memory.c.

117{
119
121 return set_ntstatus( status );
122}
NTSTATUS NTAPI NtFlushVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T NumberOfBytesToFlush, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: virtual.c:3995
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NOT_MAPPED_DATA
Definition: udferr_usr.h:157

◆ FreeUserPhysicalPages()

BOOL WINAPI DECLSPEC_HOTPATCH FreeUserPhysicalPages ( HANDLE  process,
ULONG_PTR pages,
ULONG_PTR userarray 
)

Definition at line 1301 of file memory.c.

1303{
1304 FIXME( "stub: %p %p %p\n", process, pages, userarray );
1305 *pages = 0;
1307 return FALSE;
1308}

◆ get_firmware_table()

static UINT get_firmware_table ( DWORD  provider,
SYSTEM_FIRMWARE_TABLE_ACTION  action,
DWORD  id,
void buffer,
DWORD  size 
)
static

Definition at line 1788 of file memory.c.

1790{
1794
1796 {
1798 return 0;
1799 }
1800
1801 info->ProviderSignature = provider;
1802 info->Action = action;
1803 info->TableID = id;
1804
1808 if (buffer_size <= size) memcpy( buffer, info->TableBuffer, buffer_size );
1809
1810 HeapFree( GetProcessHeap(), 0, info );
1812}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
action
Definition: namespace.c:707
GLuint id
Definition: glext.h:5910
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
@ SystemFirmwareTableInformation
Definition: extypes.h:293
#define offsetof(TYPE, MEMBER)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
uint32_t ULONG
Definition: typedefs.h:59

Referenced by EnumSystemFirmwareTables(), and GetSystemFirmwareTable().

◆ GetLargePageMinimum()

SIZE_T WINAPI GetLargePageMinimum ( void  )

Definition at line 144 of file memory.c.

145{
146 return 2 * 1024 * 1024;
147}

◆ GetLogicalProcessorInformation()

BOOL WINAPI DECLSPEC_HOTPATCH GetLogicalProcessorInformation ( SYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer,
DWORD len 
)

Definition at line 1431 of file memory.c.

1433{
1435
1436 if (!len)
1437 {
1439 return FALSE;
1440 }
1443 return set_ntstatus( status );
1444}
GLenum GLsizei len
Definition: glext.h:6722
@ SystemLogicalProcessorInformation
Definition: extypes.h:290
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133

◆ GetLogicalProcessorInformationEx()

BOOL WINAPI DECLSPEC_HOTPATCH GetLogicalProcessorInformationEx ( LOGICAL_PROCESSOR_RELATIONSHIP  relationship,
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer,
DWORD len 
)

Definition at line 1450 of file memory.c.

1452{
1454
1455 if (!len)
1456 {
1458 return FALSE;
1459 }
1461 sizeof(relationship), buffer, *len, len );
1463 return set_ntstatus( status );
1464}
NTSYSAPI NTSTATUS WINAPI NtQuerySystemInformationEx(SYSTEM_INFORMATION_CLASS, void *, ULONG, void *, ULONG, ULONG *)
@ SystemLogicalProcessorInformationEx
Definition: winternl.h:1001

◆ GetNativeSystemInfo()

void WINAPI DECLSPEC_HOTPATCH GetNativeSystemInfo ( SYSTEM_INFO si)

Definition at line 200 of file memory.c.

201{
202 SYSTEM_BASIC_INFORMATION basic_info;
203 SYSTEM_CPU_INFORMATION cpu_info;
204
205 if (is_wow64)
206 {
207 USHORT current_machine, native_machine;
208
209 RtlWow64GetProcessMachines( 0, &current_machine, &native_machine );
210 if (native_machine != IMAGE_FILE_MACHINE_AMD64)
211 {
212 GetSystemInfo( si );
214 return;
215 }
216 }
217
218 if (!set_ntstatus( RtlGetNativeSystemInformation( SystemBasicInformation,
219 &basic_info, sizeof(basic_info), NULL )) ||
220 !set_ntstatus( RtlGetNativeSystemInformation( SystemCpuInformation,
221 &cpu_info, sizeof(cpu_info), NULL )))
222 return;
223
224 fill_system_info( si, &basic_info, &cpu_info );
225}
static void fill_system_info(SYSTEM_INFO *si, const SYSTEM_BASIC_INFORMATION *basic_info, const SYSTEM_CPU_INFORMATION *cpu_info)
Definition: memory.c:150
void WINAPI DECLSPEC_HOTPATCH GetSystemInfo(SYSTEM_INFO *si)
Definition: memory.c:231
@ SystemBasicInformation
Definition: ntddk_ex.h:11
@ SystemCpuInformation
Definition: winternl.h:921
BOOL is_wow64
Definition: main.c:38
#define IMAGE_FILE_MACHINE_AMD64
Definition: ntimage.h:17
unsigned short USHORT
Definition: pedump.c:61

◆ GetNumaHighestNodeNumber()

BOOL WINAPI DECLSPEC_HOTPATCH GetNumaHighestNodeNumber ( ULONG node)

Definition at line 1508 of file memory.c.

1509{
1510 FIXME( "semi-stub: %p\n", node );
1511 *node = 0;
1512 return TRUE;
1513}
#define TRUE
Definition: types.h:120

◆ GetNumaNodeProcessorMaskEx()

BOOL WINAPI DECLSPEC_HOTPATCH GetNumaNodeProcessorMaskEx ( USHORT  node,
GROUP_AFFINITY mask 
)

Definition at line 1519 of file memory.c.

1520{
1521 FIXME( "stub: %hu %p\n", node, mask );
1523 return FALSE;
1524}
GLenum GLint GLuint mask
Definition: glext.h:6028

◆ GetNumaProximityNodeEx()

BOOL WINAPI DECLSPEC_HOTPATCH GetNumaProximityNodeEx ( ULONG  proximity_id,
USHORT node 
)

Definition at line 1530 of file memory.c.

1531{
1533 return FALSE;
1534}

◆ GetPhysicallyInstalledSystemMemory()

BOOL WINAPI DECLSPEC_HOTPATCH GetPhysicallyInstalledSystemMemory ( ULONGLONG memory)

Definition at line 1314 of file memory.c.

1315{
1316 MEMORYSTATUSEX status;
1317
1318 if (!memory)
1319 {
1321 return FALSE;
1322 }
1323 status.dwLength = sizeof(status);
1325 *memory = status.ullTotalPhys / 1024;
1326 return TRUE;
1327}
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
Definition: heapmem.c:1272
static char memory[1024 *256]
Definition: process.c:116

◆ GetSystemCpuSetInformation()

BOOL WINAPI GetSystemCpuSetInformation ( SYSTEM_CPU_SET_INFORMATION *  info,
ULONG  buffer_length,
ULONG return_length,
HANDLE  process,
ULONG  flags 
)

Definition at line 1470 of file memory.c.

1472{
1473 if (flags)
1474 FIXME("Unsupported flags %#lx.\n", flags);
1475
1476 *return_length = 0;
1477
1478 return set_ntstatus( NtQuerySystemInformationEx( SystemCpuSetInformation, &process, sizeof(process), info,
1479 buffer_length, return_length ));
1480}
GLbitfield flags
Definition: glext.h:7161

◆ GetSystemFileCacheSize()

BOOL WINAPI DECLSPEC_HOTPATCH GetSystemFileCacheSize ( SIZE_T mincache,
SIZE_T maxcache,
DWORD flags 
)

Definition at line 249 of file memory.c.

250{
251 FIXME( "stub: %p %p %p\n", mincache, maxcache, flags );
253 return FALSE;
254}

◆ GetSystemFirmwareTable()

UINT WINAPI GetSystemFirmwareTable ( DWORD  provider,
DWORD  id,
void buffer,
DWORD  size 
)

Definition at line 1827 of file memory.c.

1828{
1829 TRACE( "(0x%08lx, 0x%08lx, %p, %ld)\n", provider, id, buffer, size );
1830
1831 return get_firmware_table( provider, SystemFirmwareTable_Get, id, buffer, size );
1832}
@ SystemFirmwareTable_Get

◆ GetSystemInfo()

void WINAPI DECLSPEC_HOTPATCH GetSystemInfo ( SYSTEM_INFO si)

Definition at line 231 of file memory.c.

232{
233 SYSTEM_BASIC_INFORMATION basic_info;
234 SYSTEM_CPU_INFORMATION cpu_info;
235
237 &basic_info, sizeof(basic_info), NULL )) ||
239 &cpu_info, sizeof(cpu_info), NULL )))
240 return;
241
242 fill_system_info( si, &basic_info, &cpu_info );
243}

Referenced by GetNativeSystemInfo().

◆ GetWriteWatch()

UINT WINAPI DECLSPEC_HOTPATCH GetWriteWatch ( DWORD  flags,
void base,
SIZE_T  size,
void **  addresses,
ULONG_PTR count,
ULONG granularity 
)

Definition at line 260 of file memory.c.

262{
264 addresses, count, granularity )))
265 return ~0u;
266 return 0;
267}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
NTSTATUS NTAPI NtGetWriteWatch(IN HANDLE ProcessHandle, IN ULONG Flags, IN PVOID BaseAddress, IN SIZE_T RegionSize, IN PVOID *UserAddressArray, OUT PULONG_PTR EntriesInUserAddressArray, OUT PULONG Granularity)
Definition: virtual.c:4117

◆ GlobalAlloc()

HGLOBAL WINAPI DECLSPEC_HOTPATCH GlobalAlloc ( UINT  flags,
SIZE_T  size 
)

Definition at line 951 of file memory.c.

952{
953 struct mem_entry *mem;
955
956 /* LocalAlloc allows a 0-size fixed block, but GlobalAlloc doesn't */
957 if (!(flags & GMEM_MOVEABLE) && !size) size = 1;
958
960
962 mem->flags |= MEM_FLAG_DDESHARE;
963
964 return handle;
965}
#define MEM_FLAG_DDESHARE
Definition: memory.c:887
static struct mem_entry * unsafe_mem_from_HLOCAL(HLOCAL handle)
Definition: memory.c:909
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalAlloc(UINT flags, SIZE_T size)
Definition: memory.c:980
Definition: memory.c:890
Definition: mem.c:349
#define GMEM_MOVEABLE
Definition: winbase.h:327
#define GMEM_DDESHARE
Definition: winbase.h:331

◆ GlobalFree()

HGLOBAL WINAPI DECLSPEC_HOTPATCH GlobalFree ( HLOCAL  handle)

Definition at line 971 of file memory.c.

972{
973 return LocalFree( handle );
974}
HLOCAL WINAPI DECLSPEC_HOTPATCH LocalFree(HLOCAL handle)
Definition: memory.c:1040

◆ GlobalMemoryStatusEx()

BOOL WINAPI DECLSPEC_HOTPATCH GlobalMemoryStatusEx ( MEMORYSTATUSEX *  status)

Definition at line 1333 of file memory.c.

1334{
1335 static MEMORYSTATUSEX cached_status;
1336 static DWORD last_check;
1337 SYSTEM_BASIC_INFORMATION basic_info;
1339 VM_COUNTERS_EX vmc;
1340
1341 if (status->dwLength != sizeof(*status))
1342 {
1344 return FALSE;
1345 }
1346 if ((NtGetTickCount() - last_check) < 1000)
1347 {
1348 *status = cached_status;
1349 return TRUE;
1350 }
1351 last_check = NtGetTickCount();
1352
1354 &basic_info, sizeof(basic_info), NULL )) ||
1356 &perf_info, sizeof(perf_info), NULL)) ||
1358 &vmc, sizeof(vmc), NULL )))
1359 return FALSE;
1360
1361 status->dwMemoryLoad = 0;
1362 status->ullTotalPhys = basic_info.MmNumberOfPhysicalPages;
1363 status->ullAvailPhys = perf_info.AvailablePages;
1364 status->ullTotalPageFile = perf_info.TotalCommitLimit;
1365 status->ullAvailPageFile = status->ullTotalPageFile - perf_info.TotalCommittedPages;
1366 status->ullTotalVirtual = (ULONG_PTR)basic_info.HighestUserAddress - (ULONG_PTR)basic_info.LowestUserAddress + 1;
1367 status->ullAvailVirtual = status->ullTotalVirtual - (ULONGLONG)vmc.WorkingSetSize /* approximate */;
1368 status->ullAvailExtendedVirtual = 0;
1369
1370 status->ullTotalPhys *= basic_info.PageSize;
1371 status->ullAvailPhys *= basic_info.PageSize;
1372 status->ullTotalPageFile *= basic_info.PageSize;
1373 status->ullAvailPageFile *= basic_info.PageSize;
1374
1375 if (status->ullTotalPhys)
1376 status->dwMemoryLoad = (status->ullTotalPhys - status->ullAvailPhys) / (status->ullTotalPhys / 100);
1377
1378 TRACE_(virtual)( "MemoryLoad %lu, TotalPhys %I64u, AvailPhys %I64u, TotalPageFile %I64u, "
1379 "AvailPageFile %I64u, TotalVirtual %I64u, AvailVirtual %I64u\n",
1380 status->dwMemoryLoad, status->ullTotalPhys, status->ullAvailPhys, status->ullTotalPageFile,
1381 status->ullAvailPageFile, status->ullTotalVirtual, status->ullAvailVirtual );
1382
1383 cached_status = *status;
1384 return TRUE;
1385}
#define TRACE_(x)
Definition: compat.h:76
#define ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
@ ProcessVmCounters
Definition: winternl.h:859
if(dx< 0)
Definition: linetemp.h:194
#define SystemPerformanceInformation
Definition: memtest.h:87
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#define NtGetTickCount
Definition: rtlp.h:163
SIZE_T WorkingSetSize
Definition: pstypes.h:110
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint64_t ULONGLONG
Definition: typedefs.h:67

◆ HeapCompact()

SIZE_T WINAPI DECLSPEC_HOTPATCH HeapCompact ( HANDLE  heap,
DWORD  flags 
)

Definition at line 716 of file memory.c.

717{
718 return RtlCompactHeap( heap, flags );
719}
NTSYSAPI ULONG WINAPI RtlCompactHeap(HANDLE, ULONG)
Definition: heap.c:3103
static HANDLE heap
Definition: heap.c:65

◆ HeapCreate()

HANDLE WINAPI DECLSPEC_HOTPATCH HeapCreate ( DWORD  flags,
SIZE_T  init_size,
SIZE_T  max_size 
)

Definition at line 725 of file memory.c.

726{
727 HANDLE ret = RtlCreateHeap( flags, NULL, max_size, init_size, NULL, NULL );
729 return ret;
730}
static INT max_size
Definition: history.c:51
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSYSAPI PVOID NTAPI RtlCreateHeap(IN ULONG Flags, IN PVOID HeapBase OPTIONAL, IN ULONG ReserveSize OPTIONAL, IN ULONG CommitSize OPTIONAL, IN PVOID Lock OPTIONAL, IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL)

◆ HeapDestroy()

BOOL WINAPI DECLSPEC_HOTPATCH HeapDestroy ( HANDLE  heap)

Definition at line 736 of file memory.c.

737{
738 if (!RtlDestroyHeap( heap )) return TRUE;
740 return FALSE;
741}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
NTSYSAPI PVOID NTAPI RtlDestroyHeap(IN PVOID HeapHandle)

◆ HeapLock()

BOOL WINAPI DECLSPEC_HOTPATCH HeapLock ( HANDLE  heap)

Definition at line 747 of file memory.c.

748{
749 return RtlLockHeap( heap );
750}
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)

◆ HeapQueryInformation()

BOOL WINAPI HeapQueryInformation ( HANDLE  heap,
HEAP_INFORMATION_CLASS  info_class,
PVOID  info,
SIZE_T  size,
PSIZE_T  size_out 
)

Definition at line 756 of file memory.c.

758{
760}
NTSYSAPI NTSTATUS WINAPI RtlQueryHeapInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T)
static PIO_STATUS_BLOCK void ULONG FS_INFORMATION_CLASS info_class
Definition: pipe.c:76

◆ HeapSetInformation()

BOOL WINAPI HeapSetInformation ( HANDLE  heap,
HEAP_INFORMATION_CLASS  infoclass,
PVOID  info,
SIZE_T  size 
)

Definition at line 766 of file memory.c.

767{
768 return set_ntstatus( RtlSetHeapInformation( heap, infoclass, info, size ));
769}
NTSYSAPI NTSTATUS WINAPI RtlSetHeapInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T)

◆ HeapUnlock()

BOOL WINAPI HeapUnlock ( HANDLE  heap)

Definition at line 775 of file memory.c.

776{
777 return RtlUnlockHeap( heap );
778}
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3162

◆ HeapValidate()

BOOL WINAPI DECLSPEC_HOTPATCH HeapValidate ( HANDLE  heap,
DWORD  flags,
LPCVOID  ptr 
)

Definition at line 784 of file memory.c.

785{
786 return RtlValidateHeap( heap, flags, ptr );
787}
NTSYSAPI BOOLEAN WINAPI RtlValidateHeap(HANDLE, ULONG, LPCVOID)
static PVOID ptr
Definition: dispmode.c:27

Referenced by LocalFree(), and LocalReAlloc().

◆ HeapWalk()

BOOL WINAPI DECLSPEC_HOTPATCH HeapWalk ( HANDLE  heap,
PROCESS_HEAP_ENTRY entry 
)

Definition at line 826 of file memory.c.

827{
828 struct rtl_heap_entry rtl_entry = {0};
830
832
833 rtl_entry.lpData = entry->lpData;
834 rtl_entry.cbData = entry->cbData;
835 rtl_entry.cbOverhead = entry->cbOverhead;
836 rtl_entry.iRegionIndex = entry->iRegionIndex;
837
838 if (entry->wFlags & PROCESS_HEAP_ENTRY_BUSY)
839 rtl_entry.wFlags |= RTL_HEAP_ENTRY_BUSY;
840 if (entry->wFlags & PROCESS_HEAP_REGION)
841 rtl_entry.wFlags |= RTL_HEAP_ENTRY_REGION;
844 memcpy( &rtl_entry.Region, &entry->Region, sizeof(entry->Region) );
845
846 if (!(status = RtlWalkHeap( heap, &rtl_entry )))
847 {
848 entry->lpData = rtl_entry.lpData;
849 entry->cbData = rtl_entry.cbData;
850 entry->cbOverhead = rtl_entry.cbOverhead;
851 entry->iRegionIndex = rtl_entry.iRegionIndex;
852
853 if (rtl_entry.wFlags & RTL_HEAP_ENTRY_BUSY)
855 else if (rtl_entry.wFlags & RTL_HEAP_ENTRY_REGION)
856 entry->wFlags = PROCESS_HEAP_REGION;
857 else if (rtl_entry.wFlags & RTL_HEAP_ENTRY_UNCOMMITTED)
859 else
860 entry->wFlags = 0;
861
862 memcpy( &entry->Region, &rtl_entry.Region, sizeof(entry->Region) );
863 }
864
865 return set_ntstatus( status );
866}
#define RTL_HEAP_ENTRY_BUSY
Definition: memory.c:815
#define RTL_HEAP_ENTRY_REGION
Definition: memory.c:816
#define RTL_HEAP_ENTRY_UNCOMMITTED
Definition: memory.c:818
NTSYSAPI NTSTATUS WINAPI RtlWalkHeap(HANDLE, PVOID)
uint32_t entry
Definition: isohybrid.c:63
Definition: memory.c:793
BYTE cbOverhead
Definition: memory.c:796
WORD wFlags
Definition: memory.c:798
LPVOID lpData
Definition: memory.c:794
struct rtl_heap_entry::@518::@521 Region
SIZE_T cbData
Definition: memory.c:795
BYTE iRegionIndex
Definition: memory.c:797
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define PROCESS_HEAP_UNCOMMITTED_RANGE
Definition: winbase.h:368
#define PROCESS_HEAP_ENTRY_BUSY
Definition: winbase.h:369
#define PROCESS_HEAP_REGION
Definition: winbase.h:367

◆ HLOCAL_from_mem()

static HLOCAL HLOCAL_from_mem ( struct mem_entry mem)
inlinestatic

Definition at line 919 of file memory.c.

920{
921 if (!mem) return 0;
922 return &mem->ptr;
923}

Referenced by LocalAlloc().

◆ init_global_data()

void init_global_data ( void  )

Definition at line 931 of file memory.c.

932{
934 if (!(next_free_mem = global_data.mem_entries)) ERR( "Failed to allocate kernelbase global handle table\n" );
935 global_data.mem_entries_end = global_data.mem_entries + MAX_MEM_HANDLES;
936}
#define ERR(fmt,...)
Definition: precomp.h:57
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc(void *addr, SIZE_T size, DWORD type, DWORD protect)
Definition: memory.c:415
#define MAX_MEM_HANDLES
Definition: memory.c:905
static struct kernelbase_global_data global_data
Definition: memory.c:907
static struct mem_entry * next_free_mem
Definition: memory.c:906
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define MEM_COMMIT
Definition: nt_native.h:1313

Referenced by DllMain().

◆ InitializeContext()

BOOL WINAPI InitializeContext ( void buffer,
DWORD  context_flags,
CONTEXT **  context,
DWORD length 
)

Definition at line 1625 of file memory.c.

1626{
1627 return InitializeContext2( buffer, context_flags, context, length, ~(ULONG64)0 );
1628}
BOOL WINAPI InitializeContext2(void *buffer, DWORD context_flags, CONTEXT **context, DWORD *length, ULONG64 compaction_mask)
Definition: memory.c:1585
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
unsigned __int64 ULONG64
Definition: imports.h:198
Definition: http.c:7252

Referenced by DosBootsectorInitialize(), DosKRNLInitialize(), DosMouseInitialize(), DosStart(), InitializeBiosInt32(), and KsCreateDefaultAllocatorEx().

◆ InitializeContext2()

BOOL WINAPI InitializeContext2 ( void buffer,
DWORD  context_flags,
CONTEXT **  context,
DWORD length,
ULONG64  compaction_mask 
)

Definition at line 1585 of file memory.c.

1587{
1588 ULONG orig_length;
1590
1591 TRACE( "buffer %p, context_flags %#lx, context %p, ret_length %p, compaction_mask %s.\n",
1592 buffer, context_flags, context, length, wine_dbgstr_longlong(compaction_mask) );
1593
1594 orig_length = *length;
1595
1596 if ((status = RtlGetExtendedContextLength2( context_flags, length, compaction_mask )))
1597 {
1598 if (status == STATUS_NOT_SUPPORTED && context_flags & 0x40)
1599 {
1600 context_flags &= ~0x40;
1601 status = RtlGetExtendedContextLength2( context_flags, length, compaction_mask );
1602 }
1603
1604 if (status)
1605 return set_ntstatus( status );
1606 }
1607
1608 if (!buffer || orig_length < *length)
1609 {
1611 return FALSE;
1612 }
1613
1614 if ((status = RtlInitializeExtendedContext2( buffer, context_flags, (CONTEXT_EX **)context, compaction_mask )))
1615 return set_ntstatus( status );
1616
1617 *context = (CONTEXT *)((BYTE *)*context + (*(CONTEXT_EX **)context)->Legacy.Offset);
1618
1619 return TRUE;
1620}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
unsigned char BYTE
Definition: xxhash.c:193

Referenced by InitializeContext().

◆ is_exec_prot()

static BOOL is_exec_prot ( DWORD  protect)
static

Definition at line 449 of file memory.c.

450{
451 return protect == PAGE_EXECUTE || protect == PAGE_EXECUTE_READ || protect == PAGE_EXECUTE_READWRITE
452 || protect == PAGE_EXECUTE_WRITECOPY;
453}
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define PAGE_EXECUTE
Definition: nt_native.h:1306
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1309
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308

Referenced by VirtualAlloc2FromApp(), and VirtualAllocFromApp().

◆ IsBadStringPtrA()

BOOL WINAPI IsBadStringPtrA ( LPCSTR  str,
UINT_PTR  max 
)

Definition at line 673 of file memory.c.

674{
675 if (!str) return TRUE;
676 __TRY
677 {
678 volatile const char *p = str;
679 while (p != str + max) if (!*p++) break;
680 }
682 {
683 return TRUE;
684 }
686 return FALSE;
687}
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
GLfloat GLfloat p
Definition: glext.h:8902
const WCHAR * str
#define max(a, b)
Definition: svc.c:63

◆ IsBadStringPtrW()

BOOL WINAPI IsBadStringPtrW ( LPCWSTR  str,
UINT_PTR  max 
)

Definition at line 691 of file memory.c.

692{
693 if (!str) return TRUE;
694 __TRY
695 {
696 volatile const WCHAR *p = str;
697 while (p != str + max) if (!*p++) break;
698 }
700 {
701 return TRUE;
702 }
704 return FALSE;
705}
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ KernelBaseGetGlobalData()

void *WINAPI KernelBaseGetGlobalData ( void  )

Definition at line 941 of file memory.c.

942{
943 WARN_(globalmem)( "semi-stub!\n" );
944 return &global_data;
945}
#define WARN_(ch,...)
Definition: debug.h:157

◆ LocalAlloc()

HLOCAL WINAPI DECLSPEC_HOTPATCH LocalAlloc ( UINT  flags,
SIZE_T  size 
)

Definition at line 980 of file memory.c.

981{
982 DWORD heap_flags = 0x200 | HEAP_ADD_USER_INFO;
984 struct mem_entry *mem;
986 void *ptr;
987
988 TRACE_(globalmem)( "flags %#x, size %#Ix\n", flags, size );
989
990 if (flags & LMEM_ZEROINIT) heap_flags |= HEAP_ZERO_MEMORY;
991
992 if (!(flags & LMEM_MOVEABLE)) /* pointer */
993 {
994 ptr = HeapAlloc( heap, heap_flags, size );
995 if (ptr) RtlSetUserValueHeap( heap, heap_flags, ptr, ptr );
996 TRACE_(globalmem)( "return %p\n", ptr );
997 return ptr;
998 }
999
1000 RtlLockHeap( heap );
1001 if ((mem = next_free_mem) < global_data.mem_entries || mem >= global_data.mem_entries_end)
1002 mem = NULL;
1003 else
1004 {
1005 if (!mem->next_free) next_free_mem++;
1006 else next_free_mem = mem->next_free;
1007 mem->next_free = NULL;
1008 }
1010
1011 if (!mem) goto failed;
1013
1016 mem->lock = 0;
1017 mem->ptr = NULL;
1018
1019 if (!size) mem->flags |= MEM_FLAG_DISCARDED;
1020 else
1021 {
1022 if (!(ptr = HeapAlloc( heap, heap_flags, size ))) goto failed;
1023 RtlSetUserValueHeap( heap, heap_flags, ptr, handle );
1024 mem->ptr = ptr;
1025 }
1026
1027 TRACE_(globalmem)( "return handle %p, ptr %p\n", handle, mem->ptr );
1028 return handle;
1029
1030failed:
1031 if (mem) LocalFree( *(volatile HANDLE *)&handle );
1033 return 0;
1034}
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define MEM_FLAG_MOVEABLE
Definition: memory.c:884
#define MEM_FLAG_DISCARDED
Definition: memory.c:886
#define HEAP_ADD_USER_INFO
Definition: memory.c:874
static HLOCAL HLOCAL_from_mem(struct mem_entry *mem)
Definition: memory.c:919
#define MEM_FLAG_USED
Definition: memory.c:883
#define MEM_FLAG_DISCARDABLE
Definition: memory.c:885
BOOLEAN NTAPI RtlSetUserValueHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, IN PVOID UserValue)
Definition: heap.c:3817
#define LMEM_MOVEABLE
Definition: winbase.h:402
#define LMEM_ZEROINIT
Definition: winbase.h:408
#define LMEM_DISCARDABLE
Definition: winbase.h:405

Referenced by Dns_AllocZero(), and GlobalAlloc().

◆ LocalFree()

HLOCAL WINAPI DECLSPEC_HOTPATCH LocalFree ( HLOCAL  handle)

Definition at line 1040 of file memory.c.

1041{
1043 struct mem_entry *mem;
1044 HLOCAL ret = handle;
1045 void *ptr;
1046
1047 TRACE_(globalmem)( "handle %p\n", handle );
1048
1049 RtlLockHeap( heap );
1050 if ((ptr = unsafe_ptr_from_HLOCAL( handle )) &&
1052 {
1053 if (HeapFree( heap, HEAP_NO_SERIALIZE, ptr )) ret = 0;
1054 }
1055 else if ((mem = unsafe_mem_from_HLOCAL( handle )))
1056 {
1057 if (HeapFree( heap, HEAP_NO_SERIALIZE, mem->ptr )) ret = 0;
1058 mem->ptr = NULL;
1059 mem->next_free = next_free_mem;
1061 }
1063
1064 if (ret)
1065 {
1066 WARN_(globalmem)( "invalid handle %p\n", handle );
1068 }
1069 return ret;
1070}
BOOL WINAPI DECLSPEC_HOTPATCH HeapValidate(HANDLE heap, DWORD flags, LPCVOID ptr)
Definition: memory.c:784
static void * unsafe_ptr_from_HLOCAL(HLOCAL handle)
Definition: memory.c:925
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692

Referenced by Dns_Free(), GlobalFree(), and LocalAlloc().

◆ LocalLock()

LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock ( HLOCAL  handle)

Definition at line 1076 of file memory.c.

1077{
1079 struct mem_entry *mem;
1080 void *ret = NULL;
1081
1082 TRACE_(globalmem)( "handle %p\n", handle );
1083
1084 if (!handle) return NULL;
1086 {
1087 __TRY
1088 {
1089 volatile char *p = ret;
1090 *p |= 0;
1091 }
1093 {
1094 return NULL;
1095 }
1096 __ENDTRY
1097 return ret;
1098 }
1099
1100 RtlLockHeap( heap );
1102 {
1103 if (!(ret = mem->ptr)) SetLastError( ERROR_DISCARDED );
1104 else if (!++mem->lock) mem->lock--;
1105 }
1106 else
1107 {
1108 WARN_(globalmem)( "invalid handle %p\n", handle );
1110 }
1112
1113 return ret;
1114}
#define ERROR_DISCARDED
Definition: winerror.h:229

◆ LocalReAlloc()

HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc ( HLOCAL  handle,
SIZE_T  size,
UINT  flags 
)

Definition at line 1120 of file memory.c.

1121{
1122 DWORD heap_flags = 0x200 | HEAP_ADD_USER_INFO | HEAP_NO_SERIALIZE;
1124 struct mem_entry *mem;
1125 HLOCAL ret = 0;
1126 void *ptr;
1127
1128 TRACE_(globalmem)( "handle %p, size %#Ix, flags %#x\n", handle, size, flags );
1129
1130 if (flags & LMEM_ZEROINIT) heap_flags |= HEAP_ZERO_MEMORY;
1131
1132 RtlLockHeap( heap );
1133 if ((ptr = unsafe_ptr_from_HLOCAL( handle )) &&
1135 {
1136 if (flags & LMEM_MODIFY) ret = handle;
1138 else
1139 {
1140 if (!(flags & LMEM_MOVEABLE)) heap_flags |= HEAP_REALLOC_IN_PLACE_ONLY;
1141 ret = HeapReAlloc( heap, heap_flags, ptr, size );
1142 if (ret) RtlSetUserValueHeap( heap, heap_flags, ret, ret );
1144 }
1145 }
1146 else if ((mem = unsafe_mem_from_HLOCAL( handle )))
1147 {
1148 if (flags & LMEM_MODIFY)
1149 {
1151 ret = handle;
1152 }
1154 else
1155 {
1156 if (size)
1157 {
1158 if (mem->lock && !(flags & LMEM_MOVEABLE)) heap_flags |= HEAP_REALLOC_IN_PLACE_ONLY;
1159 if (!mem->ptr) ptr = HeapAlloc( heap, heap_flags, size );
1160 else ptr = HeapReAlloc( heap, heap_flags, mem->ptr, size );
1161
1163 else
1164 {
1165 RtlSetUserValueHeap( heap, heap_flags, ptr, handle );
1166 mem->flags &= ~MEM_FLAG_DISCARDED;
1167 mem->ptr = ptr;
1168 ret = handle;
1169 }
1170 }
1171 else if ((flags & LMEM_MOVEABLE) && !mem->lock)
1172 {
1173 HeapFree( heap, heap_flags, mem->ptr );
1174 mem->flags |= MEM_FLAG_DISCARDED;
1175 mem->ptr = NULL;
1176 ret = handle;
1177 }
1179 }
1180 }
1183
1184 return ret;
1185}
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_REALLOC_IN_PLACE_ONLY
Definition: nt_native.h:1696
#define LMEM_MODIFY
Definition: winbase.h:410

◆ LocalUnlock()

BOOL WINAPI DECLSPEC_HOTPATCH LocalUnlock ( HLOCAL  handle)

Definition at line 1191 of file memory.c.

1192{
1194 struct mem_entry *mem;
1195 BOOL ret = FALSE;
1196
1197 TRACE_(globalmem)( "handle %p\n", handle );
1198
1200 {
1202 return FALSE;
1203 }
1204
1205 RtlLockHeap( heap );
1207 {
1208 if (mem->lock)
1209 {
1210 ret = (--mem->lock != 0);
1211 if (!ret) SetLastError( NO_ERROR );
1212 }
1213 else
1214 {
1215 WARN_(globalmem)( "handle %p not locked\n", handle );
1217 }
1218 }
1219 else
1220 {
1221 WARN_(globalmem)( "invalid handle %p\n", handle );
1223 }
1225
1226 return ret;
1227}
#define NO_ERROR
Definition: dderror.h:5
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_NOT_LOCKED
Definition: winerror.h:230

◆ MapUserPhysicalPages()

BOOL WINAPI DECLSPEC_HOTPATCH MapUserPhysicalPages ( void addr,
ULONG_PTR  page_count,
ULONG_PTR pages 
)

Definition at line 1391 of file memory.c.

1392{
1393 FIXME( "stub: %p %Iu %p\n", addr, page_count, pages );
1394 *pages = 0;
1396 return FALSE;
1397}

◆ MapViewOfFile()

LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile ( HANDLE  mapping,
DWORD  access,
DWORD  offset_high,
DWORD  offset_low,
SIZE_T  count 
)

Definition at line 273 of file memory.c.

275{
276 return MapViewOfFileEx( mapping, access, offset_high, offset_low, count, NULL );
277}
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileEx(HANDLE handle, DWORD access, DWORD offset_high, DWORD offset_low, SIZE_T count, LPVOID addr)
Definition: memory.c:283
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031

◆ MapViewOfFile3()

LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile3 ( HANDLE  handle,
HANDLE  process,
PVOID  baseaddr,
ULONG64  offset,
SIZE_T  size,
ULONG  alloc_type,
ULONG  protection,
MEM_EXTENDED_PARAMETER *  params,
ULONG  params_count 
)

Definition at line 326 of file memory.c.

328{
329 LARGE_INTEGER off;
330 void *addr;
331
333
334 addr = baseaddr;
335 off.QuadPart = offset;
336 if (!set_ntstatus( NtMapViewOfSectionEx( handle, process, &addr, &off, &size, alloc_type, protection,
337 params, params_count )))
338 {
339 return NULL;
340 }
341 return addr;
342}
GLintptr offset
Definition: glext.h:5920
GLenum const GLfloat * params
Definition: glext.h:5645
LONGLONG QuadPart
Definition: typedefs.h:114
type_t * alloc_type(void)

◆ MapViewOfFileEx()

LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileEx ( HANDLE  handle,
DWORD  access,
DWORD  offset_high,
DWORD  offset_low,
SIZE_T  count,
LPVOID  addr 
)

Definition at line 283 of file memory.c.

285{
288 ULONG protect;
289 BOOL exec;
290
291 offset.u.LowPart = offset_low;
292 offset.u.HighPart = offset_high;
293
294 exec = access & FILE_MAP_EXECUTE;
295 access &= ~FILE_MAP_EXECUTE;
296
297 if (access == FILE_MAP_COPY)
298 protect = exec ? PAGE_EXECUTE_WRITECOPY : PAGE_WRITECOPY;
299 else if (access & FILE_MAP_WRITE)
300 protect = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
301 else if (access & FILE_MAP_READ)
302 protect = exec ? PAGE_EXECUTE_READ : PAGE_READONLY;
303 else protect = PAGE_NOACCESS;
304
306 &count, ViewShare, 0, protect )) < 0)
307 {
309 addr = NULL;
310 }
311 return addr;
312}
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3257
#define PAGE_READONLY
Definition: compat.h:138
#define FILE_MAP_READ
Definition: compat.h:776
#define PAGE_WRITECOPY
Definition: nt_native.h:1305
@ ViewShare
Definition: nt_native.h:1278
#define FILE_MAP_WRITE
Definition: winbase.h:162
#define FILE_MAP_COPY
Definition: winbase.h:161
#define FILE_MAP_EXECUTE
Definition: winbase.h:165

Referenced by MapViewOfFile(), and MapViewOfFileExNuma().

◆ MapViewOfFileExNuma()

LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileExNuma ( HANDLE  handle,
DWORD  access,
DWORD  offset_high,
DWORD  offset_low,
SIZE_T  count,
LPVOID  addr,
DWORD  node 
)

Definition at line 1540 of file memory.c.

1543{
1544 if (node) FIXME( "Ignoring preferred node %lu\n", node );
1545 return MapViewOfFileEx( handle, access, offset_high, offset_low, count, addr );
1546}

◆ MapViewOfFileFromApp()

LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileFromApp ( HANDLE  handle,
ULONG  access,
ULONG64  offset,
SIZE_T  size 
)

Definition at line 318 of file memory.c.

319{
320 return MapViewOfFile( handle, access, offset << 32, offset, size );
321}
#define MapViewOfFile
Definition: compat.h:745

◆ open_cross_process_connection()

static CROSS_PROCESS_WORK_LIST * open_cross_process_connection ( HANDLE  process)
static

Definition at line 46 of file memory.c.

47{
48#ifdef __aarch64__
49 CROSS_PROCESS_WORK_LIST *list;
51
52 RtlOpenCrossProcessEmulatorWorkConnection( process, &section, (void **)&list );
53 if (section) NtClose( section );
54 return list;
55#else
56 return NULL;
57#endif
58}
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
Definition: parser.c:56

Referenced by FlushInstructionCache(), and WriteProcessMemory().

◆ PrefetchVirtualMemory()

BOOL WINAPI DECLSPEC_HOTPATCH PrefetchVirtualMemory ( HANDLE  process,
ULONG_PTR  count,
WIN32_MEMORY_RANGE_ENTRY *  addresses,
ULONG  flags 
)

Definition at line 503 of file memory.c.

505{
506 return set_ntstatus( NtSetInformationVirtualMemory( process, VmPrefetchInformation,
507 count, (PMEMORY_RANGE_ENTRY)addresses,
508 &flags, sizeof(flags) ));
509}

◆ QueryMemoryResourceNotification()

BOOL WINAPI DECLSPEC_HOTPATCH QueryMemoryResourceNotification ( HANDLE  handle,
BOOL state 
)

Definition at line 1265 of file memory.c.

1266{
1267 switch (WaitForSingleObject( handle, 0 ))
1268 {
1269 case WAIT_OBJECT_0:
1270 *state = TRUE;
1271 return TRUE;
1272 case WAIT_TIMEOUT:
1273 *state = FALSE;
1274 return TRUE;
1275 }
1277 return FALSE;
1278}
static int state
Definition: maze.c:121
#define WAIT_TIMEOUT
Definition: dderror.h:14
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:439

◆ QueryVirtualMemoryInformation()

BOOL WINAPI DECLSPEC_HOTPATCH QueryVirtualMemoryInformation ( HANDLE  process,
const void addr,
WIN32_MEMORY_INFORMATION_CLASS  info_class,
void info,
SIZE_T  size,
SIZE_T ret_size 
)

Definition at line 1563 of file memory.c.

1565{
1566 switch (info_class)
1567 {
1568 case MemoryRegionInfo:
1569 return set_ntstatus( NtQueryVirtualMemory( process, addr, MemoryRegionInformation, info, size, ret_size ));
1570 default:
1571 FIXME("Unsupported info class %u.\n", info_class);
1572 return FALSE;
1573 }
1574}
NTSTATUS NTAPI NtQueryVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN MEMORY_INFORMATION_CLASS MemoryInformationClass, OUT PVOID MemoryInformation, IN SIZE_T MemoryInformationLength, OUT PSIZE_T ReturnLength)
Definition: virtual.c:4369

◆ ReadProcessMemory()

BOOL WINAPI DECLSPEC_HOTPATCH ReadProcessMemory ( HANDLE  process,
const void addr,
void buffer,
SIZE_T  size,
SIZE_T bytes_read 
)

Definition at line 347 of file memory.c.

349{
350 return set_ntstatus( NtReadVirtualMemory( process, addr, buffer, size, bytes_read ));
351}
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
Definition: virtual.c:2776

◆ ResetWriteWatch()

UINT WINAPI DECLSPEC_HOTPATCH ResetWriteWatch ( void base,
SIZE_T  size 
)

Definition at line 357 of file memory.c.

358{
360 return ~0u;
361 return 0;
362}
NTSTATUS NTAPI NtResetWriteWatch(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN SIZE_T RegionSize)
Definition: virtual.c:4288

◆ send_cross_process_notification()

static void send_cross_process_notification ( CROSS_PROCESS_WORK_LIST *  list,
UINT  id,
const void addr,
SIZE_T  size,
int  nb_args,
  ... 
)
static

Definition at line 65 of file memory.c.

67{
68#ifdef __aarch64__
69 CROSS_PROCESS_WORK_ENTRY *entry;
70 void *unused;
72 int i;
73
74 if (!list) return;
75 if ((entry = RtlWow64PopCrossProcessWorkFromFreeList( &list->free_list )))
76 {
77 entry->id = id;
78 entry->addr = (ULONG_PTR)addr;
79 entry->size = size;
80 if (nb_args)
81 {
82 va_start( args, nb_args );
83 for (i = 0; i < nb_args; i++) entry->args[i] = va_arg( args, int );
84 va_end( args );
85 }
86 RtlWow64PushCrossProcessWorkOntoWorkList( &list->work_list, entry, &unused );
87 }
88#endif
89}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
WORD unused[29]
Definition: crypt.c:1155
#define args
Definition: format.c:66
Definition: match.c:390

Referenced by FlushInstructionCache(), and WriteProcessMemory().

◆ SetProcessDefaultCpuSets()

BOOL WINAPI SetProcessDefaultCpuSets ( HANDLE  process,
const ULONG cpu_set_ids,
ULONG  count 
)

Definition at line 1497 of file memory.c.

1498{
1499 FIXME( "process %p, cpu_set_ids %p, count %lu stub.\n", process, cpu_set_ids, count );
1500
1501 return TRUE;
1502}

◆ SetSystemFileCacheSize()

BOOL WINAPI DECLSPEC_HOTPATCH SetSystemFileCacheSize ( SIZE_T  mincache,
SIZE_T  maxcache,
DWORD  flags 
)

Definition at line 368 of file memory.c.

369{
370 FIXME( "stub: %Id %Id %ld\n", mincache, maxcache, flags );
372 return FALSE;
373}

◆ SetThreadSelectedCpuSets()

BOOL WINAPI SetThreadSelectedCpuSets ( HANDLE  thread,
const ULONG cpu_set_ids,
ULONG  count 
)

Definition at line 1486 of file memory.c.

1487{
1488 FIXME( "thread %p, cpu_set_ids %p, count %lu stub.\n", thread, cpu_set_ids, count );
1489
1490 return TRUE;
1491}
static HANDLE thread
Definition: service.c:33

◆ UnmapViewOfFile()

BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFile ( const void addr)

Definition at line 379 of file memory.c.

380{
381 if (GetVersion() & 0x80000000)
382 {
384 if (!VirtualQuery( addr, &info, sizeof(info) ) || info.AllocationBase != addr)
385 {
387 return FALSE;
388 }
389 }
391}
#define ERROR_INVALID_ADDRESS
Definition: compat.h:106
SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQuery(LPCVOID addr, PMEMORY_BASIC_INFORMATION info, SIZE_T len)
Definition: memory.c:571
DWORD WINAPI GetVersion(void)
Definition: version.c:1458

◆ UnmapViewOfFile2()

BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFile2 ( HANDLE  process,
void addr,
ULONG  flags 
)

Definition at line 397 of file memory.c.

398{
399 return set_ntstatus( NtUnmapViewOfSectionEx( process, addr, flags ));
400}

◆ UnmapViewOfFileEx()

BOOL WINAPI DECLSPEC_HOTPATCH UnmapViewOfFileEx ( void addr,
ULONG  flags 
)

Definition at line 406 of file memory.c.

407{
408 return set_ntstatus( NtUnmapViewOfSectionEx( GetCurrentProcess(), addr, flags ));
409}

◆ unsafe_mem_from_HLOCAL()

static struct mem_entry * unsafe_mem_from_HLOCAL ( HLOCAL  handle)
inlinestatic

Definition at line 909 of file memory.c.

910{
911 struct mem_entry *mem = CONTAINING_RECORD( *(volatile HANDLE *)&handle, struct mem_entry, ptr );
913 if (((UINT_PTR)handle & ((sizeof(void *) << 1) - 1)) != sizeof(void *)) return NULL;
914 if (mem < data->mem_entries || mem >= data->mem_entries_end) return NULL;
915 if (!(mem->flags & MEM_FLAG_USED)) return NULL;
916 return mem;
917}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
struct mem_entry * mem_entries
Definition: memory.c:879
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by GlobalAlloc(), LocalFree(), LocalLock(), LocalReAlloc(), and LocalUnlock().

◆ unsafe_ptr_from_HLOCAL()

static void * unsafe_ptr_from_HLOCAL ( HLOCAL  handle)
inlinestatic

Definition at line 925 of file memory.c.

926{
927 if (((UINT_PTR)handle & ((sizeof(void *) << 1) - 1))) return NULL;
928 return handle;
929}

Referenced by LocalFree(), LocalLock(), LocalReAlloc(), and LocalUnlock().

◆ VirtualAlloc()

LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc ( void addr,
SIZE_T  size,
DWORD  type,
DWORD  protect 
)

Definition at line 415 of file memory.c.

416{
417 return VirtualAllocEx( GetCurrentProcess(), addr, size, type, protect );
418}
LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocEx(HANDLE process, void *addr, SIZE_T size, DWORD type, DWORD protect)
Definition: memory.c:424

Referenced by init_global_data().

◆ VirtualAlloc2()

LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc2 ( HANDLE  process,
void addr,
SIZE_T  size,
DWORD  type,
DWORD  protect,
MEM_EXTENDED_PARAMETER *  parameters,
ULONG  count 
)

Definition at line 437 of file memory.c.

440{
441 LPVOID ret = addr;
442
444 if (!set_ntstatus( NtAllocateVirtualMemoryEx( process, &ret, &size, type, protect, parameters, count )))
445 return NULL;
446 return ret;
447}

◆ VirtualAlloc2FromApp()

LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc2FromApp ( HANDLE  process,
void addr,
SIZE_T  size,
DWORD  type,
DWORD  protect,
MEM_EXTENDED_PARAMETER *  parameters,
ULONG  count 
)

Definition at line 458 of file memory.c.

460{
461 LPVOID ret = addr;
462
463 TRACE_(virtual)( "addr %p, size %p, type %#lx, protect %#lx, params %p, count %lu.\n", addr, (void *)size, type, protect,
464 parameters, count );
465
466 if (is_exec_prot( protect ))
467 {
469 return NULL;
470 }
471
473 if (!set_ntstatus( NtAllocateVirtualMemoryEx( process, &ret, &size, type, protect, parameters, count )))
474 return NULL;
475 return ret;
476}
static BOOL is_exec_prot(DWORD protect)
Definition: memory.c:449

◆ VirtualAllocEx()

LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocEx ( HANDLE  process,
void addr,
SIZE_T  size,
DWORD  type,
DWORD  protect 
)

Definition at line 424 of file memory.c.

426{
427 LPVOID ret = addr;
428
429 if (!set_ntstatus( NtAllocateVirtualMemory( process, &ret, 0, &size, type, protect ))) return NULL;
430 return ret;
431}

Referenced by VirtualAlloc(), and VirtualAllocExNuma().

◆ VirtualAllocExNuma()

LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocExNuma ( HANDLE  process,
void addr,
SIZE_T  size,
DWORD  type,
DWORD  protect,
DWORD  node 
)

Definition at line 1552 of file memory.c.

1554{
1555 if (node) FIXME( "Ignoring preferred node %lu\n", node );
1556 return VirtualAllocEx( process, addr, size, type, protect );
1557}

◆ VirtualAllocFromApp()

LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocFromApp ( void addr,
SIZE_T  size,
DWORD  type,
DWORD  protect 
)

Definition at line 482 of file memory.c.

484{
485 LPVOID ret = addr;
486
487 TRACE_(virtual)( "addr %p, size %p, type %#lx, protect %#lx.\n", addr, (void *)size, type, protect );
488
489 if (is_exec_prot( protect ))
490 {
492 return NULL;
493 }
494
495 if (!set_ntstatus( NtAllocateVirtualMemory( GetCurrentProcess(), &ret, 0, &size, type, protect ))) return NULL;
496 return ret;
497}

◆ VirtualFree()

BOOL WINAPI DECLSPEC_HOTPATCH VirtualFree ( void addr,
SIZE_T  size,
DWORD  type 
)

Definition at line 515 of file memory.c.

516{
518}
BOOL WINAPI DECLSPEC_HOTPATCH VirtualFreeEx(HANDLE process, void *addr, SIZE_T size, DWORD type)
Definition: memory.c:524

◆ VirtualFreeEx()

BOOL WINAPI DECLSPEC_HOTPATCH VirtualFreeEx ( HANDLE  process,
void addr,
SIZE_T  size,
DWORD  type 
)

Definition at line 524 of file memory.c.

525{
526 if (type == MEM_RELEASE && size)
527 {
528 WARN( "Trying to release memory with specified size.\n" );
530 return FALSE;
531 }
533}
#define WARN(fmt,...)
Definition: precomp.h:61
#define MEM_RELEASE
Definition: nt_native.h:1316
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5187

Referenced by VirtualFree().

◆ VirtualLock()

BOOL WINAPI DECLSPEC_HOTPATCH VirtualLock ( void addr,
SIZE_T  size 
)

Definition at line 539 of file memory.c.

540{
542}
NTSTATUS NTAPI NtLockVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T NumberOfBytesToLock, IN ULONG MapType)
Definition: virtual.c:3489

◆ VirtualProtect()

BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtect ( void addr,
SIZE_T  size,
DWORD  new_prot,
DWORD old_prot 
)

Definition at line 548 of file memory.c.

549{
550 return VirtualProtectEx( GetCurrentProcess(), addr, size, new_prot, old_prot );
551}
BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtectEx(HANDLE process, void *addr, SIZE_T size, DWORD new_prot, DWORD *old_prot)
Definition: memory.c:557

◆ VirtualProtectEx()

BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtectEx ( HANDLE  process,
void addr,
SIZE_T  size,
DWORD  new_prot,
DWORD old_prot 
)

Definition at line 557 of file memory.c.

559{
560 DWORD prot;
561
562 /* Win9x allows passing NULL as old_prot while this fails on NT */
563 if (!old_prot && (GetVersion() & 0x80000000)) old_prot = &prot;
564 return set_ntstatus( NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot ));
565}
NTSTATUS NTAPI NtProtectVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UnsafeBaseAddress, IN OUT SIZE_T *UnsafeNumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG UnsafeOldAccessProtection)
Definition: virtual.c:3071

Referenced by VirtualProtect().

◆ VirtualQuery()

SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQuery ( LPCVOID  addr,
PMEMORY_BASIC_INFORMATION  info,
SIZE_T  len 
)

Definition at line 571 of file memory.c.

572{
574}
SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQueryEx(HANDLE process, LPCVOID addr, PMEMORY_BASIC_INFORMATION info, SIZE_T len)
Definition: memory.c:580

Referenced by UnmapViewOfFile().

◆ VirtualQueryEx()

SIZE_T WINAPI DECLSPEC_HOTPATCH VirtualQueryEx ( HANDLE  process,
LPCVOID  addr,
PMEMORY_BASIC_INFORMATION  info,
SIZE_T  len 
)

Definition at line 580 of file memory.c.

582{
583 SIZE_T ret;
584
586 return 0;
587 return ret;
588}
@ MemoryBasicInformation
Definition: mmtypes.h:183
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by VirtualQuery(), and WriteProcessMemory().

◆ VirtualUnlock()

BOOL WINAPI DECLSPEC_HOTPATCH VirtualUnlock ( void addr,
SIZE_T  size 
)

Definition at line 594 of file memory.c.

595{
597}
NTSTATUS NTAPI NtUnlockVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T NumberOfBytesToUnlock, IN ULONG MapType)
Definition: virtual.c:3825

◆ WINE_DECLARE_DEBUG_CHANNEL() [1/2]

WINE_DECLARE_DEBUG_CHANNEL ( globalmem  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [2/2]

WINE_DECLARE_DEBUG_CHANNEL ( virtual  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( heap  )

◆ WriteProcessMemory()

BOOL WINAPI DECLSPEC_HOTPATCH WriteProcessMemory ( HANDLE  process,
void addr,
const void buffer,
SIZE_T  size,
SIZE_T bytes_written 
)

Definition at line 603 of file memory.c.

605{
606 CROSS_PROCESS_WORK_LIST *list = open_cross_process_connection( process );
607 DWORD old_prot, prot = PAGE_TARGETS_NO_UPDATE | PAGE_ENCLAVE_NO_CHANGE;
609 void *base_addr;
610 SIZE_T region_size;
611 NTSTATUS status, status2;
612
613 if (!VirtualQueryEx( process, addr, &info, sizeof(info) ))
614 {
616 return FALSE;
617 }
618
619 switch (info.Protect & ~(PAGE_GUARD | PAGE_NOCACHE))
620 {
621 case PAGE_READWRITE:
622 case PAGE_WRITECOPY:
625 /* already writable */
626 if ((status = NtWriteVirtualMemory( process, addr, buffer, size, bytes_written ))) break;
627 send_cross_process_notification( list, CrossProcessFlushCache, addr, size, 0 );
629 break;
630
631 case PAGE_EXECUTE:
633 /* make it writable */
634 base_addr = ROUND_ADDR( addr );
635 region_size = ROUND_SIZE( addr, size );
636 region_size = min( region_size, (char *)info.BaseAddress + info.RegionSize - (char *)base_addr );
638
639 send_cross_process_notification( list, CrossProcessPreVirtualProtect,
640 base_addr, region_size, 1, prot );
641 status = NtProtectVirtualMemory( process, &base_addr, &region_size, prot, &old_prot );
642 send_cross_process_notification( list, CrossProcessPostVirtualProtect,
643 base_addr, region_size, 2, prot, status );
644 if (status) break;
645
646 status = NtWriteVirtualMemory( process, addr, buffer, size, bytes_written );
647 if (!status)
648 {
649 send_cross_process_notification( list, CrossProcessFlushCache, addr, size, 0 );
651 }
652
653 prot = PAGE_TARGETS_NO_UPDATE | PAGE_ENCLAVE_NO_CHANGE | old_prot;
654 send_cross_process_notification( list, CrossProcessPreVirtualProtect,
655 base_addr, region_size, 1, prot );
656 status2 = NtProtectVirtualMemory( process, &base_addr, &region_size, prot, &old_prot );
657 send_cross_process_notification( list, CrossProcessPostVirtualProtect,
658 base_addr, region_size, 2, prot, status2 );
659 break;
660
661 default:
662 /* not writable */
664 break;
665 }
666
668 return set_ntstatus( status );
669}
#define ROUND_SIZE(addr, size)
Definition: memory.c:98
#define ROUND_ADDR(addr)
Definition: memory.c:97
#define min(a, b)
Definition: monoChain.cc:55
#define PAGE_NOCACHE
Definition: nt_native.h:1311
#define MEM_PRIVATE
Definition: nt_native.h:1318
#define PAGE_GUARD
Definition: nt_native.h:1310
NTSTATUS NTAPI NtWriteVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN PVOID Buffer, IN SIZE_T NumberOfBytesToWrite, OUT PSIZE_T NumberOfBytesWritten OPTIONAL)
Definition: virtual.c:2890
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242

Variable Documentation

◆ global_data

struct kernelbase_global_data global_data = {0}
static

◆ next_free_mem

struct mem_entry* next_free_mem
static

Definition at line 906 of file memory.c.

Referenced by init_global_data(), LocalAlloc(), and LocalFree().

◆ page_mask

const SIZE_T page_mask = 0xfff
static

Definition at line 96 of file memory.c.

Referenced by elf_map_file(), and macho_load_section_info().