pnp.cod

来自「怎样在win2000下构造驱动程序znsoft_Serial2000_demo.」· COD 代码 · 共 2,112 行 · 第 1/5 页

COD
2,112
字号

  0091e	57		 push	 edi
  0091f	57		 push	 edi
  00920	57		 push	 edi
  00921	57		 push	 edi
  00922	56		 push	 esi
  00923	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeWaitForSingleObject@20
$L15141:

; 511  :       }
; 512  : 
; 513  :       ExFreePool(pQueryCapsEvent);

  00929	56		 push	 esi
  0092a	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExFreePool@4

; 514  : 
; 515  :       status = PIrp->IoStatus.Status;

  00930	8b 43 18	 mov	 eax, DWORD PTR [ebx+24]
  00933	89 45 fc	 mov	 DWORD PTR _status$[ebp], eax

; 516  : 
; 517  :       if (pIrpStack->Parameters.DeviceCapabilities.Capabilities == NULL) {

  00936	8b 45 0c	 mov	 eax, DWORD PTR _pIrpStack$[ebp]
  00939	39 78 04	 cmp	 DWORD PTR [eax+4], edi
  0093c	0f 84 96 00 00
	00		 je	 $errQueryCaps$15145

; 518  :          goto errQueryCaps;
; 519  :       }
; 520  : 
; 521  :       //
; 522  :       // Save off their power capabilities
; 523  :       //
; 524  : 
; 525  :       SerialDump(SERPNPPOWER, ("SERIAL: Mapping power capabilities\n"));

  00942	f6 05 01 00 00
	00 01		 test	 BYTE PTR _SerialDebugLevel+1, 1
  00949	74 0b		 je	 SHORT $L15147
  0094b	68 00 00 00 00	 push	 OFFSET FLAT:$SG15152
  00950	e8 00 00 00 00	 call	 _DbgPrint
  00955	59		 pop	 ecx
$L15147:

; 526  : 
; 527  :       pIrpStack = IoGetCurrentIrpStackLocation(PIrp);
; 528  : 
; 529  :       pDevCaps = pIrpStack->Parameters.DeviceCapabilities.Capabilities;

  00956	8b 43 60	 mov	 eax, DWORD PTR [ebx+96]

; 530  : 
; 531  :       for (cap = PowerSystemSleeping1; cap < PowerSystemMaximum;
; 532  :            cap++) {

  00959	c7 45 08 02 00
	00 00		 mov	 DWORD PTR _cap$15107[ebp], 2
  00960	8b 70 04	 mov	 esi, DWORD PTR [eax+4]
  00963	8b 45 f8	 mov	 eax, DWORD PTR _pDevExt$[ebp]
  00966	05 08 05 00 00	 add	 eax, 1288		; 00000508H
  0096b	89 45 0c	 mov	 DWORD PTR 12+[ebp], eax
  0096e	8d 7e 18	 lea	 edi, DWORD PTR [esi+24]
$L15162:

; 533  :          SerialDump(SERPNPPOWER, ("  SERIAL: %d: %s <--> %s\n",
; 534  :                                   cap, SerSystemCapString[cap],
; 535  :                                   SerDeviceCapString[pDevCaps->DeviceState[cap]]
; 536  :                                   ));

  00971	f6 05 01 00 00
	00 01		 test	 BYTE PTR _SerialDebugLevel+1, 1
  00978	74 21		 je	 SHORT $L15163
  0097a	8b 07		 mov	 eax, DWORD PTR [edi]
  0097c	ff 34 85 00 00
	00 00		 push	 DWORD PTR _SerDeviceCapString[eax*4]
  00983	8b 45 08	 mov	 eax, DWORD PTR _cap$15107[ebp]
  00986	ff 34 85 00 00
	00 00		 push	 DWORD PTR _SerSystemCapString[eax*4]
  0098d	50		 push	 eax
  0098e	68 00 00 00 00	 push	 OFFSET FLAT:$SG15168
  00993	e8 00 00 00 00	 call	 _DbgPrint
  00998	83 c4 10	 add	 esp, 16			; 00000010H
$L15163:

; 537  : 
; 538  :          pDevExt->DeviceStateMap[cap] = pDevCaps->DeviceState[cap];

  0099b	8b 07		 mov	 eax, DWORD PTR [edi]
  0099d	8b 4d 0c	 mov	 ecx, DWORD PTR 12+[ebp]
  009a0	ff 45 08	 inc	 DWORD PTR _cap$15107[ebp]
  009a3	83 45 0c 04	 add	 DWORD PTR 12+[ebp], 4
  009a7	83 c7 04	 add	 edi, 4
  009aa	83 7d 08 07	 cmp	 DWORD PTR _cap$15107[ebp], 7
  009ae	89 01		 mov	 DWORD PTR [ecx], eax
  009b0	7c bf		 jl	 SHORT $L15162

; 539  :       }
; 540  : 
; 541  :       pDevExt->DeviceStateMap[PowerSystemUnspecified]
; 542  :          = PowerDeviceUnspecified;

  009b2	8b 45 f8	 mov	 eax, DWORD PTR _pDevExt$[ebp]
  009b5	83 a0 00 05 00
	00 00		 and	 DWORD PTR [eax+1280], 0

