📄 testpnp.cod
字号:
00046 c2 08 00 ret 8
_Test98_PnP@8 ENDP
_TEXT ENDS
PUBLIC _Test98_StartFdo@12
PUBLIC _Test98_FDO_PnPComplete@12
EXTRN __imp__IoDeleteDevice@4:NEAR
EXTRN __imp__IoDetachDevice@4:NEAR
EXTRN __imp__KeWaitForSingleObject@20:NEAR
EXTRN __imp__ExFreePool@4:NEAR
EXTRN __imp__MmUnmapIoSpace@8:NEAR
EXTRN _Test98_IncIoCount@4:NEAR
EXTRN _Test98_DecIoCount@4:NEAR
EXTRN __imp_@IofCallDriver@8:NEAR
EXTRN __imp_@IofCompleteRequest@8:NEAR
EXTRN __imp_@InterlockedDecrement@4:NEAR
; COMDAT _Test98_FDO_PnP@16
_TEXT SEGMENT
_DeviceObject$ = 8
_Irp$ = 12
_IrpStack$ = 16
_DeviceData$ = 20
_status$ = -28
_event$ = -48
_i$ = -20
_stack$ = -12
_irpSp$2829 = -56
_nextIrpSp$2830 = -52
_irpSp$2831 = -60
_Test98_FDO_PnP@16 PROC NEAR ; COMDAT
; 179 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 83 ec 40 sub esp, 64 ; 00000040H
00006 53 push ebx
00007 56 push esi
00008 57 push edi
; 180 : NTSTATUS status;
; 181 : KIRQL oldIrq;
; 182 : KEVENT event;
; 183 : ULONG length;
; 184 : ULONG i;
; 185 : PLIST_ENTRY entry;
; 186 : PPDO_DEVICE_DATA pdoData;
; 187 : PDEVICE_RELATIONS relations;
; 188 : PIO_STACK_LOCATION stack;
; 189 :
; 190 : PAGED_CODE ();
; 191 :
; 192 : status = Test98_IncIoCount (DeviceData);
00009 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
0000c 50 push eax
0000d e8 00 00 00 00 call _Test98_IncIoCount@4
00012 89 45 e4 mov DWORD PTR _status$[ebp], eax
; 193 : if (!NT_SUCCESS (status)) {
00015 83 7d e4 00 cmp DWORD PTR _status$[ebp], 0
00019 0f 8d 26 00 00
00 jge $L2822
; 194 : Irp->IoStatus.Information = 0;
0001f 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
00022 c7 40 1c 00 00
00 00 mov DWORD PTR [eax+28], 0
; 195 : Irp->IoStatus.Status = status;
00029 8b 45 e4 mov eax, DWORD PTR _status$[ebp]
0002c 8b 4d 0c mov ecx, DWORD PTR _Irp$[ebp]
0002f 89 41 18 mov DWORD PTR [ecx+24], eax
; 196 : IoCompleteRequest (Irp, IO_NO_INCREMENT);
00032 33 d2 xor edx, edx
00034 8b 4d 0c mov ecx, DWORD PTR _Irp$[ebp]
00037 ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
; 197 : return status;
0003d 8b 45 e4 mov eax, DWORD PTR _status$[ebp]
00040 e9 b5 03 00 00 jmp $L2812
$L2822:
; 198 : }
; 199 :
; 200 : stack = IoGetCurrentIrpStackLocation (Irp);
00045 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
00048 8b 40 60 mov eax, DWORD PTR [eax+96]
0004b 89 45 f4 mov DWORD PTR _stack$[ebp], eax
; 201 :
; 202 : switch (IrpStack->MinorFunction) {
0004e 8b 45 10 mov eax, DWORD PTR _IrpStack$[ebp]
00051 33 c9 xor ecx, ecx
00053 8a 48 01 mov cl, BYTE PTR [eax+1]
00056 89 4d c0 mov DWORD PTR -64+[ebp], ecx
00059 e9 4b 03 00 00 jmp $L2823
$L2827:
; 203 : case IRP_MN_START_DEVICE:
; 204 : // PnP manager send this IPR after assigning resoureces to the device;
; 205 : // the device may have been recently numerate and being started
; 206 : // for the first time
; 207 :
; 208 : if (DeviceData->Started) {
0005e 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
00061 33 c9 xor ecx, ecx
00063 8a 48 1a mov cl, BYTE PTR [eax+26]
00066 85 c9 test ecx, ecx
00068 0f 84 0c 00 00
00 je $L2828
; 209 : status = STATUS_SUCCESS;
0006e c7 45 e4 00 00
00 00 mov DWORD PTR _status$[ebp], 0
; 210 : break;
00075 e9 5b 03 00 00 jmp $L2824
$L2828:
; 211 : }
; 212 :
; 213 : Test98_KdPrint (DeviceData, TEST_DBG_PNP_TRACE, ("Start Device\n"));
; 214 :
; 215 : KeInitializeEvent (&event, NotificationEvent, FALSE);
0007a 6a 00 push 0
0007c 6a 00 push 0
0007e 8d 45 d0 lea eax, DWORD PTR _event$[ebp]
00081 50 push eax
00082 ff 15 00 00 00
00 call DWORD PTR __imp__KeInitializeEvent@12
; 216 : IoCopyCurrentIrpStackLocationToNext (Irp);
00088 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
0008b 8b 40 60 mov eax, DWORD PTR [eax+96]
0008e 89 45 c8 mov DWORD PTR _irpSp$2829[ebp], eax
00091 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
00094 8b 40 60 mov eax, DWORD PTR [eax+96]
00097 83 e8 24 sub eax, 36 ; 00000024H
0009a 89 45 cc mov DWORD PTR _nextIrpSp$2830[ebp], eax
0009d 8b 7d cc mov edi, DWORD PTR _nextIrpSp$2830[ebp]
000a0 8b 75 c8 mov esi, DWORD PTR _irpSp$2829[ebp]
000a3 b9 07 00 00 00 mov ecx, 7
000a8 f3 a5 rep movsd
000aa 8b 45 cc mov eax, DWORD PTR _nextIrpSp$2830[ebp]
000ad c6 40 03 00 mov BYTE PTR [eax+3], 0
; 217 :
; 218 : IoSetCompletionRoutine (Irp,
; 219 : Test98_FDO_PnPComplete,
; 220 : &event,
; 221 : TRUE,
; 222 : TRUE,
; 223 : TRUE);
000b1 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
000b4 8b 40 60 mov eax, DWORD PTR [eax+96]
000b7 83 e8 24 sub eax, 36 ; 00000024H
000ba 89 45 c4 mov DWORD PTR _irpSp$2831[ebp], eax
000bd 8b 45 c4 mov eax, DWORD PTR _irpSp$2831[ebp]
000c0 c7 40 1c 00 00
00 00 mov DWORD PTR [eax+28], OFFSET FLAT:_Test98_FDO_PnPComplete@12
000c7 8d 45 d0 lea eax, DWORD PTR _event$[ebp]
000ca 8b 4d c4 mov ecx, DWORD PTR _irpSp$2831[ebp]
000cd 89 41 20 mov DWORD PTR [ecx+32], eax
000d0 8b 45 c4 mov eax, DWORD PTR _irpSp$2831[ebp]
000d3 c6 40 03 00 mov BYTE PTR [eax+3], 0
000d7 8b 45 c4 mov eax, DWORD PTR _irpSp$2831[ebp]
000da c6 40 03 40 mov BYTE PTR [eax+3], 64 ; 00000040H
$L2832:
000de 8b 45 c4 mov eax, DWORD PTR _irpSp$2831[ebp]
000e1 33 c9 xor ecx, ecx
000e3 8a 48 03 mov cl, BYTE PTR [eax+3]
000e6 80 c9 80 or cl, 128 ; 00000080H
000e9 8b 45 c4 mov eax, DWORD PTR _irpSp$2831[ebp]
000ec 88 48 03 mov BYTE PTR [eax+3], cl
$L2833:
000ef 8b 45 c4 mov eax, DWORD PTR _irpSp$2831[ebp]
000f2 33 c9 xor ecx, ecx
000f4 8a 48 03 mov cl, BYTE PTR [eax+3]
000f7 80 c9 20 or cl, 32 ; 00000020H
000fa 8b 45 c4 mov eax, DWORD PTR _irpSp$2831[ebp]
000fd 88 48 03 mov BYTE PTR [eax+3], cl
$L2834:
; 224 :
; 225 : status = IoCallDriver (DeviceData->TopOfStack, Irp);
00100 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
00103 8b 55 0c mov edx, DWORD PTR _Irp$[ebp]
00106 8b 48 2c mov ecx, DWORD PTR [eax+44]
00109 ff 15 00 00 00
00 call DWORD PTR __imp_@IofCallDriver@8
0010f 89 45 e4 mov DWORD PTR _status$[ebp], eax
; 226 :
; 227 : if (STATUS_PENDING == status) {
00112 81 7d e4 03 01
00 00 cmp DWORD PTR _status$[ebp], 259 ; 00000103H
00119 0f 85 1e 00 00
00 jne $L2835
; 228 : // wait for it...
; 229 :
; 230 : status = KeWaitForSingleObject (&event,
; 231 : Executive,
; 232 : KernelMode,
; 233 : FALSE, // Not allertable
; 234 : NULL); // No timeout structure
0011f 6a 00 push 0
00121 6a 00 push 0
00123 6a 00 push 0
00125 6a 00 push 0
00127 8d 45 d0 lea eax, DWORD PTR _event$[ebp]
0012a 50 push eax
0012b ff 15 00 00 00
00 call DWORD PTR __imp__KeWaitForSingleObject@20
00131 89 45 e4 mov DWORD PTR _status$[ebp], eax
; 235 :
; 236 : ASSERT (STATUS_SUCCESS == status);
; 237 :
; 238 : status = Irp->IoStatus.Status;
00134 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
00137 8b 40 18 mov eax, DWORD PTR [eax+24]
0013a 89 45 e4 mov DWORD PTR _status$[ebp], eax
$L2835:
; 239 : }
; 240 :
; 241 : if (NT_SUCCESS(status)) {
0013d 83 7d e4 00 cmp DWORD PTR _status$[ebp], 0
00141 0f 8c 57 00 00
00 jl $L2836
; 242 : //
; 243 : // Do what ever after device started
; 244 : //
; 245 :
; 246 : if ((NULL == stack->Parameters.StartDevice.AllocatedResources) ||
; 247 : (NULL == stack->Parameters.StartDevice.AllocatedResourcesTranslated)) {
00147 8b 45 f4 mov eax, DWORD PTR _stack$[ebp]
0014a 83 78 04 00 cmp DWORD PTR [eax+4], 0
0014e 0f 84 0d 00 00
00 je $L2838
00154 8b 45 f4 mov eax, DWORD PTR _stack$[ebp]
00157 83 78 08 00 cmp DWORD PTR [eax+8], 0
0015b 0f 85 0c 00 00
00 jne $L2837
$L2838:
; 248 :
; 249 : status = STATUS_INSUFFICIENT_RESOURCES;
00161 c7 45 e4 9a 00
00 c0 mov DWORD PTR _status$[ebp], -1073741670 ; c000009aH
; 250 : break;
00168 e9 68 02 00 00 jmp $L2824
$L2837:
; 251 : }
; 252 : status = Test98_StartFdo (DeviceData,
; 253 : &stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList,
; 254 : &stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList);
0016d 8b 45 f4 mov eax, DWORD PTR _stack$[ebp]
00170 8b 40 08 mov eax, DWORD PTR [eax+8]
00173 83 c0 0c add eax, 12 ; 0000000cH
00176 50 push eax
00177 8b 45 f4 mov eax, DWORD PTR _stack$[ebp]
0017a 8b 40 04 mov eax, DWORD PTR [eax+4]
0017d 83 c0 0c add eax, 12 ; 0000000cH
00180 50 push eax
00181 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
00184 50 push eax
00185 e8 00 00 00 00 call _Test98_StartFdo@12
0018a 89 45 e4 mov DWORD PTR _status$[ebp], eax
; 255 :
; 256 :
; 257 : if (NT_SUCCESS (status)) {
0018d 83 7d e4 00 cmp DWORD PTR _status$[ebp], 0
00191 0f 8c 07 00 00
00 jl $L2839
; 258 : DeviceData->Started = TRUE;
00197 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
0019a c6 40 1a 01 mov BYTE PTR [eax+26], 1
$L2839:
$L2836:
; 259 : }
; 260 : }
; 261 :
; 262 : //
; 263 : // We must now complete the IRP, since we stopped it in the
; 264 : // completetion routine with MORE_PROCESSING_REQUIRED.
; 265 : //
; 266 :
; 267 : Irp->IoStatus.Information = 0;
0019e 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
001a1 c7 40 1c 00 00
00 00 mov DWORD PTR [eax+28], 0
; 268 : break;
001a8 e9 28 02 00 00 jmp $L2824
$L2840:
; 269 :
; 270 : case IRP_MN_QUERY_STOP_DEVICE:
; 271 : Test98_KdPrint (DeviceData, TEST_DBG_PNP_TRACE, ("Query Stop Device\n"));
; 272 :
; 273 : // This occurs during shutdown when user explicitly requesting
; 274 : // the service to be stopped
; 275 : //
; 276 :
; 277 : if (DeviceData->NumPDOs) {
001ad 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
001b0 83 78 24 00 cmp DWORD PTR [eax+36], 0
001b4 0f 84 0c 00 00
00 je $L2841
; 278 : status = STATUS_UNSUCCESSFUL;
001ba c7 45 e4 01 00
00 c0 mov DWORD PTR _status$[ebp], -1073741823 ; c0000001H
; 279 : } else {
001c1 e9 07 00 00 00 jmp $L2842
$L2841:
; 280 : status = STATUS_SUCCESS;
001c6 c7 45 e4 00 00
00 00 mov DWORD PTR _status$[ebp], 0
$L2842:
; 281 : }
; 282 :
; 283 : Irp->IoStatus.Status = status;
001cd 8b 45 e4 mov eax, DWORD PTR _status$[ebp]
001d0 8b 4d 0c mov ecx, DWORD PTR _Irp$[ebp]
001d3 89 41 18 mov DWORD PTR [ecx+24], eax
; 284 : IoSkipCurrentIrpStackLocation (Irp);
001d6 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
001d9 fe 40 23 inc BYTE PTR [eax+35]
001dc 8b 45 0c mov eax, DWORD PTR _Irp$[ebp]
001df 83 40 60 24 add DWORD PTR [eax+96], 36 ; 00000024H
; 285 : status = IoCallDriver (DeviceData->TopOfStack, Irp);
001e3 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
001e6 8b 55 0c mov edx, DWORD PTR _Irp$[ebp]
001e9 8b 48 2c mov ecx, DWORD PTR [eax+44]
001ec ff 15 00 00 00
00 call DWORD PTR __imp_@IofCallDriver@8
001f2 89 45 e4 mov DWORD PTR _status$[ebp], eax
; 286 :
; 287 : Test98_DecIoCount (DeviceData);
001f5 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
001f8 50 push eax
001f9 e8 00 00 00 00 call _Test98_DecIoCount@4
; 288 : return status;
001fe 8b 45 e4 mov eax, DWORD PTR _status$[ebp]
00201 e9 f4 01 00 00 jmp $L2812
$L2843:
; 289 :
; 290 : case IRP_MN_STOP_DEVICE:
; 291 : Test98_KdPrint (DeviceData, TEST_DBG_PNP_TRACE, ("Stop Device\n"));
; 292 :
; 293 : // PnP manager sends this IPR to stop a device so that it can reconfigure
; 294 : // its resources. sends this only after IRP_MN_QUERY_STOP_DEVICE
; 295 : // completed successfully
; 296 : //
; 297 : if (DeviceData->Started) {
00206 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
00209 33 c9 xor ecx, ecx
0020b 8a 48 1a mov cl, BYTE PTR [eax+26]
0020e 85 c9 test ecx, ecx
00210 0f 84 1f 00 00
00 je $L2844
; 298 : //
; 299 : // Free resources given by start device.
; 300 : //
; 301 : if (DeviceData->MappedPorts) {
00216 8b 45 14 mov eax, DWORD PTR _DeviceData$[ebp]
00219 33 c9 xor ecx, ecx
0021b 8a 48 18 mov cl, BYTE PTR [eax+24]
0021e 85 c9 test ecx, ecx
00220 0f 84 0f 00 00
00 je $L2845
; 302 : MmUnmapIoSpace (DeviceData->TestPortAddress, 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -