TITLE C:\98DDK\src\usb\TEST98\SYS\test98.c .386P include listing.inc if @Version gt 510 .model FLAT else _TEXT SEGMENT PARA USE32 PUBLIC 'CODE' _TEXT ENDS _DATA SEGMENT DWORD USE32 PUBLIC 'DATA' _DATA ENDS CONST SEGMENT DWORD USE32 PUBLIC 'CONST' CONST ENDS _BSS SEGMENT DWORD USE32 PUBLIC 'BSS' _BSS ENDS _TLS SEGMENT DWORD USE32 PUBLIC 'TLS' _TLS ENDS ; COMDAT _DriverEntry@8 _TEXT SEGMENT PARA USE32 PUBLIC 'CODE' _TEXT ENDS ; COMDAT _Test98_DriverUnload@4 _TEXT SEGMENT PARA USE32 PUBLIC 'CODE' _TEXT ENDS ; COMDAT _Test98_DecIoCount@4 _TEXT SEGMENT PARA USE32 PUBLIC 'CODE' _TEXT ENDS ; COMDAT _Test98_IncIoCount@4 _TEXT SEGMENT PARA USE32 PUBLIC 'CODE' _TEXT ENDS FLAT GROUP _DATA, CONST, _BSS ASSUME CS: FLAT, DS: FLAT, SS: FLAT endif PUBLIC _GUID_TEST_DEVICE CONST SEGMENT _GUID_TEST_DEVICE DD 0ca56030H DW 0684aH DW 011d0H DB 0d6H DB 0f6H DB 00H DB 0c0H DB 04fH DB 0b1H DB 072H DB 08bH CONST ENDS PUBLIC _Test98_DriverUnload@4 PUBLIC _DriverEntry@8 EXTRN _Test98_PnP@8:NEAR EXTRN _Test98_Power@8:NEAR EXTRN _Test98_AddDevice@8:NEAR EXTRN _Test_ProcessIOCTL@8:NEAR EXTRN _Test_Create@8:NEAR EXTRN _Test_Read@8:NEAR EXTRN _Test_Write@8:NEAR ; COMDAT _DriverEntry@8 _TEXT SEGMENT _DriverObject$ = 8 _DriverEntry@8 PROC NEAR ; COMDAT ; 57 : { 00000 55 push ebp 00001 8b ec mov ebp, esp 00003 83 ec 04 sub esp, 4 00006 53 push ebx 00007 56 push esi 00008 57 push edi ; 58 : PDEVICE_OBJECT device; ; 59 : ; 60 : UNREFERENCED_PARAMETER (UniRegistryPath); ; 61 : ; 62 : DriverObject->MajorFunction [IRP_MJ_CREATE] = ; 63 : DriverObject->MajorFunction [IRP_MJ_CLOSE] = Test_Create; 00009 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 0000c c7 40 40 00 00 00 00 mov DWORD PTR [eax+64], OFFSET FLAT:_Test_Create@8 00013 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 00016 8b 40 40 mov eax, DWORD PTR [eax+64] 00019 8b 4d 08 mov ecx, DWORD PTR _DriverObject$[ebp] 0001c 89 41 38 mov DWORD PTR [ecx+56], eax ; 64 : ; 65 : // routines to handle system PnP and power management reqeusts ; 66 : DriverObject->MajorFunction [IRP_MJ_PNP] = Test98_PnP; 0001f 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 00022 c7 80 a4 00 00 00 00 00 00 00 mov DWORD PTR [eax+164], OFFSET FLAT:_Test98_PnP@8 ; 67 : DriverObject->MajorFunction [IRP_MJ_POWER] = Test98_Power; 0002c 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 0002f c7 80 90 00 00 00 00 00 00 00 mov DWORD PTR [eax+144], OFFSET FLAT:_Test98_Power@8 ; 68 : ; 69 : // handles user mode DeviceIoControl() calls ; 70 : DriverObject->MajorFunction [IRP_MJ_DEVICE_CONTROL] = Test_ProcessIOCTL; 00039 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 0003c c7 40 70 00 00 00 00 mov DWORD PTR [eax+112], OFFSET FLAT:_Test_ProcessIOCTL@8 ; 71 : ; 72 : DriverObject->DriverUnload = Test98_DriverUnload; 00043 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 00046 c7 40 34 00 00 00 00 mov DWORD PTR [eax+52], OFFSET FLAT:_Test98_DriverUnload@4 ; 73 : ; 74 : // called when device plug-in to reat Funtional Device Object (FDO) ; 75 : DriverObject->DriverExtension->AddDevice = Test98_AddDevice; 0004d 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 00050 8b 40 18 mov eax, DWORD PTR [eax+24] 00053 c7 40 04 00 00 00 00 mov DWORD PTR [eax+4], OFFSET FLAT:_Test98_AddDevice@8 ; 76 : ; 77 : DriverObject->MajorFunction[IRP_MJ_WRITE] = Test_Write; 0005a 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 0005d c7 40 48 00 00 00 00 mov DWORD PTR [eax+72], OFFSET FLAT:_Test_Write@8 ; 78 : DriverObject->MajorFunction[IRP_MJ_READ] = Test_Read; 00064 8b 45 08 mov eax, DWORD PTR _DriverObject$[ebp] 00067 c7 40 44 00 00 00 00 mov DWORD PTR [eax+68], OFFSET FLAT:_Test_Read@8 ; 79 : ; 80 : return STATUS_SUCCESS; 0006e 33 c0 xor eax, eax 00070 e9 00 00 00 00 jmp $L2805 $L2805: ; 81 : } 00075 5f pop edi 00076 5e pop esi 00077 5b pop ebx 00078 c9 leave 00079 c2 08 00 ret 8 _DriverEntry@8 ENDP _TEXT ENDS ; COMDAT _Test98_DriverUnload@4 _TEXT SEGMENT _Test98_DriverUnload@4 PROC NEAR ; COMDAT ; 92 : { 00000 55 push ebp 00001 8b ec mov ebp, esp 00003 53 push ebx 00004 56 push esi 00005 57 push edi ; 93 : UNREFERENCED_PARAMETER (Driver); ; 94 : PAGED_CODE(); ; 95 : ; 96 : ASSERT (NULL == Driver->DeviceObject); ; 97 : ; 98 : // ; 99 : // Here we free any resources allocated in DriverEntry ; 100 : // ; 101 : ; 102 : return; 00006 e9 00 00 00 00 jmp $L2808 $L2808: ; 103 : } 0000b 5f pop edi 0000c 5e pop esi 0000d 5b pop ebx 0000e c9 leave 0000f c2 04 00 ret 4 _Test98_DriverUnload@4 ENDP _TEXT ENDS PUBLIC _Test98_DecIoCount@4 EXTRN __imp__KeSetEvent@12:NEAR EXTRN __imp_@InterlockedDecrement@4:NEAR ; COMDAT _Test98_DecIoCount@4 _TEXT SEGMENT _Data$ = 8 _Test98_DecIoCount@4 PROC NEAR ; COMDAT ; 110 : { 00000 55 push ebp 00001 8b ec mov ebp, esp 00003 53 push ebx 00004 56 push esi 00005 57 push edi ; 111 : if (0 == InterlockedDecrement (&Data->OutstandingIO)) { 00006 8b 4d 08 mov ecx, DWORD PTR _Data$[ebp] 00009 83 c1 40 add ecx, 64 ; 00000040H 0000c ff 15 00 00 00 00 call DWORD PTR __imp_@InterlockedDecrement@4 00012 85 c0 test eax, eax 00014 0f 85 11 00 00 00 jne $L2811 ; 112 : KeSetEvent (&Data->RemoveEvent, 0, FALSE); 0001a 6a 00 push 0 0001c 6a 00 push 0 0001e 8b 45 08 mov eax, DWORD PTR _Data$[ebp] 00021 83 c0 44 add eax, 68 ; 00000044H 00024 50 push eax 00025 ff 15 00 00 00 00 call DWORD PTR __imp__KeSetEvent@12 $L2811: $L2810: ; 113 : } ; 114 : } 0002b 5f pop edi 0002c 5e pop esi 0002d 5b pop ebx 0002e c9 leave 0002f c2 04 00 ret 4 _Test98_DecIoCount@4 ENDP _TEXT ENDS PUBLIC _Test98_IncIoCount@4 EXTRN __imp_@InterlockedIncrement@4:NEAR ; COMDAT _Test98_IncIoCount@4 _TEXT SEGMENT _Data$ = 8 _Test98_IncIoCount@4 PROC NEAR ; COMDAT ; 121 : { 00000 55 push ebp 00001 8b ec mov ebp, esp 00003 53 push ebx 00004 56 push esi 00005 57 push edi ; 122 : InterlockedIncrement (&Data->OutstandingIO); 00006 8b 4d 08 mov ecx, DWORD PTR _Data$[ebp] 00009 83 c1 40 add ecx, 64 ; 00000040H 0000c ff 15 00 00 00 00 call DWORD PTR __imp_@InterlockedIncrement@4 ; 123 : if (Data->Removed) { 00012 8b 45 08 mov eax, DWORD PTR _Data$[ebp] 00015 33 c9 xor ecx, ecx 00017 8a 48 1b mov cl, BYTE PTR [eax+27] 0001a 85 c9 test ecx, ecx 0001c 0f 84 2f 00 00 00 je $L2814 ; 124 : ; 125 : if (0 == InterlockedDecrement (&Data->OutstandingIO)) { 00022 8b 4d 08 mov ecx, DWORD PTR _Data$[ebp] 00025 83 c1 40 add ecx, 64 ; 00000040H 00028 ff 15 00 00 00 00 call DWORD PTR __imp_@InterlockedDecrement@4 0002e 85 c0 test eax, eax 00030 0f 85 11 00 00 00 jne $L2815 ; 126 : KeSetEvent (&Data->RemoveEvent, 0, FALSE); 00036 6a 00 push 0 00038 6a 00 push 0 0003a 8b 45 08 mov eax, DWORD PTR _Data$[ebp] 0003d 83 c0 44 add eax, 68 ; 00000044H 00040 50 push eax 00041 ff 15 00 00 00 00 call DWORD PTR __imp__KeSetEvent@12 $L2815: ; 127 : } ; 128 : return STATUS_DELETE_PENDING; 00047 b8 56 00 00 c0 mov eax, -1073741738 ; c0000056H 0004c e9 07 00 00 00 jmp $L2813 $L2814: ; 129 : } ; 130 : return STATUS_SUCCESS; 00051 33 c0 xor eax, eax 00053 e9 00 00 00 00 jmp $L2813 $L2813: ; 131 : } 00058 5f pop edi 00059 5e pop esi 0005a 5b pop ebx 0005b c9 leave 0005c c2 04 00 ret 4 _Test98_IncIoCount@4 ENDP _TEXT ENDS END