ReactOS 0.4.16-dev-297-gc569aee
compmisc.c File Reference
#include "compbatt.h"
Include dependency graph for compmisc.c:

Go to the source code of this file.

Functions

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)
 
NTSTATUS NTAPI CompBattGetDeviceObjectPointer (IN PUNICODE_STRING DeviceName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
 

Function Documentation

◆ BatteryIoctl()

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 at line 17 of file compmisc.c.

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}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
ULONG CompBattDebug
Definition: compbatt.c:17
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
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_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_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
@ Executive
Definition: ketypes.h:415

Referenced by CompBattGetBatteryGranularity(), and CompBattGetBatteryInformation().

◆ CompBattGetDeviceObjectPointer()

NTSTATUS NTAPI CompBattGetDeviceObjectPointer ( IN PUNICODE_STRING  DeviceName,
IN ACCESS_MASK  DesiredAccess,
OUT PFILE_OBJECT FileObject,
OUT PDEVICE_OBJECT DeviceObject 
)

Definition at line 74 of file compmisc.c.

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}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_OPEN
Definition: from_kernel.h:54
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
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
_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
* PFILE_OBJECT
Definition: iotypes.h:1998

Referenced by CompBattAddNewBattery().