109{
114
116 WCHAR wszDeviceName[255]={0};
118 LONG instanceNumber=0;
119
121
123
124 swprintf(wszDeviceName,
L"\\Device\\FbtUsb%02d", instanceNumber);
127 while (instanceNumber<99 && !
NT_SUCCESS(ntStatus))
128 {
129 swprintf(wszDeviceName,
L"\\Device\\FbtUsb%02d", instanceNumber);
131 FreeBT_DbgPrint(1, (
"FBTUSB: Attempting to create device %ws\n", wszDeviceName));
135 &uniDeviceName,
137 0,
140
142 instanceNumber++;
143
144 }
145
147 {
149 return ntStatus;
150
151 }
152
154
159
160 swprintf(deviceExtension->wszDosDeviceName,
L"\\DosDevices\\FbtUsb%02d", instanceNumber);
164 {
165 FreeBT_DbgPrint(1, (
"FBTUSB: Failed to create symbolic link %ws to %ws, status=0x%08x\n", deviceExtension->wszDosDeviceName, wszDeviceName, ntStatus));
167 return ntStatus;
168
169 }
170
171 FreeBT_DbgPrint(1, (
"FBTUSB: Created symbolic link %ws\n", deviceExtension->wszDosDeviceName));
172
174
176
177 deviceExtension->OpenHandleCount = 0;
178
179
181 deviceExtension->IdleReqPend = 0;
182 deviceExtension->PendingIdleIrp =
NULL;
183
184
186
187
190
191
193
194
195
197
198
199
200
201 deviceExtension->OutStandingIO = 1;
203
204#ifdef ENABLE_WMI
205
208 {
209 FreeBT_DbgPrint(1, (
"FBTUSB: FreeBT_WmiRegistration failed with %X\n", ntStatus));
212 return ntStatus;
213
214 }
215#endif
216
217
219 {
221
222 }
223
224
225
226
227
228
231
234
235
236
237
239 if (
NULL == deviceExtension->TopOfStackDeviceObject)
240 {
241#ifdef ENABLE_WMI
243#endif
247
248 }
249
250
252 &GUID_CLASS_FREEBT_USB,
254 &deviceExtension->InterfaceName);
256 {
257#ifdef ENABLE_WMI
259#endif
263 return ntStatus;
264
265 }
266
268 {
270
271 }
272
274 {
276
277 }
278
280 {
282
283 }
284
286 {
288
289 }
290
291 deviceExtension->SSRegistryEnable = 0;
292 deviceExtension->SSEnable = 0;
293
294
295
297 {
300 (
PULONG)(&deviceExtension->SSRegistryEnable));
301 if (deviceExtension->SSRegistryEnable)
302 {
303
305
306
307
308
309
311
312
313
314
316
317
318
320
321 }
322
323 }
324
325
326
328
329
330
331
334
336
337 return ntStatus;
338
339}
#define InterlockedIncrement
PDEVICE_OBJECT PhysicalDeviceObject
#define NT_SUCCESS(StatCode)
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
#define KeInitializeEvent(pEvt, foo, foo2)
#define InitializeListHead(ListHead)
#define KeInitializeSpinLock(sl)
NTSTATUS NTAPI FreeBT_GetRegistryDword(IN PWCHAR RegPath, IN PWCHAR ValueName, IN OUT PULONG Value)
VOID NTAPI DpcRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
#define FREEBT_REGISTRY_PARAMETERS_PATH
#define INITIALIZE_PNP_STATE(_Data_)
NTSTATUS NTAPI FreeBT_WmiRegistration(IN OUT PDEVICE_EXTENSION DeviceExtension)
NTSTATUS NTAPI FreeBT_WmiDeRegistration(IN OUT PDEVICE_EXTENSION DeviceExtension)
MxDeviceObject deviceObject
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTSTATUS NTAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
BOOLEAN NTAPI IoIsWdmVersionAvailable(IN UCHAR MajorVersion, IN UCHAR MinorVersion)
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
#define FILE_DEVICE_UNKNOWN
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
#define STATUS_NO_SUCH_DEVICE
#define STATUS_OBJECT_NAME_COLLISION