2 * PROJECT: ReactOS VT100 emulator
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/base/green/misc.c
5 * PURPOSE: Misceallenous operations
6 * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
16 IN PDEVICE_OBJECT DeviceObject
,
18 IN PVOID InputBuffer OPTIONAL
,
19 IN ULONG InputBufferSize
,
20 IN OUT PVOID OutputBuffer OPTIONAL
,
21 IN OUT PULONG OutputBufferSize
)
25 IO_STATUS_BLOCK IoStatus
;
28 KeInitializeEvent (&Event
, NotificationEvent
, FALSE
);
30 Irp
= IoBuildDeviceIoControlRequest(CtlCode
,
35 (OutputBufferSize
) ? *OutputBufferSize
: 0,
41 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
42 return STATUS_INSUFFICIENT_RESOURCES
;
45 Status
= IoCallDriver(DeviceObject
, Irp
);
47 if (Status
== STATUS_PENDING
)
49 DPRINT("Operation pending\n");
50 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
51 Status
= IoStatus
.Status
;
56 *OutputBufferSize
= IoStatus
.Information
;
64 IN PUNICODE_STRING RegistryPath
,
65 IN PGREEN_DRIVER_EXTENSION DriverExtension
)
67 UNICODE_STRING ParametersRegistryKey
;
68 RTL_QUERY_REGISTRY_TABLE Parameters
[4];
71 ULONG DefaultDeviceReported
= 0;
72 ULONG DefaultSampleRate
= 1200;
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
)
79 DPRINT("ExAllocatePool() failed\n");
80 return STATUS_INSUFFICIENT_RESOURCES
;
82 RtlCopyUnicodeString(&ParametersRegistryKey
, RegistryPath
);
83 RtlAppendUnicodeToString(&ParametersRegistryKey
, L
"\\Parameters");
84 ParametersRegistryKey
.Buffer
[ParametersRegistryKey
.Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
86 RtlZeroMemory(Parameters
, sizeof(Parameters
));
88 Parameters
[0].Flags
= RTL_QUERY_REGISTRY_DIRECT
;
89 Parameters
[0].Name
= L
"AttachedDevice";
90 Parameters
[0].EntryContext
= &DriverExtension
->AttachedDeviceName
;
92 Parameters
[1].Flags
= RTL_QUERY_REGISTRY_DIRECT
| RTL_REGISTRY_OPTIONAL
;
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
);
99 Parameters
[2].Flags
= RTL_QUERY_REGISTRY_DIRECT
| RTL_REGISTRY_OPTIONAL
;
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
);
106 Status
= RtlQueryRegistryValues(
107 RTL_REGISTRY_ABSOLUTE
,
108 ParametersRegistryKey
.Buffer
,