; 543  : 
; 544  :       pDevExt->DeviceStateMap[PowerSystemWorking]
; 545  :         = PowerDeviceD0;

  009bc	c7 80 04 05 00
	00 01 00 00 00	 mov	 DWORD PTR [eax+1284], 1

; 546  : 
; 547  :       pDevExt->SystemWake = pDevCaps->SystemWake;

  009c6	8b 4e 2c	 mov	 ecx, DWORD PTR [esi+44]
  009c9	89 88 78 05 00
	00		 mov	 DWORD PTR [eax+1400], ecx

; 548  :       pDevExt->DeviceWake = pDevCaps->DeviceWake;

  009cf	8b 4e 30	 mov	 ecx, DWORD PTR [esi+48]
  009d2	89 88 7c 05 00
	00		 mov	 DWORD PTR [eax+1404], ecx
$errQueryCaps$15145:
  009d8	8b 75 fc	 mov	 esi, DWORD PTR _status$[ebp]
  009db	8b 7d f8	 mov	 edi, DWORD PTR _pDevExt$[ebp]

; 549  : 
; 550  :       errQueryCaps:;
; 551  : 
; 552  :       SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);
; 553  :       return status;

  009de	e9 87 08 00 00	 jmp	 $L15843
$L15176:

; 554  :    }
; 555  : 
; 556  :    case IRP_MN_QUERY_DEVICE_RELATIONS:
; 557  :       //
; 558  :       // We just pass this down -- serenum enumerates our bus for us.
; 559  :       //
; 560  : 
; 561  :       SerialDump (SERPNPPOWER, ("SERIAL: Got IRP_MN_QUERY_DEVICE_RELATIONS "
; 562  :                                 "Irp\n"));

  009e3	a1 00 00 00 00	 mov	 eax, DWORD PTR _SerialDebugLevel
  009e8	be 00 01 00 00	 mov	 esi, 256		; 00000100H
  009ed	85 c6		 test	 eax, esi
  009ef	74 10		 je	 SHORT $L15177
  009f1	68 00 00 00 00	 push	 OFFSET FLAT:$SG15182
  009f6	e8 00 00 00 00	 call	 _DbgPrint
  009fb	a1 00 00 00 00	 mov	 eax, DWORD PTR _SerialDebugLevel
  00a00	59		 pop	 ecx
$L15177:

; 563  : 
; 564  :       switch (pIrpStack->Parameters.QueryDeviceRelations.Type) {

  00a01	8b 4d 0c	 mov	 ecx, DWORD PTR _pIrpStack$[ebp]
  00a04	8b 49 04	 mov	 ecx, DWORD PTR [ecx+4]
  00a07	83 e9 00	 sub	 ecx, 0
  00a0a	74 43		 je	 SHORT $L15194
  00a0c	49		 dec	 ecx
  00a0d	74 35		 je	 SHORT $L15208
  00a0f	49		 dec	 ecx
  00a10	74 27		 je	 SHORT $L15222
  00a12	49		 dec	 ecx
  00a13	74 19		 je	 SHORT $L15236
  00a15	49		 dec	 ecx
  00a16	74 0b		 je	 SHORT $L15250

; 584  : 
; 585  :       default:
; 586  :          SerialDump(SERPNPPOWER, ("------- Unknown Query\n"));

  00a18	85 c6		 test	 eax, esi
  00a1a	74 42		 je	 SHORT $L15932
  00a1c	68 00 00 00 00	 push	 OFFSET FLAT:$SG15270

; 587  :          break;

  00a21	eb 35		 jmp	 SHORT $L17480
$L15250:

; 580  : 
; 581  :       case TargetDeviceRelation:
; 582  :          SerialDump(SERPNPPOWER, ("------- TargetDeviceRelation Query\n"));

  00a23	85 c6		 test	 eax, esi
  00a25	74 37		 je	 SHORT $L15932
  00a27	68 00 00 00 00	 push	 OFFSET FLAT:$SG15256

; 583  :          break;

  00a2c	eb 2a		 jmp	 SHORT $L17480
$L15236:

; 576  : 
; 577  :       case RemovalRelations:
; 578  :          SerialDump(SERPNPPOWER, ("------- RemovalRelations Query\n"));

  00a2e	85 c6		 test	 eax, esi
  00a30	74 2c		 je	 SHORT $L15932
  00a32	68 00 00 00 00	 push	 OFFSET FLAT:$SG15242

; 579  :          break;

  00a37	eb 1f		 jmp	 SHORT $L17480
$L15222:

; 572  : 
; 573  :       case PowerRelations:
; 574  :          SerialDump(SERPNPPOWER, ("------- PowerRelations Query\n"));

  00a39	85 c6		 test	 eax, esi
  00a3b	74 21		 je	 SHORT $L15932
  00a3d	68 00 00 00 00	 push	 OFFSET FLAT:$SG15228

; 575  :          break;

  00a42	eb 14		 jmp	 SHORT $L17480
$L15208:

; 567  :          break;
; 568  : 
; 569  :       case EjectionRelations:
; 570  :          SerialDump(SERPNPPOWER, ("------- EjectionRelations Query\n"));

  00a44	85 c6		 test	 eax, esi
  00a46	74 16		 je	 SHORT $L15932
  00a48	68 00 00 00 00	 push	 OFFSET FLAT:$SG15214

; 571  :          break;

  00a4d	eb 09		 jmp	 SHORT $L17480
$L15194:

; 565  :       case BusRelations:
; 566  :          SerialDump(SERPNPPOWER, ("------- BusRelations Query\n"));

  00a4f	85 c6		 test	 eax, esi
  00a51	74 0b		 je	 SHORT $L15932
  00a53	68 00 00 00 00	 push	 OFFSET FLAT:$SG15200
$L17480:
  00a58	e8 00 00 00 00	 call	 _DbgPrint
  00a5d	59		 pop	 ecx
$L15932:

; 1285 :       }
; 1286 : 
; 1287 :    default:
; 1288 :       break;
; 1289 : 
; 1290 : 
; 1291 : 
; 1292 :    }   // switch (pIrpStack->MinorFunction)
; 1293 : 
; 1294 :    //
; 1295 :    // Pass to driver beneath us
; 1296 :    //
; 1297 : 
; 1298 :    IoSkipCurrentIrpStackLocation(PIrp);

  00a5e	83 43 60 24	 add	 DWORD PTR [ebx+96], 36	; 00000024H
  00a62	fe 43 23	 inc	 BYTE PTR [ebx+35]

; 1299 :    status = SerialIoCallDriver(pDevExt, pLowerDevObj, PIrp);

  00a65	53		 push	 ebx
  00a66	ff 75 fc	 push	 DWORD PTR _pLowerDevObj$[ebp]
  00a69	57		 push	 edi
$L17486:
  00a6a	e8 00 00 00 00	 call	 _SerialIoCallDriver@12
$L15087:
  00a6f	5f		 pop	 edi
  00a70	5e		 pop	 esi
  00a71	5b		 pop	 ebx

; 1300 :    return status;
; 1301 : }

  00a72	c9		 leave
  00a73	c2 08 00	 ret	 8
$L15278:

; 588  :       }
; 589  : 
; 590  :       IoSkipCurrentIrpStackLocation(PIrp);
; 591  :       status = SerialIoCallDriver(pDevExt, pLowerDevObj, PIrp);
; 592  :       return status;
; 593  : 
; 594  : 
; 595  :    case IRP_MN_QUERY_INTERFACE:
; 596  :       SerialDump (SERPNPPOWER, ("SERIAL: Got IRP_MN_QUERY_INTERFACE Irp\n"));

  00a76	f6 05 01 00 00
	00 01		 test	 BYTE PTR _SerialDebugLevel+1, 1
  00a7d	74 df		 je	 SHORT $L15932
  00a7f	68 00 00 00 00	 push	 OFFSET FLAT:$SG15284

; 597  :       break;

  00a84	eb d2		 jmp	 SHORT $L17480
