Alexandre Julliard : kernel32: Move memory resource functions to kernelbase.

Alexandre Julliard julliard at winehq.org
Mon Sep 9 16:13:36 CDT 2019


Module: wine
Branch: master
Commit: 67a9700267f05da6425f52b6e68111c785b5019e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=67a9700267f05da6425f52b6e68111c785b5019e

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sun Sep  8 15:03:17 2019 +0200

kernel32: Move memory resource functions to kernelbase.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/kernel32.spec     |  4 +--
 dlls/kernel32/sync.c            | 62 -----------------------------------------
 dlls/kernelbase/kernelbase.spec |  4 +--
 dlls/kernelbase/memory.c        | 57 +++++++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 66 deletions(-)

diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index f856597..33c97fd 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -298,7 +298,7 @@
 @ stub CreateKernelThread
 @ stdcall CreateMailslotA(str long long ptr)
 @ stdcall CreateMailslotW(wstr long long ptr)
-@ stdcall CreateMemoryResourceNotification(long)
+@ stdcall -import CreateMemoryResourceNotification(long)
 @ stdcall -import CreateMutexA(ptr long str)
 @ stdcall -import CreateMutexExA(ptr str long long)
 @ stdcall -import CreateMutexExW(ptr wstr long long)
@@ -1166,7 +1166,7 @@
 # @ stub QueryIdleProcessorCycleTime
 # @ stub QueryIdleProcessorCycleTimeEx
 @ stdcall QueryInformationJobObject(long long ptr long ptr)
-@ stdcall QueryMemoryResourceNotification(ptr ptr)
+@ stdcall -import QueryMemoryResourceNotification(ptr ptr)
 @ stub QueryNumberOfEventLogRecords
 @ stub QueryOldestEventLogRecord
 @ stdcall QueryPerformanceCounter(ptr)
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index 9c2d29f..054b8c2 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -1009,68 +1009,6 @@ BOOL WINAPI BindIoCompletionCallback( HANDLE FileHandle, LPOVERLAPPED_COMPLETION
 }
 
 
