ReactOS 0.4.15-dev-6675-gcbc63d8
compmisc.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Composite Battery Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/drivers/bus/acpi/compbatt/compmisc.c
5 * PURPOSE: Miscellaneous Support Routines
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "compbatt.h"
12
13/* FUNCTIONS ******************************************************************/
14
24{
28 PIRP Irp;
29 PAGED_CODE();
30 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING BatteryIoctl\n");
31
32 /* Initialize the event and IRP */
41 &Event,
43 if (Irp)
44 {
45 /* Call the class driver miniport */
48 {
49 /* Wait for result */
52 }
53
54 /* Print failure */
55 if (!(NT_SUCCESS(Status)) && (CompBattDebug & 8))
56 DbgPrint("BatteryIoctl: Irp failed - %x\n", Status);
57
58 /* Done */
59 if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING BatteryIoctl\n");
60 }
61 else
62 {
63 /* Out of memory */
64 if (CompBattDebug & 8) DbgPrint("BatteryIoctl: couldn't create Irp\n");
66 }
67
68 /* Return status */
69 return Status;
70}
71
78{
82 PFILE_OBJECT LocalFileObject;
84 PAGED_CODE();
85
86 /* Open a file object handle to the device */
90 NULL,
91 NULL);
92 Status = ZwCreateFile(&DeviceHandle,
96 NULL,
97 0,
100 0,
101 NULL,
102 0);
103 if (NT_SUCCESS(Status))
104 {
105 /* Reference the file object */
107 0,
110 (PVOID)&LocalFileObject,
111 NULL);
112 if (NT_SUCCESS(Status))
113 {
114 /* Return the FO and the associated DO */
115 *FileObject = LocalFileObject;
116 *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject);
117 }
118
119 /* Close the handle */
121 }
122
123 /* Return status */
124 return Status;
125}
126
127/* EOF */
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
ULONG CompBattDebug
Definition: compbatt.c:17
NTSTATUS NTAPI CompBattGetDeviceObjectPointer(IN PUNICODE_STRING DeviceName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: compmisc.c:74
NTSTATUS NTAPI BatteryIoctl(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl)
Definition: compmisc.c:17
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_SHARE_READ
Definition: compat.h:136
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define FILE_OPEN
Definition: from_kernel.h:54
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
ULONG ACCESS_MASK
Definition: nt_native.h:40
@ SynchronizationEvent
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID _In_ ULONG _In_ BOOLEAN InternalDeviceIoControl
Definition: iofuncs.h:720
* PFILE_OBJECT
Definition: iotypes.h:1998
@ Executive
Definition: ketypes.h:403