kernel32: Move memory resource functions to kernelbase.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-09-08 15:03:17 +02:00
parent cad0f61808
commit 67a9700267
4 changed files with 61 additions and 66 deletions

View File

@ -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)

View File

@ -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__
/***********************************************************************

View File

@ -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

View File

@ -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;
}