⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pnp.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 5 页
字号:

; 368  :    PDEVICE_OBJECT pLowerDevObj = NULL;
; 369  :    NTSTATUS status;
; 370  :    PSERIAL_DEVICE_EXTENSION pDevExt;
; 371  : 
; 372  :    PAGED_CODE();
; 373  : 
; 374  :    SerialDump(SERTRACECALLS, ("SERIAL: Enter SerialAddDevice with PPdo "
; 375  :                               "0x%x\n", PPdo));
; 376  : 
; 377  :    if (PPdo == NULL) {

  0000a	8b 7d 0c	 mov	 edi, DWORD PTR _PPdo$[ebp]
  0000d	85 ff		 test	 edi, edi
  0000f	75 07		 jne	 SHORT $L14872

; 378  :       //
; 379  :       // Return no more devices
; 380  :       //
; 381  : 
; 382  :       SerialDump(SERERRORS, ("SerialAddDevice: Enumeration request, returning"
; 383  :                              " NO_MORE_ENTRIES\n"));
; 384  : 
; 385  :       return (STATUS_NO_MORE_ENTRIES);

  00011	b8 1a 00 00 80	 mov	 eax, -2147483622	; 8000001aH
  00016	eb 36		 jmp	 SHORT $L14861
$L14872:

; 386  :    }
; 387  : 
; 388  : 
; 389  : 
; 390  :    //
; 391  :    // create and initialize the new device object
; 392  :    //
; 393  : 
; 394  :    status = SerialCreateDevObj(DriverObject, &pNewDevObj);

  00018	8d 45 fc	 lea	 eax, DWORD PTR _pNewDevObj$[ebp]
  0001b	50		 push	 eax
  0001c	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  0001f	e8 00 00 00 00	 call	 _SerialCreateDevObj@8
  00024	8b d8		 mov	 ebx, eax

; 395  : 
; 396  :    if (!NT_SUCCESS(status)) {

  00026	85 db		 test	 ebx, ebx

; 397  : 
; 398  :       SerialDump(SERERRORS,
; 399  :                  ("SerialAddDevice - error creating new devobj [%#08lx]\n",
; 400  :                   status));
; 401  :       return status;

  00028	7c 22		 jl	 SHORT $L16136
  0002a	56		 push	 esi

; 402  :    }
; 403  : 
; 404  : 
; 405  :    //
; 406  :    // Layer our DO on top of the lower device object
; 407  :    // The return value is a pointer to the device object to which the
; 408  :    // DO is actually attached.
; 409  :    //
; 410  : 
; 411  :    pLowerDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, PPdo);

  0002b	8b 75 fc	 mov	 esi, DWORD PTR _pNewDevObj$[ebp]
  0002e	57		 push	 edi
  0002f	56		 push	 esi
  00030	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoAttachDeviceToDeviceStack@8

; 412  : 
; 413  : 
; 414  :    //
; 415  :    // No status. Do the best we can.
; 416  :    //
; 417  :    ASSERT(pLowerDevObj != NULL);
; 418  : 
; 419  : 
; 420  :    pDevExt = pNewDevObj->DeviceExtension;

  00036	8b 4e 28	 mov	 ecx, DWORD PTR [esi+40]

; 421  :    pDevExt->LowerDeviceObject = pLowerDevObj;

  00039	89 81 a0 04 00
	00		 mov	 DWORD PTR [ecx+1184], eax

; 422  :    pDevExt->Pdo = PPdo;

  0003f	89 b9 80 05 00
	00		 mov	 DWORD PTR [ecx+1408], edi

; 423  : 
; 424  : 
; 425  : 
; 426  :    //
; 427  :    // Specify that this driver only supports buffered IO.  This basically
; 428  :    // means that the IO system copies the users data to and from
; 429  :    // system supplied buffers.
; 430  :    //
; 431  :    // Also specify that we are power pagable.
; 432  :    //
; 433  : 
; 434  :    pNewDevObj->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE;

  00045	66 81 4e 1c 04
	20		 or	 WORD PTR [esi+28], 8196	; 00002004H
  0004b	5e		 pop	 esi
$L16136:

; 435  : 
; 436  :    SerialDump(SERTRACECALLS, ("SERIAL: Leave SerialAddDevice\n"));
; 437  : 
; 438  :    return status;

  0004c	8b c3		 mov	 eax, ebx
$L14861:
  0004e	5f		 pop	 edi
  0004f	5b		 pop	 ebx

