Showing error 1557

User: Jiri Slaby
Error type: Reachable Error Location
Error type description: A specified error location is reachable in some program path
File location: ntdrivers/parport_unsafe.i.cil.c
Line in file: 2248
Project: SV-COMP 2013
Project version: 2.6.28
Tools: Manual Work
Entered: 2013-01-17 16:57:54 UTC


Source:

    1extern char __VERIFIER_nondet_char(void);
    2extern int __VERIFIER_nondet_int(void);
    3extern long __VERIFIER_nondet_long(void);
    4extern void *__VERIFIER_nondet_pointer(void);
    5/* Generated by CIL v. 1.3.6 */
    6/* print_CIL_Input is true */
    7
    8#pragma pack(push,8)
    9#pragma pack(pop)
   10typedef unsigned short wchar_t;
   11typedef unsigned long ULONG_PTR;
   12typedef unsigned long *PULONG_PTR;
   13typedef ULONG_PTR SIZE_T;
   14typedef void *PVOID;
   15typedef char CHAR;
   16typedef short SHORT;
   17typedef long LONG;
   18typedef wchar_t WCHAR;
   19typedef WCHAR *PWSTR;
   20typedef WCHAR const   *PCWSTR;
   21typedef CHAR *PCHAR;
   22typedef CHAR const   *PCSTR;
   23typedef LONG *PLONG;
   24typedef unsigned char UCHAR;
   25typedef unsigned short USHORT;
   26typedef unsigned long ULONG;
   27typedef UCHAR *PUCHAR;
   28typedef ULONG *PULONG;
   29typedef void *HANDLE;
   30typedef HANDLE *PHANDLE;
   31typedef char CCHAR;
   32typedef short CSHORT;
   33typedef ULONG LCID;
   34typedef LONG NTSTATUS;
   35typedef long long LONGLONG;
   36struct __anonstruct____missing_field_name_1 {
   37   ULONG LowPart ;
   38   LONG HighPart ;
   39};
   40struct __anonstruct_u_2 {
   41   ULONG LowPart ;
   42   LONG HighPart ;
   43};
   44union _LARGE_INTEGER {
   45   struct __anonstruct____missing_field_name_1 __annonCompField1 ;
   46   struct __anonstruct_u_2 u ;
   47   LONGLONG QuadPart ;
   48};
   49typedef union _LARGE_INTEGER LARGE_INTEGER;
   50typedef LARGE_INTEGER *PLARGE_INTEGER;
   51struct _LUID {
   52   ULONG LowPart ;
   53   LONG HighPart ;
   54};
   55typedef struct _LUID LUID;
   56typedef LARGE_INTEGER PHYSICAL_ADDRESS;
   57enum _EVENT_TYPE {
   58    NotificationEvent = 0,
   59    SynchronizationEvent = 1
   60} ;
   61typedef enum _EVENT_TYPE EVENT_TYPE;
   62typedef char const   *PCSZ;
   63struct _STRING {
   64   USHORT Length ;
   65   USHORT MaximumLength ;
   66   PCHAR Buffer ;
   67};
   68typedef struct _STRING STRING;
   69typedef STRING *PSTRING;
   70typedef PSTRING PANSI_STRING;
   71struct _UNICODE_STRING {
   72   USHORT Length ;
   73   USHORT MaximumLength ;
   74   PWSTR Buffer ;
   75};
   76typedef struct _UNICODE_STRING UNICODE_STRING;
   77typedef UNICODE_STRING *PUNICODE_STRING;
   78typedef UCHAR BOOLEAN;
   79typedef BOOLEAN *PBOOLEAN;
   80struct _LIST_ENTRY {
   81   struct _LIST_ENTRY *Flink ;
   82   struct _LIST_ENTRY *Blink ;
   83};
   84typedef struct _LIST_ENTRY LIST_ENTRY;
   85typedef struct _LIST_ENTRY *PLIST_ENTRY;
   86struct _OBJECT_ATTRIBUTES {
   87   ULONG Length ;
   88   HANDLE RootDirectory ;
   89   PUNICODE_STRING ObjectName ;
   90   ULONG Attributes ;
   91   PVOID SecurityDescriptor ;
   92   PVOID SecurityQualityOfService ;
   93};
   94typedef struct _OBJECT_ATTRIBUTES OBJECT_ATTRIBUTES;
   95typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
   96struct _GUID {
   97   unsigned long Data1 ;
   98   unsigned short Data2 ;
   99   unsigned short Data3 ;
  100   unsigned char Data4[8] ;
  101};
  102typedef struct _GUID GUID;
  103typedef GUID const   *LPCGUID;
  104typedef unsigned int size_t;
  105typedef UCHAR KIRQL;
  106typedef KIRQL *PKIRQL;
  107enum _NT_PRODUCT_TYPE {
  108    NtProductWinNt = 1,
  109    NtProductLanManNt = 2,
  110    NtProductServer = 3
  111} ;
  112typedef enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE;
  113struct _KTHREAD;
  114typedef struct _KTHREAD *PKTHREAD;
  115struct _ETHREAD;
  116typedef struct _ETHREAD *PETHREAD;
  117struct _EPROCESS;
  118typedef struct _EPROCESS *PEPROCESS;
  119struct _KINTERRUPT;
  120typedef struct _KINTERRUPT *PKINTERRUPT;
  121struct _IO_TIMER;
  122typedef struct _IO_TIMER *PIO_TIMER;
  123struct _OBJECT_TYPE;
  124typedef struct _OBJECT_TYPE *POBJECT_TYPE;
  125typedef CCHAR KPROCESSOR_MODE;
  126struct _KAPC;
  127struct _KAPC;
  128typedef void (*PKNORMAL_ROUTINE)(PVOID NormalContext , PVOID SystemArgument1 , PVOID SystemArgument2 );
  129struct _KAPC {
  130   CSHORT Type ;
  131   CSHORT Size ;
  132   ULONG Spare0 ;
  133   struct _KTHREAD *Thread ;
  134   LIST_ENTRY ApcListEntry ;
  135   void (*KernelRoutine)(struct _KAPC *Apc , PKNORMAL_ROUTINE *NormalRoutine , PVOID *NormalContext ,
  136                         PVOID *SystemArgument1 , PVOID *SystemArgument2 ) ;
  137   void (*RundownRoutine)(struct _KAPC *Apc ) ;
  138   void (*NormalRoutine)(PVOID NormalContext , PVOID SystemArgument1 , PVOID SystemArgument2 ) ;
  139   PVOID NormalContext ;
  140   PVOID SystemArgument1 ;
  141   PVOID SystemArgument2 ;
  142   CCHAR ApcStateIndex ;
  143   KPROCESSOR_MODE ApcMode ;
  144   BOOLEAN Inserted ;
  145};
  146typedef struct _KAPC KAPC;
  147struct _KDPC;
  148struct _KDPC;
  149struct _KDPC {
  150   CSHORT Type ;
  151   UCHAR Number ;
  152   UCHAR Importance ;
  153   LIST_ENTRY DpcListEntry ;
  154   void (*DeferredRoutine)(struct _KDPC *Dpc , PVOID DeferredContext , PVOID SystemArgument1 ,
  155                           PVOID SystemArgument2 ) ;
  156   PVOID DeferredContext ;
  157   PVOID SystemArgument1 ;
  158   PVOID SystemArgument2 ;
  159   PULONG_PTR Lock ;
  160};
  161typedef struct _KDPC KDPC;
  162typedef struct _KDPC *PKDPC;
  163typedef struct _KDPC *PRKDPC;
  164struct _MDL {
  165   struct _MDL *Next ;
  166   CSHORT Size ;
  167   CSHORT MdlFlags ;
  168   struct _EPROCESS *Process ;
  169   PVOID MappedSystemVa ;
  170   PVOID StartVa ;
  171   ULONG ByteCount ;
  172   ULONG ByteOffset ;
  173};
  174typedef struct _MDL MDL;
  175typedef struct _MDL *PMDL;
  176typedef PVOID PACCESS_TOKEN;
  177typedef PVOID PSECURITY_DESCRIPTOR;
  178typedef ULONG ACCESS_MASK;
  179#pragma pack(push,4)
  180struct _LUID_AND_ATTRIBUTES {
  181   LUID Luid ;
  182   ULONG Attributes ;
  183};
  184typedef struct _LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES;
  185#pragma pack(pop)
  186struct _PRIVILEGE_SET {
  187   ULONG PrivilegeCount ;
  188   ULONG Control ;
  189   LUID_AND_ATTRIBUTES Privilege[1] ;
  190};
  191typedef struct _PRIVILEGE_SET PRIVILEGE_SET;
  192enum _SECURITY_IMPERSONATION_LEVEL {
  193    SecurityAnonymous = 0,
  194    SecurityIdentification = 1,
  195    SecurityImpersonation = 2,
  196    SecurityDelegation = 3
  197} ;
  198typedef enum _SECURITY_IMPERSONATION_LEVEL SECURITY_IMPERSONATION_LEVEL;
  199typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE;
  200struct _SECURITY_QUALITY_OF_SERVICE {
  201   ULONG Length ;
  202   SECURITY_IMPERSONATION_LEVEL ImpersonationLevel ;
  203   SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode ;
  204   BOOLEAN EffectiveOnly ;
  205};
  206typedef struct _SECURITY_QUALITY_OF_SERVICE *PSECURITY_QUALITY_OF_SERVICE;
  207typedef ULONG SECURITY_INFORMATION;
  208typedef ULONG KAFFINITY;
  209typedef LONG KPRIORITY;
  210typedef ULONG_PTR KSPIN_LOCK;
  211typedef KSPIN_LOCK *PKSPIN_LOCK;
  212struct _RTL_QUERY_REGISTRY_TABLE {
  213   NTSTATUS (*QueryRoutine)(PWSTR ValueName , ULONG ValueType ,
  214                                                            PVOID ValueData , ULONG ValueLength ,
  215                                                            PVOID Context , PVOID EntryContext ) ;
  216   ULONG Flags ;
  217   PWSTR Name ;
  218   PVOID EntryContext ;
  219   ULONG DefaultType ;
  220   PVOID DefaultData ;
  221   ULONG DefaultLength ;
  222};
  223typedef struct _RTL_QUERY_REGISTRY_TABLE RTL_QUERY_REGISTRY_TABLE;
  224typedef struct _RTL_QUERY_REGISTRY_TABLE *PRTL_QUERY_REGISTRY_TABLE;
  225union __anonunion____missing_field_name_6 {
  226   NTSTATUS Status ;
  227   PVOID Pointer ;
  228};
  229struct _IO_STATUS_BLOCK {
  230   union __anonunion____missing_field_name_6 __annonCompField4 ;
  231   ULONG_PTR Information ;
  232};
  233typedef struct _IO_STATUS_BLOCK IO_STATUS_BLOCK;
  234typedef struct _IO_STATUS_BLOCK *PIO_STATUS_BLOCK;
  235enum _FILE_INFORMATION_CLASS {
  236    FileDirectoryInformation = 1,
  237    FileFullDirectoryInformation = 2,
  238    FileBothDirectoryInformation = 3,
  239    FileBasicInformation = 4,
  240    FileStandardInformation = 5,
  241    FileInternalInformation = 6,
  242    FileEaInformation = 7,
  243    FileAccessInformation = 8,
  244    FileNameInformation = 9,
  245    FileRenameInformation = 10,
  246    FileLinkInformation = 11,
  247    FileNamesInformation = 12,
  248    FileDispositionInformation = 13,
  249    FilePositionInformation = 14,
  250    FileFullEaInformation = 15,
  251    FileModeInformation = 16,
  252    FileAlignmentInformation = 17,
  253    FileAllInformation = 18,
  254    FileAllocationInformation = 19,
  255    FileEndOfFileInformation = 20,
  256    FileAlternateNameInformation = 21,
  257    FileStreamInformation = 22,
  258    FilePipeInformation = 23,
  259    FilePipeLocalInformation = 24,
  260    FilePipeRemoteInformation = 25,
  261    FileMailslotQueryInformation = 26,
  262    FileMailslotSetInformation = 27,
  263    FileCompressionInformation = 28,
  264    FileObjectIdInformation = 29,
  265    FileCompletionInformation = 30,
  266    FileMoveClusterInformation = 31,
  267    FileQuotaInformation = 32,
  268    FileReparsePointInformation = 33,
  269    FileNetworkOpenInformation = 34,
  270    FileAttributeTagInformation = 35,
  271    FileTrackingInformation = 36,
  272    FileMaximumInformation = 37
  273} ;
  274typedef enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS;
  275struct _FILE_BASIC_INFORMATION {
  276   LARGE_INTEGER CreationTime ;
  277   LARGE_INTEGER LastAccessTime ;
  278   LARGE_INTEGER LastWriteTime ;
  279   LARGE_INTEGER ChangeTime ;
  280   ULONG FileAttributes ;
  281};
  282typedef struct _FILE_BASIC_INFORMATION *PFILE_BASIC_INFORMATION;
  283struct _FILE_STANDARD_INFORMATION {
  284   LARGE_INTEGER AllocationSize ;
  285   LARGE_INTEGER EndOfFile ;
  286   ULONG NumberOfLinks ;
  287   BOOLEAN DeletePending ;
  288   BOOLEAN Directory ;
  289};
  290typedef struct _FILE_STANDARD_INFORMATION *PFILE_STANDARD_INFORMATION;
  291struct _FILE_NETWORK_OPEN_INFORMATION {
  292   LARGE_INTEGER CreationTime ;
  293   LARGE_INTEGER LastAccessTime ;
  294   LARGE_INTEGER LastWriteTime ;
  295   LARGE_INTEGER ChangeTime ;
  296   LARGE_INTEGER AllocationSize ;
  297   LARGE_INTEGER EndOfFile ;
  298   ULONG FileAttributes ;
  299};
  300typedef struct _FILE_NETWORK_OPEN_INFORMATION *PFILE_NETWORK_OPEN_INFORMATION;
  301enum _FSINFOCLASS {
  302    FileFsVolumeInformation = 1,
  303    FileFsLabelInformation = 2,
  304    FileFsSizeInformation = 3,
  305    FileFsDeviceInformation = 4,
  306    FileFsAttributeInformation = 5,
  307    FileFsControlInformation = 6,
  308    FileFsFullSizeInformation = 7,
  309    FileFsObjectIdInformation = 8,
  310    FileFsMaximumInformation = 9
  311} ;
  312typedef enum _FSINFOCLASS FS_INFORMATION_CLASS;
  313enum _INTERFACE_TYPE {
  314    InterfaceTypeUndefined = -1,
  315    Internal = 0,
  316    Isa = 1,
  317    Eisa = 2,
  318    MicroChannel = 3,
  319    TurboChannel = 4,
  320    PCIBus = 5,
  321    VMEBus = 6,
  322    NuBus = 7,
  323    PCMCIABus = 8,
  324    CBus = 9,
  325    MPIBus = 10,
  326    MPSABus = 11,
  327    ProcessorInternal = 12,
  328    InternalPowerBus = 13,
  329    PNPISABus = 14,
  330    PNPBus = 15,
  331    MaximumInterfaceType = 16
  332} ;
  333typedef enum _INTERFACE_TYPE INTERFACE_TYPE;
  334typedef enum _INTERFACE_TYPE *PINTERFACE_TYPE;
  335struct _IO_ERROR_LOG_PACKET {
  336   UCHAR MajorFunctionCode ;
  337   UCHAR RetryCount ;
  338   USHORT DumpDataSize ;
  339   USHORT NumberOfStrings ;
  340   USHORT StringOffset ;
  341   USHORT EventCategory ;
  342   NTSTATUS ErrorCode ;
  343   ULONG UniqueErrorValue ;
  344   NTSTATUS FinalStatus ;
  345   ULONG SequenceNumber ;
  346   ULONG IoControlCode ;
  347   LARGE_INTEGER DeviceOffset ;
  348   ULONG DumpData[1] ;
  349};
  350typedef struct _IO_ERROR_LOG_PACKET IO_ERROR_LOG_PACKET;
  351typedef struct _IO_ERROR_LOG_PACKET *PIO_ERROR_LOG_PACKET;
  352struct _KEY_VALUE_FULL_INFORMATION {
  353   ULONG TitleIndex ;
  354   ULONG Type ;
  355   ULONG DataOffset ;
  356   ULONG DataLength ;
  357   ULONG NameLength ;
  358   WCHAR Name[1] ;
  359};
  360typedef struct _KEY_VALUE_FULL_INFORMATION *PKEY_VALUE_FULL_INFORMATION;
  361enum _KEY_VALUE_INFORMATION_CLASS {
  362    KeyValueBasicInformation = 0,
  363    KeyValueFullInformation = 1,
  364    KeyValuePartialInformation = 2,
  365    KeyValueFullInformationAlign64 = 3,
  366    KeyValuePartialInformationAlign64 = 4
  367} ;
  368typedef enum _KEY_VALUE_INFORMATION_CLASS KEY_VALUE_INFORMATION_CLASS;
  369struct _CLIENT_ID {
  370   HANDLE UniqueProcess ;
  371   HANDLE UniqueThread ;
  372};
  373typedef struct _CLIENT_ID CLIENT_ID;
  374typedef CLIENT_ID *PCLIENT_ID;
  375enum _SYSTEM_POWER_STATE {
  376    PowerSystemUnspecified = 0,
  377    PowerSystemWorking = 1,
  378    PowerSystemSleeping1 = 2,
  379    PowerSystemSleeping2 = 3,
  380    PowerSystemSleeping3 = 4,
  381    PowerSystemHibernate = 5,
  382    PowerSystemShutdown = 6,
  383    PowerSystemMaximum = 7
  384} ;
  385typedef enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE;
  386enum __anonenum_POWER_ACTION_11 {
  387    PowerActionNone = 0,
  388    PowerActionReserved = 1,
  389    PowerActionSleep = 2,
  390    PowerActionHibernate = 3,
  391    PowerActionShutdown = 4,
  392    PowerActionShutdownReset = 5,
  393    PowerActionShutdownOff = 6,
  394    PowerActionWarmEject = 7
  395} ;
  396typedef enum __anonenum_POWER_ACTION_11 POWER_ACTION;
  397enum _DEVICE_POWER_STATE {
  398    PowerDeviceUnspecified = 0,
  399    PowerDeviceD0 = 1,
  400    PowerDeviceD1 = 2,
  401    PowerDeviceD2 = 3,
  402    PowerDeviceD3 = 4,
  403    PowerDeviceMaximum = 5
  404} ;
  405typedef enum _DEVICE_POWER_STATE DEVICE_POWER_STATE;
  406union _POWER_STATE {
  407   SYSTEM_POWER_STATE SystemState ;
  408   DEVICE_POWER_STATE DeviceState ;
  409};
  410typedef union _POWER_STATE POWER_STATE;
  411enum _POWER_STATE_TYPE {
  412    SystemPowerState = 0,
  413    DevicePowerState = 1
  414} ;
  415typedef enum _POWER_STATE_TYPE POWER_STATE_TYPE;
  416struct _KSYSTEM_TIME {
  417   ULONG LowPart ;
  418   LONG High1Time ;
  419   LONG High2Time ;
  420};
  421typedef struct _KSYSTEM_TIME KSYSTEM_TIME;
  422enum _ALTERNATIVE_ARCHITECTURE_TYPE {
  423    StandardDesign = 0,
  424    NEC98x86 = 1,
  425    EndAlternatives = 2
  426} ;
  427typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE ALTERNATIVE_ARCHITECTURE_TYPE;
  428struct _KUSER_SHARED_DATA {
  429   ULONG volatile   TickCountLow ;
  430   ULONG TickCountMultiplier ;
  431   KSYSTEM_TIME volatile   InterruptTime ;
  432   KSYSTEM_TIME volatile   SystemTime ;
  433   KSYSTEM_TIME volatile   TimeZoneBias ;
  434   USHORT ImageNumberLow ;
  435   USHORT ImageNumberHigh ;
  436   WCHAR NtSystemRoot[260] ;
  437   ULONG MaxStackTraceDepth ;
  438   ULONG CryptoExponent ;
  439   ULONG TimeZoneId ;
  440   ULONG Reserved2[8] ;
  441   NT_PRODUCT_TYPE NtProductType ;
  442   BOOLEAN ProductTypeIsValid ;
  443   ULONG NtMajorVersion ;
  444   ULONG NtMinorVersion ;
  445   BOOLEAN ProcessorFeatures[64] ;
  446   ULONG Reserved1 ;
  447   ULONG Reserved3 ;
  448   ULONG volatile   TimeSlip ;
  449   ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture ;
  450   LARGE_INTEGER SystemExpirationDate ;
  451   ULONG SuiteMask ;
  452   BOOLEAN KdDebuggerEnabled ;
  453};
  454typedef struct _KUSER_SHARED_DATA KUSER_SHARED_DATA;
  455typedef PVOID PASSIGNED_RESOURCE;
  456#pragma pack(push,4)
  457struct __anonstruct_Generic_16 {
  458   PHYSICAL_ADDRESS Start ;
  459   ULONG Length ;
  460};
  461struct __anonstruct_Port_17 {
  462   PHYSICAL_ADDRESS Start ;
  463   ULONG Length ;
  464};
  465struct __anonstruct_Interrupt_18 {
  466   ULONG Level ;
  467   ULONG Vector ;
  468   ULONG Affinity ;
  469};
  470struct __anonstruct_Memory_19 {
  471   PHYSICAL_ADDRESS Start ;
  472   ULONG Length ;
  473};
  474struct __anonstruct_Dma_20 {
  475   ULONG Channel ;
  476   ULONG Port ;
  477   ULONG Reserved1 ;
  478};
  479struct __anonstruct_DevicePrivate_21 {
  480   ULONG Data[3] ;
  481};
  482struct __anonstruct_BusNumber_22 {
  483   ULONG Start ;
  484   ULONG Length ;
  485   ULONG Reserved ;
  486};
  487struct __anonstruct_DeviceSpecificData_23 {
  488   ULONG DataSize ;
  489   ULONG Reserved1 ;
  490   ULONG Reserved2 ;
  491};
  492union __anonunion_u_15 {
  493   struct __anonstruct_Generic_16 Generic ;
  494   struct __anonstruct_Port_17 Port ;
  495   struct __anonstruct_Interrupt_18 Interrupt ;
  496   struct __anonstruct_Memory_19 Memory ;
  497   struct __anonstruct_Dma_20 Dma ;
  498   struct __anonstruct_DevicePrivate_21 DevicePrivate ;
  499   struct __anonstruct_BusNumber_22 BusNumber ;
  500   struct __anonstruct_DeviceSpecificData_23 DeviceSpecificData ;
  501};
  502struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
  503   UCHAR Type ;
  504   UCHAR ShareDisposition ;
  505   USHORT Flags ;
  506   union __anonunion_u_15 u ;
  507};
  508typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR;
  509typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
  510#pragma pack(pop)
  511struct _CM_PARTIAL_RESOURCE_LIST {
  512   USHORT Version ;
  513   USHORT Revision ;
  514   ULONG Count ;
  515   CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1] ;
  516};
  517typedef struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST;
  518typedef struct _CM_PARTIAL_RESOURCE_LIST *PCM_PARTIAL_RESOURCE_LIST;
  519struct _CM_FULL_RESOURCE_DESCRIPTOR {
  520   INTERFACE_TYPE InterfaceType ;
  521   ULONG BusNumber ;
  522   CM_PARTIAL_RESOURCE_LIST PartialResourceList ;
  523};
  524typedef struct _CM_FULL_RESOURCE_DESCRIPTOR CM_FULL_RESOURCE_DESCRIPTOR;
  525typedef struct _CM_FULL_RESOURCE_DESCRIPTOR *PCM_FULL_RESOURCE_DESCRIPTOR;
  526struct _CM_RESOURCE_LIST {
  527   ULONG Count ;
  528   CM_FULL_RESOURCE_DESCRIPTOR List[1] ;
  529};
  530typedef struct _CM_RESOURCE_LIST CM_RESOURCE_LIST;
  531typedef struct _CM_RESOURCE_LIST *PCM_RESOURCE_LIST;
  532#pragma pack(push,1)
  533#pragma pack(pop)
  534struct __anonstruct_Port_25 {
  535   ULONG Length ;
  536   ULONG Alignment ;
  537   PHYSICAL_ADDRESS MinimumAddress ;
  538   PHYSICAL_ADDRESS MaximumAddress ;
  539};
  540struct __anonstruct_Memory_26 {
  541   ULONG Length ;
  542   ULONG Alignment ;
  543   PHYSICAL_ADDRESS MinimumAddress ;
  544   PHYSICAL_ADDRESS MaximumAddress ;
  545};
  546struct __anonstruct_Interrupt_27 {
  547   ULONG MinimumVector ;
  548   ULONG MaximumVector ;
  549};
  550struct __anonstruct_Dma_28 {
  551   ULONG MinimumChannel ;
  552   ULONG MaximumChannel ;
  553};
  554struct __anonstruct_Generic_29 {
  555   ULONG Length ;
  556   ULONG Alignment ;
  557   PHYSICAL_ADDRESS MinimumAddress ;
  558   PHYSICAL_ADDRESS MaximumAddress ;
  559};
  560struct __anonstruct_DevicePrivate_30 {
  561   ULONG Data[3] ;
  562};
  563struct __anonstruct_BusNumber_31 {
  564   ULONG Length ;
  565   ULONG MinBusNumber ;
  566   ULONG MaxBusNumber ;
  567   ULONG Reserved ;
  568};
  569struct __anonstruct_AssignedResource_32 {
  570   PASSIGNED_RESOURCE AssignedResource ;
  571};
  572struct __anonstruct_SubAllocateFrom_33 {
  573   UCHAR Type ;
  574   UCHAR Reserved[3] ;
  575   PASSIGNED_RESOURCE AssignedResource ;
  576   PHYSICAL_ADDRESS Transformation ;
  577};
  578struct __anonstruct_ConfigData_34 {
  579   ULONG Priority ;
  580   ULONG Reserved1 ;
  581   ULONG Reserved2 ;
  582};
  583union __anonunion_u_24 {
  584   struct __anonstruct_Port_25 Port ;
  585   struct __anonstruct_Memory_26 Memory ;
  586   struct __anonstruct_Interrupt_27 Interrupt ;
  587   struct __anonstruct_Dma_28 Dma ;
  588   struct __anonstruct_Generic_29 Generic ;
  589   struct __anonstruct_DevicePrivate_30 DevicePrivate ;
  590   struct __anonstruct_BusNumber_31 BusNumber ;
  591   struct __anonstruct_AssignedResource_32 AssignedResource ;
  592   struct __anonstruct_SubAllocateFrom_33 SubAllocateFrom ;
  593   struct __anonstruct_ConfigData_34 ConfigData ;
  594};
  595struct _IO_RESOURCE_DESCRIPTOR {
  596   UCHAR Option ;
  597   UCHAR Type ;
  598   UCHAR ShareDisposition ;
  599   UCHAR Spare1 ;
  600   USHORT Flags ;
  601   USHORT Spare2 ;
  602   union __anonunion_u_24 u ;
  603};
  604typedef struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR;
  605typedef struct _IO_RESOURCE_DESCRIPTOR *PIO_RESOURCE_DESCRIPTOR;
  606struct _IO_RESOURCE_LIST {
  607   USHORT Version ;
  608   USHORT Revision ;
  609   ULONG Count ;
  610   IO_RESOURCE_DESCRIPTOR Descriptors[1] ;
  611};
  612typedef struct _IO_RESOURCE_LIST IO_RESOURCE_LIST;
  613typedef struct _IO_RESOURCE_LIST *PIO_RESOURCE_LIST;
  614struct _IO_RESOURCE_REQUIREMENTS_LIST {
  615   ULONG ListSize ;
  616   INTERFACE_TYPE InterfaceType ;
  617   ULONG BusNumber ;
  618   ULONG SlotNumber ;
  619   ULONG Reserved[3] ;
  620   ULONG AlternativeLists ;
  621   IO_RESOURCE_LIST List[1] ;
  622};
  623typedef struct _IO_RESOURCE_REQUIREMENTS_LIST *PIO_RESOURCE_REQUIREMENTS_LIST;
  624enum _CONFIGURATION_TYPE {
  625    ArcSystem = 0,
  626    CentralProcessor = 1,
  627    FloatingPointProcessor = 2,
  628    PrimaryIcache = 3,
  629    PrimaryDcache = 4,
  630    SecondaryIcache = 5,
  631    SecondaryDcache = 6,
  632    SecondaryCache = 7,
  633    EisaAdapter = 8,
  634    TcAdapter = 9,
  635    ScsiAdapter = 10,
  636    DtiAdapter = 11,
  637    MultiFunctionAdapter = 12,
  638    DiskController = 13,
  639    TapeController = 14,
  640    CdromController = 15,
  641    WormController = 16,
  642    SerialController = 17,
  643    NetworkController = 18,
  644    DisplayController = 19,
  645    ParallelController = 20,
  646    PointerController = 21,
  647    KeyboardController = 22,
  648    AudioController = 23,
  649    OtherController = 24,
  650    DiskPeripheral = 25,
  651    FloppyDiskPeripheral = 26,
  652    TapePeripheral = 27,
  653    ModemPeripheral = 28,
  654    MonitorPeripheral = 29,
  655    PrinterPeripheral = 30,
  656    PointerPeripheral = 31,
  657    KeyboardPeripheral = 32,
  658    TerminalPeripheral = 33,
  659    OtherPeripheral = 34,
  660    LinePeripheral = 35,
  661    NetworkPeripheral = 36,
  662    SystemMemory = 37,
  663    DockingInformation = 38,
  664    RealModeIrqRoutingTable = 39,
  665    MaximumType = 40
  666} ;
  667typedef enum _CONFIGURATION_TYPE CONFIGURATION_TYPE;
  668typedef enum _CONFIGURATION_TYPE *PCONFIGURATION_TYPE;
  669enum _KINTERRUPT_MODE {
  670    LevelSensitive = 0,
  671    Latched = 1
  672} ;
  673typedef enum _KINTERRUPT_MODE KINTERRUPT_MODE;
  674enum _KWAIT_REASON {
  675    Executive = 0,
  676    FreePage = 1,
  677    PageIn = 2,
  678    PoolAllocation = 3,
  679    DelayExecution = 4,
  680    Suspended = 5,
  681    UserRequest = 6,
  682    WrExecutive = 7,
  683    WrFreePage = 8,
  684    WrPageIn = 9,
  685    WrPoolAllocation = 10,
  686    WrDelayExecution = 11,
  687    WrSuspended = 12,
  688    WrUserRequest = 13,
  689    WrEventPair = 14,
  690    WrQueue = 15,
  691    WrLpcReceive = 16,
  692    WrLpcReply = 17,
  693    WrVirtualMemory = 18,
  694    WrPageOut = 19,
  695    WrRendezvous = 20,
  696    Spare2 = 21,
  697    Spare3 = 22,
  698    Spare4 = 23,
  699    Spare5 = 24,
  700    Spare6 = 25,
  701    WrKernel = 26,
  702    MaximumWaitReason = 27
  703} ;
  704typedef enum _KWAIT_REASON KWAIT_REASON;
  705struct _DISPATCHER_HEADER {
  706   UCHAR Type ;
  707   UCHAR Absolute ;
  708   UCHAR Size ;
  709   UCHAR Inserted ;
  710   LONG SignalState ;
  711   LIST_ENTRY WaitListHead ;
  712};
  713typedef struct _DISPATCHER_HEADER DISPATCHER_HEADER;
  714struct _KDEVICE_QUEUE {
  715   CSHORT Type ;
  716   CSHORT Size ;
  717   LIST_ENTRY DeviceListHead ;
  718   KSPIN_LOCK Lock ;
  719   BOOLEAN Busy ;
  720};
  721typedef struct _KDEVICE_QUEUE KDEVICE_QUEUE;
  722struct _KDEVICE_QUEUE_ENTRY {
  723   LIST_ENTRY DeviceListEntry ;
  724   ULONG SortKey ;
  725   BOOLEAN Inserted ;
  726};
  727typedef struct _KDEVICE_QUEUE_ENTRY KDEVICE_QUEUE_ENTRY;
  728struct _KEVENT {
  729   DISPATCHER_HEADER Header ;
  730};
  731typedef struct _KEVENT KEVENT;
  732typedef struct _KEVENT *PKEVENT;
  733typedef struct _KEVENT *PRKEVENT;
  734struct _KSEMAPHORE {
  735   DISPATCHER_HEADER Header ;
  736   LONG Limit ;
  737};
  738typedef struct _KSEMAPHORE *PKSEMAPHORE;
  739typedef struct _KSEMAPHORE *PRKSEMAPHORE;
  740enum _MEMORY_CACHING_TYPE {
  741    MmNonCached = 0,
  742    MmCached = 1,
  743    MmWriteCombined = 2,
  744    MmHardwareCoherentCached = 3,
  745    MmNonCachedUnordered = 4,
  746    MmUSWCCached = 5,
  747    MmMaximumCacheType = 6
  748} ;
  749typedef enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE;
  750enum _POOL_TYPE {
  751    NonPagedPool = 0,
  752    PagedPool = 1,
  753    NonPagedPoolMustSucceed = 2,
  754    DontUseThisType = 3,
  755    NonPagedPoolCacheAligned = 4,
  756    PagedPoolCacheAligned = 5,
  757    NonPagedPoolCacheAlignedMustS = 6,
  758    MaxPoolType = 7,
  759    NonPagedPoolSession = 32,
  760    PagedPoolSession = 33,
  761    NonPagedPoolMustSucceedSession = 34,
  762    DontUseThisTypeSession = 35,
  763    NonPagedPoolCacheAlignedSession = 36,
  764    PagedPoolCacheAlignedSession = 37,
  765    NonPagedPoolCacheAlignedMustSSession = 38
  766} ;
  767typedef enum _POOL_TYPE POOL_TYPE;
  768struct _FAST_MUTEX {
  769   LONG Count ;
  770   PKTHREAD Owner ;
  771   ULONG Contention ;
  772   KEVENT Event ;
  773   ULONG OldIrql ;
  774};
  775typedef struct _FAST_MUTEX FAST_MUTEX;
  776typedef struct _FAST_MUTEX *PFAST_MUTEX;
  777typedef ULONG_PTR ERESOURCE_THREAD;
  778union __anonunion____missing_field_name_38 {
  779   LONG OwnerCount ;
  780   ULONG TableSize ;
  781};
  782struct _OWNER_ENTRY {
  783   ERESOURCE_THREAD OwnerThread ;
  784   union __anonunion____missing_field_name_38 __annonCompField10 ;
  785};
  786typedef struct _OWNER_ENTRY OWNER_ENTRY;
  787typedef struct _OWNER_ENTRY *POWNER_ENTRY;
  788union __anonunion____missing_field_name_39 {
  789   PVOID Address ;
  790   ULONG_PTR CreatorBackTraceIndex ;
  791};
  792struct _ERESOURCE {
  793   LIST_ENTRY SystemResourcesList ;
  794   POWNER_ENTRY OwnerTable ;
  795   SHORT ActiveCount ;
  796   USHORT Flag ;
  797   PKSEMAPHORE SharedWaiters ;
  798   PKEVENT ExclusiveWaiters ;
  799   OWNER_ENTRY OwnerThreads[2] ;
  800   ULONG ContentionCount ;
  801   USHORT NumberOfSharedWaiters ;
  802   USHORT NumberOfExclusiveWaiters ;
  803   union __anonunion____missing_field_name_39 __annonCompField11 ;
  804   KSPIN_LOCK SpinLock ;
  805};
  806enum _MM_PAGE_PRIORITY {
  807    LowPagePriority = 0,
  808    NormalPagePriority = 16,
  809    HighPagePriority = 32
  810} ;
  811typedef enum _MM_PAGE_PRIORITY MM_PAGE_PRIORITY;
  812struct _DRIVER_OBJECT;
  813struct _DRIVER_OBJECT;
  814struct _SECURITY_SUBJECT_CONTEXT {
  815   PACCESS_TOKEN ClientToken ;
  816   SECURITY_IMPERSONATION_LEVEL ImpersonationLevel ;
  817   PACCESS_TOKEN PrimaryToken ;
  818   PVOID ProcessAuditId ;
  819};
  820typedef struct _SECURITY_SUBJECT_CONTEXT SECURITY_SUBJECT_CONTEXT;
  821struct _INITIAL_PRIVILEGE_SET {
  822   ULONG PrivilegeCount ;
  823   ULONG Control ;
  824   LUID_AND_ATTRIBUTES Privilege[3] ;
  825};
  826typedef struct _INITIAL_PRIVILEGE_SET INITIAL_PRIVILEGE_SET;
  827union __anonunion_Privileges_40 {
  828   INITIAL_PRIVILEGE_SET InitialPrivilegeSet ;
  829   PRIVILEGE_SET PrivilegeSet ;
  830};
  831struct _ACCESS_STATE {
  832   LUID OperationID ;
  833   BOOLEAN SecurityEvaluated ;
  834   BOOLEAN GenerateAudit ;
  835   BOOLEAN GenerateOnClose ;
  836   BOOLEAN PrivilegesAllocated ;
  837   ULONG Flags ;
  838   ACCESS_MASK RemainingDesiredAccess ;
  839   ACCESS_MASK PreviouslyGrantedAccess ;
  840   ACCESS_MASK OriginalDesiredAccess ;
  841   SECURITY_SUBJECT_CONTEXT SubjectSecurityContext ;
  842   PSECURITY_DESCRIPTOR SecurityDescriptor ;
  843   PVOID AuxData ;
  844   union __anonunion_Privileges_40 Privileges ;
  845   BOOLEAN AuditPrivileges ;
  846   UNICODE_STRING ObjectName ;
  847   UNICODE_STRING ObjectTypeName ;
  848};
  849typedef struct _ACCESS_STATE *PACCESS_STATE;
  850struct _DEVICE_OBJECT;
  851struct _DEVICE_OBJECT;
  852struct _DRIVER_OBJECT;
  853struct _FILE_OBJECT;
  854struct _FILE_OBJECT;
  855struct _IRP;
  856struct _IRP;
  857struct _SCSI_REQUEST_BLOCK;
  858struct _SCSI_REQUEST_BLOCK;
  859typedef NTSTATUS (*PDRIVER_DISPATCH)(struct _DEVICE_OBJECT *DeviceObject , struct _IRP *Irp );
  860struct _COMPRESSED_DATA_INFO;
  861struct _FAST_IO_DISPATCH {
  862   ULONG SizeOfFastIoDispatch ;
  863   BOOLEAN (*FastIoCheckIfPossible)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  864                                    ULONG Length , BOOLEAN Wait , ULONG LockKey ,
  865                                    BOOLEAN CheckForReadOperation , PIO_STATUS_BLOCK IoStatus ,
  866                                    struct _DEVICE_OBJECT *DeviceObject ) ;
  867   BOOLEAN (*FastIoRead)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  868                         ULONG Length , BOOLEAN Wait , ULONG LockKey , PVOID Buffer ,
  869                         PIO_STATUS_BLOCK IoStatus , struct _DEVICE_OBJECT *DeviceObject ) ;
  870   BOOLEAN (*FastIoWrite)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  871                          ULONG Length , BOOLEAN Wait , ULONG LockKey , PVOID Buffer ,
  872                          PIO_STATUS_BLOCK IoStatus , struct _DEVICE_OBJECT *DeviceObject ) ;
  873   BOOLEAN (*FastIoQueryBasicInfo)(struct _FILE_OBJECT *FileObject , BOOLEAN Wait ,
  874                                   PFILE_BASIC_INFORMATION Buffer , PIO_STATUS_BLOCK IoStatus ,
  875                                   struct _DEVICE_OBJECT *DeviceObject ) ;
  876   BOOLEAN (*FastIoQueryStandardInfo)(struct _FILE_OBJECT *FileObject , BOOLEAN Wait ,
  877                                      PFILE_STANDARD_INFORMATION Buffer , PIO_STATUS_BLOCK IoStatus ,
  878                                      struct _DEVICE_OBJECT *DeviceObject ) ;
  879   BOOLEAN (*FastIoLock)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  880                         PLARGE_INTEGER Length , PEPROCESS ProcessId , ULONG Key ,
  881                         BOOLEAN FailImmediately , BOOLEAN ExclusiveLock , PIO_STATUS_BLOCK IoStatus ,
  882                         struct _DEVICE_OBJECT *DeviceObject ) ;
  883   BOOLEAN (*FastIoUnlockSingle)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  884                                 PLARGE_INTEGER Length , PEPROCESS ProcessId , ULONG Key ,
  885                                 PIO_STATUS_BLOCK IoStatus , struct _DEVICE_OBJECT *DeviceObject ) ;
  886   BOOLEAN (*FastIoUnlockAll)(struct _FILE_OBJECT *FileObject , PEPROCESS ProcessId ,
  887                              PIO_STATUS_BLOCK IoStatus , struct _DEVICE_OBJECT *DeviceObject ) ;
  888   BOOLEAN (*FastIoUnlockAllByKey)(struct _FILE_OBJECT *FileObject , PVOID ProcessId ,
  889                                   ULONG Key , PIO_STATUS_BLOCK IoStatus , struct _DEVICE_OBJECT *DeviceObject ) ;
  890   BOOLEAN (*FastIoDeviceControl)(struct _FILE_OBJECT *FileObject , BOOLEAN Wait ,
  891                                  PVOID InputBuffer , ULONG InputBufferLength , PVOID OutputBuffer ,
  892                                  ULONG OutputBufferLength , ULONG IoControlCode ,
  893                                  PIO_STATUS_BLOCK IoStatus , struct _DEVICE_OBJECT *DeviceObject ) ;
  894   void (*AcquireFileForNtCreateSection)(struct _FILE_OBJECT *FileObject ) ;
  895   void (*ReleaseFileForNtCreateSection)(struct _FILE_OBJECT *FileObject ) ;
  896   void (*FastIoDetachDevice)(struct _DEVICE_OBJECT *SourceDevice , struct _DEVICE_OBJECT *TargetDevice ) ;
  897   BOOLEAN (*FastIoQueryNetworkOpenInfo)(struct _FILE_OBJECT *FileObject , BOOLEAN Wait ,
  898                                         struct _FILE_NETWORK_OPEN_INFORMATION *Buffer ,
  899                                         struct _IO_STATUS_BLOCK *IoStatus , struct _DEVICE_OBJECT *DeviceObject ) ;
  900   NTSTATUS (*AcquireForModWrite)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER EndingOffset ,
  901                                  struct _ERESOURCE **ResourceToRelease , struct _DEVICE_OBJECT *DeviceObject ) ;
  902   BOOLEAN (*MdlRead)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  903                      ULONG Length , ULONG LockKey , PMDL *MdlChain , PIO_STATUS_BLOCK IoStatus ,
  904                      struct _DEVICE_OBJECT *DeviceObject ) ;
  905   BOOLEAN (*MdlReadComplete)(struct _FILE_OBJECT *FileObject , PMDL MdlChain , struct _DEVICE_OBJECT *DeviceObject ) ;
  906   BOOLEAN (*PrepareMdlWrite)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  907                              ULONG Length , ULONG LockKey , PMDL *MdlChain , PIO_STATUS_BLOCK IoStatus ,
  908                              struct _DEVICE_OBJECT *DeviceObject ) ;
  909   BOOLEAN (*MdlWriteComplete)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  910                               PMDL MdlChain , struct _DEVICE_OBJECT *DeviceObject ) ;
  911   BOOLEAN (*FastIoReadCompressed)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  912                                   ULONG Length , ULONG LockKey , PVOID Buffer , PMDL *MdlChain ,
  913                                   PIO_STATUS_BLOCK IoStatus , struct _COMPRESSED_DATA_INFO *CompressedDataInfo ,
  914                                   ULONG CompressedDataInfoLength , struct _DEVICE_OBJECT *DeviceObject ) ;
  915   BOOLEAN (*FastIoWriteCompressed)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  916                                    ULONG Length , ULONG LockKey , PVOID Buffer ,
  917                                    PMDL *MdlChain , PIO_STATUS_BLOCK IoStatus , struct _COMPRESSED_DATA_INFO *CompressedDataInfo ,
  918                                    ULONG CompressedDataInfoLength , struct _DEVICE_OBJECT *DeviceObject ) ;
  919   BOOLEAN (*MdlReadCompleteCompressed)(struct _FILE_OBJECT *FileObject , PMDL MdlChain ,
  920                                        struct _DEVICE_OBJECT *DeviceObject ) ;
  921   BOOLEAN (*MdlWriteCompleteCompressed)(struct _FILE_OBJECT *FileObject , PLARGE_INTEGER FileOffset ,
  922                                         PMDL MdlChain , struct _DEVICE_OBJECT *DeviceObject ) ;
  923   BOOLEAN (*FastIoQueryOpen)(struct _IRP *Irp , PFILE_NETWORK_OPEN_INFORMATION NetworkInformation ,
  924                              struct _DEVICE_OBJECT *DeviceObject ) ;
  925   NTSTATUS (*ReleaseForModWrite)(struct _FILE_OBJECT *FileObject , struct _ERESOURCE *ResourceToRelease ,
  926                                  struct _DEVICE_OBJECT *DeviceObject ) ;
  927   NTSTATUS (*AcquireForCcFlush)(struct _FILE_OBJECT *FileObject , struct _DEVICE_OBJECT *DeviceObject ) ;
  928   NTSTATUS (*ReleaseForCcFlush)(struct _FILE_OBJECT *FileObject , struct _DEVICE_OBJECT *DeviceObject ) ;
  929};
  930typedef struct _FAST_IO_DISPATCH *PFAST_IO_DISPATCH;
  931enum _IO_ALLOCATION_ACTION {
  932    KeepObject = 1,
  933    DeallocateObject = 2,
  934    DeallocateObjectKeepRegisters = 3
  935} ;
  936typedef enum _IO_ALLOCATION_ACTION IO_ALLOCATION_ACTION;
  937struct _IO_SECURITY_CONTEXT {
  938   PSECURITY_QUALITY_OF_SERVICE SecurityQos ;
  939   PACCESS_STATE AccessState ;
  940   ACCESS_MASK DesiredAccess ;
  941   ULONG FullCreateOptions ;
  942};
  943typedef struct _IO_SECURITY_CONTEXT *PIO_SECURITY_CONTEXT;
  944struct _VPB {
  945   CSHORT Type ;
  946   CSHORT Size ;
  947   USHORT Flags ;
  948   USHORT VolumeLabelLength ;
  949   struct _DEVICE_OBJECT *DeviceObject ;
  950   struct _DEVICE_OBJECT *RealDevice ;
  951   ULONG SerialNumber ;
  952   ULONG ReferenceCount ;
  953   WCHAR VolumeLabel[(32U * sizeof(WCHAR )) / sizeof(WCHAR )] ;
  954};
  955typedef struct _VPB *PVPB;
  956struct _WAIT_CONTEXT_BLOCK {
  957   KDEVICE_QUEUE_ENTRY WaitQueueEntry ;
  958   IO_ALLOCATION_ACTION (*DeviceRoutine)(struct _DEVICE_OBJECT *DeviceObject , struct _IRP *Irp ,
  959                                         PVOID MapRegisterBase , PVOID Context ) ;
  960   PVOID DeviceContext ;
  961   ULONG NumberOfMapRegisters ;
  962   PVOID DeviceObject ;
  963   PVOID CurrentIrp ;
  964   PKDPC BufferChainingDpc ;
  965};
  966typedef struct _WAIT_CONTEXT_BLOCK WAIT_CONTEXT_BLOCK;
  967union __anonunion_Queue_43 {
  968   LIST_ENTRY ListEntry ;
  969   WAIT_CONTEXT_BLOCK Wcb ;
  970};
  971struct _DEVOBJ_EXTENSION;
  972struct _DEVICE_OBJECT {
  973   CSHORT Type ;
  974   USHORT Size ;
  975   LONG ReferenceCount ;
  976   struct _DRIVER_OBJECT *DriverObject ;
  977   struct _DEVICE_OBJECT *NextDevice ;
  978   struct _DEVICE_OBJECT *AttachedDevice ;
  979   struct _IRP *CurrentIrp ;
  980   PIO_TIMER Timer ;
  981   ULONG Flags ;
  982   ULONG Characteristics ;
  983   PVPB Vpb ;
  984   PVOID DeviceExtension ;
  985   ULONG DeviceType ;
  986   CCHAR StackSize ;
  987   union __anonunion_Queue_43 Queue ;
  988   ULONG AlignmentRequirement ;
  989   KDEVICE_QUEUE DeviceQueue ;
  990   KDPC Dpc ;
  991   ULONG ActiveThreadCount ;
  992   PSECURITY_DESCRIPTOR SecurityDescriptor ;
  993   KEVENT DeviceLock ;
  994   USHORT SectorSize ;
  995   USHORT Spare1 ;
  996   struct _DEVOBJ_EXTENSION *DeviceObjectExtension ;
  997   PVOID Reserved ;
  998};
  999typedef struct _DEVICE_OBJECT DEVICE_OBJECT;
 1000typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
 1001struct _DEVOBJ_EXTENSION {
 1002   CSHORT Type ;
 1003   USHORT Size ;
 1004   PDEVICE_OBJECT DeviceObject ;
 1005};
 1006struct _DRIVER_EXTENSION {
 1007   struct _DRIVER_OBJECT *DriverObject ;
 1008   NTSTATUS (*AddDevice)(struct _DRIVER_OBJECT *DriverObject , struct _DEVICE_OBJECT *PhysicalDeviceObject ) ;
 1009   ULONG Count ;
 1010   UNICODE_STRING ServiceKeyName ;
 1011};
 1012typedef struct _DRIVER_EXTENSION *PDRIVER_EXTENSION;
 1013struct _DRIVER_OBJECT {
 1014   CSHORT Type ;
 1015   CSHORT Size ;
 1016   PDEVICE_OBJECT DeviceObject ;
 1017   ULONG Flags ;
 1018   PVOID DriverStart ;
 1019   ULONG DriverSize ;
 1020   PVOID DriverSection ;
 1021   PDRIVER_EXTENSION DriverExtension ;
 1022   UNICODE_STRING DriverName ;
 1023   PUNICODE_STRING HardwareDatabase ;
 1024   PFAST_IO_DISPATCH FastIoDispatch ;
 1025   NTSTATUS (*DriverInit)(struct _DRIVER_OBJECT *DriverObject , PUNICODE_STRING RegistryPath ) ;
 1026   void (*DriverStartIo)(struct _DEVICE_OBJECT *DeviceObject , struct _IRP *Irp ) ;
 1027   void (*DriverUnload)(struct _DRIVER_OBJECT *DriverObject ) ;
 1028   PDRIVER_DISPATCH MajorFunction[28] ;
 1029};
 1030typedef struct _DRIVER_OBJECT DRIVER_OBJECT;
 1031typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
 1032struct _SECTION_OBJECT_POINTERS {
 1033   PVOID DataSectionObject ;
 1034   PVOID SharedCacheMap ;
 1035   PVOID ImageSectionObject ;
 1036};
 1037typedef struct _SECTION_OBJECT_POINTERS SECTION_OBJECT_POINTERS;
 1038typedef SECTION_OBJECT_POINTERS *PSECTION_OBJECT_POINTERS;
 1039struct _IO_COMPLETION_CONTEXT {
 1040   PVOID Port ;
 1041   PVOID Key ;
 1042};
 1043typedef struct _IO_COMPLETION_CONTEXT *PIO_COMPLETION_CONTEXT;
 1044struct _FILE_OBJECT {
 1045   CSHORT Type ;
 1046   CSHORT Size ;
 1047   PDEVICE_OBJECT DeviceObject ;
 1048   PVPB Vpb ;
 1049   PVOID FsContext ;
 1050   PVOID FsContext2 ;
 1051   PSECTION_OBJECT_POINTERS SectionObjectPointer ;
 1052   PVOID PrivateCacheMap ;
 1053   NTSTATUS FinalStatus ;
 1054   struct _FILE_OBJECT *RelatedFileObject ;
 1055   BOOLEAN LockOperation ;
 1056   BOOLEAN DeletePending ;
 1057   BOOLEAN ReadAccess ;
 1058   BOOLEAN WriteAccess ;
 1059   BOOLEAN DeleteAccess ;
 1060   BOOLEAN SharedRead ;
 1061   BOOLEAN SharedWrite ;
 1062   BOOLEAN SharedDelete ;
 1063   ULONG Flags ;
 1064   UNICODE_STRING FileName ;
 1065   LARGE_INTEGER CurrentByteOffset ;
 1066   ULONG Waiters ;
 1067   ULONG Busy ;
 1068   PVOID LastLock ;
 1069   KEVENT Lock ;
 1070   KEVENT Event ;
 1071   PIO_COMPLETION_CONTEXT CompletionContext ;
 1072};
 1073typedef struct _FILE_OBJECT *PFILE_OBJECT;
 1074union __anonunion_AssociatedIrp_44 {
 1075   struct _IRP *MasterIrp ;
 1076   LONG IrpCount ;
 1077   PVOID SystemBuffer ;
 1078};
 1079struct __anonstruct_AsynchronousParameters_46 {
 1080   void (*UserApcRoutine)(PVOID ApcContext , PIO_STATUS_BLOCK IoStatusBlock ,
 1081                                                          ULONG Reserved ) ;
 1082   PVOID UserApcContext ;
 1083};
 1084union __anonunion_Overlay_45 {
 1085   struct __anonstruct_AsynchronousParameters_46 AsynchronousParameters ;
 1086   LARGE_INTEGER AllocationSize ;
 1087};
 1088struct __anonstruct____missing_field_name_50 {
 1089   PVOID DriverContext[4] ;
 1090};
 1091union __anonunion____missing_field_name_49 {
 1092   KDEVICE_QUEUE_ENTRY DeviceQueueEntry ;
 1093   struct __anonstruct____missing_field_name_50 __annonCompField14 ;
 1094};
 1095struct _IO_STACK_LOCATION;
 1096union __anonunion____missing_field_name_52 {
 1097   struct _IO_STACK_LOCATION *CurrentStackLocation ;
 1098   ULONG PacketType ;
 1099};
 1100struct __anonstruct____missing_field_name_51 {
 1101   LIST_ENTRY ListEntry ;
 1102   union __anonunion____missing_field_name_52 __annonCompField16 ;
 1103};
 1104struct __anonstruct_Overlay_48 {
 1105   union __anonunion____missing_field_name_49 __annonCompField15 ;
 1106   PETHREAD Thread ;
 1107   PCHAR AuxiliaryBuffer ;
 1108   struct __anonstruct____missing_field_name_51 __annonCompField17 ;
 1109   PFILE_OBJECT OriginalFileObject ;
 1110};
 1111union __anonunion_Tail_47 {
 1112   struct __anonstruct_Overlay_48 Overlay ;
 1113   KAPC Apc ;
 1114   PVOID CompletionKey ;
 1115};
 1116struct _IRP {
 1117   CSHORT Type ;
 1118   USHORT Size ;
 1119   PMDL MdlAddress ;
 1120   ULONG Flags ;
 1121   union __anonunion_AssociatedIrp_44 AssociatedIrp ;
 1122   LIST_ENTRY ThreadListEntry ;
 1123   IO_STATUS_BLOCK IoStatus ;
 1124   KPROCESSOR_MODE RequestorMode ;
 1125   BOOLEAN PendingReturned ;
 1126   CHAR StackCount ;
 1127   CHAR CurrentLocation ;
 1128   BOOLEAN Cancel ;
 1129   KIRQL CancelIrql ;
 1130   CCHAR ApcEnvironment ;
 1131   UCHAR AllocationFlags ;
 1132   PIO_STATUS_BLOCK UserIosb ;
 1133   PKEVENT UserEvent ;
 1134   union __anonunion_Overlay_45 Overlay ;
 1135   void (*CancelRoutine)(struct _DEVICE_OBJECT *DeviceObject , struct _IRP *Irp ) ;
 1136   PVOID UserBuffer ;
 1137   union __anonunion_Tail_47 Tail ;
 1138};
 1139typedef struct _IRP IRP;
 1140typedef struct _IRP *PIRP;
 1141enum _DEVICE_RELATION_TYPE {
 1142    BusRelations = 0,
 1143    EjectionRelations = 1,
 1144    PowerRelations = 2,
 1145    RemovalRelations = 3,
 1146    TargetDeviceRelation = 4
 1147} ;
 1148typedef enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE;
 1149struct _DEVICE_RELATIONS {
 1150   ULONG Count ;
 1151   PDEVICE_OBJECT Objects[1] ;
 1152};
 1153typedef struct _DEVICE_RELATIONS DEVICE_RELATIONS;
 1154typedef struct _DEVICE_RELATIONS *PDEVICE_RELATIONS;
 1155enum _DEVICE_USAGE_NOTIFICATION_TYPE {
 1156    DeviceUsageTypeUndefined = 0,
 1157    DeviceUsageTypePaging = 1,
 1158    DeviceUsageTypeHibernation = 2,
 1159    DeviceUsageTypeDumpFile = 3
 1160} ;
 1161typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE DEVICE_USAGE_NOTIFICATION_TYPE;
 1162struct _INTERFACE {
 1163   USHORT Size ;
 1164   USHORT Version ;
 1165   PVOID Context ;
 1166   void (*InterfaceReference)(PVOID Context ) ;
 1167   void (*InterfaceDereference)(PVOID Context ) ;
 1168};
 1169typedef struct _INTERFACE *PINTERFACE;
 1170struct _DEVICE_CAPABILITIES {
 1171   USHORT Size ;
 1172   USHORT Version ;
 1173   ULONG DeviceD1 : 1 ;
 1174   ULONG DeviceD2 : 1 ;
 1175   ULONG LockSupported : 1 ;
 1176   ULONG EjectSupported : 1 ;
 1177   ULONG Removable : 1 ;
 1178   ULONG DockDevice : 1 ;
 1179   ULONG UniqueID : 1 ;
 1180   ULONG SilentInstall : 1 ;
 1181   ULONG RawDeviceOK : 1 ;
 1182   ULONG SurpriseRemovalOK : 1 ;
 1183   ULONG WakeFromD0 : 1 ;
 1184   ULONG WakeFromD1 : 1 ;
 1185   ULONG WakeFromD2 : 1 ;
 1186   ULONG WakeFromD3 : 1 ;
 1187   ULONG HardwareDisabled : 1 ;
 1188   ULONG NonDynamic : 1 ;
 1189   ULONG WarmEjectSupported : 1 ;
 1190   ULONG Reserved : 15 ;
 1191   ULONG Address ;
 1192   ULONG UINumber ;
 1193   DEVICE_POWER_STATE DeviceState[7] ;
 1194   SYSTEM_POWER_STATE SystemWake ;
 1195   DEVICE_POWER_STATE DeviceWake ;
 1196   ULONG D1Latency ;
 1197   ULONG D2Latency ;
 1198   ULONG D3Latency ;
 1199};
 1200typedef struct _DEVICE_CAPABILITIES *PDEVICE_CAPABILITIES;
 1201struct _POWER_SEQUENCE {
 1202   ULONG SequenceD1 ;
 1203   ULONG SequenceD2 ;
 1204   ULONG SequenceD3 ;
 1205};
 1206typedef struct _POWER_SEQUENCE *PPOWER_SEQUENCE;
 1207enum __anonenum_BUS_QUERY_ID_TYPE_53 {
 1208    BusQueryDeviceID = 0,
 1209    BusQueryHardwareIDs = 1,
 1210    BusQueryCompatibleIDs = 2,
 1211    BusQueryInstanceID = 3,
 1212    BusQueryDeviceSerialNumber = 4
 1213} ;
 1214typedef enum __anonenum_BUS_QUERY_ID_TYPE_53 BUS_QUERY_ID_TYPE;
 1215enum __anonenum_DEVICE_TEXT_TYPE_54 {
 1216    DeviceTextDescription = 0,
 1217    DeviceTextLocationInformation = 1
 1218} ;
 1219typedef enum __anonenum_DEVICE_TEXT_TYPE_54 DEVICE_TEXT_TYPE;
 1220#pragma pack(push,4)
 1221struct __anonstruct_Create_56 {
 1222   PIO_SECURITY_CONTEXT SecurityContext ;
 1223   ULONG Options ;
 1224   USHORT FileAttributes ;
 1225   USHORT ShareAccess ;
 1226   ULONG EaLength ;
 1227};
 1228struct __anonstruct_Read_57 {
 1229   ULONG Length ;
 1230   ULONG Key ;
 1231   LARGE_INTEGER ByteOffset ;
 1232};
 1233struct __anonstruct_Write_58 {
 1234   ULONG Length ;
 1235   ULONG Key ;
 1236   LARGE_INTEGER ByteOffset ;
 1237};
 1238struct __anonstruct_QueryFile_59 {
 1239   ULONG Length ;
 1240   FILE_INFORMATION_CLASS FileInformationClass ;
 1241};
 1242struct __anonstruct____missing_field_name_62 {
 1243   BOOLEAN ReplaceIfExists ;
 1244   BOOLEAN AdvanceOnly ;
 1245};
 1246union __anonunion____missing_field_name_61 {
 1247   struct __anonstruct____missing_field_name_62 __annonCompField18 ;
 1248   ULONG ClusterCount ;
 1249   HANDLE DeleteHandle ;
 1250};
 1251struct __anonstruct_SetFile_60 {
 1252   ULONG Length ;
 1253   FILE_INFORMATION_CLASS FileInformationClass ;
 1254   PFILE_OBJECT FileObject ;
 1255   union __anonunion____missing_field_name_61 __annonCompField19 ;
 1256};
 1257struct __anonstruct_QueryVolume_63 {
 1258   ULONG Length ;
 1259   FS_INFORMATION_CLASS FsInformationClass ;
 1260};
 1261struct __anonstruct_DeviceIoControl_64 {
 1262   ULONG OutputBufferLength ;
 1263   ULONG InputBufferLength ;
 1264   ULONG IoControlCode ;
 1265   PVOID Type3InputBuffer ;
 1266};
 1267struct __anonstruct_QuerySecurity_65 {
 1268   SECURITY_INFORMATION SecurityInformation ;
 1269   ULONG Length ;
 1270};
 1271struct __anonstruct_SetSecurity_66 {
 1272   SECURITY_INFORMATION SecurityInformation ;
 1273   PSECURITY_DESCRIPTOR SecurityDescriptor ;
 1274};
 1275struct __anonstruct_MountVolume_67 {
 1276   PVPB Vpb ;
 1277   PDEVICE_OBJECT DeviceObject ;
 1278};
 1279struct __anonstruct_VerifyVolume_68 {
 1280   PVPB Vpb ;
 1281   PDEVICE_OBJECT DeviceObject ;
 1282};
 1283struct __anonstruct_Scsi_69 {
 1284   struct _SCSI_REQUEST_BLOCK *Srb ;
 1285};
 1286struct __anonstruct_QueryDeviceRelations_70 {
 1287   DEVICE_RELATION_TYPE Type ;
 1288};
 1289struct __anonstruct_QueryInterface_71 {
 1290   GUID const   *InterfaceType ;
 1291   USHORT Size ;
 1292   USHORT Version ;
 1293   PINTERFACE Interface ;
 1294   PVOID InterfaceSpecificData ;
 1295};
 1296struct __anonstruct_DeviceCapabilities_72 {
 1297   PDEVICE_CAPABILITIES Capabilities ;
 1298};
 1299struct __anonstruct_FilterResourceRequirements_73 {
 1300   PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList ;
 1301};
 1302struct __anonstruct_ReadWriteConfig_74 {
 1303   ULONG WhichSpace ;
 1304   PVOID Buffer ;
 1305   ULONG Offset ;
 1306   ULONG Length ;
 1307};
 1308struct __anonstruct_SetLock_75 {
 1309   BOOLEAN Lock ;
 1310};
 1311struct __anonstruct_QueryId_76 {
 1312   BUS_QUERY_ID_TYPE IdType ;
 1313};
 1314struct __anonstruct_QueryDeviceText_77 {
 1315   DEVICE_TEXT_TYPE DeviceTextType ;
 1316   LCID LocaleId ;
 1317};
 1318struct __anonstruct_UsageNotification_78 {
 1319   BOOLEAN InPath ;
 1320   BOOLEAN Reserved[3] ;
 1321   DEVICE_USAGE_NOTIFICATION_TYPE Type ;
 1322};
 1323struct __anonstruct_WaitWake_79 {
 1324   SYSTEM_POWER_STATE PowerState ;
 1325};
 1326struct __anonstruct_PowerSequence_80 {
 1327   PPOWER_SEQUENCE PowerSequence ;
 1328};
 1329struct __anonstruct_Power_81 {
 1330   ULONG SystemContext ;
 1331   POWER_STATE_TYPE Type ;
 1332   POWER_STATE State ;
 1333   POWER_ACTION ShutdownType ;
 1334};
 1335struct __anonstruct_StartDevice_82 {
 1336   PCM_RESOURCE_LIST AllocatedResources ;
 1337   PCM_RESOURCE_LIST AllocatedResourcesTranslated ;
 1338};
 1339struct __anonstruct_WMI_83 {
 1340   ULONG_PTR ProviderId ;
 1341   PVOID DataPath ;
 1342   ULONG BufferSize ;
 1343   PVOID Buffer ;
 1344};
 1345struct __anonstruct_Others_84 {
 1346   PVOID Argument1 ;
 1347   PVOID Argument2 ;
 1348   PVOID Argument3 ;
 1349   PVOID Argument4 ;
 1350};
 1351union __anonunion_Parameters_55 {
 1352   struct __anonstruct_Create_56 Create ;
 1353   struct __anonstruct_Read_57 Read ;
 1354   struct __anonstruct_Write_58 Write ;
 1355   struct __anonstruct_QueryFile_59 QueryFile ;
 1356   struct __anonstruct_SetFile_60 SetFile ;
 1357   struct __anonstruct_QueryVolume_63 QueryVolume ;
 1358   struct __anonstruct_DeviceIoControl_64 DeviceIoControl ;
 1359   struct __anonstruct_QuerySecurity_65 QuerySecurity ;
 1360   struct __anonstruct_SetSecurity_66 SetSecurity ;
 1361   struct __anonstruct_MountVolume_67 MountVolume ;
 1362   struct __anonstruct_VerifyVolume_68 VerifyVolume ;
 1363   struct __anonstruct_Scsi_69 Scsi ;
 1364   struct __anonstruct_QueryDeviceRelations_70 QueryDeviceRelations ;
 1365   struct __anonstruct_QueryInterface_71 QueryInterface ;
 1366   struct __anonstruct_DeviceCapabilities_72 DeviceCapabilities ;
 1367   struct __anonstruct_FilterResourceRequirements_73 FilterResourceRequirements ;
 1368   struct __anonstruct_ReadWriteConfig_74 ReadWriteConfig ;
 1369   struct __anonstruct_SetLock_75 SetLock ;
 1370   struct __anonstruct_QueryId_76 QueryId ;
 1371   struct __anonstruct_QueryDeviceText_77 QueryDeviceText ;
 1372   struct __anonstruct_UsageNotification_78 UsageNotification ;
 1373   struct __anonstruct_WaitWake_79 WaitWake ;
 1374   struct __anonstruct_PowerSequence_80 PowerSequence ;
 1375   struct __anonstruct_Power_81 Power ;
 1376   struct __anonstruct_StartDevice_82 StartDevice ;
 1377   struct __anonstruct_WMI_83 WMI ;
 1378   struct __anonstruct_Others_84 Others ;
 1379};
 1380struct _IO_STACK_LOCATION {
 1381   UCHAR MajorFunction ;
 1382   UCHAR MinorFunction ;
 1383   UCHAR Flags ;
 1384   UCHAR Control ;
 1385   union __anonunion_Parameters_55 Parameters ;
 1386   PDEVICE_OBJECT DeviceObject ;
 1387   PFILE_OBJECT FileObject ;
 1388   NTSTATUS (*CompletionRoutine)(PDEVICE_OBJECT DeviceObject , PIRP Irp , PVOID Context ) ;
 1389   PVOID Context ;
 1390};
 1391typedef struct _IO_STACK_LOCATION IO_STACK_LOCATION;
 1392typedef struct _IO_STACK_LOCATION *PIO_STACK_LOCATION;
 1393#pragma pack(pop)
 1394struct _CONFIGURATION_INFORMATION {
 1395   ULONG DiskCount ;
 1396   ULONG FloppyCount ;
 1397   ULONG CdRomCount ;
 1398   ULONG TapeCount ;
 1399   ULONG ScsiPortCount ;
 1400   ULONG SerialCount ;
 1401   ULONG ParallelCount ;
 1402   BOOLEAN AtDiskPrimaryAddressClaimed ;
 1403   BOOLEAN AtDiskSecondaryAddressClaimed ;
 1404   ULONG Version ;
 1405   ULONG MediumChangerCount ;
 1406};
 1407typedef struct _CONFIGURATION_INFORMATION CONFIGURATION_INFORMATION;
 1408typedef struct _CONFIGURATION_INFORMATION *PCONFIGURATION_INFORMATION;
 1409struct _IO_REMOVE_LOCK_COMMON_BLOCK {
 1410   BOOLEAN Removed ;
 1411   BOOLEAN Reserved[3] ;
 1412   LONG IoCount ;
 1413   KEVENT RemoveEvent ;
 1414};
 1415typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK IO_REMOVE_LOCK_COMMON_BLOCK;
 1416struct _IO_REMOVE_LOCK {
 1417   IO_REMOVE_LOCK_COMMON_BLOCK Common ;
 1418};
 1419typedef struct _IO_REMOVE_LOCK IO_REMOVE_LOCK;
 1420typedef struct _IO_REMOVE_LOCK *PIO_REMOVE_LOCK;
 1421struct _OBJECT_HANDLE_INFORMATION {
 1422   ULONG HandleAttributes ;
 1423   ACCESS_MASK GrantedAccess ;
 1424};
 1425typedef struct _OBJECT_HANDLE_INFORMATION *POBJECT_HANDLE_INFORMATION;
 1426struct _PARPORT_REMOVAL_RELATIONS {
 1427   PDEVICE_OBJECT DeviceObject ;
 1428   ULONG Flags ;
 1429   PUNICODE_STRING DeviceName ;
 1430};
 1431typedef struct _PARPORT_REMOVAL_RELATIONS PARPORT_REMOVAL_RELATIONS;
 1432typedef struct _PARPORT_REMOVAL_RELATIONS *PPARPORT_REMOVAL_RELATIONS;
 1433struct _PARALLEL_PARCHIP_INFO {
 1434   PUCHAR Controller ;
 1435   PUCHAR EcrController ;
 1436   ULONG HardwareModes ;
 1437   NTSTATUS (*ParChipSetMode)(PVOID SetChipContext , UCHAR ChipMode ) ;
 1438   NTSTATUS (*ParChipClearMode)(PVOID ClearChipContext , UCHAR ChipMode ) ;
 1439   PVOID Context ;
 1440   BOOLEAN success ;
 1441};
 1442typedef struct _PARALLEL_PARCHIP_INFO PARALLEL_PARCHIP_INFO;
 1443struct _PARALLEL_PORT_INFORMATION {
 1444   PHYSICAL_ADDRESS OriginalController ;
 1445   PUCHAR Controller ;
 1446   ULONG SpanOfController ;
 1447   BOOLEAN (*TryAllocatePort)(PVOID TryAllocateContext ) ;
 1448   void (*FreePort)(PVOID FreeContext ) ;
 1449   ULONG (*QueryNumWaiters)(PVOID QueryAllocsContext ) ;
 1450   PVOID Context ;
 1451};
 1452typedef struct _PARALLEL_PORT_INFORMATION PARALLEL_PORT_INFORMATION;
 1453typedef struct _PARALLEL_PORT_INFORMATION *PPARALLEL_PORT_INFORMATION;
 1454struct _PARALLEL_PNP_INFORMATION {
 1455   PHYSICAL_ADDRESS OriginalEcpController ;
 1456   PUCHAR EcpController ;
 1457   ULONG SpanOfEcpController ;
 1458   ULONG PortNumber ;
 1459   ULONG HardwareCapabilities ;
 1460   NTSTATUS (*TrySetChipMode)(PVOID SetChipContext , UCHAR ChipMode ) ;
 1461   NTSTATUS (*ClearChipMode)(PVOID ClearChipContext , UCHAR ChipMode ) ;
 1462   ULONG FifoDepth ;
 1463   ULONG FifoWidth ;
 1464   PHYSICAL_ADDRESS EppControllerPhysicalAddress ;
 1465   ULONG SpanOfEppController ;
 1466   ULONG Ieee1284_3DeviceCount ;
 1467   NTSTATUS (*TrySelectDevice)(PVOID TrySelectContext , PVOID TrySelectCommand ) ;
 1468   NTSTATUS (*DeselectDevice)(PVOID DeselectContext , PVOID DeselectCommand ) ;
 1469   PVOID Context ;
 1470   ULONG CurrentMode ;
 1471   PWSTR PortName ;
 1472};
 1473typedef struct _PARALLEL_PNP_INFORMATION PARALLEL_PNP_INFORMATION;
 1474typedef struct _PARALLEL_PNP_INFORMATION *PPARALLEL_PNP_INFORMATION;
 1475struct _PARALLEL_1284_COMMAND {
 1476   UCHAR ID ;
 1477   UCHAR Port ;
 1478   ULONG CommandFlags ;
 1479};
 1480typedef struct _PARALLEL_1284_COMMAND PARALLEL_1284_COMMAND;
 1481typedef struct _PARALLEL_1284_COMMAND *PPARALLEL_1284_COMMAND;
 1482struct _PARALLEL_CHIP_MODE {
 1483   UCHAR ModeFlags ;
 1484   BOOLEAN success ;
 1485};
 1486typedef struct _PARALLEL_CHIP_MODE PARALLEL_CHIP_MODE;
 1487struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE {
 1488   BOOLEAN (*InterruptServiceRoutine)(struct _KINTERRUPT *Interrupt , PVOID ServiceContext ) ;
 1489   PVOID InterruptServiceContext ;
 1490   void (*DeferredPortCheckRoutine)(PVOID DeferredContext ) ;
 1491   PVOID DeferredPortCheckContext ;
 1492};
 1493typedef struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE PARALLEL_INTERRUPT_SERVICE_ROUTINE;
 1494typedef struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE *PPARALLEL_INTERRUPT_SERVICE_ROUTINE;
 1495struct _PARALLEL_INTERRUPT_INFORMATION {
 1496   PKINTERRUPT InterruptObject ;
 1497   BOOLEAN (*TryAllocatePortAtInterruptLevel)(PVOID TryAllocateContext ) ;
 1498   void (*FreePortFromInterruptLevel)(PVOID FreeContext ) ;
 1499   PVOID Context ;
 1500};
 1501typedef struct _PARALLEL_INTERRUPT_INFORMATION PARALLEL_INTERRUPT_INFORMATION;
 1502typedef struct _PARALLEL_INTERRUPT_INFORMATION *PPARALLEL_INTERRUPT_INFORMATION;
 1503struct _MORE_PARALLEL_PORT_INFORMATION {
 1504   INTERFACE_TYPE InterfaceType ;
 1505   ULONG BusNumber ;
 1506   ULONG InterruptLevel ;
 1507   ULONG InterruptVector ;
 1508   KAFFINITY InterruptAffinity ;
 1509   KINTERRUPT_MODE InterruptMode ;
 1510};
 1511typedef struct _MORE_PARALLEL_PORT_INFORMATION MORE_PARALLEL_PORT_INFORMATION;
 1512typedef struct _MORE_PARALLEL_PORT_INFORMATION *PMORE_PARALLEL_PORT_INFORMATION;
 1513struct __anonstruct_WMIGUIDREGINFO_114 {
 1514   LPCGUID Guid ;
 1515   ULONG InstanceCount ;
 1516   ULONG Flags ;
 1517};
 1518typedef struct __anonstruct_WMIGUIDREGINFO_114 WMIGUIDREGINFO;
 1519typedef struct __anonstruct_WMIGUIDREGINFO_114 *PWMIGUIDREGINFO;
 1520enum __anonenum_WMIENABLEDISABLECONTROL_115 {
 1521    WmiEventControl = 0,
 1522    WmiDataBlockControl = 1
 1523} ;
 1524typedef enum __anonenum_WMIENABLEDISABLECONTROL_115 WMIENABLEDISABLECONTROL;
 1525struct _WMILIB_CONTEXT {
 1526   ULONG GuidCount ;
 1527   PWMIGUIDREGINFO GuidList ;
 1528   NTSTATUS (*QueryWmiRegInfo)(PDEVICE_OBJECT DeviceObject , PULONG RegFlags , PUNICODE_STRING InstanceName ,
 1529                               PUNICODE_STRING *RegistryPath , PUNICODE_STRING MofResourceName ,
 1530                               PDEVICE_OBJECT *Pdo ) ;
 1531   NTSTATUS (*QueryWmiDataBlock)(PDEVICE_OBJECT DeviceObject , PIRP Irp , ULONG GuidIndex ,
 1532                                 ULONG InstanceIndex , ULONG InstanceCount , PULONG InstanceLengthArray ,
 1533                                 ULONG BufferAvail , PUCHAR Buffer ) ;
 1534   NTSTATUS (*SetWmiDataBlock)(PDEVICE_OBJECT DeviceObject , PIRP Irp , ULONG GuidIndex ,
 1535                               ULONG InstanceIndex , ULONG BufferSize , PUCHAR Buffer ) ;
 1536   NTSTATUS (*SetWmiDataItem)(PDEVICE_OBJECT DeviceObject , PIRP Irp , ULONG GuidIndex ,
 1537                              ULONG InstanceIndex , ULONG DataItemId , ULONG BufferSize ,
 1538                              PUCHAR Buffer ) ;
 1539   NTSTATUS (*ExecuteWmiMethod)(PDEVICE_OBJECT DeviceObject , PIRP Irp , ULONG GuidIndex ,
 1540                                ULONG InstanceIndex , ULONG MethodId , ULONG InBufferSize ,
 1541                                ULONG OutBufferSize , PUCHAR Buffer ) ;
 1542   NTSTATUS (*WmiFunctionControl)(PDEVICE_OBJECT DeviceObject , PIRP Irp , ULONG GuidIndex ,
 1543                                  WMIENABLEDISABLECONTROL Function , BOOLEAN Enable ) ;
 1544};
 1545typedef struct _WMILIB_CONTEXT WMILIB_CONTEXT;
 1546typedef struct _WMILIB_CONTEXT *PWMILIB_CONTEXT;
 1547enum __anonenum_SYSCTL_IRP_DISPOSITION_116 {
 1548    IrpProcessed = 0,
 1549    IrpNotCompleted = 1,
 1550    IrpNotWmi = 2,
 1551    IrpForward = 3
 1552} ;
 1553typedef enum __anonenum_SYSCTL_IRP_DISPOSITION_116 SYSCTL_IRP_DISPOSITION;
 1554typedef enum __anonenum_SYSCTL_IRP_DISPOSITION_116 *PSYSCTL_IRP_DISPOSITION;
 1555struct _PARPORT_WMI_ALLOC_FREE_COUNTS {
 1556   ULONG PortAllocates ;
 1557   ULONG PortFrees ;
 1558};
 1559typedef struct _PARPORT_WMI_ALLOC_FREE_COUNTS PARPORT_WMI_ALLOC_FREE_COUNTS;
 1560struct _DEVICE_EXTENSION {
 1561   ULONG ExtensionSignatureBegin ;
 1562   ULONG DeviceStateFlags ;
 1563   PDEVICE_OBJECT DeviceObject ;
 1564   PDRIVER_OBJECT DriverObject ;
 1565   PDEVICE_OBJECT PhysicalDeviceObject ;
 1566   PDEVICE_OBJECT ParentDeviceObject ;
 1567   LONG OpenCloseRefCount ;
 1568   LIST_ENTRY RemovalRelationsList ;
 1569   LIST_ENTRY WorkQueue ;
 1570   LONG WorkQueueCount ;
 1571   PARALLEL_PORT_INFORMATION PortInfo ;
 1572   PARALLEL_PNP_INFORMATION PnpInfo ;
 1573   ULONG AddressSpace ;
 1574   ULONG EcpAddressSpace ;
 1575   INTERFACE_TYPE InterfaceType ;
 1576   ULONG BusNumber ;
 1577   BOOLEAN FoundInterrupt ;
 1578   KIRQL InterruptLevel ;
 1579   ULONG InterruptVector ;
 1580   KAFFINITY InterruptAffinity ;
 1581   KINTERRUPT_MODE InterruptMode ;
 1582   ULONG DmaChannel ;
 1583   ULONG DmaPort ;
 1584   USHORT DmaWidth ;
 1585   LIST_ENTRY IsrList ;
 1586   PKINTERRUPT InterruptObject ;
 1587   ULONG InterruptRefCount ;
 1588   KDPC FreePortDpc ;
 1589   BOOLEAN UnMapRegisters ;
 1590   BOOLEAN NationalChecked ;
 1591   BOOLEAN NationalChipFound ;
 1592   BOOLEAN FilterMode ;
 1593   UCHAR EcrPortData ;
 1594   PARALLEL_PARCHIP_INFO ChipInfo ;
 1595   UNICODE_STRING DeviceName ;
 1596   UNICODE_STRING SymbolicLinkName ;
 1597   DEVICE_POWER_STATE DeviceState ;
 1598   SYSTEM_POWER_STATE SystemState ;
 1599   IO_REMOVE_LOCK RemoveLock ;
 1600   FAST_MUTEX ExtensionFastMutex ;
 1601   FAST_MUTEX OpenCloseMutex ;
 1602   WMILIB_CONTEXT WmiLibContext ;
 1603   PARPORT_WMI_ALLOC_FREE_COUNTS WmiPortAllocFreeCounts ;
 1604   BOOLEAN CheckedForGenericEpp ;
 1605   BOOLEAN spare[3] ;
 1606   ULONG ExtensionSignatureEnd ;
 1607};
 1608typedef struct _DEVICE_EXTENSION DEVICE_EXTENSION;
 1609typedef struct _DEVICE_EXTENSION *PDEVICE_EXTENSION;
 1610struct _SYNCHRONIZED_COUNT_CONTEXT {
 1611   PLONG Count ;
 1612   LONG NewCount ;
 1613};
 1614typedef struct _SYNCHRONIZED_COUNT_CONTEXT SYNCHRONIZED_COUNT_CONTEXT;
 1615struct _SYNCHRONIZED_LIST_CONTEXT {
 1616   PLIST_ENTRY List ;
 1617   PLIST_ENTRY NewEntry ;
 1618};
 1619typedef struct _SYNCHRONIZED_LIST_CONTEXT SYNCHRONIZED_LIST_CONTEXT;
 1620typedef struct _SYNCHRONIZED_LIST_CONTEXT *PSYNCHRONIZED_LIST_CONTEXT;
 1621struct _SYNCHRONIZED_DISCONNECT_CONTEXT {
 1622   PDEVICE_EXTENSION Extension ;
 1623   PPARALLEL_INTERRUPT_SERVICE_ROUTINE IsrInfo ;
 1624};
 1625typedef struct _SYNCHRONIZED_DISCONNECT_CONTEXT SYNCHRONIZED_DISCONNECT_CONTEXT;
 1626typedef struct _SYNCHRONIZED_DISCONNECT_CONTEXT *PSYNCHRONIZED_DISCONNECT_CONTEXT;
 1627struct _ISR_LIST_ENTRY {
 1628   LIST_ENTRY ListEntry ;
 1629   BOOLEAN (*ServiceRoutine)(struct _KINTERRUPT *Interrupt , PVOID ServiceContext ) ;
 1630   PVOID ServiceContext ;
 1631   void (*DeferredPortCheckRoutine)(PVOID DeferredContext ) ;
 1632   PVOID CheckContext ;
 1633};
 1634typedef struct _ISR_LIST_ENTRY ISR_LIST_ENTRY;
 1635typedef struct _ISR_LIST_ENTRY *PISR_LIST_ENTRY;
 1636struct _REMOVAL_RELATIONS_LIST_ENTRY {
 1637   LIST_ENTRY ListEntry ;
 1638   PDEVICE_OBJECT DeviceObject ;
 1639   ULONG Flags ;
 1640   UNICODE_STRING DeviceName ;
 1641};
 1642typedef struct _REMOVAL_RELATIONS_LIST_ENTRY REMOVAL_RELATIONS_LIST_ENTRY;
 1643typedef struct _REMOVAL_RELATIONS_LIST_ENTRY *PREMOVAL_RELATIONS_LIST_ENTRY;
 1644#pragma pack(push,8)
 1645#pragma pack(pop)
 1646struct _KAPC;
 1647struct _KDPC;
 1648#pragma pack(push,4)
 1649#pragma pack(pop)
 1650#pragma pack(push,4)
 1651#pragma pack(pop)
 1652#pragma pack(push,1)
 1653#pragma pack(pop)
 1654struct _DRIVER_OBJECT;
 1655struct _DEVICE_OBJECT;
 1656struct _DRIVER_OBJECT;
 1657struct _FILE_OBJECT;
 1658struct _IRP;
 1659struct _SCSI_REQUEST_BLOCK;
 1660#pragma pack(push,4)
 1661#pragma pack(pop)
 1662#pragma pack(push,8)
 1663#pragma pack(pop)
 1664struct _KAPC;
 1665struct _KDPC;
 1666#pragma pack(push,4)
 1667#pragma pack(pop)
 1668#pragma pack(push,4)
 1669#pragma pack(pop)
 1670#pragma pack(push,1)
 1671#pragma pack(pop)
 1672struct _DRIVER_OBJECT;
 1673struct _DEVICE_OBJECT;
 1674struct _DRIVER_OBJECT;
 1675struct _FILE_OBJECT;
 1676struct _IRP;
 1677struct _SCSI_REQUEST_BLOCK;
 1678#pragma pack(push,4)
 1679#pragma pack(pop)
 1680#pragma pack(push,8)
 1681#pragma pack(pop)
 1682struct _KAPC;
 1683struct _KDPC;
 1684#pragma pack(push,4)
 1685#pragma pack(pop)
 1686#pragma pack(push,4)
 1687#pragma pack(pop)
 1688#pragma pack(push,1)
 1689#pragma pack(pop)
 1690struct _DRIVER_OBJECT;
 1691struct _DEVICE_OBJECT;
 1692struct _DRIVER_OBJECT;
 1693struct _FILE_OBJECT;
 1694struct _IRP;
 1695struct _SCSI_REQUEST_BLOCK;
 1696#pragma pack(push,4)
 1697#pragma pack(pop)
 1698#pragma pack(push,8)
 1699#pragma pack(pop)
 1700struct _KAPC;
 1701struct _KDPC;
 1702#pragma pack(push,4)
 1703#pragma pack(pop)
 1704#pragma pack(push,4)
 1705#pragma pack(pop)
 1706#pragma pack(push,1)
 1707#pragma pack(pop)
 1708struct _DRIVER_OBJECT;
 1709struct _DEVICE_OBJECT;
 1710struct _DRIVER_OBJECT;
 1711struct _FILE_OBJECT;
 1712struct _IRP;
 1713struct _SCSI_REQUEST_BLOCK;
 1714#pragma pack(push,4)
 1715#pragma pack(pop)
 1716#pragma pack(push,8)
 1717#pragma pack(pop)
 1718struct _KAPC;
 1719struct _KDPC;
 1720#pragma pack(push,4)
 1721#pragma pack(pop)
 1722#pragma pack(push,4)
 1723#pragma pack(pop)
 1724#pragma pack(push,1)
 1725#pragma pack(pop)
 1726struct _DRIVER_OBJECT;
 1727struct _DEVICE_OBJECT;
 1728struct _DRIVER_OBJECT;
 1729struct _FILE_OBJECT;
 1730struct _IRP;
 1731struct _SCSI_REQUEST_BLOCK;
 1732#pragma pack(push,4)
 1733#pragma pack(pop)
 1734#pragma pack(push,8)
 1735#pragma pack(pop)
 1736struct _KAPC;
 1737struct _KDPC;
 1738#pragma pack(push,4)
 1739#pragma pack(pop)
 1740#pragma pack(push,4)
 1741#pragma pack(pop)
 1742#pragma pack(push,1)
 1743#pragma pack(pop)
 1744struct _DRIVER_OBJECT;
 1745struct _DEVICE_OBJECT;
 1746struct _DRIVER_OBJECT;
 1747struct _FILE_OBJECT;
 1748struct _IRP;
 1749struct _SCSI_REQUEST_BLOCK;
 1750#pragma pack(push,4)
 1751#pragma pack(pop)
 1752#pragma pack(push,8)
 1753#pragma pack(pop)
 1754struct _KAPC;
 1755struct _KDPC;
 1756#pragma pack(push,4)
 1757#pragma pack(pop)
 1758#pragma pack(push,4)
 1759#pragma pack(pop)
 1760#pragma pack(push,1)
 1761#pragma pack(pop)
 1762struct _DRIVER_OBJECT;
 1763struct _DEVICE_OBJECT;
 1764struct _DRIVER_OBJECT;
 1765struct _FILE_OBJECT;
 1766struct _IRP;
 1767struct _SCSI_REQUEST_BLOCK;
 1768#pragma pack(push,4)
 1769#pragma pack(pop)
 1770#pragma pack(push,8)
 1771#pragma pack(pop)
 1772struct _KAPC;
 1773struct _KDPC;
 1774#pragma pack(push,4)
 1775#pragma pack(pop)
 1776#pragma pack(push,4)
 1777#pragma pack(pop)
 1778#pragma pack(push,1)
 1779#pragma pack(pop)
 1780struct _DRIVER_OBJECT;
 1781struct _DEVICE_OBJECT;
 1782struct _DRIVER_OBJECT;
 1783struct _FILE_OBJECT;
 1784struct _IRP;
 1785struct _SCSI_REQUEST_BLOCK;
 1786#pragma pack(push,4)
 1787#pragma pack(pop)
 1788#pragma pack(push,8)
 1789#pragma pack(pop)
 1790struct _KAPC;
 1791struct _KDPC;
 1792#pragma pack(push,4)
 1793#pragma pack(pop)
 1794#pragma pack(push,4)
 1795#pragma pack(pop)
 1796#pragma pack(push,1)
 1797#pragma pack(pop)
 1798struct _DRIVER_OBJECT;
 1799struct _DEVICE_OBJECT;
 1800struct _DRIVER_OBJECT;
 1801struct _FILE_OBJECT;
 1802struct _IRP;
 1803struct _SCSI_REQUEST_BLOCK;
 1804#pragma pack(push,4)
 1805#pragma pack(pop)
 1806#pragma pack(push,8)
 1807#pragma pack(pop)
 1808struct _KAPC;
 1809struct _KDPC;
 1810#pragma pack(push,4)
 1811#pragma pack(pop)
 1812#pragma pack(push,4)
 1813#pragma pack(pop)
 1814#pragma pack(push,1)
 1815#pragma pack(pop)
 1816struct _DRIVER_OBJECT;
 1817struct _DEVICE_OBJECT;
 1818struct _DRIVER_OBJECT;
 1819struct _FILE_OBJECT;
 1820struct _IRP;
 1821struct _SCSI_REQUEST_BLOCK;
 1822#pragma pack(push,4)
 1823#pragma pack(pop)
 1824#pragma pack(push,8)
 1825#pragma pack(pop)
 1826struct _KAPC;
 1827struct _KDPC;
 1828#pragma pack(push,4)
 1829#pragma pack(pop)
 1830#pragma pack(push,4)
 1831#pragma pack(pop)
 1832#pragma pack(push,1)
 1833#pragma pack(pop)
 1834struct _DRIVER_OBJECT;
 1835struct _DEVICE_OBJECT;
 1836struct _DRIVER_OBJECT;
 1837struct _FILE_OBJECT;
 1838struct _IRP;
 1839struct _SCSI_REQUEST_BLOCK;
 1840#pragma pack(push,4)
 1841#pragma pack(pop)
 1842#pragma pack(push,8)
 1843#pragma pack(pop)
 1844struct _KAPC;
 1845struct _KDPC;
 1846#pragma pack(push,4)
 1847#pragma pack(pop)
 1848#pragma pack(push,4)
 1849#pragma pack(pop)
 1850#pragma pack(push,1)
 1851#pragma pack(pop)
 1852struct _DRIVER_OBJECT;
 1853struct _DEVICE_OBJECT;
 1854struct _DRIVER_OBJECT;
 1855struct _FILE_OBJECT;
 1856struct _IRP;
 1857struct _SCSI_REQUEST_BLOCK;
 1858#pragma pack(push,4)
 1859#pragma pack(pop)
 1860#pragma pack(push,8)
 1861#pragma pack(pop)
 1862struct _KAPC;
 1863struct _KDPC;
 1864#pragma pack(push,4)
 1865#pragma pack(pop)
 1866#pragma pack(push,4)
 1867#pragma pack(pop)
 1868#pragma pack(push,1)
 1869#pragma pack(pop)
 1870struct _DRIVER_OBJECT;
 1871struct _DEVICE_OBJECT;
 1872struct _DRIVER_OBJECT;
 1873struct _FILE_OBJECT;
 1874struct _IRP;
 1875struct _SCSI_REQUEST_BLOCK;
 1876#pragma pack(push,4)
 1877#pragma pack(pop)
 1878#pragma pack(push,8)
 1879#pragma pack(pop)
 1880struct _KAPC;
 1881struct _KDPC;
 1882#pragma pack(push,4)
 1883#pragma pack(pop)
 1884#pragma pack(push,4)
 1885#pragma pack(pop)
 1886#pragma pack(push,1)
 1887#pragma pack(pop)
 1888struct _DRIVER_OBJECT;
 1889struct _DEVICE_OBJECT;
 1890struct _DRIVER_OBJECT;
 1891struct _FILE_OBJECT;
 1892struct _IRP;
 1893struct _SCSI_REQUEST_BLOCK;
 1894#pragma pack(push,4)
 1895#pragma pack(pop)
 1896#pragma pack(push,8)
 1897#pragma pack(pop)
 1898struct _KAPC;
 1899struct _KDPC;
 1900#pragma pack(push,4)
 1901#pragma pack(pop)
 1902#pragma pack(push,4)
 1903#pragma pack(pop)
 1904#pragma pack(push,1)
 1905#pragma pack(pop)
 1906struct _DRIVER_OBJECT;
 1907struct _DEVICE_OBJECT;
 1908struct _DRIVER_OBJECT;
 1909struct _FILE_OBJECT;
 1910struct _IRP;
 1911struct _SCSI_REQUEST_BLOCK;
 1912#pragma pack(push,4)
 1913#pragma pack(pop)
 1914#pragma pack(push,8)
 1915#pragma pack(pop)
 1916struct _KAPC;
 1917struct _KDPC;
 1918#pragma pack(push,4)
 1919#pragma pack(pop)
 1920#pragma pack(push,4)
 1921#pragma pack(pop)
 1922#pragma pack(push,1)
 1923#pragma pack(pop)
 1924struct _DRIVER_OBJECT;
 1925struct _DEVICE_OBJECT;
 1926struct _DRIVER_OBJECT;
 1927struct _FILE_OBJECT;
 1928struct _IRP;
 1929struct _SCSI_REQUEST_BLOCK;
 1930#pragma pack(push,4)
 1931#pragma pack(pop)
 1932#pragma once
 1933#pragma once
 1934#pragma once
 1935#pragma once
 1936#pragma warning(push)
 1937#pragma warning(disable:4035)
 1938#pragma warning(pop)
 1939#pragma once
 1940extern void *malloc(unsigned long sz ) ;
 1941extern void *memcpy(void * , void const   * , size_t  ) ;
 1942extern void *memset(void * , int  , size_t  ) ;
 1943extern void *memmove(void * , void const   * , size_t  ) ;
 1944#pragma warning(disable:4103)
 1945#pragma warning(disable:4103)
 1946  NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo ,
 1947                                                                                                PCWSTR Path ,
 1948                                                                                                PRTL_QUERY_REGISTRY_TABLE QueryTable ,
 1949                                                                                                PVOID Context ,
 1950                                                                                                PVOID Environment ) ;
 1951  NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo ,
 1952                                                                                                PCWSTR Path ,
 1953                                                                                                PCWSTR ValueName ) ;
 1954extern   NTSTATUS RtlIntegerToUnicodeString(ULONG Value ,
 1955                                                                                                          ULONG Base ,
 1956                                                                                                          PUNICODE_STRING String ) ;
 1957extern   NTSTATUS RtlUnicodeStringToInteger(PUNICODE_STRING String ,
 1958                                                                                                          ULONG Base ,
 1959                                                                                                          PULONG Value ) ;
 1960  void RtlInitString(PSTRING DestinationString ,
 1961                                                                                   PCSZ SourceString ) ;
 1962  void RtlInitUnicodeString(PUNICODE_STRING DestinationString ,
 1963                                                                                          PCWSTR SourceString ) ;
 1964  NTSTATUS RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString ,
 1965                                                                                                      PANSI_STRING SourceString ,
 1966                                                                                                      BOOLEAN AllocateDestinationString ) ;
 1967extern   LONG RtlCompareUnicodeString(PUNICODE_STRING String1 ,
 1968                                                                                                    PUNICODE_STRING String2 ,
 1969                                                                                                    BOOLEAN CaseInSensitive ) ;
 1970  void RtlCopyUnicodeString(PUNICODE_STRING DestinationString ,
 1971                                                                                          PUNICODE_STRING SourceString ) ;
 1972extern   NTSTATUS RtlAppendUnicodeStringToString(PUNICODE_STRING Destination ,
 1973                                                                                                               PUNICODE_STRING Source ) ;
 1974  void RtlFreeUnicodeString(PUNICODE_STRING UnicodeString ) ;
 1975  SIZE_T RtlCompareMemory(void const   *Source1 ,
 1976                                                                                        void const   *Source2 ,
 1977                                                                                        SIZE_T Length ) ;
 1978#pragma warning(push)
 1979#pragma warning(disable:4035)
 1980#pragma warning(pop)
 1981extern   UCHAR READ_PORT_UCHAR(PUCHAR Port ) ;
 1982extern   void WRITE_PORT_UCHAR(PUCHAR Port , UCHAR Value ) ;
 1983extern   LONG InterlockedIncrement(PLONG Addend ) ;
 1984extern   LONG InterlockedDecrement(PLONG Addend ) ;
 1985extern   LONG InterlockedExchange(PLONG Target ,
 1986                                                                                                 LONG Value ) ;
 1987#pragma warning(disable:4035)
 1988#pragma warning(push)
 1989#pragma warning(disable:4164)
 1990#pragma function(_enable)
 1991#pragma function(_disable)
 1992#pragma warning(pop)
 1993#pragma warning(disable:4103)
 1994#pragma warning(disable:4103)
 1995#pragma warning(disable:4103)
 1996#pragma warning(disable:4103)
 1997extern   void KeInitializeDpc(PRKDPC Dpc , void (*DeferredRoutine)(struct _KDPC *Dpc ,
 1998                                                                                                 PVOID DeferredContext ,
 1999                                                                                                 PVOID SystemArgument1 ,
 2000                                                                                                 PVOID SystemArgument2 ) ,
 2001                                                            PVOID DeferredContext ) ;
 2002extern   BOOLEAN KeInsertQueueDpc(PRKDPC Dpc , PVOID SystemArgument1 ,
 2003                                                                PVOID SystemArgument2 ) ;
 2004extern   BOOLEAN KeSynchronizeExecution(PKINTERRUPT Interrupt ,
 2005                                                                      BOOLEAN (*SynchronizeRoutine)(PVOID SynchronizeContext ) ,
 2006                                                                      PVOID SynchronizeContext ) ;
 2007  void KeInitializeEvent(PRKEVENT Event , EVENT_TYPE Type ,
 2008                                                       BOOLEAN State ) ;
 2009  LONG KeSetEvent(PRKEVENT Event , KPRIORITY Increment ,
 2010                                                BOOLEAN Wait ) ;
 2011  void KeInitializeSemaphore(PRKSEMAPHORE Semaphore ,
 2012                                                           LONG Count , LONG Limit ) ;
 2013  LONG KeReleaseSemaphore(PRKSEMAPHORE Semaphore , KPRIORITY Increment ,
 2014                                                        LONG Adjustment , BOOLEAN Wait ) ;
 2015  NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode ,
 2016                                                                BOOLEAN Alertable ,
 2017                                                                PLARGE_INTEGER Interval ) ;
 2018  NTSTATUS KeWaitForSingleObject(PVOID Object , KWAIT_REASON WaitReason ,
 2019                                                               KPROCESSOR_MODE WaitMode ,
 2020                                                               BOOLEAN Alertable ,
 2021                                                               PLARGE_INTEGER Timeout ) ;
 2022  void KeInitializeSpinLock(PKSPIN_LOCK SpinLock ) ;
 2023  void KfReleaseSpinLock(PKSPIN_LOCK SpinLock ,
 2024                                                                                        KIRQL NewIrql ) ;
 2025extern   ULONG KeQueryTimeIncrement(void) ;
 2026  PVOID ExAllocatePoolWithTag(POOL_TYPE PoolType ,
 2027                                                                                            SIZE_T NumberOfBytes ,
 2028                                                                                            ULONG Tag ) ;
 2029  void ExFreePool(PVOID P ) ;
 2030  void ExAcquireFastMutex(PFAST_MUTEX FastMutex ) ;
 2031  void ExReleaseFastMutex(PFAST_MUTEX FastMutex ) ;
 2032  PLIST_ENTRY ExfInterlockedInsertHeadList(PLIST_ENTRY ListHead ,
 2033                                                                                                          PLIST_ENTRY ListEntry ,
 2034                                                                                                          PKSPIN_LOCK Lock ) ;
 2035  PLIST_ENTRY ExfInterlockedInsertTailList(PLIST_ENTRY ListHead ,
 2036                                                                                                          PLIST_ENTRY ListEntry ,
 2037                                                                                                          PKSPIN_LOCK Lock ) ;
 2038  PLIST_ENTRY ExfInterlockedRemoveHeadList(PLIST_ENTRY ListHead ,
 2039                                                                                                          PKSPIN_LOCK Lock ) ;
 2040  void MmUnlockPages(PMDL MemoryDescriptorList ) ;
 2041  PVOID MmMapLockedPagesSpecifyCache(PMDL MemoryDescriptorList ,
 2042                                                                   KPROCESSOR_MODE AccessMode ,
 2043                                                                   MEMORY_CACHING_TYPE CacheType ,
 2044                                                                   PVOID BaseAddress ,
 2045                                                                   ULONG BugCheckOnFailure ,
 2046                                                                   MM_PAGE_PRIORITY Priority ) ;
 2047  PVOID MmAllocateContiguousMemory(SIZE_T NumberOfBytes ,
 2048                                                                 PHYSICAL_ADDRESS HighestAcceptableAddress ) ;
 2049  void MmFreeContiguousMemory(PVOID BaseAddress ) ;
 2050  void MmResetDriverPaging(PVOID AddressWithinSection ) ;
 2051  PVOID MmPageEntireDriver(PVOID AddressWithinSection ) ;
 2052  NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle ,
 2053                                                              ULONG DesiredAccess ,
 2054                                                              POBJECT_ATTRIBUTES ObjectAttributes ,
 2055                                                              HANDLE ProcessHandle ,
 2056                                                              PCLIENT_ID ClientId ,
 2057                                                              void (*StartRoutine)(PVOID StartContext ) ,
 2058                                                              PVOID StartContext ) ;
 2059  NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus ) ;
 2060#pragma warning(disable:4103)
 2061#pragma warning(disable:4103)
 2062extern   void IoAcquireCancelSpinLock(PKIRQL Irql ) ;
 2063extern   PVOID IoAllocateErrorLogEntry(PVOID IoObject ,
 2064                                                                     UCHAR EntrySize ) ;
 2065  PMDL IoAllocateMdl(PVOID VirtualAddress , ULONG Length ,
 2066                                                   BOOLEAN SecondaryBuffer , BOOLEAN ChargeQuota ,
 2067                                                   PIRP Irp ) ;
 2068  PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice ,
 2069                                                                           PDEVICE_OBJECT TargetDevice ) ;
 2070  PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction ,
 2071                                                                   PDEVICE_OBJECT DeviceObject ,
 2072                                                                   PVOID Buffer ,
 2073                                                                   ULONG Length ,
 2074                                                                   PLARGE_INTEGER StartingOffset ,
 2075                                                                   PIO_STATUS_BLOCK IoStatusBlock ) ;
 2076  PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode ,
 2077                                                                   PDEVICE_OBJECT DeviceObject ,
 2078                                                                   PVOID InputBuffer ,
 2079                                                                   ULONG InputBufferLength ,
 2080                                                                   PVOID OutputBuffer ,
 2081                                                                   ULONG OutputBufferLength ,
 2082                                                                   BOOLEAN InternalDeviceIoControl ,
 2083                                                                   PKEVENT Event ,
 2084                                                                   PIO_STATUS_BLOCK IoStatusBlock ) ;
 2085  NTSTATUS IofCallDriver(PDEVICE_OBJECT DeviceObject ,
 2086                                                                                        PIRP Irp ) ;
 2087  void IofCompleteRequest(PIRP Irp ,
 2088                                                                                         CCHAR PriorityBoost ) ;
 2089extern   NTSTATUS IoConnectInterrupt(PKINTERRUPT *InterruptObject ,
 2090                                                                   BOOLEAN (*ServiceRoutine)(struct _KINTERRUPT *Interrupt ,
 2091                                                                                             PVOID ServiceContext ) ,
 2092                                                                   PVOID ServiceContext ,
 2093                                                                   PKSPIN_LOCK SpinLock ,
 2094                                                                   ULONG Vector ,
 2095                                                                   KIRQL Irql , KIRQL SynchronizeIrql ,
 2096                                                                   KINTERRUPT_MODE InterruptMode ,
 2097                                                                   BOOLEAN ShareVector ,
 2098                                                                   KAFFINITY ProcessorEnableMask ,
 2099                                                                   BOOLEAN FloatingSave ) ;
 2100  NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject ,
 2101                                                        ULONG DeviceExtensionSize ,
 2102                                                        PUNICODE_STRING DeviceName ,
 2103                                                        ULONG DeviceType , ULONG DeviceCharacteristics ,
 2104                                                        BOOLEAN Exclusive , PDEVICE_OBJECT *DeviceObject ) ;
 2105  NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName ,
 2106                                                              PUNICODE_STRING DeviceName ) ;
 2107  void IoDeleteDevice(PDEVICE_OBJECT DeviceObject ) ;
 2108  NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName ) ;
 2109  void IoDetachDevice(PDEVICE_OBJECT TargetDevice ) ;
 2110extern   void IoDisconnectInterrupt(PKINTERRUPT InterruptObject ) ;
 2111  void IoFreeIrp(PIRP Irp ) ;
 2112  void IoFreeMdl(PMDL Mdl ) ;
 2113  PCONFIGURATION_INFORMATION IoGetConfigurationInformation(void) ;
 2114  NTSTATUS IoQueryDeviceDescription(PINTERFACE_TYPE BusType ,
 2115                                                                  PULONG BusNumber ,
 2116                                                                  PCONFIGURATION_TYPE ControllerType ,
 2117                                                                  PULONG ControllerNumber ,
 2118                                                                  PCONFIGURATION_TYPE PeripheralType ,
 2119                                                                  PULONG PeripheralNumber ,
 2120                                                                  NTSTATUS (*CalloutRoutine)(PVOID Context ,
 2121                                                                                             PUNICODE_STRING PathName ,
 2122                                                                                             INTERFACE_TYPE BusType ,
 2123                                                                                             ULONG BusNumber ,
 2124                                                                                             PKEY_VALUE_FULL_INFORMATION *BusInformation ,
 2125                                                                                             CONFIGURATION_TYPE ControllerType ,
 2126                                                                                             ULONG ControllerNumber ,
 2127                                                                                             PKEY_VALUE_FULL_INFORMATION *ControllerInformation ,
 2128                                                                                             CONFIGURATION_TYPE PeripheralType ,
 2129                                                                                             ULONG PeripheralNumber ,
 2130                                                                                             PKEY_VALUE_FULL_INFORMATION *PeripheralInformation ) ,
 2131                                                                  PVOID Context ) ;
 2132  void IoReleaseCancelSpinLock(KIRQL Irql ) ;
 2133extern   NTSTATUS IoReportResourceUsage(PUNICODE_STRING DriverClassName ,
 2134                                                                      PDRIVER_OBJECT DriverObject ,
 2135                                                                      PCM_RESOURCE_LIST DriverList ,
 2136                                                                      ULONG DriverListSize ,
 2137                                                                      PDEVICE_OBJECT DeviceObject ,
 2138                                                                      PCM_RESOURCE_LIST DeviceList ,
 2139                                                                      ULONG DeviceListSize ,
 2140                                                                      BOOLEAN OverrideConflict ,
 2141                                                                      PBOOLEAN ConflictDetected ) ;
 2142  void IoSetHardErrorOrVerifyDevice(PIRP Irp , PDEVICE_OBJECT DeviceObject ) ;
 2143extern   void IoInitializeRemoveLockEx(PIO_REMOVE_LOCK Lock ,
 2144                                                                                                     ULONG AllocateTag ,
 2145                                                                                                     ULONG MaxLockedMinutes ,
 2146                                                                                                     ULONG HighWatermark ,
 2147                                                                                                     ULONG RemlockSize ) ;
 2148  NTSTATUS IoAcquireRemoveLockEx(PIO_REMOVE_LOCK RemoveLock ,
 2149                                                                                               PVOID Tag ,
 2150                                                                                               PCSTR File ,
 2151                                                                                               ULONG Line ,
 2152                                                                                               ULONG RemlockSize ) ;
 2153extern   void IoReleaseRemoveLockEx(PIO_REMOVE_LOCK RemoveLock ,
 2154                                                                                                  PVOID Tag ,
 2155                                                                                                  ULONG RemlockSize ) ;
 2156extern   void IoReleaseRemoveLockAndWaitEx(PIO_REMOVE_LOCK RemoveLock ,
 2157                                                                                                         PVOID Tag ,
 2158                                                                                                         ULONG RemlockSize ) ;
 2159extern   void IoWriteErrorLogEntry(PVOID ElEntry ) ;
 2160extern   NTSTATUS IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject ,
 2161                                                                         ULONG Action ) ;
 2162extern   NTSTATUS IoOpenDeviceRegistryKey(PDEVICE_OBJECT DeviceObject ,
 2163                                                                        ULONG DevInstKeyType ,
 2164                                                                        ACCESS_MASK DesiredAccess ,
 2165                                                                        PHANDLE DevInstRegKey ) ;
 2166  NTSTATUS IoRegisterDeviceInterface(PDEVICE_OBJECT PhysicalDeviceObject ,
 2167                                                                                                   GUID const   *InterfaceClassGuid ,
 2168                                                                                                   PUNICODE_STRING ReferenceString ,
 2169                                                                                                   PUNICODE_STRING SymbolicLinkName ) ;
 2170  NTSTATUS IoSetDeviceInterfaceState(PUNICODE_STRING SymbolicLinkName ,
 2171                                                                   BOOLEAN Enable ) ;
 2172extern   void KeStallExecutionProcessor(ULONG MicroSeconds ) ;
 2173#pragma warning(disable:4200)
 2174#pragma warning(default:4200)
 2175extern   NTSTATUS PoRequestPowerIrp(PDEVICE_OBJECT DeviceObject ,
 2176                                                                  UCHAR MinorFunction ,
 2177                                                                  POWER_STATE PowerState ,
 2178                                                                  void (*CompletionFunction)(PDEVICE_OBJECT DeviceObject ,
 2179                                                                                             UCHAR MinorFunction ,
 2180                                                                                             POWER_STATE PowerState ,
 2181                                                                                             PVOID Context ,
 2182                                                                                             PIO_STATUS_BLOCK IoStatus ) ,
 2183                                                                  PVOID Context ,
 2184                                                                  PIRP *Irp ) ;
 2185extern   POWER_STATE PoSetPowerState(PDEVICE_OBJECT DeviceObject ,
 2186                                                                   POWER_STATE_TYPE Type ,
 2187                                                                   POWER_STATE State ) ;
 2188  NTSTATUS PoCallDriver(PDEVICE_OBJECT DeviceObject ,
 2189                                                      PIRP Irp ) ;
 2190  void PoStartNextPowerIrp(PIRP Irp ) ;
 2191  NTSTATUS ObReferenceObjectByHandle(HANDLE Handle ,
 2192                                                                   ACCESS_MASK DesiredAccess ,
 2193                                                                   POBJECT_TYPE ObjectType ,
 2194                                                                   KPROCESSOR_MODE AccessMode ,
 2195                                                                   PVOID *Object ,
 2196                                                                   POBJECT_HANDLE_INFORMATION HandleInformation ) ;
 2197extern   void ObfReferenceObject(PVOID Object ) ;
 2198  void ObfDereferenceObject(PVOID Object ) ;
 2199  NTSTATUS ZwClose(HANDLE Handle ) ;
 2200extern   NTSTATUS ZwQueryValueKey(HANDLE KeyHandle ,
 2201                                                                                                PUNICODE_STRING ValueName ,
 2202                                                                                                KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass ,
 2203                                                                                                PVOID KeyValueInformation ,
 2204                                                                                                ULONG Length ,
 2205                                                                                                PULONG ResultLength ) ;
 2206extern   NTSTATUS ZwSetValueKey(HANDLE KeyHandle ,
 2207                                                                                              PUNICODE_STRING ValueName ,
 2208                                                                                              ULONG TitleIndex ,
 2209                                                                                              ULONG Type ,
 2210                                                                                              PVOID Data ,
 2211                                                                                              ULONG DataSize ) ;
 2212  struct _GUID  const  GUID_PARALLEL_DEVICE ;
 2213  struct _GUID  const  GUID_PARCLASS_DEVICE ;
 2214#pragma once
 2215extern NTSTATUS WmiCompleteRequest(PDEVICE_OBJECT DeviceObject , PIRP Irp , NTSTATUS Status ,
 2216                                   ULONG BufferUsed , CCHAR PriorityBoost ) ;
 2217NTSTATUS WmiSystemControl(PWMILIB_CONTEXT WmiLibInfo , PDEVICE_OBJECT DeviceObject ,
 2218                          PIRP Irp , PSYSCTL_IRP_DISPOSITION IrpDisposition ) ;
 2219void PptCompleteRequest(PIRP Irp , CCHAR PriorityBoost ) ;
 2220ULONG PptDebugLevel ;
 2221ULONG PptBreakOn ;
 2222UNICODE_STRING RegistryPath ;
 2223UCHAR PptDot3Retries ;
 2224union _LARGE_INTEGER  const  PhysicalZero ;
 2225LONG PortInfoReferenceCount ;
 2226PFAST_MUTEX PortInfoMutex ;
 2227int s ;
 2228int UNLOADED  ;
 2229int NP  ;
 2230int DC  ;
 2231int SKIP1  ;
 2232int SKIP2  ;
 2233int MPR1  ;
 2234int MPR3  ;
 2235int IPC  ;
 2236int pended  ;
 2237NTSTATUS (*compFptr)(PDEVICE_OBJECT DeviceObject , PIRP Irp , PVOID Context )  ;
 2238int compRegistered  ;
 2239int lowerDriverReturn  ;
 2240int setEventCalled  ;
 2241int customIrp  ;
 2242int myStatus  ;
 2243int routine  ;
 2244void errorFn(void) 
 2245{ 
 2246
 2247  {
 2248  ERROR: 
 2249  goto ERROR;
 2250}
 2251}
 2252NTSTATUS PptWmiInitWmi(PDEVICE_OBJECT DeviceObject ) ;
 2253NTSTATUS PptDispatchSystemControl(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2254void PptPnpInitDispatchFunctionTable(void) ;
 2255NTSTATUS PptPnpAddDevice(PDRIVER_OBJECT pDriverObject , PDEVICE_OBJECT pPhysicalDeviceObject ) ;
 2256NTSTATUS PptDispatchPnp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2257NTSTATUS PptFailRequest(PIRP Irp , NTSTATUS Status ) ;
 2258NTSTATUS PptDispatchPreProcessIrp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2259NTSTATUS PptDispatchPostProcessIrp(void) ;
 2260NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject , PUNICODE_STRING pRegistryPath ) ;
 2261void PptUnload(PDRIVER_OBJECT DriverObject ) ;
 2262NTSTATUS PptSynchCompletionRoutine(PDEVICE_OBJECT DeviceObject , PIRP Irp , PKEVENT Event ) ;
 2263void PptLogError(PDRIVER_OBJECT DriverObject , PDEVICE_OBJECT DeviceObject , PHYSICAL_ADDRESS P1 ,
 2264                 PHYSICAL_ADDRESS P2 , ULONG SequenceNumber , UCHAR MajorFunctionCode ,
 2265                 UCHAR RetryCount , ULONG UniqueErrorValue , NTSTATUS FinalStatus ,
 2266                 NTSTATUS SpecificIOStatus ) ;
 2267NTSTATUS PptConnectInterrupt(PDEVICE_EXTENSION Extension ) ;
 2268void PptDisconnectInterrupt(PDEVICE_EXTENSION Extension ) ;
 2269NTSTATUS PptDispatchCreate(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2270NTSTATUS PptDispatchClose(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2271BOOLEAN PptSynchronizedIncrement(PVOID SyncContext ) ;
 2272BOOLEAN PptSynchronizedDecrement(PVOID SyncContext ) ;
 2273BOOLEAN PptSynchronizedRead(PVOID SyncContext ) ;
 2274BOOLEAN PptSynchronizedQueue(PVOID Context ) ;
 2275BOOLEAN PptSynchronizedDisconnect(PVOID Context ) ;
 2276void PptCancelRoutine(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2277void PptFreePortDpc(PKDPC Dpc , PVOID Extension , PVOID SystemArgument1 , PVOID SystemArgument2 ) ;
 2278BOOLEAN PptTryAllocatePortAtInterruptLevel(PVOID Context ) ;
 2279void PptFreePortFromInterruptLevel(PVOID Context ) ;
 2280BOOLEAN PptInterruptService(PKINTERRUPT Interrupt , PVOID Extension ) ;
 2281BOOLEAN PptTryAllocatePort(PVOID Extension ) ;
 2282BOOLEAN PptTraversePortCheckList(PVOID Extension ) ;
 2283void PptFreePort(PVOID Extension ) ;
 2284ULONG PptQueryNumWaiters(PVOID Extension ) ;
 2285NTSTATUS PptDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2286NTSTATUS PptDispatchCleanup(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2287BOOLEAN PptIsNecR98Machine(void) ;
 2288NTSTATUS PptDispatchPower(PDEVICE_OBJECT pDeviceObject , PIRP pIrp ) ;
 2289void PptRegInitDriverSettings(PUNICODE_STRING RegistryPath___0 ) ;
 2290PWSTR PptGetPortNameFromPhysicalDeviceObject(PDEVICE_OBJECT PhysicalDeviceObject ) ;
 2291PVOID PptSetCancelRoutine(PIRP Irp , void (*CancelRoutine)(struct _DEVICE_OBJECT *DeviceObject ,
 2292                                                           struct _IRP *Irp ) ) ;
 2293NTSTATUS PptAcquireRemoveLockOrFailIrp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2294void PptDebugDumpPnpIrpInfo(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 2295NTSTATUS PptAcquireRemoveLock(PIO_REMOVE_LOCK RemoveLock , PVOID Tag ) ;
 2296void PptReleaseRemoveLock(PIO_REMOVE_LOCK RemoveLock , PVOID Tag ) ;
 2297void PptReleaseRemoveLockAndWait(PIO_REMOVE_LOCK RemoveLock , PVOID Tag ) ;
 2298void PptDebugDumpResourceList(PIO_RESOURCE_LIST ResourceList ) ;
 2299void PptDebugDumpResourceRequirementsList(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) ;
 2300NTSTATUS PptDetectChipFilter(PDEVICE_EXTENSION Extension ) ;
 2301NTSTATUS PptDetectPortType(PDEVICE_EXTENSION Extension ) ;
 2302NTSTATUS PptSetChipMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) ;
 2303NTSTATUS PptClearChipMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) ;
 2304ULONG PptInitiate1284_3(PVOID Extension ) ;
 2305NTSTATUS PptTrySelectDevice(PVOID Context , PVOID TrySelectCommand ) ;
 2306NTSTATUS PptDeselectDevice(PVOID Context , PVOID DeselectCommand ) ;
 2307ULONG Ppt1284_3AssignAddress(PDEVICE_EXTENSION DeviceExtension ) ;
 2308BOOLEAN PptSend1284_3Command(PDEVICE_EXTENSION DeviceExtension , UCHAR Command ) ;
 2309NTSTATUS PptTrySelectLegacyZip(PVOID Context , PVOID TrySelectCommand ) ;
 2310NTSTATUS PptDeselectLegacyZip(PVOID Context , PVOID DeselectCommand ) ;
 2311void PptDumpRemovalRelationsList(PDEVICE_EXTENSION Extension ) ;
 2312NTSTATUS PptRegGetDeviceParameterDword(PDEVICE_OBJECT Pdo , PWSTR ParameterName ,
 2313                                       PULONG ParameterValue ) ;
 2314NTSTATUS PptRegSetDeviceParameterDword(PDEVICE_OBJECT Pdo , PWSTR ParameterName ,
 2315                                       PULONG ParameterValue ) ;
 2316NTSTATUS PptBuildParallelPortDeviceName(ULONG Number , PUNICODE_STRING DeviceName ) ;
 2317NTSTATUS PptInitializeDeviceExtension(PDRIVER_OBJECT DriverObject , PDEVICE_OBJECT PhysicalDeviceObject ,
 2318                                      PDEVICE_OBJECT DeviceObject , PUNICODE_STRING UniNameString ,
 2319                                      PWSTR PortName , ULONG PortNumber ) ;
 2320NTSTATUS PptGetPortNumberFromLptName(PWSTR PortName , PULONG PortNumber ) ;
 2321PDEVICE_OBJECT PptBuildDeviceObject(PDRIVER_OBJECT DriverObject , PDEVICE_OBJECT PhysicalDeviceObject ) ;
 2322void PptDetectEppPort(PDEVICE_EXTENSION Extension ) ;
 2323void PptCleanRemovalRelationsList(PDEVICE_EXTENSION Extension ) ;
 2324BOOLEAN CheckPort(PUCHAR wPortAddr , UCHAR bMask , UCHAR bValue , USHORT usTimeDelay ) ;
 2325NTSTATUS PptDispatchCleanup(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 2326{ PDEVICE_EXTENSION extension ;
 2327  KIRQL cancelIrql ;
 2328
 2329  {
 2330  extension = DeviceObject->DeviceExtension;
 2331  {
 2332  }
 2333  if (extension->DeviceStateFlags & 4096UL) {
 2334    goto targetExit;
 2335  } else {
 2336
 2337  }
 2338  {
 2339  IoAcquireCancelSpinLock(& cancelIrql);
 2340/*   IoReleaseCancelSpinLock(cancelIrql); */ /* INLINED */
 2341  }
 2342  targetExit: 
 2343  {
 2344  myStatus = 0L;
 2345  Irp->IoStatus.__annonCompField4.Status = 0L;
 2346  Irp->IoStatus.Information = 0;
 2347  PptCompleteRequest(Irp, 0);
 2348  }
 2349  return (0L);
 2350}
 2351}
 2352#pragma once
 2353#pragma once
 2354#pragma once
 2355#pragma once
 2356#pragma warning(push)
 2357#pragma warning(disable:4035)
 2358#pragma warning(pop)
 2359#pragma once
 2360#pragma warning(disable:4103)
 2361#pragma warning(disable:4103)
 2362#pragma warning(push)
 2363#pragma warning(disable:4035)
 2364#pragma warning(pop)
 2365#pragma warning(disable:4035)
 2366#pragma warning(push)
 2367#pragma warning(disable:4164)
 2368#pragma function(_enable)
 2369#pragma function(_disable)
 2370#pragma warning(pop)
 2371#pragma warning(disable:4103)
 2372#pragma warning(disable:4103)
 2373#pragma warning(disable:4103)
 2374#pragma warning(disable:4103)
 2375#pragma warning(disable:4103)
 2376#pragma warning(disable:4103)
 2377#pragma warning(disable:4200)
 2378#pragma warning(default:4200)
 2379#pragma once
 2380PCHAR PnpIrpName[25]  = 
 2381  {      "IRP_MN_START_DEVICE                 0x00",      "IRP_MN_QUERY_REMOVE_DEVICE          0x01",      "IRP_MN_REMOVE_DEVICE                0x02",      "IRP_MN_CANCEL_REMOVE_DEVICE         0x03", 
 2382        "IRP_MN_STOP_DEVICE                  0x04",      "IRP_MN_QUERY_STOP_DEVICE            0x05",      "IRP_MN_CANCEL_STOP_DEVICE           0x06",      "IRP_MN_QUERY_DEVICE_RELATIONS       0x07", 
 2383        "IRP_MN_QUERY_INTERFACE              0x08",      "IRP_MN_QUERY_CAPABILITIES           0x09",      "IRP_MN_QUERY_RESOURCES              0x0A",      "IRP_MN_QUERY_RESOURCE_REQUIREMENTS  0x0B", 
 2384        "IRP_MN_QUERY_DEVICE_TEXT            0x0C",      "IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D",      " unused MinorFunction               0x0E",      "IRP_MN_READ_CONFIG                  0x0F", 
 2385        "IRP_MN_WRITE_CONFIG                 0x10",      "IRP_MN_EJECT                        0x11",      "IRP_MN_SET_LOCK                     0x12",      "IRP_MN_QUERY_ID                     0x13", 
 2386        "IRP_MN_QUERY_PNP_DEVICE_STATE       0x14",      "IRP_MN_QUERY_BUS_INFORMATION        0x15",      "IRP_MN_DEVICE_USAGE_NOTIFICATION    0x16",      "IRP_MN_SURPRISE_REMOVAL             0x17", 
 2387        "IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18"};
 2388void PptDebugDumpPnpIrpInfo(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 2389{ PDEVICE_EXTENSION extension ;
 2390  PIO_STACK_LOCATION irpStack ;
 2391  PCHAR irpName ;
 2392
 2393  {
 2394  extension = DeviceObject->DeviceExtension;
 2395  irpStack = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 2396  if ((int )irpStack->MinorFunction <= 24) {
 2397    irpName = PnpIrpName[irpStack->MinorFunction];
 2398  } else {
 2399    {
 2400    }
 2401    irpName = " - MinorFunction > 0x18 - don\'t handle  ";
 2402  }
 2403  {
 2404  }
 2405  return;
 2406}
 2407}
 2408NTSTATUS PptAcquireRemoveLock(PIO_REMOVE_LOCK RemoveLock , PVOID Tag ) 
 2409{ NTSTATUS status ;
 2410
 2411  {
 2412  {
 2413  status = IoAcquireRemoveLockEx(RemoveLock, Tag, "debug.c", 69, sizeof(IO_REMOVE_LOCK ));
 2414  }
 2415  return (status);
 2416}
 2417}
 2418void PptReleaseRemoveLock(PIO_REMOVE_LOCK RemoveLock , PVOID Tag ) 
 2419{ 
 2420
 2421  {
 2422  {
 2423  IoReleaseRemoveLockEx(RemoveLock, Tag, sizeof(IO_REMOVE_LOCK ));
 2424  }
 2425  return;
 2426}
 2427}
 2428void PptReleaseRemoveLockAndWait(PIO_REMOVE_LOCK RemoveLock , PVOID Tag ) 
 2429{ 
 2430
 2431  {
 2432  {
 2433  IoReleaseRemoveLockAndWaitEx(RemoveLock, Tag, sizeof(IO_REMOVE_LOCK ));
 2434  }
 2435  return;
 2436}
 2437}
 2438void PptDebugDumpResourceList(PIO_RESOURCE_LIST ResourceList ) 
 2439{ ULONG count ;
 2440  ULONG i ;
 2441  PIO_RESOURCE_DESCRIPTOR curDesc ;
 2442
 2443  {
 2444  count = ResourceList->Count;
 2445  {
 2446  }
 2447  i = 0;
 2448  curDesc = ResourceList->Descriptors;
 2449  {
 2450  while (1) {
 2451    while_4_continue: /* CIL Label */ ;
 2452    if (i < count) {
 2453
 2454    } else {
 2455      goto while_4_break;
 2456    }
 2457    if (curDesc->Type == 2) {
 2458      goto switch_5_2;
 2459    } else {
 2460      if (curDesc->Type == 4) {
 2461        goto switch_5_4;
 2462      } else {
 2463        if (curDesc->Type == 1) {
 2464          goto switch_5_1;
 2465        } else {
 2466          if (curDesc->Type == 0) {
 2467            goto switch_5_0;
 2468          } else {
 2469            {
 2470            goto switch_5_default;
 2471            if (0) {
 2472              switch_5_2: /* CIL Label */ ;
 2473              {
 2474              }
 2475              goto switch_5_break;
 2476              switch_5_4: /* CIL Label */ ;
 2477              {
 2478              }
 2479              goto switch_5_break;
 2480              switch_5_1: /* CIL Label */ ;
 2481              {
 2482              }
 2483              goto switch_5_break;
 2484              switch_5_0: /* CIL Label */ ;
 2485              {
 2486              }
 2487              goto switch_5_break;
 2488              switch_5_default: /* CIL Label */ ;
 2489              {
 2490              }
 2491            } else {
 2492              switch_5_break: /* CIL Label */ ;
 2493            }
 2494            }
 2495          }
 2496        }
 2497      }
 2498    }
 2499    i += 1UL;
 2500    curDesc += 1;
 2501  }
 2502  while_4_break: /* CIL Label */ ;
 2503  }
 2504  return;
 2505}
 2506}
 2507void PptDebugDumpResourceRequirementsList(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) 
 2508{ ULONG listCount ;
 2509  PIO_RESOURCE_LIST curList ;
 2510  ULONG i ;
 2511
 2512  {
 2513  listCount = ResourceRequirementsList->AlternativeLists;
 2514  {
 2515  }
 2516  i = 0;
 2517  curList = ResourceRequirementsList->List;
 2518  {
 2519  while (1) {
 2520    while_12_continue: /* CIL Label */ ;
 2521    if (i < listCount) {
 2522
 2523    } else {
 2524      goto while_12_break;
 2525    }
 2526    {
 2527    }
 2528    {
 2529    PptDebugDumpResourceList(curList);
 2530    curList = (struct _IO_RESOURCE_LIST *)(curList->Descriptors + curList->Count);
 2531    i += 1UL;
 2532    }
 2533  }
 2534  while_12_break: /* CIL Label */ ;
 2535  }
 2536  return;
 2537}
 2538}
 2539#pragma once
 2540#pragma once
 2541#pragma once
 2542#pragma once
 2543#pragma warning(push)
 2544#pragma warning(disable:4035)
 2545#pragma warning(pop)
 2546#pragma once
 2547#pragma warning(disable:4103)
 2548#pragma warning(disable:4103)
 2549#pragma warning(push)
 2550#pragma warning(disable:4035)
 2551#pragma warning(pop)
 2552#pragma warning(disable:4035)
 2553#pragma warning(push)
 2554#pragma warning(disable:4164)
 2555#pragma function(_enable)
 2556#pragma function(_disable)
 2557#pragma warning(pop)
 2558#pragma warning(disable:4103)
 2559#pragma warning(disable:4103)
 2560#pragma warning(disable:4103)
 2561#pragma warning(disable:4103)
 2562#pragma warning(disable:4103)
 2563#pragma warning(disable:4103)
 2564#pragma warning(disable:4200)
 2565#pragma warning(default:4200)
 2566#pragma once
 2567void PptLogError(PDRIVER_OBJECT DriverObject , PDEVICE_OBJECT DeviceObject , PHYSICAL_ADDRESS P1 ,
 2568                 PHYSICAL_ADDRESS P2 , ULONG SequenceNumber , UCHAR MajorFunctionCode ,
 2569                 UCHAR RetryCount , ULONG UniqueErrorValue , NTSTATUS FinalStatus ,
 2570                 NTSTATUS SpecificIOStatus ) 
 2571{ PIO_ERROR_LOG_PACKET ErrorLogEntry ;
 2572  PVOID ObjectToUse ;
 2573  SHORT DumpToAllocate ;
 2574  PVOID tmp ;
 2575
 2576  {
 2577  {
 2578  }
 2579  if ((unsigned int )((CHAR *)DeviceObject) != (unsigned int )((CHAR *)((void *)0))) {
 2580    ObjectToUse = DeviceObject;
 2581  } else {
 2582    ObjectToUse = DriverObject;
 2583  }
 2584  DumpToAllocate = 0;
 2585  if (P1.__annonCompField1.LowPart != 0UL) {
 2586    DumpToAllocate = (short )sizeof(PHYSICAL_ADDRESS );
 2587  } else {
 2588    if (P1.__annonCompField1.HighPart != 0L) {
 2589      DumpToAllocate = (short )sizeof(PHYSICAL_ADDRESS );
 2590    } else {
 2591
 2592    }
 2593  }
 2594  if (P2.__annonCompField1.LowPart != 0UL) {
 2595    DumpToAllocate = (int )DumpToAllocate + (int )((short )sizeof(PHYSICAL_ADDRESS ));
 2596  } else {
 2597    if (P2.__annonCompField1.HighPart != 0L) {
 2598      DumpToAllocate = (int )DumpToAllocate + (int )((short )sizeof(PHYSICAL_ADDRESS ));
 2599    } else {
 2600
 2601    }
 2602  }
 2603  {
 2604  tmp = IoAllocateErrorLogEntry(ObjectToUse, (unsigned char )(sizeof(IO_ERROR_LOG_PACKET ) + (unsigned int )DumpToAllocate));
 2605  ErrorLogEntry = tmp;
 2606  }
 2607  if (! ErrorLogEntry) {
 2608    return;
 2609  } else {
 2610
 2611  }
 2612  ErrorLogEntry->ErrorCode = SpecificIOStatus;
 2613  ErrorLogEntry->SequenceNumber = SequenceNumber;
 2614  ErrorLogEntry->MajorFunctionCode = MajorFunctionCode;
 2615  ErrorLogEntry->RetryCount = RetryCount;
 2616  ErrorLogEntry->UniqueErrorValue = UniqueErrorValue;
 2617  ErrorLogEntry->FinalStatus = FinalStatus;
 2618  ErrorLogEntry->DumpDataSize = DumpToAllocate;
 2619  if (DumpToAllocate) {
 2620    {
 2621    memcpy(ErrorLogEntry->DumpData, & P1, sizeof(PHYSICAL_ADDRESS ));
 2622    }
 2623    if ((unsigned int )DumpToAllocate > sizeof(PHYSICAL_ADDRESS )) {
 2624      {
 2625      memcpy((UCHAR *)(ErrorLogEntry->DumpData) + sizeof(PHYSICAL_ADDRESS ), & P2,
 2626             sizeof(PHYSICAL_ADDRESS ));
 2627      }
 2628    } else {
 2629
 2630    }
 2631  } else {
 2632
 2633  }
 2634  {
 2635  IoWriteErrorLogEntry(ErrorLogEntry);
 2636  }
 2637  return;
 2638}
 2639}
 2640#pragma once
 2641#pragma once
 2642#pragma once
 2643#pragma once
 2644#pragma warning(push)
 2645#pragma warning(disable:4035)
 2646#pragma warning(pop)
 2647#pragma once
 2648#pragma warning(disable:4103)
 2649#pragma warning(disable:4103)
 2650#pragma warning(push)
 2651#pragma warning(disable:4035)
 2652#pragma warning(pop)
 2653#pragma warning(disable:4035)
 2654#pragma warning(push)
 2655#pragma warning(disable:4164)
 2656#pragma function(_enable)
 2657#pragma function(_disable)
 2658#pragma warning(pop)
 2659#pragma warning(disable:4103)
 2660#pragma warning(disable:4103)
 2661#pragma warning(disable:4103)
 2662#pragma warning(disable:4103)
 2663#pragma warning(disable:4103)
 2664#pragma warning(disable:4103)
 2665#pragma warning(disable:4200)
 2666#pragma warning(default:4200)
 2667#pragma once
 2668NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject , PUNICODE_STRING pRegistryPath ) 
 2669{ void *Buffer ;
 2670
 2671  {
 2672  {
 2673  PptRegInitDriverSettings(pRegistryPath);
 2674  Buffer = ExAllocatePoolWithTag(1, pRegistryPath->MaximumLength, 1349673296UL);
 2675  }
 2676  if ((unsigned int )((void *)0) == (unsigned int )Buffer) {
 2677    {
 2678    }
 2679    return (-1073741670L);
 2680  } else {
 2681    {
 2682    memset(RegistryPath.Buffer, 0, pRegistryPath->MaximumLength);
 2683    RegistryPath.Length = pRegistryPath->Length;
 2684    RegistryPath.MaximumLength = pRegistryPath->MaximumLength;
 2685    memmove(RegistryPath.Buffer, pRegistryPath->Buffer, pRegistryPath->Length);
 2686    }
 2687  }
 2688  {
 2689  PptPnpInitDispatchFunctionTable();
 2690  DriverObject->MajorFunction[0] = & PptDispatchCreate;
 2691  DriverObject->MajorFunction[2] = & PptDispatchClose;
 2692  DriverObject->MajorFunction[15] = & PptDispatchInternalDeviceControl;
 2693  DriverObject->MajorFunction[18] = & PptDispatchCleanup;
 2694  DriverObject->MajorFunction[27] = & PptDispatchPnp;
 2695  DriverObject->MajorFunction[22] = & PptDispatchPower;
 2696  DriverObject->MajorFunction[23] = & PptDispatchSystemControl;
 2697  (DriverObject->DriverExtension)->AddDevice = & PptPnpAddDevice;
 2698  DriverObject->DriverUnload = & PptUnload;
 2699  }
 2700  return (0L);
 2701}
 2702}
 2703void PptUnload(PDRIVER_OBJECT DriverObject ) 
 2704{ PDEVICE_OBJECT CurrentDevice ;
 2705  PDEVICE_EXTENSION Extension ;
 2706  PLIST_ENTRY Head ;
 2707  PISR_LIST_ENTRY Entry ;
 2708  PLIST_ENTRY _EX_Blink ;
 2709  PLIST_ENTRY _EX_Flink ;
 2710  PCONFIGURATION_INFORMATION tmp ;
 2711
 2712  {
 2713  {
 2714  }
 2715  CurrentDevice = DriverObject->DeviceObject;
 2716  {
 2717  while (1) {
 2718    while_17_continue: /* CIL Label */ ;
 2719    if (CurrentDevice) {
 2720
 2721    } else {
 2722      goto while_17_break;
 2723    }
 2724    Extension = CurrentDevice->DeviceExtension;
 2725    if (Extension->InterruptRefCount) {
 2726      {
 2727      PptDisconnectInterrupt(Extension);
 2728      }
 2729    } else {
 2730
 2731    }
 2732    {
 2733    while (1) {
 2734      while_18_continue: /* CIL Label */ ;
 2735      if (! ((unsigned int )Extension->IsrList.Flink == (unsigned int )(& Extension->IsrList))) {
 2736
 2737      } else {
 2738        goto while_18_break;
 2739      }
 2740      {
 2741      Head = Extension->IsrList.Flink;
 2742      _EX_Flink = (Extension->IsrList.Flink)->Flink;
 2743      _EX_Blink = (Extension->IsrList.Flink)->Blink;
 2744      _EX_Blink->Flink = _EX_Flink;
 2745      _EX_Flink->Blink = _EX_Blink;
 2746      Entry = (ISR_LIST_ENTRY *)((CHAR *)Head - (unsigned long )(& ((ISR_LIST_ENTRY *)0)->ListEntry));
 2747/*       ExFreePool(Entry); */ /* INLINED */
 2748      }
 2749    }
 2750    while_18_break: /* CIL Label */ ;
 2751    }
 2752    {
 2753/*     ExFreePool(Extension->DeviceName.Buffer); */ /* INLINED */
 2754/*     IoDeleteDevice(CurrentDevice); */ /* INLINED */
 2755    tmp = IoGetConfigurationInformation();
 2756    tmp->ParallelCount -= 1UL;
 2757    CurrentDevice = DriverObject->DeviceObject;
 2758    }
 2759  }
 2760  while_17_break: /* CIL Label */ ;
 2761  }
 2762  if (PortInfoMutex) {
 2763    {
 2764/*     ExFreePool(PortInfoMutex); */ /* INLINED */
 2765    PortInfoMutex = (void *)0;
 2766    }
 2767  } else {
 2768
 2769  }
 2770  {
 2771/*   RtlFreeUnicodeString(& RegistryPath); */ /* INLINED */
 2772  }
 2773  return;
 2774}
 2775}
 2776#pragma once
 2777#pragma once
 2778#pragma once
 2779#pragma once
 2780#pragma warning(push)
 2781#pragma warning(disable:4035)
 2782#pragma warning(pop)
 2783#pragma once
 2784#pragma warning(disable:4103)
 2785#pragma warning(disable:4103)
 2786#pragma warning(push)
 2787#pragma warning(disable:4035)
 2788#pragma warning(pop)
 2789#pragma warning(disable:4035)
 2790#pragma warning(push)
 2791#pragma warning(disable:4164)
 2792#pragma function(_enable)
 2793#pragma function(_disable)
 2794#pragma warning(pop)
 2795#pragma warning(disable:4103)
 2796#pragma warning(disable:4103)
 2797#pragma warning(disable:4103)
 2798#pragma warning(disable:4103)
 2799#pragma warning(disable:4103)
 2800#pragma warning(disable:4103)
 2801#pragma warning(disable:4200)
 2802#pragma warning(default:4200)
 2803#pragma once
 2804void PptCleanRemovalRelationsList(PDEVICE_EXTENSION Extension ) 
 2805{ PLIST_ENTRY listHead ;
 2806  PLIST_ENTRY thisListEntry ;
 2807  PREMOVAL_RELATIONS_LIST_ENTRY node ;
 2808  PLIST_ENTRY _EX_Blink ;
 2809  PLIST_ENTRY _EX_Flink ;
 2810
 2811  {
 2812  {
 2813  listHead = & Extension->RemovalRelationsList;
 2814  thisListEntry = (void *)0;
 2815  node = (void *)0;
 2816/*   ExAcquireFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2817  }
 2818  {
 2819  while (1) {
 2820    while_19_continue: /* CIL Label */ ;
 2821    if (! ((unsigned int )listHead->Flink == (unsigned int )listHead)) {
 2822
 2823    } else {
 2824      goto while_19_break;
 2825    }
 2826    thisListEntry = listHead->Flink;
 2827    _EX_Flink = (listHead->Flink)->Flink;
 2828    _EX_Blink = (listHead->Flink)->Blink;
 2829    _EX_Blink->Flink = _EX_Flink;
 2830    _EX_Flink->Blink = _EX_Blink;
 2831    node = (REMOVAL_RELATIONS_LIST_ENTRY *)((CHAR *)thisListEntry - (unsigned long )(& ((REMOVAL_RELATIONS_LIST_ENTRY *)0)->ListEntry));
 2832    {
 2833    }
 2834    {
 2835/*     RtlFreeUnicodeString(& node->DeviceName); */ /* INLINED */
 2836/*     ExFreePool(node); */ /* INLINED */
 2837    }
 2838  }
 2839  while_19_break: /* CIL Label */ ;
 2840  }
 2841  {
 2842/*   ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2843  }
 2844  return;
 2845}
 2846}
 2847NTSTATUS PptAddPptRemovalRelation(PDEVICE_EXTENSION Extension , PPARPORT_REMOVAL_RELATIONS PptRemovalRelations ) 
 2848{ PREMOVAL_RELATIONS_LIST_ENTRY node ;
 2849  PVOID tmp ;
 2850  PVOID tmp___0 ;
 2851  PLIST_ENTRY _EX_Blink ;
 2852  PLIST_ENTRY _EX_ListHead ;
 2853
 2854  {
 2855  {
 2856  tmp = ExAllocatePoolWithTag(1, sizeof(REMOVAL_RELATIONS_LIST_ENTRY ), 1349673296UL);
 2857  node = tmp;
 2858  }
 2859  {
 2860  }
 2861  if (! node) {
 2862    {
 2863    }
 2864    return (-1073741670L);
 2865  } else {
 2866
 2867  }
 2868  {
 2869  node->DeviceObject = PptRemovalRelations->DeviceObject;
 2870  node->Flags = PptRemovalRelations->Flags;
 2871  memset(& node->DeviceName, 0, sizeof(UNICODE_STRING ));
 2872  tmp___0 = ExAllocatePoolWithTag(1, (PptRemovalRelations->DeviceName)->MaximumLength,
 2873                                  1349673296UL);
 2874  node->DeviceName.Buffer = tmp___0;
 2875  }
 2876  if (! node->DeviceName.Buffer) {
 2877    {
 2878    }
 2879    {
 2880/*     ExFreePool(node); */ /* INLINED */
 2881    }
 2882    return (-1073741670L);
 2883  } else {
 2884
 2885  }
 2886  {
 2887  node->DeviceName.MaximumLength = (PptRemovalRelations->DeviceName)->MaximumLength;
 2888/*   RtlCopyUnicodeString(& node->DeviceName, PptRemovalRelations->DeviceName); */ /* INLINED */
 2889/*   ExAcquireFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2890  _EX_ListHead = & Extension->RemovalRelationsList;
 2891  _EX_Blink = _EX_ListHead->Blink;
 2892  node->ListEntry.Flink = _EX_ListHead;
 2893  node->ListEntry.Blink = _EX_Blink;
 2894  _EX_Blink->Flink = & node->ListEntry;
 2895  _EX_ListHead->Blink = & node->ListEntry;
 2896/*   ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2897  }
 2898  return (0L);
 2899}
 2900}
 2901NTSTATUS PptRemovePptRemovalRelation(PDEVICE_EXTENSION Extension , PPARPORT_REMOVAL_RELATIONS PptRemovalRelations ) 
 2902{ PDEVICE_OBJECT callerDevObj ;
 2903  PLIST_ENTRY listHead ;
 2904  PDEVICE_OBJECT listDevObj ;
 2905  PLIST_ENTRY thisListEntry ;
 2906  PLIST_ENTRY firstListEntry ;
 2907  BOOLEAN found ;
 2908  BOOLEAN done ;
 2909  PREMOVAL_RELATIONS_LIST_ENTRY node ;
 2910  PLIST_ENTRY _EX_Blink ;
 2911  PLIST_ENTRY _EX_Flink ;
 2912  PLIST_ENTRY _EX_Blink___0 ;
 2913  PLIST_ENTRY _EX_ListHead ;
 2914
 2915  {
 2916  callerDevObj = PptRemovalRelations->DeviceObject;
 2917  listHead = & Extension->RemovalRelationsList;
 2918  listDevObj = (void *)0;
 2919  thisListEntry = (void *)0;
 2920  firstListEntry = (void *)0;
 2921  found = 0;
 2922  done = 0;
 2923  node = (void *)0;
 2924  {
 2925  }
 2926  {
 2927/*   ExAcquireFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2928  }
 2929  if ((unsigned int )listHead->Flink == (unsigned int )listHead) {
 2930    {
 2931    }
 2932    {
 2933/*     ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2934    }
 2935    return (0L);
 2936  } else {
 2937    {
 2938    }
 2939    {
 2940/*     ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2941    }
 2942  }
 2943  {
 2944/*   ExAcquireFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2945  }
 2946  {
 2947  while (1) {
 2948    while_27_continue: /* CIL Label */ ;
 2949    if (! done) {
 2950
 2951    } else {
 2952      goto while_27_break;
 2953    }
 2954    thisListEntry = listHead->Flink;
 2955    _EX_Flink = (listHead->Flink)->Flink;
 2956    _EX_Blink = (listHead->Flink)->Blink;
 2957    _EX_Blink->Flink = _EX_Flink;
 2958    _EX_Flink->Blink = _EX_Blink;
 2959    node = (REMOVAL_RELATIONS_LIST_ENTRY *)((CHAR *)thisListEntry - (unsigned long )(& ((REMOVAL_RELATIONS_LIST_ENTRY *)0)->ListEntry));
 2960    if ((unsigned int )node->DeviceObject == (unsigned int )callerDevObj) {
 2961      {
 2962      }
 2963      found = 1;
 2964      done = 1;
 2965    } else {
 2966      if ((unsigned int )firstListEntry == (unsigned int )thisListEntry) {
 2967        {
 2968        }
 2969        done = 1;
 2970      } else {
 2971        if (! firstListEntry) {
 2972          {
 2973          }
 2974          firstListEntry = thisListEntry;
 2975        } else {
 2976
 2977        }
 2978      }
 2979    }
 2980    if (! found) {
 2981      _EX_ListHead = listHead;
 2982      _EX_Blink___0 = _EX_ListHead->Blink;
 2983      node->ListEntry.Flink = _EX_ListHead;
 2984      node->ListEntry.Blink = _EX_Blink___0;
 2985      _EX_Blink___0->Flink = & node->ListEntry;
 2986      _EX_ListHead->Blink = & node->ListEntry;
 2987    } else {
 2988
 2989    }
 2990  }
 2991  while_27_break: /* CIL Label */ ;
 2992  }
 2993  {
 2994/*   ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 2995  }
 2996  if (found) {
 2997    {
 2998/*     RtlFreeUnicodeString(& node->DeviceName); */ /* INLINED */
 2999/*     ExFreePool(node); */ /* INLINED */
 3000    }
 3001  } else {
 3002
 3003  }
 3004  {
 3005  }
 3006  return (0L);
 3007}
 3008}
 3009void PptDumpRemovalRelationsList(PDEVICE_EXTENSION Extension ) 
 3010{ PLIST_ENTRY listHead ;
 3011  PLIST_ENTRY thisListEntry ;
 3012  PLIST_ENTRY firstListEntry ;
 3013  BOOLEAN done ;
 3014  PREMOVAL_RELATIONS_LIST_ENTRY node ;
 3015  PLIST_ENTRY _EX_Blink ;
 3016  PLIST_ENTRY _EX_Flink ;
 3017  PLIST_ENTRY _EX_Flink___0 ;
 3018  PLIST_ENTRY _EX_ListHead ;
 3019  PLIST_ENTRY _EX_Blink___0 ;
 3020  PLIST_ENTRY _EX_ListHead___0 ;
 3021
 3022  {
 3023  listHead = & Extension->RemovalRelationsList;
 3024  thisListEntry = (void *)0;
 3025  firstListEntry = (void *)0;
 3026  done = 0;
 3027  node = (void *)0;
 3028  {
 3029  }
 3030  {
 3031/*   ExAcquireFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 3032  }
 3033  if ((unsigned int )listHead->Flink == (unsigned int )listHead) {
 3034    {
 3035    }
 3036    {
 3037/*     ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 3038    }
 3039    return;
 3040  } else {
 3041    {
 3042    }
 3043  }
 3044  {
 3045  while (1) {
 3046    while_35_continue: /* CIL Label */ ;
 3047    if (! done) {
 3048
 3049    } else {
 3050      goto while_35_break;
 3051    }
 3052    thisListEntry = listHead->Flink;
 3053    _EX_Flink = (listHead->Flink)->Flink;
 3054    _EX_Blink = (listHead->Flink)->Blink;
 3055    _EX_Blink->Flink = _EX_Flink;
 3056    _EX_Flink->Blink = _EX_Blink;
 3057    node = (REMOVAL_RELATIONS_LIST_ENTRY *)((CHAR *)thisListEntry - (unsigned long )(& ((REMOVAL_RELATIONS_LIST_ENTRY *)0)->ListEntry));
 3058    if ((unsigned int )firstListEntry == (unsigned int )thisListEntry) {
 3059      _EX_ListHead = listHead;
 3060      _EX_Flink___0 = _EX_ListHead->Flink;
 3061      node->ListEntry.Flink = _EX_Flink___0;
 3062      node->ListEntry.Blink = _EX_ListHead;
 3063      _EX_Flink___0->Blink = & node->ListEntry;
 3064      _EX_ListHead->Flink = & node->ListEntry;
 3065      done = 1;
 3066      {
 3067      }
 3068    } else {
 3069      {
 3070      }
 3071      _EX_ListHead___0 = listHead;
 3072      _EX_Blink___0 = _EX_ListHead___0->Blink;
 3073      node->ListEntry.Flink = _EX_ListHead___0;
 3074      node->ListEntry.Blink = _EX_Blink___0;
 3075      _EX_Blink___0->Flink = & node->ListEntry;
 3076      _EX_ListHead___0->Blink = & node->ListEntry;
 3077    }
 3078    if (! firstListEntry) {
 3079      firstListEntry = thisListEntry;
 3080    } else {
 3081
 3082    }
 3083  }
 3084  while_35_break: /* CIL Label */ ;
 3085  }
 3086  {
 3087/*   ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 3088  }
 3089  return;
 3090}
 3091}
 3092void PptDumpPptRemovalRelationsStruct(PPARPORT_REMOVAL_RELATIONS PptRemovalRelations ) 
 3093{ 
 3094
 3095  {
 3096  return;
 3097}
 3098}
 3099NTSTATUS PptDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 3100{ PIO_STACK_LOCATION IrpSp ;
 3101  PDEVICE_EXTENSION Extension ;
 3102  NTSTATUS Status ;
 3103  PPARALLEL_PORT_INFORMATION PortInfo ;
 3104  PPARALLEL_PNP_INFORMATION PnpInfo ;
 3105  PMORE_PARALLEL_PORT_INFORMATION MorePortInfo ;
 3106  KIRQL CancelIrql ;
 3107  SYNCHRONIZED_COUNT_CONTEXT SyncContext ;
 3108  PPARALLEL_INTERRUPT_SERVICE_ROUTINE IsrInfo ;
 3109  PPARALLEL_INTERRUPT_INFORMATION InterruptInfo ;
 3110  PISR_LIST_ENTRY IsrListEntry ;
 3111  SYNCHRONIZED_LIST_CONTEXT ListContext ;
 3112  SYNCHRONIZED_DISCONNECT_CONTEXT DisconnectContext ;
 3113  BOOLEAN DisconnectInterrupt ;
 3114  NTSTATUS tmp ;
 3115  PPARPORT_REMOVAL_RELATIONS removalRelations ;
 3116  PPARPORT_REMOVAL_RELATIONS removalRelations___0 ;
 3117  PLIST_ENTRY _EX_Blink ;
 3118  PLIST_ENTRY _EX_ListHead ;
 3119  ULONG EnableConnectInterruptIoctl ;
 3120  PVOID tmp___0 ;
 3121  BOOLEAN tmp___1 ;
 3122  PLIST_ENTRY _EX_Blink___0 ;
 3123  PLIST_ENTRY _EX_ListHead___0 ;
 3124
 3125  {
 3126  Extension = DeviceObject->DeviceExtension;
 3127  {
 3128  }
 3129  if (Irp->UserEvent) {
 3130
 3131  } else {
 3132
 3133  }
 3134  if (Extension->DeviceStateFlags & 4096UL) {
 3135    {
 3136    }
 3137    {
 3138    tmp = PptFailRequest(Irp, -1073741738L);
 3139    }
 3140    return (tmp);
 3141  } else {
 3142
 3143  }
 3144  {
 3145  Status = PptAcquireRemoveLockOrFailIrp(DeviceObject, Irp);
 3146  }
 3147  if (! (Status >= 0L)) {
 3148    {
 3149    }
 3150    return (Status);
 3151  } else {
 3152
 3153  }
 3154  IrpSp = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 3155  Irp->IoStatus.Information = 0;
 3156  if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (50 << 2))) {
 3157    goto switch_41_exp_0;
 3158  } else {
 3159    if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (51 << 2))) {
 3160      goto switch_41_exp_1;
 3161    } else {
 3162      if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (40 << 2))) {
 3163        goto switch_41_exp_2;
 3164      } else {
 3165        if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (11 << 2))) {
 3166          goto switch_41_exp_3;
 3167        } else {
 3168          if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (12 << 2))) {
 3169            goto switch_41_exp_4;
 3170          } else {
 3171            if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (15 << 2))) {
 3172              goto switch_41_exp_5;
 3173            } else {
 3174              if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (21 << 2))) {
 3175                goto switch_41_exp_6;
 3176              } else {
 3177                if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (17 << 2))) {
 3178                  goto switch_41_exp_7;
 3179                } else {
 3180                  if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (13 << 2))) {
 3181                    goto switch_41_exp_8;
 3182                  } else {
 3183                    if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (14 << 2))) {
 3184                      goto switch_41_exp_9;
 3185                    } else {
 3186                      if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (19 << 2))) {
 3187                        goto switch_41_exp_10;
 3188                      } else {
 3189                        if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (20 << 2))) {
 3190                          goto switch_41_exp_11;
 3191                        } else {
 3192                          if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (22 << 2))) {
 3193                            goto switch_41_exp_12;
 3194                          } else {
 3195                            if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (23 << 2))) {
 3196                              goto switch_41_exp_13;
 3197                            } else {
 3198                              if (IrpSp->Parameters.DeviceIoControl.IoControlCode == ((22 << 16) | (24 << 2))) {
 3199                                goto switch_41_exp_14;
 3200                              } else {
 3201                                {
 3202                                goto switch_41_default;
 3203                                if (0) {
 3204                                  switch_41_exp_0: /* CIL Label */ ;
 3205                                  {
 3206                                  }
 3207                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARPORT_REMOVAL_RELATIONS )) {
 3208                                    {
 3209                                    }
 3210                                    Status = -1073741789L;
 3211                                  } else {
 3212                                    {
 3213                                    removalRelations = Irp->AssociatedIrp.SystemBuffer;
 3214/*                                     PptDumpPptRemovalRelationsStruct(removalRelations); */ /* INLINED */
 3215                                    PptDumpRemovalRelationsList(Extension);
 3216                                    PptAddPptRemovalRelation(Extension, removalRelations);
 3217                                    PptDumpRemovalRelationsList(Extension);
 3218                                    }
 3219                                    {
 3220                                    }
 3221                                    Status = 0L;
 3222                                  }
 3223                                  {
 3224                                  Irp->IoStatus.__annonCompField4.Status = Status;
 3225                                  myStatus = Status;
 3226                                  PptReleaseRemoveLock(& Extension->RemoveLock, Irp);
 3227                                  PptCompleteRequest(Irp, 0);
 3228                                  }
 3229                                  return (Status);
 3230                                  switch_41_exp_1: /* CIL Label */ ;
 3231                                  {
 3232                                  }
 3233                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARPORT_REMOVAL_RELATIONS )) {
 3234                                    {
 3235                                    }
 3236                                    Status = -1073741789L;
 3237                                  } else {
 3238                                    {
 3239                                    removalRelations___0 = Irp->AssociatedIrp.SystemBuffer;
 3240/*                                     PptDumpPptRemovalRelationsStruct(Irp->AssociatedIrp.SystemBuffer); */ /* INLINED */
 3241                                    PptDumpRemovalRelationsList(Extension);
 3242                                    PptRemovePptRemovalRelation(Extension, removalRelations___0);
 3243                                    PptDumpRemovalRelationsList(Extension);
 3244                                    }
 3245                                    {
 3246                                    }
 3247                                    Status = 0L;
 3248                                  }
 3249                                  {
 3250                                  Irp->IoStatus.__annonCompField4.Status = Status;
 3251                                  myStatus = Status;
 3252                                  PptReleaseRemoveLock(& Extension->RemoveLock, Irp);
 3253                                  PptCompleteRequest(Irp, 0);
 3254                                  }
 3255                                  return (Status);
 3256                                  switch_41_exp_2: /* CIL Label */ 
 3257                                  {
 3258                                  PptFreePort(Extension);
 3259                                  Irp->IoStatus.__annonCompField4.Status = 0L;
 3260                                  myStatus = 0L;
 3261                                  PptReleaseRemoveLock(& Extension->RemoveLock, Irp);
 3262                                  PptCompleteRequest(Irp, 0);
 3263                                  }
 3264                                  return (0L);
 3265                                  switch_41_exp_3: /* CIL Label */ 
 3266                                  {
 3267                                  IoAcquireCancelSpinLock(& CancelIrql);
 3268                                  }
 3269                                  if (Irp->Cancel) {
 3270                                    Status = -1073741536L;
 3271                                  } else {
 3272                                    SyncContext.Count = & Extension->WorkQueueCount;
 3273                                    if (Extension->InterruptRefCount) {
 3274                                      {
 3275                                      KeSynchronizeExecution(Extension->InterruptObject,
 3276                                                             & PptSynchronizedIncrement,
 3277                                                             & SyncContext);
 3278                                      }
 3279                                    } else {
 3280                                      {
 3281                                      PptSynchronizedIncrement(& SyncContext);
 3282                                      }
 3283                                    }
 3284                                    if (SyncContext.NewCount) {
 3285                                      {
 3286                                      PptSetCancelRoutine(Irp, & PptCancelRoutine);
 3287                                      }
 3288                                      if (pended == 0) {
 3289                                        pended = 1;
 3290                                      } else {
 3291                                        {
 3292                                        errorFn();
 3293                                        }
 3294                                      }
 3295                                      (Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation)->Control = (int )(Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation)->Control | 1;
 3296                                      _EX_ListHead = & Extension->WorkQueue;
 3297                                      _EX_Blink = _EX_ListHead->Blink;
 3298                                      Irp->Tail.Overlay.__annonCompField17.ListEntry.Flink = _EX_ListHead;
 3299                                      Irp->Tail.Overlay.__annonCompField17.ListEntry.Blink = _EX_Blink;
 3300                                      _EX_Blink->Flink = & Irp->Tail.Overlay.__annonCompField17.ListEntry;
 3301                                      _EX_ListHead->Blink = & Irp->Tail.Overlay.__annonCompField17.ListEntry;
 3302                                      Status = 259L;
 3303                                    } else {
 3304                                      Extension->WmiPortAllocFreeCounts.PortAllocates += 1UL;
 3305                                      Status = 0L;
 3306                                    }
 3307                                  }
 3308                                  {
 3309/*                                   IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3310                                  }
 3311                                  goto switch_41_break;
 3312                                  switch_41_exp_4: /* CIL Label */ ;
 3313                                  {
 3314                                  }
 3315                                  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < (ULONG )sizeof(PARALLEL_PORT_INFORMATION )) {
 3316                                    Status = -1073741789L;
 3317                                  } else {
 3318                                    Irp->IoStatus.Information = sizeof(PARALLEL_PORT_INFORMATION );
 3319                                    PortInfo = Irp->AssociatedIrp.SystemBuffer;
 3320                                    *PortInfo = Extension->PortInfo;
 3321                                    Status = 0L;
 3322                                  }
 3323                                  goto switch_41_break;
 3324                                  switch_41_exp_5: /* CIL Label */ ;
 3325                                  {
 3326                                  }
 3327                                  Status = 0L;
 3328                                  goto switch_41_break;
 3329                                  switch_41_exp_6: /* CIL Label */ ;
 3330                                  {
 3331                                  }
 3332                                  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < (ULONG )sizeof(PARALLEL_PNP_INFORMATION )) {
 3333                                    Status = -1073741789L;
 3334                                  } else {
 3335                                    Irp->IoStatus.Information = sizeof(PARALLEL_PNP_INFORMATION );
 3336                                    PnpInfo = Irp->AssociatedIrp.SystemBuffer;
 3337                                    *PnpInfo = Extension->PnpInfo;
 3338                                    Status = 0L;
 3339                                  }
 3340                                  goto switch_41_break;
 3341                                  switch_41_exp_7: /* CIL Label */ ;
 3342                                  {
 3343                                  }
 3344                                  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < (ULONG )sizeof(MORE_PARALLEL_PORT_INFORMATION )) {
 3345                                    Status = -1073741789L;
 3346                                  } else {
 3347                                    Irp->IoStatus.Information = sizeof(MORE_PARALLEL_PORT_INFORMATION );
 3348                                    MorePortInfo = Irp->AssociatedIrp.SystemBuffer;
 3349                                    MorePortInfo->InterfaceType = Extension->InterfaceType;
 3350                                    MorePortInfo->BusNumber = Extension->BusNumber;
 3351                                    MorePortInfo->InterruptLevel = Extension->InterruptLevel;
 3352                                    MorePortInfo->InterruptVector = Extension->InterruptVector;
 3353                                    MorePortInfo->InterruptAffinity = Extension->InterruptAffinity;
 3354                                    MorePortInfo->InterruptMode = Extension->InterruptMode;
 3355                                    Status = 0L;
 3356                                  }
 3357                                  goto switch_41_break;
 3358                                  switch_41_exp_8: /* CIL Label */ ;
 3359                                  {
 3360                                  }
 3361                                  EnableConnectInterruptIoctl = 0;
 3362                                  {
 3363                                  }
 3364                                  if (0UL == EnableConnectInterruptIoctl) {
 3365                                    {
 3366                                    }
 3367                                    Status = -1073741823L;
 3368                                    goto targetExit;
 3369                                  } else {
 3370                                    {
 3371                                    }
 3372                                  }
 3373                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARALLEL_INTERRUPT_SERVICE_ROUTINE )) {
 3374                                    Status = -1073741789L;
 3375                                  } else {
 3376                                    if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < (ULONG )sizeof(PARALLEL_INTERRUPT_INFORMATION )) {
 3377                                      Status = -1073741789L;
 3378                                    } else {
 3379                                      {
 3380                                      IsrInfo = Irp->AssociatedIrp.SystemBuffer;
 3381                                      InterruptInfo = Irp->AssociatedIrp.SystemBuffer;
 3382                                      IoAcquireCancelSpinLock(& CancelIrql);
 3383                                      }
 3384                                      if (Extension->InterruptRefCount) {
 3385                                        {
 3386                                        Extension->InterruptRefCount += 1UL;
 3387/*                                         IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3388                                        Status = 0L;
 3389                                        }
 3390                                      } else {
 3391                                        {
 3392/*                                         IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3393                                        Status = PptConnectInterrupt(Extension);
 3394                                        }
 3395                                        if (Status >= 0L) {
 3396                                          {
 3397                                          IoAcquireCancelSpinLock(& CancelIrql);
 3398                                          Extension->InterruptRefCount += 1UL;
 3399/*                                           IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3400                                          }
 3401                                        } else {
 3402
 3403                                        }
 3404                                      }
 3405                                      if (Status >= 0L) {
 3406                                        {
 3407                                        tmp___0 = ExAllocatePoolWithTag(0, sizeof(ISR_LIST_ENTRY ),
 3408                                                                        1349673296UL);
 3409                                        IsrListEntry = tmp___0;
 3410                                        }
 3411                                        if (IsrListEntry) {
 3412                                          {
 3413                                          IsrListEntry->ServiceRoutine = IsrInfo->InterruptServiceRoutine;
 3414                                          IsrListEntry->ServiceContext = IsrInfo->InterruptServiceContext;
 3415                                          IsrListEntry->DeferredPortCheckRoutine = IsrInfo->DeferredPortCheckRoutine;
 3416                                          IsrListEntry->CheckContext = IsrInfo->DeferredPortCheckContext;
 3417                                          ListContext.List = & Extension->IsrList;
 3418                                          ListContext.NewEntry = & IsrListEntry->ListEntry;
 3419                                          KeSynchronizeExecution(Extension->InterruptObject,
 3420                                                                 & PptSynchronizedQueue,
 3421                                                                 & ListContext);
 3422                                          InterruptInfo->InterruptObject = Extension->InterruptObject;
 3423                                          InterruptInfo->TryAllocatePortAtInterruptLevel = & PptTryAllocatePortAtInterruptLevel;
 3424                                          InterruptInfo->FreePortFromInterruptLevel = & PptFreePortFromInterruptLevel;
 3425                                          InterruptInfo->Context = Extension;
 3426                                          Irp->IoStatus.Information = sizeof(PARALLEL_INTERRUPT_INFORMATION );
 3427                                          Status = 0L;
 3428                                          }
 3429                                        } else {
 3430                                          Status = -1073741670L;
 3431                                        }
 3432                                      } else {
 3433
 3434                                      }
 3435                                    }
 3436                                  }
 3437                                  goto switch_41_break;
 3438                                  switch_41_exp_9: /* CIL Label */ ;
 3439                                  {
 3440                                  }
 3441                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARALLEL_INTERRUPT_SERVICE_ROUTINE )) {
 3442                                    Status = -1073741789L;
 3443                                  } else {
 3444                                    {
 3445                                    IsrInfo = Irp->AssociatedIrp.SystemBuffer;
 3446                                    IoAcquireCancelSpinLock(& CancelIrql);
 3447                                    }
 3448                                    if (Extension->InterruptRefCount) {
 3449                                      {
 3450/*                                       IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3451                                      DisconnectContext.Extension = Extension;
 3452                                      DisconnectContext.IsrInfo = IsrInfo;
 3453                                      tmp___1 = KeSynchronizeExecution(Extension->InterruptObject,
 3454                                                                       & PptSynchronizedDisconnect,
 3455                                                                       & DisconnectContext);
 3456                                      }
 3457                                      if (tmp___1) {
 3458                                        {
 3459                                        Status = 0L;
 3460                                        IoAcquireCancelSpinLock(& CancelIrql);
 3461                                        Extension->InterruptRefCount -= 1UL;
 3462                                        }
 3463                                        if (Extension->InterruptRefCount == 0UL) {
 3464                                          DisconnectInterrupt = 1;
 3465                                        } else {
 3466                                          DisconnectInterrupt = 0;
 3467                                        }
 3468                                        {
 3469/*                                         IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3470                                        }
 3471                                      } else {
 3472                                        Status = -1073741811L;
 3473                                        DisconnectInterrupt = 0;
 3474                                      }
 3475                                    } else {
 3476                                      {
 3477/*                                       IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3478                                      DisconnectInterrupt = 0;
 3479                                      Status = -1073741811L;
 3480                                      }
 3481                                    }
 3482                                    if (DisconnectInterrupt) {
 3483                                      {
 3484                                      PptDisconnectInterrupt(Extension);
 3485                                      }
 3486                                    } else {
 3487
 3488                                    }
 3489                                  }
 3490                                  goto switch_41_break;
 3491                                  switch_41_exp_10: /* CIL Label */ ;
 3492                                  {
 3493                                  }
 3494                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARALLEL_CHIP_MODE )) {
 3495                                    Status = -1073741789L;
 3496                                  } else {
 3497                                    {
 3498                                    }
 3499                                    {
 3500                                    Status = PptSetChipMode(Extension, ((struct _PARALLEL_CHIP_MODE *)Irp->AssociatedIrp.SystemBuffer)->ModeFlags);
 3501                                    }
 3502                                  }
 3503                                  goto switch_41_break;
 3504                                  switch_41_exp_11: /* CIL Label */ ;
 3505                                  {
 3506                                  }
 3507                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARALLEL_CHIP_MODE )) {
 3508                                    Status = -1073741789L;
 3509                                  } else {
 3510                                    {
 3511                                    }
 3512                                    {
 3513                                    Status = PptClearChipMode(Extension, ((struct _PARALLEL_CHIP_MODE *)Irp->AssociatedIrp.SystemBuffer)->ModeFlags);
 3514                                    }
 3515                                  }
 3516                                  goto switch_41_break;
 3517                                  switch_41_exp_12: /* CIL Label */ ;
 3518                                  {
 3519                                  }
 3520                                  {
 3521                                  Extension->PnpInfo.Ieee1284_3DeviceCount = PptInitiate1284_3(Extension);
 3522                                  Status = 0L;
 3523                                  }
 3524                                  goto switch_41_break;
 3525                                  switch_41_exp_13: /* CIL Label */ ;
 3526                                  {
 3527                                  }
 3528                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARALLEL_1284_COMMAND )) {
 3529                                    {
 3530                                    }
 3531                                    Status = -1073741789L;
 3532                                  } else {
 3533                                    if (Irp->Cancel) {
 3534                                      Status = -1073741536L;
 3535                                    } else {
 3536                                      {
 3537                                      Status = PptTrySelectDevice(Extension, Irp->AssociatedIrp.SystemBuffer);
 3538                                      IoAcquireCancelSpinLock(& CancelIrql);
 3539                                      }
 3540                                      if (Status == 259L) {
 3541                                        {
 3542                                        PptSetCancelRoutine(Irp, & PptCancelRoutine);
 3543                                        }
 3544                                        if (pended == 0) {
 3545                                          pended = 1;
 3546                                        } else {
 3547                                          {
 3548                                          errorFn();
 3549                                          }
 3550                                        }
 3551                                        (Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation)->Control = (int )(Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation)->Control | 1;
 3552                                        _EX_ListHead___0 = & Extension->WorkQueue;
 3553                                        _EX_Blink___0 = _EX_ListHead___0->Blink;
 3554                                        Irp->Tail.Overlay.__annonCompField17.ListEntry.Flink = _EX_ListHead___0;
 3555                                        Irp->Tail.Overlay.__annonCompField17.ListEntry.Blink = _EX_Blink___0;
 3556                                        _EX_Blink___0->Flink = & Irp->Tail.Overlay.__annonCompField17.ListEntry;
 3557                                        _EX_ListHead___0->Blink = & Irp->Tail.Overlay.__annonCompField17.ListEntry;
 3558                                        {
 3559                                        }
 3560                                      } else {
 3561
 3562                                      }
 3563                                      {
 3564/*                                       IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 3565                                      }
 3566                                    }
 3567                                  }
 3568                                  goto switch_41_break;
 3569                                  switch_41_exp_14: /* CIL Label */ ;
 3570                                  {
 3571                                  }
 3572                                  if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG )sizeof(PARALLEL_1284_COMMAND )) {
 3573                                    {
 3574                                    }
 3575                                    Status = -1073741789L;
 3576                                  } else {
 3577                                    {
 3578                                    Status = PptDeselectDevice(Extension, Irp->AssociatedIrp.SystemBuffer);
 3579                                    }
 3580                                  }
 3581                                  goto switch_41_break;
 3582                                  switch_41_default: /* CIL Label */ ;
 3583                                  {
 3584                                  }
 3585                                  Status = -1073741811L;
 3586                                  goto switch_41_break;
 3587                                } else {
 3588                                  switch_41_break: /* CIL Label */ ;
 3589                                }
 3590                                }
 3591                              }
 3592                            }
 3593                          }
 3594                        }
 3595                      }
 3596                    }
 3597                  }
 3598                }
 3599              }
 3600            }
 3601          }
 3602        }
 3603      }
 3604    }
 3605  }
 3606  targetExit: 
 3607  if (Status != 259L) {
 3608    {
 3609    Irp->IoStatus.__annonCompField4.Status = Status;
 3610    myStatus = Status;
 3611    PptReleaseRemoveLock(& Extension->RemoveLock, Irp);
 3612    PptCompleteRequest(Irp, 0);
 3613    }
 3614  } else {
 3615
 3616  }
 3617  return (Status);
 3618}
 3619}
 3620#pragma once
 3621#pragma once
 3622#pragma once
 3623#pragma once
 3624#pragma warning(push)
 3625#pragma warning(disable:4035)
 3626#pragma warning(pop)
 3627#pragma once
 3628#pragma warning(disable:4103)
 3629#pragma warning(disable:4103)
 3630#pragma warning(push)
 3631#pragma warning(disable:4035)
 3632#pragma warning(pop)
 3633#pragma warning(disable:4035)
 3634#pragma warning(push)
 3635#pragma warning(disable:4164)
 3636#pragma function(_enable)
 3637#pragma function(_disable)
 3638#pragma warning(pop)
 3639#pragma warning(disable:4103)
 3640#pragma warning(disable:4103)
 3641#pragma warning(disable:4103)
 3642#pragma warning(disable:4103)
 3643#pragma warning(disable:4103)
 3644#pragma warning(disable:4103)
 3645#pragma warning(disable:4200)
 3646#pragma warning(default:4200)
 3647#pragma once
 3648BOOLEAN PptIsNecR98Machine(void) 
 3649{ UNICODE_STRING Path ;
 3650  RTL_QUERY_REGISTRY_TABLE ParamTable[2] ;
 3651  NTSTATUS Status ;
 3652  UNICODE_STRING identifierString ;
 3653  UNICODE_STRING necR98Identifier ;
 3654  UNICODE_STRING necR98JIdentifier ;
 3655  PVOID tmp ;
 3656  LONG tmp___0 ;
 3657  LONG tmp___1 ;
 3658
 3659  {
 3660  {
 3661  identifierString.Length = 0;
 3662  identifierString.MaximumLength = 32;
 3663  tmp = ExAllocatePoolWithTag(1, identifierString.MaximumLength, 1349673296UL);
 3664  identifierString.Buffer = tmp;
 3665  }
 3666  if (! identifierString.Buffer) {
 3667    return (0);
 3668  } else {
 3669
 3670  }
 3671  {
 3672  memset(ParamTable, 0, sizeof(ParamTable));
 3673  ParamTable[0].Flags = 36;
 3674  ParamTable[0].EntryContext = & identifierString;
 3675  ParamTable[0].DefaultType = 1;
 3676  ParamTable[0].DefaultData = & Path;
 3677  ParamTable[0].DefaultLength = 0;
 3678  Status = RtlQueryRegistryValues(0, Path.Buffer, ParamTable, (void *)0, (void *)0);
 3679  }
 3680  if (Status >= 0L) {
 3681    {
 3682    tmp___0 = RtlCompareUnicodeString(& identifierString, & necR98Identifier, 0);
 3683    }
 3684    if (tmp___0 == 0L) {
 3685      goto _L;
 3686    } else {
 3687      {
 3688      tmp___1 = RtlCompareUnicodeString(& identifierString, & necR98JIdentifier, 0);
 3689      }
 3690      if (tmp___1 == 0L) {
 3691        _L: /* CIL Label */ 
 3692        {
 3693        }
 3694        {
 3695/*         ExFreePool(identifierString.Buffer); */ /* INLINED */
 3696        }
 3697        return (1);
 3698      } else {
 3699
 3700      }
 3701    }
 3702  } else {
 3703    {
 3704    }
 3705    {
 3706/*     ExFreePool(identifierString.Buffer); */ /* INLINED */
 3707    }
 3708    return (0);
 3709  }
 3710  {
 3711  }
 3712  {
 3713/*   ExFreePool(identifierString.Buffer); */ /* INLINED */
 3714  }
 3715  return (0);
 3716}
 3717}
 3718#pragma once
 3719#pragma once
 3720#pragma once
 3721#pragma once
 3722#pragma warning(push)
 3723#pragma warning(disable:4035)
 3724#pragma warning(pop)
 3725#pragma once
 3726#pragma warning(disable:4103)
 3727#pragma warning(disable:4103)
 3728#pragma warning(push)
 3729#pragma warning(disable:4035)
 3730#pragma warning(pop)
 3731#pragma warning(disable:4035)
 3732#pragma warning(push)
 3733#pragma warning(disable:4164)
 3734#pragma function(_enable)
 3735#pragma function(_disable)
 3736#pragma warning(pop)
 3737#pragma warning(disable:4103)
 3738#pragma warning(disable:4103)
 3739#pragma warning(disable:4103)
 3740#pragma warning(disable:4103)
 3741#pragma warning(disable:4103)
 3742#pragma warning(disable:4103)
 3743#pragma warning(disable:4200)
 3744#pragma warning(default:4200)
 3745#pragma once
 3746NTSTATUS PptDispatchCreate(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 3747{ PDEVICE_EXTENSION extension ;
 3748  NTSTATUS status ;
 3749  NTSTATUS tmp ;
 3750
 3751  {
 3752  extension = DeviceObject->DeviceExtension;
 3753  status = 0L;
 3754  if (extension->DeviceStateFlags & 4096UL) {
 3755    {
 3756    }
 3757    {
 3758    tmp = PptFailRequest(Irp, -1073741738L);
 3759    }
 3760    return (tmp);
 3761  } else {
 3762
 3763  }
 3764  {
 3765  status = PptAcquireRemoveLockOrFailIrp(DeviceObject, Irp);
 3766  }
 3767  if (! (status >= 0L)) {
 3768    {
 3769    }
 3770    return (status);
 3771  } else {
 3772
 3773  }
 3774  {
 3775/*   ExAcquireFastMutex(& extension->OpenCloseMutex); */ /* INLINED */
 3776  InterlockedIncrement(& extension->OpenCloseRefCount);
 3777/*   ExReleaseFastMutex(& extension->OpenCloseMutex); */ /* INLINED */
 3778  }
 3779  {
 3780  }
 3781  {
 3782  PptReleaseRemoveLock(& extension->RemoveLock, Irp);
 3783  Irp->IoStatus.__annonCompField4.Status = status;
 3784  myStatus = status;
 3785  Irp->IoStatus.Information = 0;
 3786  PptCompleteRequest(Irp, 0);
 3787  }
 3788  return (status);
 3789}
 3790}
 3791NTSTATUS PptDispatchClose(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 3792{ PDEVICE_EXTENSION extension ;
 3793  NTSTATUS status ;
 3794  LONG tmp ;
 3795
 3796  {
 3797  extension = DeviceObject->DeviceExtension;
 3798  if (extension->DeviceStateFlags & 4096UL) {
 3799    {
 3800    Irp->IoStatus.__annonCompField4.Status = 0L;
 3801    myStatus = 0L;
 3802    Irp->IoStatus.Information = 0;
 3803    PptCompleteRequest(Irp, 0);
 3804    }
 3805    return (0L);
 3806  } else {
 3807
 3808  }
 3809  {
 3810  status = PptAcquireRemoveLock(& extension->RemoveLock, Irp);
 3811  }
 3812  if (! (status >= 0L)) {
 3813    {
 3814    Irp->IoStatus.__annonCompField4.Status = 0L;
 3815    myStatus = 0L;
 3816    Irp->IoStatus.Information = 0;
 3817    PptCompleteRequest(Irp, 0);
 3818    }
 3819    return (0L);
 3820  } else {
 3821
 3822  }
 3823  {
 3824/*   ExAcquireFastMutex(& extension->OpenCloseMutex); */ /* INLINED */
 3825  }
 3826  if (extension->OpenCloseRefCount > 0L) {
 3827    {
 3828    tmp = InterlockedDecrement(& extension->OpenCloseRefCount);
 3829    }
 3830    if (tmp < 0L) {
 3831      {
 3832      InterlockedIncrement(& extension->OpenCloseRefCount);
 3833      }
 3834    } else {
 3835
 3836    }
 3837    {
 3838/*     ExReleaseFastMutex(& extension->OpenCloseMutex); */ /* INLINED */
 3839    }
 3840    {
 3841    }
 3842  } else {
 3843    {
 3844/*     ExReleaseFastMutex(& extension->OpenCloseMutex); */ /* INLINED */
 3845    }
 3846    {
 3847    }
 3848  }
 3849  {
 3850  Irp->IoStatus.__annonCompField4.Status = 0L;
 3851  myStatus = 0L;
 3852  Irp->IoStatus.Information = 0;
 3853  PptCompleteRequest(Irp, 0);
 3854  PptReleaseRemoveLock(& extension->RemoveLock, Irp);
 3855  }
 3856  return (0L);
 3857}
 3858}
 3859#pragma once
 3860#pragma once
 3861#pragma once
 3862#pragma once
 3863#pragma warning(push)
 3864#pragma warning(disable:4035)
 3865#pragma warning(pop)
 3866#pragma once
 3867#pragma warning(disable:4103)
 3868#pragma warning(disable:4103)
 3869#pragma warning(push)
 3870#pragma warning(disable:4035)
 3871#pragma warning(pop)
 3872#pragma warning(disable:4035)
 3873#pragma warning(push)
 3874#pragma warning(disable:4164)
 3875#pragma function(_enable)
 3876#pragma function(_disable)
 3877#pragma warning(pop)
 3878#pragma warning(disable:4103)
 3879#pragma warning(disable:4103)
 3880#pragma warning(disable:4103)
 3881#pragma warning(disable:4103)
 3882#pragma warning(disable:4103)
 3883#pragma warning(disable:4103)
 3884#pragma warning(disable:4200)
 3885#pragma warning(default:4200)
 3886static UCHAR ModeQualifier___6[7]  = {      170,      85,      0,      255, 
 3887        135,      120,      255};
 3888#pragma once
 3889BOOLEAN PptCheckIfStl1284_3(PDEVICE_EXTENSION DeviceExtension , ULONG ulDaisyIndex ,
 3890                            BOOLEAN bNoStrobe ) ;
 3891BOOLEAN PptCheckIfNon1284_3Present(PDEVICE_EXTENSION Extension ) ;
 3892BOOLEAN PptCheckIfStlProductId(PDEVICE_EXTENSION DeviceExtension , ULONG ulDaisyIndex ) ;
 3893ULONG PptInitiate1284_3(PVOID Extension ) 
 3894{ ULONG deviceCount1 ;
 3895  ULONG deviceCount2 ;
 3896  ULONG loopCount ;
 3897  ULONG maxTries ;
 3898
 3899  {
 3900  deviceCount1 = 0;
 3901  deviceCount2 = 0;
 3902  loopCount = 0;
 3903  maxTries = 3;
 3904  {
 3905  while (1) {
 3906    while_76_continue: /* CIL Label */ ;
 3907    {
 3908    KeStallExecutionProcessor(5);
 3909    deviceCount1 = Ppt1284_3AssignAddress(Extension);
 3910    KeStallExecutionProcessor(5);
 3911    deviceCount2 = Ppt1284_3AssignAddress(Extension);
 3912    }
 3913    if (deviceCount1 != deviceCount2) {
 3914      loopCount += 1UL;
 3915      if (loopCount < maxTries) {
 3916
 3917      } else {
 3918        goto while_76_break;
 3919      }
 3920    } else {
 3921      goto while_76_break;
 3922    }
 3923  }
 3924  while_76_break: /* CIL Label */ ;
 3925  }
 3926  return (deviceCount2);
 3927}
 3928}
 3929NTSTATUS PptTrySelectDevice(PVOID Context , PVOID TrySelectCommand ) 
 3930{ NTSTATUS Status ;
 3931  PDEVICE_EXTENSION Extension ;
 3932  PPARALLEL_1284_COMMAND Command ;
 3933  BOOLEAN success ;
 3934  SYNCHRONIZED_COUNT_CONTEXT SyncContext ;
 3935  KIRQL CancelIrql ;
 3936  UCHAR i ;
 3937  UCHAR DeviceID ;
 3938  NTSTATUS tmp ;
 3939
 3940  {
 3941  Status = 0L;
 3942  Extension = Context;
 3943  Command = TrySelectCommand;
 3944  success = 0;
 3945  {
 3946  }
 3947  if (Command->CommandFlags & 4UL) {
 3948    {
 3949    tmp = PptTrySelectLegacyZip(Context, TrySelectCommand);
 3950    }
 3951    return (tmp);
 3952  } else {
 3953    if ((int )Command->ID == 5) {
 3954      {
 3955      tmp = PptTrySelectLegacyZip(Context, TrySelectCommand);
 3956      }
 3957      return (tmp);
 3958    } else {
 3959
 3960    }
 3961  }
 3962  DeviceID = Command->ID;
 3963  if (! (Command->CommandFlags & 1UL)) {
 3964    if ((ULONG )DeviceID > Extension->PnpInfo.Ieee1284_3DeviceCount) {
 3965      {
 3966      }
 3967      Status = -1073741811L;
 3968    } else {
 3969      goto _L___1;
 3970    }
 3971  } else {
 3972    _L___1: /* CIL Label */ 
 3973    if (Command->CommandFlags & 2UL) {
 3974      if (! (Command->CommandFlags & 1UL)) {
 3975        if ((ULONG )DeviceID < Extension->PnpInfo.Ieee1284_3DeviceCount) {
 3976          i = 0;
 3977          {
 3978          while (1) {
 3979            while_79_continue: /* CIL Label */ ;
 3980            if ((int )i < (int )PptDot3Retries) {
 3981              if (! success) {
 3982
 3983              } else {
 3984                goto while_79_break;
 3985              }
 3986            } else {
 3987              goto while_79_break;
 3988            }
 3989            {
 3990            success = PptSend1284_3Command(Extension, (unsigned char )(224 | (int )DeviceID));
 3991            KeStallExecutionProcessor(5);
 3992            i = (UCHAR )((int )i + 1);
 3993            }
 3994          }
 3995          while_79_break: /* CIL Label */ ;
 3996          }
 3997          if (success) {
 3998            {
 3999            }
 4000            Status = 0L;
 4001          } else {
 4002            {
 4003            }
 4004            Status = -1073741823L;
 4005          }
 4006        } else {
 4007          goto _L;
 4008        }
 4009      } else {
 4010        _L: /* CIL Label */ 
 4011        {
 4012        }
 4013        Status = 0L;
 4014      }
 4015    } else {
 4016      {
 4017      }
 4018      {
 4019      IoAcquireCancelSpinLock(& CancelIrql);
 4020      SyncContext.Count = & Extension->WorkQueueCount;
 4021      }
 4022      if (Extension->InterruptRefCount) {
 4023        {
 4024        KeSynchronizeExecution(Extension->InterruptObject, & PptSynchronizedIncrement,
 4025                               & SyncContext);
 4026        }
 4027      } else {
 4028        {
 4029        PptSynchronizedIncrement(& SyncContext);
 4030        }
 4031      }
 4032      if (SyncContext.NewCount) {
 4033        {
 4034/*         IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 4035        Status = 259L;
 4036        }
 4037      } else {
 4038        {
 4039/*         IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 4040        }
 4041        {
 4042        }
 4043        Extension->WmiPortAllocFreeCounts.PortAllocates += 1UL;
 4044        if (! (Command->CommandFlags & 1UL)) {
 4045          if ((ULONG )DeviceID < Extension->PnpInfo.Ieee1284_3DeviceCount) {
 4046            i = 0;
 4047            {
 4048            while (1) {
 4049              while_85_continue: /* CIL Label */ ;
 4050              if ((int )i < (int )PptDot3Retries) {
 4051                if (! success) {
 4052
 4053                } else {
 4054                  goto while_85_break;
 4055                }
 4056              } else {
 4057                goto while_85_break;
 4058              }
 4059              {
 4060              success = PptSend1284_3Command(Extension, (unsigned char )(224 | (int )DeviceID));
 4061              KeStallExecutionProcessor(5);
 4062              i = (UCHAR )((int )i + 1);
 4063              }
 4064            }
 4065            while_85_break: /* CIL Label */ ;
 4066            }
 4067            if (success) {
 4068              {
 4069              }
 4070              Status = 0L;
 4071            } else {
 4072              {
 4073              }
 4074              Status = -1073741823L;
 4075            }
 4076          } else {
 4077            goto _L___0;
 4078          }
 4079        } else {
 4080          _L___0: /* CIL Label */ 
 4081          {
 4082          }
 4083          Status = 0L;
 4084        }
 4085      }
 4086    }
 4087  }
 4088  return (Status);
 4089}
 4090}
 4091NTSTATUS PptDeselectDevice(PVOID Context , PVOID DeselectCommand ) 
 4092{ NTSTATUS Status ;
 4093  PDEVICE_EXTENSION Extension ;
 4094  PPARALLEL_1284_COMMAND Command ;
 4095  BOOLEAN success ;
 4096  UCHAR i ;
 4097  UCHAR DeviceID ;
 4098  NTSTATUS tmp ;
 4099
 4100  {
 4101  Status = 0L;
 4102  Extension = Context;
 4103  Command = DeselectCommand;
 4104  success = 0;
 4105  {
 4106  }
 4107  if (Command->CommandFlags & 4UL) {
 4108    {
 4109    tmp = PptDeselectLegacyZip(Context, DeselectCommand);
 4110    }
 4111    return (tmp);
 4112  } else {
 4113    if ((int )Command->ID == 5) {
 4114      {
 4115      tmp = PptDeselectLegacyZip(Context, DeselectCommand);
 4116      }
 4117      return (tmp);
 4118    } else {
 4119
 4120    }
 4121  }
 4122  DeviceID = Command->ID;
 4123  if (! (Command->CommandFlags & 1UL)) {
 4124    if ((ULONG )DeviceID > Extension->PnpInfo.Ieee1284_3DeviceCount) {
 4125      {
 4126      }
 4127      Status = -1073741811L;
 4128    } else {
 4129      goto _L___0;
 4130    }
 4131  } else {
 4132    _L___0: /* CIL Label */ 
 4133    if (! (Command->CommandFlags & 1UL)) {
 4134      if ((ULONG )DeviceID < Extension->PnpInfo.Ieee1284_3DeviceCount) {
 4135        i = 0;
 4136        {
 4137        while (1) {
 4138          while_91_continue: /* CIL Label */ ;
 4139          if ((int )i < (int )PptDot3Retries) {
 4140            if (! success) {
 4141
 4142            } else {
 4143              goto while_91_break;
 4144            }
 4145          } else {
 4146            goto while_91_break;
 4147          }
 4148          {
 4149          success = PptSend1284_3Command(Extension, (unsigned char)48);
 4150          KeStallExecutionProcessor(5);
 4151          i = (UCHAR )((int )i + 1);
 4152          }
 4153        }
 4154        while_91_break: /* CIL Label */ ;
 4155        }
 4156        if (success) {
 4157          {
 4158          }
 4159          if (! (Command->CommandFlags & 2UL)) {
 4160            {
 4161            PptFreePort(Extension);
 4162            }
 4163          } else {
 4164
 4165          }
 4166          Status = 0L;
 4167        } else {
 4168          {
 4169          }
 4170          Status = -1073741823L;
 4171        }
 4172      } else {
 4173        goto _L;
 4174      }
 4175    } else {
 4176      _L: /* CIL Label */ 
 4177      {
 4178      }
 4179      if (! (Command->CommandFlags & 2UL)) {
 4180        {
 4181        PptFreePort(Extension);
 4182        }
 4183      } else {
 4184
 4185      }
 4186      Status = 0L;
 4187    }
 4188  }
 4189  return (Status);
 4190}
 4191}
 4192ULONG Ppt1284_3AssignAddress(PDEVICE_EXTENSION DeviceExtension ) 
 4193{ UCHAR i = __VERIFIER_nondet_char() ;
 4194  UCHAR value ;
 4195  UCHAR newvalue ;
 4196  UCHAR status ;
 4197  PUCHAR CurrentPort ;
 4198  PUCHAR CurrentStatus ;
 4199  PUCHAR CurrentControl ;
 4200  ULONG Delay ;
 4201  UCHAR number ;
 4202  BOOLEAN lastdevice ;
 4203  UCHAR idx ;
 4204  UCHAR tmp ;
 4205  BOOLEAN bStlNon1284_3Found ;
 4206  BOOLEAN bStlNon1284_3Valid ;
 4207  BOOLEAN tmp___0 ;
 4208  BOOLEAN tmp___1 ;
 4209
 4210  {
 4211  {
 4212  Delay = 5;
 4213  number = 0;
 4214  lastdevice = 0;
 4215  CurrentPort = DeviceExtension->PortInfo.Controller;
 4216  CurrentStatus = CurrentPort + 1;
 4217  CurrentControl = CurrentPort + 2;
 4218  value = READ_PORT_UCHAR(CurrentControl);
 4219  newvalue = (unsigned char )(((int )value & -9) | 4);
 4220  newvalue = (unsigned char )((int )newvalue & -33);
 4221  WRITE_PORT_UCHAR(CurrentControl, newvalue);
 4222  WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4223  WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[i]);
 4224  KeStallExecutionProcessor(Delay);
 4225  status = READ_PORT_UCHAR(CurrentStatus);
 4226  }
 4227  if (((int )status & 184) == 184) {
 4228    {
 4229    WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[4]);
 4230    KeStallExecutionProcessor(Delay);
 4231    status = READ_PORT_UCHAR(CurrentStatus);
 4232    }
 4233    if (((int )status & 184) == 24) {
 4234      {
 4235      WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[5]);
 4236      KeStallExecutionProcessor(Delay);
 4237      status = READ_PORT_UCHAR(CurrentStatus);
 4238      }
 4239      if (((int )status & 48) == 48) {
 4240        {
 4241        KeStallExecutionProcessor(Delay);
 4242        }
 4243        {
 4244        while (1) {
 4245          while_95_continue: /* CIL Label */ ;
 4246          if ((int )number < 4) {
 4247            if (! lastdevice) {
 4248
 4249            } else {
 4250              goto while_95_break;
 4251            }
 4252          } else {
 4253            goto while_95_break;
 4254          }
 4255          {
 4256          WRITE_PORT_UCHAR(CurrentPort, number);
 4257          number = (unsigned char )((int )number + 1);
 4258          KeStallExecutionProcessor(Delay);
 4259          tmp = READ_PORT_UCHAR(CurrentStatus);
 4260          }
 4261          if (((int )tmp & 128) == 0) {
 4262            lastdevice = 1;
 4263          } else {
 4264
 4265          }
 4266          {
 4267          WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4268          WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue | 1));
 4269          KeStallExecutionProcessor(Delay);
 4270          WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4271          KeStallExecutionProcessor(Delay);
 4272          }
 4273        }
 4274        while_95_break: /* CIL Label */ ;
 4275        }
 4276        {
 4277        WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[6]);
 4278        }
 4279        if (number) {
 4280          {
 4281          bStlNon1284_3Found = PptCheckIfNon1284_3Present(DeviceExtension);
 4282          bStlNon1284_3Valid = 0;
 4283          idx = 0;
 4284          }
 4285          {
 4286          while (1) {
 4287            while_96_continue: /* CIL Label */ ;
 4288            if ((int )idx < (int )number) {
 4289
 4290            } else {
 4291              goto while_96_break;
 4292            }
 4293            {
 4294            tmp___0 = PptCheckIfStl1284_3(DeviceExtension, idx, bStlNon1284_3Found);
 4295            }
 4296            if (1 == (int )tmp___0) {
 4297              goto __Cont;
 4298            } else {
 4299
 4300            }
 4301            if (1 == (int )bStlNon1284_3Found) {
 4302              {
 4303              tmp___1 = PptCheckIfStlProductId(DeviceExtension, idx);
 4304              }
 4305              if (1 == (int )tmp___1) {
 4306                bStlNon1284_3Valid = 1;
 4307                goto __Cont;
 4308              } else {
 4309
 4310              }
 4311            } else {
 4312
 4313            }
 4314            goto while_96_break;
 4315            __Cont: /* CIL Label */ 
 4316            idx = (UCHAR )((int )idx + 1);
 4317          }
 4318          while_96_break: /* CIL Label */ ;
 4319          }
 4320          if (1 == (int )bStlNon1284_3Valid) {
 4321            number = idx;
 4322          } else {
 4323
 4324          }
 4325        } else {
 4326
 4327        }
 4328      } else {
 4329
 4330      }
 4331    } else {
 4332
 4333    }
 4334  } else {
 4335
 4336  }
 4337  {
 4338  WRITE_PORT_UCHAR(CurrentControl, value);
 4339  }
 4340  return ((unsigned long )number);
 4341}
 4342}
 4343BOOLEAN PptCheckIfNon1284_3Present(PDEVICE_EXTENSION Extension ) 
 4344{ BOOLEAN bReturnValue ;
 4345  UCHAR i = __VERIFIER_nondet_char() ;
 4346  UCHAR value ;
 4347  UCHAR newvalue ;
 4348  UCHAR status ;
 4349  ULONG Delay ;
 4350  PUCHAR CurrentPort ;
 4351  PUCHAR CurrentStatus ;
 4352  PUCHAR CurrentControl ;
 4353  UCHAR ucAckStatus ;
 4354
 4355  {
 4356  {
 4357  bReturnValue = 0;
 4358  Delay = 3;
 4359  CurrentPort = Extension->PortInfo.Controller;
 4360  CurrentStatus = CurrentPort + 1;
 4361  CurrentControl = CurrentPort + 2;
 4362  value = READ_PORT_UCHAR(CurrentControl);
 4363  newvalue = (unsigned char )(((int )value & -9) | 4);
 4364  newvalue = (unsigned char )((int )newvalue & -33);
 4365  WRITE_PORT_UCHAR(CurrentControl, newvalue);
 4366  WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4367  WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[i]);
 4368  KeStallExecutionProcessor(Delay);
 4369  status = READ_PORT_UCHAR(CurrentStatus);
 4370  }
 4371  if (((int )status & 184) == 184) {
 4372    {
 4373    ucAckStatus = (int )status & 64;
 4374    WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[4]);
 4375    KeStallExecutionProcessor(Delay);
 4376    status = READ_PORT_UCHAR(CurrentStatus);
 4377    }
 4378    if (((int )status & 184) == 24) {
 4379      if ((int )ucAckStatus != ((int )status & 64)) {
 4380        {
 4381        ucAckStatus = (int )status & 64;
 4382        WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[5]);
 4383        KeStallExecutionProcessor(Delay);
 4384        status = READ_PORT_UCHAR(CurrentStatus);
 4385        }
 4386        if (((int )status & 48) == 48) {
 4387          bReturnValue = 1;
 4388        } else {
 4389
 4390        }
 4391      } else {
 4392
 4393      }
 4394      {
 4395      WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[6]);
 4396      }
 4397    } else {
 4398
 4399    }
 4400  } else {
 4401
 4402  }
 4403  {
 4404  WRITE_PORT_UCHAR(CurrentControl, value);
 4405  }
 4406  return (bReturnValue);
 4407}
 4408}
 4409BOOLEAN PptCheckIfStl1284_3(PDEVICE_EXTENSION DeviceExtension , ULONG ulDaisyIndex ,
 4410                            BOOLEAN bNoStrobe ) 
 4411{ BOOLEAN bReturnValue ;
 4412  UCHAR i = __VERIFIER_nondet_char() ;
 4413  UCHAR value ;
 4414  UCHAR newvalue ;
 4415  UCHAR status ;
 4416  ULONG Delay ;
 4417  UCHAR ucExpectedPattern ;
 4418  UCHAR ucReadValue ;
 4419  UCHAR ucReadPattern ;
 4420  PUCHAR CurrentPort ;
 4421  PUCHAR CurrentStatus ;
 4422  PUCHAR CurrentControl ;
 4423
 4424  {
 4425  {
 4426  bReturnValue = 0;
 4427  Delay = 3;
 4428  CurrentPort = DeviceExtension->PortInfo.Controller;
 4429  CurrentStatus = CurrentPort + 1;
 4430  CurrentControl = CurrentPort + 2;
 4431  value = READ_PORT_UCHAR(CurrentControl);
 4432  newvalue = (unsigned char )(((int )value & -9) | 4);
 4433  newvalue = (unsigned char )((int )newvalue & -33);
 4434  WRITE_PORT_UCHAR(CurrentControl, newvalue);
 4435  WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4436  WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[i]);
 4437  KeStallExecutionProcessor(Delay);
 4438  status = READ_PORT_UCHAR(CurrentStatus);
 4439  }
 4440  if (((int )status & 184) == 184) {
 4441    {
 4442    WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[4]);
 4443    KeStallExecutionProcessor(Delay);
 4444    status = READ_PORT_UCHAR(CurrentStatus);
 4445    }
 4446    if (((int )status & 184) == 24) {
 4447      {
 4448      WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[5]);
 4449      KeStallExecutionProcessor(Delay);
 4450      status = READ_PORT_UCHAR(CurrentStatus);
 4451      }
 4452      if (((int )status & 48) == 48) {
 4453        {
 4454        KeStallExecutionProcessor(Delay);
 4455        WRITE_PORT_UCHAR(CurrentPort, (unsigned char )(136UL | ulDaisyIndex));
 4456        KeStallExecutionProcessor(Delay);
 4457        }
 4458        if (ulDaisyIndex) {
 4459          if ((int )bNoStrobe == 0) {
 4460            {
 4461            WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4462            WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue | 1));
 4463            KeStallExecutionProcessor(Delay);
 4464            WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4465            KeStallExecutionProcessor(Delay);
 4466            }
 4467          } else {
 4468
 4469          }
 4470        } else {
 4471
 4472        }
 4473        ucExpectedPattern = 240;
 4474        bReturnValue = 1;
 4475        {
 4476        while (1) {
 4477          while_97_continue: /* CIL Label */ ;
 4478          if (ucExpectedPattern) {
 4479
 4480          } else {
 4481            goto while_97_break;
 4482          }
 4483          {
 4484          KeStallExecutionProcessor(Delay);
 4485          WRITE_PORT_UCHAR(CurrentPort, (unsigned char )(128UL | ulDaisyIndex));
 4486          KeStallExecutionProcessor(Delay);
 4487          WRITE_PORT_UCHAR(CurrentPort, (unsigned char )(136UL | ulDaisyIndex));
 4488          KeStallExecutionProcessor(Delay);
 4489          ucReadValue = READ_PORT_UCHAR(CurrentStatus);
 4490          ucReadPattern = ((int )ucReadValue << 1) & 112;
 4491          ucReadPattern = (int )ucReadPattern | ((int )ucReadValue & 128);
 4492          }
 4493          if ((int )ucReadPattern != (int )ucExpectedPattern) {
 4494            bReturnValue = 0;
 4495            goto while_97_break;
 4496          } else {
 4497
 4498          }
 4499          ucExpectedPattern = (int )ucExpectedPattern - 16;
 4500        }
 4501        while_97_break: /* CIL Label */ ;
 4502        }
 4503        {
 4504        WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[6]);
 4505        }
 4506      } else {
 4507
 4508      }
 4509    } else {
 4510
 4511    }
 4512  } else {
 4513
 4514  }
 4515  {
 4516  WRITE_PORT_UCHAR(CurrentControl, value);
 4517  }
 4518  return (bReturnValue);
 4519}
 4520}
 4521BOOLEAN PptCheckIfStlProductId(PDEVICE_EXTENSION DeviceExtension , ULONG ulDaisyIndex ) 
 4522{ BOOLEAN bReturnValue ;
 4523  UCHAR i = __VERIFIER_nondet_char() ;
 4524  UCHAR value ;
 4525  UCHAR newvalue ;
 4526  UCHAR status ;
 4527  ULONG Delay ;
 4528  UCHAR ucProdIdHiByteHiNibble ;
 4529  UCHAR ucProdIdHiByteLoNibble ;
 4530  UCHAR ucProdIdLoByteHiNibble ;
 4531  UCHAR ucProdIdLoByteLoNibble ;
 4532  UCHAR ucProdIdHiByte ;
 4533  UCHAR ucProdIdLoByte ;
 4534  USHORT usProdId ;
 4535  PUCHAR CurrentPort ;
 4536  PUCHAR CurrentStatus ;
 4537  PUCHAR CurrentControl ;
 4538
 4539  {
 4540  {
 4541  bReturnValue = 0;
 4542  Delay = 3;
 4543  CurrentPort = DeviceExtension->PortInfo.Controller;
 4544  CurrentStatus = CurrentPort + 1;
 4545  CurrentControl = CurrentPort + 2;
 4546  value = READ_PORT_UCHAR(CurrentControl);
 4547  newvalue = (unsigned char )(((int )value & -9) | 4);
 4548  newvalue = (unsigned char )((int )newvalue & -33);
 4549  WRITE_PORT_UCHAR(CurrentControl, newvalue);
 4550  WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4551  WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[i]);
 4552  KeStallExecutionProcessor(Delay);
 4553  status = READ_PORT_UCHAR(CurrentStatus);
 4554  }
 4555  if (((int )status & 184) == 184) {
 4556    {
 4557    WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[4]);
 4558    KeStallExecutionProcessor(Delay);
 4559    status = READ_PORT_UCHAR(CurrentStatus);
 4560    }
 4561    if (((int )status & 184) == 24) {
 4562      {
 4563      WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[5]);
 4564      KeStallExecutionProcessor(Delay);
 4565      status = READ_PORT_UCHAR(CurrentStatus);
 4566      }
 4567      if (((int )status & 48) == 48) {
 4568        {
 4569        WRITE_PORT_UCHAR(CurrentPort, (unsigned char )(16UL | ulDaisyIndex));
 4570        KeStallExecutionProcessor(Delay);
 4571        KeStallExecutionProcessor(Delay);
 4572        ucProdIdLoByteHiNibble = READ_PORT_UCHAR(CurrentStatus);
 4573        ucProdIdLoByteHiNibble = (int )ucProdIdLoByteHiNibble & 240;
 4574        KeStallExecutionProcessor(Delay);
 4575        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4576        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue | 1));
 4577        KeStallExecutionProcessor(Delay);
 4578        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4579        KeStallExecutionProcessor(Delay);
 4580        ucProdIdLoByteLoNibble = READ_PORT_UCHAR(CurrentStatus);
 4581        ucProdIdLoByteLoNibble = (int )ucProdIdLoByteLoNibble >> 4;
 4582        ucProdIdLoByte = (int )ucProdIdLoByteHiNibble | (int )ucProdIdLoByteLoNibble;
 4583        KeStallExecutionProcessor(Delay);
 4584        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4585        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue | 1));
 4586        KeStallExecutionProcessor(Delay);
 4587        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4588        KeStallExecutionProcessor(Delay);
 4589        ucProdIdHiByteHiNibble = READ_PORT_UCHAR(CurrentStatus);
 4590        ucProdIdHiByteHiNibble = (int )ucProdIdHiByteHiNibble & 240;
 4591        KeStallExecutionProcessor(Delay);
 4592        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4593        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue | 1));
 4594        KeStallExecutionProcessor(Delay);
 4595        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4596        KeStallExecutionProcessor(Delay);
 4597        ucProdIdHiByteLoNibble = READ_PORT_UCHAR(CurrentStatus);
 4598        ucProdIdHiByteLoNibble = (int )ucProdIdHiByteLoNibble >> 4;
 4599        ucProdIdHiByte = (int )ucProdIdHiByteHiNibble | (int )ucProdIdHiByteLoNibble;
 4600        KeStallExecutionProcessor(Delay);
 4601        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4602        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue | 1));
 4603        KeStallExecutionProcessor(Delay);
 4604        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4605        KeStallExecutionProcessor(Delay);
 4606        usProdId = ((int )ucProdIdHiByte << 8) | (int )ucProdIdLoByte;
 4607        }
 4608        if (43775 == (int )usProdId) {
 4609          bReturnValue = 1;
 4610        } else {
 4611          if (43263 == (int )usProdId) {
 4612            bReturnValue = 1;
 4613          } else {
 4614
 4615          }
 4616        }
 4617        {
 4618        WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[6]);
 4619        }
 4620      } else {
 4621
 4622      }
 4623    } else {
 4624
 4625    }
 4626  } else {
 4627
 4628  }
 4629  {
 4630  WRITE_PORT_UCHAR(CurrentControl, value);
 4631  }
 4632  return (bReturnValue);
 4633}
 4634}
 4635BOOLEAN PptSend1284_3Command(PDEVICE_EXTENSION DeviceExtension , UCHAR Command ) 
 4636{ UCHAR i = __VERIFIER_nondet_char() ;
 4637  UCHAR value ;
 4638  UCHAR newvalue ;
 4639  UCHAR test ;
 4640  PUCHAR CurrentPort ;
 4641  PUCHAR CurrentStatus ;
 4642  PUCHAR CurrentControl ;
 4643  ULONG Delay ;
 4644  BOOLEAN success ;
 4645  UCHAR tmp ;
 4646  UCHAR tmp___0 ;
 4647  int tmp___3 ;
 4648  BOOLEAN tmp___4 ;
 4649  UCHAR tmp___5 ;
 4650  int tmp___8 ;
 4651  BOOLEAN tmp___9 ;
 4652  UCHAR tmp___10 ;
 4653  int tmp___13 ;
 4654  BOOLEAN tmp___14 ;
 4655  UCHAR tmp___15 ;
 4656
 4657  {
 4658  Delay = 3;
 4659  success = 0;
 4660  CurrentPort = DeviceExtension->PortInfo.Controller;
 4661  CurrentStatus = CurrentPort + 1;
 4662  CurrentControl = CurrentPort + 2;
 4663  test = (unsigned char )((int )Command & 248);
 4664  {
 4665  }
 4666  {
 4667  value = READ_PORT_UCHAR(CurrentControl);
 4668  newvalue = (unsigned char )(((int )value & -9) | 4);
 4669  newvalue = (unsigned char )((int )newvalue & -33);
 4670  WRITE_PORT_UCHAR(CurrentControl, newvalue);
 4671  WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4672  KeStallExecutionProcessor(Delay);
 4673  WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[i]);
 4674  KeStallExecutionProcessor(Delay);
 4675  tmp___15 = READ_PORT_UCHAR(CurrentPort + 1);
 4676  }
 4677  if (((int )tmp___15 & 184) == 184) {
 4678    tmp___13 = 1;
 4679  } else {
 4680    {
 4681    tmp___14 = CheckPort(CurrentPort + 1, 184, (unsigned char)184, 5);
 4682    tmp___13 = tmp___14;
 4683    }
 4684  }
 4685  if (tmp___13) {
 4686    {
 4687    WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[4]);
 4688    KeStallExecutionProcessor(Delay);
 4689    tmp___10 = READ_PORT_UCHAR(CurrentPort + 1);
 4690    }
 4691    if (((int )tmp___10 & 184) == 24) {
 4692      tmp___8 = 1;
 4693    } else {
 4694      {
 4695      tmp___9 = CheckPort(CurrentPort + 1, 184, (unsigned char)24, 5);
 4696      tmp___8 = tmp___9;
 4697      }
 4698    }
 4699    if (tmp___8) {
 4700      {
 4701      WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[5]);
 4702      KeStallExecutionProcessor(Delay);
 4703      tmp___5 = READ_PORT_UCHAR(CurrentPort + 1);
 4704      }
 4705      if (((int )tmp___5 & 48) == 48) {
 4706        tmp___3 = 1;
 4707      } else {
 4708        {
 4709        tmp___4 = CheckPort(CurrentPort + 1, 48, (unsigned char)48, 5);
 4710        tmp___3 = tmp___4;
 4711        }
 4712      }
 4713      if (tmp___3) {
 4714        {
 4715        KeStallExecutionProcessor(Delay);
 4716        WRITE_PORT_UCHAR(CurrentPort, Command);
 4717        KeStallExecutionProcessor(Delay);
 4718        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4719        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue | 1));
 4720        KeStallExecutionProcessor(Delay);
 4721        }
 4722        if (test == 224) {
 4723          goto switch_99_224;
 4724        } else {
 4725          if (test == 48) {
 4726            goto switch_99_48;
 4727          } else {
 4728            {
 4729            goto switch_99_default;
 4730            if (0) {
 4731              switch_99_224: /* CIL Label */ ;
 4732              {
 4733              }
 4734              {
 4735              tmp = READ_PORT_UCHAR(CurrentStatus);
 4736              }
 4737              if (((int )tmp & 8) == 8) {
 4738                success = 1;
 4739                {
 4740                }
 4741              } else {
 4742
 4743              }
 4744              if (! success) {
 4745                {
 4746                }
 4747              } else {
 4748
 4749              }
 4750              goto switch_99_break;
 4751              switch_99_48: /* CIL Label */ 
 4752              {
 4753              tmp___0 = READ_PORT_UCHAR(CurrentStatus);
 4754              }
 4755              if (((int )tmp___0 & 8) != 8) {
 4756                success = 1;
 4757                {
 4758                }
 4759              } else {
 4760
 4761              }
 4762              if (! success) {
 4763                {
 4764                }
 4765              } else {
 4766
 4767              }
 4768              goto switch_99_break;
 4769              switch_99_default: /* CIL Label */ ;
 4770              {
 4771              }
 4772              {
 4773              KeStallExecutionProcessor(Delay);
 4774              success = 1;
 4775              }
 4776              goto switch_99_break;
 4777            } else {
 4778              switch_99_break: /* CIL Label */ ;
 4779            }
 4780            }
 4781          }
 4782        }
 4783        {
 4784        WRITE_PORT_UCHAR(CurrentControl, (unsigned char )((int )newvalue & -2));
 4785        KeStallExecutionProcessor(Delay);
 4786        WRITE_PORT_UCHAR(CurrentPort, ModeQualifier___6[6]);
 4787        }
 4788      } else {
 4789
 4790      }
 4791    } else {
 4792
 4793    }
 4794  } else {
 4795
 4796  }
 4797  {
 4798  WRITE_PORT_UCHAR(CurrentControl, value);
 4799  }
 4800  return (success);
 4801}
 4802}
 4803#pragma once
 4804#pragma once
 4805#pragma once
 4806#pragma once
 4807#pragma warning(push)
 4808#pragma warning(disable:4035)
 4809#pragma warning(pop)
 4810#pragma once
 4811#pragma warning(disable:4103)
 4812#pragma warning(disable:4103)
 4813#pragma warning(push)
 4814#pragma warning(disable:4035)
 4815#pragma warning(pop)
 4816#pragma warning(disable:4035)
 4817#pragma warning(push)
 4818#pragma warning(disable:4164)
 4819#pragma function(_enable)
 4820#pragma function(_disable)
 4821#pragma warning(pop)
 4822#pragma warning(disable:4103)
 4823#pragma warning(disable:4103)
 4824#pragma warning(disable:4103)
 4825#pragma warning(disable:4103)
 4826#pragma warning(disable:4103)
 4827#pragma warning(disable:4103)
 4828#pragma warning(disable:4200)
 4829#pragma warning(default:4200)
 4830#pragma once
 4831NTSTATUS PptDetectPortCapabilities(PDEVICE_EXTENSION Extension ) ;
 4832void PptDetectEcpPort(PDEVICE_EXTENSION Extension ) ;
 4833void PptDetectEppPortIfDot3DevicePresent(PDEVICE_EXTENSION Extension ) ;
 4834void PptDetectEppPortIfUserRequested(PDEVICE_EXTENSION Extension ) ;
 4835void PptDetectBytePort(PDEVICE_EXTENSION Extension ) ;
 4836void PptDetermineFifoDepth(PDEVICE_EXTENSION Extension ) ;
 4837void PptDetermineFifoWidth(PDEVICE_EXTENSION Extension ) ;
 4838NTSTATUS PptEcrSetMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) ;
 4839NTSTATUS PptEcrClearMode(PDEVICE_EXTENSION Extension ) ;
 4840NTSTATUS PptFindNatChip(PDEVICE_EXTENSION Extension ) ;
 4841NTSTATUS PptBuildResourceList(PDEVICE_EXTENSION Extension , ULONG Partial , PULONG Addresses ,
 4842                              PCM_RESOURCE_LIST Resources ) ;
 4843NTSTATUS PptSetByteMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) ;
 4844NTSTATUS PptClearByteMode(PDEVICE_EXTENSION Extension ) ;
 4845NTSTATUS PptCheckByteMode(PDEVICE_EXTENSION Extension ) ;
 4846int Extension_FilterMode  =    0;
 4847NTSTATUS PptDetectChipFilter(PDEVICE_EXTENSION Extension ) 
 4848{ NTSTATUS Status ;
 4849  KEVENT Event ;
 4850  UCHAR ecrLast ;
 4851  PUCHAR Controller ;
 4852  PUCHAR EcpController ;
 4853  PUCHAR wPortECR ;
 4854
 4855  {
 4856  Status = -1073741810L;
 4857  Controller = Extension->PortInfo.Controller;
 4858  EcpController = Extension->PnpInfo.EcpController;
 4859  {
 4860  }
 4861  {
 4862  Extension->ChipInfo.success = 0;
 4863  Extension->ChipInfo.Controller = Controller;
 4864  Extension->ChipInfo.EcrController = EcpController;
 4865/*   KeInitializeEvent(& Event, 0, 0); */ /* INLINED */
 4866  }
 4867  if (Extension_FilterMode) {
 4868    if (Extension->PnpInfo.HardwareCapabilities & 1UL) {
 4869      {
 4870      }
 4871      {
 4872      Status = (*(Extension->ChipInfo.ParChipSetMode))(Extension->ChipInfo.Context,
 4873                                                       96);
 4874      }
 4875      if (Status >= 0L) {
 4876        {
 4877        }
 4878        {
 4879        wPortECR = EcpController + 2;
 4880        ecrLast = READ_PORT_UCHAR(wPortECR);
 4881        PptDetermineFifoWidth(Extension);
 4882        PptDetermineFifoDepth(Extension);
 4883        WRITE_PORT_UCHAR(wPortECR, ecrLast);
 4884        Status = (*(Extension->ChipInfo.ParChipClearMode))(Extension->ChipInfo.Context,
 4885                                                           96);
 4886        }
 4887      } else {
 4888
 4889      }
 4890    } else {
 4891
 4892    }
 4893  } else {
 4894
 4895  }
 4896  {
 4897  }
 4898  return (Status);
 4899}
 4900}
 4901NTSTATUS PptDetectPortType(PDEVICE_EXTENSION Extension ) 
 4902{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 4903  NTSTATUS Status ;
 4904  UNICODE_STRING ParportPath ;
 4905  RTL_QUERY_REGISTRY_TABLE RegTable[2] ;
 4906  ULONG IdentifierHex ;
 4907  ULONG zero ;
 4908
 4909  {
 4910  IdentifierHex = 12169;
 4911  zero = 0;
 4912  {
 4913  }
 4914  {
 4915  memset(RegTable, 0, sizeof(RegTable));
 4916  RegTable[0].Flags = 36;
 4917  RegTable[0].EntryContext = & IdentifierHex;
 4918  RegTable[0].DefaultType = 4;
 4919  RegTable[0].DefaultData = & zero;
 4920  RegTable[0].DefaultLength = sizeof(ULONG );
 4921  Status = RtlQueryRegistryValues(1, ParportPath.Buffer, RegTable, (void *)0, (void *)0);
 4922  }
 4923  {
 4924  }
 4925  {
 4926  }
 4927  if (Status >= 0L) {
 4928    if (IdentifierHex == 0UL) {
 4929
 4930    } else {
 4931      goto _L;
 4932    }
 4933  } else {
 4934    _L: /* CIL Label */ 
 4935    if (Status != -1073741772L) {
 4936      {
 4937      }
 4938      {
 4939      }
 4940      {
 4941      PptDetectEcpPort(Extension);
 4942      PptDetectBytePort(Extension);
 4943      }
 4944      if (Extension->PnpInfo.HardwareCapabilities & 9UL) {
 4945        return (0L);
 4946      } else {
 4947        return (-1073741810L);
 4948      }
 4949    } else {
 4950
 4951    }
 4952  }
 4953  IdentifierHex = 12169;
 4954  if (__BLAST_NONDET) {
 4955    Status = 0L;
 4956  } else {
 4957    Status = 3221225473UL;
 4958  }
 4959  {
 4960  }
 4961  {
 4962  Status = PptDetectPortCapabilities(Extension);
 4963  }
 4964  {
 4965  }
 4966  Status = 0L;
 4967  {
 4968  }
 4969  return (Status);
 4970}
 4971}
 4972NTSTATUS PptDetectPortCapabilities(PDEVICE_EXTENSION Extension ) 
 4973{ NTSTATUS Status ;
 4974
 4975  {
 4976  {
 4977  }
 4978  {
 4979  }
 4980  {
 4981  PptDetectEcpPort(Extension);
 4982  }
 4983  if (Extension->PnpInfo.HardwareCapabilities & 1UL) {
 4984    if (((unsigned long )Extension->PortInfo.Controller & 15UL) != 12UL) {
 4985      {
 4986      }
 4987      {
 4988      Status = PptFindNatChip(Extension);
 4989      }
 4990      if (Status >= 0L) {
 4991        if (! Extension->NationalChipFound) {
 4992          {
 4993          }
 4994          {
 4995          }
 4996          {
 4997          PptDetectEppPortIfDot3DevicePresent(Extension);
 4998          }
 4999          if (! Extension->CheckedForGenericEpp) {
 5000            {
 5001            PptDetectEppPortIfUserRequested(Extension);
 5002            }
 5003          } else {
 5004
 5005          }
 5006        } else {
 5007          {
 5008          }
 5009          Extension->CheckedForGenericEpp = 1;
 5010        }
 5011      } else {
 5012
 5013      }
 5014    } else {
 5015      goto _L;
 5016    }
 5017  } else {
 5018    _L: /* CIL Label */ 
 5019    {
 5020    }
 5021    Extension->CheckedForGenericEpp = 1;
 5022  }
 5023  {
 5024  }
 5025  {
 5026  PptDetectBytePort(Extension);
 5027  }
 5028  if (Extension->PnpInfo.HardwareCapabilities & 11UL) {
 5029    {
 5030    }
 5031    return (0L);
 5032  } else {
 5033
 5034  }
 5035  {
 5036  }
 5037  return (-1073741810L);
 5038}
 5039}
 5040void PptDetectEcpPort(PDEVICE_EXTENSION Extension ) 
 5041{ PUCHAR Controller ;
 5042  PUCHAR wPortDCR ;
 5043  PUCHAR wPortECR ;
 5044  UCHAR ecrLast ;
 5045  UCHAR ecr ;
 5046  UCHAR dcr ;
 5047
 5048  {
 5049  Controller = Extension->PortInfo.Controller;
 5050  wPortDCR = Controller + 2;
 5051  if ((unsigned int )((PUCHAR )0) == (unsigned int )Extension->PnpInfo.EcpController) {
 5052    {
 5053    }
 5054    return;
 5055  } else {
 5056
 5057  }
 5058  wPortECR = Extension->PnpInfo.EcpController + 2;
 5059  {
 5060  }
 5061  {
 5062  }
 5063  {
 5064  ecr = READ_PORT_UCHAR(wPortECR);
 5065  ecrLast = ecr;
 5066  }
 5067  {
 5068  }
 5069  {
 5070  dcr = (unsigned char)14;
 5071  WRITE_PORT_UCHAR(wPortDCR, dcr);
 5072  ecr = READ_PORT_UCHAR(wPortECR);
 5073  ecrLast = ecr;
 5074  }
 5075  {
 5076  }
 5077  if (((int )ecr & 3) == 3) {
 5078    goto _L;
 5079  } else {
 5080    if ((int )ecrLast == 255) {
 5081      _L: /* CIL Label */ 
 5082      {
 5083      }
 5084      {
 5085      dcr = (unsigned char)12;
 5086      WRITE_PORT_UCHAR(wPortDCR, dcr);
 5087      }
 5088      return;
 5089    } else {
 5090
 5091    }
 5092  }
 5093  if (((int )ecr & 3) == 2) {
 5094    {
 5095    dcr = (unsigned char)12;
 5096    WRITE_PORT_UCHAR(wPortDCR, dcr);
 5097    ecr = READ_PORT_UCHAR(wPortECR);
 5098    }
 5099    if (((int )ecr & 3) == 0) {
 5100      {
 5101      }
 5102      {
 5103      dcr = (unsigned char)12;
 5104      WRITE_PORT_UCHAR(wPortDCR, dcr);
 5105      }
 5106      return;
 5107    } else {
 5108
 5109    }
 5110  } else {
 5111
 5112  }
 5113  {
 5114  WRITE_PORT_UCHAR(wPortECR, 20);
 5115  ecr = READ_PORT_UCHAR(wPortECR);
 5116  }
 5117  if (! (((int )ecr & 3) == 1)) {
 5118    {
 5119    }
 5120    {
 5121    dcr = (unsigned char)12;
 5122    WRITE_PORT_UCHAR(wPortDCR, dcr);
 5123    }
 5124    return;
 5125  } else {
 5126
 5127  }
 5128  {
 5129  WRITE_PORT_UCHAR(wPortECR, ecrLast);
 5130  ecrLast = READ_PORT_UCHAR(wPortECR);
 5131  ecr = (unsigned char )((int )ecrLast & 31);
 5132  WRITE_PORT_UCHAR(wPortECR, (unsigned char )((int )ecr | 192));
 5133  PptDetermineFifoWidth(Extension);
 5134  }
 5135  if (0UL != Extension->PnpInfo.FifoWidth) {
 5136    {
 5137    Extension->PnpInfo.HardwareCapabilities |= 1UL;
 5138    PptDetermineFifoDepth(Extension);
 5139    }
 5140    {
 5141    }
 5142  } else {
 5143
 5144  }
 5145  {
 5146  WRITE_PORT_UCHAR(wPortECR, ecrLast);
 5147  }
 5148  return;
 5149}
 5150}
 5151void PptDetectEppPortIfDot3DevicePresent(PDEVICE_EXTENSION Extension ) 
 5152{ NTSTATUS status ;
 5153  PUCHAR Controller ;
 5154  UCHAR Reverse ;
 5155  UCHAR Forward ;
 5156  BOOLEAN daisyChainDevicePresent ;
 5157  PARALLEL_1284_COMMAND Command ;
 5158
 5159  {
 5160  Controller = Extension->PortInfo.Controller;
 5161  Reverse = (unsigned char)38;
 5162  Forward = (unsigned char)6;
 5163  daisyChainDevicePresent = 0;
 5164  if (0UL == Extension->PnpInfo.Ieee1284_3DeviceCount) {
 5165    {
 5166    }
 5167    return;
 5168  } else {
 5169
 5170  }
 5171  {
 5172  Command.ID = 0;
 5173  Command.Port = 0;
 5174  Command.CommandFlags = 2UL;
 5175  status = PptTrySelectDevice(Extension, & Command);
 5176  }
 5177  if (! (status >= 0L)) {
 5178    {
 5179    }
 5180    return;
 5181  } else {
 5182
 5183  }
 5184  {
 5185  PptDetectEppPort(Extension);
 5186  Command.ID = 0;
 5187  Command.Port = 0;
 5188  Command.CommandFlags = 2UL;
 5189  status = PptDeselectDevice(Extension, & Command);
 5190  }
 5191  if (! (status >= 0L)) {
 5192    {
 5193    }
 5194  } else {
 5195    {
 5196    }
 5197  }
 5198  return;
 5199}
 5200}
 5201void PptDetectEppPortIfUserRequested(PDEVICE_EXTENSION Extension ) 
 5202{ ULONG RequestEppTest ;
 5203
 5204  {
 5205  RequestEppTest = 0;
 5206  if (RequestEppTest) {
 5207    {
 5208    PptDetectEppPort(Extension);
 5209    }
 5210  } else {
 5211
 5212  }
 5213  return;
 5214}
 5215}
 5216void PptDetectEppPort(PDEVICE_EXTENSION Extension ) 
 5217{ PUCHAR Controller ;
 5218  UCHAR dcr ;
 5219  UCHAR i = __VERIFIER_nondet_char() ;
 5220  UCHAR Reverse ;
 5221  UCHAR Forward ;
 5222  BOOLEAN daisyChainDevicePresent ;
 5223  ULONG DisableEppTest ;
 5224  UCHAR tmp ;
 5225
 5226  {
 5227  Reverse = (unsigned char)38;
 5228  Forward = (unsigned char)6;
 5229  daisyChainDevicePresent = 0;
 5230  DisableEppTest = 0;
 5231  {
 5232  }
 5233  {
 5234  Controller = Extension->PortInfo.Controller;
 5235  dcr = READ_PORT_UCHAR(Controller + 2);
 5236  Extension->PnpInfo.HardwareCapabilities |= 2UL;
 5237  }
 5238  {
 5239  }
 5240  {
 5241  PptEcrSetMode(Extension, 148);
 5242  WRITE_PORT_UCHAR(Controller + 2, Reverse);
 5243  KeStallExecutionProcessor(5);
 5244  WRITE_PORT_UCHAR(Controller + 4, i);
 5245  WRITE_PORT_UCHAR(Controller + 2, Forward);
 5246  KeStallExecutionProcessor(5);
 5247  tmp = READ_PORT_UCHAR(Controller);
 5248  }
 5249  if ((int )tmp != (int )i) {
 5250    Extension->PnpInfo.HardwareCapabilities &= 4294967293UL;
 5251  } else {
 5252
 5253  }
 5254  {
 5255  PptEcrClearMode(Extension);
 5256  WRITE_PORT_UCHAR(Controller + 2, dcr);
 5257  Extension->CheckedForGenericEpp = 1;
 5258  }
 5259  if (Extension->PnpInfo.HardwareCapabilities & 2UL) {
 5260    {
 5261    }
 5262  } else {
 5263    {
 5264    }
 5265  }
 5266  return;
 5267}
 5268}
 5269void PptDetectBytePort(PDEVICE_EXTENSION Extension ) 
 5270{ NTSTATUS Status ;
 5271
 5272  {
 5273  Status = 0L;
 5274  {
 5275  }
 5276  {
 5277  Status = PptSetByteMode(Extension, 52);
 5278  }
 5279  if (Status >= 0L) {
 5280    {
 5281    }
 5282    Extension->PnpInfo.HardwareCapabilities |= 8UL;
 5283  } else {
 5284    {
 5285    }
 5286  }
 5287  {
 5288  PptClearByteMode(Extension);
 5289  }
 5290  return;
 5291}
 5292}
 5293void PptDetermineFifoDepth(PDEVICE_EXTENSION Extension ) 
 5294{ PUCHAR Controller ;
 5295  PUCHAR wPortECR ;
 5296  PUCHAR wPortDFIFO ;
 5297  UCHAR ecr ;
 5298  UCHAR ecrLast ;
 5299  ULONG wFifoDepth ;
 5300  UCHAR writeFifoDepth ;
 5301  UCHAR readFifoDepth ;
 5302  ULONG limitCount ;
 5303  UCHAR testData ;
 5304  UCHAR tmp ;
 5305  UCHAR tmp___0 ;
 5306
 5307  {
 5308  {
 5309  Controller = Extension->PortInfo.Controller;
 5310  wPortECR = Extension->PnpInfo.EcpController + 2;
 5311  wPortDFIFO = Extension->PnpInfo.EcpController;
 5312  wFifoDepth = 0;
 5313  ecrLast = READ_PORT_UCHAR(wPortECR);
 5314  WRITE_PORT_UCHAR(wPortECR, 212);
 5315  ecr = READ_PORT_UCHAR(wPortECR);
 5316  }
 5317  if (((int )ecr & 3) == 1) {
 5318    writeFifoDepth = 0;
 5319    limitCount = 0;
 5320    {
 5321    while (1) {
 5322      while_148_continue: /* CIL Label */ ;
 5323      {
 5324      tmp = READ_PORT_UCHAR(wPortECR);
 5325      }
 5326      if (((int )tmp & 3) != 2) {
 5327        if (limitCount <= 4098UL) {
 5328
 5329        } else {
 5330          goto while_148_break;
 5331        }
 5332      } else {
 5333        goto while_148_break;
 5334      }
 5335      {
 5336      WRITE_PORT_UCHAR(wPortDFIFO, (unsigned char )((int )writeFifoDepth & 255));
 5337      writeFifoDepth = (UCHAR )((int )writeFifoDepth + 1);
 5338      limitCount += 1UL;
 5339      }
 5340    }
 5341    while_148_break: /* CIL Label */ ;
 5342    }
 5343    {
 5344    }
 5345    readFifoDepth = 0;
 5346    limitCount = 0;
 5347    {
 5348    while (1) {
 5349      while_150_continue: /* CIL Label */ ;
 5350      {
 5351      tmp___0 = READ_PORT_UCHAR(wPortECR);
 5352      }
 5353      if (((int )tmp___0 & 3) != 1) {
 5354        if (limitCount <= 4098UL) {
 5355
 5356        } else {
 5357          goto while_150_break;
 5358        }
 5359      } else {
 5360        goto while_150_break;
 5361      }
 5362      {
 5363      testData = READ_PORT_UCHAR(wPortDFIFO);
 5364      }
 5365      if ((int )testData != ((int )readFifoDepth & 255)) {
 5366        {
 5367        WRITE_PORT_UCHAR(wPortECR, ecrLast);
 5368        }
 5369        {
 5370        }
 5371        return;
 5372      } else {
 5373
 5374      }
 5375      readFifoDepth = (UCHAR )((int )readFifoDepth + 1);
 5376      limitCount += 1UL;
 5377    }
 5378    while_150_break: /* CIL Label */ ;
 5379    }
 5380    {
 5381    }
 5382    if ((int )writeFifoDepth == (int )readFifoDepth) {
 5383      wFifoDepth = readFifoDepth;
 5384    } else {
 5385      {
 5386      WRITE_PORT_UCHAR(wPortECR, ecrLast);
 5387      }
 5388      {
 5389      }
 5390      return;
 5391    }
 5392  } else {
 5393    {
 5394    }
 5395    {
 5396    WRITE_PORT_UCHAR(wPortECR, ecrLast);
 5397    }
 5398    return;
 5399  }
 5400  {
 5401  WRITE_PORT_UCHAR(wPortECR, ecrLast);
 5402  Extension->PnpInfo.FifoDepth = wFifoDepth;
 5403  }
 5404  return;
 5405}
 5406}
 5407void PptDetermineFifoWidth(PDEVICE_EXTENSION Extension ) 
 5408{ PUCHAR Controller ;
 5409  UCHAR bConfigA ;
 5410  PUCHAR wPortECR ;
 5411
 5412  {
 5413  {
 5414  }
 5415  {
 5416  Controller = Extension->PortInfo.Controller;
 5417  wPortECR = Extension->PnpInfo.EcpController + 2;
 5418  WRITE_PORT_UCHAR(wPortECR, 244);
 5419  bConfigA = READ_PORT_UCHAR(Extension->PnpInfo.EcpController);
 5420  Extension->PnpInfo.FifoWidth = (unsigned long )(((int )bConfigA & 112) >> 4);
 5421  WRITE_PORT_UCHAR(wPortECR, 20);
 5422  }
 5423  return;
 5424}
 5425}
 5426NTSTATUS PptSetChipMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) 
 5427{ NTSTATUS Status ;
 5428  UCHAR EcrMode ;
 5429
 5430  {
 5431  Status = 0L;
 5432  EcrMode = (unsigned char )((int )ChipMode & -32);
 5433  {
 5434  }
 5435  if (Extension->PnpInfo.CurrentMode != 0UL) {
 5436    {
 5437    }
 5438    Status = -1073741436L;
 5439    goto ExitSetChipModeNoChange;
 5440  } else {
 5441
 5442  }
 5443  if (Extension_FilterMode) {
 5444    {
 5445    }
 5446    {
 5447    Status = (*(Extension->ChipInfo.ParChipSetMode))(Extension->ChipInfo.Context,
 5448                                                     ChipMode);
 5449    }
 5450  } else {
 5451    {
 5452    }
 5453    if ((int )EcrMode == 96) {
 5454      if ((Extension->PnpInfo.HardwareCapabilities & 1UL) ^ 1UL) {
 5455        {
 5456        }
 5457        return (-1073741810L);
 5458      } else {
 5459
 5460      }
 5461      {
 5462      Status = PptEcrSetMode(Extension, ChipMode);
 5463      }
 5464      goto ExitSetChipModeWithChanges;
 5465    } else {
 5466
 5467    }
 5468    if ((int )EcrMode == 128) {
 5469      if ((Extension->PnpInfo.HardwareCapabilities & 2UL) ^ 2UL) {
 5470        {
 5471        }
 5472        return (-1073741810L);
 5473      } else {
 5474
 5475      }
 5476      {
 5477      Status = PptEcrSetMode(Extension, ChipMode);
 5478      }
 5479      goto ExitSetChipModeWithChanges;
 5480    } else {
 5481
 5482    }
 5483    if ((int )EcrMode == 32) {
 5484      if ((Extension->PnpInfo.HardwareCapabilities & 8UL) ^ 8UL) {
 5485        {
 5486        }
 5487        return (-1073741810L);
 5488      } else {
 5489
 5490      }
 5491      {
 5492      Status = PptSetByteMode(Extension, ChipMode);
 5493      }
 5494      goto ExitSetChipModeWithChanges;
 5495    } else {
 5496
 5497    }
 5498  }
 5499  ExitSetChipModeWithChanges: 
 5500  if (Status >= 0L) {
 5501    {
 5502    }
 5503    Extension->PnpInfo.CurrentMode = EcrMode;
 5504  } else {
 5505    {
 5506    }
 5507  }
 5508  ExitSetChipModeNoChange: 
 5509  {
 5510  }
 5511  return (Status);
 5512}
 5513}
 5514NTSTATUS PptClearChipMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) 
 5515{ NTSTATUS Status ;
 5516  ULONG EcrMode ;
 5517
 5518  {
 5519  Status = -1073741823L;
 5520  EcrMode = (int )ChipMode & -32;
 5521  {
 5522  }
 5523  if (EcrMode != Extension->PnpInfo.CurrentMode) {
 5524    {
 5525    }
 5526    Status = -1073741436L;
 5527    goto ExitClearChipModeNoChange;
 5528  } else {
 5529
 5530  }
 5531  if (Extension_FilterMode) {
 5532    {
 5533    }
 5534    {
 5535    Status = (*(Extension->ChipInfo.ParChipClearMode))(Extension->ChipInfo.Context,
 5536                                                       ChipMode);
 5537    }
 5538  } else {
 5539    {
 5540    }
 5541    if (EcrMode == 96UL) {
 5542      {
 5543      Status = PptEcrClearMode(Extension);
 5544      }
 5545      goto ExitClearChipModeWithChanges;
 5546    } else {
 5547
 5548    }
 5549    if (EcrMode == 128UL) {
 5550      {
 5551      Status = PptEcrClearMode(Extension);
 5552      }
 5553      goto ExitClearChipModeWithChanges;
 5554    } else {
 5555
 5556    }
 5557    if (EcrMode == 32UL) {
 5558      {
 5559      Status = PptClearByteMode(Extension);
 5560      }
 5561      goto ExitClearChipModeWithChanges;
 5562    } else {
 5563
 5564    }
 5565  }
 5566  ExitClearChipModeWithChanges: 
 5567  if (Status >= 0L) {
 5568    {
 5569    }
 5570    Extension->PnpInfo.CurrentMode = 0;
 5571  } else {
 5572
 5573  }
 5574  ExitClearChipModeNoChange: 
 5575  {
 5576  }
 5577  return (Status);
 5578}
 5579}
 5580NTSTATUS PptEcrSetMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) 
 5581{ UCHAR ecr ;
 5582  PUCHAR Controller ;
 5583  PUCHAR wPortECR ;
 5584
 5585  {
 5586  {
 5587  }
 5588  Controller = Extension->PortInfo.Controller;
 5589  wPortECR = Extension->PnpInfo.EcpController + 2;
 5590  {
 5591  }
 5592  {
 5593  ecr = READ_PORT_UCHAR(wPortECR);
 5594  Extension->EcrPortData = ecr;
 5595  ecr = (int )ecr & 31;
 5596  WRITE_PORT_UCHAR(wPortECR, (unsigned char )((int )ecr | 32));
 5597  WRITE_PORT_UCHAR(wPortECR, ChipMode);
 5598  }
 5599  {
 5600  }
 5601  return (0L);
 5602}
 5603}
 5604NTSTATUS PptSetByteMode(PDEVICE_EXTENSION Extension , UCHAR ChipMode ) 
 5605{ NTSTATUS Status ;
 5606
 5607  {
 5608  if (Extension->PnpInfo.HardwareCapabilities & 1UL) {
 5609    {
 5610    Status = PptEcrSetMode(Extension, ChipMode);
 5611    }
 5612  } else {
 5613
 5614  }
 5615  {
 5616  Status = PptCheckByteMode(Extension);
 5617  }
 5618  return (Status);
 5619}
 5620}
 5621NTSTATUS PptClearByteMode(PDEVICE_EXTENSION Extension ) 
 5622{ NTSTATUS Status ;
 5623
 5624  {
 5625  Status = 0L;
 5626  if (Extension->PnpInfo.HardwareCapabilities & 1UL) {
 5627    {
 5628    Status = PptEcrClearMode(Extension);
 5629    }
 5630  } else {
 5631
 5632  }
 5633  return (Status);
 5634}
 5635}
 5636NTSTATUS PptCheckByteMode(PDEVICE_EXTENSION Extension ) 
 5637{ PUCHAR Controller ;
 5638  UCHAR dcr ;
 5639  UCHAR tmp ;
 5640  UCHAR tmp___0 ;
 5641
 5642  {
 5643  {
 5644  Controller = Extension->PortInfo.Controller;
 5645  dcr = READ_PORT_UCHAR(Controller + 2);
 5646  WRITE_PORT_UCHAR(Controller + 2, (unsigned char )((int )dcr | 32));
 5647  WRITE_PORT_UCHAR(Controller, (unsigned char)85);
 5648  tmp___0 = READ_PORT_UCHAR(Controller);
 5649  }
 5650  if ((int )tmp___0 == 85) {
 5651    {
 5652    WRITE_PORT_UCHAR(Controller, (unsigned char)170);
 5653    tmp = READ_PORT_UCHAR(Controller);
 5654    }
 5655    if ((int )tmp == 170) {
 5656      return (-1073741823L);
 5657    } else {
 5658
 5659    }
 5660  } else {
 5661
 5662  }
 5663  {
 5664  WRITE_PORT_UCHAR(Controller + 2, dcr);
 5665  }
 5666  return (0L);
 5667}
 5668}
 5669NTSTATUS PptEcrClearMode(PDEVICE_EXTENSION Extension ) 
 5670{ UCHAR ecr ;
 5671  PUCHAR Controller ;
 5672  PUCHAR wPortECR ;
 5673
 5674  {
 5675  {
 5676  Controller = Extension->PortInfo.Controller;
 5677  ecr = Extension->EcrPortData;
 5678  Extension->EcrPortData = 0;
 5679  wPortECR = Extension->PnpInfo.EcpController + 2;
 5680  WRITE_PORT_UCHAR(wPortECR, (unsigned char )((int )ecr & 31));
 5681  WRITE_PORT_UCHAR(wPortECR, ecr);
 5682  }
 5683  return (0L);
 5684}
 5685}
 5686NTSTATUS PptFindNatChip(PDEVICE_EXTENSION Extension ) 
 5687{ BOOLEAN found ;
 5688  BOOLEAN OkToLook ;
 5689  BOOLEAN Conflict ;
 5690  PUCHAR ChipAddr[4] ;
 5691  PUCHAR AddrList[4] ;
 5692  PUCHAR PortAddr ;
 5693  ULONG_PTR Port ;
 5694  UCHAR SaveIdx ;
 5695  UCHAR cr ;
 5696  UCHAR ii ;
 5697  NTSTATUS Status ;
 5698  ULONG ResourceDescriptorCount ;
 5699  ULONG ResourcesSize ;
 5700  PCM_RESOURCE_LIST Resources ;
 5701  ULONG NationalChecked ;
 5702  ULONG NationalChipFound ;
 5703  PVOID tmp ;
 5704  UCHAR tmp___0 ;
 5705  UCHAR tmp___1 ;
 5706  UCHAR tmp___2 ;
 5707  UCHAR tmp___3 ;
 5708  UCHAR tmp___4 ;
 5709  UCHAR tmp___5 ;
 5710  UCHAR tmp___6 ;
 5711  UCHAR tmp___7 ;
 5712  PDEVICE_OBJECT pdo ;
 5713
 5714  {
 5715  found = 0;
 5716  OkToLook = 0;
 5717  ChipAddr[0] = (UCHAR *)920;
 5718  ChipAddr[1] = (UCHAR *)622;
 5719  ChipAddr[2] = (UCHAR *)348;
 5720  ChipAddr[3] = (UCHAR *)46;
 5721  AddrList[0] = (UCHAR *)888;
 5722  AddrList[1] = (UCHAR *)956;
 5723  AddrList[2] = (UCHAR *)632;
 5724  AddrList[3] = (UCHAR *)0;
 5725  NationalChecked = 0;
 5726  NationalChipFound = 0;
 5727  if ((int )Extension->NationalChecked == 1) {
 5728    {
 5729    }
 5730    return (0L);
 5731  } else {
 5732
 5733  }
 5734  Extension->NationalChecked = 1;
 5735  if (NationalChecked) {
 5736    if (NationalChipFound) {
 5737      Extension->NationalChipFound = 1;
 5738    } else {
 5739      Extension->NationalChipFound = 0;
 5740    }
 5741    return (0L);
 5742  } else {
 5743
 5744  }
 5745  {
 5746  ResourceDescriptorCount = sizeof(ChipAddr) / sizeof(ULONG );
 5747  ResourcesSize = (ULONG )sizeof(CM_RESOURCE_LIST ) + (ResourceDescriptorCount - 1UL) * (ULONG )sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR );
 5748  tmp = ExAllocatePoolWithTag(0, ResourcesSize, 1349673296UL);
 5749  Resources = (struct _CM_RESOURCE_LIST *)tmp;
 5750  }
 5751  if ((unsigned int )Resources == (unsigned int )((void *)0)) {
 5752    {
 5753    }
 5754    return (-1073741823L);
 5755  } else {
 5756
 5757  }
 5758  {
 5759  memset(Resources, 0, ResourcesSize);
 5760  Status = PptBuildResourceList(Extension, sizeof(ChipAddr) / sizeof(ULONG ), ChipAddr,
 5761                                Resources);
 5762  }
 5763  if (! (Status >= 0L)) {
 5764    {
 5765    }
 5766    {
 5767/*     ExFreePool(Resources); */ /* INLINED */
 5768    }
 5769    return (Status);
 5770  } else {
 5771
 5772  }
 5773  {
 5774  Status = IoReportResourceUsage((void *)0, Extension->DriverObject, Resources, sizeof(Resources),
 5775                                 Extension->DeviceObject, (void *)0, 0, 0, & Conflict);
 5776/*   ExFreePool(Resources); */ /* INLINED */
 5777  }
 5778  if (! (Status >= 0L)) {
 5779    {
 5780    }
 5781    return (Status);
 5782  } else {
 5783
 5784  }
 5785  if (Conflict) {
 5786    {
 5787    }
 5788    return (-1073741823L);
 5789  } else {
 5790
 5791  }
 5792  ii = 0;
 5793  {
 5794  while (1) {
 5795    while_180_continue: /* CIL Label */ ;
 5796    if (! found) {
 5797      if ((int )ii < 4) {
 5798
 5799      } else {
 5800        goto while_180_break;
 5801      }
 5802    } else {
 5803      goto while_180_break;
 5804    }
 5805    {
 5806    PortAddr = ChipAddr[ii];
 5807    tmp___1 = READ_PORT_UCHAR(PortAddr);
 5808    }
 5809    if ((int )tmp___1 == 136) {
 5810      {
 5811      tmp___2 = READ_PORT_UCHAR(PortAddr);
 5812      }
 5813      if ((int )tmp___2 < 32) {
 5814        OkToLook = 1;
 5815      } else {
 5816        goto _L;
 5817      }
 5818    } else {
 5819      _L: /* CIL Label */ 
 5820      {
 5821      READ_PORT_UCHAR(PortAddr);
 5822      cr = READ_PORT_UCHAR(PortAddr);
 5823      }
 5824      if ((int )cr != 255) {
 5825        {
 5826        tmp___0 = READ_PORT_UCHAR(PortAddr);
 5827        }
 5828        if ((int )tmp___0 == (int )cr) {
 5829          OkToLook = 1;
 5830        } else {
 5831
 5832        }
 5833      } else {
 5834
 5835      }
 5836    }
 5837    if (OkToLook) {
 5838      {
 5839      OkToLook = 0;
 5840      WRITE_PORT_UCHAR(PortAddr, 8);
 5841      cr = READ_PORT_UCHAR(PortAddr);
 5842      }
 5843      if ((int )cr == 8) {
 5844        {
 5845        tmp___3 = READ_PORT_UCHAR(PortAddr + 1);
 5846        cr = (unsigned char )((int )tmp___3 & 240);
 5847        }
 5848        if ((int )cr == 16) {
 5849          goto _L___0;
 5850        } else {
 5851          if ((int )cr == 80) {
 5852            goto _L___0;
 5853          } else {
 5854            if ((int )cr == 112) {
 5855              goto _L___0;
 5856            } else {
 5857              if ((int )cr == 48) {
 5858                goto _L___0;
 5859              } else {
 5860                if ((int )cr == 32) {
 5861                  goto _L___0;
 5862                } else {
 5863                  if ((int )cr == 144) {
 5864                    goto _L___0;
 5865                  } else {
 5866                    if ((int )cr == 176) {
 5867                      goto _L___0;
 5868                    } else {
 5869                      if ((int )cr == 96) {
 5870                        _L___0: /* CIL Label */ 
 5871                        {
 5872                        found = 1;
 5873                        WRITE_PORT_UCHAR(PortAddr, 1);
 5874                        tmp___4 = READ_PORT_UCHAR(PortAddr + 1);
 5875                        Port = (int )tmp___4 & 3;
 5876                        }
 5877                        if ((unsigned int )Extension->PortInfo.Controller == (unsigned int )AddrList[Port]) {
 5878                          Extension->NationalChipFound = 1;
 5879                        } else {
 5880
 5881                        }
 5882                      } else {
 5883
 5884                      }
 5885                    }
 5886                  }
 5887                }
 5888              }
 5889            }
 5890          }
 5891        }
 5892      } else {
 5893
 5894      }
 5895    } else {
 5896
 5897    }
 5898    if (! found) {
 5899      {
 5900      SaveIdx = READ_PORT_UCHAR(PortAddr);
 5901      WRITE_PORT_UCHAR(PortAddr, 32);
 5902      WRITE_PORT_UCHAR(PortAddr + 1, 0);
 5903      tmp___5 = READ_PORT_UCHAR(PortAddr + 1);
 5904      cr = (unsigned char )((int )tmp___5 & 248);
 5905      }
 5906      if ((int )cr == 192) {
 5907        goto _L___1;
 5908      } else {
 5909        if ((int )cr == 160) {
 5910          _L___1: /* CIL Label */ 
 5911          {
 5912          found = 1;
 5913          WRITE_PORT_UCHAR(PortAddr, 7);
 5914          WRITE_PORT_UCHAR(PortAddr + 1, 4);
 5915          WRITE_PORT_UCHAR(PortAddr, 96);
 5916          tmp___6 = READ_PORT_UCHAR(PortAddr + 1);
 5917          Port = (unsigned long )(((int )tmp___6 << 8) & 65280);
 5918          WRITE_PORT_UCHAR(PortAddr, 97);
 5919          tmp___7 = READ_PORT_UCHAR(PortAddr + 1);
 5920          Port |= (unsigned long )tmp___7;
 5921          }
 5922          if ((unsigned int )Extension->PortInfo.Controller == (unsigned int )((UCHAR *)Port)) {
 5923            Extension->NationalChipFound = 1;
 5924          } else {
 5925
 5926          }
 5927        } else {
 5928          {
 5929          WRITE_PORT_UCHAR(PortAddr, SaveIdx);
 5930          }
 5931        }
 5932      }
 5933    } else {
 5934
 5935    }
 5936    ii = (UCHAR )((int )ii + 1);
 5937  }
 5938  while_180_break: /* CIL Label */ ;
 5939  }
 5940  pdo = Extension->PhysicalDeviceObject;
 5941  NationalChecked = 1;
 5942  if (Extension->NationalChipFound) {
 5943    NationalChipFound = 1;
 5944  } else {
 5945    NationalChipFound = 0;
 5946  }
 5947  {
 5948  Status = IoReportResourceUsage((void *)0, Extension->DriverObject, (void *)0, 0,
 5949                                 Extension->DeviceObject, (void *)0, 0, 0, & Conflict);
 5950  }
 5951  {
 5952  }
 5953  return (Status);
 5954}
 5955}
 5956NTSTATUS PptBuildResourceList(PDEVICE_EXTENSION Extension , ULONG Partial , PULONG Addresses ,
 5957                              PCM_RESOURCE_LIST Resources ) 
 5958{ UCHAR i ;
 5959
 5960  {
 5961  Resources->Count = 1;
 5962  Resources->List[0].InterfaceType = Extension->InterfaceType;
 5963  Resources->List[0].BusNumber = Extension->BusNumber;
 5964  Resources->List[0].PartialResourceList.Version = 0;
 5965  Resources->List[0].PartialResourceList.Revision = 0;
 5966  Resources->List[0].PartialResourceList.Count = Partial;
 5967  i = 0;
 5968  {
 5969  while (1) {
 5970    while_182_continue: /* CIL Label */ ;
 5971    if ((ULONG )i < Partial) {
 5972
 5973    } else {
 5974      goto while_182_break;
 5975    }
 5976    Resources->List[0].PartialResourceList.PartialDescriptors[i].Type = 1;
 5977    Resources->List[0].PartialResourceList.PartialDescriptors[i].ShareDisposition = 2;
 5978    Resources->List[0].PartialResourceList.PartialDescriptors[i].Flags = 1;
 5979    Resources->List[0].PartialResourceList.PartialDescriptors[i].u.Port.Start.QuadPart = *(Addresses + i);
 5980    Resources->List[0].PartialResourceList.PartialDescriptors[i].u.Port.Length = 2UL;
 5981    i = (UCHAR )((int )i + 1);
 5982  }
 5983  while_182_break: /* CIL Label */ ;
 5984  }
 5985  return (0L);
 5986}
 5987}
 5988#pragma once
 5989#pragma once
 5990#pragma once
 5991#pragma once
 5992#pragma warning(push)
 5993#pragma warning(disable:4035)
 5994#pragma warning(pop)
 5995#pragma once
 5996#pragma warning(disable:4103)
 5997#pragma warning(disable:4103)
 5998#pragma warning(push)
 5999#pragma warning(disable:4035)
 6000#pragma warning(pop)
 6001#pragma warning(disable:4035)
 6002#pragma warning(push)
 6003#pragma warning(disable:4164)
 6004#pragma function(_enable)
 6005#pragma function(_disable)
 6006#pragma warning(pop)
 6007#pragma warning(disable:4103)
 6008#pragma warning(disable:4103)
 6009#pragma warning(disable:4103)
 6010#pragma warning(disable:4103)
 6011#pragma warning(disable:4103)
 6012#pragma warning(disable:4103)
 6013#pragma warning(disable:4200)
 6014#pragma warning(default:4200)
 6015#pragma once
 6016#pragma once
 6017  struct _GUID  const  GUID_PARALLEL_DEVICE  =    {2549575408U, 63619, 4560, {175, 31, 0, 0, 248, 0, 132, 92}};
 6018  struct _GUID  const  GUID_PARCLASS_DEVICE  =    {2166343333U, 63272, 4560, {165, 55, 0, 0, 248, 117, 62, 209}};
 6019ULONG PptDebugLevel  =    0UL;
 6020ULONG PptBreakOn  =    0UL;
 6021UNICODE_STRING RegistryPath  =    {0, 0, 0};
 6022LONG PortInfoReferenceCount  =    -1L;
 6023PFAST_MUTEX PortInfoMutex  =    (void *)0;
 6024union _LARGE_INTEGER  const  PhysicalZero  =    {{0, 0L}};
 6025UCHAR PptDot3Retries  =    5;
 6026#pragma once
 6027#pragma once
 6028#pragma once
 6029#pragma once
 6030#pragma warning(push)
 6031#pragma warning(disable:4035)
 6032#pragma warning(pop)
 6033#pragma once
 6034#pragma warning(disable:4103)
 6035#pragma warning(disable:4103)
 6036#pragma warning(push)
 6037#pragma warning(disable:4035)
 6038#pragma warning(pop)
 6039#pragma warning(disable:4035)
 6040#pragma warning(push)
 6041#pragma warning(disable:4164)
 6042#pragma function(_enable)
 6043#pragma function(_disable)
 6044#pragma warning(pop)
 6045#pragma warning(disable:4103)
 6046#pragma warning(disable:4103)
 6047#pragma warning(disable:4103)
 6048#pragma warning(disable:4103)
 6049#pragma warning(disable:4103)
 6050#pragma warning(disable:4103)
 6051#pragma warning(disable:4200)
 6052#pragma warning(default:4200)
 6053#pragma once
 6054NTSTATUS PptPnpFilterResourceRequirements(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6055NTSTATUS PptPnpQueryDeviceRelations(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6056NTSTATUS PptPnpQueryStopDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6057NTSTATUS PptPnpCancelStopDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6058NTSTATUS PptPnpStopDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6059NTSTATUS PptPnpQueryRemoveDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6060NTSTATUS PptPnpCancelRemoveDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6061NTSTATUS PptPnpRemoveDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6062NTSTATUS PptPnpSurpriseRemoval(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6063NTSTATUS PptPnpUnhandledIrp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6064NTSTATUS PptPnpStartDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) ;
 6065NTSTATUS PptPnpStartValidateResources(PDEVICE_OBJECT DeviceObject , BOOLEAN FoundPort ,
 6066                                      BOOLEAN FoundIrq , BOOLEAN FoundDma ) ;
 6067NTSTATUS PptPnpStartScanCmResourceList(PDEVICE_EXTENSION Extension , PIRP Irp , PBOOLEAN FoundPort ,
 6068                                       PBOOLEAN FoundIrq , PBOOLEAN FoundDma ) ;
 6069NTSTATUS PptPnpPassThroughPnpIrpAndReleaseRemoveLock(PDEVICE_EXTENSION Extension ,
 6070                                                     PIRP Irp ) ;
 6071void PptPnpFilterNukeIrqResourceDescriptors(PIO_RESOURCE_LIST IoResourceList ) ;
 6072void PptPnpFilterNukeIrqResourceDescriptorsFromAllLists(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) ;
 6073BOOLEAN PptPnpFilterExistsNonIrqResourceList(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) ;
 6074PVOID PptPnpFilterGetEndOfResourceRequirementsList(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) ;
 6075BOOLEAN PptPnpListContainsIrqResourceDescriptor(PIO_RESOURCE_LIST List ) ;
 6076void PptPnpFilterRemoveIrqResourceLists(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) ;
 6077NTSTATUS PptPnpBounceAndCatchPnpIrp(PDEVICE_EXTENSION Extension , PIRP Irp ) ;
 6078PDEVICE_RELATIONS PptPnpBuildRemovalRelations(PDEVICE_EXTENSION Extension ) 
 6079{ PDEVICE_RELATIONS relations ;
 6080  PLIST_ENTRY listHead ;
 6081  PLIST_ENTRY thisListEntry ;
 6082  PLIST_ENTRY firstListEntry ;
 6083  BOOLEAN done ;
 6084  PREMOVAL_RELATIONS_LIST_ENTRY node ;
 6085  ULONG count ;
 6086  ULONG i ;
 6087  PDEVICE_OBJECT pDevObj ;
 6088  PLIST_ENTRY _EX_Blink ;
 6089  PLIST_ENTRY _EX_Flink ;
 6090  PLIST_ENTRY _EX_Flink___0 ;
 6091  PLIST_ENTRY _EX_ListHead ;
 6092  PLIST_ENTRY _EX_Blink___0 ;
 6093  PLIST_ENTRY _EX_ListHead___0 ;
 6094  PVOID tmp ;
 6095  PLIST_ENTRY _EX_Blink___1 ;
 6096  PLIST_ENTRY _EX_Flink___1 ;
 6097  PLIST_ENTRY _EX_Blink___2 ;
 6098  PLIST_ENTRY _EX_ListHead___1 ;
 6099
 6100  {
 6101  relations = (void *)0;
 6102  listHead = & Extension->RemovalRelationsList;
 6103  thisListEntry = (void *)0;
 6104  firstListEntry = (void *)0;
 6105  done = 0;
 6106  node = (void *)0;
 6107  {
 6108  }
 6109  {
 6110/*   ExAcquireFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 6111  }
 6112  if ((unsigned int )listHead->Flink == (unsigned int )listHead) {
 6113    {
 6114    }
 6115    goto targetExit;
 6116  } else {
 6117
 6118  }
 6119  count = 0;
 6120  {
 6121  while (1) {
 6122    while_185_continue: /* CIL Label */ ;
 6123    if (! done) {
 6124
 6125    } else {
 6126      goto while_185_break;
 6127    }
 6128    thisListEntry = listHead->Flink;
 6129    _EX_Flink = (listHead->Flink)->Flink;
 6130    _EX_Blink = (listHead->Flink)->Blink;
 6131    _EX_Blink->Flink = _EX_Flink;
 6132    _EX_Flink->Blink = _EX_Blink;
 6133    node = (REMOVAL_RELATIONS_LIST_ENTRY *)((CHAR *)thisListEntry - (unsigned long )(& ((REMOVAL_RELATIONS_LIST_ENTRY *)0)->ListEntry));
 6134    if ((unsigned int )firstListEntry == (unsigned int )thisListEntry) {
 6135      _EX_ListHead = listHead;
 6136      _EX_Flink___0 = _EX_ListHead->Flink;
 6137      node->ListEntry.Flink = _EX_Flink___0;
 6138      node->ListEntry.Blink = _EX_ListHead;
 6139      _EX_Flink___0->Blink = & node->ListEntry;
 6140      _EX_ListHead->Flink = & node->ListEntry;
 6141      done = 1;
 6142      {
 6143      }
 6144    } else {
 6145      {
 6146      }
 6147      _EX_ListHead___0 = listHead;
 6148      _EX_Blink___0 = _EX_ListHead___0->Blink;
 6149      node->ListEntry.Flink = _EX_ListHead___0;
 6150      node->ListEntry.Blink = _EX_Blink___0;
 6151      _EX_Blink___0->Flink = & node->ListEntry;
 6152      _EX_ListHead___0->Blink = & node->ListEntry;
 6153      count += 1UL;
 6154    }
 6155    if (! firstListEntry) {
 6156      {
 6157      }
 6158      firstListEntry = thisListEntry;
 6159    } else {
 6160
 6161    }
 6162  }
 6163  while_185_break: /* CIL Label */ ;
 6164  }
 6165  {
 6166  }
 6167  {
 6168  tmp = ExAllocatePoolWithTag(1, (ULONG )sizeof(DEVICE_RELATIONS ) + (count - 1UL) * (ULONG )sizeof(PDEVICE_OBJECT ),
 6169                              1349673296UL);
 6170  relations = tmp;
 6171  }
 6172  if (! relations) {
 6173    {
 6174    }
 6175    goto targetExit;
 6176  } else {
 6177
 6178  }
 6179  relations->Count = count;
 6180  i = 0;
 6181  {
 6182  while (1) {
 6183    while_191_continue: /* CIL Label */ ;
 6184    if (i < count) {
 6185
 6186    } else {
 6187      goto while_191_break;
 6188    }
 6189    thisListEntry = listHead->Flink;
 6190    _EX_Flink___1 = (listHead->Flink)->Flink;
 6191    _EX_Blink___1 = (listHead->Flink)->Blink;
 6192    _EX_Blink___1->Flink = _EX_Flink___1;
 6193    _EX_Flink___1->Blink = _EX_Blink___1;
 6194    node = (REMOVAL_RELATIONS_LIST_ENTRY *)((CHAR *)thisListEntry - (unsigned long )(& ((REMOVAL_RELATIONS_LIST_ENTRY *)0)->ListEntry));
 6195    {
 6196    }
 6197    {
 6198    pDevObj = node->DeviceObject;
 6199    ObfReferenceObject(pDevObj);
 6200    relations->Objects[i] = pDevObj;
 6201    _EX_ListHead___1 = listHead;
 6202    _EX_Blink___2 = _EX_ListHead___1->Blink;
 6203    node->ListEntry.Flink = _EX_ListHead___1;
 6204    node->ListEntry.Blink = _EX_Blink___2;
 6205    _EX_Blink___2->Flink = & node->ListEntry;
 6206    _EX_ListHead___1->Blink = & node->ListEntry;
 6207    i += 1UL;
 6208    }
 6209  }
 6210  while_191_break: /* CIL Label */ ;
 6211  }
 6212  targetExit: 
 6213  {
 6214/*   ExReleaseFastMutex(& Extension->ExtensionFastMutex); */ /* INLINED */
 6215  }
 6216  return (relations);
 6217}
 6218}
 6219NTSTATUS PptPnpStartScanPciCardCmResourceList(PDEVICE_EXTENSION Extension , PIRP Irp ,
 6220                                              PBOOLEAN FoundPort , PBOOLEAN FoundIrq ,
 6221                                              PBOOLEAN FoundDma ) 
 6222{ NTSTATUS status ;
 6223  PIO_STACK_LOCATION irpStack ;
 6224  PCM_RESOURCE_LIST ResourceList ;
 6225  PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor ;
 6226  PCM_PARTIAL_RESOURCE_LIST PartialResourceList ;
 6227  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResourceDescriptor ;
 6228  ULONG i ;
 6229  ULONG length ;
 6230
 6231  {
 6232  status = 0L;
 6233  irpStack = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 6234  {
 6235  }
 6236  *FoundPort = 0;
 6237  *FoundIrq = 0;
 6238  *FoundDma = 0;
 6239  ResourceList = irpStack->Parameters.StartDevice.AllocatedResourcesTranslated;
 6240  FullResourceDescriptor = & ResourceList->List[0];
 6241  if (FullResourceDescriptor) {
 6242    Extension->InterfaceType = FullResourceDescriptor->InterfaceType;
 6243    PartialResourceList = & FullResourceDescriptor->PartialResourceList;
 6244    i = 0;
 6245    {
 6246    while (1) {
 6247      while_194_continue: /* CIL Label */ ;
 6248      if (i < PartialResourceList->Count) {
 6249
 6250      } else {
 6251        goto while_194_break;
 6252      }
 6253      PartialResourceDescriptor = & PartialResourceList->PartialDescriptors[i];
 6254      if (PartialResourceDescriptor->Type == 1) {
 6255        goto switch_195_1;
 6256      } else {
 6257        if (PartialResourceDescriptor->Type == 6) {
 6258          goto switch_195_6;
 6259        } else {
 6260          if (PartialResourceDescriptor->Type == 2) {
 6261            goto switch_195_2;
 6262          } else {
 6263            if (PartialResourceDescriptor->Type == 4) {
 6264              goto switch_195_4;
 6265            } else {
 6266              {
 6267              goto switch_195_default;
 6268              if (0) {
 6269                switch_195_1: /* CIL Label */ 
 6270                length = PartialResourceDescriptor->u.Port.Length;
 6271                if (length == 8) {
 6272                  goto switch_196_8;
 6273                } else {
 6274                  if (length == 4) {
 6275                    goto switch_196_4;
 6276                  } else {
 6277                    {
 6278                    goto switch_196_default;
 6279                    if (0) {
 6280                      switch_196_8: /* CIL Label */ ;
 6281                      {
 6282                      }
 6283                      Extension->PortInfo.OriginalController = PartialResourceDescriptor->u.Port.Start;
 6284                      Extension->PortInfo.SpanOfController = PartialResourceDescriptor->u.Port.Length;
 6285                      Extension->PortInfo.Controller = (UCHAR *)((unsigned long )Extension->PortInfo.OriginalController.QuadPart);
 6286                      Extension->AddressSpace = PartialResourceDescriptor->Flags;
 6287                      *FoundPort = 1;
 6288                      goto switch_196_break;
 6289                      switch_196_4: /* CIL Label */ ;
 6290                      {
 6291                      }
 6292                      Extension->PnpInfo.OriginalEcpController = PartialResourceDescriptor->u.Port.Start;
 6293                      Extension->PnpInfo.SpanOfEcpController = PartialResourceDescriptor->u.Port.Length;
 6294                      Extension->PnpInfo.EcpController = (UCHAR *)((unsigned long )Extension->PnpInfo.OriginalEcpController.QuadPart);
 6295                      Extension->EcpAddressSpace = PartialResourceDescriptor->Flags;
 6296                      goto switch_196_break;
 6297                      switch_196_default: /* CIL Label */ ;
 6298                      {
 6299                      }
 6300                    } else {
 6301                      switch_196_break: /* CIL Label */ ;
 6302                    }
 6303                    }
 6304                  }
 6305                }
 6306                goto switch_195_break;
 6307                switch_195_6: /* CIL Label */ 
 6308                Extension->BusNumber = PartialResourceDescriptor->u.BusNumber.Start;
 6309                goto switch_195_break;
 6310                switch_195_2: /* CIL Label */ 
 6311                *FoundIrq = 1;
 6312                Extension->FoundInterrupt = 1;
 6313                Extension->InterruptLevel = (unsigned char )PartialResourceDescriptor->u.Interrupt.Level;
 6314                Extension->InterruptVector = PartialResourceDescriptor->u.Interrupt.Vector;
 6315                Extension->InterruptAffinity = PartialResourceDescriptor->u.Interrupt.Affinity;
 6316                if ((int )PartialResourceDescriptor->Flags & 1) {
 6317                  Extension->InterruptMode = 1;
 6318                } else {
 6319                  Extension->InterruptMode = 0;
 6320                }
 6321                goto switch_195_break;
 6322                switch_195_4: /* CIL Label */ 
 6323                *FoundDma = 1;
 6324                Extension->DmaChannel = PartialResourceDescriptor->u.Dma.Channel;
 6325                Extension->DmaPort = PartialResourceDescriptor->u.Dma.Port;
 6326                Extension->DmaWidth = PartialResourceDescriptor->Flags;
 6327                goto switch_195_break;
 6328                switch_195_default: /* CIL Label */ ;
 6329                goto switch_195_break;
 6330              } else {
 6331                switch_195_break: /* CIL Label */ ;
 6332              }
 6333              }
 6334            }
 6335          }
 6336        }
 6337      }
 6338      i += 1UL;
 6339    }
 6340    while_194_break: /* CIL Label */ ;
 6341    }
 6342  } else {
 6343
 6344  }
 6345  return (status);
 6346}
 6347}
 6348BOOLEAN PptIsPci(PDEVICE_EXTENSION Extension , PIRP Irp ) 
 6349{ NTSTATUS status ;
 6350  PIO_STACK_LOCATION irpStack ;
 6351  PCM_RESOURCE_LIST ResourceList ;
 6352  PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor ;
 6353  PCM_PARTIAL_RESOURCE_LIST PartialResourceList ;
 6354  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResourceDescriptor ;
 6355  ULONG i ;
 6356  ULONG portResourceDescriptorCount ;
 6357  BOOLEAN largePortRangeFound ;
 6358  ULONG rangeLength ;
 6359
 6360  {
 6361  status = 0L;
 6362  irpStack = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 6363  portResourceDescriptorCount = 0;
 6364  largePortRangeFound = 0;
 6365  ResourceList = irpStack->Parameters.StartDevice.AllocatedResourcesTranslated;
 6366  if ((unsigned int )ResourceList == (unsigned int )((void *)0)) {
 6367    {
 6368    }
 6369    return (0);
 6370  } else {
 6371
 6372  }
 6373  FullResourceDescriptor = & ResourceList->List[0];
 6374  if (FullResourceDescriptor) {
 6375    {
 6376    }
 6377    PartialResourceList = & FullResourceDescriptor->PartialResourceList;
 6378    i = 0;
 6379    {
 6380    while (1) {
 6381      while_202_continue: /* CIL Label */ ;
 6382      if (i < PartialResourceList->Count) {
 6383
 6384      } else {
 6385        goto while_202_break;
 6386      }
 6387      PartialResourceDescriptor = & PartialResourceList->PartialDescriptors[i];
 6388      if (PartialResourceDescriptor->Type == 1) {
 6389        goto switch_203_1;
 6390      } else {
 6391        {
 6392        goto switch_203_default;
 6393        if (0) {
 6394          switch_203_1: /* CIL Label */ 
 6395          rangeLength = PartialResourceDescriptor->u.Port.Length;
 6396          {
 6397          }
 6398          portResourceDescriptorCount += 1UL;
 6399          if (rangeLength > 8UL) {
 6400            {
 6401            }
 6402            largePortRangeFound = 1;
 6403          } else {
 6404
 6405          }
 6406          goto switch_203_break;
 6407          switch_203_default: /* CIL Label */ ;
 6408          {
 6409          }
 6410        } else {
 6411          switch_203_break: /* CIL Label */ ;
 6412        }
 6413        }
 6414      }
 6415      i += 1UL;
 6416    }
 6417    while_202_break: /* CIL Label */ ;
 6418    }
 6419  } else {
 6420
 6421  }
 6422  if (portResourceDescriptorCount > 2UL) {
 6423    goto _L;
 6424  } else {
 6425    if (1 == (int )largePortRangeFound) {
 6426      _L: /* CIL Label */ 
 6427      {
 6428      }
 6429      return (1);
 6430    } else {
 6431      {
 6432      }
 6433      return (0);
 6434    }
 6435  }
 6436}
 6437}
 6438void PptCompleteRequest(PIRP Irp , CCHAR PriorityBoost ) 
 6439{ 
 6440
 6441  {
 6442  {
 6443  IofCompleteRequest(Irp, PriorityBoost);
 6444  }
 6445  return;
 6446}
 6447}
 6448static PDRIVER_DISPATCH PptPnpDispatchFunctionTable[25]  ;
 6449void PptPnpInitDispatchFunctionTable(void) 
 6450{ ULONG i = __VERIFIER_nondet_long() ;
 6451
 6452  {
 6453  PptPnpDispatchFunctionTable[i] = & PptPnpUnhandledIrp;
 6454  PptPnpDispatchFunctionTable[0] = & PptPnpStartDevice;
 6455  PptPnpDispatchFunctionTable[13] = & PptPnpFilterResourceRequirements;
 6456  PptPnpDispatchFunctionTable[7] = & PptPnpQueryDeviceRelations;
 6457  PptPnpDispatchFunctionTable[5] = & PptPnpQueryStopDevice;
 6458  PptPnpDispatchFunctionTable[6] = & PptPnpCancelStopDevice;
 6459  PptPnpDispatchFunctionTable[4] = & PptPnpStopDevice;
 6460  PptPnpDispatchFunctionTable[1] = & PptPnpQueryRemoveDevice;
 6461  PptPnpDispatchFunctionTable[3] = & PptPnpCancelRemoveDevice;
 6462  PptPnpDispatchFunctionTable[2] = & PptPnpRemoveDevice;
 6463  PptPnpDispatchFunctionTable[23] = & PptPnpSurpriseRemoval;
 6464  return;
 6465}
 6466}
 6467NTSTATUS PptPnpAddDevice(PDRIVER_OBJECT pDriverObject , PDEVICE_OBJECT pPhysicalDeviceObject ) 
 6468{ NTSTATUS status ;
 6469  PDEVICE_OBJECT parentDevice ;
 6470  PDEVICE_OBJECT pDeviceObject ;
 6471  PDEVICE_EXTENSION Extension ;
 6472  PCONFIGURATION_INFORMATION tmp ;
 6473
 6474  {
 6475  status = 0L;
 6476  {
 6477  }
 6478  {
 6479  pDeviceObject = PptBuildDeviceObject(pDriverObject, pPhysicalDeviceObject);
 6480  }
 6481  if ((unsigned int )((void *)0) == (unsigned int )pDeviceObject) {
 6482    {
 6483    }
 6484    return (-1073741823L);
 6485  } else {
 6486
 6487  }
 6488  {
 6489  Extension = pDeviceObject->DeviceExtension;
 6490  status = IoRegisterDeviceInterface(pPhysicalDeviceObject, & GUID_PARALLEL_DEVICE,
 6491                                     (void *)0, & Extension->SymbolicLinkName);
 6492  }
 6493  if (! (status >= 0L)) {
 6494    {
 6495    }
 6496    {
 6497/*     IoDeleteDevice(pDeviceObject); */ /* INLINED */
 6498    }
 6499    return (status);
 6500  } else {
 6501
 6502  }
 6503  {
 6504  parentDevice = IoAttachDeviceToDeviceStack(pDeviceObject, pPhysicalDeviceObject);
 6505  }
 6506  if ((unsigned int )((void *)0) == (unsigned int )parentDevice) {
 6507    {
 6508    }
 6509    {
 6510/*     IoDeleteDevice(pDeviceObject); */ /* INLINED */
 6511    }
 6512    return (-1073741823L);
 6513  } else {
 6514
 6515  }
 6516  {
 6517  Extension->ParentDeviceObject = parentDevice;
 6518  tmp = IoGetConfigurationInformation();
 6519  tmp->ParallelCount += 1UL;
 6520  pDeviceObject->Flags &= 4294967167UL;
 6521  }
 6522  {
 6523  }
 6524  return (0L);
 6525}
 6526}
 6527NTSTATUS PptDispatchPnp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 6528{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 6529  NTSTATUS status ;
 6530  PIO_STACK_LOCATION irpStack ;
 6531  UCHAR minorFunction ;
 6532
 6533  {
 6534  {
 6535  PptDebugDumpPnpIrpInfo(DeviceObject, Irp);
 6536  status = PptAcquireRemoveLockOrFailIrp(DeviceObject, Irp);
 6537  }
 6538  if (status >= 0L) {
 6539    irpStack = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 6540    minorFunction = irpStack->MinorFunction;
 6541    if ((int )minorFunction > 24) {
 6542      {
 6543      status = PptPnpUnhandledIrp(DeviceObject, Irp);
 6544      }
 6545    } else {
 6546      if (__BLAST_NONDET == 0) {
 6547        goto switch_214_0;
 6548      } else {
 6549        if (__BLAST_NONDET == 1) {
 6550          goto switch_214_1;
 6551        } else {
 6552          if (__BLAST_NONDET == 2) {
 6553            goto switch_214_2;
 6554          } else {
 6555            if (__BLAST_NONDET == 3) {
 6556              goto switch_214_3;
 6557            } else {
 6558              if (__BLAST_NONDET == 4) {
 6559                goto switch_214_4;
 6560              } else {
 6561                if (__BLAST_NONDET == 5) {
 6562                  goto switch_214_5;
 6563                } else {
 6564                  if (__BLAST_NONDET == 6) {
 6565                    goto switch_214_6;
 6566                  } else {
 6567                    if (__BLAST_NONDET == 7) {
 6568                      goto switch_214_7;
 6569                    } else {
 6570                      if (__BLAST_NONDET == 8) {
 6571                        goto switch_214_8;
 6572                      } else {
 6573                        if (__BLAST_NONDET == 9) {
 6574                          goto switch_214_9;
 6575                        } else {
 6576                          {
 6577                          goto switch_214_default;
 6578                          if (0) {
 6579                            switch_214_0: /* CIL Label */ 
 6580                            {
 6581                            status = PptPnpUnhandledIrp(DeviceObject, Irp);
 6582                            }
 6583                            goto switch_214_break;
 6584                            switch_214_1: /* CIL Label */ 
 6585                            {
 6586                            status = PptPnpStartDevice(DeviceObject, Irp);
 6587                            }
 6588                            goto switch_214_break;
 6589                            switch_214_2: /* CIL Label */ 
 6590                            {
 6591                            status = PptPnpFilterResourceRequirements(DeviceObject,
 6592                                                                      Irp);
 6593                            }
 6594                            goto switch_214_break;
 6595                            switch_214_3: /* CIL Label */ 
 6596                            {
 6597                            status = PptPnpQueryDeviceRelations(DeviceObject, Irp);
 6598                            }
 6599                            goto switch_214_break;
 6600                            switch_214_4: /* CIL Label */ 
 6601                            {
 6602                            status = PptPnpQueryStopDevice(DeviceObject, Irp);
 6603                            }
 6604                            goto switch_214_break;
 6605                            switch_214_5: /* CIL Label */ 
 6606                            {
 6607                            status = PptPnpCancelStopDevice(DeviceObject, Irp);
 6608                            }
 6609                            goto switch_214_break;
 6610                            switch_214_6: /* CIL Label */ 
 6611                            {
 6612                            status = PptPnpStopDevice(DeviceObject, Irp);
 6613                            }
 6614                            goto switch_214_break;
 6615                            switch_214_7: /* CIL Label */ 
 6616                            {
 6617                            status = PptPnpQueryRemoveDevice(DeviceObject, Irp);
 6618                            }
 6619                            goto switch_214_break;
 6620                            switch_214_8: /* CIL Label */ 
 6621                            {
 6622                            status = PptPnpCancelRemoveDevice(DeviceObject, Irp);
 6623                            }
 6624                            goto switch_214_break;
 6625                            switch_214_9: /* CIL Label */ 
 6626                            {
 6627                            status = PptPnpRemoveDevice(DeviceObject, Irp);
 6628                            }
 6629                            goto switch_214_break;
 6630                            switch_214_default: /* CIL Label */ 
 6631                            {
 6632                            status = PptPnpSurpriseRemoval(DeviceObject, Irp);
 6633                            }
 6634                            goto switch_214_break;
 6635                          } else {
 6636                            switch_214_break: /* CIL Label */ ;
 6637                          }
 6638                          }
 6639                        }
 6640                      }
 6641                    }
 6642                  }
 6643                }
 6644              }
 6645            }
 6646          }
 6647        }
 6648      }
 6649    }
 6650  } else {
 6651
 6652  }
 6653  return (status);
 6654}
 6655}
 6656NTSTATUS PptPnpStartDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 6657{ PDEVICE_EXTENSION extension ;
 6658  NTSTATUS status ;
 6659  BOOLEAN foundPort ;
 6660  BOOLEAN foundIrq ;
 6661  BOOLEAN foundDma ;
 6662
 6663  {
 6664  {
 6665  extension = DeviceObject->DeviceExtension;
 6666  foundPort = 0;
 6667  foundIrq = 0;
 6668  foundDma = 0;
 6669  status = PptPnpBounceAndCatchPnpIrp(extension, Irp);
 6670  }
 6671  if (! (status >= 0L)) {
 6672    if (status != -1073741637L) {
 6673      goto targetExit;
 6674    } else {
 6675
 6676    }
 6677  } else {
 6678
 6679  }
 6680  {
 6681  status = PptPnpStartScanCmResourceList(extension, Irp, & foundPort, & foundIrq,
 6682                                         & foundDma);
 6683  }
 6684  if (! (status >= 0L)) {
 6685    goto targetExit;
 6686  } else {
 6687
 6688  }
 6689  {
 6690  status = PptPnpStartValidateResources(DeviceObject, foundPort, foundIrq, foundDma);
 6691  }
 6692  if (! (status >= 0L)) {
 6693    goto targetExit;
 6694  } else {
 6695
 6696  }
 6697  {
 6698  extension->PnpInfo.Ieee1284_3DeviceCount = PptInitiate1284_3(extension);
 6699  status = PptDetectChipFilter(extension);
 6700  }
 6701  if (! (status >= 0L)) {
 6702    {
 6703    PptDetectPortType(extension);
 6704    }
 6705  } else {
 6706
 6707  }
 6708  {
 6709  status = PptWmiInitWmi(DeviceObject);
 6710  }
 6711  if (! (status >= 0L)) {
 6712    goto targetExit;
 6713  } else {
 6714
 6715  }
 6716  {
 6717  status = IoSetDeviceInterfaceState(& extension->SymbolicLinkName, 1);
 6718  }
 6719  if (! (status >= 0L)) {
 6720    status = -1073741637L;
 6721  } else {
 6722
 6723  }
 6724  targetExit: 
 6725  if (status >= 0L) {
 6726    {
 6727/*     ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 6728    extension->DeviceStateFlags |= 1UL;
 6729/*     ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 6730    }
 6731  } else {
 6732
 6733  }
 6734  {
 6735  Irp->IoStatus.__annonCompField4.Status = status;
 6736  myStatus = status;
 6737  Irp->IoStatus.Information = 0;
 6738  PptCompleteRequest(Irp, 0);
 6739  PptReleaseRemoveLock(& extension->RemoveLock, Irp);
 6740  }
 6741  return (status);
 6742}
 6743}
 6744NTSTATUS PptPnpStartScanCmResourceList(PDEVICE_EXTENSION Extension , PIRP Irp , PBOOLEAN FoundPort ,
 6745                                       PBOOLEAN FoundIrq , PBOOLEAN FoundDma ) 
 6746{ NTSTATUS status ;
 6747  PIO_STACK_LOCATION irpStack ;
 6748  PCM_RESOURCE_LIST ResourceList ;
 6749  PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor ;
 6750  PCM_PARTIAL_RESOURCE_LIST PartialResourceList ;
 6751  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResourceDescriptor ;
 6752  ULONG i ;
 6753  PHYSICAL_ADDRESS start ;
 6754  ULONG length ;
 6755  BOOLEAN isPci ;
 6756  BOOLEAN tmp ;
 6757  BOOLEAN tmp___0 ;
 6758  BOOLEAN tmp___1 ;
 6759
 6760  {
 6761  status = 0L;
 6762  irpStack = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 6763  isPci = 0;
 6764  *FoundPort = 0;
 6765  *FoundIrq = 0;
 6766  *FoundDma = 0;
 6767  ResourceList = irpStack->Parameters.StartDevice.AllocatedResourcesTranslated;
 6768  if ((unsigned int )ResourceList == (unsigned int )((void *)0)) {
 6769    {
 6770    }
 6771    status = -1073741670L;
 6772    goto targetExit;
 6773  } else {
 6774
 6775  }
 6776  if ((int )((KUSER_SHARED_DATA * const  )4292804608U)->AlternativeArchitecture != 1) {
 6777    {
 6778    tmp = PptIsPci(Extension, Irp);
 6779    }
 6780    if (1 == (int )tmp) {
 6781      {
 6782      }
 6783      {
 6784      status = PptPnpStartScanPciCardCmResourceList(Extension, Irp, FoundPort, FoundIrq,
 6785                                                    FoundDma);
 6786      isPci = 1;
 6787      }
 6788      goto targetExit;
 6789    } else {
 6790
 6791    }
 6792  } else {
 6793
 6794  }
 6795  FullResourceDescriptor = & ResourceList->List[0];
 6796  if (FullResourceDescriptor) {
 6797    Extension->InterfaceType = FullResourceDescriptor->InterfaceType;
 6798    PartialResourceList = & FullResourceDescriptor->PartialResourceList;
 6799    i = 0;
 6800    {
 6801    while (1) {
 6802      while_217_continue: /* CIL Label */ ;
 6803      if (i < PartialResourceList->Count) {
 6804
 6805      } else {
 6806        goto while_217_break;
 6807      }
 6808      PartialResourceDescriptor = & PartialResourceList->PartialDescriptors[i];
 6809      if (PartialResourceDescriptor->Type == 1) {
 6810        goto switch_218_1;
 6811      } else {
 6812        if (PartialResourceDescriptor->Type == 6) {
 6813          goto switch_218_6;
 6814        } else {
 6815          if (PartialResourceDescriptor->Type == 2) {
 6816            goto switch_218_2;
 6817          } else {
 6818            if (PartialResourceDescriptor->Type == 4) {
 6819              goto switch_218_4;
 6820            } else {
 6821              {
 6822              goto switch_218_default;
 6823              if (0) {
 6824                switch_218_1: /* CIL Label */ 
 6825                start = PartialResourceDescriptor->u.Port.Start;
 6826                length = PartialResourceDescriptor->u.Port.Length;
 6827                {
 6828                }
 6829                *FoundPort = 1;
 6830                if (Extension->PortInfo.OriginalController.__annonCompField1.LowPart == 0UL) {
 6831                  if (Extension->PortInfo.OriginalController.__annonCompField1.HighPart == 0L) {
 6832                    {
 6833                    }
 6834                    Extension->PortInfo.OriginalController = PartialResourceDescriptor->u.Port.Start;
 6835                    Extension->PortInfo.SpanOfController = PartialResourceDescriptor->u.Port.Length;
 6836                    Extension->PortInfo.Controller = (UCHAR *)((unsigned long )Extension->PortInfo.OriginalController.QuadPart);
 6837                    Extension->AddressSpace = PartialResourceDescriptor->Flags;
 6838                    if (Extension->PortInfo.SpanOfController == 4096UL) {
 6839                      {
 6840                      tmp___0 = PptIsNecR98Machine();
 6841                      }
 6842                      if (tmp___0) {
 6843                        Extension->PortInfo.SpanOfController = 8;
 6844                      } else {
 6845
 6846                      }
 6847                    } else {
 6848
 6849                    }
 6850                  } else {
 6851                    goto _L___0;
 6852                  }
 6853                } else {
 6854                  _L___0: /* CIL Label */ 
 6855                  if (Extension->PnpInfo.OriginalEcpController.__annonCompField1.LowPart == 0UL) {
 6856                    if (Extension->PnpInfo.OriginalEcpController.__annonCompField1.HighPart == 0L) {
 6857                      if ((int )((KUSER_SHARED_DATA * const  )4292804608U)->AlternativeArchitecture != 1) {
 6858                        if (PartialResourceDescriptor->u.Port.Start.__annonCompField1.LowPart < Extension->PortInfo.OriginalController.__annonCompField1.LowPart) {
 6859                          if (PartialResourceDescriptor->u.Port.Start.__annonCompField1.HighPart < Extension->PortInfo.OriginalController.__annonCompField1.HighPart) {
 6860                            {
 6861                            }
 6862                            Extension->PnpInfo.OriginalEcpController = Extension->PortInfo.OriginalController;
 6863                            Extension->PnpInfo.SpanOfEcpController = Extension->PortInfo.SpanOfController;
 6864                            Extension->PnpInfo.EcpController = Extension->PortInfo.Controller;
 6865                            Extension->EcpAddressSpace = Extension->AddressSpace;
 6866                            Extension->PortInfo.OriginalController = PartialResourceDescriptor->u.Port.Start;
 6867                            Extension->PortInfo.SpanOfController = PartialResourceDescriptor->u.Port.Length;
 6868                            Extension->PortInfo.Controller = (UCHAR *)((unsigned long )Extension->PortInfo.OriginalController.QuadPart);
 6869                            Extension->AddressSpace = PartialResourceDescriptor->Flags;
 6870                            if (Extension->PortInfo.SpanOfController == 4096UL) {
 6871                              {
 6872                              tmp___1 = PptIsNecR98Machine();
 6873                              }
 6874                              if (tmp___1) {
 6875                                Extension->PortInfo.SpanOfController = 8;
 6876                              } else {
 6877
 6878                              }
 6879                            } else {
 6880
 6881                            }
 6882                          } else {
 6883                            goto _L;
 6884                          }
 6885                        } else {
 6886                          _L: /* CIL Label */ 
 6887                          {
 6888                          }
 6889                          Extension->PnpInfo.OriginalEcpController = PartialResourceDescriptor->u.Port.Start;
 6890                          Extension->PnpInfo.SpanOfEcpController = PartialResourceDescriptor->u.Port.Length;
 6891                          Extension->PnpInfo.EcpController = (UCHAR *)((unsigned long )Extension->PnpInfo.OriginalEcpController.QuadPart);
 6892                          Extension->EcpAddressSpace = PartialResourceDescriptor->Flags;
 6893                        }
 6894                      } else {
 6895
 6896                      }
 6897                    } else {
 6898
 6899                    }
 6900                  } else {
 6901
 6902                  }
 6903                }
 6904                goto switch_218_break;
 6905                switch_218_6: /* CIL Label */ 
 6906                Extension->BusNumber = PartialResourceDescriptor->u.BusNumber.Start;
 6907                goto switch_218_break;
 6908                switch_218_2: /* CIL Label */ 
 6909                *FoundIrq = 1;
 6910                Extension->FoundInterrupt = 1;
 6911                Extension->InterruptLevel = (unsigned char )PartialResourceDescriptor->u.Interrupt.Level;
 6912                Extension->InterruptVector = PartialResourceDescriptor->u.Interrupt.Vector;
 6913                Extension->InterruptAffinity = PartialResourceDescriptor->u.Interrupt.Affinity;
 6914                if ((int )PartialResourceDescriptor->Flags & 1) {
 6915                  Extension->InterruptMode = 1;
 6916                } else {
 6917                  Extension->InterruptMode = 0;
 6918                }
 6919                goto switch_218_break;
 6920                switch_218_4: /* CIL Label */ 
 6921                *FoundDma = 1;
 6922                Extension->DmaChannel = PartialResourceDescriptor->u.Dma.Channel;
 6923                Extension->DmaPort = PartialResourceDescriptor->u.Dma.Port;
 6924                Extension->DmaWidth = PartialResourceDescriptor->Flags;
 6925                goto switch_218_break;
 6926                switch_218_default: /* CIL Label */ ;
 6927                goto switch_218_break;
 6928              } else {
 6929                switch_218_break: /* CIL Label */ ;
 6930              }
 6931              }
 6932            }
 6933          }
 6934        }
 6935      }
 6936      i += 1UL;
 6937    }
 6938    while_217_break: /* CIL Label */ ;
 6939    }
 6940  } else {
 6941
 6942  }
 6943  targetExit: 
 6944  if (0 == (int )isPci) {
 6945    {
 6946    }
 6947    {
 6948    }
 6949    {
 6950    }
 6951    {
 6952    }
 6953  } else {
 6954
 6955  }
 6956  return (status);
 6957}
 6958}
 6959NTSTATUS PptPnpStartValidateResources(PDEVICE_OBJECT DeviceObject , BOOLEAN FoundPort ,
 6960                                      BOOLEAN FoundIrq , BOOLEAN FoundDma ) 
 6961{ PDEVICE_EXTENSION extension ;
 6962  NTSTATUS status ;
 6963
 6964  {
 6965  extension = DeviceObject->DeviceExtension;
 6966  status = 0L;
 6967  if (! FoundPort) {
 6968    status = -1073741810L;
 6969  } else {
 6970    extension->PortInfo.Controller = (UCHAR *)((unsigned long )extension->PortInfo.OriginalController.QuadPart);
 6971    if (! extension->PortInfo.Controller) {
 6972      {
 6973      PptLogError(DeviceObject->DriverObject, DeviceObject, extension->PortInfo.OriginalController,
 6974                  PhysicalZero, 0, 0, 0, 10, 0L, 4);
 6975      status = -1073741709L;
 6976      }
 6977    } else {
 6978
 6979    }
 6980  }
 6981  return (status);
 6982}
 6983}
 6984NTSTATUS PptPnpFilterResourceRequirements(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 6985{ PDEVICE_EXTENSION extension ;
 6986  ULONG filterResourceMethod ;
 6987  PIO_RESOURCE_REQUIREMENTS_LIST pResourceRequirementsIn ;
 6988  NTSTATUS status ;
 6989  PIO_STACK_LOCATION IrpStack ;
 6990  BOOLEAN tmp ;
 6991  BOOLEAN tmp___0 ;
 6992
 6993  {
 6994  {
 6995  extension = DeviceObject->DeviceExtension;
 6996  filterResourceMethod = 1;
 6997  status = PptPnpBounceAndCatchPnpIrp(extension, Irp);
 6998  }
 6999  if (! (status >= 0L)) {
 7000    if (status != -1073741637L) {
 7001      goto targetExit;
 7002    } else {
 7003
 7004    }
 7005  } else {
 7006
 7007  }
 7008  if (Irp->IoStatus.Information == 0UL) {
 7009    IrpStack = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 7010    pResourceRequirementsIn = IrpStack->Parameters.FilterResourceRequirements.IoResourceRequirementList;
 7011    if ((unsigned int )pResourceRequirementsIn == (unsigned int )((void *)0)) {
 7012      goto targetExit;
 7013    } else {
 7014
 7015    }
 7016  } else {
 7017    pResourceRequirementsIn = (struct _IO_RESOURCE_REQUIREMENTS_LIST *)Irp->IoStatus.Information;
 7018  }
 7019  {
 7020  }
 7021  {
 7022  }
 7023  {
 7024  PptDebugDumpResourceRequirementsList(pResourceRequirementsIn);
 7025  }
 7026  if (filterResourceMethod == 1) {
 7027    goto switch_229_1;
 7028  } else {
 7029    if (filterResourceMethod == 0) {
 7030      goto switch_229_0;
 7031    } else {
 7032      if (filterResourceMethod == 2) {
 7033        goto switch_229_2;
 7034      } else {
 7035        {
 7036        goto switch_229_default;
 7037        if (0) {
 7038          switch_229_1: /* CIL Label */ ;
 7039          {
 7040          }
 7041          {
 7042          tmp = PptPnpFilterExistsNonIrqResourceList(pResourceRequirementsIn);
 7043          }
 7044          if (tmp) {
 7045            {
 7046            }
 7047            {
 7048            PptPnpFilterRemoveIrqResourceLists(pResourceRequirementsIn);
 7049            }
 7050          } else {
 7051            {
 7052            }
 7053            {
 7054            PptPnpFilterNukeIrqResourceDescriptorsFromAllLists(pResourceRequirementsIn);
 7055            }
 7056          }
 7057          {
 7058          }
 7059          {
 7060          PptDebugDumpResourceRequirementsList(pResourceRequirementsIn);
 7061          }
 7062          goto switch_229_break;
 7063          switch_229_0: /* CIL Label */ ;
 7064          {
 7065          }
 7066          {
 7067          tmp___0 = PptPnpFilterExistsNonIrqResourceList(pResourceRequirementsIn);
 7068          }
 7069          if (tmp___0) {
 7070            {
 7071            }
 7072            {
 7073            PptPnpFilterRemoveIrqResourceLists(pResourceRequirementsIn);
 7074            }
 7075            {
 7076            }
 7077            {
 7078            PptDebugDumpResourceRequirementsList(pResourceRequirementsIn);
 7079            }
 7080          } else {
 7081            {
 7082            }
 7083          }
 7084          goto switch_229_break;
 7085          switch_229_2: /* CIL Label */ ;
 7086          {
 7087          }
 7088          goto switch_229_break;
 7089          switch_229_default: /* CIL Label */ ;
 7090          {
 7091          }
 7092        } else {
 7093          switch_229_break: /* CIL Label */ ;
 7094        }
 7095        }
 7096      }
 7097    }
 7098  }
 7099  targetExit: 
 7100  {
 7101  Irp->IoStatus.__annonCompField4.Status = status;
 7102  myStatus = status;
 7103  PptCompleteRequest(Irp, 0);
 7104  PptReleaseRemoveLock(& extension->RemoveLock, Irp);
 7105  }
 7106  return (status);
 7107}
 7108}
 7109BOOLEAN PptPnpFilterExistsNonIrqResourceList(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) 
 7110{ ULONG listCount ;
 7111  PIO_RESOURCE_LIST curList ;
 7112  ULONG i ;
 7113  ULONG remain ;
 7114  PIO_RESOURCE_DESCRIPTOR curDesc ;
 7115  BOOLEAN foundIrq ;
 7116
 7117  {
 7118  listCount = ResourceRequirementsList->AlternativeLists;
 7119  {
 7120  }
 7121  i = 0;
 7122  curList = ResourceRequirementsList->List;
 7123  {
 7124  while (1) {
 7125    while_241_continue: /* CIL Label */ ;
 7126    if (i < listCount) {
 7127
 7128    } else {
 7129      goto while_241_break;
 7130    }
 7131    {
 7132    }
 7133    remain = curList->Count;
 7134    curDesc = curList->Descriptors;
 7135    foundIrq = 0;
 7136    {
 7137    while (1) {
 7138      while_243_continue: /* CIL Label */ ;
 7139      if (remain) {
 7140
 7141      } else {
 7142        goto while_243_break;
 7143      }
 7144      {
 7145      }
 7146      if ((int )curDesc->Type == 2) {
 7147        {
 7148        }
 7149        foundIrq = 1;
 7150        goto while_243_break;
 7151      } else {
 7152
 7153      }
 7154      curDesc += 1;
 7155      remain -= 1UL;
 7156    }
 7157    while_243_break: /* CIL Label */ ;
 7158    }
 7159    if ((int )foundIrq == 0) {
 7160      {
 7161      }
 7162      return (1);
 7163    } else {
 7164
 7165    }
 7166    curList = (struct _IO_RESOURCE_LIST *)(curList->Descriptors + curList->Count);
 7167    i += 1UL;
 7168  }
 7169  while_241_break: /* CIL Label */ ;
 7170  }
 7171  {
 7172  }
 7173  return (0);
 7174}
 7175}
 7176void PptPnpFilterRemoveIrqResourceLists(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) 
 7177{ ULONG listCount ;
 7178  PIO_RESOURCE_LIST curList ;
 7179  PIO_RESOURCE_LIST nextList ;
 7180  ULONG i ;
 7181  PCHAR currentEndOfResourceRequirementsList ;
 7182  LONG bytesToMove ;
 7183  PVOID tmp ;
 7184  BOOLEAN tmp___0 ;
 7185
 7186  {
 7187  listCount = ResourceRequirementsList->AlternativeLists;
 7188  {
 7189  }
 7190  {
 7191  tmp = PptPnpFilterGetEndOfResourceRequirementsList(ResourceRequirementsList);
 7192  currentEndOfResourceRequirementsList = tmp;
 7193  i = 0;
 7194  curList = ResourceRequirementsList->List;
 7195  }
 7196  {
 7197  while (1) {
 7198    while_249_continue: /* CIL Label */ ;
 7199    if (i < listCount) {
 7200
 7201    } else {
 7202      goto while_249_break;
 7203    }
 7204    {
 7205    }
 7206    {
 7207    }
 7208    {
 7209    tmp___0 = PptPnpListContainsIrqResourceDescriptor(curList);
 7210    }
 7211    if (tmp___0) {
 7212      {
 7213      }
 7214      nextList = (struct _IO_RESOURCE_LIST *)(curList->Descriptors + curList->Count);
 7215      bytesToMove = (long )(currentEndOfResourceRequirementsList - (CHAR *)nextList);
 7216      if (bytesToMove > 0L) {
 7217        {
 7218        memmove(curList, nextList, bytesToMove);
 7219        currentEndOfResourceRequirementsList -= (CHAR *)nextList - (CHAR *)curList;
 7220        }
 7221      } else {
 7222
 7223      }
 7224      listCount -= 1UL;
 7225    } else {
 7226      {
 7227      }
 7228      curList = (struct _IO_RESOURCE_LIST *)(curList->Descriptors + curList->Count);
 7229      i += 1UL;
 7230    }
 7231  }
 7232  while_249_break: /* CIL Label */ ;
 7233  }
 7234  ResourceRequirementsList->AlternativeLists = listCount;
 7235  {
 7236  }
 7237  return;
 7238}
 7239}
 7240PVOID PptPnpFilterGetEndOfResourceRequirementsList(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) 
 7241{ ULONG listCount ;
 7242  PIO_RESOURCE_LIST curList ;
 7243  ULONG i ;
 7244
 7245  {
 7246  listCount = ResourceRequirementsList->AlternativeLists;
 7247  i = 0;
 7248  curList = ResourceRequirementsList->List;
 7249  {
 7250  while (1) {
 7251    while_255_continue: /* CIL Label */ ;
 7252    if (i < listCount) {
 7253
 7254    } else {
 7255      goto while_255_break;
 7256    }
 7257    curList = (struct _IO_RESOURCE_LIST *)(curList->Descriptors + curList->Count);
 7258    i += 1UL;
 7259  }
 7260  while_255_break: /* CIL Label */ ;
 7261  }
 7262  return ((void *)curList);
 7263}
 7264}
 7265void PptPnpFilterNukeIrqResourceDescriptorsFromAllLists(PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList ) 
 7266{ ULONG listCount ;
 7267  ULONG i ;
 7268  PIO_RESOURCE_LIST curList ;
 7269
 7270  {
 7271  listCount = ResourceRequirementsList->AlternativeLists;
 7272  i = 0;
 7273  curList = ResourceRequirementsList->List;
 7274  {
 7275  }
 7276  {
 7277  while (1) {
 7278    while_257_continue: /* CIL Label */ ;
 7279    if (i < listCount) {
 7280
 7281    } else {
 7282      goto while_257_break;
 7283    }
 7284    {
 7285    }
 7286    {
 7287    PptPnpFilterNukeIrqResourceDescriptors(curList);
 7288    curList = (struct _IO_RESOURCE_LIST *)(curList->Descriptors + curList->Count);
 7289    i += 1UL;
 7290    }
 7291  }
 7292  while_257_break: /* CIL Label */ ;
 7293  }
 7294  return;
 7295}
 7296}
 7297void PptPnpFilterNukeIrqResourceDescriptors(PIO_RESOURCE_LIST IoResourceList ) 
 7298{ PIO_RESOURCE_DESCRIPTOR pIoResourceDescriptorIn ;
 7299  ULONG i ;
 7300
 7301  {
 7302  pIoResourceDescriptorIn = IoResourceList->Descriptors;
 7303  i = 0;
 7304  {
 7305  while (1) {
 7306    while_259_continue: /* CIL Label */ ;
 7307    if (i < IoResourceList->Count) {
 7308
 7309    } else {
 7310      goto while_259_break;
 7311    }
 7312    if ((int )pIoResourceDescriptorIn->Type == 2) {
 7313      pIoResourceDescriptorIn->Type = 0;
 7314      {
 7315      }
 7316    } else {
 7317
 7318    }
 7319    pIoResourceDescriptorIn += 1;
 7320    i += 1UL;
 7321  }
 7322  while_259_break: /* CIL Label */ ;
 7323  }
 7324  return;
 7325}
 7326}
 7327NTSTATUS PptPnpQueryDeviceRelations(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7328{ PDEVICE_EXTENSION extension ;
 7329  PIO_STACK_LOCATION irpSp ;
 7330  DEVICE_RELATION_TYPE type ;
 7331  PDEVICE_RELATIONS removalRelations ;
 7332  NTSTATUS tmp ;
 7333
 7334  {
 7335  extension = DeviceObject->DeviceExtension;
 7336  irpSp = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 7337  type = irpSp->Parameters.QueryDeviceRelations.Type;
 7338  if (type == 3) {
 7339    goto switch_261_3;
 7340  } else {
 7341    if (type == 0) {
 7342      goto switch_261_0;
 7343    } else {
 7344      if (type == 1) {
 7345        goto switch_261_1;
 7346      } else {
 7347        if (type == 2) {
 7348          goto switch_261_2;
 7349        } else {
 7350          if (type == 4) {
 7351            goto switch_261_4;
 7352          } else {
 7353            {
 7354            goto switch_261_default;
 7355            if (0) {
 7356              switch_261_3: /* CIL Label */ ;
 7357              {
 7358              }
 7359              {
 7360              PptDumpRemovalRelationsList(extension);
 7361              }
 7362              if (Irp->IoStatus.Information) {
 7363                {
 7364                }
 7365              } else {
 7366                {
 7367                removalRelations = PptPnpBuildRemovalRelations(extension);
 7368                }
 7369                if (removalRelations) {
 7370                  {
 7371                  }
 7372                  Irp->IoStatus.__annonCompField4.Status = 0L;
 7373                  myStatus = 0L;
 7374                  Irp->IoStatus.Information = (unsigned long )removalRelations;
 7375                } else {
 7376                  {
 7377                  }
 7378                }
 7379              }
 7380              goto switch_261_break;
 7381              switch_261_0: /* CIL Label */ ;
 7382              {
 7383              }
 7384              goto switch_261_break;
 7385              switch_261_1: /* CIL Label */ ;
 7386              {
 7387              }
 7388              goto switch_261_break;
 7389              switch_261_2: /* CIL Label */ ;
 7390              {
 7391              }
 7392              goto switch_261_break;
 7393              switch_261_4: /* CIL Label */ ;
 7394              {
 7395              }
 7396              goto switch_261_break;
 7397              switch_261_default: /* CIL Label */ ;
 7398              {
 7399              }
 7400              goto switch_261_break;
 7401            } else {
 7402              switch_261_break: /* CIL Label */ ;
 7403            }
 7404            }
 7405          }
 7406        }
 7407      }
 7408    }
 7409  }
 7410  {
 7411  tmp = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(DeviceObject->DeviceExtension,
 7412                                                    Irp);
 7413  }
 7414  return (tmp);
 7415}
 7416}
 7417NTSTATUS PptPnpQueryStopDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7418{ NTSTATUS status ;
 7419  PDEVICE_EXTENSION extension ;
 7420  LONG handlesOpen ;
 7421
 7422  {
 7423  {
 7424  status = 0L;
 7425  extension = DeviceObject->DeviceExtension;
 7426/*   ExAcquireFastMutex(& extension->OpenCloseMutex); */ /* INLINED */
 7427  handlesOpen = extension->OpenCloseRefCount;
 7428/*   ExReleaseFastMutex(& extension->OpenCloseMutex); */ /* INLINED */
 7429  }
 7430  if (handlesOpen > 0L) {
 7431    {
 7432    status = -2147483631L;
 7433    PptFailRequest(Irp, status);
 7434    PptReleaseRemoveLock(& extension->RemoveLock, Irp);
 7435    }
 7436  } else {
 7437    {
 7438    Irp->IoStatus.__annonCompField4.Status = 0L;
 7439    myStatus = 0L;
 7440    status = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(extension, Irp);
 7441/*     ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7442    extension->DeviceStateFlags |= 65552UL;
 7443/*     ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7444    }
 7445  }
 7446  return (status);
 7447}
 7448}
 7449NTSTATUS PptPnpCancelStopDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7450{ PDEVICE_EXTENSION extension ;
 7451  NTSTATUS tmp ;
 7452
 7453  {
 7454  {
 7455  extension = DeviceObject->DeviceExtension;
 7456/*   ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7457  }
 7458  if (extension->DeviceStateFlags & 16UL) {
 7459    extension->DeviceStateFlags &= 4294901743UL;
 7460  } else {
 7461
 7462  }
 7463  {
 7464/*   ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7465  Irp->IoStatus.__annonCompField4.Status = 0L;
 7466  myStatus = 0L;
 7467  tmp = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(extension, Irp);
 7468  }
 7469  return (tmp);
 7470}
 7471}
 7472NTSTATUS PptPnpStopDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7473{ PDEVICE_EXTENSION extension ;
 7474  NTSTATUS tmp ;
 7475
 7476  {
 7477  {
 7478  extension = DeviceObject->DeviceExtension;
 7479/*   ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7480  extension->DeviceStateFlags |= 32UL;
 7481  extension->DeviceStateFlags &= 4294967278UL;
 7482/*   ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7483  Irp->IoStatus.__annonCompField4.Status = 0L;
 7484  myStatus = 0L;
 7485  tmp = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(extension, Irp);
 7486  }
 7487  return (tmp);
 7488}
 7489}
 7490NTSTATUS PptPnpQueryRemoveDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7491{ PDEVICE_EXTENSION extension ;
 7492  NTSTATUS tmp ;
 7493
 7494  {
 7495  extension = DeviceObject->DeviceExtension;
 7496  {
 7497  }
 7498  {
 7499/*   ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7500  extension->DeviceStateFlags |= 65792UL;
 7501/*   ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7502  Irp->IoStatus.__annonCompField4.Status = 0L;
 7503  myStatus = 0L;
 7504  tmp = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(extension, Irp);
 7505  }
 7506  return (tmp);
 7507}
 7508}
 7509NTSTATUS PptPnpCancelRemoveDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7510{ PDEVICE_EXTENSION extension ;
 7511  NTSTATUS tmp ;
 7512
 7513  {
 7514  {
 7515  extension = DeviceObject->DeviceExtension;
 7516/*   ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7517  }
 7518  if (extension->DeviceStateFlags & 256UL) {
 7519    extension->DeviceStateFlags &= 4294901503UL;
 7520  } else {
 7521
 7522  }
 7523  {
 7524/*   ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7525  Irp->IoStatus.__annonCompField4.Status = 0L;
 7526  myStatus = 0L;
 7527  tmp = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(extension, Irp);
 7528  }
 7529  return (tmp);
 7530}
 7531}
 7532NTSTATUS PptPnpRemoveDevice(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7533{ PDEVICE_EXTENSION extension ;
 7534  NTSTATUS status ;
 7535
 7536  {
 7537  {
 7538  extension = DeviceObject->DeviceExtension;
 7539/*   ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7540  extension->DeviceStateFlags |= 512UL;
 7541/*   ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7542  IoWMIRegistrationControl(DeviceObject, 2);
 7543  IoSetDeviceInterfaceState(& extension->SymbolicLinkName, 0);
 7544  Irp->IoStatus.__annonCompField4.Status = 0L;
 7545  myStatus = 0L;
 7546  }
 7547  if (s == NP) {
 7548    s = SKIP1;
 7549  } else {
 7550    {
 7551    errorFn();
 7552    }
 7553  }
 7554  {
 7555  Irp->CurrentLocation = (CHAR )((int )Irp->CurrentLocation + 1);
 7556  Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation += 1;
 7557  status = IofCallDriver(extension->ParentDeviceObject, Irp);
 7558  PptReleaseRemoveLockAndWait(& extension->RemoveLock, Irp);
 7559  PptCleanRemovalRelationsList(extension);
 7560/*   RtlFreeUnicodeString(& extension->DeviceName); */ /* INLINED */
 7561/*   RtlFreeUnicodeString(& extension->SymbolicLinkName); */ /* INLINED */
 7562  }
 7563  if (extension->PnpInfo.PortName) {
 7564    {
 7565/*     ExFreePool(extension->PnpInfo.PortName); */ /* INLINED */
 7566    extension->PnpInfo.PortName = (void *)0;
 7567    }
 7568  } else {
 7569
 7570  }
 7571  {
 7572/*   IoDetachDevice(extension->ParentDeviceObject); */ /* INLINED */
 7573/*   IoDeleteDevice(DeviceObject); */ /* INLINED */
 7574  }
 7575  return (status);
 7576}
 7577}
 7578NTSTATUS PptPnpSurpriseRemoval(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7579{ PDEVICE_EXTENSION extension ;
 7580  KIRQL cancelIrql ;
 7581  NTSTATUS tmp ;
 7582
 7583  {
 7584  {
 7585  extension = DeviceObject->DeviceExtension;
 7586/*   ExAcquireFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7587  extension->DeviceStateFlags |= 4096UL;
 7588/*   ExReleaseFastMutex(& extension->ExtensionFastMutex); */ /* INLINED */
 7589  IoAcquireCancelSpinLock(& cancelIrql);
 7590/*   IoReleaseCancelSpinLock(cancelIrql); */ /* INLINED */
 7591  IoSetDeviceInterfaceState(& extension->SymbolicLinkName, 0);
 7592  Irp->IoStatus.__annonCompField4.Status = 0L;
 7593  myStatus = 0L;
 7594  tmp = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(extension, Irp);
 7595  }
 7596  return (tmp);
 7597}
 7598}
 7599BOOLEAN PptPnpListContainsIrqResourceDescriptor(PIO_RESOURCE_LIST List ) 
 7600{ ULONG i ;
 7601  PIO_RESOURCE_DESCRIPTOR curDesc ;
 7602
 7603  {
 7604  curDesc = List->Descriptors;
 7605  i = 0;
 7606  {
 7607  while (1) {
 7608    while_272_continue: /* CIL Label */ ;
 7609    if (i < List->Count) {
 7610
 7611    } else {
 7612      goto while_272_break;
 7613    }
 7614    if ((int )curDesc->Type == 2) {
 7615      return (1);
 7616    } else {
 7617      curDesc += 1;
 7618    }
 7619    i += 1UL;
 7620  }
 7621  while_272_break: /* CIL Label */ ;
 7622  }
 7623  return (0);
 7624}
 7625}
 7626NTSTATUS PptPnpBounceAndCatchPnpIrp(PDEVICE_EXTENSION Extension , PIRP Irp ) 
 7627{ NTSTATUS status ;
 7628  KEVENT event ;
 7629  PDEVICE_OBJECT parentDevObj ;
 7630  PIO_STACK_LOCATION irpSp ;
 7631  PIO_STACK_LOCATION nextIrpSp ;
 7632  PIO_STACK_LOCATION irpSp___0 ;
 7633
 7634  {
 7635  parentDevObj = Extension->ParentDeviceObject;
 7636  {
 7637  }
 7638  {
 7639/*   KeInitializeEvent(& event, 0, 0); */ /* INLINED */
 7640  irpSp = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 7641  nextIrpSp = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation - 1;
 7642  memcpy(nextIrpSp, irpSp, (long )(& ((IO_STACK_LOCATION *)0)->CompletionRoutine));
 7643  nextIrpSp->Control = 0;
 7644  }
 7645  if (s != NP) {
 7646    {
 7647    errorFn();
 7648    }
 7649  } else {
 7650    if (compRegistered != 0) {
 7651      {
 7652      errorFn();
 7653      }
 7654    } else {
 7655      compRegistered = 1;
 7656      compFptr = & PptSynchCompletionRoutine;
 7657      routine = 0;
 7658    }
 7659  }
 7660  {
 7661  irpSp___0 = Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation - 1;
 7662  irpSp___0->CompletionRoutine = & PptSynchCompletionRoutine;
 7663  irpSp___0->Context = & event;
 7664  irpSp___0->Control = 0;
 7665  irpSp___0->Control = 64;
 7666  irpSp___0->Control = (int )irpSp___0->Control | 128;
 7667  irpSp___0->Control = (int )irpSp___0->Control | 32;
 7668  status = IofCallDriver(parentDevObj, Irp);
 7669  KeWaitForSingleObject(& event, 5, 0, 0, (void *)0);
 7670  }
 7671  if (status == 259L) {
 7672    status = myStatus;
 7673  } else {
 7674
 7675  }
 7676  return (status);
 7677}
 7678}
 7679NTSTATUS PptPnpPassThroughPnpIrpAndReleaseRemoveLock(PDEVICE_EXTENSION Extension ,
 7680                                                     PIRP Irp ) 
 7681{ NTSTATUS status ;
 7682
 7683  {
 7684  if (s == NP) {
 7685    s = SKIP1;
 7686  } else {
 7687    {
 7688    errorFn();
 7689    }
 7690  }
 7691  {
 7692  Irp->CurrentLocation = (CHAR )((int )Irp->CurrentLocation + 1);
 7693  Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation += 1;
 7694  status = IofCallDriver(Extension->ParentDeviceObject, Irp);
 7695  PptReleaseRemoveLock(& Extension->RemoveLock, Irp);
 7696  }
 7697  return (status);
 7698}
 7699}
 7700NTSTATUS PptPnpUnhandledIrp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 7701{ NTSTATUS tmp ;
 7702
 7703  {
 7704  {
 7705  tmp = PptPnpPassThroughPnpIrpAndReleaseRemoveLock(DeviceObject->DeviceExtension,
 7706                                                    Irp);
 7707  }
 7708  return (tmp);
 7709}
 7710}
 7711#pragma once
 7712#pragma once
 7713#pragma once
 7714#pragma once
 7715#pragma warning(push)
 7716#pragma warning(disable:4035)
 7717#pragma warning(pop)
 7718#pragma once
 7719#pragma warning(disable:4103)
 7720#pragma warning(disable:4103)
 7721#pragma warning(push)
 7722#pragma warning(disable:4035)
 7723#pragma warning(pop)
 7724#pragma warning(disable:4035)
 7725#pragma warning(push)
 7726#pragma warning(disable:4164)
 7727#pragma function(_enable)
 7728#pragma function(_disable)
 7729#pragma warning(pop)
 7730#pragma warning(disable:4103)
 7731#pragma warning(disable:4103)
 7732#pragma warning(disable:4103)
 7733#pragma warning(disable:4103)
 7734#pragma warning(disable:4103)
 7735#pragma warning(disable:4103)
 7736#pragma warning(disable:4200)
 7737#pragma warning(default:4200)
 7738#pragma once
 7739NTSTATUS PptPowerComplete(PDEVICE_OBJECT pDeviceObject , PIRP pIrp , PDEVICE_EXTENSION Extension ) 
 7740{ POWER_STATE_TYPE powerType ;
 7741  POWER_STATE powerState ;
 7742  PIO_STACK_LOCATION pIrpStack ;
 7743
 7744  {
 7745  pIrpStack = pIrp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 7746  powerType = pIrpStack->Parameters.Power.Type;
 7747  powerState = pIrpStack->Parameters.Power.State;
 7748  if (pIrpStack->MinorFunction == 3) {
 7749    goto switch_274_3;
 7750  } else {
 7751    if (pIrpStack->MinorFunction == 2) {
 7752      goto switch_274_2;
 7753    } else {
 7754      {
 7755      goto switch_274_default;
 7756      if (0) {
 7757        switch_274_3: /* CIL Label */ ;
 7758        goto switch_274_break;
 7759        switch_274_2: /* CIL Label */ ;
 7760        {
 7761        }
 7762        if (powerType == 1) {
 7763          goto switch_276_1;
 7764        } else {
 7765          if (powerType == 0) {
 7766            goto switch_276_0;
 7767          } else {
 7768            if (0) {
 7769              switch_276_1: /* CIL Label */ ;
 7770              if ((int )Extension->DeviceState < (int )powerState.DeviceState) {
 7771
 7772              } else {
 7773                if ((int )powerState.DeviceState < (int )Extension->DeviceState) {
 7774                  {
 7775                  PoSetPowerState(Extension->DeviceObject, powerType, powerState);
 7776                  }
 7777                  if (1 == (int )Extension->DeviceState) {
 7778
 7779                  } else {
 7780
 7781                  }
 7782                  Extension->DeviceState = powerState.DeviceState;
 7783                } else {
 7784
 7785                }
 7786              }
 7787              goto switch_276_break;
 7788              switch_276_0: /* CIL Label */ ;
 7789              if ((int )Extension->SystemState < (int )powerState.SystemState) {
 7790
 7791              } else {
 7792                if ((int )powerState.SystemState < (int )Extension->SystemState) {
 7793                  if (1 == (int )powerState.SystemState) {
 7794                    {
 7795                    powerState.DeviceState = 1;
 7796                    PoRequestPowerIrp(Extension->DeviceObject, 2, powerState, (void *)0,
 7797                                      (void *)0, (void *)0);
 7798                    }
 7799                  } else {
 7800
 7801                  }
 7802                  Extension->SystemState = powerState.SystemState;
 7803                } else {
 7804
 7805                }
 7806              }
 7807              goto switch_276_break;
 7808            } else {
 7809              switch_276_break: /* CIL Label */ ;
 7810            }
 7811          }
 7812        }
 7813        goto switch_274_break;
 7814        switch_274_default: /* CIL Label */ ;
 7815      } else {
 7816        switch_274_break: /* CIL Label */ ;
 7817      }
 7818      }
 7819    }
 7820  }
 7821  {
 7822/*   PoStartNextPowerIrp(pIrp); */ /* INLINED */
 7823  }
 7824  return (0L);
 7825}
 7826}
 7827void InitNEC_98(PDEVICE_EXTENSION Extension ) 
 7828{ PUCHAR Controller ;
 7829
 7830  {
 7831  {
 7832  Controller = Extension->PortInfo.Controller;
 7833  WRITE_PORT_UCHAR(Controller + 9, 16);
 7834  WRITE_PORT_UCHAR(Controller + 14, 0);
 7835  WRITE_PORT_UCHAR(Controller + 2, 4);
 7836  }
 7837  return;
 7838}
 7839}
 7840NTSTATUS PptDispatchPower(PDEVICE_OBJECT pDeviceObject , PIRP pIrp ) 
 7841{ POWER_STATE_TYPE powerType ;
 7842  POWER_STATE powerState ;
 7843  PIO_STACK_LOCATION pIrpStack ;
 7844  NTSTATUS status ;
 7845  PDEVICE_EXTENSION Extension ;
 7846  BOOLEAN hookit ;
 7847  NTSTATUS status___0 ;
 7848  NTSTATUS tmp ;
 7849  PIO_STACK_LOCATION irpSp ;
 7850  PIO_STACK_LOCATION nextIrpSp ;
 7851  PIO_STACK_LOCATION irpSp___0 ;
 7852
 7853  {
 7854  {
 7855  status = 0L;
 7856  hookit = 0;
 7857  Extension = pDeviceObject->DeviceExtension;
 7858  pIrpStack = pIrp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 7859  tmp = PptAcquireRemoveLock(& Extension->RemoveLock, pIrp);
 7860  status___0 = tmp;
 7861  }
 7862  if (! (status___0 >= 0L)) {
 7863    {
 7864/*     PoStartNextPowerIrp(pIrp); */ /* INLINED */
 7865    pIrp->IoStatus.__annonCompField4.Status = status___0;
 7866    PptCompleteRequest(pIrp, 0);
 7867    }
 7868    return (status___0);
 7869  } else {
 7870
 7871  }
 7872  powerType = pIrpStack->Parameters.Power.Type;
 7873  powerState = pIrpStack->Parameters.Power.State;
 7874  if (pIrpStack->MinorFunction == 3) {
 7875    goto switch_277_3;
 7876  } else {
 7877    if (pIrpStack->MinorFunction == 2) {
 7878      goto switch_277_2;
 7879    } else {
 7880      {
 7881      goto switch_277_default;
 7882      if (0) {
 7883        switch_277_3: /* CIL Label */ 
 7884        status = 0L;
 7885        goto switch_277_break;
 7886        switch_277_2: /* CIL Label */ ;
 7887        {
 7888        }
 7889        if (powerType == 1) {
 7890          goto switch_279_1;
 7891        } else {
 7892          if (powerType == 0) {
 7893            goto switch_279_0;
 7894          } else {
 7895            if (0) {
 7896              switch_279_1: /* CIL Label */ ;
 7897              if ((int )Extension->DeviceState < (int )powerState.DeviceState) {
 7898                {
 7899                PoSetPowerState(Extension->DeviceObject, powerType, powerState);
 7900                }
 7901                if (1 == (int )Extension->DeviceState) {
 7902
 7903                } else {
 7904
 7905                }
 7906                Extension->DeviceState = powerState.DeviceState;
 7907              } else {
 7908                if ((int )powerState.DeviceState < (int )Extension->DeviceState) {
 7909                  hookit = 1;
 7910                  if ((int )((KUSER_SHARED_DATA * const  )4292804608U)->AlternativeArchitecture == 1) {
 7911                    {
 7912                    InitNEC_98(Extension);
 7913                    }
 7914                  } else {
 7915
 7916                  }
 7917                } else {
 7918
 7919                }
 7920              }
 7921              goto switch_279_break;
 7922              switch_279_0: /* CIL Label */ ;
 7923              if ((int )Extension->SystemState < (int )powerState.SystemState) {
 7924                if (1 == (int )Extension->SystemState) {
 7925
 7926                } else {
 7927
 7928                }
 7929                {
 7930                powerState.DeviceState = 4;
 7931                PoRequestPowerIrp(Extension->DeviceObject, 2, powerState, (void *)0,
 7932                                  (void *)0, (void *)0);
 7933                Extension->SystemState = powerState.SystemState;
 7934                }
 7935              } else {
 7936                if ((int )powerState.SystemState < (int )Extension->SystemState) {
 7937                  hookit = 1;
 7938                } else {
 7939
 7940                }
 7941              }
 7942              goto switch_279_break;
 7943            } else {
 7944              switch_279_break: /* CIL Label */ ;
 7945            }
 7946          }
 7947        }
 7948        goto switch_277_break;
 7949        switch_277_default: /* CIL Label */ 
 7950        status = -1073741637L;
 7951      } else {
 7952        switch_277_break: /* CIL Label */ ;
 7953      }
 7954      }
 7955    }
 7956  }
 7957  {
 7958  irpSp = pIrp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation;
 7959  nextIrpSp = pIrp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation - 1;
 7960  memcpy(nextIrpSp, irpSp, (long )(& ((IO_STACK_LOCATION *)0)->CompletionRoutine));
 7961  nextIrpSp->Control = 0;
 7962  }
 7963  if (! (status >= 0L)) {
 7964    {
 7965    pIrp->IoStatus.__annonCompField4.Status = status;
 7966/*     PoStartNextPowerIrp(pIrp); */ /* INLINED */
 7967    PptCompleteRequest(pIrp, 0);
 7968    }
 7969  } else {
 7970    if (hookit) {
 7971      if (s != NP) {
 7972        {
 7973        errorFn();
 7974        }
 7975      } else {
 7976        if (compRegistered != 0) {
 7977          {
 7978          errorFn();
 7979          }
 7980        } else {
 7981          compRegistered = 1;
 7982          compFptr = & PptPowerComplete;
 7983          routine = 1;
 7984        }
 7985      }
 7986      {
 7987      irpSp___0 = pIrp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation - 1;
 7988      irpSp___0->CompletionRoutine = & PptPowerComplete;
 7989      irpSp___0->Context = Extension;
 7990      irpSp___0->Control = 0;
 7991      irpSp___0->Control = 64;
 7992      irpSp___0->Control = (int )irpSp___0->Control | 128;
 7993      irpSp___0->Control = (int )irpSp___0->Control | 32;
 7994      status = PoCallDriver(Extension->ParentDeviceObject, pIrp);
 7995      }
 7996    } else {
 7997      {
 7998/*       PoStartNextPowerIrp(pIrp); */ /* INLINED */
 7999      status = PoCallDriver(Extension->ParentDeviceObject, pIrp);
 8000      }
 8001    }
 8002  }
 8003  {
 8004  PptReleaseRemoveLock(& Extension->RemoveLock, pIrp);
 8005  }
 8006  return (status);
 8007}
 8008}
 8009#pragma once
 8010#pragma once
 8011#pragma once
 8012#pragma once
 8013#pragma warning(push)
 8014#pragma warning(disable:4035)
 8015#pragma warning(pop)
 8016#pragma once
 8017#pragma warning(disable:4103)
 8018#pragma warning(disable:4103)
 8019#pragma warning(push)
 8020#pragma warning(disable:4035)
 8021#pragma warning(pop)
 8022#pragma warning(disable:4035)
 8023#pragma warning(push)
 8024#pragma warning(disable:4164)
 8025#pragma function(_enable)
 8026#pragma function(_disable)
 8027#pragma warning(pop)
 8028#pragma warning(disable:4103)
 8029#pragma warning(disable:4103)
 8030#pragma warning(disable:4103)
 8031#pragma warning(disable:4103)
 8032#pragma warning(disable:4103)
 8033#pragma warning(disable:4103)
 8034#pragma warning(disable:4200)
 8035#pragma warning(default:4200)
 8036static UCHAR LegacyZipModeQualifier___11[3]  = {      0,      60,      32};
 8037#pragma once
 8038void PptLegacyZipClockDiskModeByte(PUCHAR Controller , UCHAR ModeByte ) 
 8039{ 
 8040
 8041  {
 8042  {
 8043  WRITE_PORT_UCHAR(Controller, ModeByte);
 8044  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)4);
 8045  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)6);
 8046  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)4);
 8047  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)12);
 8048  }
 8049  return;
 8050}
 8051}
 8052void PptLegacyZipClockPrtModeByte(PUCHAR Controller , UCHAR ModeByte ) 
 8053{ 
 8054
 8055  {
 8056  {
 8057  WRITE_PORT_UCHAR(Controller, ModeByte);
 8058  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)12);
 8059  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)14);
 8060  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)12);
 8061  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)4);
 8062  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)12);
 8063  }
 8064  return;
 8065}
 8066}
 8067void PptLegacyZipSetDiskMode(PUCHAR Controller , UCHAR Mode ) 
 8068{ ULONG i = __VERIFIER_nondet_long() ;
 8069
 8070  {
 8071  {
 8072  PptLegacyZipClockDiskModeByte(Controller, LegacyZipModeQualifier___11[i]);
 8073  PptLegacyZipClockDiskModeByte(Controller, Mode);
 8074  }
 8075  return;
 8076}
 8077}
 8078BOOLEAN PptLegacyZipCheckDevice(PUCHAR Controller ) 
 8079{ UCHAR tmp ;
 8080  UCHAR tmp___0 ;
 8081
 8082  {
 8083  {
 8084  WRITE_PORT_UCHAR(Controller + 2, (unsigned char)6);
 8085  tmp___0 = READ_PORT_UCHAR(Controller + 1);
 8086  }
 8087  if (((int )tmp___0 & 8) == 8) {
 8088    {
 8089    WRITE_PORT_UCHAR(Controller + 2, (unsigned char)4);
 8090    tmp = READ_PORT_UCHAR(Controller + 1);
 8091    }
 8092    if (((int )tmp & 8) != 8) {
 8093      return (1);
 8094    } else {
 8095
 8096    }
 8097  } else {
 8098
 8099  }
 8100  return (0);
 8101}
 8102}
 8103NTSTATUS PptTrySelectLegacyZip(PVOID Context , PVOID TrySelectCommand ) 
 8104{ PDEVICE_EXTENSION Extension ;
 8105  PPARALLEL_1284_COMMAND Command ;
 8106  NTSTATUS Status ;
 8107  PUCHAR Controller ;
 8108  SYNCHRONIZED_COUNT_CONTEXT SyncContext ;
 8109  KIRQL CancelIrql ;
 8110  BOOLEAN tmp ;
 8111
 8112  {
 8113  Extension = Context;
 8114  Command = TrySelectCommand;
 8115  Status = 0L;
 8116  Controller = Extension->PortInfo.Controller;
 8117  {
 8118  }
 8119  if (! (Command->CommandFlags & 2UL)) {
 8120    {
 8121    }
 8122    {
 8123    IoAcquireCancelSpinLock(& CancelIrql);
 8124    SyncContext.Count = & Extension->WorkQueueCount;
 8125    }
 8126    if (Extension->InterruptRefCount) {
 8127      {
 8128      KeSynchronizeExecution(Extension->InterruptObject, & PptSynchronizedIncrement,
 8129                             & SyncContext);
 8130      }
 8131    } else {
 8132      {
 8133      PptSynchronizedIncrement(& SyncContext);
 8134      }
 8135    }
 8136    if (SyncContext.NewCount) {
 8137      Status = 259L;
 8138    } else {
 8139
 8140    }
 8141    {
 8142/*     IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 8143    }
 8144  } else {
 8145
 8146  }
 8147  if (Status >= 0L) {
 8148    if (Status != 259L) {
 8149      if (Command->CommandFlags & 32UL) {
 8150        {
 8151        PptLegacyZipSetDiskMode(Controller, (unsigned char)207);
 8152        }
 8153      } else {
 8154        {
 8155        PptLegacyZipSetDiskMode(Controller, (unsigned char)143);
 8156        }
 8157      }
 8158      {
 8159      tmp = PptLegacyZipCheckDevice(Controller);
 8160      }
 8161      if (tmp) {
 8162        {
 8163        }
 8164        if (! Extension->CheckedForGenericEpp) {
 8165          if (Extension->PnpInfo.HardwareCapabilities & 1UL) {
 8166            if (! Extension->NationalChipFound) {
 8167              {
 8168              PptDetectEppPort(Extension);
 8169              }
 8170            } else {
 8171
 8172            }
 8173          } else {
 8174
 8175          }
 8176          Extension->CheckedForGenericEpp = 1;
 8177        } else {
 8178
 8179        }
 8180      } else {
 8181        {
 8182        }
 8183        {
 8184        PptDeselectLegacyZip(Context, TrySelectCommand);
 8185        Status = -1073741823L;
 8186        }
 8187      }
 8188    } else {
 8189
 8190    }
 8191  } else {
 8192
 8193  }
 8194  return (Status);
 8195}
 8196}
 8197NTSTATUS PptDeselectLegacyZip(PVOID Context , PVOID DeselectCommand ) 
 8198{ ULONG i = __VERIFIER_nondet_long() ;
 8199  PDEVICE_EXTENSION Extension ;
 8200  PUCHAR Controller ;
 8201  PPARALLEL_1284_COMMAND Command ;
 8202
 8203  {
 8204  Extension = Context;
 8205  Controller = Extension->PortInfo.Controller;
 8206  Command = DeselectCommand;
 8207  {
 8208  }
 8209  {
 8210  PptLegacyZipClockPrtModeByte(Controller, LegacyZipModeQualifier___11[i]);
 8211  PptLegacyZipClockPrtModeByte(Controller, (unsigned char)15);
 8212  }
 8213  if (! (Command->CommandFlags & 2UL)) {
 8214    {
 8215    PptFreePort(Extension);
 8216    }
 8217  } else {
 8218
 8219  }
 8220  return (0L);
 8221}
 8222}
 8223#pragma once
 8224#pragma once
 8225#pragma once
 8226#pragma once
 8227#pragma warning(push)
 8228#pragma warning(disable:4035)
 8229#pragma warning(pop)
 8230#pragma once
 8231#pragma warning(disable:4103)
 8232#pragma warning(disable:4103)
 8233#pragma warning(push)
 8234#pragma warning(disable:4035)
 8235#pragma warning(pop)
 8236#pragma warning(disable:4035)
 8237#pragma warning(push)
 8238#pragma warning(disable:4164)
 8239#pragma function(_enable)
 8240#pragma function(_disable)
 8241#pragma warning(pop)
 8242#pragma warning(disable:4103)
 8243#pragma warning(disable:4103)
 8244#pragma warning(disable:4103)
 8245#pragma warning(disable:4103)
 8246#pragma warning(disable:4103)
 8247#pragma warning(disable:4103)
 8248#pragma warning(disable:4200)
 8249#pragma warning(default:4200)
 8250#pragma once
 8251void PptRegInitDriverSettings(PUNICODE_STRING RegistryPath___0 ) 
 8252{ NTSTATUS Status ;
 8253  RTL_QUERY_REGISTRY_TABLE paramTable[3] ;
 8254  PWSTR path ;
 8255  ULONG defaultDebugLevel ;
 8256  ULONG defaultBreakOn ;
 8257  PVOID tmp ;
 8258
 8259  {
 8260  {
 8261  defaultDebugLevel = 0UL;
 8262  defaultBreakOn = 0UL;
 8263  tmp = ExAllocatePoolWithTag(1, (unsigned int )RegistryPath___0->Length + sizeof(WCHAR ),
 8264                              1349673296UL);
 8265  path = tmp;
 8266  }
 8267  if (! path) {
 8268    PptDebugLevel = defaultDebugLevel;
 8269    PptBreakOn = defaultBreakOn;
 8270    return;
 8271  } else {
 8272
 8273  }
 8274  {
 8275  memmove(path, RegistryPath___0->Buffer, RegistryPath___0->Length);
 8276  *(path + (int )RegistryPath___0->Length / 2) = (unsigned short)0;
 8277  memset(paramTable, 0, sizeof(paramTable));
 8278  paramTable[0].Flags = 32;
 8279  paramTable[0].EntryContext = & PptDebugLevel;
 8280  paramTable[0].DefaultType = 4;
 8281  paramTable[0].DefaultData = & defaultDebugLevel;
 8282  paramTable[0].DefaultLength = sizeof(ULONG );
 8283  paramTable[1].Flags = 32;
 8284  paramTable[1].EntryContext = & PptBreakOn;
 8285  paramTable[1].DefaultType = 4;
 8286  paramTable[1].DefaultData = & defaultBreakOn;
 8287  paramTable[1].DefaultLength = sizeof(ULONG );
 8288  Status = RtlQueryRegistryValues(2147483648U, path, paramTable, (void *)0, (void *)0);
 8289  }
 8290  if (! (Status >= 0L)) {
 8291    PptDebugLevel = defaultDebugLevel;
 8292    PptBreakOn = defaultBreakOn;
 8293  } else {
 8294
 8295  }
 8296  {
 8297/*   ExFreePool(path); */ /* INLINED */
 8298  }
 8299  {
 8300  }
 8301  return;
 8302}
 8303}
 8304NTSTATUS PptRegGetDeviceParameterDword(PDEVICE_OBJECT Pdo , PWSTR ParameterName ,
 8305                                       PULONG ParameterValue ) 
 8306{ NTSTATUS status ;
 8307  HANDLE hKey ;
 8308  RTL_QUERY_REGISTRY_TABLE queryTable[2] ;
 8309  ULONG defaultValue ;
 8310
 8311  {
 8312  {
 8313  status = IoOpenDeviceRegistryKey(Pdo, 1, 131097L, & hKey);
 8314  }
 8315  if (! (status >= 0L)) {
 8316    return (status);
 8317  } else {
 8318
 8319  }
 8320  {
 8321  defaultValue = *ParameterValue;
 8322  memset(& queryTable, 0, sizeof(queryTable));
 8323  queryTable[0].Flags = 32;
 8324  queryTable[0].Name = ParameterName;
 8325  queryTable[0].EntryContext = ParameterValue;
 8326  queryTable[0].DefaultType = 4;
 8327  queryTable[0].DefaultData = & defaultValue;
 8328  queryTable[0].DefaultLength = sizeof(ULONG );
 8329  status = RtlQueryRegistryValues(1073741824, hKey, queryTable, (void *)0, (void *)0);
 8330  }
 8331  if (! (status >= 0L)) {
 8332    *ParameterValue = defaultValue;
 8333  } else {
 8334
 8335  }
 8336  {
 8337  ZwClose(hKey);
 8338  }
 8339  return (status);
 8340}
 8341}
 8342NTSTATUS PptRegSetDeviceParameterDword(PDEVICE_OBJECT Pdo , PWSTR ParameterName ,
 8343                                       PULONG ParameterValue ) 
 8344{ NTSTATUS status ;
 8345  HANDLE hKey ;
 8346  UNICODE_STRING valueName ;
 8347
 8348  {
 8349  {
 8350  status = IoOpenDeviceRegistryKey(Pdo, 1, 131078L, & hKey);
 8351  }
 8352  if (! (status >= 0L)) {
 8353    {
 8354    }
 8355    return (status);
 8356  } else {
 8357
 8358  }
 8359  {
 8360/*   RtlInitUnicodeString(& valueName, ParameterName); */ /* INLINED */
 8361  status = ZwSetValueKey(hKey, & valueName, 0, 4, ParameterValue, sizeof(ULONG ));
 8362  }
 8363  if (! (status >= 0L)) {
 8364    {
 8365    }
 8366  } else {
 8367
 8368  }
 8369  {
 8370  ZwClose(hKey);
 8371  }
 8372  return (status);
 8373}
 8374}
 8375#pragma once
 8376#pragma once
 8377#pragma once
 8378#pragma once
 8379#pragma warning(push)
 8380#pragma warning(disable:4035)
 8381#pragma warning(pop)
 8382#pragma once
 8383#pragma warning(disable:4103)
 8384#pragma warning(disable:4103)
 8385#pragma warning(push)
 8386#pragma warning(disable:4035)
 8387#pragma warning(pop)
 8388#pragma warning(disable:4035)
 8389#pragma warning(push)
 8390#pragma warning(disable:4164)
 8391#pragma function(_enable)
 8392#pragma function(_disable)
 8393#pragma warning(pop)
 8394#pragma warning(disable:4103)
 8395#pragma warning(disable:4103)
 8396#pragma warning(disable:4103)
 8397#pragma warning(disable:4103)
 8398#pragma warning(disable:4103)
 8399#pragma warning(disable:4103)
 8400#pragma warning(disable:4200)
 8401#pragma warning(default:4200)
 8402#pragma once
 8403NTSTATUS PptFailRequest(PIRP Irp , NTSTATUS Status ) 
 8404{ 
 8405
 8406  {
 8407  {
 8408  Irp->IoStatus.__annonCompField4.Status = Status;
 8409  myStatus = Status;
 8410  Irp->IoStatus.Information = 0;
 8411  PptCompleteRequest(Irp, 0);
 8412  }
 8413  return (Status);
 8414}
 8415}
 8416NTSTATUS PptAcquireRemoveLockOrFailIrp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 8417{ PDEVICE_EXTENSION extension ;
 8418  PIO_REMOVE_LOCK removeLock ;
 8419  NTSTATUS status ;
 8420  NTSTATUS tmp ;
 8421
 8422  {
 8423  {
 8424  extension = DeviceObject->DeviceExtension;
 8425  removeLock = & extension->RemoveLock;
 8426  tmp = IoAcquireRemoveLockEx(removeLock, Irp, "util.c", 33, sizeof(IO_REMOVE_LOCK ));
 8427  status = tmp;
 8428  }
 8429  if (! (status >= 0L)) {
 8430    {
 8431    PptFailRequest(Irp, status);
 8432    }
 8433  } else {
 8434
 8435  }
 8436  return (status);
 8437}
 8438}
 8439NTSTATUS PptDispatchPreProcessIrp(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 8440{ PDEVICE_EXTENSION Extension ;
 8441  NTSTATUS status ;
 8442  NTSTATUS tmp ;
 8443
 8444  {
 8445  {
 8446  Extension = DeviceObject->DeviceExtension;
 8447  tmp = PptAcquireRemoveLock(& Extension->RemoveLock, Irp);
 8448  status = tmp;
 8449  }
 8450  if (! (status >= 0L)) {
 8451    {
 8452    Irp->IoStatus.Information = 0;
 8453    Irp->IoStatus.__annonCompField4.Status = status;
 8454    myStatus = status;
 8455    PptCompleteRequest(Irp, 0);
 8456    }
 8457  } else {
 8458
 8459  }
 8460  return (status);
 8461}
 8462}
 8463NTSTATUS PptDispatchPostProcessIrp(void) 
 8464{ 
 8465
 8466  {
 8467  return (0L);
 8468}
 8469}
 8470NTSTATUS PptSynchCompletionRoutine(PDEVICE_OBJECT DeviceObject , PIRP Irp , PKEVENT Event ) 
 8471{ 
 8472
 8473  {
 8474  {
 8475  KeSetEvent(Event, 0, 0);
 8476  }
 8477  return (-1073741802L);
 8478}
 8479}
 8480PWSTR PptGetPortNameFromPhysicalDeviceObject(PDEVICE_OBJECT PhysicalDeviceObject ) 
 8481{ NTSTATUS status ;
 8482  HANDLE hKey ;
 8483  PKEY_VALUE_FULL_INFORMATION buffer ;
 8484  ULONG bufferLength ;
 8485  ULONG resultLength ;
 8486  PWSTR valueNameWstr ;
 8487  UNICODE_STRING valueName ;
 8488  PWSTR portName ;
 8489  PVOID tmp ;
 8490  PVOID tmp___0 ;
 8491
 8492  {
 8493  {
 8494  }
 8495  {
 8496  status = IoOpenDeviceRegistryKey(PhysicalDeviceObject, 1, 2031616L, & hKey);
 8497  }
 8498  if (! (status >= 0L)) {
 8499    {
 8500    }
 8501    return ((void *)0);
 8502  } else {
 8503
 8504  }
 8505  {
 8506  bufferLength = 0;
 8507  buffer = (void *)0;
 8508/*   RtlInitUnicodeString(& valueName, valueNameWstr); */ /* INLINED */
 8509  status = -1073741789L;
 8510  }
 8511  {
 8512  while (1) {
 8513    while_290_continue: /* CIL Label */ ;
 8514    if (status == -1073741789L) {
 8515
 8516    } else {
 8517      goto while_290_break;
 8518    }
 8519    {
 8520    status = ZwQueryValueKey(hKey, & valueName, 1, buffer, bufferLength, & resultLength);
 8521    }
 8522    if (status == -1073741789L) {
 8523      if (buffer) {
 8524        {
 8525/*         ExFreePool(buffer); */ /* INLINED */
 8526        }
 8527      } else {
 8528
 8529      }
 8530      {
 8531      tmp = ExAllocatePoolWithTag(1, resultLength, 1349673296UL);
 8532      buffer = tmp;
 8533      bufferLength = resultLength;
 8534      }
 8535      if (! buffer) {
 8536        {
 8537        }
 8538        {
 8539        ZwClose(hKey);
 8540        }
 8541        return ((void *)0);
 8542      } else {
 8543
 8544      }
 8545    } else {
 8546
 8547    }
 8548  }
 8549  while_290_break: /* CIL Label */ ;
 8550  }
 8551  {
 8552  ZwClose(hKey);
 8553  }
 8554  if (! (status >= 0L)) {
 8555    if (buffer) {
 8556      {
 8557/*       ExFreePool(buffer); */ /* INLINED */
 8558      }
 8559    } else {
 8560
 8561    }
 8562    {
 8563    }
 8564    return ((void *)0);
 8565  } else {
 8566
 8567  }
 8568  if (buffer->Type != 1UL) {
 8569    goto _L;
 8570  } else {
 8571    if (! buffer->DataLength) {
 8572      _L: /* CIL Label */ 
 8573      {
 8574      }
 8575      {
 8576/*       ExFreePool(buffer); */ /* INLINED */
 8577      }
 8578      return ((void *)0);
 8579    } else {
 8580
 8581    }
 8582  }
 8583  {
 8584  tmp___0 = ExAllocatePoolWithTag(1, buffer->DataLength, 1349673296UL);
 8585  portName = tmp___0;
 8586  }
 8587  if (! portName) {
 8588    {
 8589    }
 8590    {
 8591/*     ExFreePool(buffer); */ /* INLINED */
 8592    }
 8593    return ((void *)0);
 8594  } else {
 8595
 8596  }
 8597  {
 8598  memcpy(portName, (UCHAR *)buffer + buffer->DataOffset, buffer->DataLength);
 8599/*   ExFreePool(buffer); */ /* INLINED */
 8600  }
 8601  return (portName);
 8602}
 8603}
 8604NTSTATUS PptConnectInterrupt(PDEVICE_EXTENSION Extension ) 
 8605{ NTSTATUS Status ;
 8606
 8607  {
 8608  Status = 0L;
 8609  if (! Extension->FoundInterrupt) {
 8610    return (-1073741637L);
 8611  } else {
 8612
 8613  }
 8614  {
 8615  Status = IoConnectInterrupt(& Extension->InterruptObject, & PptInterruptService,
 8616                              Extension, (void *)0, Extension->InterruptVector, Extension->InterruptLevel,
 8617                              Extension->InterruptLevel, Extension->InterruptMode,
 8618                              1, Extension->InterruptAffinity, 0);
 8619  }
 8620  if (! (Status >= 0L)) {
 8621    {
 8622    PptLogError((Extension->DeviceObject)->DriverObject, Extension->DeviceObject,
 8623                Extension->PortInfo.OriginalController, PhysicalZero, 0, 0, 0, 14,
 8624                Status, 20);
 8625    }
 8626    {
 8627    }
 8628  } else {
 8629
 8630  }
 8631  return (Status);
 8632}
 8633}
 8634void PptDisconnectInterrupt(PDEVICE_EXTENSION Extension ) 
 8635{ 
 8636
 8637  {
 8638  {
 8639  IoDisconnectInterrupt(Extension->InterruptObject);
 8640  }
 8641  return;
 8642}
 8643}
 8644BOOLEAN PptSynchronizedIncrement(PVOID SyncContext ) 
 8645{ 
 8646
 8647  {
 8648  *(((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->Count) += 1L;
 8649  ((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->NewCount = *(((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->Count);
 8650  return (1);
 8651}
 8652}
 8653BOOLEAN PptSynchronizedDecrement(PVOID SyncContext ) 
 8654{ 
 8655
 8656  {
 8657  *(((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->Count) -= 1L;
 8658  ((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->NewCount = *(((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->Count);
 8659  return (1);
 8660}
 8661}
 8662BOOLEAN PptSynchronizedRead(PVOID SyncContext ) 
 8663{ 
 8664
 8665  {
 8666  ((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->NewCount = *(((struct _SYNCHRONIZED_COUNT_CONTEXT *)SyncContext)->Count);
 8667  return (1);
 8668}
 8669}
 8670BOOLEAN PptSynchronizedQueue(PVOID Context ) 
 8671{ PSYNCHRONIZED_LIST_CONTEXT ListContext ;
 8672  PLIST_ENTRY _EX_Blink ;
 8673  PLIST_ENTRY _EX_ListHead ;
 8674
 8675  {
 8676  ListContext = Context;
 8677  _EX_ListHead = ListContext->List;
 8678  _EX_Blink = _EX_ListHead->Blink;
 8679  (ListContext->NewEntry)->Flink = _EX_ListHead;
 8680  (ListContext->NewEntry)->Blink = _EX_Blink;
 8681  _EX_Blink->Flink = ListContext->NewEntry;
 8682  _EX_ListHead->Blink = ListContext->NewEntry;
 8683  return (1);
 8684}
 8685}
 8686BOOLEAN PptSynchronizedDisconnect(PVOID Context ) 
 8687{ PSYNCHRONIZED_DISCONNECT_CONTEXT DisconnectContext ;
 8688  BOOLEAN (*ServiceRoutine)(struct _KINTERRUPT *Interrupt , PVOID ServiceContext ) ;
 8689  PVOID ServiceContext ;
 8690  PLIST_ENTRY Current ;
 8691  PISR_LIST_ENTRY ListEntry ;
 8692  PLIST_ENTRY _EX_Blink ;
 8693  PLIST_ENTRY _EX_Flink ;
 8694
 8695  {
 8696  DisconnectContext = Context;
 8697  ServiceRoutine = (DisconnectContext->IsrInfo)->InterruptServiceRoutine;
 8698  ServiceContext = (DisconnectContext->IsrInfo)->InterruptServiceContext;
 8699  Current = (DisconnectContext->Extension)->IsrList.Flink;
 8700  {
 8701  while (1) {
 8702    while_296_continue: /* CIL Label */ ;
 8703    if ((unsigned int )Current != (unsigned int )(& (DisconnectContext->Extension)->IsrList)) {
 8704
 8705    } else {
 8706      goto while_296_break;
 8707    }
 8708    ListEntry = (ISR_LIST_ENTRY *)((CHAR *)Current - (unsigned long )(& ((ISR_LIST_ENTRY *)0)->ListEntry));
 8709    if ((unsigned int )ListEntry->ServiceRoutine == (unsigned int )ServiceRoutine) {
 8710      if ((unsigned int )ListEntry->ServiceContext == (unsigned int )ServiceContext) {
 8711        _EX_Flink = Current->Flink;
 8712        _EX_Blink = Current->Blink;
 8713        _EX_Blink->Flink = _EX_Flink;
 8714        _EX_Flink->Blink = _EX_Blink;
 8715        return (1);
 8716      } else {
 8717
 8718      }
 8719    } else {
 8720
 8721    }
 8722    Current = Current->Flink;
 8723  }
 8724  while_296_break: /* CIL Label */ ;
 8725  }
 8726  return (0);
 8727}
 8728}
 8729void PptCancelRoutine(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 8730{ PDEVICE_EXTENSION Extension ;
 8731  SYNCHRONIZED_COUNT_CONTEXT SyncContext ;
 8732  PLIST_ENTRY _EX_Blink ;
 8733  PLIST_ENTRY _EX_Flink ;
 8734
 8735  {
 8736  {
 8737  }
 8738  Extension = DeviceObject->DeviceExtension;
 8739  SyncContext.Count = & Extension->WorkQueueCount;
 8740  if (Extension->InterruptRefCount) {
 8741    {
 8742    KeSynchronizeExecution(Extension->InterruptObject, & PptSynchronizedDecrement,
 8743                           & SyncContext);
 8744    }
 8745  } else {
 8746    {
 8747    PptSynchronizedDecrement(& SyncContext);
 8748    }
 8749  }
 8750  {
 8751  _EX_Flink = Irp->Tail.Overlay.__annonCompField17.ListEntry.Flink;
 8752  _EX_Blink = Irp->Tail.Overlay.__annonCompField17.ListEntry.Blink;
 8753  _EX_Blink->Flink = _EX_Flink;
 8754  _EX_Flink->Blink = _EX_Blink;
 8755/*   IoReleaseCancelSpinLock(Irp->CancelIrql); */ /* INLINED */
 8756  Irp->IoStatus.Information = 0;
 8757  Irp->IoStatus.__annonCompField4.Status = -1073741536L;
 8758  myStatus = -1073741536L;
 8759  PptReleaseRemoveLock(& Extension->RemoveLock, Irp);
 8760  PptCompleteRequest(Irp, 0);
 8761  }
 8762  return;
 8763}
 8764}
 8765void PptFreePortDpc(PKDPC Dpc , PVOID Extension , PVOID SystemArgument1 , PVOID SystemArgument2 ) 
 8766{ 
 8767
 8768  {
 8769  {
 8770  PptFreePort(Extension);
 8771  }
 8772  return;
 8773}
 8774}
 8775BOOLEAN PptTryAllocatePortAtInterruptLevel(PVOID Context ) 
 8776{ 
 8777
 8778  {
 8779  if (((struct _DEVICE_EXTENSION *)Context)->WorkQueueCount == -1L) {
 8780    ((struct _DEVICE_EXTENSION *)Context)->WorkQueueCount = 0;
 8781    ((struct _DEVICE_EXTENSION *)Context)->WmiPortAllocFreeCounts.PortAllocates += 1UL;
 8782    return (1);
 8783  } else {
 8784    return (0);
 8785  }
 8786}
 8787}
 8788void PptFreePortFromInterruptLevel(PVOID Context ) 
 8789{ 
 8790
 8791  {
 8792  if (((struct _DEVICE_EXTENSION *)Context)->WorkQueueCount == 0L) {
 8793    ((struct _DEVICE_EXTENSION *)Context)->WorkQueueCount = -1;
 8794  } else {
 8795    {
 8796    KeInsertQueueDpc(& ((struct _DEVICE_EXTENSION *)Context)->FreePortDpc, (void *)0,
 8797                     (void *)0);
 8798    }
 8799  }
 8800  return;
 8801}
 8802}
 8803BOOLEAN PptInterruptService(PKINTERRUPT Interrupt , PVOID Extension ) 
 8804{ PLIST_ENTRY Current ;
 8805  PISR_LIST_ENTRY IsrListEntry ;
 8806  PDEVICE_EXTENSION DeviceExtension ;
 8807  BOOLEAN tmp ;
 8808
 8809  {
 8810  DeviceExtension = Extension;
 8811  Current = DeviceExtension->IsrList.Flink;
 8812  {
 8813  while (1) {
 8814    while_298_continue: /* CIL Label */ ;
 8815    if ((unsigned int )Current != (unsigned int )(& DeviceExtension->IsrList)) {
 8816
 8817    } else {
 8818      goto while_298_break;
 8819    }
 8820    {
 8821    IsrListEntry = (ISR_LIST_ENTRY *)((CHAR *)Current - (unsigned long )(& ((ISR_LIST_ENTRY *)0)->ListEntry));
 8822    tmp = (*(IsrListEntry->ServiceRoutine))(Interrupt, IsrListEntry->ServiceContext);
 8823    }
 8824    if (tmp) {
 8825      return (1);
 8826    } else {
 8827
 8828    }
 8829    Current = Current->Flink;
 8830  }
 8831  while_298_break: /* CIL Label */ ;
 8832  }
 8833  return (0);
 8834}
 8835}
 8836BOOLEAN PptTryAllocatePort(PVOID Extension ) 
 8837{ PDEVICE_EXTENSION DeviceExtension ;
 8838  KIRQL CancelIrql ;
 8839  BOOLEAN b ;
 8840
 8841  {
 8842  DeviceExtension = Extension;
 8843  if (DeviceExtension->InterruptRefCount) {
 8844    {
 8845    b = KeSynchronizeExecution(DeviceExtension->InterruptObject, & PptTryAllocatePortAtInterruptLevel,
 8846                               DeviceExtension);
 8847    }
 8848  } else {
 8849    {
 8850    IoAcquireCancelSpinLock(& CancelIrql);
 8851    b = PptTryAllocatePortAtInterruptLevel(DeviceExtension);
 8852/*     IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 8853    }
 8854  }
 8855  {
 8856  }
 8857  return (b);
 8858}
 8859}
 8860BOOLEAN PptTraversePortCheckList(PVOID Extension ) 
 8861{ PDEVICE_EXTENSION DeviceExtension ;
 8862  PLIST_ENTRY Current ;
 8863  PISR_LIST_ENTRY CheckEntry ;
 8864
 8865  {
 8866  DeviceExtension = Extension;
 8867  if (DeviceExtension->WorkQueueCount >= 0L) {
 8868    return (0);
 8869  } else {
 8870
 8871  }
 8872  Current = DeviceExtension->IsrList.Flink;
 8873  {
 8874  while (1) {
 8875    while_300_continue: /* CIL Label */ ;
 8876    if ((unsigned int )Current != (unsigned int )(& DeviceExtension->IsrList)) {
 8877
 8878    } else {
 8879      goto while_300_break;
 8880    }
 8881    CheckEntry = (ISR_LIST_ENTRY *)((CHAR *)Current - (unsigned long )(& ((ISR_LIST_ENTRY *)0)->ListEntry));
 8882    if (CheckEntry->DeferredPortCheckRoutine) {
 8883      {
 8884      (*(CheckEntry->DeferredPortCheckRoutine))(CheckEntry->CheckContext);
 8885      }
 8886    } else {
 8887
 8888    }
 8889    Current = Current->Flink;
 8890  }
 8891  while_300_break: /* CIL Label */ ;
 8892  }
 8893  return (1);
 8894}
 8895}
 8896void PptFreePort(PVOID Extension ) 
 8897{ PDEVICE_EXTENSION DeviceExtension ;
 8898  SYNCHRONIZED_COUNT_CONTEXT SyncContext ;
 8899  KIRQL CancelIrql ;
 8900  ULONG InterruptRefCount ;
 8901  BOOLEAN Allocated ;
 8902
 8903  {
 8904  DeviceExtension = Extension;
 8905  {
 8906  }
 8907  {
 8908  SyncContext.Count = & DeviceExtension->WorkQueueCount;
 8909  IoAcquireCancelSpinLock(& CancelIrql);
 8910  }
 8911  if (DeviceExtension->InterruptRefCount) {
 8912    {
 8913    KeSynchronizeExecution(DeviceExtension->InterruptObject, & PptSynchronizedDecrement,
 8914                           & SyncContext);
 8915    }
 8916  } else {
 8917    {
 8918    PptSynchronizedDecrement(& SyncContext);
 8919    }
 8920  }
 8921  {
 8922/*   IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 8923  DeviceExtension->WmiPortAllocFreeCounts.PortFrees += 1UL;
 8924  Allocated = 0;
 8925  }
 8926  {
 8927  while (1) {
 8928    while_302_continue: /* CIL Label */ ;
 8929    if (! Allocated) {
 8930      if (SyncContext.NewCount >= 0L) {
 8931
 8932      } else {
 8933        goto while_302_break;
 8934      }
 8935    } else {
 8936      goto while_302_break;
 8937    }
 8938  }
 8939  while_302_break: /* CIL Label */ ;
 8940  }
 8941  if (! Allocated) {
 8942    {
 8943    IoAcquireCancelSpinLock(& CancelIrql);
 8944    InterruptRefCount = DeviceExtension->InterruptRefCount;
 8945/*     IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 8946    }
 8947    if (InterruptRefCount) {
 8948      {
 8949      KeSynchronizeExecution(DeviceExtension->InterruptObject, & PptTraversePortCheckList,
 8950                             DeviceExtension);
 8951      }
 8952    } else {
 8953
 8954    }
 8955  } else {
 8956
 8957  }
 8958  return;
 8959}
 8960}
 8961ULONG PptQueryNumWaiters(PVOID Extension ) 
 8962{ PDEVICE_EXTENSION DeviceExtension ;
 8963  KIRQL CancelIrql ;
 8964  SYNCHRONIZED_COUNT_CONTEXT SyncContext ;
 8965  unsigned long tmp ;
 8966
 8967  {
 8968  DeviceExtension = Extension;
 8969  SyncContext.Count = & DeviceExtension->WorkQueueCount;
 8970  if (DeviceExtension->InterruptRefCount) {
 8971    {
 8972    KeSynchronizeExecution(DeviceExtension->InterruptObject, & PptSynchronizedRead,
 8973                           & SyncContext);
 8974    }
 8975  } else {
 8976    {
 8977    IoAcquireCancelSpinLock(& CancelIrql);
 8978    PptSynchronizedRead(& SyncContext);
 8979/*     IoReleaseCancelSpinLock(CancelIrql); */ /* INLINED */
 8980    }
 8981  }
 8982  if (SyncContext.NewCount >= 0L) {
 8983    tmp = (unsigned long )SyncContext.NewCount;
 8984  } else {
 8985    tmp = 0;
 8986  }
 8987  return (tmp);
 8988}
 8989}
 8990PVOID PptSetCancelRoutine(PIRP Irp , void (*CancelRoutine)(struct _DEVICE_OBJECT *DeviceObject ,
 8991                                                           struct _IRP *Irp ) ) 
 8992{ LONG tmp ;
 8993
 8994  {
 8995  {
 8996  tmp = InterlockedExchange((LONG *)((PVOID *)(& Irp->CancelRoutine)), (long )((void *)CancelRoutine));
 8997  }
 8998  return ((void (*)(struct _DEVICE_OBJECT *DeviceObject , struct _IRP *Irp ))((void *)tmp));
 8999}
 9000}
 9001extern int ( /* missing proto */  KeQueryTickCount)() ;
 9002BOOLEAN CheckPort(PUCHAR wPortAddr , UCHAR bMask , UCHAR bValue , USHORT usTimeDelay ) 
 9003{ UCHAR dsr ;
 9004  LARGE_INTEGER Wait ;
 9005  LARGE_INTEGER Start ;
 9006  LARGE_INTEGER End ;
 9007  ULONG tmp ;
 9008  ULONG tmp___0 ;
 9009
 9010  {
 9011  {
 9012  dsr = READ_PORT_UCHAR(wPortAddr);
 9013  }
 9014  if (((int )dsr & (int )bMask) == (int )bValue) {
 9015    return (1);
 9016  } else {
 9017
 9018  }
 9019  {
 9020  tmp = KeQueryTimeIncrement();
 9021  Wait.QuadPart = (ULONG )(((int )usTimeDelay * 10) * 10) + tmp;
 9022  KeQueryTickCount(& Start);
 9023  }
 9024  {
 9025  while (1) {
 9026    while_303_continue: /* CIL Label */ ;
 9027    {
 9028    KeQueryTickCount(& End);
 9029    dsr = READ_PORT_UCHAR(wPortAddr);
 9030    }
 9031    if (((int )dsr & (int )bMask) == (int )bValue) {
 9032      return (1);
 9033    } else {
 9034
 9035    }
 9036    {
 9037    tmp___0 = KeQueryTimeIncrement();
 9038    }
 9039    if ((End.QuadPart - Start.QuadPart) * (LONGLONG )tmp___0 > Wait.QuadPart) {
 9040      goto CheckPort_TimeOut;
 9041    } else {
 9042
 9043    }
 9044  }
 9045  while_303_break: /* CIL Label */ ;
 9046  }
 9047  CheckPort_TimeOut: 
 9048  return (0);
 9049}
 9050}
 9051NTSTATUS PptBuildParallelPortDeviceName(ULONG Number , PUNICODE_STRING DeviceName ) 
 9052{ UNICODE_STRING uniDeviceString ;
 9053  UNICODE_STRING uniBaseNameString ;
 9054  UNICODE_STRING uniPortNumberString ;
 9055  WCHAR wcPortNum[10] ;
 9056  NTSTATUS status ;
 9057  PVOID tmp ;
 9058
 9059  {
 9060  {
 9061  }
 9062  {
 9063/*   RtlInitUnicodeString(DeviceName, (void *)0); */ /* INLINED */
 9064  uniPortNumberString.Length = 0;
 9065  uniPortNumberString.MaximumLength = sizeof(wcPortNum);
 9066  uniPortNumberString.Buffer = wcPortNum;
 9067  status = RtlIntegerToUnicodeString(Number, 10, & uniPortNumberString);
 9068  }
 9069  if (! (status >= 0L)) {
 9070    {
 9071    }
 9072    return (status);
 9073  } else {
 9074
 9075  }
 9076  {
 9077  DeviceName->MaximumLength = (unsigned short )((unsigned int )(((int )uniDeviceString.Length + (int )uniBaseNameString.Length) + (int )uniPortNumberString.Length) + sizeof((unsigned short)0));
 9078  tmp = ExAllocatePoolWithTag(1, DeviceName->MaximumLength, 1349673296UL);
 9079  DeviceName->Buffer = tmp;
 9080  }
 9081  if ((unsigned int )((void *)0) == (unsigned int )DeviceName->Buffer) {
 9082    {
 9083    }
 9084    return (-1073741670L);
 9085  } else {
 9086
 9087  }
 9088  {
 9089  memset(DeviceName->Buffer, 0, DeviceName->MaximumLength);
 9090  RtlAppendUnicodeStringToString(DeviceName, & uniDeviceString);
 9091  RtlAppendUnicodeStringToString(DeviceName, & uniBaseNameString);
 9092  RtlAppendUnicodeStringToString(DeviceName, & uniPortNumberString);
 9093  }
 9094  return (0L);
 9095}
 9096}
 9097NTSTATUS PptInitializeDeviceExtension(PDRIVER_OBJECT DriverObject , PDEVICE_OBJECT PhysicalDeviceObject ,
 9098                                      PDEVICE_OBJECT DeviceObject , PUNICODE_STRING UniNameString ,
 9099                                      PWSTR PortName , ULONG PortNumber ) 
 9100{ PDEVICE_EXTENSION Extension ;
 9101  ULONG bufferLength ;
 9102  PVOID tmp ;
 9103
 9104  {
 9105  {
 9106  Extension = DeviceObject->DeviceExtension;
 9107  memset(Extension, 0, sizeof(DEVICE_EXTENSION ));
 9108  Extension->ExtensionSignatureBegin = 2022144135;
 9109  Extension->ExtensionSignatureEnd = 2272823160U;
 9110  Extension->DriverObject = DriverObject;
 9111  Extension->PhysicalDeviceObject = PhysicalDeviceObject;
 9112  Extension->DeviceObject = DeviceObject;
 9113  Extension->PnpInfo.PortNumber = PortNumber;
 9114  IoInitializeRemoveLockEx(& Extension->RemoveLock, 1349673296UL, 1, 10, sizeof(IO_REMOVE_LOCK ));
 9115  Extension->OpenCloseMutex.Count = 1;
 9116  Extension->OpenCloseMutex.Contention = 0;
 9117/*   KeInitializeEvent(& Extension->OpenCloseMutex.Event, 1, 0); */ /* INLINED */
 9118  Extension->ExtensionFastMutex.Count = 1;
 9119  Extension->ExtensionFastMutex.Contention = 0;
 9120/*   KeInitializeEvent(& Extension->ExtensionFastMutex.Event, 1, 0); */ /* INLINED */
 9121  Extension->NationalChipFound = 0;
 9122  Extension->NationalChecked = 0;
 9123  Extension->WorkQueue.Blink = & Extension->WorkQueue;
 9124  Extension->WorkQueue.Flink = Extension->WorkQueue.Blink;
 9125  Extension->WorkQueueCount = -1;
 9126  Extension->PortInfo.FreePort = & PptFreePort;
 9127  Extension->PortInfo.TryAllocatePort = & PptTryAllocatePort;
 9128  Extension->PortInfo.QueryNumWaiters = & PptQueryNumWaiters;
 9129  Extension->PortInfo.Context = Extension;
 9130  Extension->PnpInfo.HardwareCapabilities = 0;
 9131  Extension->PnpInfo.TrySetChipMode = & PptSetChipMode;
 9132  Extension->PnpInfo.ClearChipMode = & PptClearChipMode;
 9133  Extension->PnpInfo.TrySelectDevice = & PptTrySelectDevice;
 9134  Extension->PnpInfo.DeselectDevice = & PptDeselectDevice;
 9135  Extension->PnpInfo.Context = Extension;
 9136  Extension->PnpInfo.PortName = PortName;
 9137  Extension->RemovalRelationsList.Blink = & Extension->RemovalRelationsList;
 9138  Extension->RemovalRelationsList.Flink = Extension->RemovalRelationsList.Blink;
 9139  Extension->IsrList.Blink = & Extension->IsrList;
 9140  Extension->IsrList.Flink = Extension->IsrList.Blink;
 9141  Extension->InterruptObject = (void *)0;
 9142  Extension->InterruptRefCount = 0;
 9143  KeInitializeDpc(& Extension->FreePortDpc, & PptFreePortDpc, Extension);
 9144  bufferLength = (unsigned int )UniNameString->MaximumLength + sizeof((unsigned short)0);
 9145  tmp = ExAllocatePoolWithTag(0, bufferLength, 1349673296UL);
 9146  Extension->DeviceName.Buffer = tmp;
 9147  }
 9148  if (! Extension->DeviceName.Buffer) {
 9149    return (-1073741670L);
 9150  } else {
 9151
 9152  }
 9153  {
 9154  memset(Extension->DeviceName.Buffer, 0, bufferLength);
 9155  Extension->DeviceName.Length = 0;
 9156  Extension->DeviceName.MaximumLength = UniNameString->MaximumLength;
 9157/*   RtlCopyUnicodeString(& Extension->DeviceName, UniNameString); */ /* INLINED */
 9158  Extension->PnpInfo.CurrentMode = 0;
 9159  Extension_FilterMode = 0;
 9160  }
 9161  return (0L);
 9162}
 9163}
 9164NTSTATUS PptGetPortNumberFromLptName(PWSTR PortName , PULONG PortNumber ) 
 9165{ NTSTATUS status ;
 9166  UNICODE_STRING str ;
 9167  int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 9168
 9169  {
 9170  if (__BLAST_NONDET) {
 9171    {
 9172    }
 9173    return (-1073741823L);
 9174  } else {
 9175
 9176  }
 9177  {
 9178/*   RtlInitUnicodeString(& str, PortName + 3); */ /* INLINED */
 9179  status = RtlUnicodeStringToInteger(& str, 10, PortNumber);
 9180  }
 9181  if (! (status >= 0L)) {
 9182    {
 9183    }
 9184    return (-1073741823L);
 9185  } else {
 9186
 9187  }
 9188  if (*PortNumber == 0UL) {
 9189    {
 9190    }
 9191    return (-1073741823L);
 9192  } else {
 9193
 9194  }
 9195  {
 9196  }
 9197  return (0L);
 9198}
 9199}
 9200PDEVICE_OBJECT PptBuildDeviceObject(PDRIVER_OBJECT DriverObject , PDEVICE_OBJECT PhysicalDeviceObject ) 
 9201{ UNICODE_STRING uniNameString ;
 9202  ULONG portNumber ;
 9203  PWSTR portName ;
 9204  NTSTATUS status ;
 9205  PDEVICE_OBJECT deviceObject ;
 9206
 9207  {
 9208  uniNameString.Length = 0;
 9209  uniNameString.MaximumLength = 0;
 9210  uniNameString.Buffer = 0;
 9211  portNumber = 0;
 9212  portName = (void *)0;
 9213  status = 0L;
 9214  deviceObject = (void *)0;
 9215  {
 9216  }
 9217  {
 9218  portName = PptGetPortNameFromPhysicalDeviceObject(PhysicalDeviceObject);
 9219  }
 9220  if ((unsigned int )((void *)0) == (unsigned int )portName) {
 9221    {
 9222    }
 9223    goto targetExit;
 9224  } else {
 9225
 9226  }
 9227  {
 9228  }
 9229  {
 9230  status = PptGetPortNumberFromLptName(portName, & portNumber);
 9231  }
 9232  if (! (status >= 0L)) {
 9233    {
 9234    }
 9235    {
 9236/*     ExFreePool(portName); */ /* INLINED */
 9237    }
 9238    goto targetExit;
 9239  } else {
 9240
 9241  }
 9242  portNumber -= 1UL;
 9243  {
 9244  }
 9245  {
 9246  status = PptBuildParallelPortDeviceName(portNumber, & uniNameString);
 9247  }
 9248  if (! (status >= 0L)) {
 9249    {
 9250    }
 9251    {
 9252/*     ExFreePool(portName); */ /* INLINED */
 9253    }
 9254    goto targetExit;
 9255  } else {
 9256
 9257  }
 9258  {
 9259  }
 9260  {
 9261  status = IoCreateDevice(DriverObject, sizeof(DEVICE_EXTENSION ), & uniNameString,
 9262                          22, 256, 0, & deviceObject);
 9263  }
 9264  if (-1073741771L == status) {
 9265    {
 9266    }
 9267    portNumber = 7;
 9268    {
 9269    while (1) {
 9270      while_319_continue: /* CIL Label */ ;
 9271      {
 9272/*       RtlFreeUnicodeString(& uniNameString); */ /* INLINED */
 9273      portNumber += 1UL;
 9274      status = PptBuildParallelPortDeviceName(portNumber, & uniNameString);
 9275      }
 9276      if (! (status >= 0L)) {
 9277        {
 9278        }
 9279        {
 9280/*         ExFreePool(portName); */ /* INLINED */
 9281        }
 9282        goto targetExit;
 9283      } else {
 9284
 9285      }
 9286      {
 9287      }
 9288      {
 9289      status = IoCreateDevice(DriverObject, sizeof(DEVICE_EXTENSION ), & uniNameString,
 9290                              22, 256, 0, & deviceObject);
 9291      }
 9292      if (-1073741771L == status) {
 9293
 9294      } else {
 9295        goto while_319_break;
 9296      }
 9297    }
 9298    while_319_break: /* CIL Label */ ;
 9299    }
 9300  } else {
 9301
 9302  }
 9303  if (! (status >= 0L)) {
 9304    {
 9305    }
 9306    {
 9307    deviceObject = (void *)0;
 9308/*     ExFreePool(portName); */ /* INLINED */
 9309    }
 9310    goto targetExit;
 9311  } else {
 9312
 9313  }
 9314  {
 9315  status = PptInitializeDeviceExtension(DriverObject, PhysicalDeviceObject, deviceObject,
 9316                                        & uniNameString, portName, portNumber);
 9317  }
 9318  if (! (status >= 0L)) {
 9319    {
 9320    }
 9321    {
 9322/*     IoDeleteDevice(deviceObject); */ /* INLINED */
 9323    deviceObject = (void *)0;
 9324/*     ExFreePool(portName); */ /* INLINED */
 9325    }
 9326    goto targetExit;
 9327  } else {
 9328
 9329  }
 9330  if (PhysicalDeviceObject->Flags & 8192UL) {
 9331    deviceObject->Flags |= 8192UL;
 9332  } else {
 9333
 9334  }
 9335  {
 9336  }
 9337  targetExit: 
 9338  {
 9339/*   RtlFreeUnicodeString(& uniNameString); */ /* INLINED */
 9340  }
 9341  return (deviceObject);
 9342}
 9343}
 9344#pragma once
 9345#pragma once
 9346#pragma once
 9347#pragma once
 9348#pragma warning(push)
 9349#pragma warning(disable:4035)
 9350#pragma warning(pop)
 9351#pragma once
 9352#pragma warning(disable:4103)
 9353#pragma warning(disable:4103)
 9354#pragma warning(push)
 9355#pragma warning(disable:4035)
 9356#pragma warning(pop)
 9357#pragma warning(disable:4035)
 9358#pragma warning(push)
 9359#pragma warning(disable:4164)
 9360#pragma function(_enable)
 9361#pragma function(_disable)
 9362#pragma warning(pop)
 9363#pragma warning(disable:4103)
 9364#pragma warning(disable:4103)
 9365#pragma warning(disable:4103)
 9366#pragma warning(disable:4103)
 9367#pragma warning(disable:4103)
 9368#pragma warning(disable:4103)
 9369#pragma warning(disable:4200)
 9370#pragma warning(default:4200)
 9371#pragma once
 9372#pragma warning(disable:4200)
 9373NTSTATUS PptWmiQueryWmiRegInfo(PDEVICE_OBJECT PDevObj , PULONG PRegFlags , PUNICODE_STRING PInstanceName ,
 9374                               PUNICODE_STRING *PRegistryPath , PUNICODE_STRING MofResourceName ,
 9375                               PDEVICE_OBJECT *Pdo ) ;
 9376NTSTATUS PptWmiQueryWmiDataBlock(PDEVICE_OBJECT DeviceObject , PIRP Irp , ULONG GuidIndex ,
 9377                                 ULONG InstanceIndex , ULONG InstanceCount , PULONG InstanceLengthArray ,
 9378                                 ULONG OutBufferSize , PUCHAR Buffer ) ;
 9379#pragma alloc_text(PAGEPARWMI0,PptWmiInitWmi)
 9380#pragma alloc_text(PAGEPARWMI0,PptDispatchSystemControl)
 9381#pragma alloc_text(PAGEPARWMI0,PptWmiQueryWmiRegInfo)
 9382#pragma alloc_text(PAGEPARWMI0,PptWmiQueryWmiDataBlock)
 9383GUID PptWmiAllocFreeCountsGuid  =    {1270573546, 26707, 4562, {142, 206, 0, 192, 79, 142, 244, 129}};
 9384WMIGUIDREGINFO PptWmiGuidList[1]  = {      {& PptWmiAllocFreeCountsGuid, 1, 0}};
 9385NTSTATUS PptWmiInitWmi(PDEVICE_OBJECT DeviceObject ) 
 9386{ PDEVICE_EXTENSION devExt ;
 9387  PWMILIB_CONTEXT wmiContext ;
 9388  NTSTATUS tmp ;
 9389
 9390  {
 9391  {
 9392  devExt = DeviceObject->DeviceExtension;
 9393  wmiContext = & devExt->WmiLibContext;
 9394  wmiContext->GuidCount = sizeof(PptWmiGuidList) / sizeof(WMIGUIDREGINFO );
 9395  wmiContext->GuidList = PptWmiGuidList;
 9396  wmiContext->QueryWmiRegInfo = & PptWmiQueryWmiRegInfo;
 9397  wmiContext->QueryWmiDataBlock = & PptWmiQueryWmiDataBlock;
 9398  wmiContext->SetWmiDataBlock = (void *)0;
 9399  wmiContext->SetWmiDataItem = (void *)0;
 9400  wmiContext->ExecuteWmiMethod = (void *)0;
 9401  wmiContext->WmiFunctionControl = (void *)0;
 9402  tmp = IoWMIRegistrationControl(DeviceObject, 1);
 9403  }
 9404  return (tmp);
 9405}
 9406}
 9407NTSTATUS PptDispatchSystemControl(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
 9408{ SYSCTL_IRP_DISPOSITION disposition ;
 9409  NTSTATUS status ;
 9410  PDEVICE_EXTENSION pDevExt ;
 9411
 9412  {
 9413  {
 9414  pDevExt = (struct _DEVICE_EXTENSION *)DeviceObject->DeviceExtension;
 9415  status = WmiSystemControl(& pDevExt->WmiLibContext, DeviceObject, Irp, & disposition);
 9416  }
 9417  if (disposition == 0) {
 9418    goto switch_325_0;
 9419  } else {
 9420    if (disposition == 1) {
 9421      goto switch_325_1;
 9422    } else {
 9423      if (disposition == 3) {
 9424        goto switch_325_3;
 9425      } else {
 9426        if (disposition == 2) {
 9427          goto switch_325_2;
 9428        } else {
 9429          {
 9430          goto switch_325_default;
 9431          if (0) {
 9432            switch_325_0: /* CIL Label */ 
 9433            s = DC;
 9434            goto switch_325_break;
 9435            switch_325_1: /* CIL Label */ 
 9436            {
 9437            PptCompleteRequest(Irp, 0);
 9438            }
 9439            goto switch_325_break;
 9440            switch_325_3: /* CIL Label */ ;
 9441            switch_325_2: /* CIL Label */ ;
 9442            if (s == NP) {
 9443              s = SKIP1;
 9444            } else {
 9445              {
 9446              errorFn();
 9447              }
 9448            }
 9449            {
 9450            Irp->CurrentLocation = (CHAR )((int )Irp->CurrentLocation + 1);
 9451            Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation += 1;
 9452            status = IofCallDriver(pDevExt->ParentDeviceObject, Irp);
 9453            }
 9454            goto switch_325_break;
 9455            switch_325_default: /* CIL Label */ ;
 9456            if (s == NP) {
 9457              s = SKIP1;
 9458            } else {
 9459              {
 9460              errorFn();
 9461              }
 9462            }
 9463            {
 9464            Irp->CurrentLocation = (CHAR )((int )Irp->CurrentLocation + 1);
 9465            Irp->Tail.Overlay.__annonCompField17.__annonCompField16.CurrentStackLocation += 1;
 9466            status = IofCallDriver(pDevExt->ParentDeviceObject, Irp);
 9467            }
 9468            goto switch_325_break;
 9469          } else {
 9470            switch_325_break: /* CIL Label */ ;
 9471          }
 9472          }
 9473        }
 9474      }
 9475    }
 9476  }
 9477  return (status);
 9478}
 9479}
 9480NTSTATUS PptWmiQueryWmiRegInfo(PDEVICE_OBJECT PDevObj , PULONG PRegFlags , PUNICODE_STRING PInstanceName ,
 9481                               PUNICODE_STRING *PRegistryPath , PUNICODE_STRING MofResourceName ,
 9482                               PDEVICE_OBJECT *Pdo ) 
 9483{ PDEVICE_EXTENSION devExt ;
 9484
 9485  {
 9486  devExt = PDevObj->DeviceExtension;
 9487  {
 9488  }
 9489  *PRegFlags = 32;
 9490  *PRegistryPath = & RegistryPath;
 9491  *Pdo = devExt->PhysicalDeviceObject;
 9492  return (0L);
 9493}
 9494}
 9495NTSTATUS PptWmiQueryWmiDataBlock(PDEVICE_OBJECT DeviceObject , PIRP Irp , ULONG GuidIndex ,
 9496                                 ULONG InstanceIndex , ULONG InstanceCount , PULONG InstanceLengthArray ,
 9497                                 ULONG OutBufferSize , PUCHAR Buffer ) 
 9498{ NTSTATUS status ;
 9499  ULONG size ;
 9500  PDEVICE_EXTENSION devExt ;
 9501
 9502  {
 9503  size = sizeof(PARPORT_WMI_ALLOC_FREE_COUNTS );
 9504  devExt = DeviceObject->DeviceExtension;
 9505  if (GuidIndex == 0) {
 9506    goto switch_327_0;
 9507  } else {
 9508    {
 9509    goto switch_327_default;
 9510    if (0) {
 9511      switch_327_0: /* CIL Label */ ;
 9512      if (OutBufferSize < size) {
 9513        status = -1073741789L;
 9514        goto switch_327_break;
 9515      } else {
 9516
 9517      }
 9518      *((struct _PARPORT_WMI_ALLOC_FREE_COUNTS *)Buffer) = devExt->WmiPortAllocFreeCounts;
 9519      *InstanceLengthArray = size;
 9520      status = 0L;
 9521      goto switch_327_break;
 9522      switch_327_default: /* CIL Label */ 
 9523      status = -1073741163L;
 9524      goto switch_327_break;
 9525    } else {
 9526      switch_327_break: /* CIL Label */ ;
 9527    }
 9528    }
 9529  }
 9530  {
 9531  status = WmiCompleteRequest(DeviceObject, Irp, status, size, 0);
 9532  }
 9533  return (status);
 9534}
 9535}
 9536#pragma once
 9537#pragma once
 9538#pragma once
 9539#pragma once
 9540#pragma warning(push)
 9541#pragma warning(disable:4035)
 9542#pragma warning(pop)
 9543#pragma once
 9544#pragma warning(disable:4103)
 9545#pragma warning(disable:4103)
 9546#pragma warning(push)
 9547#pragma warning(disable:4035)
 9548#pragma warning(pop)
 9549#pragma warning(disable:4035)
 9550#pragma warning(push)
 9551#pragma warning(disable:4164)
 9552#pragma function(_enable)
 9553#pragma function(_disable)
 9554#pragma warning(pop)
 9555#pragma warning(disable:4103)
 9556#pragma warning(disable:4103)
 9557#pragma warning(disable:4103)
 9558#pragma warning(disable:4103)
 9559#pragma warning(disable:4103)
 9560#pragma warning(disable:4103)
 9561#pragma warning(disable:4200)
 9562#pragma warning(default:4200)
 9563void _BLAST_init(void) 
 9564{ 
 9565
 9566  {
 9567  UNLOADED = 0;
 9568  NP = 1;
 9569  DC = 2;
 9570  SKIP1 = 3;
 9571  SKIP2 = 4;
 9572  MPR1 = 5;
 9573  MPR3 = 6;
 9574  IPC = 7;
 9575  s = UNLOADED;
 9576  pended = 0;
 9577  compFptr = 0;
 9578  compRegistered = 0;
 9579  lowerDriverReturn = 0;
 9580  setEventCalled = 0;
 9581  customIrp = 0;
 9582  return;
 9583}
 9584}
 9585IRP *pirp  ;
 9586void stub_driver_init(void) 
 9587{ 
 9588
 9589  {
 9590  s = NP;
 9591  customIrp = 0;
 9592  setEventCalled = customIrp;
 9593  lowerDriverReturn = setEventCalled;
 9594  compRegistered = lowerDriverReturn;
 9595  compFptr = compRegistered;
 9596  pended = compFptr;
 9597  return;
 9598}
 9599}
 9600int main(void) 
 9601{ DRIVER_OBJECT d ;
 9602  NTSTATUS status = __VERIFIER_nondet_long() ;
 9603  int we_should_unload = __VERIFIER_nondet_int() ;
 9604  IRP irp ;
 9605  int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 9606  int irp_choice = __VERIFIER_nondet_int() ;
 9607  DEVICE_OBJECT devobj ;
 9608  s = __VERIFIER_nondet_int();
 9609
 9610  {
 9611  {
 9612  pirp = & irp;
 9613  _BLAST_init();
 9614  }
 9615  if (status >= 0L) {
 9616    s = NP;
 9617    customIrp = 0;
 9618    setEventCalled = customIrp;
 9619    lowerDriverReturn = setEventCalled;
 9620    compRegistered = lowerDriverReturn;
 9621    compFptr = compRegistered;
 9622    pended = compFptr;
 9623    pirp->IoStatus.__annonCompField4.Status = 0L;
 9624    myStatus = 0L;
 9625    if (irp_choice == 0) {
 9626      pirp->IoStatus.__annonCompField4.Status = -1073741637L;
 9627      myStatus = -1073741637L;
 9628    } else {
 9629
 9630    }
 9631    {
 9632    stub_driver_init();
 9633    }
 9634    if (! (status >= 0L)) {
 9635      return (-1);
 9636    } else {
 9637
 9638    }
 9639    if (__BLAST_NONDET == 0) {
 9640      goto switch_328_0;
 9641    } else {
 9642      if (__BLAST_NONDET == 1) {
 9643        goto switch_328_1;
 9644      } else {
 9645        if (__BLAST_NONDET == 3) {
 9646          goto switch_328_3;
 9647        } else {
 9648          if (__BLAST_NONDET == 4) {
 9649            goto switch_328_4;
 9650          } else {
 9651            if (__BLAST_NONDET == 5) {
 9652              goto switch_328_5;
 9653            } else {
 9654              if (__BLAST_NONDET == 6) {
 9655                goto switch_328_6;
 9656              } else {
 9657                if (__BLAST_NONDET == 8) {
 9658                  goto switch_328_8;
 9659                } else {
 9660                  if (__BLAST_NONDET == 11) {
 9661                    goto switch_328_11;
 9662                  } else {
 9663                    {
 9664                    goto switch_328_default;
 9665                    if (0) {
 9666                      switch_328_0: /* CIL Label */ 
 9667                      {
 9668                      status = PptDispatchCreate(& devobj, pirp);
 9669                      }
 9670                      goto switch_328_break;
 9671                      switch_328_1: /* CIL Label */ 
 9672                      {
 9673                      status = PptDispatchClose(& devobj, pirp);
 9674                      }
 9675                      goto switch_328_break;
 9676                      switch_328_3: /* CIL Label */ 
 9677                      {
 9678                      status = PptDispatchPnp(& devobj, pirp);
 9679                      }
 9680                      goto switch_328_break;
 9681                      switch_328_4: /* CIL Label */ 
 9682                      {
 9683                      status = PptDispatchPower(& devobj, pirp);
 9684                      }
 9685                      goto switch_328_break;
 9686                      switch_328_5: /* CIL Label */ 
 9687                      {
 9688                      status = PptDispatchCleanup(& devobj, pirp);
 9689                      }
 9690                      goto switch_328_break;
 9691                      switch_328_6: /* CIL Label */ 
 9692                      {
 9693                      status = PptDispatchSystemControl(& devobj, pirp);
 9694                      }
 9695                      goto switch_328_break;
 9696                      switch_328_8: /* CIL Label */ 
 9697                      {
 9698                      status = PptDispatchInternalDeviceControl(& devobj, pirp);
 9699                      }
 9700                      goto switch_328_break;
 9701                      switch_328_11: /* CIL Label */ 
 9702                      {
 9703                      status = PptDispatchCleanup(& devobj, pirp);
 9704                      }
 9705                      goto switch_328_break;
 9706                      switch_328_default: /* CIL Label */ ;
 9707                      return (-1);
 9708                    } else {
 9709                      switch_328_break: /* CIL Label */ ;
 9710                    }
 9711                    }
 9712                  }
 9713                }
 9714              }
 9715            }
 9716          }
 9717        }
 9718      }
 9719    }
 9720    if (we_should_unload) {
 9721      {
 9722      PptUnload(& d);
 9723      }
 9724    } else {
 9725
 9726    }
 9727  } else {
 9728
 9729  }
 9730  if (pended == 1) {
 9731    if (s == NP) {
 9732      s = NP;
 9733    } else {
 9734      goto _L___2;
 9735    }
 9736  } else {
 9737    _L___2: /* CIL Label */ 
 9738    if (pended == 1) {
 9739      if (s == MPR3) {
 9740        s = MPR3;
 9741      } else {
 9742        goto _L___1;
 9743      }
 9744    } else {
 9745      _L___1: /* CIL Label */ 
 9746      if (s == UNLOADED) {
 9747
 9748      } else {
 9749        if (status == -1L) {
 9750
 9751        } else {
 9752          if (s != SKIP2) {
 9753            if (s != IPC) {
 9754              if (s != DC) {
 9755                {
 9756                errorFn();
 9757                }
 9758              } else {
 9759                goto _L___0;
 9760              }
 9761            } else {
 9762              goto _L___0;
 9763            }
 9764          } else {
 9765            _L___0: /* CIL Label */ 
 9766            if (pended == 1) {
 9767              if (status != 259L) {
 9768                {
 9769                errorFn();
 9770                }
 9771              } else {
 9772
 9773              }
 9774            } else {
 9775              if (s == DC) {
 9776                {
 9777                errorFn();
 9778                }
 9779              } else {
 9780                if (status != (NTSTATUS )lowerDriverReturn) {
 9781                  {
 9782                  errorFn();
 9783                  }
 9784                } else {
 9785
 9786                }
 9787              }
 9788            }
 9789          }
 9790        }
 9791      }
 9792    }
 9793  }
 9794  return (status);
 9795}
 9796}
 9797char _SLAM_alloc_dummy  ;
 9798void ExAcquireFastMutex(PFAST_MUTEX FastMutex ) ;
 9799void ExAcquireFastMutex(PFAST_MUTEX FastMutex ) 
 9800{ 
 9801
 9802  {
 9803  return;
 9804}
 9805}
 9806  void ExReleaseFastMutex(PFAST_MUTEX FastMutex ) ;
 9807void ExReleaseFastMutex(PFAST_MUTEX FastMutex ) 
 9808{ 
 9809
 9810  {
 9811  return;
 9812}
 9813}
 9814  PVOID ExAllocatePoolWithTag(POOL_TYPE PoolType ,
 9815                                                                                            SIZE_T NumberOfBytes ,
 9816                                                                                            ULONG Tag ) ;
 9817PVOID ExAllocatePoolWithTag(POOL_TYPE PoolType , SIZE_T NumberOfBytes ,
 9818                                                            ULONG Tag ) 
 9819{ PVOID x ;
 9820  char *tmp ;
 9821
 9822  {
 9823  {
 9824  tmp = malloc(NumberOfBytes);
 9825  x = tmp;
 9826  }
 9827  return (x);
 9828}
 9829}
 9830  void ExFreePool(PVOID P ) ;
 9831void ExFreePool(PVOID P ) 
 9832{ 
 9833
 9834  {
 9835  return;
 9836}
 9837}
 9838  PLIST_ENTRY ExfInterlockedInsertHeadList(PLIST_ENTRY ListHead ,
 9839                                                                                                          PLIST_ENTRY ListEntry ,
 9840                                                                                                          PKSPIN_LOCK Lock ) ;
 9841PLIST_ENTRY ExfInterlockedInsertHeadList(PLIST_ENTRY ListHead ,
 9842                                                                          PLIST_ENTRY ListEntry ,
 9843                                                                          PKSPIN_LOCK Lock ) 
 9844{ 
 9845
 9846  {
 9847  return ((void *)0);
 9848}
 9849}
 9850  PLIST_ENTRY ExfInterlockedInsertTailList(PLIST_ENTRY ListHead ,
 9851                                                                                                          PLIST_ENTRY ListEntry ,
 9852                                                                                                          PKSPIN_LOCK Lock ) ;
 9853PLIST_ENTRY ExfInterlockedInsertTailList(PLIST_ENTRY ListHead ,
 9854                                                                          PLIST_ENTRY ListEntry ,
 9855                                                                          PKSPIN_LOCK Lock ) 
 9856{ 
 9857
 9858  {
 9859  return ((void *)0);
 9860}
 9861}
 9862  PLIST_ENTRY ExfInterlockedRemoveHeadList(PLIST_ENTRY ListHead ,
 9863                                                                                                          PKSPIN_LOCK Lock ) ;
 9864PLIST_ENTRY ExfInterlockedRemoveHeadList(PLIST_ENTRY ListHead ,
 9865                                                                          PKSPIN_LOCK Lock ) 
 9866{ 
 9867
 9868  {
 9869  return ((void *)0);
 9870}
 9871}
 9872  PMDL IoAllocateMdl(PVOID VirtualAddress , ULONG Length ,
 9873                                                   BOOLEAN SecondaryBuffer , BOOLEAN ChargeQuota ,
 9874                                                   PIRP Irp ) ;
 9875PMDL IoAllocateMdl(PVOID VirtualAddress , ULONG Length , BOOLEAN SecondaryBuffer ,
 9876                   BOOLEAN ChargeQuota , PIRP Irp ) 
 9877{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 9878  char *tmp ;
 9879
 9880  {
 9881  if (__BLAST_NONDET == 0) {
 9882    goto switch_329_0;
 9883  } else {
 9884    {
 9885    goto switch_329_default;
 9886    if (0) {
 9887      switch_329_0: /* CIL Label */ 
 9888      {
 9889      tmp = malloc(sizeof(MDL ));
 9890      }
 9891      return ((void *)tmp);
 9892      switch_329_default: /* CIL Label */ ;
 9893      return ((void *)0);
 9894    } else {
 9895      switch_329_break: /* CIL Label */ ;
 9896    }
 9897    }
 9898  }
 9899}
 9900}
 9901  PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice ,
 9902                                                                           PDEVICE_OBJECT TargetDevice ) ;
 9903PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice , PDEVICE_OBJECT TargetDevice ) 
 9904{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 9905
 9906  {
 9907  if (__BLAST_NONDET == 0) {
 9908    goto switch_330_0;
 9909  } else {
 9910    {
 9911    goto switch_330_default;
 9912    if (0) {
 9913      switch_330_0: /* CIL Label */ ;
 9914      return (TargetDevice);
 9915      switch_330_default: /* CIL Label */ ;
 9916      return ((void *)0);
 9917    } else {
 9918      switch_330_break: /* CIL Label */ ;
 9919    }
 9920    }
 9921  }
 9922}
 9923}
 9924  PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction ,
 9925                                                                   PDEVICE_OBJECT DeviceObject ,
 9926                                                                   PVOID Buffer ,
 9927                                                                   ULONG Length ,
 9928                                                                   PLARGE_INTEGER StartingOffset ,
 9929                                                                   PIO_STATUS_BLOCK IoStatusBlock ) ;
 9930PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction , PDEVICE_OBJECT DeviceObject ,
 9931                                   PVOID Buffer , ULONG Length , PLARGE_INTEGER StartingOffset ,
 9932                                   PIO_STATUS_BLOCK IoStatusBlock ) 
 9933{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 9934  char *tmp ;
 9935
 9936  {
 9937  customIrp = 1;
 9938  if (__BLAST_NONDET == 0) {
 9939    goto switch_331_0;
 9940  } else {
 9941    {
 9942    goto switch_331_default;
 9943    if (0) {
 9944      switch_331_0: /* CIL Label */ 
 9945      {
 9946      tmp = malloc(sizeof(IRP ));
 9947      }
 9948      return ((void *)tmp);
 9949      switch_331_default: /* CIL Label */ ;
 9950      return ((void *)0);
 9951    } else {
 9952      switch_331_break: /* CIL Label */ ;
 9953    }
 9954    }
 9955  }
 9956}
 9957}
 9958  PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode ,
 9959                                                                   PDEVICE_OBJECT DeviceObject ,
 9960                                                                   PVOID InputBuffer ,
 9961                                                                   ULONG InputBufferLength ,
 9962                                                                   PVOID OutputBuffer ,
 9963                                                                   ULONG OutputBufferLength ,
 9964                                                                   BOOLEAN InternalDeviceIoControl ,
 9965                                                                   PKEVENT Event ,
 9966                                                                   PIO_STATUS_BLOCK IoStatusBlock ) ;
 9967PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode , PDEVICE_OBJECT DeviceObject ,
 9968                                   PVOID InputBuffer , ULONG InputBufferLength , PVOID OutputBuffer ,
 9969                                   ULONG OutputBufferLength , BOOLEAN InternalDeviceIoControl ,
 9970                                   PKEVENT Event , PIO_STATUS_BLOCK IoStatusBlock ) 
 9971{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
 9972  char *tmp ;
 9973
 9974  {
 9975  customIrp = 1;
 9976  if (__BLAST_NONDET == 0) {
 9977    goto switch_332_0;
 9978  } else {
 9979    {
 9980    goto switch_332_default;
 9981    if (0) {
 9982      switch_332_0: /* CIL Label */ 
 9983      {
 9984      tmp = malloc(sizeof(IRP ));
 9985      }
 9986      return ((void *)tmp);
 9987      switch_332_default: /* CIL Label */ ;
 9988      return ((void *)0);
 9989    } else {
 9990      switch_332_break: /* CIL Label */ ;
 9991    }
 9992    }
 9993  }
 9994}
 9995}
 9996  NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject ,
 9997                                                        ULONG DeviceExtensionSize ,
 9998                                                        PUNICODE_STRING DeviceName ,
 9999                                                        ULONG DeviceType , ULONG DeviceCharacteristics ,
10000                                                        BOOLEAN Exclusive , PDEVICE_OBJECT *DeviceObject ) ;
10001NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject , ULONG DeviceExtensionSize ,
10002                        PUNICODE_STRING DeviceName , ULONG DeviceType , ULONG DeviceCharacteristics ,
10003                        BOOLEAN Exclusive , PDEVICE_OBJECT *DeviceObject ) 
10004{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10005  char *tmp ;
10006
10007  {
10008  if (__BLAST_NONDET == 0) {
10009    goto switch_333_0;
10010  } else {
10011    {
10012    goto switch_333_default;
10013    if (0) {
10014      switch_333_0: /* CIL Label */ 
10015      {
10016      tmp = malloc(sizeof(DEVICE_OBJECT ));
10017      *DeviceObject = (void *)tmp;
10018      }
10019      return (0L);
10020      switch_333_default: /* CIL Label */ ;
10021      return (-1073741823L);
10022    } else {
10023      switch_333_break: /* CIL Label */ ;
10024    }
10025    }
10026  }
10027}
10028}
10029  NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName ,
10030                                                              PUNICODE_STRING DeviceName ) ;
10031NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName , PUNICODE_STRING DeviceName ) 
10032{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10033
10034  {
10035  if (__BLAST_NONDET == 0) {
10036    goto switch_334_0;
10037  } else {
10038    {
10039    goto switch_334_default;
10040    if (0) {
10041      switch_334_0: /* CIL Label */ ;
10042      return (0L);
10043      switch_334_default: /* CIL Label */ ;
10044      return (-1073741823L);
10045    } else {
10046      switch_334_break: /* CIL Label */ ;
10047    }
10048    }
10049  }
10050}
10051}
10052  void IoDeleteDevice(PDEVICE_OBJECT DeviceObject ) ;
10053void IoDeleteDevice(PDEVICE_OBJECT DeviceObject ) 
10054{ 
10055
10056  {
10057  return;
10058}
10059}
10060  NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName ) ;
10061NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName ) 
10062{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10063
10064  {
10065  if (__BLAST_NONDET == 0) {
10066    goto switch_335_0;
10067  } else {
10068    {
10069    goto switch_335_default;
10070    if (0) {
10071      switch_335_0: /* CIL Label */ ;
10072      return (0L);
10073      switch_335_default: /* CIL Label */ ;
10074      return (-1073741823L);
10075    } else {
10076      switch_335_break: /* CIL Label */ ;
10077    }
10078    }
10079  }
10080}
10081}
10082  void IoDetachDevice(PDEVICE_OBJECT TargetDevice ) ;
10083void IoDetachDevice(PDEVICE_OBJECT TargetDevice ) 
10084{ 
10085
10086  {
10087  return;
10088}
10089}
10090  void IoFreeIrp(PIRP Irp ) ;
10091void IoFreeIrp(PIRP Irp ) 
10092{ 
10093
10094  {
10095  return;
10096}
10097}
10098  void IoFreeMdl(PMDL Mdl ) ;
10099void IoFreeMdl(PMDL Mdl ) 
10100{ 
10101
10102  {
10103  return;
10104}
10105}
10106  PCONFIGURATION_INFORMATION IoGetConfigurationInformation(void) ;
10107PCONFIGURATION_INFORMATION IoGetConfigurationInformation(void) 
10108{ char *tmp ;
10109
10110  {
10111  {
10112  tmp = malloc(sizeof(CONFIGURATION_INFORMATION ));
10113  }
10114  return ((void *)tmp);
10115}
10116}
10117  NTSTATUS IoQueryDeviceDescription(PINTERFACE_TYPE BusType ,
10118                                                                  PULONG BusNumber ,
10119                                                                  PCONFIGURATION_TYPE ControllerType ,
10120                                                                  PULONG ControllerNumber ,
10121                                                                  PCONFIGURATION_TYPE PeripheralType ,
10122                                                                  PULONG PeripheralNumber ,
10123                                                                  NTSTATUS (*CalloutRoutine)(PVOID Context ,
10124                                                                                             PUNICODE_STRING PathName ,
10125                                                                                             INTERFACE_TYPE BusType ,
10126                                                                                             ULONG BusNumber ,
10127                                                                                             PKEY_VALUE_FULL_INFORMATION *BusInformation ,
10128                                                                                             CONFIGURATION_TYPE ControllerType ,
10129                                                                                             ULONG ControllerNumber ,
10130                                                                                             PKEY_VALUE_FULL_INFORMATION *ControllerInformation ,
10131                                                                                             CONFIGURATION_TYPE PeripheralType ,
10132                                                                                             ULONG PeripheralNumber ,
10133                                                                                             PKEY_VALUE_FULL_INFORMATION *PeripheralInformation ) ,
10134                                                                  PVOID Context ) ;
10135NTSTATUS IoQueryDeviceDescription(PINTERFACE_TYPE BusType , PULONG BusNumber , PCONFIGURATION_TYPE ControllerType ,
10136                                  PULONG ControllerNumber , PCONFIGURATION_TYPE PeripheralType ,
10137                                  PULONG PeripheralNumber , NTSTATUS (*CalloutRoutine)(PVOID Context ,
10138                                                                                       PUNICODE_STRING PathName ,
10139                                                                                       INTERFACE_TYPE BusType ,
10140                                                                                       ULONG BusNumber ,
10141                                                                                       PKEY_VALUE_FULL_INFORMATION *BusInformation ,
10142                                                                                       CONFIGURATION_TYPE ControllerType ,
10143                                                                                       ULONG ControllerNumber ,
10144                                                                                       PKEY_VALUE_FULL_INFORMATION *ControllerInformation ,
10145                                                                                       CONFIGURATION_TYPE PeripheralType ,
10146                                                                                       ULONG PeripheralNumber ,
10147                                                                                       PKEY_VALUE_FULL_INFORMATION *PeripheralInformation ) ,
10148                                  PVOID Context ) 
10149{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10150
10151  {
10152  if (__BLAST_NONDET == 0) {
10153    goto switch_336_0;
10154  } else {
10155    {
10156    goto switch_336_default;
10157    if (0) {
10158      switch_336_0: /* CIL Label */ ;
10159      return (0L);
10160      switch_336_default: /* CIL Label */ ;
10161      return (-1073741823L);
10162    } else {
10163      switch_336_break: /* CIL Label */ ;
10164    }
10165    }
10166  }
10167}
10168}
10169  NTSTATUS IoRegisterDeviceInterface(PDEVICE_OBJECT PhysicalDeviceObject ,
10170                                                                                                   GUID const   *InterfaceClassGuid ,
10171                                                                                                   PUNICODE_STRING ReferenceString ,
10172                                                                                                   PUNICODE_STRING SymbolicLinkName ) ;
10173NTSTATUS IoRegisterDeviceInterface(PDEVICE_OBJECT PhysicalDeviceObject ,
10174                                                                   GUID const   *InterfaceClassGuid ,
10175                                                                   PUNICODE_STRING ReferenceString ,
10176                                                                   PUNICODE_STRING SymbolicLinkName ) 
10177{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10178
10179  {
10180  if (__BLAST_NONDET == 0) {
10181    goto switch_337_0;
10182  } else {
10183    {
10184    goto switch_337_default;
10185    if (0) {
10186      switch_337_0: /* CIL Label */ ;
10187      return (0L);
10188      switch_337_default: /* CIL Label */ ;
10189      return (-1073741808L);
10190    } else {
10191      switch_337_break: /* CIL Label */ ;
10192    }
10193    }
10194  }
10195}
10196}
10197  void IoReleaseCancelSpinLock(KIRQL Irql ) ;
10198void IoReleaseCancelSpinLock(KIRQL Irql ) 
10199{ 
10200
10201  {
10202  return;
10203}
10204}
10205  NTSTATUS IoSetDeviceInterfaceState(PUNICODE_STRING SymbolicLinkName ,
10206                                                                   BOOLEAN Enable ) ;
10207NTSTATUS IoSetDeviceInterfaceState(PUNICODE_STRING SymbolicLinkName , BOOLEAN Enable ) 
10208{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10209
10210  {
10211  if (__BLAST_NONDET == 0) {
10212    goto switch_338_0;
10213  } else {
10214    {
10215    goto switch_338_default;
10216    if (0) {
10217      switch_338_0: /* CIL Label */ ;
10218      return (0L);
10219      switch_338_default: /* CIL Label */ ;
10220      return (-1073741823L);
10221    } else {
10222      switch_338_break: /* CIL Label */ ;
10223    }
10224    }
10225  }
10226}
10227}
10228  void IoSetHardErrorOrVerifyDevice(PIRP Irp , PDEVICE_OBJECT DeviceObject ) ;
10229void IoSetHardErrorOrVerifyDevice(PIRP Irp , PDEVICE_OBJECT DeviceObject ) 
10230{ 
10231
10232  {
10233  return;
10234}
10235}
10236void stubMoreProcessingRequired(void) 
10237{ 
10238
10239  {
10240  if (s == NP) {
10241    s = MPR1;
10242  } else {
10243    {
10244    errorFn();
10245    }
10246  }
10247  return;
10248}
10249}
10250  NTSTATUS IofCallDriver(PDEVICE_OBJECT DeviceObject ,
10251                                                                                        PIRP Irp ) ;
10252NTSTATUS IofCallDriver(PDEVICE_OBJECT DeviceObject ,
10253                                                        PIRP Irp ) 
10254{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10255  NTSTATUS returnVal2 ;
10256  int compRetStatus ;
10257  PVOID lcontext = __VERIFIER_nondet_pointer() ;
10258  NTSTATUS tmp ;
10259  NTSTATUS tmp___0 ;
10260
10261  {
10262  if (compRegistered) {
10263    if (routine == 0) {
10264      {
10265      tmp = PptSynchCompletionRoutine(DeviceObject, Irp, lcontext);
10266      compRetStatus = tmp;
10267      }
10268    } else {
10269      if (routine == 1) {
10270        {
10271        tmp___0 = PptPowerComplete(DeviceObject, Irp, lcontext);
10272        compRetStatus = tmp___0;
10273        }
10274      } else {
10275
10276      }
10277    }
10278    if ((long )compRetStatus == -1073741802L) {
10279      {
10280      stubMoreProcessingRequired();
10281      }
10282    } else {
10283
10284    }
10285  } else {
10286
10287  }
10288  if (__BLAST_NONDET == 0) {
10289    goto switch_339_0;
10290  } else {
10291    if (__BLAST_NONDET == 1) {
10292      goto switch_339_1;
10293    } else {
10294      {
10295      goto switch_339_default;
10296      if (0) {
10297        switch_339_0: /* CIL Label */ 
10298        returnVal2 = 0L;
10299        goto switch_339_break;
10300        switch_339_1: /* CIL Label */ 
10301        returnVal2 = -1073741823L;
10302        goto switch_339_break;
10303        switch_339_default: /* CIL Label */ 
10304        returnVal2 = 259L;
10305        goto switch_339_break;
10306      } else {
10307        switch_339_break: /* CIL Label */ ;
10308      }
10309      }
10310    }
10311  }
10312  if (s == NP) {
10313    s = IPC;
10314    lowerDriverReturn = returnVal2;
10315  } else {
10316    if (s == MPR1) {
10317      if (returnVal2 == 259L) {
10318        s = MPR3;
10319        lowerDriverReturn = returnVal2;
10320      } else {
10321        s = NP;
10322        lowerDriverReturn = returnVal2;
10323      }
10324    } else {
10325      if (s == SKIP1) {
10326        s = SKIP2;
10327        lowerDriverReturn = returnVal2;
10328      } else {
10329        {
10330        errorFn();
10331        }
10332      }
10333    }
10334  }
10335  return (returnVal2);
10336}
10337}
10338  void IofCompleteRequest(PIRP Irp ,
10339                                                                                         CCHAR PriorityBoost ) ;
10340void IofCompleteRequest(PIRP Irp , CCHAR PriorityBoost ) 
10341{ 
10342
10343  {
10344  if (s == NP) {
10345    s = DC;
10346  } else {
10347    {
10348    errorFn();
10349    }
10350  }
10351  return;
10352}
10353}
10354  KIRQL KeAcquireSpinLockRaiseToDpc(PKSPIN_LOCK SpinLock ) ;
10355KIRQL KeAcquireSpinLockRaiseToDpc(PKSPIN_LOCK SpinLock ) 
10356{ 
10357
10358  {
10359  return ((unsigned char)0);
10360}
10361}
10362  NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode ,
10363                                                                BOOLEAN Alertable ,
10364                                                                PLARGE_INTEGER Interval ) ;
10365NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode , BOOLEAN Alertable , PLARGE_INTEGER Interval ) 
10366{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10367
10368  {
10369  if (__BLAST_NONDET == 0) {
10370    goto switch_340_0;
10371  } else {
10372    {
10373    goto switch_340_default;
10374    if (0) {
10375      switch_340_0: /* CIL Label */ ;
10376      return (0L);
10377      switch_340_default: /* CIL Label */ ;
10378      return (-1073741823L);
10379    } else {
10380      switch_340_break: /* CIL Label */ ;
10381    }
10382    }
10383  }
10384}
10385}
10386  void KeInitializeEvent(PRKEVENT Event , EVENT_TYPE Type ,
10387                                                       BOOLEAN State ) ;
10388void KeInitializeEvent(PRKEVENT Event , EVENT_TYPE Type , BOOLEAN State ) 
10389{ 
10390
10391  {
10392  return;
10393}
10394}
10395  void KeInitializeSemaphore(PRKSEMAPHORE Semaphore ,
10396                                                           LONG Count , LONG Limit ) ;
10397void KeInitializeSemaphore(PRKSEMAPHORE Semaphore , LONG Count , LONG Limit ) 
10398{ 
10399
10400  {
10401  return;
10402}
10403}
10404  void KeInitializeSpinLock(PKSPIN_LOCK SpinLock ) ;
10405void KeInitializeSpinLock(PKSPIN_LOCK SpinLock ) 
10406{ 
10407
10408  {
10409  return;
10410}
10411}
10412  LONG KeReleaseSemaphore(PRKSEMAPHORE Semaphore , KPRIORITY Increment ,
10413                                                        LONG Adjustment , BOOLEAN Wait ) ;
10414LONG KeReleaseSemaphore(PRKSEMAPHORE Semaphore , KPRIORITY Increment , LONG Adjustment ,
10415                        BOOLEAN Wait ) 
10416{ LONG r = __VERIFIER_nondet_long() ;
10417
10418  {
10419  return (r);
10420}
10421}
10422  void KfReleaseSpinLock(PKSPIN_LOCK SpinLock ,
10423                                                                                        KIRQL NewIrql ) ;
10424void KfReleaseSpinLock(PKSPIN_LOCK SpinLock , KIRQL NewIrql ) 
10425{ 
10426
10427  {
10428  return;
10429}
10430}
10431  LONG KeSetEvent(PRKEVENT Event , KPRIORITY Increment ,
10432                                                BOOLEAN Wait ) ;
10433LONG KeSetEvent(PRKEVENT Event , KPRIORITY Increment , BOOLEAN Wait ) 
10434{ LONG l = __VERIFIER_nondet_long() ;
10435
10436  {
10437  setEventCalled = 1;
10438  return (l);
10439}
10440}
10441  NTSTATUS KeWaitForSingleObject(PVOID Object , KWAIT_REASON WaitReason ,
10442                                                               KPROCESSOR_MODE WaitMode ,
10443                                                               BOOLEAN Alertable ,
10444                                                               PLARGE_INTEGER Timeout ) ;
10445NTSTATUS KeWaitForSingleObject(PVOID Object , KWAIT_REASON WaitReason , KPROCESSOR_MODE WaitMode ,
10446                               BOOLEAN Alertable , PLARGE_INTEGER Timeout ) 
10447{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10448
10449  {
10450  if (s == MPR3) {
10451    if (setEventCalled == 1) {
10452      s = NP;
10453      setEventCalled = 0;
10454    } else {
10455      goto _L;
10456    }
10457  } else {
10458    _L: /* CIL Label */ 
10459    if (customIrp == 1) {
10460      s = NP;
10461      customIrp = 0;
10462    } else {
10463      if (s == MPR3) {
10464        {
10465        errorFn();
10466        }
10467      } else {
10468
10469      }
10470    }
10471  }
10472  if (__BLAST_NONDET == 0) {
10473    goto switch_341_0;
10474  } else {
10475    {
10476    goto switch_341_default;
10477    if (0) {
10478      switch_341_0: /* CIL Label */ ;
10479      return (0L);
10480      switch_341_default: /* CIL Label */ ;
10481      return (-1073741823L);
10482    } else {
10483      switch_341_break: /* CIL Label */ ;
10484    }
10485    }
10486  }
10487}
10488}
10489  PVOID MmAllocateContiguousMemory(SIZE_T NumberOfBytes ,
10490                                                                 PHYSICAL_ADDRESS HighestAcceptableAddress ) ;
10491PVOID MmAllocateContiguousMemory(SIZE_T NumberOfBytes , PHYSICAL_ADDRESS HighestAcceptableAddress ) 
10492{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10493  char *tmp ;
10494
10495  {
10496  if (__BLAST_NONDET == 0) {
10497    goto switch_342_0;
10498  } else {
10499    if (__BLAST_NONDET == 1) {
10500      goto switch_342_1;
10501    } else {
10502      if (0) {
10503        switch_342_0: /* CIL Label */ 
10504        {
10505        tmp = malloc(NumberOfBytes);
10506        }
10507        return (tmp);
10508        switch_342_1: /* CIL Label */ ;
10509        return ((void *)0);
10510      } else {
10511        switch_342_break: /* CIL Label */ ;
10512      }
10513    }
10514  }
10515  return ((void *)0);
10516}
10517}
10518  void MmFreeContiguousMemory(PVOID BaseAddress ) ;
10519void MmFreeContiguousMemory(PVOID BaseAddress ) 
10520{ 
10521
10522  {
10523  return;
10524}
10525}
10526  PVOID MmMapLockedPagesSpecifyCache(PMDL MemoryDescriptorList ,
10527                                                                   KPROCESSOR_MODE AccessMode ,
10528                                                                   MEMORY_CACHING_TYPE CacheType ,
10529                                                                   PVOID BaseAddress ,
10530                                                                   ULONG BugCheckOnFailure ,
10531                                                                   MM_PAGE_PRIORITY Priority ) ;
10532PVOID MmMapLockedPagesSpecifyCache(PMDL MemoryDescriptorList , KPROCESSOR_MODE AccessMode ,
10533                                   MEMORY_CACHING_TYPE CacheType , PVOID BaseAddress ,
10534                                   ULONG BugCheckOnFailure , MM_PAGE_PRIORITY Priority ) 
10535{ 
10536
10537  {
10538  return ((void *)0);
10539}
10540}
10541  PVOID MmPageEntireDriver(PVOID AddressWithinSection ) ;
10542PVOID MmPageEntireDriver(PVOID AddressWithinSection ) 
10543{ 
10544
10545  {
10546  return ((void *)0);
10547}
10548}
10549  void MmResetDriverPaging(PVOID AddressWithinSection ) ;
10550void MmResetDriverPaging(PVOID AddressWithinSection ) 
10551{ 
10552
10553  {
10554  return;
10555}
10556}
10557  void MmUnlockPages(PMDL MemoryDescriptorList ) ;
10558void MmUnlockPages(PMDL MemoryDescriptorList ) 
10559{ 
10560
10561  {
10562  return;
10563}
10564}
10565  NTSTATUS ObReferenceObjectByHandle(HANDLE Handle ,
10566                                                                   ACCESS_MASK DesiredAccess ,
10567                                                                   POBJECT_TYPE ObjectType ,
10568                                                                   KPROCESSOR_MODE AccessMode ,
10569                                                                   PVOID *Object ,
10570                                                                   POBJECT_HANDLE_INFORMATION HandleInformation ) ;
10571NTSTATUS ObReferenceObjectByHandle(HANDLE Handle , ACCESS_MASK DesiredAccess , POBJECT_TYPE ObjectType ,
10572                                   KPROCESSOR_MODE AccessMode , PVOID *Object , POBJECT_HANDLE_INFORMATION HandleInformation ) 
10573{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10574
10575  {
10576  if (__BLAST_NONDET == 0) {
10577    goto switch_343_0;
10578  } else {
10579    {
10580    goto switch_343_default;
10581    if (0) {
10582      switch_343_0: /* CIL Label */ ;
10583      return (0L);
10584      switch_343_default: /* CIL Label */ ;
10585      return (-1073741823L);
10586    } else {
10587      switch_343_break: /* CIL Label */ ;
10588    }
10589    }
10590  }
10591}
10592}
10593  void ObfDereferenceObject(PVOID Object ) ;
10594void ObfDereferenceObject(PVOID Object ) 
10595{ 
10596
10597  {
10598  return;
10599}
10600}
10601  NTSTATUS PoCallDriver(PDEVICE_OBJECT DeviceObject ,
10602                                                      PIRP Irp ) ;
10603NTSTATUS PoCallDriver(PDEVICE_OBJECT DeviceObject , PIRP Irp ) 
10604{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10605  int compRetStatus ;
10606  NTSTATUS returnVal ;
10607  PVOID lcontext = __VERIFIER_nondet_pointer() ;
10608  NTSTATUS tmp ;
10609  NTSTATUS tmp___0 ;
10610
10611  {
10612  if (compRegistered) {
10613    if (routine == 0) {
10614      {
10615      tmp = PptSynchCompletionRoutine(DeviceObject, Irp, lcontext);
10616      compRetStatus = tmp;
10617      }
10618    } else {
10619      if (routine == 1) {
10620        {
10621        tmp___0 = PptPowerComplete(DeviceObject, Irp, lcontext);
10622        compRetStatus = tmp___0;
10623        }
10624      } else {
10625
10626      }
10627    }
10628    if ((long )compRetStatus == -1073741802L) {
10629      {
10630      stubMoreProcessingRequired();
10631      }
10632    } else {
10633
10634    }
10635  } else {
10636
10637  }
10638  if (__BLAST_NONDET == 0) {
10639    goto switch_344_0;
10640  } else {
10641    if (__BLAST_NONDET == 1) {
10642      goto switch_344_1;
10643    } else {
10644      {
10645      goto switch_344_default;
10646      if (0) {
10647        switch_344_0: /* CIL Label */ 
10648        returnVal = 0L;
10649        goto switch_344_break;
10650        switch_344_1: /* CIL Label */ 
10651        returnVal = -1073741823L;
10652        goto switch_344_break;
10653        switch_344_default: /* CIL Label */ 
10654        returnVal = 259L;
10655        goto switch_344_break;
10656      } else {
10657        switch_344_break: /* CIL Label */ ;
10658      }
10659      }
10660    }
10661  }
10662  if (s == NP) {
10663    s = IPC;
10664    lowerDriverReturn = returnVal;
10665  } else {
10666    if (s == MPR1) {
10667      if (returnVal == 259L) {
10668        s = MPR3;
10669        lowerDriverReturn = returnVal;
10670      } else {
10671        s = NP;
10672        lowerDriverReturn = returnVal;
10673      }
10674    } else {
10675      if (s == SKIP1) {
10676        s = SKIP2;
10677        lowerDriverReturn = returnVal;
10678      } else {
10679        {
10680        errorFn();
10681        }
10682      }
10683    }
10684  }
10685  return (returnVal);
10686}
10687}
10688  void PoStartNextPowerIrp(PIRP Irp ) ;
10689void PoStartNextPowerIrp(PIRP Irp ) 
10690{ 
10691
10692  {
10693  return;
10694}
10695}
10696  NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle ,
10697                                                              ULONG DesiredAccess ,
10698                                                              POBJECT_ATTRIBUTES ObjectAttributes ,
10699                                                              HANDLE ProcessHandle ,
10700                                                              PCLIENT_ID ClientId ,
10701                                                              void (*StartRoutine)(PVOID StartContext ) ,
10702                                                              PVOID StartContext ) ;
10703NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle , ULONG DesiredAccess , POBJECT_ATTRIBUTES ObjectAttributes ,
10704                              HANDLE ProcessHandle , PCLIENT_ID ClientId , void (*StartRoutine)(PVOID StartContext ) ,
10705                              PVOID StartContext ) 
10706{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10707
10708  {
10709  if (__BLAST_NONDET == 0) {
10710    goto switch_345_0;
10711  } else {
10712    {
10713    goto switch_345_default;
10714    if (0) {
10715      switch_345_0: /* CIL Label */ ;
10716      return (0L);
10717      switch_345_default: /* CIL Label */ ;
10718      return (-1073741823L);
10719    } else {
10720      switch_345_break: /* CIL Label */ ;
10721    }
10722    }
10723  }
10724}
10725}
10726  NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus ) ;
10727NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus ) 
10728{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10729
10730  {
10731  if (__BLAST_NONDET == 0) {
10732    goto switch_346_0;
10733  } else {
10734    {
10735    goto switch_346_default;
10736    if (0) {
10737      switch_346_0: /* CIL Label */ ;
10738      return (0L);
10739      switch_346_default: /* CIL Label */ ;
10740      return (-1073741823L);
10741    } else {
10742      switch_346_break: /* CIL Label */ ;
10743    }
10744    }
10745  }
10746}
10747}
10748  NTSTATUS RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString ,
10749                                                                                                      PANSI_STRING SourceString ,
10750                                                                                                      BOOLEAN AllocateDestinationString ) ;
10751NTSTATUS RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString ,
10752                                                                      PANSI_STRING SourceString ,
10753                                                                      BOOLEAN AllocateDestinationString ) 
10754{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10755
10756  {
10757  if (__BLAST_NONDET == 0) {
10758    goto switch_347_0;
10759  } else {
10760    {
10761    goto switch_347_default;
10762    if (0) {
10763      switch_347_0: /* CIL Label */ ;
10764      return (0L);
10765      switch_347_default: /* CIL Label */ ;
10766      return (-1073741823L);
10767    } else {
10768      switch_347_break: /* CIL Label */ ;
10769    }
10770    }
10771  }
10772}
10773}
10774  SIZE_T RtlCompareMemory(void const   *Source1 ,
10775                                                                                        void const   *Source2 ,
10776                                                                                        SIZE_T Length ) ;
10777SIZE_T RtlCompareMemory(void const   *Source1 , void const   *Source2 ,
10778                                                        SIZE_T Length ) 
10779{ SIZE_T r = __VERIFIER_nondet_long() ;
10780
10781  {
10782  return (r);
10783}
10784}
10785  void RtlCopyUnicodeString(PUNICODE_STRING DestinationString ,
10786                                                                                          PUNICODE_STRING SourceString ) ;
10787void RtlCopyUnicodeString(PUNICODE_STRING DestinationString ,
10788                                                          PUNICODE_STRING SourceString ) 
10789{ 
10790
10791  {
10792  return;
10793}
10794}
10795  NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo ,
10796                                                                                                PCWSTR Path ,
10797                                                                                                PCWSTR ValueName ) ;
10798NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo ,
10799                                                                PCWSTR Path , PCWSTR ValueName ) 
10800{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10801
10802  {
10803  if (__BLAST_NONDET == 0) {
10804    goto switch_348_0;
10805  } else {
10806    {
10807    goto switch_348_default;
10808    if (0) {
10809      switch_348_0: /* CIL Label */ ;
10810      return (0L);
10811      switch_348_default: /* CIL Label */ ;
10812      return (-1073741823L);
10813    } else {
10814      switch_348_break: /* CIL Label */ ;
10815    }
10816    }
10817  }
10818}
10819}
10820  void RtlFreeUnicodeString(PUNICODE_STRING UnicodeString ) ;
10821void RtlFreeUnicodeString(PUNICODE_STRING UnicodeString ) 
10822{ 
10823
10824  {
10825  return;
10826}
10827}
10828  void RtlInitString(PSTRING DestinationString ,
10829                                                                                   PCSZ SourceString ) ;
10830void RtlInitString(PSTRING DestinationString , PCSZ SourceString ) 
10831{ 
10832
10833  {
10834  return;
10835}
10836}
10837  void RtlInitUnicodeString(PUNICODE_STRING DestinationString ,
10838                                                                                          PCWSTR SourceString ) ;
10839void RtlInitUnicodeString(PUNICODE_STRING DestinationString ,
10840                                                          PCWSTR SourceString ) 
10841{ 
10842
10843  {
10844  return;
10845}
10846}
10847  NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo ,
10848                                                                                                PCWSTR Path ,
10849                                                                                                PRTL_QUERY_REGISTRY_TABLE QueryTable ,
10850                                                                                                PVOID Context ,
10851                                                                                                PVOID Environment ) ;
10852NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo ,
10853                                                                PCWSTR Path , PRTL_QUERY_REGISTRY_TABLE QueryTable ,
10854                                                                PVOID Context , PVOID Environment ) 
10855{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10856
10857  {
10858  if (__BLAST_NONDET == 0) {
10859    goto switch_349_0;
10860  } else {
10861    {
10862    goto switch_349_default;
10863    if (0) {
10864      switch_349_0: /* CIL Label */ ;
10865      return (0L);
10866      switch_349_default: /* CIL Label */ ;
10867      return (-1073741823L);
10868    } else {
10869      switch_349_break: /* CIL Label */ ;
10870    }
10871    }
10872  }
10873}
10874}
10875  NTSTATUS ZwClose(HANDLE Handle ) ;
10876NTSTATUS ZwClose(HANDLE Handle ) 
10877{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10878
10879  {
10880  if (__BLAST_NONDET == 0) {
10881    goto switch_350_0;
10882  } else {
10883    {
10884    goto switch_350_default;
10885    if (0) {
10886      switch_350_0: /* CIL Label */ ;
10887      return (0L);
10888      switch_350_default: /* CIL Label */ ;
10889      return (-1073741823L);
10890    } else {
10891      switch_350_break: /* CIL Label */ ;
10892    }
10893    }
10894  }
10895}
10896}
10897NTSTATUS WmiSystemControl(PWMILIB_CONTEXT WmiLibInfo , PDEVICE_OBJECT DeviceObject ,
10898                          PIRP Irp , PSYSCTL_IRP_DISPOSITION IrpDisposition ) 
10899{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10900
10901  {
10902  if (__BLAST_NONDET == 0) {
10903    goto switch_351_0;
10904  } else {
10905    {
10906    goto switch_351_default;
10907    if (0) {
10908      switch_351_0: /* CIL Label */ 
10909      return (0L);
10910      switch_351_default: /* CIL Label */ ;
10911      return (-1073741823L);
10912    } else {
10913      switch_351_break: /* CIL Label */ ;
10914    }
10915    }
10916  }
10917}
10918}
10919  NTSTATUS IoAcquireRemoveLockEx(PIO_REMOVE_LOCK RemoveLock ,
10920                                                                                               PVOID Tag ,
10921                                                                                               PCSTR File ,
10922                                                                                               ULONG Line ,
10923                                                                                               ULONG RemlockSize ) ;
10924NTSTATUS IoAcquireRemoveLockEx(PIO_REMOVE_LOCK RemoveLock ,
10925                                                               PVOID Tag , PCSTR File ,
10926                                                               ULONG Line , ULONG RemlockSize ) 
10927{ int __BLAST_NONDET = __VERIFIER_nondet_int() ;
10928
10929  {
10930  if (__BLAST_NONDET) {
10931    return (0L);
10932  } else {
10933    return (-1073741738L);
10934  }
10935}
10936}