-/***********************************************************************
- *           CreateMemoryResourceNotification   (KERNEL32.@)
- */
-HANDLE WINAPI CreateMemoryResourceNotification(MEMORY_RESOURCE_NOTIFICATION_TYPE type)
-{
-    static const WCHAR lowmemW[] =
-        {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
-         '\\','L','o','w','M','e','m','o','r','y','C','o','n','d','i','t','i','o','n',0};
-    static const WCHAR highmemW[] =
-        {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
-         '\\','H','i','g','h','M','e','m','o','r','y','C','o','n','d','i','t','i','o','n',0};
-    HANDLE ret;
-    UNICODE_STRING nameW;
-    OBJECT_ATTRIBUTES attr;
-    NTSTATUS status;
-
-    switch (type)
-    {
-    case LowMemoryResourceNotification:
-        RtlInitUnicodeString( &nameW, lowmemW );
-        break;
-    case HighMemoryResourceNotification:
-        RtlInitUnicodeString( &nameW, highmemW );
-        break;
-    default:
-        SetLastError( ERROR_INVALID_PARAMETER );
-        return 0;
-    }
-
-    attr.Length                   = sizeof(attr);
-    attr.RootDirectory            = 0;
-    attr.ObjectName               = &nameW;
-    attr.Attributes               = 0;
-    attr.SecurityDescriptor       = NULL;
-    attr.SecurityQualityOfService = NULL;
-    status = NtOpenEvent( &ret, EVENT_ALL_ACCESS, &attr );
-    if (status != STATUS_SUCCESS)
-    {
-        SetLastError( RtlNtStatusToDosError(status) );
-        return 0;
-    }
-    return ret;
-}
-
-/***********************************************************************
- *          QueryMemoryResourceNotification   (KERNEL32.@)
- */
-BOOL WINAPI QueryMemoryResourceNotification(HANDLE handle, PBOOL state)
-{
-    switch (WaitForSingleObject( handle, 0 ))
-    {
-    case WAIT_OBJECT_0:
-        *state = TRUE;
-        return TRUE;
-    case WAIT_TIMEOUT:
-        *state = FALSE;
-        return TRUE;
-    }
-    SetLastError( ERROR_INVALID_PARAMETER );
-    return FALSE;
-}
-
 #ifdef __i386__
 
 /***********************************************************************
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 4d5e644..e4125a4 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -194,7 +194,7 @@
 @ stdcall CreateHardLinkA(str str ptr) kernel32.CreateHardLinkA
 @ stdcall CreateHardLinkW(wstr wstr ptr) kernel32.CreateHardLinkW
 @ stdcall CreateIoCompletionPort(long long long long)
-@ stdcall CreateMemoryResourceNotification(long) kernel32.CreateMemoryResourceNotification
+@ stdcall CreateMemoryResourceNotification(long)
 @ stdcall CreateMutexA(ptr long str)
 @ stdcall CreateMutexExA(ptr str long long)
 @ stdcall CreateMutexExW(ptr wstr long long)
@@ -1202,7 +1202,7 @@
 # @ stub QueryIdleProcessorCycleTimeEx
 # @ stub QueryInterruptTime
 # @ stub QueryInterruptTimePrecise
-@ stdcall QueryMemoryResourceNotification(ptr ptr) kernel32.QueryMemoryResourceNotification
+@ stdcall QueryMemoryResourceNotification(ptr ptr)
 # @ stub QueryOptionalDelayLoadedAPI
 @ stdcall QueryPerformanceCounter(ptr) kernel32.QueryPerformanceCounter
 @ stdcall QueryPerformanceFrequency(ptr) kernel32.QueryPerformanceFrequency
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c
index ec9eace..aa834a3 100644
--- a/dlls/kernelbase/memory.c
+++ b/dlls/kernelbase/memory.c
@@ -382,3 +382,60 @@ BOOL WINAPI DECLSPEC_HOTPATCH HeapWalk( HANDLE heap, PROCESS_HEAP_ENTRY *entry )
 {
     return set_ntstatus( RtlWalkHeap( heap, entry ));
 }
+
+
+/***********************************************************************
+ * Memory resource functions
+ ***********************************************************************/
+
+
+/***********************************************************************
+ *           CreateMemoryResourceNotification   (kernelbase.@)
+ */
+HANDLE WINAPI DECLSPEC_HOTPATCH CreateMemoryResourceNotification( MEMORY_RESOURCE_NOTIFICATION_TYPE type )
+{
+    static const WCHAR lowmemW[] =
+        {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
+         '\\','L','o','w','M','e','m','o','r','y','C','o','n','d','i','t','i','o','n',0};
+    static const WCHAR highmemW[] =
+        {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
+         '\\','H','i','g','h','M','e','m','o','r','y','C','o','n','d','i','t','i','o','n',0};
+    HANDLE ret;
+    UNICODE_STRING nameW;
+    OBJECT_ATTRIBUTES attr;
+
+    switch (type)
+    {
+    case LowMemoryResourceNotification:
+        RtlInitUnicodeString( &nameW, lowmemW );
+        break;
+    case HighMemoryResourceNotification:
+        RtlInitUnicodeString( &nameW, highmemW );
+        break;
+    default:
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return 0;
+    }
+
+    InitializeObjectAttributes( &attr, &nameW, 0, 0, NULL );
+    if (!set_ntstatus( NtOpenEvent( &ret, EVENT_ALL_ACCESS, &attr ))) return 0;
+    return ret;
+}
+
+/***********************************************************************
+ *          QueryMemoryResourceNotification   (kernelbase.@)
+ */
+BOOL WINAPI DECLSPEC_HOTPATCH QueryMemoryResourceNotification( HANDLE handle, BOOL *state )
+{
+    switch (WaitForSingleObject( handle, 0 ))
+    {
+    case WAIT_OBJECT_0:
+        *state = TRUE;
+        return TRUE;
+    case WAIT_TIMEOUT:
+        *state = FALSE;
+        return TRUE;
+    }
+    SetLastError( ERROR_INVALID_PARAMETER );
+    return FALSE;
+}




More information about the wine-cvs mailing list