; 439  : }

  00050	c9		 leave
  00051	c2 08 00	 ret	 8
_SerialAddDevice@8 ENDP
PAGESRP0	ENDS
PUBLIC	_SerialStartDevice@8
PUBLIC	_SerialPnpDispatch@8
EXTRN	__imp__MmLockPagableSectionByHandle@4:NEAR
EXTRN	__imp__MmUnlockPagableImageSection@4:NEAR
EXTRN	_SerialGetRegistryKeyValue@20:NEAR
EXTRN	__imp_@InterlockedIncrement@4:NEAR
EXTRN	__imp_@InterlockedDecrement@4:NEAR
EXTRN	__imp__KeWaitForSingleObject@20:NEAR
EXTRN	_SerialIRPPrologue@8:NEAR
EXTRN	_SerialIRPEpilogue@4:NEAR
EXTRN	_SerialIoCallDriver@12:NEAR
EXTRN	_SerialRemoveDevObj@4:NEAR
EXTRN	_SerialReleaseResources@4:NEAR
EXTRN	_SerialKillPendingIrps@4:NEAR
EXTRN	__imp__wcslen:NEAR
EXTRN	__imp__IoOpenDeviceRegistryKey@16:NEAR
EXTRN	_SerialGotoPowerState@12:NEAR
EXTRN	__imp_@ExAcquireFastMutex@4:NEAR
EXTRN	__imp_@ExReleaseFastMutex@4:NEAR
EXTRN	_SerialDisableInterfacesResources@8:NEAR
EXTRN	_SerialSetDeviceFlags@16:NEAR
EXTRN	_SerialGlobals:BYTE
EXTRN	__imp_@IofCallDriver@8:NEAR
EXTRN	__imp_@IofCompleteRequest@8:NEAR
EXTRN	__imp__ZwClose@4:NEAR
;	COMDAT _SerialPnpDispatch@8
PAGESRP0	SEGMENT
$SG15013 DB	'M', 00H, 'u', 00H, 'l', 00H, 't', 00H, 'i', 00H, 'p', 00H
	DB	'o', 00H, 'r', 00H, 't', 00H, 'D', 00H, 'e', 00H, 'v', 00H, 'i'
	DB	00H, 'c', 00H, 'e', 00H, 00H, 00H
$SG15016 DB	'*', 00H, 'P', 00H, 'N', 00H, 'P', 00H, '0', 00H, '5', 00H
	DB	'0', 00H, '2', 00H, 00H, 00H
	ORG $+2
$SG15017 DB	'*', 00H, 'P', 00H, 'N', 00H, 'P', 00H, '0', 00H, '5', 00H
	DB	'0', 00H, '1', 00H, 00H, 00H
	ORG $+2
$SG15104 DB	'M', 00H, 'u', 00H, 'l', 00H, 't', 00H, 'i', 00H, 'p', 00H
	DB	'o', 00H, 'r', 00H, 't', 00H, 'D', 00H, 'e', 00H, 'v', 00H, 'i'
	DB	00H, 'c', 00H, 'e', 00H, 00H, 00H
; Function compile flags: /Ogsy
_PDevObj$ = 8
_PIrp$ = 12
_pDevExt$ = -8
_pLowerDevObj$ = -4
_pIrpStack$ = -16
_status$ = 12
_pQueryCapsEvent$14902 = 8
_pIdBuf$14999 = -24
_pPnpIdStr$15000 = 12
_isMulti$15002 = -12
_pnpKey$15003 = -16
_curStr$15021 = 8
_pnpKey$15060 = -20
_pResFiltEvent$15061 = 8
_isMulti$15062 = 12
_j$15067 = -12
_gotISR$15069 = -4
_gotInt$15070 = 8
_listNum$15071 = -16
_SerialPnpDispatch@8 PROC NEAR				; COMDAT

; 465  : {

  00068	55		 push	 ebp
  00069	8b ec		 mov	 ebp, esp
  0006b	83 ec 18	 sub	 esp, 24			; 00000018H

; 466  :    PSERIAL_DEVICE_EXTENSION pDevExt = PDevObj->DeviceExtension;

  0006e	8b 45 08	 mov	 eax, DWORD PTR _PDevObj$[ebp]
  00071	53		 push	 ebx

; 467  :    PDEVICE_OBJECT pLowerDevObj = pDevExt->LowerDeviceObject;
; 468  :    PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(PIrp);

  00072	8b 5d 0c	 mov	 ebx, DWORD PTR _PIrp$[ebp]
  00075	56		 push	 esi
  00076	57		 push	 edi
  00077	8b 78 28	 mov	 edi, DWORD PTR [eax+40]
  0007a	8b 73 60	 mov	 esi, DWORD PTR [ebx+96]

; 469  :    NTSTATUS status;
; 470  :    PDEVICE_CAPABILITIES pDevCaps;
; 471  : 
; 472  :    PAGED_CODE();
; 473  : 
; 474  :    if ((status = SerialIRPPrologue(PIrp, pDevExt)) != STATUS_SUCCESS) {

  0007d	57		 push	 edi
  0007e	8b 87 a0 04 00
	00		 mov	 eax, DWORD PTR [edi+1184]
  00084	53		 push	 ebx
  00085	89 7d f8	 mov	 DWORD PTR _pDevExt$[ebp], edi
  00088	89 45 fc	 mov	 DWORD PTR _pLowerDevObj$[ebp], eax
  0008b	89 75 f0	 mov	 DWORD PTR _pIrpStack$[ebp], esi
  0008e	e8 00 00 00 00	 call	 _SerialIRPPrologue@8
  00093	85 c0		 test	 eax, eax
  00095	74 07		 je	 SHORT $L14896
$L16220:

; 490  :          PIrp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;

  00097	8b f0		 mov	 esi, eax
  00099	e9 ce 05 00 00	 jmp	 $L16218
$L14896:

; 475  :       SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);
; 476  :       return status;
; 477  :    }
; 478  : 
; 479  :    switch (pIrpStack->MinorFunction) {

  0009e	0f b6 46 01	 movzx	 eax, BYTE PTR [esi+1]
  000a2	83 f8 17	 cmp	 eax, 23			; 00000017H
  000a5	0f 87 00 01 00
	00		 ja	 $L15274
  000ab	0f b6 80 00 00
	00 00		 movzx	 eax, BYTE PTR $L16199[eax]
  000b2	ff 24 85 00 00
	00 00		 jmp	 DWORD PTR $L16222[eax*4]
$L14904:

; 480  :    case IRP_MN_QUERY_CAPABILITIES: {
; 481  :       PKEVENT pQueryCapsEvent;
; 482  :       SYSTEM_POWER_STATE cap;
; 483  : 
; 484  :       SerialDump(SERPNPPOWER, ("SERIAL: Got IRP_MN_QUERY_DEVICE_CAPABILITIES "
; 485  :                                "IRP\n"));
; 486  : 
; 487  :       pQueryCapsEvent = ExAllocatePool(NonPagedPool, sizeof(KEVENT));

  000b9	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  000be	6a 10		 push	 16			; 00000010H
  000c0	6a 00		 push	 0
  000c2	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12

; 488  : 
; 489  :       if (pQueryCapsEvent == NULL) {

  000c8	85 c0		 test	 eax, eax
  000ca	89 45 08	 mov	 DWORD PTR _pQueryCapsEvent$14902[ebp], eax
  000cd	75 0a		 jne	 SHORT $L14909

; 490  :          PIrp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;

  000cf	be 9a 00 00 c0	 mov	 esi, -1073741670	; c000009aH
  000d4	e9 90 05 00 00	 jmp	 $L16216
$L14909:

; 491  :          SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);
; 492  :          return STATUS_INSUFFICIENT_RESOURCES;
; 493  :       }
; 494  : 
; 495  :       KeInitializeEvent(pQueryCapsEvent, SynchronizationEvent, FALSE);

  000d9	6a 00		 push	 0
  000db	6a 01		 push	 1
  000dd	ff 75 08	 push	 DWORD PTR _pQueryCapsEvent$14902[ebp]
  000e0	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeInitializeEvent@12

; 496  : 
; 497  :       IoCopyCurrentIrpStackLocationToNext(PIrp);

  000e6	8b 73 60	 mov	 esi, DWORD PTR [ebx+96]
  000e9	6a 07		 push	 7
  000eb	59		 pop	 ecx

; 498  :       IoSetCompletionRoutine(PIrp, SerialSyncCompletion, pQueryCapsEvent,
; 499  :                              TRUE, TRUE, TRUE);
; 500  : 
; 501  :       status = IoCallDriver(pLowerDevObj, PIrp);

  000ec	8b d3		 mov	 edx, ebx
  000ee	8d 46 dc	 lea	 eax, DWORD PTR [esi-36]
  000f1	8b f8		 mov	 edi, eax
  000f3	f3 a5		 rep movsd
  000f5	80 60 03 00	 and	 BYTE PTR [eax+3], 0
  000f9	8b 43 60	 mov	 eax, DWORD PTR [ebx+96]
  000fc	8b 4d 08	 mov	 ecx, DWORD PTR _pQueryCapsEvent$14902[ebp]
  000ff	83 e8 24	 sub	 eax, 36			; 00000024H
  00102	89 48 20	 mov	 DWORD PTR [eax+32], ecx
  00105	8b 4d fc	 mov	 ecx, DWORD PTR _pLowerDevObj$[ebp]
  00108	c7 40 1c 00 00
	00 00		 mov	 DWORD PTR [eax+28], OFFSET FLAT:_SerialSyncCompletion@12
  0010f	c6 40 03 e0	 mov	 BYTE PTR [eax+3], 224	; 000000e0H
  00113	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@IofCallDriver@8

; 502  : 
; 503  : 
; 504  :       //
; 505  :       // Wait for lower drivers to be done with the Irp
; 506  :       //
; 507  : 
; 508  :       if (status == STATUS_PENDING) {
; 509  :          KeWaitForSingleObject(pQueryCapsEvent, Executive, KernelMode, FALSE,
; 510  :                                NULL);

  00119	33 f6		 xor	 esi, esi
  0011b	3d 03 01 00 00	 cmp	 eax, 259		; 00000103H
  00120	75 0d		 jne	 SHORT $L14922
  00122	56		 push	 esi
  00123	56		 push	 esi
  00124	56		 push	 esi
  00125	56		 push	 esi
  00126	ff 75 08	 push	 DWORD PTR _pQueryCapsEvent$14902[ebp]
  00129	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeWaitForSingleObject@20
$L14922:

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

  0012f	ff 75 08	 push	 DWORD PTR _pQueryCapsEvent$14902[ebp]
  00132	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExFreePool@4

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

  00138	8b 43 18	 mov	 eax, DWORD PTR [ebx+24]
  0013b	89 45 0c	 mov	 DWORD PTR _status$[ebp], eax

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

  0013e	8b 45 f0	 mov	 eax, DWORD PTR _pIrpStack$[ebp]
  00141	39 70 04	 cmp	 DWORD PTR [eax+4], esi
  00144	74 4b		 je	 SHORT $errQueryCaps$14926

; 518  :          goto errQueryCaps;
; 519  :       }
; 520  : 
; 521  :       //
; 522  :       // Save off their power capabilities
; 523  :       //
; 524  : 
; 525  :       SerialDump(SERPNPPOWER, ("SERIAL: Mapping power capabilities\n"));
; 526  : 
; 527  :       pIrpStack = IoGetCurrentIrpStackLocation(PIrp);
; 528  : 
; 529  :       pDevCaps = pIrpStack->Parameters.DeviceCapabilities.Capabilities;

  00146	8b 43 60	 mov	 eax, DWORD PTR [ebx+96]
  00149	8b 4d f8	 mov	 ecx, DWORD PTR _pDevExt$[ebp]
  0014c	c7 45 08 05 00
	00 00		 mov	 DWORD PTR 8+[ebp], 5
  00153	8b 40 04	 mov	 eax, DWORD PTR [eax+4]
  00156	8d b1 08 05 00
	00		 lea	 esi, DWORD PTR [ecx+1288]
  0015c	8d 50 18	 lea	 edx, DWORD PTR [eax+24]
$L14933:

; 530  : 
; 531  :       for (cap = PowerSystemSleeping1; cap < PowerSystemMaximum;
; 532  :            cap++) {
; 533  :          SerialDump(SERPNPPOWER, ("  SERIAL: %d: %s <--> %s\n",
; 534  :                                   cap, SerSystemCapString[cap],
; 535  :                                   SerDeviceCapString[pDevCaps->DeviceState[cap]]
; 536  :                                   ));
; 537  : 
; 538  :          pDevExt->DeviceStateMap[cap] = pDevCaps->DeviceState[cap];

  0015f	8b 3a		 mov	 edi, DWORD PTR [edx]
  00161	83 c2 04	 add	 edx, 4
  00164	89 3e		 mov	 DWORD PTR [esi], edi
  00166	83 c6 04	 add	 esi, 4
  00169	ff 4d 08	 dec	 DWORD PTR 8+[ebp]
  0016c	75 f1		 jne	 SHORT $L14933

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

  0016e	83 a1 00 05 00
	00 00		 and	 DWORD PTR [ecx+1280], 0

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

⌨️ 快捷键说明

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