kernel32: Forward power request functions to ntdll.

Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Chip Davis 2019-07-31 21:40:29 -05:00 committed by Alexandre Julliard
parent ca2b701249
commit 49ffaddf9b
2 changed files with 47 additions and 11 deletions

View File

@ -19,10 +19,15 @@
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(powermgnt);
@ -113,10 +118,36 @@ EXECUTION_STATE WINAPI SetThreadExecutionState(EXECUTION_STATE flags)
*/
HANDLE WINAPI PowerCreateRequest(REASON_CONTEXT *context)
{
FIXME("(%p): stub\n", context);
COUNTED_REASON_CONTEXT nt_context;
HANDLE handle;
NTSTATUS status;
WCHAR module_name[MAX_PATH];
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return INVALID_HANDLE_VALUE;
TRACE( "(%p)\n", context );
nt_context.Version = context->Version;
nt_context.Flags = context->Flags;
if (context->Flags & POWER_REQUEST_CONTEXT_SIMPLE_STRING)
RtlInitUnicodeString( &nt_context.u.SimpleString, context->Reason.SimpleReasonString );
else if (context->Flags & POWER_REQUEST_CONTEXT_DETAILED_STRING)
{
int i;
GetModuleFileNameW( context->Reason.Detailed.LocalizedReasonModule, module_name, ARRAY_SIZE(module_name) );
RtlInitUnicodeString( &nt_context.u.s.ResourceFileName, module_name );
nt_context.u.s.ResourceReasonId = context->Reason.Detailed.LocalizedReasonId;
nt_context.u.s.StringCount = context->Reason.Detailed.ReasonStringCount;
nt_context.u.s.ReasonStrings = heap_alloc( nt_context.u.s.StringCount * sizeof(UNICODE_STRING) );
for (i = 0; i < nt_context.u.s.StringCount; i++)
RtlInitUnicodeString( &nt_context.u.s.ReasonStrings[i], context->Reason.Detailed.ReasonStrings[i] );
}
status = NtCreatePowerRequest( &handle, &nt_context );
if (nt_context.Flags & POWER_REQUEST_CONTEXT_DETAILED_STRING)
heap_free( nt_context.u.s.ReasonStrings );
if (status)
SetLastError( RtlNtStatusToDosError(status) );
return status == STATUS_SUCCESS ? handle : INVALID_HANDLE_VALUE;
}
/***********************************************************************
@ -124,10 +155,10 @@ HANDLE WINAPI PowerCreateRequest(REASON_CONTEXT *context)
*/
BOOL WINAPI PowerSetRequest(HANDLE request, POWER_REQUEST_TYPE type)
{
FIXME("(%p, %u): stub\n", request, type);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
NTSTATUS status = NtSetPowerRequest( request, type );
if (status)
SetLastError( RtlNtStatusToDosError(status) );
return status == STATUS_SUCCESS;
}
/***********************************************************************
@ -135,8 +166,8 @@ BOOL WINAPI PowerSetRequest(HANDLE request, POWER_REQUEST_TYPE type)
*/
BOOL WINAPI PowerClearRequest(HANDLE request, POWER_REQUEST_TYPE type)
{
FIXME("(%p, %u): stub\n", request, type);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
NTSTATUS status = NtClearPowerRequest( request, type );
if (status)
SetLastError( RtlNtStatusToDosError(status) );
return status == STATUS_SUCCESS;
}

View File

@ -5585,6 +5585,11 @@ typedef enum _POWER_REQUEST_TYPE
PowerRequestAwayModeRequired
} POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
#define POWER_REQUEST_CONTEXT_VERSION 0
#define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
#define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
typedef union _FILE_SEGMENT_ELEMENT {
PVOID64 Buffer;
ULONGLONG Alignment;