$L15292:

; 598  : 
; 599  : 
; 600  :    case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
; 601  :       SerialDump (SERPNPPOWER, ("SERIAL: Got "
; 602  :                                 "IRP_MN_QUERY_RESOURCE_REQUIREMENTS Irp\n"));

  00a86	f6 05 01 00 00
	00 01		 test	 BYTE PTR _SerialDebugLevel+1, 1
  00a8d	74 cf		 je	 SHORT $L15932
  00a8f	68 00 00 00 00	 push	 OFFSET FLAT:$SG15298

; 603  :       break;

  00a94	eb c2		 jmp	 SHORT $L17480
$L15307:

; 604  : 
; 605  : 
; 606  :    case IRP_MN_START_DEVICE: {
; 607  :       PVOID startLockPtr;
; 608  : 
; 609  :       SerialDump (SERPNPPOWER, ("SERIAL: Got IRP_MN_START_DEVICE Irp\n"));

  00a96	f6 05 01 00 00
	00 01		 test	 BYTE PTR _SerialDebugLevel+1, 1
  00a9d	74 0b		 je	 SHORT $L15308
  00a9f	68 00 00 00 00	 push	 OFFSET FLAT:$SG15313
  00aa4	e8 00 00 00 00	 call	 _DbgPrint
  00aa9	59		 pop	 ecx
$L15308:

; 610  : 
; 611  :       //
; 612  :       // SerialStartDevice will pass this Irp to the next driver,
; 613  :       // and process it as completion so just complete it here.
; 614  :       //
; 615  : 
; 616  :       SerialLockPagableSectionByHandle(SerialGlobals.PAGESER_Handle);

  00aaa	ff 35 08 00 00
	00		 push	 DWORD PTR _SerialGlobals+8
  00ab0	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__MmLockPagableSectionByHandle@4
  00ab6	be 14 00 00 00	 mov	 esi, OFFSET FLAT:_SerialGlobals+20
  00abb	8b ce		 mov	 ecx, esi
  00abd	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@InterlockedIncrement@4

; 617  : 
; 618  :       //
; 619  :       // We used to make sure the stack was powered up, but now it
; 620  :       // is supposed to be done implicitly by start_device.
; 621  :       // If that wasn't the case we would just make this call:
; 622  :       //
; 623  :       //   status = SerialGotoPowerState(PDevObj, pDevExt, PowerDeviceD0);
; 624  :       //
; 625  : 
; 626  :       pDevExt->PowerState = PowerDeviceD0;
; 627  : 
; 628  :       status = SerialStartDevice(PDevObj, PIrp);

  00ac3	53		 push	 ebx
  00ac4	c7 87 a4 04 00
	00 01 00 00 00	 mov	 DWORD PTR [edi+1188], 1
  00ace	ff 75 08	 push	 DWORD PTR _PDevObj$[ebp]
  00ad1	e8 00 00 00 00	 call	 _SerialStartDevice@8

; 629  : 
; 630  :       (void)SerialGotoPowerState(PDevObj, pDevExt, PowerDeviceD3);

  00ad6	6a 04		 push	 4
  00ad8	57		 push	 edi
  00ad9	ff 75 08	 push	 DWORD PTR _PDevObj$[ebp]
  00adc	89 45 fc	 mov	 DWORD PTR _status$[ebp], eax
  00adf	e8 00 00 00 00	 call	 _SerialGotoPowerState@12

; 631  : 
; 632  :       SerialUnlockPagableImageSection(SerialGlobals.PAGESER_Handle);

  00ae4	8b ce		 mov	 ecx, esi
  00ae6	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@InterlockedDecrement@4
  00aec	ff 35 08 00 00
	00		 push	 DWORD PTR _SerialGlobals+8
  00af2	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__MmUnlockPagableImageSection@4

; 633  : 
; 634  : 
; 635  :       PIrp->IoStatus.Status = status;

  00af8	8b 75 fc	 mov	 esi, DWORD PTR _status$[ebp]

; 636  : 
; 637  :       SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);
; 638  :       return status;

  00afb	e9 b0 fd ff ff	 jmp	 $L17502
$L15322:

; 639  :    }
; 640  : 
; 641  : 
; 642  :    case IRP_MN_READ_CONFIG:
; 643  :       SerialDump (SERPNPPOWER, ("SERIAL: Got IRP_MN_READ_CONFIG Irp\n"));

  00b00	f6 05 01 00 00
	00 01		 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?