Commit 49ffaddf authored by Chip Davis's avatar Chip Davis Committed by Alexandre Julliard

kernel32: Forward power request functions to ntdll.

parent ca2b7012
......@@ -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];
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] );
}
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return INVALID_HANDLE_VALUE;
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;
}
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment