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.

83 lines
2.0 KiB

  1. //
  2. // addDevice.c
  3. //
  4. #include "pch.h"
  5. NTSTATUS
  6. P5AddDevice(
  7. IN PDRIVER_OBJECT DriverObject,
  8. IN PDEVICE_OBJECT Pdo
  9. )
  10. /*++
  11. Routine Description:
  12. This is the WDM AddDevice routine for parport devices.
  13. Arguments:
  14. DriverObject - Driver Object
  15. Pdo - PDO
  16. Return Value:
  17. STATUS_SUCCESS - on SUCCESS
  18. Error Status - otherwise
  19. --*/
  20. {
  21. NTSTATUS status = STATUS_SUCCESS;
  22. PDEVICE_OBJECT fdo = NULL;
  23. PDEVICE_OBJECT lowerDevObj = NULL;
  24. PFDO_EXTENSION fdx = NULL;
  25. BOOLEAN haveDeviceInterface = FALSE;
  26. __try {
  27. fdo = PptBuildFdo( DriverObject, Pdo );
  28. if( !fdo ) {
  29. status = STATUS_UNSUCCESSFUL;
  30. __leave;
  31. }
  32. fdx = fdo->DeviceExtension;
  33. status = IoRegisterDeviceInterface( Pdo, &GUID_PARALLEL_DEVICE, NULL, &fdx->DeviceInterface);
  34. if( status != STATUS_SUCCESS ) {
  35. __leave;
  36. }
  37. haveDeviceInterface = TRUE;
  38. lowerDevObj = IoAttachDeviceToDeviceStack( fdo, Pdo );
  39. if( !lowerDevObj ) {
  40. status = STATUS_UNSUCCESSFUL;
  41. __leave;
  42. }
  43. fdx->ParentDeviceObject = lowerDevObj;
  44. KeInitializeEvent( &fdx->FdoThreadEvent, NotificationEvent, FALSE );
  45. // legacy drivers may use this count
  46. IoGetConfigurationInformation()->ParallelCount++;
  47. // done initializing - tell IO system we are ready to receive IRPs
  48. fdo->Flags &= ~DO_DEVICE_INITIALIZING;
  49. DD((PCE)fdx,DDT,"P5AddDevice - SUCCESS\n");
  50. }
  51. __finally {
  52. if( status != STATUS_SUCCESS ) {
  53. if( haveDeviceInterface ) {
  54. RtlFreeUnicodeString( &fdx->DeviceInterface );
  55. }
  56. if( fdo ) {
  57. IoDeleteDevice( fdo );
  58. }
  59. }
  60. }
  61. return status;
  62. }