ReactOS  0.4.14-dev-376-gaedba84
misc.c File Reference
#include "green.h"
#include <debug.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS GreenDeviceIoControl (IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer OPTIONAL, IN OUT PULONG OutputBufferSize)
 
NTSTATUS ReadRegistryEntries (IN PUNICODE_STRING RegistryPath, IN PGREEN_DRIVER_EXTENSION DriverExtension)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file misc.c.

Function Documentation

◆ GreenDeviceIoControl()

NTSTATUS GreenDeviceIoControl ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  CtlCode,
IN PVOID InputBuffer  OPTIONAL,
IN ULONG  InputBufferSize,
IN OUT PVOID OutputBuffer  OPTIONAL,
IN OUT PULONG  OutputBufferSize 
)

Definition at line 15 of file misc.c.

22 {
23  KEVENT Event;
24  PIRP Irp;
27 
29 
33  InputBufferSize,
35  (OutputBufferSize) ? *OutputBufferSize : 0,
36  FALSE,
37  &Event,
38  &IoStatus);
39  if (Irp == NULL)
40  {
41  DPRINT("IoBuildDeviceIoControlRequest() failed\n");
43  }
44 
46 
47  if (Status == STATUS_PENDING)
48  {
49  DPRINT("Operation pending\n");
51  Status = IoStatus.Status;
52  }
53 
54  if (OutputBufferSize)
55  {
56  *OutputBufferSize = IoStatus.Information;
57  }
58 
59  return Status;
60 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
CHAR InputBuffer[80]
Definition: conmgr.c:33
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
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

Referenced by CreateGreenFdo().

◆ ReadRegistryEntries()

NTSTATUS ReadRegistryEntries ( IN PUNICODE_STRING  RegistryPath,
IN PGREEN_DRIVER_EXTENSION  DriverExtension 
)

Definition at line 63 of file misc.c.

66 {
67  UNICODE_STRING ParametersRegistryKey;
70 
71  ULONG DefaultDeviceReported = 0;
72  ULONG DefaultSampleRate = 1200;
73 
74  ParametersRegistryKey.Length = 0;
75  ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
76  ParametersRegistryKey.Buffer = ExAllocatePool(PagedPool, ParametersRegistryKey.MaximumLength);
77  if (!ParametersRegistryKey.Buffer)
78  {
79  DPRINT("ExAllocatePool() failed\n");
81  }
82  RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
83  RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
84  ParametersRegistryKey.Buffer[ParametersRegistryKey.Length / sizeof(WCHAR)] = UNICODE_NULL;
85 
87 
89  Parameters[0].Name = L"AttachedDevice";
90  Parameters[0].EntryContext = &DriverExtension->AttachedDeviceName;
91 
93  Parameters[1].Name = L"DeviceReported";
94  Parameters[1].EntryContext = &DriverExtension->DeviceReported;
95  Parameters[1].DefaultType = REG_DWORD;
96  Parameters[1].DefaultData = &DefaultDeviceReported;
97  Parameters[1].DefaultLength = sizeof(ULONG);
98 
100  Parameters[2].Name = L"SampleRate";
101  Parameters[2].EntryContext = &DriverExtension->SampleRate;
102  Parameters[2].DefaultType = REG_DWORD;
103  Parameters[2].DefaultData = &DefaultSampleRate;
104  Parameters[2].DefaultLength = sizeof(ULONG);
105 
108  ParametersRegistryKey.Buffer,
109  Parameters,
110  NULL,
111  NULL);
112 
113  return Status;
114 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define RTL_REGISTRY_OPTIONAL
Definition: nt_native.h:169
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define REG_DWORD
Definition: sdbapi.c:596
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144