Check for GMEM_ZEROINIT flag and pass HEAP_ZERO_MEMORY flag to RtlAllocateHeap if...
[reactos.git] / reactos / lib / kernel32 / mem / global.c
index 72cad0d..5532043 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: global.c,v 1.6 2001/04/05 01:54:16 ekohl Exp $
+/* $Id: global.c,v 1.10 2002/10/28 15:08:32 robd Exp $
  *
  * Win32 Global/Local heap functions (GlobalXXX, LocalXXX).
  * These functions included in Win32 for compatibility with 16 bit Windows
@@ -46,7 +46,10 @@ GlobalAlloc(UINT uFlags,
 
    if ((uFlags & GMEM_MOVEABLE)==0) /* POINTER */
      {
-       return ((HGLOBAL)RtlAllocateHeap(hProcessHeap, 0, dwBytes));
+       if ((uFlags & GMEM_ZEROINIT)==0)
+          return ((HGLOBAL)RtlAllocateHeap(hProcessHeap, 0, dwBytes));
+          else
+          return ((HGLOBAL)RtlAllocateHeap(hProcessHeap, HEAP_ZERO_MEMORY, dwBytes));
      }
    else  /* HANDLE */
      {
@@ -218,7 +221,39 @@ GlobalLock(HGLOBAL hMem)
 VOID STDCALL
 GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
 {
-   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       NTSTATUS                Status;
+       SYSTEM_PERFORMANCE_INFO Spi;
+       QUOTA_LIMITS            Ql;
+       VM_COUNTERS             Vmc;
+       PIMAGE_NT_HEADERS       ImageNtHeader;
+
+       RtlZeroMemory (lpBuffer, sizeof (MEMORYSTATUS));
+       lpBuffer->dwLength = sizeof (MEMORYSTATUS);
+       Status = NtQuerySystemInformation (
+                       SystemPerformanceInformation,
+                       & Spi,
+                       sizeof Spi,
+                       NULL
+                       );
+       /* FIXME: perform computations and fill lpBuffer fields */
+       Status = NtQueryInformationProcess (
+                       GetCurrentProcess(),
+                       ProcessQuotaLimits,
+                       & Ql,
+                       sizeof Ql,
+                       NULL
+                       );
+       /* FIXME: perform computations and fill lpBuffer fields */
+       Status = NtQueryInformationProcess (
+                       GetCurrentProcess(),
+                       ProcessVmCounters,
+                       & Vmc,
+                       sizeof Vmc,
+                       NULL
+                       );
+       /* FIXME: perform computations and fill lpBuffer fields */
+       ImageNtHeader = RtlImageNtHeader ((PVOID)NtCurrentPeb()->ImageBaseAddress);
+       /* FIXME: perform computations and fill lpBuffer fields */
 }