Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

648 lines
19 KiB

  1. // @doc
  2. /**********************************************************************
  3. *
  4. * @module GckShell.c |
  5. *
  6. * Basic driver entry points for GcKernel.sys
  7. *
  8. * History
  9. * ----------------------------------------------------------
  10. * Mitchell S. Dernis Original
  11. *
  12. * (c) 1986-1998 Microsoft Corporation. All right reserved.
  13. *
  14. * @topic GckShell |
  15. * Contains the most basic driver entry points (that any NT\WDM driver
  16. * would have) for GcKernel.sys.
  17. *
  18. **********************************************************************/
  19. #define __DEBUG_MODULE_IN_USE__ GCK_GCKSHELL_C
  20. #include <wdm.h>
  21. #include "Debug.h"
  22. #include "GckShell.h"
  23. #include "vmmid.h"
  24. #ifdef BUILD_98
  25. extern void* KeyBoardHook(void);
  26. #endif
  27. //
  28. // Mark the pageable routines as such
  29. //
  30. #ifdef ALLOC_PRAGMA
  31. #pragma alloc_text (INIT, DriverEntry)
  32. #pragma alloc_text (PAGE, GCK_Create)
  33. #pragma alloc_text (PAGE, GCK_Close)
  34. #pragma alloc_text (PAGE, GCK_Unload)
  35. #endif
  36. //
  37. // Allow debug output for this moduel, and set the intial level
  38. //
  39. DECLARE_MODULE_DEBUG_LEVEL((DBG_WARN|DBG_ERROR|DBG_CRITICAL));
  40. //
  41. // Instance the global variables
  42. //
  43. GCK_GLOBALS Globals;
  44. ULONG ulWaitTime = 30;
  45. #ifdef BUILD_98
  46. #pragma data_seg("_LDATA", "LCODE")
  47. LONG g_lHookRefCount = 0;
  48. ULONG g_rgdwKeyEvents[50] = { 0 };
  49. ULONG g_pPreviousKeyhook = 0;
  50. UCHAR g_ucWriteIndex = 0;
  51. UCHAR g_ucReadIndex = 0;
  52. #pragma data_seg()
  53. #pragma code_seg("_LTEXT", "LCODE")
  54. #endif BUILD_98
  55. void KeyHookC(ULONG dwScanCode)
  56. {
  57. #ifdef BUILD_98
  58. g_rgdwKeyEvents[g_ucWriteIndex++] = dwScanCode;
  59. if (g_ucWriteIndex >= 50)
  60. {
  61. g_ucWriteIndex = 0;
  62. }
  63. #else !BUILD_98
  64. UNREFERENCED_PARAMETER (dwScanCode);
  65. #endif BUILD_98
  66. }
  67. #ifdef BUILD_98
  68. //-----------------------------------------------------------------------------
  69. // InitHook - Sets up the keyboard hook
  70. //-----------------------------------------------------------------------------
  71. BOOLEAN HookKeyboard(void)
  72. {
  73. volatile ULONG dwHook = (ULONG)KeyBoardHook;
  74. RtlZeroMemory((void*)g_rgdwKeyEvents, sizeof(ULONG) * 50);
  75. g_ucWriteIndex = 0;
  76. g_ucReadIndex = 0;
  77. // GetVxDServiceOrdinal eax, VKD_Filter_Keyboard_Input
  78. __asm mov eax, __VKD_Filter_Keyboard_Input
  79. __asm mov esi, dwHook
  80. VxDCall(__Hook_Device_Service)
  81. __asm jc initfail
  82. __asm mov [g_pPreviousKeyhook], esi // Since we are using C we can't use the funky callback
  83. return TRUE;
  84. initfail:
  85. return FALSE;
  86. };
  87. #pragma code_seg()
  88. void UnHookKeyboard()
  89. {
  90. volatile ULONG dwHook = (ULONG)KeyBoardHook;
  91. // GetVxDServiceOrdinal eax, VKD_Filter_Keyboard_Input
  92. __asm mov eax, __VKD_Filter_Keyboard_Input
  93. __asm mov esi, dwHook
  94. VxDCall(__Unhook_Device_Service)
  95. __asm clc
  96. }
  97. #endif BUILD_98
  98. /***********************************************************************************
  99. **
  100. ** NTSTATUS DriverEntry(IN PDRIVER_OBJECT pDriverObject, IN PUNICODE_STRING pRegistryPath )
  101. **
  102. ** @func Standard DriverEntry routine
  103. **
  104. ** @rdesc STATUS_SUCCESS or various errors
  105. **
  106. *************************************************************************************/
  107. NTSTATUS DriverEntry
  108. (
  109. IN PDRIVER_OBJECT pDriverObject, // @parm Driver Object
  110. IN PUNICODE_STRING puniRegistryPath // @parm Path to driver specific registry section.
  111. )
  112. {
  113. NTSTATUS NtStatus = STATUS_SUCCESS;
  114. int i;
  115. UNREFERENCED_PARAMETER (puniRegistryPath);
  116. PAGED_CODE();
  117. GCK_DBG_CRITICAL_PRINT(("Built %s at %s\n", __DATE__, __TIME__));
  118. GCK_DBG_CRITICAL_PRINT(("Entering DriverEntry, pDriverObject = 0x%0.8x, puniRegistryPath = %s\n", pDriverObject, puniRegistryPath));
  119. // Allow Control Device module to initialize itself
  120. NtStatus = GCK_CTRL_DriverEntry(pDriverObject, puniRegistryPath);
  121. if( NT_ERROR(NtStatus) )
  122. {
  123. return NtStatus;
  124. }
  125. // Allow Filter Device module to initialize itself
  126. NtStatus = GCK_FLTR_DriverEntry(pDriverObject, puniRegistryPath);
  127. if( NT_ERROR(NtStatus) )
  128. {
  129. return NtStatus;
  130. }
  131. // Allow SideWinder Virtual Bus module to initialize itself
  132. NtStatus = GCK_SWVB_DriverEntry(pDriverObject, puniRegistryPath);
  133. if( NT_ERROR(NtStatus) )
  134. {
  135. return NtStatus;
  136. }
  137. // Allow SideWinder Virtual Keyboard module to initialize itself
  138. NtStatus = GCK_VKBD_DriverEntry(pDriverObject, puniRegistryPath);
  139. if( NT_ERROR(NtStatus) )
  140. {
  141. return NtStatus;
  142. }
  143. // Hook all IRPs so we can pass them on.
  144. GCK_DBG_TRACE_PRINT(("Filling out entry point structure\n"));
  145. for (i=0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
  146. {
  147. pDriverObject->MajorFunction[i] = GCK_Pass;
  148. }
  149. // Initialize any shared global data
  150. #ifdef BUILD_98
  151. g_lHookRefCount = 0;
  152. #endif
  153. // Define entries for IRPs we expect to handle
  154. pDriverObject->MajorFunction[IRP_MJ_CREATE] = GCK_Create;
  155. pDriverObject->MajorFunction[IRP_MJ_CLOSE] = GCK_Close;
  156. pDriverObject->MajorFunction[IRP_MJ_READ] = GCK_Read;
  157. pDriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
  158. pDriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = GCK_Ioctl;
  159. pDriverObject->MajorFunction[IRP_MJ_PNP] = GCK_PnP;
  160. pDriverObject->MajorFunction[IRP_MJ_POWER] = GCK_Power;
  161. pDriverObject->DriverExtension->AddDevice = GCK_FLTR_AddDevice; //only the filter has an add device
  162. pDriverObject->DriverUnload = GCK_Unload;
  163. GCK_DBG_EXIT_PRINT (("Normal exit of DriverEntry: 0x%0.8x\n", NtStatus));
  164. return NtStatus;
  165. }
  166. /***********************************************************************************
  167. **
  168. ** VOID GCK_Unload(IN PDRIVER_OBJECT pDriverObject )
  169. **
  170. ** @func Called to unload driver, delete Control Device here
  171. **
  172. *************************************************************************************/
  173. VOID GCK_Unload
  174. (
  175. IN PDRIVER_OBJECT pDriverObject // @parm Driver Object for our driver
  176. )
  177. {
  178. PAGED_CODE ();
  179. GCK_DBG_ENTRY_PRINT(("Entering GCK_Unload, pDriverObject = 0x%0.8x\n", pDriverObject));
  180. UNREFERENCED_PARAMETER(pDriverObject);
  181. GCK_SWVB_UnLoad();
  182. //
  183. // We should not be unloaded until all the PDOs have been removed from
  184. // our queue. The control device object should be the only thing left.
  185. //
  186. ASSERT (NULL == pDriverObject->DeviceObject);
  187. ASSERT (NULL == Globals.pControlObject);
  188. GCK_DBG_EXIT_PRINT(("Exiting GCK_Unload\n"));
  189. return;
  190. }
  191. /***********************************************************************************
  192. **
  193. ** NTSTATUS GCK_Create ( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp )
  194. **
  195. ** @func Handles the IRP_MJ_CREATE - Generated by Win32 CreateFile or OpenFile
  196. **
  197. ** @rdesc STATUS_SUCCESS, or various error codes
  198. **
  199. *************************************************************************************/
  200. NTSTATUS GCK_Create (
  201. IN PDEVICE_OBJECT pDeviceObject, // @parm Device Object for context of IRP
  202. IN PIRP pIrp // @parm pointer to IRP
  203. )
  204. {
  205. NTSTATUS NtStatus;
  206. ULONG ulGckDevObjType;
  207. PAGED_CODE ();
  208. GCK_DBG_ENTRY_PRINT (("GCK_Create, pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  209. KdPrint(("GCK_Create, pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  210. ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  211. switch(ulGckDevObjType)
  212. {
  213. case GCK_DO_TYPE_CONTROL:
  214. KdPrint((" -- GCK_DO_TYPE_CONTROL\n"));
  215. NtStatus = GCK_CTRL_Create(pDeviceObject, pIrp);
  216. break;
  217. case GCK_DO_TYPE_FILTER:
  218. KdPrint((" -- GCK_DO_TYPE_FILTER\n"));
  219. NtStatus = GCK_FLTR_Create(pDeviceObject, pIrp);
  220. break;
  221. case GCK_DO_TYPE_SWVB:
  222. KdPrint((" -- GCK_DO_TYPE_SWVB\n"));
  223. NtStatus = GCK_SWVB_Create(pDeviceObject, pIrp);
  224. break;
  225. default:
  226. //
  227. // If this assertion is hit, this Device Object was never properly initialized
  228. // by GcKernel, or it has been trashed.
  229. //
  230. ASSERT(FALSE);
  231. NtStatus = STATUS_UNSUCCESSFUL;
  232. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  233. }
  234. GCK_DBG_EXIT_PRINT(("Exiting GCK_Create. Status: 0x%0.8x\n", NtStatus));
  235. KdPrint(("Exiting GCK_Create. Status: 0x%0.8x\n", NtStatus));
  236. return NtStatus;
  237. }
  238. /***********************************************************************************
  239. **
  240. ** NTSTATUS GCK_Close ( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp )
  241. **
  242. ** @func Handles IRP_MJ_CLOSE - Generated by Win32 CloseFile
  243. **
  244. ** @rdesc STATUS_SUCCESS or various errors
  245. **
  246. *************************************************************************************/
  247. NTSTATUS GCK_Close (
  248. IN PDEVICE_OBJECT pDeviceObject, // @parm pointer DeviceObject for context
  249. IN PIRP pIrp // @parm pointer to IRP to handle
  250. )
  251. {
  252. NTSTATUS NtStatus;
  253. ULONG ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  254. PAGED_CODE ();
  255. GCK_DBG_ENTRY_PRINT (("GCK_Close, pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  256. ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  257. switch(ulGckDevObjType)
  258. {
  259. case GCK_DO_TYPE_CONTROL:
  260. NtStatus = GCK_CTRL_Close(pDeviceObject, pIrp);
  261. break;
  262. case GCK_DO_TYPE_FILTER:
  263. NtStatus = GCK_FLTR_Close(pDeviceObject, pIrp);
  264. break;
  265. case GCK_DO_TYPE_SWVB:
  266. NtStatus = GCK_SWVB_Close(pDeviceObject, pIrp);
  267. break;
  268. default:
  269. //
  270. // If this assertion is hit, this Device Object was never properly initialized
  271. // by GcKernel, or it has been trashed.
  272. //
  273. ASSERT(FALSE);
  274. NtStatus = STATUS_UNSUCCESSFUL;
  275. }
  276. GCK_DBG_EXIT_PRINT(("Exiting GCK_Close. Status: 0x%0.8x\n", NtStatus));
  277. return NtStatus;
  278. }
  279. /***********************************************************************************
  280. **
  281. ** NTSTATUS GCK_Read (IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp)
  282. **
  283. ** @func Handles IRP_MJ_READ - Generated by Win32 ReadFile
  284. **
  285. ** @rdesc STATUS_SUCCESS, or various errors
  286. **
  287. *************************************************************************************/
  288. NTSTATUS GCK_Read
  289. (
  290. IN PDEVICE_OBJECT pDeviceObject, // @parm Device Object as our context
  291. IN PIRP pIrp // @parm IRP to handle
  292. )
  293. {
  294. NTSTATUS NtStatus;
  295. ULONG ulGckDevObjType;
  296. GCK_DBG_RT_ENTRY_PRINT(("Entering GCK_Read. pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  297. ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  298. switch(ulGckDevObjType)
  299. {
  300. case GCK_DO_TYPE_CONTROL:
  301. NtStatus = STATUS_NOT_SUPPORTED;
  302. //Assert as we shouldn't get read on the control device
  303. ASSERT( NT_SUCCESS(NtStatus) );
  304. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  305. break;
  306. case GCK_DO_TYPE_FILTER:
  307. NtStatus = GCK_FLTR_Read(pDeviceObject, pIrp);
  308. break;
  309. case GCK_DO_TYPE_SWVB:
  310. NtStatus = GCK_SWVB_Read(pDeviceObject, pIrp);
  311. break;
  312. default:
  313. //
  314. // If this assertion is hit, this Device Object was never properly initialized
  315. // by GcKernel, or it has been trashed.
  316. //
  317. ASSERT(FALSE);
  318. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  319. NtStatus = STATUS_UNSUCCESSFUL;
  320. }
  321. GCK_DBG_EXIT_PRINT(("Exiting GCK_Read. Status: 0x%0.8x\n", NtStatus));
  322. return NtStatus;
  323. }
  324. /***********************************************************************************
  325. **
  326. ** NTSTATUS GCK_Power (IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp)
  327. **
  328. ** @func Handles IRP_MJ_POWER
  329. **
  330. ** @rdesc STATUS_SUCCESS, or various errors
  331. **
  332. *************************************************************************************/
  333. NTSTATUS GCK_Power
  334. (
  335. IN PDEVICE_OBJECT pDeviceObject, // @parm Device Object for our context
  336. IN PIRP pIrp // @parm IRP to handle
  337. )
  338. {
  339. NTSTATUS NtStatus;
  340. ULONG ulGckDevObjType;
  341. GCK_DBG_ENTRY_PRINT(("Entering GCK_Power. pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  342. ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  343. switch(ulGckDevObjType)
  344. {
  345. case GCK_DO_TYPE_CONTROL:
  346. NtStatus = STATUS_NOT_SUPPORTED;
  347. //Assert as we shouldn't get power on the control device
  348. ASSERT( NT_SUCCESS(NtStatus) );
  349. IoCompleteRequest(pIrp, IO_NO_INCREMENT);
  350. break;
  351. case GCK_DO_TYPE_FILTER:
  352. NtStatus = GCK_FLTR_Power(pDeviceObject, pIrp);
  353. break;
  354. case GCK_DO_TYPE_SWVB:
  355. NtStatus = GCK_SWVB_Power(pDeviceObject, pIrp);
  356. break;
  357. default:
  358. //
  359. // If this assertion is hit, this Device Object was never properly initialized
  360. // by GcKernel, or it has been trashed.
  361. //
  362. ASSERT(FALSE);
  363. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  364. NtStatus = STATUS_UNSUCCESSFUL;
  365. }
  366. GCK_DBG_EXIT_PRINT(("Exiting GCK_Power. Status: 0x%0.8x\n", NtStatus));
  367. return NtStatus;
  368. }
  369. /***********************************************************************************
  370. **
  371. ** NTSTATUS GCK_PnP (IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp)
  372. **
  373. ** @func Handles IRP_MJ_PnP
  374. **
  375. ** @rdesc STATUS_SUCCESS, or various errors
  376. **
  377. *************************************************************************************/
  378. NTSTATUS GCK_PnP
  379. (
  380. IN PDEVICE_OBJECT pDeviceObject, // @parm Device Object for our context
  381. IN PIRP pIrp // @parm IRP to handle
  382. )
  383. {
  384. NTSTATUS NtStatus;
  385. ULONG ulGckDevObjType;
  386. GCK_DBG_ENTRY_PRINT(("Entering GCK_PnP. pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  387. ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  388. switch(ulGckDevObjType)
  389. {
  390. case GCK_DO_TYPE_CONTROL:
  391. NtStatus = STATUS_NOT_SUPPORTED;
  392. //Assert as we shouldn't get PnP on the control device
  393. ASSERT( NT_SUCCESS(NtStatus) );
  394. pIrp->IoStatus.Status = NtStatus;
  395. IoCompleteRequest(pIrp, IO_NO_INCREMENT);
  396. break;
  397. case GCK_DO_TYPE_FILTER:
  398. NtStatus = GCK_FLTR_PnP(pDeviceObject, pIrp);
  399. break;
  400. case GCK_DO_TYPE_SWVB:
  401. NtStatus = GCK_SWVB_PnP(pDeviceObject, pIrp);
  402. break;
  403. default:
  404. //
  405. // If this assertion is hit, this Device Object was never properly initialized
  406. // by GcKernel, or it has been trashed.
  407. //
  408. ASSERT(FALSE);
  409. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  410. NtStatus = STATUS_UNSUCCESSFUL;
  411. }
  412. GCK_DBG_EXIT_PRINT(("Exiting GCK_PnP. Status: 0x%0.8x\n", NtStatus));
  413. return NtStatus;
  414. }
  415. /***********************************************************************************
  416. **
  417. ** NTSTATUS GCK_Ioctl (IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp)
  418. **
  419. ** @func Handles IRP_MJ_IOCTL and IRP_MJ_INTERNAL_IOCTL
  420. **
  421. ** @rdesc STATUS_SUCCES, or various errors
  422. **
  423. *************************************************************************************/
  424. NTSTATUS GCK_Ioctl
  425. (
  426. IN PDEVICE_OBJECT pDeviceObject, // @parm pointer to Device Object
  427. IN PIRP pIrp // @parm pointer to IRP
  428. )
  429. {
  430. NTSTATUS NtStatus;
  431. ULONG ulGckDevObjType;
  432. ULONG uIoctl;
  433. PIO_STACK_LOCATION pIrpStack;
  434. GCK_DBG_ENTRY_PRINT(("Entering GCK_Ioctl. pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  435. pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
  436. uIoctl = pIrpStack->Parameters.DeviceIoControl.IoControlCode;
  437. if (uIoctl == IOCTL_GCK_ENABLE_KEYHOOK)
  438. { // Special case IOCTL, device independant
  439. #ifdef BUILD_WIN2K
  440. pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
  441. #else !BUILD_WIN2K
  442. if (InterlockedIncrement(&g_lHookRefCount) == 1)
  443. { // Not already hooked
  444. HookKeyboard();
  445. }
  446. pIrp->IoStatus.Status = STATUS_SUCCESS;
  447. #endif BUILD_WIN2K
  448. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  449. return STATUS_SUCCESS;
  450. }
  451. if (uIoctl == IOCTL_GCK_DISABLE_KEYHOOK)
  452. { // Special case also device independant
  453. #ifdef BUILD_WIN2K
  454. pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
  455. #else !BUILD_WIN2K
  456. if (InterlockedDecrement(&g_lHookRefCount) < 1)
  457. { // Last hooker is going away
  458. UnHookKeyboard();
  459. g_lHookRefCount = 0;
  460. }
  461. pIrp->IoStatus.Status = STATUS_SUCCESS;
  462. #endif BUILD_WIN2K
  463. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  464. return STATUS_SUCCESS;
  465. }
  466. if (uIoctl == IOCTL_GCK_GET_KEYHOOK_DATA)
  467. {
  468. #ifdef BUILD_WIN2K
  469. NtStatus = STATUS_UNSUCCESSFUL;
  470. #else !BUILD_WIN2K
  471. ULONG uOutLength = pIrpStack->Parameters.DeviceIoControl.OutputBufferLength;
  472. if (uOutLength < sizeof(ULONG))
  473. {
  474. NtStatus = STATUS_BUFFER_TOO_SMALL;
  475. }
  476. else
  477. {
  478. ULONG* pulIoBuffer = (ULONG*)(pIrp->AssociatedIrp.SystemBuffer);
  479. *pulIoBuffer = 0;
  480. pIrp->IoStatus.Information = sizeof(ULONG);
  481. NtStatus = STATUS_SUCCESS;
  482. if (g_lHookRefCount > 0)
  483. { // There is a hook
  484. if (g_ucWriteIndex != g_ucReadIndex)
  485. { // We have data in the Queue
  486. *pulIoBuffer = g_rgdwKeyEvents[g_ucReadIndex++];
  487. if (g_ucReadIndex >= 50)
  488. {
  489. g_ucReadIndex = 0;
  490. }
  491. }
  492. }
  493. }
  494. #endif BUILD_WIN2K
  495. pIrp->IoStatus.Status = NtStatus;
  496. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  497. return NtStatus;
  498. }
  499. ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  500. switch(ulGckDevObjType)
  501. {
  502. case GCK_DO_TYPE_CONTROL:
  503. NtStatus = GCK_CTRL_Ioctl(pDeviceObject, pIrp);
  504. break;
  505. case GCK_DO_TYPE_FILTER:
  506. NtStatus = GCK_FLTR_Ioctl(pDeviceObject, pIrp);
  507. break;
  508. case GCK_DO_TYPE_SWVB:
  509. NtStatus = GCK_SWVB_Ioctl(pDeviceObject, pIrp);
  510. break;
  511. default:
  512. //
  513. // If this assertion is hit, this Device Object was never properly initialized
  514. // by GcKernel, or it has been trashed.
  515. //
  516. ASSERT(FALSE);
  517. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  518. NtStatus = STATUS_UNSUCCESSFUL;
  519. }
  520. GCK_DBG_EXIT_PRINT(("Exiting GCK_Ioctl. Status: 0x%0.8x\n", NtStatus));
  521. return NtStatus;
  522. }
  523. /***********************************************************************************
  524. **
  525. ** NTSTATUS GCK_Pass ( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp )
  526. **
  527. ** @func Passes on unhandled IRPs to lower drivers DEBUG version trace out info
  528. ** Cannot be pageable since we have no idea what IRPs we're getting.
  529. **
  530. ** @rdesc STATUS_SUCCESS, various errors
  531. **
  532. *************************************************************************************/
  533. NTSTATUS GCK_Pass (
  534. IN PDEVICE_OBJECT pDeviceObject, // @parm Device Object as our context
  535. IN PIRP pIrp // @parm IRP to pass on
  536. )
  537. {
  538. NTSTATUS NtStatus;
  539. ULONG ulGckDevObjType;
  540. PGCK_FILTER_EXT pFilterExt;
  541. // Debug version want IRP stack for traceouts.
  542. #if (DBG==1)
  543. PIO_STACK_LOCATION pIrpStack;
  544. pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
  545. #endif
  546. GCK_DBG_ENTRY_PRINT(("Entering GCK_Pass. pDO = 0x%0.8x, pIrp = 0x%0.8x\n", pDeviceObject, pIrp));
  547. GCK_DBG_TRACE_PRINT(
  548. (
  549. "GCK_Pass called with Irp MajorFunction = 0x%0.8x, MinorFunction = 0x%0.8x\n",
  550. pIrpStack->MajorFunction, pIrpStack->MinorFunction)
  551. );
  552. ulGckDevObjType = *(PULONG)pDeviceObject->DeviceExtension;
  553. switch(ulGckDevObjType)
  554. {
  555. case GCK_DO_TYPE_FILTER:
  556. GCK_DBG_TRACE_PRINT(( "Passing IRP to lower driver\n"));
  557. pFilterExt = (PGCK_FILTER_EXT)pDeviceObject->DeviceExtension;
  558. IoSkipCurrentIrpStackLocation (pIrp);
  559. NtStatus = IoCallDriver (pFilterExt->pTopOfStack, pIrp);
  560. break;
  561. case GCK_DO_TYPE_CONTROL:
  562. case GCK_DO_TYPE_SWVB:
  563. // No one to pass to, so return default status
  564. NtStatus = pIrp->IoStatus.Status;
  565. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  566. break;
  567. default:
  568. //
  569. // If this assertion is hit, this Device Object was never properly initialized
  570. // by GcKernel, or it has been trashed.
  571. //
  572. ASSERT(FALSE);
  573. NtStatus = STATUS_UNSUCCESSFUL;
  574. pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
  575. IoCompleteRequest (pIrp, IO_NO_INCREMENT);
  576. };
  577. //return
  578. GCK_DBG_EXIT_PRINT(("Exiting GCK_Pass. Status: 0x%0.8x\n", NtStatus));
  579. return NtStatus;
  580. }