ReactOS  0.4.12-dev-375-g61fed54
heapmem.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for heapmem.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI BaseDllInitializeMemoryManager (VOID)
 
HANDLE WINAPI HeapCreate (DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
 
BOOL WINAPI HeapDestroy (HANDLE hHeap)
 
HANDLE WINAPI GetProcessHeap (VOID)
 
DWORD WINAPI GetProcessHeaps (DWORD NumberOfHeaps, PHANDLE ProcessHeaps)
 
BOOL WINAPI HeapLock (HANDLE hHeap)
 
BOOL WINAPI HeapUnlock (HANDLE hHeap)
 
SIZE_T WINAPI HeapCompact (HANDLE hHeap, DWORD dwFlags)
 
BOOL WINAPI HeapValidate (HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem)
 
DWORD WINAPI HeapCreateTagsW (HANDLE hHeap, DWORD dwFlags, PWSTR lpTagName, PWSTR lpTagSubName)
 
DWORD WINAPI HeapExtend (HANDLE hHeap, DWORD dwFlags, PVOID BaseAddress, DWORD dwBytes)
 
PWSTR WINAPI HeapQueryTagW (HANDLE hHeap, DWORD dwFlags, WORD wTagIndex, BOOL bResetCounters, PVOID lpTagInfo)
 
BOOL WINAPI HeapSummary (HANDLE hHeap, DWORD dwFlags, PVOID Summary)
 
BOOL WINAPI HeapUsage (HANDLE hHeap, DWORD dwFlags, DWORD Unknown, DWORD Unknown2, IN PVOID Usage)
 
BOOL WINAPI HeapWalk (HANDLE hHeap, LPPROCESS_HEAP_ENTRY lpEntry)
 
BOOL WINAPI HeapQueryInformation (HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass, PVOID HeapInformation OPTIONAL, SIZE_T HeapInformationLength OPTIONAL, PSIZE_T ReturnLength OPTIONAL)
 
BOOL WINAPI HeapSetInformation (HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass, PVOID HeapInformation OPTIONAL, SIZE_T HeapInformationLength OPTIONAL)
 
HGLOBAL NTAPI GlobalAlloc (UINT uFlags, SIZE_T dwBytes)
 
SIZE_T NTAPI GlobalCompact (DWORD dwMinFree)
 
VOID NTAPI GlobalFix (HGLOBAL hMem)
 
UINT NTAPI GlobalFlags (HGLOBAL hMem)
 
HGLOBAL NTAPI GlobalFree (HGLOBAL hMem)
 
HGLOBAL NTAPI GlobalHandle (LPCVOID pMem)
 
LPVOID NTAPI GlobalLock (HGLOBAL hMem)
 
HGLOBAL NTAPI GlobalReAlloc (HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
 
SIZE_T NTAPI GlobalSize (HGLOBAL hMem)
 
VOID NTAPI GlobalUnfix (HGLOBAL hMem)
 
BOOL NTAPI GlobalUnlock (HGLOBAL hMem)
 
BOOL NTAPI GlobalUnWire (HGLOBAL hMem)
 
LPVOID NTAPI GlobalWire (HGLOBAL hMem)
 
BOOL NTAPI GlobalMemoryStatusEx (LPMEMORYSTATUSEX lpBuffer)
 
VOID NTAPI GlobalMemoryStatus (LPMEMORYSTATUS lpBuffer)
 
HLOCAL NTAPI LocalAlloc (UINT uFlags, SIZE_T dwBytes)
 
SIZE_T NTAPI LocalCompact (UINT dwMinFree)
 
UINT NTAPI LocalFlags (HLOCAL hMem)
 
HLOCAL NTAPI LocalFree (HLOCAL hMem)
 
HLOCAL NTAPI LocalHandle (LPCVOID pMem)
 
LPVOID NTAPI LocalLock (HLOCAL hMem)
 
HLOCAL NTAPI LocalReAlloc (HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
 
SIZE_T WINAPI LocalShrink (HLOCAL hMem, UINT cbNewSize)
 
SIZE_T NTAPI LocalSize (HLOCAL hMem)
 
BOOL NTAPI LocalUnlock (HLOCAL hMem)
 

Variables

RTL_HANDLE_TABLE BaseHeapHandleTable
 
HANDLE BaseHeap
 
ULONG_PTR SystemRangeStart
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file heapmem.c.

Function Documentation

◆ BaseDllInitializeMemoryManager()

VOID NTAPI BaseDllInitializeMemoryManager ( VOID  )

Definition at line 26 of file heapmem.c.

27 {
28  BaseHeap = RtlGetProcessHeap();
30  sizeof(BASE_HEAP_HANDLE_ENTRY),
34  sizeof(SystemRangeStart),
35  NULL);
36 }
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
ULONG_PTR SystemRangeStart
Definition: heapmem.c:20
NTSYSAPI VOID NTAPI RtlInitializeHandleTable(_In_ ULONG TableSize, _In_ ULONG HandleSize, _In_ PRTL_HANDLE_TABLE HandleTable)
RTL_HANDLE_TABLE BaseHeapHandleTable
Definition: heapmem.c:18
smooth NULL
Definition: ftsmooth.c:416
Definition: baseheap.h:68
HANDLE BaseHeap
Definition: heapmem.c:19

Referenced by DllMain().

◆ GetProcessHeap()

HANDLE WINAPI GetProcessHeap ( VOID  )

Definition at line 100 of file heapmem.c.

101 {
102  /* Call the RTL API */
103  return RtlGetProcessHeap();
104 }

◆ GetProcessHeaps()

DWORD WINAPI GetProcessHeaps ( DWORD  NumberOfHeaps,
PHANDLE  ProcessHeaps 
)

Definition at line 111 of file heapmem.c.

113 {
114  /* Call the RTL API */
115  return RtlGetProcessHeaps(NumberOfHeaps, ProcessHeaps);
116 }
NTSYSAPI ULONG WINAPI RtlGetProcessHeaps(ULONG, HANDLE *)
Definition: heap.c:3618

◆ GlobalAlloc()

HGLOBAL NTAPI GlobalAlloc ( UINT  uFlags,
SIZE_T  dwBytes 
)

Definition at line 368 of file heapmem.c.

370 {
371  ULONG Flags = 0;
372  PVOID Ptr = NULL;
373  HANDLE hMemory;
374  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
375  BASE_TRACE_ALLOC(dwBytes, uFlags);
376  ASSERT(BaseHeap);
377 
378  /* Make sure the flags are valid */
379  if (uFlags & ~GMEM_VALID_FLAGS)
380  {
381  /* They aren't, fail */
384  return NULL;
385  }
386 
387  /* Convert ZEROINIT */
389 
390  /* Check if we're not movable, which means pointer-based heap */
391  if (!(uFlags & GMEM_MOVEABLE))
392  {
393  /* Check if this is DDESHARE (deprecated) */
395 
396  /* Allocate heap for it */
397  Ptr = RtlAllocateHeap(BaseHeap, Flags, dwBytes ? dwBytes : 1);
400  return Ptr;
401  }
402 
403  /* This is heap based, so lock it in first */
405 
406  /*
407  * Disable locking, enable custom flags, and write the
408  * movable flag (deprecated)
409  */
413 
414  /* Allocate the handle */
415  HandleEntry = BaseHeapAllocEntry();
416  if (!HandleEntry)
417  {
418  /* Fail */
419  hMemory = NULL;
422  }
423  else
424  {
425  /* Get the object and make sure we have size */
426  hMemory = &HandleEntry->Object;
427  if (dwBytes)
428  {
429  /* Allocate the actual memory for it */
430  Ptr = RtlAllocateHeap(BaseHeap, Flags, dwBytes);
431  BASE_TRACE_PTR(HandleEntry, Ptr);
432  if (!Ptr)
433  {
434  /* We failed, manually set the allocate flag and free the handle */
435  HandleEntry->Flags = RTL_HANDLE_VALID;
436  BaseHeapFreeEntry(HandleEntry);
437 
438  /* For the cleanup case */
439  HandleEntry = NULL;
440  }
441  else
442  {
443  /* All worked well, save our heap entry */
445  }
446  }
447  }
448 
449  /* Cleanup! First unlock the heap */
451 
452  /* Check if a handle was allocated */
453  if (HandleEntry)
454  {
455  /* Set the pointer and allocated flag */
456  HandleEntry->Object = Ptr;
457  HandleEntry->Flags = RTL_HANDLE_VALID;
458  if (!Ptr)
459  {
460  /* We don't have a valid pointer, but so reuse this handle */
461  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSE;
462  }
463 
464  /* Check if the handle is discardable */
465  if (uFlags & GMEM_DISCARDABLE)
466  {
467  /* Save it in the handle entry */
468  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSABLE;
469  }
470 
471  /* Check if the handle is moveable */
472  if (uFlags & GMEM_MOVEABLE)
473  {
474  /* Save it in the handle entry */
475  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_MOVABLE;
476  }
477 
478  /* Check if the handle is DDE Shared */
479  if (uFlags & GMEM_DDESHARE)
480  {
481  /* Save it in the handle entry */
482  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_DDESHARE;
483  }
484 
485  /* Set the pointer */
486  Ptr = hMemory;
487  }
488 
489  /* Return the pointer */
490  return Ptr;
491 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define BaseHeapFreeEntry(he)
Definition: baseheap.h:116
#define RTL_HANDLE_VALID
Definition: rtltypes.h:372
#define BaseHeapAllocEntry()
Definition: baseheap.h:104
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
#define BASE_HEAP_ENTRY_FLAG_REUSE
Definition: baseheap.h:85
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define BASE_TRACE_ALLOC(x, y)
Definition: baseheap.h:44
UINT uFlags
Definition: api.c:60
#define HEAP_SETTABLE_USER_VALUE
Definition: nt_native.h:1704
#define BASE_TRACE_ALLOC2(x)
Definition: baseheap.h:47
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN NTAPI RtlSetUserValueHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, IN PVOID UserValue)
Definition: heap.c:3655
#define BASE_TRACE_PTR(x, y)
Definition: baseheap.h:50
#define GMEM_DISCARDABLE
Definition: winbase.h:296
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define SetLastError(x)
Definition: compat.h:409
#define GMEM_VALID_FLAGS
Definition: winbase.h:307
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: baseheap.h:68
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
#define BASE_HEAP_ENTRY_FLAG_MOVABLE
Definition: baseheap.h:83
PVOID Object
Definition: baseheap.h:74
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
HANDLE BaseHeap
Definition: heapmem.c:19
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BASE_HEAP_ENTRY_FLAG_REUSABLE
Definition: baseheap.h:84
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define GMEM_DDESHARE
Definition: winbase.h:295
unsigned int ULONG
Definition: retypes.h:1
#define BASE_HEAP_ENTRY_FLAG_DDESHARE
Definition: baseheap.h:86
USHORT Flags
Definition: baseheap.h:70
#define GMEM_MOVEABLE
Definition: winbase.h:291
#define GMEM_ZEROINIT
Definition: winbase.h:303

Referenced by alloc_and_set_onevalue(), CGlobalAllocator::Allocate(), ata_adapter_info(), ata_bblk(), ata_send_ioctl(), ata_send_scsi(), BeginUpdateResourceW(), BindInfo_GetBindInfo(), build_wpad_url(), CDevSettings_GetData(), clipboard_thread(), ClipboardReadMemoryBlock(), CommandLineToArgvT(), CompressBegin(), copy_stg_medium(), CopyBlock(), CopyCurrentGlyph(), CopyEventEntry(), CopyKeyName(), CopyLines(), CopyMemToClipboard(), CopyStgMedium(), CopyTextToClipboard(), create_callback(), create_channelbsc(), create_decoder(), create_dib(), create_doc_with_string(), create_execute(), create_metafile(), create_mfpict(), create_poke(), create_stream(), create_stream_from_map(), create_stream_on_data(), create_stream_on_file(), create_stream_on_mip_ro(), create_text(), create_textA(), create_textW(), CreateILockBytesOnHGlobal(), CreateMappedBitmap(), CreateMemoryDialog(), CreateStreamOnHGlobal(), DataObject_DAdvise(), DataObjectImpl_CreateComplex(), DataObjectImpl_CreateText(), dde_server_wndproc(), DdeCreateDataHandle(), doc_load_string(), TMouse::doClip(), dup_global_mem(), EDIT_WM_Copy(), EditVariableDlgProc(), EngComputeGlyphSet(), EnumFormatImpl_Create(), ExpandEnvironmentStringsForUserA(), expose_marshalled_dataobject(), fgetws(), get_data_from_storage(), get_data_from_stream(), get_rtf_text(), get_unicode_text(), GetAllUsersProfileDirectoryA(), GetClipboardData(), GetDefaultUserProfileDirectoryA(), GetEnvironmentVariables(), GetHGlobalFromILockBytes(), GetProfilesDirectoryA(), GetUserProfileDirectoryA(), grab_clipboard_process(), GuiCopyFromTextModeBuffer(), HEXEDIT_Copy(), HGLOBAL_UserUnmarshal(), HMETAFILEPICT_UserUnmarshal(), ICImageDecompress(), ImmCreateIMCC(), IntSynthesizeMultiByte(), IntSynthesizeWideChar(), K32CreateDBMonMutex(), load_dib(), load_image(), load_mf_pict(), load_string(), LoadTextFileToEdit(), localui_AddPortUI(), main(), MainWndProc(), marshal_WdtpInterfacePointer(), ME_GetDataObject(), MessageBoxTextToClipboard(), BrowserNavigator::navigated(), NoStatStream_Construct(), ObjectFromLresult(), OLEClipbrd_Initialize(), OleCreateMenuDescriptor(), OleDuplicateData(), OleMetafilePictFromIconAndLabel(), OnNewVariable(), OnPaint(), PackDDElParam(), pagesetup_change_printer_dialog(), pagesetup_set_devmode(), pagesetup_set_devnames(), PRINTDLG_CreateDevNames(), PRINTDLG_CreateDevNamesW(), PrintDlgA(), PrintDlgW(), PropertySheetA(), PropertySheetW(), read_post_data_stream(), RECORD_StreamFromFile(), render_embed_source_hack(), RenderFILENAMEA(), RenderFILENAMEW(), RenderHDROP(), RenderPREFEREDDROPEFFECT(), RenderSHELLIDLIST(), round_global_size(), SaveTextFileFromEdit(), set_clipboard_data_process(), set_clipboard_data_thread(), set_clipboard_formats(), set_dataobject_format(), SetAllVars(), START_TEST(), synthesize_dib(), test_apm(), test_brush_pens(), test_bsc_marshaling(), test_bufferrawformat(), test_ClipboardOwner(), test_componentinfo(), test_CopyStgMedium(), test_createfromstream(), test_decode_1bpp(), test_decode_24bpp(), test_decode_4bpp(), test_decode_adobe_cmyk(), test_decode_rle4(), test_decode_rle8(), test_DragQueryFile(), test_empty_image(), test_empty_image_2(), test_enhmetafile(), test_freed_hglobal(), test_FreeDDElParam(), test_GdipLoadImageFromStream(), test_getdatahere(), test_GlobalAlloc(), test_handles(), test_handles_process_open(), test_heap(), test_Invoke(), test_IStream_Clone(), test_load_save_bmp(), test_load_save_emf(), test_load_save_empty_picture(), test_load_save_icon(), test_loadwmf(), test_marshal_HGLOBAL(), test_marshal_HMETAFILEPICT(), test_metafile(), test_multi_encoder(), test_multiframegif(), test_nonole_clipboard(), test_obsolete_flags(), test_paste(), test_pattern_brush(), test_pic(), test_RegisterClipboardFormatA(), test_set_clipboard(), test_string_data(), test_supported_encoders(), test_UnpackDDElParam(), TestGlobalAllocNFree(), TestGlobalDiscard(), TestGlobalFlagsFixed(), TestGlobalFlagsMoveable(), TestGlobalHandle(), TestGlobalLockNUnlock(), TestGlobalReAllocFixed(), TestGlobalReAllocMovable(), TestGlobalSize(), unpack_dde_message(), update_devmode_handleA(), update_devmode_handleW(), WDML_BuildExecuteCommand(), WDML_ClientQueueAdvise(), WDML_ClientQueuePoke(), WDML_DataHandle2Global(), WdtpInterfacePointer_UserMarshal(), WdtpInterfacePointer_UserUnmarshal(), WinHelpA(), WinHttpGetDefaultProxyConfiguration(), WinHttpGetIEProxyConfigForCurrentUser(), and wmain().

◆ GlobalCompact()

SIZE_T NTAPI GlobalCompact ( DWORD  dwMinFree)

Definition at line 498 of file heapmem.c.

499 {
500  /* Call the RTL Heap Manager */
501  return RtlCompactHeap(BaseHeap, 0);
502 }
NTSYSAPI ULONG WINAPI RtlCompactHeap(HANDLE, ULONG)
Definition: heap.c:2959
HANDLE BaseHeap
Definition: heapmem.c:19

◆ GlobalFix()

VOID NTAPI GlobalFix ( HGLOBAL  hMem)

Definition at line 509 of file heapmem.c.

510 {
511  /* Lock the memory if it the handle is valid */
512  if (INVALID_HANDLE_VALUE != hMem) GlobalLock(hMem);
513 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755

◆ GlobalFlags()

UINT NTAPI GlobalFlags ( HGLOBAL  hMem)

Definition at line 520 of file heapmem.c.

521 {
522  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
523  HANDLE Handle = NULL;
524  ULONG Flags = 0;
526 
527  /* Start by locking the heap */
529  _SEH2_TRY
530  {
531  /* Check if this is a simple RTL Heap Managed block */
532  if (!((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
533  {
534  /* Then we'll query RTL Heap */
536  BASE_TRACE_PTR(Handle, hMem);
537 
538  /*
539  * Check if RTL Heap didn't find a handle associated with us or
540  * said that this heap isn't movable, which means something we're
541  * really not a handle-based heap.
542  */
543  if (!(Handle) || !(Flags & BASE_HEAP_FLAG_MOVABLE))
544  {
545  /* Then set the flags to 0 */
546  uFlags = 0;
547  }
548  else
549  {
550  /* Otherwise we're handle-based, so get the internal handle */
551  hMem = Handle;
552  }
553  }
554 
555  /* Check if the handle is actually an entry in our table */
557  {
558  /* Then get the entry */
559  HandleEntry = BaseHeapGetEntry(hMem);
560  BASE_TRACE_HANDLE(HandleEntry, hMem);
561 
562  /* Make sure it's a valid handle */
563  if (BaseHeapValidateEntry(HandleEntry))
564  {
565  /* Get the lock count first */
566  uFlags = HandleEntry->LockCount & GMEM_LOCKCOUNT;
567 
568  /* Now check if it's discardable */
569  if (HandleEntry->Flags & BASE_HEAP_ENTRY_FLAG_REUSABLE)
570  {
571  /* Set the Win32 Flag */
573  }
574 
575  /* Check if it's DDE Shared */
576  if (HandleEntry->Flags & BASE_HEAP_ENTRY_FLAG_DDESHARE)
577  {
578  /* Set the Win32 Flag */
580  }
581 
582  /* Now check if it's discarded */
583  if (HandleEntry->Flags & BASE_HEAP_ENTRY_FLAG_REUSE)
584  {
585  /* Set the Win32 Flag */
587  }
588  }
589  }
590 
591  /* Check if by now, we still haven't gotten any useful flags */
593  }
595  {
596  /* Set the exception code */
598  }
599  _SEH2_END;
600 
601  /* All done! Unlock heap and return Win32 Flags */
603  return uFlags;
604 }
#define BASE_HEAP_ENTRY_FLAG_REUSE
Definition: baseheap.h:85
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define GMEM_INVALID_HANDLE
Definition: winbase.h:305
#define GMEM_DISCARDED
Definition: winbase.h:304
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
UINT uFlags
Definition: api.c:60
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define BASE_TRACE_PTR(x, y)
Definition: baseheap.h:50
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define GMEM_DISCARDABLE
Definition: winbase.h:296
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
BOOLEAN NTAPI RtlGetUserInfoHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, OUT PVOID *UserValue, OUT PULONG UserFlags)
Definition: heap.c:3772
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int UINT
Definition: ndis.h:50
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
_SEH2_END
Definition: create.c:4424
#define BASE_HEAP_ENTRY_FLAG_REUSABLE
Definition: baseheap.h:84
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
#define GMEM_DDESHARE
Definition: winbase.h:295
unsigned int ULONG
Definition: retypes.h:1
USHORT LockCount
Definition: baseheap.h:71
#define BASE_HEAP_ENTRY_FLAG_DDESHARE
Definition: baseheap.h:86
USHORT Flags
Definition: baseheap.h:70
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define GMEM_LOCKCOUNT
Definition: winbase.h:306

Referenced by DisplayImageInfo(), DisplayStatus(), ImmGetIMCCLockCount(), ModifyStatus(), PrintDlgW(), PrintFlags(), ShowStatus(), test_CopyStgMedium(), test_heap(), test_ImmGetIMCCLockCount(), test_pattern_brush(), TestGlobalDiscard(), TestGlobalFlagsFixed(), TestGlobalFlagsMoveable(), and ValidateFlags().

◆ GlobalFree()

HGLOBAL NTAPI GlobalFree ( HGLOBAL  hMem)

Definition at line 611 of file heapmem.c.

612 {
613  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
614  LPVOID Ptr;
615  BASE_TRACE_DEALLOC(hMem);
616 
617  /* Check if this was a simple allocated heap entry */
618  if (!((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
619  {
620  /* Free it with the RTL Heap Manager */
621  if (RtlFreeHeap(BaseHeap, 0, hMem))
622  {
623  /* Return NULL since there's no handle */
624  return NULL;
625  }
626  else
627  {
628  /* Otherwise fail */
631  return hMem;
632  }
633  }
634 
635  /* It's a handle probably, so lock the heap */
637  _SEH2_TRY
638  {
639  /* Make sure that this is an entry in our handle database */
641  {
642  /* Get the entry */
643  HandleEntry = BaseHeapGetEntry(hMem);
644  BASE_TRACE_HANDLE(HandleEntry, hMem);
645 
646  /* Make sure the handle is valid */
647  if (!BaseHeapValidateEntry(HandleEntry))
648  {
649  /* It's not, fail */
651  Ptr = NULL;
652  }
653  else
654  {
655  /* It's valid, so get the pointer */
656  Ptr = HandleEntry->Object;
657 
658  /* Free this handle */
659  BaseHeapFreeEntry(HandleEntry);
660 
661  /* If the pointer is 0, then we don't have a handle either */
662  if (!Ptr) hMem = NULL;
663  }
664  }
665  else
666  {
667  /* Otherwise, reuse the handle as a pointer */
669  Ptr = hMem;
670  }
671 
672  /* Check if we got here with a valid heap pointer */
673  if (Ptr)
674  {
675  /* Free it with the RTL Heap Manager */
677  {
678  /* Everything worked */
679  hMem = NULL;
680  }
681  else
682  {
683  /* This wasn't a real heap handle */
685  }
686  }
687  }
689  {
690  /* Set the exception code */
692  }
693  _SEH2_END;
694 
695  /* We're done, so unlock the heap and return the handle */
697  return hMem;
698 }
#define BaseHeapFreeEntry(he)
Definition: baseheap.h:116
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
PVOID Object
Definition: baseheap.h:74
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
_SEH2_END
Definition: create.c:4424
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define BASE_TRACE_DEALLOC(x)
Definition: baseheap.h:56

Referenced by _tWinMain(), alloc_and_set_onevalue(), ata_bblk(), ata_send_ioctl(), ata_send_scsi(), BeginUpdateResourceW(), BindStatusCallback_Release(), CDevSettings_GetData(), ClipboardReadBitmap(), ClipboardReadEnhMetafile(), ClipboardReadMemory(), ClipboardReadMemoryBlock(), ClipboardReadMetafile(), ClipboardReadPalette(), CmdDebugService(), COMCTL32_ReleaseStgMedium(), CompressEnd(), CopyBlock(), CopyEventEntry(), CopyLines(), create_stream(), CreateMappedBitmap(), CreateMemoryDialog(), DataObjectImpl_Release(), dde_msg_client_wndproc(), DdeCreateDataHandle(), DdeFreeDataHandle(), DdePostAdvise(), DragFinish(), dup_metafilepict(), EditVariableDlgProc(), EndUpdateResourceW(), EngComputeGlyphSet(), EnumFormatImpl_Release(), ExpandEnvironmentStringsForUserA(), expose_marshalled_dataobject(), fgetws(), ShellDirectory::fill_w32fdata_shell(), fill_w32fdata_shell(), CGlobalAllocator::Free(), free_metafilepict(), FreeDDElParam(), get_data_from_storage(), get_data_from_stream(), get_descriptors(), get_stgmed_for_storage(), get_stgmed_for_stream(), GetAllUsersProfileDirectoryA(), GetClipboardData(), GetDefaultUserProfileDirectoryA(), GetEnvironmentVariables(), GetProfilesDirectoryA(), GetUserProfileDirectoryA(), handle_release(), HEXEDIT_Copy(), HGLOBAL_UserFree(), HGLOBALLockBytesImpl_Release(), HMETAFILEPICT_UserFree(), ICImageDecompress(), ImmDestroyIMCC(), COpenWithMenu::Initialize(), K32CreateDBMonMutex(), load_dib(), load_mf_pict(), LoadTextFileToEdit(), LocalFree(), main(), MainWndProc(), MessageBoxTextToClipboard(), BrowserNavigator::navigated(), NoStatStreamImpl_Destroy(), NOTEPAD_WndProc(), ObjectFromLresult(), OLEClipbrd_Initialize(), OleDestroyMenuDescriptor(), OleDuplicateData(), OleMetafilePictFromIconAndLabel(), CMainWindow::OnCommand(), OnDeleteVariable(), OnNewVariable(), OnPaint(), pagesetup_change_printer_dialog(), PrintUIEntryW(), ProcessCommandLine(), PROPSHEET_CleanUp(), proxy_active(), read_post_data_stream(), RECORD_StreamFromFile(), release_request_data(), ReleaseListViewItems(), ReleaseStgMedium(), render_embed_source_hack(), render_format(), round_global_size(), SaveTextFileFromEdit(), set_clipboard_formats(), set_dataobject_format(), SetAllVars(), SHGetRealIDL(), START_TEST(), test_abort_proc(), test_AddPortUI(), test_brush_pens(), test_componentinfo(), test_CopyStgMedium(), test_createfromstream(), test_decode_1bpp(), test_decode_24bpp(), test_decode_4bpp(), test_decode_adobe_cmyk(), test_decode_rle4(), test_decode_rle8(), test_DeviceCapabilities(), test_freed_hglobal(), test_FreeDDElParam(), test_GlobalAlloc(), test_handles(), test_heap(), test_Invoke(), test_load_save_bmp(), test_load_save_emf(), test_load_save_icon(), test_marshal_HGLOBAL(), test_marshal_HMETAFILEPICT(), test_msg_client(), test_obsolete_flags(), test_onevalue_cap(), test_PageSetupDlgA(), test_pattern_brush(), test_physical(), test_PrintDlgA(), test_PrintDlgExW(), test_resolution(), test_supported_sizes(), test_UnpackDDElParam(), test_WinHttpDetectAutoProxyConfigUrl(), test_WinHttpGetIEProxyConfigForCurrentUser(), test_WinHttpGetProxyForUrl(), TestGlobalAllocNFree(), TestGlobalDiscard(), TestGlobalFlagsFixed(), TestGlobalFlagsMoveable(), TestGlobalHandle(), TestGlobalLockNUnlock(), TestGlobalReAllocFixed(), TestGlobalReAllocMovable(), TestGlobalSize(), unpack_dde_message(), CTravelEntry::Update(), update_devmode_handleA(), update_devmode_handleW(), WDML_BuildExecuteCommand(), WDML_FreeTransaction(), WDML_HandleAdviseReply(), WDML_HandleIncomingData(), WDML_HandlePokeReply(), WDML_HandleRequestReply(), WDML_ServerHandleAdvise(), WDML_ServerHandlePoke(), WDML_ServerHandleRequest(), WdtpInterfacePointer_UserMarshal(), WdtpInterfacePointer_UserUnmarshal(), WinHttpGetDefaultProxyConfiguration(), WinHttpGetIEProxyConfigForCurrentUser(), WinHttpGetProxyForUrl(), WinHttpOpen(), wmain(), wWinMain(), and CTravelEntry::~CTravelEntry().

◆ GlobalHandle()

HGLOBAL NTAPI GlobalHandle ( LPCVOID  pMem)

Definition at line 705 of file heapmem.c.

706 {
707  HANDLE Handle = NULL;
708  ULONG Flags;
709 
710  /* Lock the heap */
712  _SEH2_TRY
713  {
714  /* Query RTL Heap */
717  (PVOID)pMem,
718  &Handle,
719  &Flags))
720  {
721  /* RTL Heap Manager does not know about this heap */
723  }
724  else
725  {
726  /*
727  * Check if RTL Heap didn't find a handle for us or said that
728  * this heap isn't movable.
729  */
730  BASE_TRACE_PTR(Handle, pMem);
731  if (!(Handle) || !(Flags & BASE_HEAP_FLAG_MOVABLE))
732  {
733  /* We're actually handle-based, so the pointer is a handle */
734  Handle = (HANDLE)pMem;
735  }
736  }
737  }
739  {
740  /* Set the exception code */
742  }
743  _SEH2_END;
744 
745  /* All done, unlock the heap and return the handle */
747  return Handle;
748 }
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
_SEH2_TRY
Definition: create.c:4250
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define BASE_TRACE_PTR(x, y)
Definition: baseheap.h:50
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
BOOLEAN NTAPI RtlGetUserInfoHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, OUT PVOID *UserValue, OUT PULONG UserFlags)
Definition: heap.c:3772
_In_ HANDLE Handle
Definition: extypes.h:390
PVOID HANDLE
Definition: typedefs.h:71
#define SetLastError(x)
Definition: compat.h:409
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
HANDLE BaseHeap
Definition: heapmem.c:19
_SEH2_END
Definition: create.c:4424
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Referenced by CompressEnd(), FreeDDElParam(), GetClipboardData(), LocalHandle(), test_GlobalAlloc(), test_ImmGetIMCCLockCount(), and TestGlobalHandle().

◆ GlobalLock()

LPVOID NTAPI GlobalLock ( HGLOBAL  hMem)

Definition at line 755 of file heapmem.c.

756 {
757  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
758  LPVOID Ptr;
759 
760  /* Check if this was a simple allocated heap entry */
761  if (!((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
762  {
763  /* Make sure it's not a kernel or invalid address */
764  if ((hMem >= (HGLOBAL)SystemRangeStart) || (IsBadReadPtr(hMem, 1)))
765  {
766  /* Signal an error */
768  return NULL;
769  }
770 
771  /* It's all good */
772  return hMem;
773  }
774 
775  /* Otherwise, lock the heap */
777  _SEH2_TRY
778  {
779  /* Get the handle entry */
780  HandleEntry = BaseHeapGetEntry(hMem);
781  BASE_TRACE_HANDLE(HandleEntry, hMem);
782 
783  /* Make sure it's valid */
784  if (!BaseHeapValidateEntry(HandleEntry))
785  {
786  /* It's not, fail */
789  Ptr = NULL;
790  }
791  else
792  {
793  /* Otherwise, get the pointer */
794  Ptr = HandleEntry->Object;
795  if (Ptr)
796  {
797  /* Increase the lock count, unless we've went too far */
798  if (HandleEntry->LockCount++ == GMEM_LOCKCOUNT)
799  {
800  /* In which case we simply unlock once */
801  HandleEntry->LockCount--;
802  }
803  }
804  else
805  {
806  /* The handle is still there but the memory was already freed */
808  }
809  }
810  }
812  {
814  Ptr = NULL;
815  }
816  _SEH2_END;
817 
818  /* All done. Unlock the heap and return the pointer */
820  return Ptr;
821 }
ULONG_PTR SystemRangeStart
Definition: heapmem.c:20
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
PVOID Object
Definition: baseheap.h:74
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
_SEH2_END
Definition: create.c:4424
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:807
USHORT LockCount
Definition: baseheap.h:71
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define GMEM_LOCKCOUNT
Definition: winbase.h:306
#define ERROR_DISCARDED
Definition: winerror.h:229

Referenced by CRecyclerDropTarget::_DoDeleteDataObject(), CFSDropTarget::_DoDrop(), alloc_and_set_onevalue(), BeginUpdateResourceW(), bsc_OnStopBinding(), check_dib_size(), check_get(), check_iml_data(), check_output(), check_output_raw(), ClipboardReadBitmap(), ClipboardReadEnhMetafile(), ClipboardReadMemoryBlock(), ClipboardReadMetafile(), ClipboardReadPalette(), ClipboardWriteMemory(), CommandLineToArgvT(), CompressBegin(), anonymous_namespace{mstscax.cpp}::CoClass::ControlInfoToString(), copy_stg_medium(), CopyBlock(), CopyCurrentGlyph(), CopyEventEntry(), CopyKeyName(), CopyLines(), CopyMemToClipboard(), CopyStgMedium(), CopyTextToClipboard(), create_decoder(), create_dib(), create_execute(), create_map_from_stream(), create_metafile(), create_mfpict(), create_poke(), create_stream(), create_stream_from_map(), create_stream_on_data(), create_stream_on_file(), create_stream_on_mip_ro(), create_text(), create_textA(), create_textW(), CreateDIBPatternBrush(), CreateMemoryDialog(), D3DXSaveSurfaceToFileInMemory(), DataCache_Draw(), DataCache_GetExtent(), DataObjectImpl_CreateComplex(), DataObjectImpl_CreateText(), dde_msg_client_wndproc(), dde_server_wndproc(), dde_server_wndprocA(), dde_server_wndprocW(), DdeAccessData(), DdeCreateDataHandle(), TMouse::doClip(), CDefaultContextMenu::DoCopyOrCut(), CDefaultContextMenu::DoPaste(), DragQueryFileA(), DragQueryFileW(), DragQueryPoint(), DrawTextFromClipboard(), CExeDropHandler::Drop(), dup_global_mem(), dup_metafilepict(), EDIT_WM_Copy(), EDIT_WM_Paste(), EndUpdateResourceW(), ExtCreatePen(), FILEDLG95_FILENAME_FillFromSelection(), ShellDirectory::fill_w32fdata_shell(), fill_w32fdata_shell(), free_metafilepict(), get_current_dataobject(), get_current_ole_clip_window(), get_descriptors(), get_onevalue(), get_priv_data(), get_stgdef(), get_unicode_text(), GetClipboardData(), GetClipboardDataDimensions(), PIDList::GetData(), GetHGlobalFromILockBytes(), GetNumSelected(), GetPidlFromDataObject(), GlobalFix(), GlobalWire(), GuiCopyFromTextModeBuffer(), GuiPasteToTextModeBuffer(), handle_read(), handle_write(), HEXEDIT_Copy(), HEXEDIT_Paste(), HGLOBAL_UserMarshal(), HGLOBAL_UserUnmarshal(), HGLOBALLockBytesImpl_ReadAt(), HGLOBALLockBytesImpl_WriteAt(), HMETAFILEPICT_UserFree(), HMETAFILEPICT_UserMarshal(), HMETAFILEPICT_UserSize(), HMETAFILEPICT_UserUnmarshal(), ICImageDecompress(), ImmLockIMCC(), CLayerUIPropPage::Initialize(), COpenWithMenu::Initialize(), BtrfsContextMenu::Initialize(), BtrfsVolPropSheet::Initialize(), BtrfsPropSheet::Initialize(), CZipFolder::Initialize(), IntSynthesizeMultiByte(), IntSynthesizeWideChar(), BtrfsContextMenu::InvokeCommand(), InvokeObjectPickerDialog(), InvokeRemoteRegistryPickerDialog(), is_fixed(), is_moveable(), IsDataUnicode(), IsMovable(), load_dib(), load_image(), load_mf_pict(), LocalLock(), MainWndProc(), make_dc(), marshal_WdtpInterfacePointer(), ME_AppendToHGLOBAL(), ME_ReadFromHGLOBALRTF(), ME_ReadFromHGLOBALUnicode(), MessageBoxTextToClipboard(), NoStatStreamImpl_Read(), NoStatStreamImpl_Write(), OleCreateMenuDescriptor(), OleDuplicateData(), OLEMenu_CallWndProc(), OLEMenu_GetMsgProc(), OleMetafilePictFromIconAndLabel(), OleSetMenuDescriptor(), TreeDropTarget::OnDrop(), DesktopDropTarget::OnDrop(), OnPaint(), PackDDElParam(), pagesetup_change_printer_dialog(), pagesetup_get_a_devname(), pagesetup_get_devmode(), pagesetup_get_orientation(), pagesetup_get_papersize(), pagesetup_set_defaultsource(), pagesetup_set_devmode(), pagesetup_set_devnames(), pagesetup_set_orientation(), pagesetup_set_papersize(), Tnclip::Paste(), PasteIntoCurrentGlyph(), PlayMetaFileFromClipboard(), post_dde_message(), PRINTDLG_ChangePrinterA(), PRINTDLG_ChangePrinterW(), PRINTDLG_CreateDCA(), PRINTDLG_CreateDCW(), PRINTDLG_CreateDevNames(), PRINTDLG_CreateDevNamesW(), PRINTDLG_WMInitDialog(), PRINTDLG_WMInitDialogW(), PrintDlgA(), PrintDlgW(), QueryDeskCplExtInterface(), QueryDeskCplString(), ReadClipboard(), CConsole::ReadLine(), ReleaseStgMedium(), render_embed_source_hack(), RenderFILENAMEA(), RenderFILENAMEW(), RenderHDROP(), RenderPREFEREDDROPEFFECT(), RenderSHELLIDLIST(), ReuseDDElParam(), RunningObjectTableImpl_Register(), save_dib(), save_mfpict(), set_clipboard_formats(), set_dataobject_format(), SetClipboardData(), CIDLDataObj::SetData(), SetDIBitsToDeviceFromClipboard(), SH_GetApidlFromDataObject(), SHGetRealIDL(), show_reflink_paste(), snapshot_GetDataHere(), stgmedium_cmp(), synthesize_bitmap(), synthesize_dib(), synthesize_emf(), test_apm(), test_bom(), test_brush_pens(), test_bufferrawformat(), test_cf_dataobject(), test_componentinfo(), test_CopyStgMedium(), test_createfromstream(), test_data_cache_dib_contents_stream(), test_data_handles(), test_decode_1bpp(), test_decode_24bpp(), test_decode_4bpp(), test_decode_adobe_cmyk(), test_decode_rle4(), test_decode_rle8(), test_DeviceCapabilities(), test_DragQueryFile(), test_empty_image(), test_empty_image_2(), test_enhmetafile(), test_freed_hglobal(), test_freethreadedmarshaldata(), test_GdipLoadImageFromStream(), test_GlobalAlloc(), test_handles_process(), test_handles_process_open(), test_handles_thread2(), test_heap(), test_Invoke(), test_load_save_bmp(), test_load_save_emf(), test_load_save_empty_picture(), test_load_save_icon(), test_loadwmf(), test_marshal_HGLOBAL(), test_marshal_HMETAFILEPICT(), test_metafile(), test_moniker(), test_multiframegif(), test_mxwriter_encoding(), test_omitxmldeclaration(), test_PackDDElParam(), test_paste(), test_pattern_brush(), test_persist_save_data(), test_pic(), test_PrintDlgA(), test_PrintDlgExW(), test_resolution(), test_save(), test_set_clipboard(), test_single_source(), test_synthesized(), test_UnpackDDElParam(), test_writeenddocument(), TestGlobalFlagsFixed(), TestGlobalFlagsMoveable(), TestGlobalHandle(), TestGlobalLockNUnlock(), TestGlobalReAllocFixed(), TestGlobalReAllocMovable(), unpack_dde_message(), UnpackDDElParam(), update_devmode_handleA(), update_devmode_handleW(), UpdateResourceW(), WDML_BuildExecuteCommand(), WDML_ClientQueueAdvise(), WDML_ClientQueuePoke(), WDML_DataHandle2Global(), WDML_Global2DataHandle(), WDML_IsAppOwned(), WDML_ServerHandleAdvise(), WDML_ServerHandleExecute(), WDML_ServerHandlePoke(), WdtpInterfacePointer_UserMarshal(), WdtpInterfacePointer_UserUnmarshal(), WinHelpA(), wmain(), and xslprocessor_transform().

◆ GlobalMemoryStatus()

VOID NTAPI GlobalMemoryStatus ( LPMEMORYSTATUS  lpBuffer)

Definition at line 1348 of file heapmem.c.

1349 {
1350  MEMORYSTATUSEX lpBufferEx;
1351 
1352  /* Call the extended function */
1353  lpBufferEx.dwLength = sizeof(MEMORYSTATUSEX);
1354  if (GlobalMemoryStatusEx(&lpBufferEx))
1355  {
1356  /* Reset the right size and fill out the information */
1357  lpBuffer->dwLength = sizeof(MEMORYSTATUS);
1358  lpBuffer->dwMemoryLoad = lpBufferEx.dwMemoryLoad;
1359  lpBuffer->dwTotalPhys = (SIZE_T)min(lpBufferEx.ullTotalPhys, MAXULONG_PTR);
1360  lpBuffer->dwAvailPhys = (SIZE_T)min(lpBufferEx.ullAvailPhys, MAXULONG_PTR);
1361  lpBuffer->dwTotalPageFile = (SIZE_T)min(lpBufferEx.ullTotalPageFile, MAXULONG_PTR);
1362  lpBuffer->dwAvailPageFile = (SIZE_T)min(lpBufferEx.ullAvailPageFile, MAXULONG_PTR);
1363  lpBuffer->dwTotalVirtual = (SIZE_T)min(lpBufferEx.ullTotalVirtual, MAXULONG_PTR);
1364  lpBuffer->dwAvailVirtual = (SIZE_T)min(lpBufferEx.ullAvailVirtual, MAXULONG_PTR);
1365  }
1366 }
#define MAXULONG_PTR
Definition: basetsd.h:103
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:163
struct _MEMORYSTATUS MEMORYSTATUS
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define min(a, b)
Definition: monoChain.cc:55
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
Definition: heapmem.c:1272

Referenced by AllSysInfo(), and CommandMemory().

◆ GlobalMemoryStatusEx()

BOOL NTAPI GlobalMemoryStatusEx ( LPMEMORYSTATUSEX  lpBuffer)

Definition at line 1272 of file heapmem.c.

1273 {
1274  SYSTEM_PERFORMANCE_INFORMATION PerformanceInfo;
1275  VM_COUNTERS VmCounters;
1276  QUOTA_LIMITS QuotaLimits;
1277  ULONGLONG PageFile, PhysicalMemory;
1278 
1279  if (lpBuffer->dwLength != sizeof(*lpBuffer))
1280  {
1282  return FALSE;
1283  }
1284 
1285  /* Query performance information */
1287  &PerformanceInfo,
1288  sizeof(PerformanceInfo),
1289  NULL);
1290 
1291  /* Calculate memory load */
1293  PerformanceInfo.AvailablePages) * 100) /
1295 
1296  /* Save physical memory */
1299  lpBuffer->ullTotalPhys = PhysicalMemory;
1300 
1301  /* Now save available physical memory */
1302  PhysicalMemory = PerformanceInfo.AvailablePages *
1304  lpBuffer->ullAvailPhys = PhysicalMemory;
1305 
1306  /* Query VM and Quota Limits */
1309  &QuotaLimits,
1310  sizeof(QUOTA_LIMITS),
1311  NULL);
1314  &VmCounters,
1315  sizeof(VM_COUNTERS),
1316  NULL);
1317 
1318  /* Save the commit limit */
1319  lpBuffer->ullTotalPageFile = min(QuotaLimits.PagefileLimit,
1320  PerformanceInfo.CommitLimit);
1321  lpBuffer->ullTotalPageFile *= BaseStaticServerData->SysInfo.PageSize;
1322 
1323  /* Calculate how many pages are left */
1324  PageFile = PerformanceInfo.CommitLimit - PerformanceInfo.CommittedPages;
1325 
1326  /* Save the total */
1327  lpBuffer->ullAvailPageFile = min(PageFile,
1328  QuotaLimits.PagefileLimit -
1329  VmCounters.PagefileUsage);
1330  lpBuffer->ullAvailPageFile *= BaseStaticServerData->SysInfo.PageSize;
1331 
1332  /* Now calculate the total virtual space */
1335 
1336  /* And finally the available virtual space */
1337  lpBuffer->ullAvailVirtual = lpBuffer->ullTotalVirtual - VmCounters.VirtualSize;
1338  lpBuffer->ullAvailExtendedVirtual = 0;
1339 
1340  return TRUE;
1341 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
#define DWORD
Definition: msvc.h:34
NTSTATUS NTAPI NtQueryInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:59
SIZE_T PagefileUsage
Definition: winternl.h:1614
SIZE_T VirtualSize
Definition: winternl.h:1606
struct _QUOTA_LIMITS QUOTA_LIMITS
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:163
smooth NULL
Definition: ftsmooth.c:416
#define SystemPerformanceInformation
Definition: memtest.h:87
#define NtCurrentProcess()
Definition: nt_native.h:1657
SYSTEM_BASIC_INFORMATION SysInfo
Definition: base.h:122
uint64_t ULONGLONG
Definition: typedefs.h:65
#define SetLastError(x)
Definition: compat.h:409
#define min(a, b)
Definition: monoChain.cc:55

Referenced by AboutDlgProc(), build_systeminfo_tree(), CommandMemory(), get_available_physical_memory(), get_total_physical_memory(), GetSystemInformation(), GlobalMemoryStatus(), Hib_InitDialog(), InitializeSystemPage(), OnSelChange(), set_installer_properties(), and test_GetPhysicallyInstalledSystemMemory().

◆ GlobalReAlloc()

HGLOBAL NTAPI GlobalReAlloc ( HGLOBAL  hMem,
SIZE_T  dwBytes,
UINT  uFlags 
)

Definition at line 825 of file heapmem.c.

828 {
829  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
830  HANDLE Handle;
831  LPVOID Ptr;
832  ULONG Flags = 0;
833 
834  /* Throw out invalid flags */
836  {
838  return NULL;
839  }
840 
841  /* Throw out invalid combo */
842  if ((uFlags & GMEM_DISCARDABLE) && !(uFlags & GMEM_MODIFY))
843  {
845  return NULL;
846  }
847 
848  /* Convert ZEROINIT */
850 
851  /* If this wasn't a movable heap, then we MUST re-alloc in place */
853 
854  /* Lock the heap and disable built-in locking in the RTL Heap functions */
857 
858  /* Check if this is a simple handle-based block */
859  if (((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
860  {
861  /* Get the entry */
862  HandleEntry = BaseHeapGetEntry(hMem);
863  BASE_TRACE_HANDLE(HandleEntry, hMem);
864 
865  /* Make sure the handle is valid */
866  if (!BaseHeapValidateEntry(HandleEntry))
867  {
868  /* Fail */
871  hMem = NULL;
872  }
873  else if (uFlags & GMEM_MODIFY)
874  {
875  /* User is changing flags... check if the memory was discardable */
876  if (uFlags & GMEM_DISCARDABLE)
877  {
878  /* Then set the flag */
879  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSABLE;
880  }
881  else
882  {
883  /* Otherwise, remove the flag */
884  HandleEntry->Flags &= ~BASE_HEAP_ENTRY_FLAG_REUSABLE;
885  }
886  }
887  else
888  {
889  /* Otherwise, get the object and check if we have no size */
890  Ptr = HandleEntry->Object;
891  if (!dwBytes)
892  {
893  /* Clear the handle and check for a pointer */
894  hMem = NULL;
895  if (Ptr)
896  {
897  /* Make sure the handle isn't locked */
898  if ((uFlags & GMEM_MOVEABLE) && !(HandleEntry->LockCount))
899  {
900  /* Free the current heap */
901  if (RtlFreeHeap(BaseHeap, Flags, Ptr))
902  {
903  /* Free the handle */
904  HandleEntry->Object = NULL;
905  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSE;
906 
907  /* Get the object pointer */
908  hMem = &HandleEntry->Object;
909  }
910  }
911  }
912  else
913  {
914  /* Otherwise just return the object pointer */
915  hMem = &HandleEntry->Object;
916  }
917  }
918  else
919  {
920  /* Otherwise, we're allocating, so set the new flags needed */
922  if (!Ptr)
923  {
924  /* We don't have a base, so allocate one */
925  Ptr = RtlAllocateHeap(BaseHeap, Flags, dwBytes);
927  if (Ptr)
928  {
929  /* Allocation succeeded, so save our entry */
932  Ptr,
933  hMem);
934  }
935  }
936  else
937  {
938  /*
939  * If it's not movable or currently locked, we MUST allocate
940  * in-place!
941  */
942  if (!(uFlags & GMEM_MOVEABLE) && (HandleEntry->LockCount))
943  {
944  /* Set the flag */
946  }
947  else
948  {
949  /* Otherwise clear the flag if we set it previously */
951  }
952 
953  /* Do the re-allocation. No need to save the entry again */
954  Ptr = RtlReAllocateHeap(BaseHeap, Flags, Ptr, dwBytes);
955  }
956 
957  /* Make sure we have a pointer by now */
958  if (Ptr)
959  {
960  /* Write it in the handle entry and mark it in use */
961  HandleEntry->Object = Ptr;
962  HandleEntry->Flags &= ~BASE_HEAP_ENTRY_FLAG_REUSE;
963  }
964  else
965  {
966  /* Otherwise we failed */
967  hMem = NULL;
969  }
970  }
971  }
972  }
973  else if (uFlags & GMEM_MODIFY)
974  {
975  /* This is not a handle-based heap and the caller wants it to be one */
976  if (uFlags & GMEM_MOVEABLE)
977  {
978  /* Get information on its current state */
979  Handle = hMem;
982  hMem,
983  &Handle,
984  NULL))
985  {
986  /*
987  * Check if the handle matches the pointer or the moveable flag
988  * isn't there, which is what we expect since it currently isn't.
989  */
990  if ((Handle == hMem) || !(Flags & BASE_HEAP_FLAG_MOVABLE))
991  {
992  /* Allocate a handle for it */
993  HandleEntry = BaseHeapAllocEntry();
994  if (!HandleEntry)
995  {
996  /* No entry could be allocated */
999  return NULL;
1000  }
1001 
1002  /* Calculate the size of the current heap */
1003  dwBytes = RtlSizeHeap(BaseHeap, HEAP_NO_SERIALIZE, hMem);
1004 
1005  /* Set the movable flag */
1007 
1008  /* Now allocate the actual heap for it */
1009  HandleEntry->Object = RtlAllocateHeap(BaseHeap,
1010  Flags,
1011  dwBytes);
1012  BASE_TRACE_PTR(HandleEntry->Object, HandleEntry);
1013  if (!HandleEntry->Object)
1014  {
1015  /*
1016  * We failed, manually set the allocate flag and
1017  * free the handle
1018  */
1019  HandleEntry->Flags = RTL_HANDLE_VALID;
1020  BaseHeapFreeEntry(HandleEntry);
1021 
1022  /* For the cleanup case */
1024  HandleEntry = NULL;
1026  }
1027  else
1028  {
1029  /* Otherwise, copy the new heap and free the old one */
1030  RtlMoveMemory(HandleEntry->Object, hMem, dwBytes);
1032 
1033  /* Select the heap pointer */
1034  hMem = (HANDLE)&HandleEntry->Object;
1035 
1036  /* Initialize the count and default flags */
1037  HandleEntry->LockCount = 0;
1038  HandleEntry->Flags = RTL_HANDLE_VALID |
1040 
1041  /* Check if it's also discardable */
1043  {
1044  /* Set the internal flag */
1045  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSABLE;
1046  }
1047 
1048  /* Check if it's also DDE Shared */
1049  if (uFlags & GMEM_DDESHARE)
1050  {
1051  /* Set the internal flag */
1052  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_DDESHARE;
1053  }
1054 
1055  /* Allocation succeeded, so save our entry */
1058  HandleEntry->Object,
1059  hMem);
1060  }
1061  }
1062  }
1063  }
1064  }
1065  else
1066  {
1067  /* Otherwise, this is a simple RTL Managed Heap, so just call it */
1068  hMem = RtlReAllocateHeap(BaseHeap,
1070  hMem,
1071  dwBytes);
1072  if (!hMem)
1073  {
1074  /* Fail */
1077  }
1078  }
1079 
1080  /* All done, unlock the heap and return the pointer */
1082  return hMem;
1083 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define BaseHeapFreeEntry(he)
Definition: baseheap.h:116
#define RTL_HANDLE_VALID
Definition: rtltypes.h:372
#define BaseHeapAllocEntry()
Definition: baseheap.h:104
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
#define BASE_HEAP_ENTRY_FLAG_REUSE
Definition: baseheap.h:85
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
UINT uFlags
Definition: api.c:60
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2552
#define HEAP_SETTABLE_USER_VALUE
Definition: nt_native.h:1704
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define BASE_TRACE_ALLOC2(x)
Definition: baseheap.h:47
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN NTAPI RtlSetUserValueHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, IN PVOID UserValue)
Definition: heap.c:3655
#define BASE_TRACE_PTR(x, y)
Definition: baseheap.h:50
#define GMEM_DISCARDABLE
Definition: winbase.h:296
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI RtlGetUserInfoHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, OUT PVOID *UserValue, OUT PULONG UserFlags)
Definition: heap.c:3772
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
_In_ HANDLE Handle
Definition: extypes.h:390
if(!(yy_init))
Definition: macro.lex.yy.c:717
PVOID HANDLE
Definition: typedefs.h:71
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
#define GMEM_VALID_FLAGS
Definition: winbase.h:307
Definition: baseheap.h:68
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
#define BASE_HEAP_ENTRY_FLAG_MOVABLE
Definition: baseheap.h:83
PVOID Object
Definition: baseheap.h:74
NTSYSAPI SIZE_T NTAPI RtlSizeHeap(_In_ PVOID HeapHandle, _In_ ULONG Flags, _In_ PVOID MemoryPointer)
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BASE_HEAP_ENTRY_FLAG_REUSABLE
Definition: baseheap.h:84
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
#define GMEM_MODIFY
Definition: winbase.h:292
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define GMEM_DDESHARE
Definition: winbase.h:295
unsigned int ULONG
Definition: retypes.h:1
USHORT LockCount
Definition: baseheap.h:71
#define BASE_HEAP_ENTRY_FLAG_DDESHARE
Definition: baseheap.h:86
USHORT Flags
Definition: baseheap.h:70
#define HEAP_REALLOC_IN_PLACE_ONLY
Definition: nt_native.h:1696
#define GMEM_MOVEABLE
Definition: winbase.h:291
#define GMEM_ZEROINIT
Definition: winbase.h:303

Referenced by DdeAddData(), get_rtf_text(), handle_setsize(), handle_write(), HGLOBALLockBytesImpl_SetSize(), ImmReSizeIMCC(), ME_AppendToHGLOBAL(), NoStatStreamImpl_SetSize(), pagesetup_set_devmode(), pagesetup_set_devnames(), PRINTDLG_CreateDevNames(), PRINTDLG_CreateDevNamesW(), PrintDlgA(), PrintDlgW(), CGlobalAllocator::Reallocate(), test_GlobalAlloc(), test_heap(), TestGlobalReAllocFixed(), TestGlobalReAllocMovable(), update_devmode_handleA(), update_devmode_handleW(), and wmain().

◆ GlobalSize()

SIZE_T NTAPI GlobalSize ( HGLOBAL  hMem)

Definition at line 1090 of file heapmem.c.

1091 {
1092  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
1093  PVOID Handle = NULL;
1094  ULONG Flags = 0;
1096 
1097  /* Lock the heap */
1099  _SEH2_TRY
1100  {
1101  /* Check if this is a simple RTL Heap Managed block */
1102  if (!((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
1103  {
1104  /* Then we'll query RTL Heap */
1105  if (RtlGetUserInfoHeap(BaseHeap, Flags, hMem, &Handle, &Flags))
1106  {
1107  BASE_TRACE_PTR(Handle, hMem);
1108  /*
1109  * Check if RTL Heap didn't give us a handle or said that this
1110  * heap isn't movable.
1111  */
1112  if (!(Handle) || !(Flags & BASE_HEAP_FLAG_MOVABLE))
1113  {
1114  /* We're not a handle heap, so use the generic call */
1116  }
1117  else
1118  {
1119  /* We're a handle heap so get the internal handle */
1120  hMem = Handle;
1121  }
1122  }
1123  }
1124 
1125  /* Make sure that this is an entry in our handle database */
1127  {
1128  /* Get the entry */
1129  HandleEntry = BaseHeapGetEntry(hMem);
1130  BASE_TRACE_HANDLE(HandleEntry, hMem);
1131 
1132  /* Make sure the handle is valid */
1133  if (!BaseHeapValidateEntry(HandleEntry))
1134  {
1135  /* Fail */
1138  }
1139  else if (HandleEntry->Flags & BASE_HEAP_ENTRY_FLAG_REUSE)
1140  {
1141  /* We've reused this block, but we've saved the size for you */
1142  dwSize = HandleEntry->OldSize;
1143  }
1144  else
1145  {
1146  /* Otherwise, query RTL about it */
1149  HandleEntry->Object);
1150  }
1151  }
1152  }
1154  {
1155  /* Set failure for later */
1156  dwSize = MAXULONG_PTR;
1157  }
1158  _SEH2_END;
1159 
1160  /* Check if by now, we still haven't gotten any useful size */
1161  if (dwSize == MAXULONG_PTR)
1162  {
1163  /* Fail */
1166  dwSize = 0;
1167  }
1168 
1169  /* All done! Unlock heap and return the size */
1171  return dwSize;
1172 }
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
#define BASE_HEAP_ENTRY_FLAG_REUSE
Definition: baseheap.h:85
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define MAXULONG_PTR
Definition: basetsd.h:103
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define BASE_TRACE_PTR(x, y)
Definition: baseheap.h:50
ULONG OldSize
Definition: baseheap.h:75
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI RtlGetUserInfoHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, OUT PVOID *UserValue, OUT PULONG UserFlags)
Definition: heap.c:3772
_In_ HANDLE Handle
Definition: extypes.h:390
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
PVOID Object
Definition: baseheap.h:74
NTSYSAPI SIZE_T NTAPI RtlSizeHeap(_In_ PVOID HeapHandle, _In_ ULONG Flags, _In_ PVOID MemoryPointer)
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_SEH2_END
Definition: create.c:4424
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
unsigned int ULONG
Definition: retypes.h:1
USHORT Flags
Definition: baseheap.h:70
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by bsc_OnStopBinding(), check_output(), check_output_raw(), ClipboardWriteMemory(), CopyStgMedium(), create_map_from_stream(), CreateILockBytesOnHGlobal(), dde_server_wndproc(), DdeAccessData(), dup_global_mem(), ShellDirectory::fill_w32fdata_shell(), get_current_dataobject(), GetClipboardData(), handle_create(), HGLOBAL_UserMarshal(), HGLOBAL_UserSize(), ImmGetIMCCSize(), is_freed(), IsDataUnicode(), LocalSize(), ME_AppendToHGLOBAL(), MyAllocatePool(), MyFreePool(), NoStatStream_Construct(), OleDuplicateData(), post_dde_message(), PostMessageA(), PostMessageW(), round_global_size(), RunningObjectTableImpl_Register(), save_dib(), SetClipboardData(), snapshot_GetDataHere(), stgmedium_cmp(), test_cf_dataobject(), test_CopyStgMedium(), test_data_cache_dib_contents_stream(), test_freethreadedmarshaldata(), test_GlobalAlloc(), test_handles(), test_heap(), test_marshal_HGLOBAL(), test_moniker(), test_persist_save_data(), test_string_data_process(), test_synthesized(), TestGlobalSize(), unpack_dde_message(), update_devmode_handleA(), update_devmode_handleW(), WDML_ClientQueuePoke(), WDML_DataHandle2Global(), WDML_Global2DataHandle(), WDML_ServerHandleExecute(), WDML_ServerHandlePoke(), WdtpInterfacePointer_UserMarshal(), wmain(), and xslprocessor_transform().

◆ GlobalUnfix()

VOID NTAPI GlobalUnfix ( HGLOBAL  hMem)

Definition at line 1179 of file heapmem.c.

1180 {
1181  /* If the handle is valid, unlock it */
1182  if (hMem != INVALID_HANDLE_VALUE) GlobalUnlock(hMem);
1183 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

◆ GlobalUnlock()

BOOL NTAPI GlobalUnlock ( HGLOBAL  hMem)

Definition at line 1190 of file heapmem.c.

1191 {
1192  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
1193  BOOL RetVal = TRUE;
1194 
1195  /* Check if this was a simple allocated heap entry */
1196  if (!((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY)) return RetVal;
1197 
1198  /* Otherwise, lock the heap */
1200 
1201  /* Get the handle entry */
1202  HandleEntry = BaseHeapGetEntry(hMem);
1203  BASE_TRACE_HANDLE(HandleEntry, hMem);
1204 
1205  _SEH2_TRY
1206  {
1207  /* Make sure it's valid */
1208  if (!BaseHeapValidateEntry(HandleEntry))
1209  {
1210  /* It's not, fail */
1213  RetVal = FALSE;
1214  }
1215  else
1216  {
1217  /* Otherwise, decrement lock count, unless we're already at 0*/
1218  if (!HandleEntry->LockCount--)
1219  {
1220  /* In which case we simply lock it back and fail */
1221  HandleEntry->LockCount++;
1223  RetVal = FALSE;
1224  }
1225  else if (!HandleEntry->LockCount)
1226  {
1227  /* Nothing to unlock */
1229  RetVal = FALSE;
1230  }
1231  }
1232  }
1234  {
1236  RetVal = FALSE;
1237  }
1238  _SEH2_END;
1239 
1240  /* All done. Unlock the heap and return the pointer */
1242  return RetVal;
1243 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
#define NO_ERROR
Definition: dderror.h:5
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
_SEH2_END
Definition: create.c:4424
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
USHORT LockCount
Definition: baseheap.h:71
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ERROR_NOT_LOCKED
Definition: winerror.h:230

Referenced by alloc_and_set_onevalue(), BeginUpdateResourceW(), bsc_OnStopBinding(), check_dib_size(), check_get(), check_iml_data(), check_output(), check_output_raw(), ClipboardReadBitmap(), ClipboardReadEnhMetafile(), ClipboardReadMemoryBlock(), ClipboardReadMetafile(), ClipboardReadPalette(), ClipboardWriteMemory(), COMCTL32_ReleaseStgMedium(), CompressEnd(), anonymous_namespace{mstscax.cpp}::CoClass::ControlInfoToString(), copy_stg_medium(), CopyBlock(), CopyCurrentGlyph(), CopyEventEntry(), CopyKeyName(), CopyLines(), CopyMemToClipboard(), CopyStgMedium(), CopyTextToClipboard(), create_decoder(), create_dib(), create_execute(), create_map_from_stream(), create_metafile(), create_mfpict(), create_poke(), create_stream(), create_stream_from_map(), create_stream_on_data(), create_stream_on_file(), create_stream_on_mip_ro(), create_text(), create_textA(), create_textW(), CreateDIBPatternBrush(), CreateMemoryDialog(), D3DXSaveSurfaceToFileInMemory(), DataCache_Draw(), DataCache_GetExtent(), DataObjectImpl_CreateComplex(), DataObjectImpl_CreateText(), dde_msg_client_wndproc(), dde_server_wndproc(), dde_server_wndprocA(), dde_server_wndprocW(), DdeCreateDataHandle(), DdeUnaccessData(), TMouse::doClip(), CDefaultContextMenu::DoCopyOrCut(), CDefaultContextMenu::DoPaste(), DragQueryFileA(), DragQueryFileW(), DragQueryPoint(), DrawTextFromClipboard(), dup_global_mem(), dup_metafilepict(), EDIT_WM_Copy(), EDIT_WM_Paste(), EndUpdateResourceW(), ExtCreatePen(), ShellDirectory::fill_w32fdata_shell(), fill_w32fdata_shell(), free_metafilepict(), get_current_dataobject(), get_current_ole_clip_window(), get_descriptors(), get_onevalue(), get_priv_data(), get_stgdef(), get_unicode_text(), GetClipboardData(), GetClipboardDataDimensions(), GetHGlobalFromILockBytes(), GlobalUnfix(), GlobalUnWire(), GuiCopyFromTextModeBuffer(), GuiPasteToTextModeBuffer(), handle_read(), handle_write(), HEXEDIT_Copy(), HEXEDIT_Paste(), HGLOBAL_UserMarshal(), HGLOBAL_UserUnmarshal(), HGLOBALLockBytesImpl_ReadAt(), HGLOBALLockBytesImpl_WriteAt(), HMETAFILEPICT_UserFree(), HMETAFILEPICT_UserMarshal(), HMETAFILEPICT_UserSize(), HMETAFILEPICT_UserUnmarshal(), ICImageDecompress(), ImmUnlockIMCC(), CLayerUIPropPage::Initialize(), COpenWithMenu::Initialize(), BtrfsContextMenu::Initialize(), BtrfsVolPropSheet::Initialize(), BtrfsPropSheet::Initialize(), CZipFolder::Initialize(), BtrfsContextMenu::InvokeCommand(), InvokeObjectPickerDialog(), InvokeRemoteRegistryPickerDialog(), is_fixed(), is_moveable(), IsDataUnicode(), IsMovable(), load_dib(), load_image(), load_mf_pict(), MainWndProc(), make_dc(), marshal_WdtpInterfacePointer(), ME_AppendToHGLOBAL(), ME_ReadFromHGLOBALRTF(), ME_ReadFromHGLOBALUnicode(), MessageBoxTextToClipboard(), MsgiKMToUMCleanup(), NoStatStreamImpl_Read(), NoStatStreamImpl_Write(), OleCreateMenuDescriptor(), OleDuplicateData(), OLEMenu_CallWndProc(), OLEMenu_GetMsgProc(), OleMetafilePictFromIconAndLabel(), OleSetMenuDescriptor(), TreeDropTarget::OnDrop(), DesktopDropTarget::OnDrop(), OnPaint(), PackDDElParam(), pagesetup_change_printer_dialog(), pagesetup_get_a_devname(), pagesetup_get_devmode(), pagesetup_get_orientation(), pagesetup_get_papersize(), pagesetup_set_defaultsource(), pagesetup_set_devmode(), pagesetup_set_devnames(), pagesetup_set_orientation(), pagesetup_set_papersize(), Tnclip::Paste(), PasteIntoCurrentGlyph(), PlayMetaFileFromClipboard(), post_dde_message(), PRINTDLG_ChangePrinterA(), PRINTDLG_ChangePrinterW(), PRINTDLG_CreateDCA(), PRINTDLG_CreateDCW(), PRINTDLG_CreateDevNames(), PRINTDLG_CreateDevNamesW(), PRINTDLG_WMInitDialog(), PRINTDLG_WMInitDialogW(), PrintDlgA(), PrintDlgW(), QueryDeskCplExtInterface(), QueryDeskCplString(), ReadClipboard(), CConsole::ReadLine(), ReleaseStgMedium(), render_embed_source_hack(), RenderFILENAMEA(), RenderFILENAMEW(), RenderHDROP(), RenderPREFEREDDROPEFFECT(), RenderSHELLIDLIST(), ReuseDDElParam(), RunningObjectTableImpl_Register(), save_dib(), save_mfpict(), set_clipboard_formats(), set_dataobject_format(), SetClipboardData(), CIDLDataObj::SetData(), SetDIBitsToDeviceFromClipboard(), SHGetRealIDL(), show_reflink_paste(), snapshot_GetDataHere(), stgmedium_cmp(), synthesize_bitmap(), synthesize_dib(), synthesize_emf(), test_bom(), test_brush_pens(), test_bufferrawformat(), test_cf_dataobject(), test_componentinfo(), test_CopyStgMedium(), test_createfromstream(), test_data_cache_dib_contents_stream(), test_data_handles(), test_decode_1bpp(), test_decode_24bpp(), test_decode_4bpp(), test_decode_adobe_cmyk(), test_decode_rle4(), test_decode_rle8(), test_DeviceCapabilities(), test_DragQueryFile(), test_freed_hglobal(), test_freethreadedmarshaldata(), test_GdipLoadImageFromStream(), test_GlobalAlloc(), test_handles_process(), test_handles_process_open(), test_handles_thread2(), test_heap(), test_ImmGetIMCCLockCount(), test_Invoke(), test_load_save_bmp(), test_load_save_emf(), test_load_save_empty_picture(), test_load_save_icon(), test_loadwmf(), test_marshal_HGLOBAL(), test_marshal_HMETAFILEPICT(), test_moniker(), test_multiframegif(), test_mxwriter_encoding(), test_omitxmldeclaration(), test_PackDDElParam(), test_paste(), test_persist_save_data(), test_pic(), test_PrintDlgA(), test_PrintDlgExW(), test_resolution(), test_save(), test_set_clipboard(), test_single_source(), test_synthesized(), test_UnpackDDElParam(), TestGlobalFlagsMoveable(), TestGlobalHandle(), TestGlobalLockNUnlock(), TestGlobalReAllocFixed(), TestGlobalReAllocMovable(), unpack_dde_message(), UnpackDDElParam(), update_devmode_handleA(), update_devmode_handleW(), UpdateResourceW(), WDML_BuildExecuteCommand(), WDML_ClientQueueAdvise(), WDML_ClientQueuePoke(), WDML_DataHandle2Global(), WDML_Global2DataHandle(), WDML_IsAppOwned(), WDML_ServerHandleAdvise(), WDML_ServerHandleExecute(), WDML_ServerHandlePoke(), WdtpInterfacePointer_UserMarshal(), WdtpInterfacePointer_UserUnmarshal(), WinHelpA(), wmain(), xslprocessor_transform(), BtrfsContextMenu::~BtrfsContextMenu(), BtrfsPropSheet::~BtrfsPropSheet(), BtrfsVolPropSheet::~BtrfsVolPropSheet(), and PIDList::~PIDList().

◆ GlobalUnWire()

BOOL NTAPI GlobalUnWire ( HGLOBAL  hMem)

Definition at line 1250 of file heapmem.c.

1251 {
1252  /* This is simply an unlock */
1253  return GlobalUnlock(hMem);
1254 }
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

◆ GlobalWire()

LPVOID NTAPI GlobalWire ( HGLOBAL  hMem)

Definition at line 1261 of file heapmem.c.

1262 {
1263  /* This is just a lock */
1264  return GlobalLock(hMem);
1265 }
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755

◆ HeapCompact()

SIZE_T WINAPI HeapCompact ( HANDLE  hHeap,
DWORD  dwFlags 
)

Definition at line 145 of file heapmem.c.

146 {
147  /* Call the RTL API */
148  return RtlCompactHeap(hHeap, dwFlags);
149 }
NTSYSAPI ULONG WINAPI RtlCompactHeap(HANDLE, ULONG)
Definition: heap.c:2959
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by _heapmin().

◆ HeapCreate()

HANDLE WINAPI HeapCreate ( DWORD  flOptions,
SIZE_T  dwInitialSize,
SIZE_T  dwMaximumSize 
)

Definition at line 45 of file heapmem.c.

48 {
49  HANDLE hRet;
50  ULONG Flags;
51 
52  /* Remove non-Win32 flags and tag this allocation */
55 
56  /* Check if heap is growable and ensure max size is correct */
57  if (dwMaximumSize == 0)
59  else if (dwMaximumSize < BaseStaticServerData->SysInfo.PageSize &&
60  dwInitialSize > dwMaximumSize)
61  {
62  /* Max size is non-zero but less than page size which can't be correct.
63  Fix it up by bumping it to the initial size whatever it is. */
64  dwMaximumSize = dwInitialSize;
65  }
66 
67  /* Call RTL Heap */
68  hRet = RtlCreateHeap(Flags,
69  NULL,
70  dwMaximumSize,
71  dwInitialSize,
72  NULL,
73  NULL);
74 
75  /* Set the last error if we failed, and return the pointer */
77  return hRet;
78 }
#define HEAP_CLASS_1
Definition: nt_native.h:1711
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
#define HEAP_GROWABLE
Definition: nt_native.h:1693
#define SetLastError(x)
Definition: compat.h:409
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)
unsigned int ULONG
Definition: retypes.h:1
_In_ PATHOBJ _In_ CLIPOBJ _In_ BRUSHOBJ _In_ POINTL _In_ MIX _In_ FLONG flOptions
Definition: winddi.h:3591
#define HEAP_GENERATE_EXCEPTIONS
Definition: nt_native.h:1694

Referenced by DllMain(), CListNode::operator new(), runtimehost_init(), ShimLib_Init(), test_dpa(), and test_HeapCreate().

◆ HeapCreateTagsW()

DWORD WINAPI HeapCreateTagsW ( HANDLE  hHeap,
DWORD  dwFlags,
PWSTR  lpTagName,
PWSTR  lpTagSubName 
)

Definition at line 169 of file heapmem.c.

173 {
174  /* Call the RTL API */
175  return RtlCreateTagHeap(hHeap,
176  dwFlags,
177  lpTagName,
178  lpTagSubName);
179 }
ULONG NTAPI RtlCreateTagHeap(IN HANDLE HeapHandle, IN ULONG Flags, IN PWSTR TagName, IN PWSTR TagSubName)
Definition: heap.c:3875
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ HeapDestroy()

BOOL WINAPI HeapDestroy ( HANDLE  hHeap)

Definition at line 85 of file heapmem.c.

86 {
87  /* Return TRUE if the heap was destroyed */
88  if (!RtlDestroyHeap(hHeap)) return TRUE;
89 
90  /* Otherwise, we got the handle back, so fail */
92  return FALSE;
93 }
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI PVOID NTAPI RtlDestroyHeap(IN PVOID HeapHandle)
#define SetLastError(x)
Definition: compat.h:409

Referenced by DllMain(), CListNode::operator delete(), runtimehost_uninit(), ShimLib_Deinit(), and test_HeapCreate().

◆ HeapExtend()

DWORD WINAPI HeapExtend ( HANDLE  hHeap,
DWORD  dwFlags,
PVOID  BaseAddress,
DWORD  dwBytes 
)

Definition at line 186 of file heapmem.c.

190 {
192 
193  /* Call the RTL API. Gone in Vista, so commented out. */
194  Status = STATUS_NOT_IMPLEMENTED; //RtlExtendHeap(hHeap, dwFlags, BaseAddress, dwBytes);
195  if (!NT_SUCCESS(Status))
196  {
197  /* We failed */
199  return FALSE;
200  }
201 
202  /* Return success */
203  return TRUE;
204 }
#define TRUE
Definition: types.h:120
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24

◆ HeapLock()

BOOL WINAPI HeapLock ( HANDLE  hHeap)

Definition at line 123 of file heapmem.c.

124 {
125  /* Call the RTL API */
126  return RtlLockHeap(hHeap);
127 }
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)

Referenced by dll_entry_point(), IsBlockFromHeap(), mutex_thread_proc(), and RtlInitializeHeapLock().

◆ HeapQueryInformation()

BOOL WINAPI HeapQueryInformation ( HANDLE  HeapHandle,
HEAP_INFORMATION_CLASS  HeapInformationClass,
PVOID HeapInformation  OPTIONAL,
SIZE_T HeapInformationLength  OPTIONAL,
PSIZE_T ReturnLength  OPTIONAL 
)

Definition at line 314 of file heapmem.c.

319 {
321 
322  Status = RtlQueryHeapInformation(HeapHandle,
323  HeapInformationClass,
324  HeapInformation,
325  HeapInformationLength,
326  ReturnLength);
327 
328  if (!NT_SUCCESS(Status))
329  {
331  return FALSE;
332  }
333 
334  return TRUE;
335 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS WINAPI RtlQueryHeapInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T)
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24

◆ HeapQueryTagW()

PWSTR WINAPI HeapQueryTagW ( HANDLE  hHeap,
DWORD  dwFlags,
WORD  wTagIndex,
BOOL  bResetCounters,
PVOID  lpTagInfo 
)

Definition at line 211 of file heapmem.c.

216 {
217  /* Call the RTL API */
218  return RtlQueryTagHeap(hHeap,
219  dwFlags,
220  wTagIndex,
221  (BOOLEAN)bResetCounters,
222  lpTagInfo);
223 }
PWSTR NTAPI RtlQueryTagHeap(IN PVOID HeapHandle, IN ULONG Flags, IN USHORT TagIndex, IN BOOLEAN ResetCounters, OUT PRTL_HEAP_TAG_INFO HeapTagInfo)
Definition: heap.c:3850
unsigned char BOOLEAN
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ HeapSetInformation()

BOOL WINAPI HeapSetInformation ( HANDLE  HeapHandle,
HEAP_INFORMATION_CLASS  HeapInformationClass,
PVOID HeapInformation  OPTIONAL,
SIZE_T HeapInformationLength  OPTIONAL 
)

Definition at line 342 of file heapmem.c.

346 {
348 
349  Status = RtlSetHeapInformation(HeapHandle,
350  HeapInformationClass,
351  HeapInformation,
352  HeapInformationLength);
353 
354  if (!NT_SUCCESS(Status))
355  {
357  return FALSE;
358  }
359 
360  return TRUE;
361 }
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS WINAPI RtlSetHeapInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T)
LONG NTSTATUS
Definition: precomp.h:26
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24

◆ HeapSummary()

BOOL WINAPI HeapSummary ( HANDLE  hHeap,
DWORD  dwFlags,
PVOID  Summary 
)

Definition at line 230 of file heapmem.c.

233 {
236 
237  /* Fill in the length information */
238  Usage.Length = sizeof(Usage);
239 
240  /* Call RTL. Gone in Vista, so commented out */
241  Status = STATUS_NOT_IMPLEMENTED; //RtlUsageHeap(hHeap, dwFlags, &Usage);
242  if (!NT_SUCCESS(Status))
243  {
244  /* We failed */
246  return FALSE;
247  }
248 
249  /* FIXME: Summary == Usage?! */
250  RtlCopyMemory(Summary, &Usage, sizeof(Usage));
251  return TRUE;
252 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
LONG NTSTATUS
Definition: precomp.h:26
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24

◆ HeapUnlock()

BOOL WINAPI HeapUnlock ( HANDLE  hHeap)

Definition at line 134 of file heapmem.c.

135 {
136  /* Call the RTL API */
137  return RtlUnlockHeap(hHeap);
138 }
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018

Referenced by IsBlockFromHeap().

◆ HeapUsage()

BOOL WINAPI HeapUsage ( HANDLE  hHeap,
DWORD  dwFlags,
DWORD  Unknown,
DWORD  Unknown2,
IN PVOID  Usage 
)

Definition at line 259 of file heapmem.c.

264 {
266 
267  /* Call RTL. Gone in Vista, so commented out */
268  Status = STATUS_NOT_IMPLEMENTED; //RtlUsageHeap(hHeap, dwFlags, &Usage);
269  if (!NT_SUCCESS(Status))
270  {
271  /* We failed */
273  return FALSE;
274  }
275  else if (Status == STATUS_MORE_ENTRIES)
276  {
277  /* There are still more entries to parse */
278  return TRUE;
279  }
280 
281  /* Otherwise, we're completely done, so we return FALSE, but NO_ERROR */
283  return FALSE;
284 }
#define TRUE
Definition: types.h:120
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define SetLastError(x)
Definition: compat.h:409
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
Status
Definition: gdiplustypes.h:24

◆ HeapValidate()

BOOL WINAPI HeapValidate ( HANDLE  hHeap,
DWORD  dwFlags,
LPCVOID  lpMem 
)

Definition at line 156 of file heapmem.c.

159 {
160  /* Call the RTL API */
161  return RtlValidateHeap(hHeap, dwFlags, (PVOID)lpMem);
162 }
NTSYSAPI BOOLEAN WINAPI RtlValidateHeap(HANDLE, ULONG, LPCVOID)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by __getmainargs(), __wgetmainargs(), _heapchk(), _heapwalk(), pdb_process_internal(), and test_heap_checks().

◆ HeapWalk()

BOOL WINAPI HeapWalk ( HANDLE  hHeap,
LPPROCESS_HEAP_ENTRY  lpEntry 
)

Definition at line 291 of file heapmem.c.

293 {
295 
296  DPRINT1("Warning, HeapWalk is calling RtlWalkHeap with Win32 parameters\n");
297 
298  Status = RtlWalkHeap(hHeap, lpEntry);
299 
300  if (!NT_SUCCESS(Status))
301  {
303  return FALSE;
304  }
305 
306  return TRUE;
307 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define SetLastError(x)
Definition: compat.h:409
NTSYSAPI NTSTATUS WINAPI RtlWalkHeap(HANDLE, PVOID)
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define DPRINT1
Definition: precomp.h:8

Referenced by _heapwalk(), and IsBlockFromHeap().

◆ LocalAlloc()

HLOCAL NTAPI LocalAlloc ( UINT  uFlags,
SIZE_T  dwBytes 
)

Definition at line 1373 of file heapmem.c.

1375 {
1376  ULONG Flags = 0;
1377  PVOID Ptr = NULL;
1378  HANDLE hMemory;
1379  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
1380  BASE_TRACE_ALLOC(dwBytes, uFlags);
1381  ASSERT(BaseHeap);
1382 
1383  /* Make sure the flags are valid */
1384  if (uFlags & ~LMEM_VALID_FLAGS)
1385  {
1386  /* They aren't, fail */
1389  return NULL;
1390  }
1391 
1392  /* Convert ZEROINIT */
1394 
1395  /* Check if we're not movable, which means pointer-based heap */
1396  if (!(uFlags & LMEM_MOVEABLE))
1397  {
1398  /* Allocate heap for it */
1399  Ptr = RtlAllocateHeap(BaseHeap, Flags, dwBytes);
1401  return Ptr;
1402  }
1403 
1404  /* This is heap based, so lock it in first */
1406 
1407  /*
1408  * Disable locking, enable custom flags, and write the
1409  * movable flag (deprecated)
1410  */
1414 
1415  /* Allocate the handle */
1416  HandleEntry = BaseHeapAllocEntry();
1417  if (!HandleEntry)
1418  {
1419  /* Fail */
1420  hMemory = NULL;
1423  goto Quickie;
1424  }
1425 
1426  /* Get the object and make sure we have size */
1427  hMemory = &HandleEntry->Object;
1428  if (dwBytes)
1429  {
1430  /* Allocate the actual memory for it */
1431  Ptr = RtlAllocateHeap(BaseHeap, Flags, dwBytes);
1432  BASE_TRACE_PTR(HandleEntry, Ptr);
1433  if (!Ptr)
1434  {
1435  /* We failed, manually set the allocate flag and free the handle */
1436  HandleEntry->Flags = RTL_HANDLE_VALID;
1437  BaseHeapFreeEntry(HandleEntry);
1438 
1439  /* For the cleanup case */
1440  HandleEntry = NULL;
1441  }
1442  else
1443  {
1444  /* All worked well, save our heap entry */
1446  }
1447  }
1448 
1449 Quickie:
1450  /* Cleanup! First unlock the heap */
1452 
1453  /* Check if a handle was allocated */
1454  if (HandleEntry)
1455  {
1456  /* Set the pointer and allocated flag */
1457  HandleEntry->Object = Ptr;
1458  HandleEntry->Flags = RTL_HANDLE_VALID;
1459  if (!Ptr)
1460  {
1461  /* We don't have a valid pointer, but so reuse this handle */
1462  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSE;
1463  }
1464 
1465  /* Check if the handle is discardable */
1466  if (uFlags & GMEM_DISCARDABLE)
1467  {
1468  /* Save it in the handle entry */
1469  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSABLE;
1470  }
1471 
1472  /* Check if the handle is moveable */
1473  if (uFlags & GMEM_MOVEABLE)
1474  {
1475  /* Save it in the handle entry */
1476  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_MOVABLE;
1477  }
1478 
1479  /* Set the pointer */
1480  Ptr = hMemory;
1481  }
1482 
1483  /* Return the pointer */
1484  return Ptr;
1485 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define BaseHeapFreeEntry(he)
Definition: baseheap.h:116
#define RTL_HANDLE_VALID
Definition: rtltypes.h:372
#define BaseHeapAllocEntry()
Definition: baseheap.h:104
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
#define BASE_HEAP_ENTRY_FLAG_REUSE
Definition: baseheap.h:85
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define BASE_TRACE_ALLOC(x, y)
Definition: baseheap.h:44
UINT uFlags
Definition: api.c:60
#define HEAP_SETTABLE_USER_VALUE
Definition: nt_native.h:1704
#define BASE_TRACE_ALLOC2(x)
Definition: baseheap.h:47
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN NTAPI RtlSetUserValueHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, IN PVOID UserValue)
Definition: heap.c:3655
#define BASE_TRACE_PTR(x, y)
Definition: baseheap.h:50
#define GMEM_DISCARDABLE
Definition: winbase.h:296
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define LMEM_VALID_FLAGS
Definition: winbase.h:361
#define LMEM_ZEROINIT
Definition: winbase.h:356
#define LMEM_MOVEABLE
Definition: winbase.h:350
#define SetLastError(x)
Definition: compat.h:409
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: baseheap.h:68
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
#define BASE_HEAP_ENTRY_FLAG_MOVABLE
Definition: baseheap.h:83
PVOID Object
Definition: baseheap.h:74
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
HANDLE BaseHeap
Definition: heapmem.c:19
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BASE_HEAP_ENTRY_FLAG_REUSABLE
Definition: baseheap.h:84
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
USHORT Flags
Definition: baseheap.h:70
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by AccpLookupCurrentUser(), AccpLookupSidByName(), AccpOpenNamedObject(), AccRewriteGetExplicitEntriesFromAcl(), AccRewriteGetHandleRights(), AccRewriteSetEntriesInAcl(), Alloc(), AllocAndLoadString(), AllocAndLoadStringsCat(), CLocalAllocator::Allocate(), AppendUserEnvironmentVariable(), AuthzInitializeContextFromSid(), AuthzInitializeResourceManager(), AuthzpQueryToken(), blob_to_str(), CallBackConvertToAscii(), CheckEscapesA(), client_start(), CommandLineToArgvW(), compat_catpath(), CompressBegin(), ConvertSecurityDescriptorToStringSecurityDescriptorW(), ConvertSidToStringSidA(), ConvertSidToStringSidW(), ConvertStringSecurityDescriptorToSecurityDescriptorW(), ConvertStringSidToSidW(), CShellLink::CopyDataBlock(), CreateDefaultSecurityDescriptor(), CRYPT_DecodeEnsureSpace(), CRYPT_EncodeDataContentInfoHeader(), CRYPT_EncodeEnsureSpace(), CryptUnprotectData(), DecompressBegin(), DisplayStuffUsingWin32Setup(), DllMain(), Dns_AllocZero(), DoStartService(), DSEnumProc(), DuplicationString(), EDIT_EM_GetHandle(), EDIT_EM_SetHandle(), EDIT_WM_NCCreate(), EnumDeviceDrivers(), EnumPageFilesW(), EnumProcesses(), ExtractZipImage(), FindDeviceDriver(), FindDfltProvRegVals(), FindProvRegVals(), FindProvTypesRegVals(), FormatMessageA(), FormatMessageW(), generateTestSignal(), get_module_version(), GetBatteryState(), GetDeviceDriverBaseNameW(), GetDeviceDriverFileNameW(), getDeviceInterfaceDetail(), GetMappedFileNameA(), GetModuleBaseNameA(), GetModuleFileNameExA(), GetPerformanceInfo(), GetProcessImageFileNameA(), GetProcessImageFileNameW(), CDefView::GetSelectedObjects(), GetShellSecurityDescriptor(), GetUserAndDomainName(), GetUserNameA(), GetUserNameW(), GetUserSid(), GetUserSidStringFromToken(), HandleSetHandlePrintHex(), HEXEDIT_HEM_LOADBUFFER(), HEXEDIT_HEM_SETMAXBUFFERSIZE(), HidD_GetPreparsedData(), HTTPREQ_QueryOption(), I_ScQueryServiceTagInfo(), IEffectivePermission_fnGetEffectivePermission(), IMAPIMalloc_fnAlloc(), IMAPIMalloc_fnRealloc(), InfoMessageBox(), InitializeConnectionInfo(), InitMonitorDialog(), IntCreateDICW(), ISecurityObjectTypeInfo_fnGetInheritSource(), LookupAccountSidA(), malloc(), MirrorRgnByWidth(), MonSelSetMonitorsInfo(), OF(), Open(), operator new(), pCDevSettings_AllocAndCopyString(), pCDevSettings_GetDeviceInstanceId(), pCDevSettings_GetMonitorDevice(), pCDevSettings_GetMonitorName(), query_reg_path(), QueryDeskCplExtInterface(), QueryDeskCplString(), ReAlloc(), RegisterGPNotification(), ReloadPrincipalsList(), RpcpAddInterface(), serialize(), server_start(), SetSpyedBlockTableLength(), SetSystemEnvironment(), SetUserEnvironment(), SetUserEnvironmentVariable(), SHAddDataBlock(), SHCloneIETHREADPARAM(), SHCreateIETHREADPARAM(), SHCreatePropSheetExtArrayEx(), SHQueryValueExA(), SHQueryValueExW(), SHReadDataBlockList(), SKAllocValueW(), StatisticsMain(), StrDupA(), StrDupW(), test__hwrite(), test__lwrite(), test_EM_GETHANDLE(), test_enum_provider_types(), test_enum_providers(), test_get_default_provider(), test_heap(), test_LocalAlloc(), test_lsa(), test_sequence(), test_set_provider_ex(), U32AccelCacheAdd(), U32LoadAccelerators(), VfdCheckDriverFile(), VfdCreateImageFile(), VfdFormatMedia(), VfdGetDriverConfig(), VfdGetImageInfo(), VfdOpenImage(), VfdSaveImage(), Win32ErrorHandler(), Win32WarningHandler(), and WlxInitialize().

◆ LocalCompact()

SIZE_T NTAPI LocalCompact ( UINT  dwMinFree)

Definition at line 1492 of file heapmem.c.

1493 {
1494  /* Call the RTL Heap Manager */
1495  return RtlCompactHeap(BaseHeap, 0);
1496 }
NTSYSAPI ULONG WINAPI RtlCompactHeap(HANDLE, ULONG)
Definition: heap.c:2959
HANDLE BaseHeap
Definition: heapmem.c:19

◆ LocalFlags()

UINT NTAPI LocalFlags ( HLOCAL  hMem)

Definition at line 1503 of file heapmem.c.

1504 {
1505  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
1506  HANDLE Handle = NULL;
1507  ULONG Flags = 0;
1509 
1510  /* Start by locking the heap */
1512 
1513  /* Check if this is a simple RTL Heap Managed block */
1514  if (!((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
1515  {
1516  /* Then we'll query RTL Heap */
1518  BASE_TRACE_PTR(Handle, hMem);
1519 
1520  /*
1521  * Check if RTL Heap didn't find a handle associated with us or
1522  * said that this heap isn't movable, which means something we're
1523  * really not a handle-based heap.
1524  */
1525  if (!(Handle) || !(Flags & BASE_HEAP_FLAG_MOVABLE))
1526  {
1527  /* Then set the flags to 0 */
1528  uFlags = 0;
1529  }
1530  else
1531  {
1532  /* Otherwise we're handle-based, so get the internal handle */
1533  hMem = Handle;
1534  }
1535  }
1536 
1537  /* Check if the handle is actually an entry in our table */
1539  {
1540  /* Then get the entry */
1541  HandleEntry = BaseHeapGetEntry(hMem);
1542  BASE_TRACE_HANDLE(HandleEntry, hMem);
1543 
1544  /* Make sure it's a valid handle */
1545  if (BaseHeapValidateEntry(HandleEntry))
1546  {
1547  /* Get the lock count first */
1548  uFlags = HandleEntry->LockCount & LMEM_LOCKCOUNT;
1549 
1550  /* Now check if it's discardable */
1551  if (HandleEntry->Flags & BASE_HEAP_ENTRY_FLAG_REUSABLE)
1552  {
1553  /* Set the Win32 Flag */
1555  }
1556 
1557  /* Now check if it's discarded */
1558  if (HandleEntry->Flags & BASE_HEAP_ENTRY_FLAG_REUSE)
1559  /* Set the Win32 Flag */
1561  }
1562  }
1563 
1564  /* Check if by now, we still haven't gotten any useful flags */
1566 
1567  /* All done! Unlock heap and return Win32 Flags */
1569  return uFlags;
1570 }
#define LMEM_LOCKCOUNT
Definition: winbase.h:360
#define BASE_HEAP_ENTRY_FLAG_REUSE
Definition: baseheap.h:85
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
UINT uFlags
Definition: api.c:60
#define LMEM_DISCARDED
Definition: winbase.h:357
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define BASE_TRACE_PTR(x, y)
Definition: baseheap.h:50
#define LMEM_DISCARDABLE
Definition: winbase.h:353
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI RtlGetUserInfoHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, OUT PVOID *UserValue, OUT PULONG UserFlags)
Definition: heap.c:3772
_In_ HANDLE Handle
Definition: extypes.h:390
#define LMEM_INVALID_HANDLE
Definition: winbase.h:359
unsigned int UINT
Definition: ndis.h:50
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
#define BASE_HEAP_ENTRY_FLAG_REUSABLE
Definition: baseheap.h:84
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
unsigned int ULONG
Definition: retypes.h:1
USHORT LockCount
Definition: baseheap.h:71
USHORT Flags
Definition: baseheap.h:70

Referenced by AcpiNsLookup(), and test_heap().

◆ LocalFree()

HLOCAL NTAPI LocalFree ( HLOCAL  hMem)

Definition at line 1577 of file heapmem.c.

1578 {
1579  /* This is identical to a Global Free */
1580  return GlobalFree(hMem);
1581 }
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611

Referenced by _SHGetUserProfilePath(), _tmain(), _tWinMain(), AboutDialogProc(), AccFreeIndexArray(), AccpLookupSidByName(), AccpOpenNamedObject(), AccRewriteGetExplicitEntriesFromAcl(), AccRewriteGetHandleRights(), AccRewriteSetEntriesInAcl(), AddMenuItem(), AddPrincipalListEntry(), AddUserProfile(), AllocAndLoadString(), AllocAndLoadStringsCat(), AppendUserEnvironmentVariable(), ApplyParameterStringsToMessage(), AuthzFreeContext(), AuthzFreeResourceManager(), AuthzInitializeContextFromSid(), AuthzInitializeResourceManager(), AuthzpQueryToken(), BuildAdvPropTitle(), BuildLogListAndFilterList(), CallBackConvertToAscii(), CDataEncodeMsg_Close(), CDataEncodeMsg_Update(), CDecodeMsg_Close(), CDecodeMsg_DecodeContent(), CDecodeMsg_DecodeDataContent(), CDecodeMsg_DecodeHashedContent(), CDecodeMsg_FinalizeSignedContent(), CDecodeSignedMsg_GetParam(), Cert_free(), cert_get_name_from_rdn_attr(), cert_name_to_str_with_indent(), CertCreateCTLContext(), CertCreateSelfSignCertificate(), CertGetEnhancedKeyUsage(), CertGetNameStringW(), CertGetPublicKeyLength(), CertIsRDNAttrsInCertificateName(), CertIsValidCRLForCertificate(), CertNameToStrA(), CertSetEnhancedKeyUsage(), CertStrToNameW(), ChangeListViewText(), CheckEscapesA(), cleanUp(), client_stop(), Close(), cmd_type(), cmdHelpMsg(), CNG_ImportECCPubKey(), CNG_PrepareSignatureECC(), command_line_to_args(), CommandLineToArgvW(), compare_alt_name_with_constraints(), compare_crl_issued_by(), compare_subject_with_email_constraints(), compat_catpath(), ConMsgPrintf2V(), ConMsgPrintfV(), ConMsgPuts(), ConResMsgPrintfExV(), ConvertSecurityDescriptorToStringSecurityDescriptorA(), ConvertSecurityDescriptorToStringSecurityDescriptorW(), ConvertSidToStringSidA(), ConvertStringSecurityDescriptorToSecurityDescriptorW(), ConvertStringSidToSidW(), CopySystemProfile(), CreateApplicationWindow(), CreateDefaultSecurityDescriptor(), CreateEnvironmentBlock(), CreateFontWindow(), CreateUserProfileExW(), CRL_free(), CRYPT_AsnDecodeCert(), CRYPT_AsnDecodeCRL(), CRYPT_AsnDecodeRsaPrivKey(), CRYPT_AsnDecodeRsaPubKey(), CRYPT_AsnEncodeNameConstraints(), CRYPT_CheckChainNameConstraints(), CRYPT_CheckChainPolicies(), CRYPT_CheckUsages(), CRYPT_CreateSignedCert(), CRYPT_DecodeBasicConstraints(), CRYPT_EncodePKCSDigestedData(), CRYPT_FormatAltName(), CRYPT_FormatAuthorityInfoAccess(), CRYPT_FormatAuthorityKeyId2(), CRYPT_FormatBasicConstraints2(), CRYPT_FormatCPS(), CRYPT_FormatCRLDistPoints(), CRYPT_FormatEnhancedKeyUsage(), CRYPT_FormatKeyUsage(), CRYPT_FormatNetscapeCertType(), CRYPT_FormatUserNotice(), CRYPT_FreeSpace(), CRYPT_GetIssuer(), CRYPT_GetUrlFromCertificateIssuer(), CRYPT_GetUrlFromCRLDistPointsExt(), CRYPT_IsCertificateSelfSigned(), CryptHashPublicKeyInfo(), CryptHashToBeSigned(), CryptMsgEncodeAndSignCTL(), CryptUnprotectData(), CryptVerifyCertificateSignatureEx(), CSignedEncodeMsg_GetParam(), CSignedMsgData_AppendMessageDigestAttribute(), CSignedMsgData_UpdateAuthenticatedAttributes(), CTL_free(), debugstr_sid(), DecompressEnd(), DeleteDC(), DestroyAcceleratorTable(), DestroySecurityPage(), DeviceProblemTextW(), directory_name_matches(), display_app_usages(), display_error(), DisplayApplet(), DisplayDacl(), DisplayError(), DisplayStuffUsingWin32Setup(), DisplayWin32Error(), dlg_win32error(), DllMain(), Dns_Free(), DoCreate(), DoDeleteService(), DoFormatMessage(), DoStartService(), CVfdShExt::DoVfdDrop(), dump_alt_name(), dump_basic_constraints(), dump_cert_policies(), dump_enhanced_key_usage(), dump_name_constraints(), DumpEnum(), DumpUDT(), DwInitializeSdFromThreadToken(), EDIT_EM_SetHandle(), EDIT_WM_NCCreate(), EDIT_WM_NCDestroy(), EditSecurity(), EnterCriticalPolicySection(), enum_components(), enum_products(), EnumDeviceDrivers(), EnumPageFilesW(), EnumProcesses(), ErrorMessage(), COMExceptionBase::ErrorMessage(), ErrorMessageBox(), ErrorMsgBox(), export_validate_filename(), ExtractZipImage(), fill_sid(), find_cert_by_issuer(), FindDeviceDriver(), FindDfltProvRegVals(), FindProvTypesRegVals(), FontWndProc(), format_message(), FormatOutput(), FormatVerisignExtension(), free(), Free(), CLocalAllocator::Free(), free_file_op_queue(), FreeConnectionInfo(), FreePrincipalsList(), get_cert_common_name(), get_cps_str_from_qualifier(), get_file_handle(), get_module_version(), get_user_notice_from_qualifier(), GetBatteryState(), DriveVolume::GetClusterInfo(), getCurrentChannelConfig(), GetDeviceDriverBaseNameW(), GetDeviceDriverFileNameW(), getDeviceInterfaceDetail(), GetDeviceLocationString(), GetError(), GetEventCategory(), GetEventMessage(), GetEventUserName(), GetLastErrorText(), GetMappedFileNameA(), GetModuleBaseNameA(), GetModuleFileNameExA(), GetOwnerModuleFromTagEntry(), GetPerformanceInfo(), GetProcessImageFileNameA(), GetProcessImageFileNameW(), GetShellSecurityDescriptor(), GetUserAndDomainName(), GetUserNameA(), GetUserNameW(), GetUserSid(), GetUserSidStringFromToken(), GRPFILE_ReadGroupFile(), HandleSetHandlePrintHex(), Help(), HEXEDIT_HEM_LOADBUFFER(), HEXEDIT_HEM_SETMAXBUFFERSIZE(), HEXEDIT_WM_NCDESTROY(), HidD_FreePreparsedData(), HidD_GetPreparsedData(), IDeskDisplayAdapter_Destroy(), IDeskMonitor_Destroy(), IEffectivePermission_fnGetEffectivePermission(), IFileDialog2_fnRelease(), IFileDialog2_fnSetCancelButtonLabel(), IFileDialog2_fnSetDefaultExtension(), IFileDialog2_fnSetFileNameLabel(), IFileDialog2_fnSetOkButtonLabel(), IFileDialog2_fnSetTitle(), IMAPIMalloc_fnFree(), IMAPIMalloc_fnRealloc(), import_validate_filename(), InfoMessageBox(), InitDialog(), InitDisplayAdapterDialog(), InitializeSecurity(), InitMonitorDialog(), InitRecoveryPage(), InstallBuiltinAccounts(), InstallOneService(), InstallPrivileges(), is_ca_cert(), IStream_fnRelease(), last_error::last_error(), LoadAndFormatString(), LoadAndFormatStringsCat(), LogToFile(), LookupAccountSidA(), LsapGetDomainInfo(), LsapLookupAccountDomainSids(), LsapLookupBuiltinDomainSids(), LsapLookupWellKnownSids(), LsarpCreateAccount(), LsarpOpenAccount(), main(), map_name_2_sid(), match_dns_to_subject_alt_name(), match_dns_to_subject_dn(), mi_show_error(), MirrorRgnByWidth(), MonSelSetMonitorsInfo(), DriveVolume::MoveFileDumb(), msi_enum_patches(), MsiGetShortcutTargetW(), MSIREG_DeleteUserDataComponentKey(), MSIREG_DeleteUserDataPatchKey(), MSIREG_DeleteUserDataProductKey(), MSIREG_OpenFeaturesKey(), MSIREG_OpenInstallProps(), MSIREG_OpenProductKey(), MSIREG_OpenUserDataComponentKey(), MSIREG_OpenUserDataFeaturesKey(), MSIREG_OpenUserDataPatchKey(), MSIREG_OpenUserDataProductKey(), MSIREG_OpenUserDataProductPatchesKey(), MsiSourceListAddSourceW(), MyMessageBox(), NewDocSelDlgProc(), ntstatus_error::ntstatus_error(), OF(), OnBrowse(), OnDestroy(), OnOK(), operator delete(), output_formatstring(), OutputError(), OutputText(), pCDevSettings_FreeString(), pCDevSettings_GetDeviceInstanceId(), PerfDataRefresh(), playTestTone(), PrintError(), PrintErrorMessage(), PrintFileDacl(), PrintLastError(), printm(), PrintMessage(), PrintNetMessage(), PrintSid(), PrintWin32Error(), ProcessCmdLine(), query_reg_path(), read_key_value(), RecycleBin5_Constructor(), RegisterGPNotification(), RegistrationProc(), registry_callback(), REGPROC_print_error(), release_cert_info(), ReloadPrincipalsList(), ReportLastError(), ResetProgressDialog(), RpcpAddInterface(), RSAENH_CPGetProvParam(), SampAddMemberToAlias(), SampRemoveMemberFromAlias(), SampRemoveMemberFromAllAliases(), SampSetupAddMemberToAlias(), SamrGetAliasMembership(), SdSet(), SdShow(), serialize(), server_stop(), service_main(), set_file_name(), set_issuer_statement(), set_user_sid_prop(), SetControlText(), setCurrentChannelConfig(), SetRegUlong(), SetServiceStatusText(), SetStartupType(), SetSystemEnvironment(), SetUserEnvironment(), SetUserEnvironmentVariable(), SHDestroyIETHREADPARAM(), SHDestroyPropSheetExtArray(), ShellMessageBoxA(), ShellMessageBoxW(), ShellMessageBoxWrapW(), SHFreeDataBlockList(), SHLoadIndirectString(), ShowHelpWindow(), ShowLastError(), ShowLastWin32Error(), ShowMonitorProperties(), ShowWin32Error(), SHQueryValueExA(), SHQueryValueExW(), SHReadDataBlockList(), SHRemoveDataBlock(), START_TEST(), StartDocW(), StatisticsMain(), StatusBarLoadAndFormatString(), StatusBarLoadString(), stopTestTone(), store_key_pair(), TdbInsertToolbar(), test__hwrite(), test__lwrite(), test_appsearch_complocator(), test_BuildSecurityDescriptorW(), test_child_token_sd(), test_commandline2argv(), test_ConvertSecurityDescriptorToString(), test_ConvertStringSecurityDescriptor(), test_CreateDirectoryA(), test_CreateWellKnownSid(), test_cryptunprotectdata(), test_datalink(), test_decodeAltName(), test_decodeAuthorityInfoAccess(), test_decodeAuthorityKeyId(), test_decodeAuthorityKeyId2(), test_decodeBasicConstraints(), test_decodeBits(), test_decodeCatMemberInfo(), test_decodeCatNameValue(), test_decodeCert(), test_decodeCertPolicies(), test_decodeCertPolicyConstraints(), test_decodeCertPolicyMappings(), test_decodeCertToBeSigned(), test_decodeCMSSignerInfo(), test_decodeCRLDistPoints(), test_decodeCRLIssuingDistPoint(), test_decodeCRLToBeSigned(), test_decodeCTL(), test_decodeEnhancedKeyUsage(), test_decodeExtensions(), test_decodeInt(), test_decodeName(), test_decodeNameConstraints(), test_decodeNameValue(), test_decodeOctets(), test_decodePKCSAttribute(), test_decodePKCSAttributes(), test_decodePKCSContentInfo(), test_decodePKCSSignerInfo(), test_decodePKCSSMimeCapabilities(), test_decodePolicyQualifierUserNotice(), test_decodePublicKeyInfo(), test_decodeRsaPrivateKey(), test_decodeRsaPublicKey(), test_decodeSequenceOfAny(), test_decodeSPCLink(), test_decodeSPCPEImage(), test_decodeSpOpusInfo(), test_decodeUnicodeName(), test_decodeUnicodeNameValue(), test_EM_GETHANDLE(), test_encodeAltName(), test_encodeAuthorityInfoAccess(), test_encodeAuthorityKeyId(), test_encodeAuthorityKeyId2(), test_encodeBasicConstraints(), test_encodeBits(), test_encodeCatMemberInfo(), test_encodeCatNameValue(), test_encodeCert(), test_encodeCertPolicies(), test_encodeCertPolicyConstraints(), test_encodeCertPolicyMappings(), test_encodeCertToBeSigned(), test_encodeCMSSignerInfo(), test_encodeCRLDistPoints(), test_encodeCRLIssuingDistPoint(), test_encodeCRLToBeSigned(), test_encodeCTL(), test_encodeEnhancedKeyUsage(), test_encodeEnumerated(), test_encodeExtensions(), test_encodeInt(), test_encodeName(), test_encodeNameConstraints(), test_encodeNameValue(), test_encodeOctets(), test_encodePKCSAttribute(), test_encodePKCSAttributes(), test_encodePKCSContentInfo(), test_encodePKCSSignerInfo(), test_encodePKCSSMimeCapabilities(), test_encodePolicyQualifierUserNotice(), test_encodePublicKeyInfo(), test_encodeRsaPublicKey(), test_encodeSequenceOfAny(), test_encodeSPCFinancialCriteria(), test_encodeSPCLink(), test_encodeSPCPEImage(), test_encodeSpOpusInfo(), test_encodeUnicodeName(), test_encodeUnicodeNameValue(), test_enum_provider_types(), test_enum_providers(), test_get_default_provider(), test_GetExplicitEntriesFromAclW(), test_GetNamedSecurityInfoA(), test_GetSecurityInfo(), test_GetShellSecurityDescriptor(), test_GetSidSubAuthority(), test_heap(), test_IMalloc(), test_LocalAlloc(), test_LookupAccountSid(), test_lsa(), test_message_allocate_buffer(), test_message_allocate_buffer_wide(), test_MsiEnumClients(), test_MsiEnumComponents(), test_MsiEnumComponentsEx(), test_MsiEnumPatches(), test_MsiEnumPatchesEx(), test_MsiEnumProducts(), test_MsiEnumProductsEx(), test_MsiGetComponentPath(), test_MsiGetComponentPathEx(), test_MsiGetPatchInfoEx(), test_MsiGetProductCode(), test_MsiGetProductInfoEx(), test_MsiGetUserInfo(), test_MsiOpenProduct(), test_MsiQueryComponentState(), test_MsiQueryFeatureState(), test_MsiQueryProductState(), test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListAddSourceEx(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), test_MsiSourceListGetInfo(), test_MsiSourceListSetInfo(), test_one_cmdline(), test_PrivateObjectSecurity(), test_process_components(), test_reg_create_key(), test_reg_open_key(), test_register_user(), test_secure_connection(), test_security_descriptor(), test_sequence(), test_set_provider_ex(), test_SetEntriesInAclA(), test_SetEntriesInAclW(), test_SHGetShellKey(), test_sid(), test_sid_str(), test_simpleroundtrip(), test_StrDupA(), test_system_security_access(), test_token_attr(), test_token_label(), test_token_security_descriptor(), testAcquireCertPrivateKey(), TestCommandLine(), testTimeEncoding(), testVerifyCertSig(), testVerifyCertSigEx(), TrustIsCertificateSelfSigned(), TV1_AddDependantsToTree(), TV2_AddDependantsToTree(), U32LoadAccelerators(), UnregisterGPNotification(), UpdateControlStates(), UpdatePrincipalInfo(), UpdatePrincipalListItem(), UpdateServiceCount(), verify_cert_revocation_from_aia_ext(), VfdCheckDriverFile(), VfdCreateImageFile(), VfdFormatMedia(), VfdGetDriverConfig(), VfdGetImageInfo(), VfdGuiClose(), VfdGuiFormat(), VfdImageTip(), VfdMakeFileDesc(), VfdOpenImage(), VfdSaveImage(), WhoamiGroups(), WhoamiLogonId(), WhoamiUser(), Win32ErrorHandler(), Win32WarningHandler(), WINTRUST_GetTimeFromSigner(), WlxInitialize(), wWinMain(), and XCOPY_FailMessage().

◆ LocalHandle()

HLOCAL NTAPI LocalHandle ( LPCVOID  pMem)

Definition at line 1588 of file heapmem.c.

1589 {
1590  /* This is identical to a Global Handle */
1591  return GlobalHandle(pMem);
1592 }
HGLOBAL NTAPI GlobalHandle(LPCVOID pMem)
Definition: heapmem.c:705

Referenced by BcdOpenStoreFromFile(), CreateGreenFdo(), HandleSetHandlePrintHex(), IopCreateFile(), and test_LocalAlloc().

◆ LocalLock()

LPVOID NTAPI LocalLock ( HLOCAL  hMem)

Definition at line 1599 of file heapmem.c.

1600 {
1601  /* This is the same as a GlobalLock, assuming these never change */
1603  return GlobalLock(hMem);
1604 }
#define LMEM_LOCKCOUNT
Definition: winbase.h:360
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define C_ASSERT(e)
Definition: ntstrsafe.h:22
#define GMEM_LOCKCOUNT
Definition: winbase.h:306

Referenced by EDIT_EM_GetHandle(), EDIT_EM_SetHandle(), EDIT_LockBuffer(), EDIT_UnlockBuffer(), GRPFILE_ReadGroupFile(), GRPFILE_WriteGroupFile(), HandleSetHandlePrintHex(), HEXEDIT_Copy(), HEXEDIT_Delete(), HEXEDIT_HEM_COPYBUFFER(), HEXEDIT_HEM_LOADBUFFER(), HEXEDIT_PaintLines(), HEXEDIT_Paste(), HEXEDIT_WM_CHAR(), HEXEDIT_WM_KEYDOWN(), test__hwrite(), test__lwrite(), test_EM_GETHANDLE(), test_heap(), and test_LocalAlloc().

◆ LocalReAlloc()

HLOCAL NTAPI LocalReAlloc ( HLOCAL  hMem,
SIZE_T  dwBytes,
UINT  uFlags 
)

Definition at line 1608 of file heapmem.c.

1611 {
1612  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
1613  LPVOID Ptr;
1614  ULONG Flags = 0;
1615 
1616  /* Convert ZEROINIT */
1618 
1619  /* If this wasn't a movable heap, then we MUST re-alloc in place */
1621 
1622  /* Lock the heap and disable built-in locking in the RTL Heap functions */
1625 
1626  /* Check if this is a simple handle-based block */
1627  if (((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
1628  {
1629  /* Get the entry */
1630  HandleEntry = BaseHeapGetEntry(hMem);
1631  BASE_TRACE_HANDLE(HandleEntry, hMem);
1632 
1633  /* Make sure the handle is valid */
1634  if (!BaseHeapValidateEntry(HandleEntry))
1635  {
1636  /* Fail */
1639  hMem = NULL;
1640  }
1641  else if (uFlags & LMEM_MODIFY)
1642  {
1643  /* User is changing flags... check if the memory was discardable */
1644  if (uFlags & LMEM_DISCARDABLE)
1645  {
1646  /* Then set the flag */
1647  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSABLE;
1648  }
1649  else
1650  {
1651  /* Otherwise, remove the flag */
1652  HandleEntry->Flags &= ~BASE_HEAP_ENTRY_FLAG_REUSABLE;
1653  }
1654  }
1655  else
1656  {
1657  /* Otherwise, get the object and check if we have no size */
1658  Ptr = HandleEntry->Object;
1659  if (!dwBytes)
1660  {
1661  /* Clear the handle and check for a pointer */
1662  hMem = NULL;
1663  if (Ptr)
1664  {
1665  /* Make sure the handle isn't locked */
1666  if ((uFlags & LMEM_MOVEABLE) && !(HandleEntry->LockCount))
1667  {
1668  /* Free the current heap */
1670 
1671  /* Free the handle */
1672  HandleEntry->Object = NULL;
1673  HandleEntry->Flags |= BASE_HEAP_ENTRY_FLAG_REUSE;
1674 
1675  /* Get the object pointer */
1676  hMem = &HandleEntry->Object;
1677  }
1678  }
1679  else
1680  {
1681  /* Otherwise just return the object pointer */
1682  hMem = &HandleEntry->Object;
1683  }
1684  }
1685  else
1686  {
1687  /* Otherwise, we're allocating, so set the new flags needed */
1689  if (!Ptr)
1690  {
1691  /* We don't have a base, so allocate one */
1692  Ptr = RtlAllocateHeap(BaseHeap, Flags, dwBytes);
1694  if (Ptr)
1695  {
1696  /* Allocation succeeded, so save our entry */
1699  Ptr,
1700  hMem);
1701  }
1702  }
1703  else
1704  {
1705  /*
1706  * If it's not movable or currently locked, we MUST allocate
1707  * in-place!
1708  */
1709  if (!(uFlags & LMEM_MOVEABLE) && (HandleEntry->LockCount))
1710  {
1711  /* Set the flag */
1713  }
1714  else
1715  {
1716  /* Otherwise clear the flag if we set it previously */
1718  }
1719 
1720  /* And do the re-allocation */
1721  Ptr = RtlReAllocateHeap(BaseHeap, Flags, Ptr, dwBytes);
1722  }
1723 
1724  /* Make sure we have a pointer by now */
1725  if (Ptr)
1726  {
1727  /* Write it in the handle entry and mark it in use */
1728  HandleEntry->Object = Ptr;
1729  HandleEntry->Flags &= ~BASE_HEAP_ENTRY_FLAG_REUSE;
1730  }
1731  else
1732  {
1733  /* Otherwise we failed */
1734  hMem = NULL;
1736  }
1737  }
1738  }
1739  }
1740  else if (!(uFlags & LMEM_MODIFY))
1741  {
1742  /* Otherwise, this is a simple RTL Managed Heap, so just call it */
1743  hMem = RtlReAllocateHeap(BaseHeap,
1745  hMem,
1746  dwBytes);
1747  if (!hMem)
1748  {
1749  /* Fail */
1752  }
1753  }
1754 
1755  /* All done, unlock the heap and return the pointer */
1757  return hMem;
1758 }
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
#define BASE_HEAP_ENTRY_FLAG_REUSE
Definition: baseheap.h:85
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
UINT uFlags
Definition: api.c:60
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2552
#define HEAP_SETTABLE_USER_VALUE
Definition: nt_native.h:1704
#define BASE_TRACE_ALLOC2(x)
Definition: baseheap.h:47
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN NTAPI RtlSetUserValueHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress, IN PVOID UserValue)
Definition: heap.c:3655
#define LMEM_DISCARDABLE
Definition: winbase.h:353
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define LMEM_ZEROINIT
Definition: winbase.h:356
#define LMEM_MOVEABLE
Definition: winbase.h:350
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
#define BASE_HEAP_FLAG_MOVABLE
Definition: baseheap.h:98
PVOID Object
Definition: baseheap.h:74
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
#define LMEM_MODIFY
Definition: winbase.h:358
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BASE_HEAP_ENTRY_FLAG_REUSABLE
Definition: baseheap.h:84
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
USHORT LockCount
Definition: baseheap.h:71
USHORT Flags
Definition: baseheap.h:70
#define HEAP_REALLOC_IN_PLACE_ONLY
Definition: nt_native.h:1696

Referenced by AccRewriteGetHandleRights(), EDIT_LockBuffer(), EDIT_MakeFit(), EDIT_UnlockBuffer(), GetUserSid(), GetUserSidStringFromToken(), HEXEDIT_HEM_LOADBUFFER(), HEXEDIT_HEM_SETMAXBUFFERSIZE(), IMAPIMalloc_fnRealloc(), realloc(), ReAlloc(), CLocalAllocator::Reallocate(), SetSpyedBlockTableLength(), SHAddDataBlock(), SHReadDataBlockList(), SHRemoveDataBlock(), test_heap(), and test_LocalAlloc().

◆ LocalShrink()

SIZE_T WINAPI LocalShrink ( HLOCAL  hMem,
UINT  cbNewSize 
)

Definition at line 1765 of file heapmem.c.

1767 {
1768  /* Call RTL */
1769  return RtlCompactHeap(BaseHeap, 0);
1770 }
NTSYSAPI ULONG WINAPI RtlCompactHeap(HANDLE, ULONG)
Definition: heap.c:2959
HANDLE BaseHeap
Definition: heapmem.c:19

◆ LocalSize()

◆ LocalUnlock()

BOOL NTAPI LocalUnlock ( HLOCAL  hMem)

Definition at line 1788 of file heapmem.c.

1789 {
1790  PBASE_HEAP_HANDLE_ENTRY HandleEntry;
1791  BOOL RetVal = TRUE;
1792 
1793  /* Check if this was a simple allocated heap entry */
1794  if (!((ULONG_PTR)hMem & BASE_HEAP_IS_HANDLE_ENTRY))
1795  {
1796  /* Fail, because LocalUnlock is not supported on LMEM_FIXED allocations */
1798  return FALSE;
1799  }
1800 
1801  /* Otherwise, lock the heap */
1803 
1804  /* Get the handle entry */
1805  HandleEntry = BaseHeapGetEntry(hMem);
1806  BASE_TRACE_HANDLE(HandleEntry, hMem);
1807  _SEH2_TRY
1808  {
1809  /* Make sure it's valid */
1810  if (!BaseHeapValidateEntry(HandleEntry))
1811  {
1812  /* It's not, fail */
1815  RetVal = FALSE;
1816  }
1817  else
1818  {
1819  /* Otherwise, decrement lock count, unless we're already at 0*/
1820  if (!HandleEntry->LockCount--)
1821  {
1822  /* In which case we simply lock it back and fail */
1823  HandleEntry->LockCount++;
1825  RetVal = FALSE;
1826  }
1827  else if (!HandleEntry->LockCount)
1828  {
1829  /* Nothing to unlock */
1831  RetVal = FALSE;
1832  }
1833  }
1834  }
1836  {
1838  RetVal = FALSE;
1839  }
1840  _SEH2_END;
1841 
1842  /* All done. Unlock the heap and return the pointer */
1844  return RetVal;
1845 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
NTSYSAPI BOOLEAN WINAPI RtlLockHeap(HANDLE)
#define BASE_TRACE_HANDLE(x, y)
Definition: baseheap.h:53
#define NO_ERROR
Definition: dderror.h:5
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
#define BaseHeapGetEntry(h)
Definition: baseheap.h:107
Definition: baseheap.h:68
NTSYSAPI BOOLEAN WINAPI RtlUnlockHeap(HANDLE)
Definition: heap.c:3018
#define BASE_HEAP_IS_HANDLE_ENTRY
Definition: baseheap.h:91
HANDLE BaseHeap
Definition: heapmem.c:19
_SEH2_END
Definition: create.c:4424
#define BASE_TRACE_FAILURE()
Definition: baseheap.h:59
#define BaseHeapValidateEntry(he)
Definition: baseheap.h:113
USHORT LockCount
Definition: baseheap.h:71
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ERROR_NOT_LOCKED
Definition: winerror.h:230

Referenced by EDIT_EM_GetHandle(), EDIT_EM_SetHandle(), EDIT_LockBuffer(), EDIT_UnlockBuffer(), HandleSetHandlePrintHex(), HEXEDIT_Copy(), HEXEDIT_Delete(), HEXEDIT_HEM_COPYBUFFER(), HEXEDIT_HEM_LOADBUFFER(), HEXEDIT_PaintLines(), HEXEDIT_Paste(), HEXEDIT_WM_CHAR(), HEXEDIT_WM_KEYDOWN(), test_EM_GETHANDLE(), test_heap(), and test_LocalAlloc().

Variable Documentation

◆ BaseHeap

◆ BaseHeapHandleTable

RTL_HANDLE_TABLE BaseHeapHandleTable

Definition at line 18 of file heapmem.c.

Referenced by BaseDllInitializeMemoryManager().

◆ SystemRangeStart

ULONG_PTR SystemRangeStart

Definition at line 20 of file heapmem.c.

Referenced by BaseDllInitializeMemoryManager(), and GlobalLock().