pnp.cod

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

COD
2,077
字号
; 222  :                     0,
; 223  :                     0,
; 224  :                     0,
; 225  :                     19,
; 226  :                     STATUS_SUCCESS,
; 227  :                     SERIAL_INSUFFICIENT_RESOURCES,
; 228  :                     0,
; 229  :                     NULL,
; 230  :                     0,
; 231  :                     NULL
; 232  :                     );

  0014d	57		 push	 edi
  0014e	a1 04 00 00 00	 mov	 eax, DWORD PTR _SerialPhysicalZero+4
  00153	57		 push	 edi
  00154	8b 0d 00 00 00
	00		 mov	 ecx, DWORD PTR _SerialPhysicalZero
  0015a	57		 push	 edi
  0015b	57		 push	 edi
  0015c	68 08 00 06 c0	 push	 -1073348600		; c0060008H
  00161	57		 push	 edi
  00162	6a 13		 push	 19			; 00000013H
  00164	57		 push	 edi
  00165	57		 push	 edi
  00166	57		 push	 edi
  00167	50		 push	 eax
  00168	51		 push	 ecx
  00169	50		 push	 eax
  0016a	51		 push	 ecx
  0016b	57		 push	 edi
  0016c	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  0016f	e8 00 00 00 00	 call	 _SerialLogError@64

; 233  :       SerialDump(
; 234  :                 SERERRORS,
; 235  :                 ("SERIAL: Couldn't allocate memory for DeviceName\n"));
; 236  : 
; 237  :       status = STATUS_INSUFFICIENT_RESOURCES;

  00174	c7 45 f8 9a 00
	00 c0		 mov	 DWORD PTR _status$[ebp], -1073741670 ; c000009aH

; 238  :       goto SerialCreateDevObjError;

  0017b	eb 55		 jmp	 SHORT $SerialCreateDevObjError$14819
$L14822:

; 239  :    }
; 240  : 
; 241  :    pDevExt->DeviceName.MaximumLength = deviceObjName.Length
; 242  :       + sizeof(WCHAR);

  0017d	8b 45 f0	 mov	 eax, DWORD PTR _deviceObjName$[ebp]

; 243  : 
; 244  :    //
; 245  :    // Zero fill it.
; 246  :    //
; 247  : 
; 248  :    RtlZeroMemory(pDevExt->DeviceName.Buffer,
; 249  :                  pDevExt->DeviceName.MaximumLength);

  00180	8b fa		 mov	 edi, edx
  00182	83 c0 02	 add	 eax, 2
  00185	0f b7 c8	 movzx	 ecx, ax
  00188	8b d1		 mov	 edx, ecx
  0018a	66 89 46 62	 mov	 WORD PTR [esi+98], ax
  0018e	33 c0		 xor	 eax, eax
  00190	c1 e9 02	 shr	 ecx, 2
  00193	f3 ab		 rep stosd
  00195	8b ca		 mov	 ecx, edx
  00197	83 e1 03	 and	 ecx, 3
  0019a	f3 aa		 rep stosb

; 250  : 
; 251  :    RtlAppendUnicodeStringToString(&pDevExt->DeviceName, &deviceObjName);

  0019c	8b 3d 00 00 00
	00		 mov	 edi, DWORD PTR __imp__RtlAppendUnicodeStringToString@8
  001a2	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  001a5	50		 push	 eax
  001a6	8d 46 60	 lea	 eax, DWORD PTR [esi+96]
  001a9	50		 push	 eax
  001aa	ff d7		 call	 edi

; 252  : 
; 253  :    pDevExt->NtNameForPort.Buffer = ExAllocatePool(PagedPool,
; 254  :                                                   deviceObjName.MaximumLength);

  001ac	0f b7 45 f2	 movzx	 eax, WORD PTR _deviceObjName$[ebp+2]
  001b0	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  001b5	50		 push	 eax
  001b6	53		 push	 ebx
  001b7	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12

; 255  : 
; 256  :    if (pDevExt->NtNameForPort.Buffer == NULL) {

  001bd	85 c0		 test	 eax, eax
  001bf	89 46 74	 mov	 DWORD PTR [esi+116], eax
  001c2	75 4d		 jne	 SHORT $L14834

; 257  :       SerialDump(SERERRORS, ("SerialAddDevice: Cannot allocate memory for "
; 258  :                              "NtName\n"));
; 259  :       status = STATUS_INSUFFICIENT_RESOURCES;

  001c4	c7 45 f8 9a 00
	00 c0		 mov	 DWORD PTR _status$[ebp], -1073741670 ; c000009aH
  001cb	eb 03		 jmp	 SHORT $L16128
$L16127:
  001cd	8b 75 08	 mov	 esi, DWORD PTR _pDevExt$[ebp]
$L16128:
  001d0	33 ff		 xor	 edi, edi
$SerialCreateDevObjError$14819:

; 309  : 
; 310  : 
; 311  :    SerialCreateDevObjError:
; 312  : 
; 313  :    SerialDump (SERERRORS,("SERIAL: SerialCreateDevObj Error, Cleaning up\n") );
; 314  : 
; 315  :    //
; 316  :    // Free the allocated strings for the NT and symbolic names if they exist.
; 317  :    //
; 318  : 
; 319  :    if (deviceObjName.Buffer != NULL) {

  001d2	39 7d f4	 cmp	 DWORD PTR _deviceObjName$[ebp+4], edi
  001d5	8b 1d 00 00 00
	00		 mov	 ebx, DWORD PTR __imp__ExFreePool@4
  001db	74 05		 je	 SHORT $L14847

; 320  :       ExFreePool(deviceObjName.Buffer);

  001dd	ff 75 f4	 push	 DWORD PTR _deviceObjName$[ebp+4]
  001e0	ff d3		 call	 ebx
$L14847:

; 321  :    }
; 322  : 
; 323  :    if (deviceObject) {

  001e2	39 7d fc	 cmp	 DWORD PTR _deviceObject$[ebp], edi
  001e5	74 1d		 je	 SHORT $L14848

; 324  : 
; 325  :       if (pDevExt->NtNameForPort.Buffer != NULL) {

  001e7	8b 46 74	 mov	 eax, DWORD PTR [esi+116]
  001ea	3b c7		 cmp	 eax, edi
  001ec	74 03		 je	 SHORT $L14850

; 326  :          ExFreePool(pDevExt->NtNameForPort.Buffer);

  001ee	50		 push	 eax
  001ef	ff d3		 call	 ebx
$L14850:

; 327  :       }
; 328  : 
; 329  :       if (pDevExt->DeviceName.Buffer != NULL) {

  001f1	8b 76 64	 mov	 esi, DWORD PTR [esi+100]
  001f4	3b f7		 cmp	 esi, edi
  001f6	74 03		 je	 SHORT $L14852

; 330  :          ExFreePool(pDevExt->DeviceName.Buffer);

  001f8	56		 push	 esi
  001f9	ff d3		 call	 ebx
$L14852:

; 331  :       }
; 332  : 
; 333  :       IoDeleteDevice(deviceObject);

  001fb	ff 75 fc	 push	 DWORD PTR _deviceObject$[ebp]
  001fe	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoDeleteDevice@4
$L14848:

; 334  :    }
; 335  : 
; 336  :    *NewDeviceObject = NULL;

  00204	8b 45 0c	 mov	 eax, DWORD PTR _NewDeviceObject$[ebp]
  00207	89 38		 mov	 DWORD PTR [eax], edi

; 337  : 
; 338  :    SerialDump (SERTRACECALLS,("SERIAL: Leave SerialCreateDevObj\n") );
; 339  :    return status;

  00209	8b 45 f8	 mov	 eax, DWORD PTR _status$[ebp]
  0020c	e9 2b 01 00 00	 jmp	 $L14782
$L14834:

; 260  :       goto SerialCreateDevObjError;
; 261  :    }
; 262  : 
; 263  :    pDevExt->NtNameForPort.MaximumLength = deviceObjName.MaximumLength;

  00211	66 8b 45 f2	 mov	 ax, WORD PTR _deviceObjName$[ebp+2]
  00215	66 89 46 72	 mov	 WORD PTR [esi+114], ax

; 264  :    RtlAppendUnicodeStringToString(&pDevExt->NtNameForPort,
; 265  :                                   &deviceObjName);

  00219	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  0021c	50		 push	 eax
  0021d	8d 46 70	 lea	 eax, DWORD PTR [esi+112]
  00220	50		 push	 eax
  00221	ff d7		 call	 edi

; 266  : 
; 267  : 
; 268  : 
; 269  :    //
; 270  :    // Set up the device extension.
; 271  :    //
; 272  : 
; 273  :    pDevExt->DeviceIsOpened = FALSE;

  00223	80 a6 9d 01 00
	00 00		 and	 BYTE PTR [esi+413], 0

; 274  :    pDevExt->DeviceObject   = deviceObject;

  0022a	8b 4d fc	 mov	 ecx, DWORD PTR _deviceObject$[ebp]
  0022d	8d 86 8c 00 00
	00		 lea	 eax, DWORD PTR [esi+140]

; 275  :    pDevExt->DriverObject   = DriverObject;
; 276  :    pDevExt->DeviceObject   = deviceObject;
; 277  :    pDevExt->PowerState     = PowerDeviceD0;
; 278  : 
; 279  :    pDevExt->TxFifoAmount           = driverDefaults.TxFIFODefault;
; 280  :    pDevExt->CreatedSymbolicLink    = TRUE;
; 281  :    pDevExt->OwnsPowerPolicy = TRUE;
; 282  : 
; 283  :    InitializeListHead(&pDevExt->CommonInterruptObject);
; 284  :    InitializeListHead(&pDevExt->TopLevelSharers);
; 285  :    InitializeListHead(&pDevExt->MultiportSiblings);
; 286  :    InitializeListHead(&pDevExt->AllDevObjs);
; 287  :    InitializeListHead(&pDevExt->ReadQueue);
; 288  :    InitializeListHead(&pDevExt->WriteQueue);
; 289  :    InitializeListHead(&pDevExt->MaskQueue);
; 290  :    InitializeListHead(&pDevExt->PurgeQueue);
; 291  :    InitializeListHead(&pDevExt->StalledIrpQueue);
; 292  : 
; 293  :    ExInitializeFastMutex(&pDevExt->OpenMutex);

  00233	8b 3d 00 00 00
	00		 mov	 edi, DWORD PTR __imp__KeInitializeEvent@12
  00239	6a 00		 push	 0
  0023b	53		 push	 ebx
  0023c	89 08		 mov	 DWORD PTR [eax], ecx
  0023e	8b 4d 08	 mov	 ecx, DWORD PTR _DriverObject$[ebp]
  00241	89 8e a8 04 00
	00		 mov	 DWORD PTR [esi+1192], ecx
  00247	8b 4d fc	 mov	 ecx, DWORD PTR _deviceObject$[ebp]
  0024a	89 08		 mov	 DWORD PTR [eax], ecx
  0024c	89 9e a4 04 00
	00		 mov	 DWORD PTR [esi+1188], ebx
  00252	a1 18 00 00 00	 mov	 eax, DWORD PTR _driverDefaults+24
  00257	83 a6 3c 05 00
	00 00		 and	 DWORD PTR [esi+1340], 0
  0025e	89 86 50 01 00
	00		 mov	 DWORD PTR [esi+336], eax
  00264	8d 46 10	 lea	 eax, DWORD PTR [esi+16]
  00267	89 46 14	 mov	 DWORD PTR [esi+20], eax
  0026a	88 9e e1 01 00
	00		 mov	 BYTE PTR [esi+481], bl
  00270	89 00		 mov	 DWORD PTR [eax], eax
  00272	8d 46 08	 lea	 eax, DWORD PTR [esi+8]
  00275	89 46 0c	 mov	 DWORD PTR [esi+12], eax
  00278	88 9e 74 05 00
	00		 mov	 BYTE PTR [esi+1396], bl
  0027e	89 00		 mov	 DWORD PTR [eax], eax
  00280	8d 46 18	 lea	 eax, DWORD PTR [esi+24]
  00283	89 46 1c	 mov	 DWORD PTR [esi+28], eax
  00286	89 9e 34 05 00
	00		 mov	 DWORD PTR [esi+1332], ebx
  0028c	89 00		 mov	 DWORD PTR [eax], eax
  0028e	8d 46 20	 lea	 eax, DWORD PTR [esi+32]
  00291	89 46 24	 mov	 DWORD PTR [esi+36], eax
  00294	89 00		 mov	 DWORD PTR [eax], eax
  00296	8d 86 a4 00 00
	00		 lea	 eax, DWORD PTR [esi+164]
  0029c	89 86 a8 00 00
	00		 mov	 DWORD PTR [esi+168], eax
  002a2	89 00		 mov	 DWORD PTR [eax], eax
  002a4	8d 86 ac 00 00
	00		 lea	 eax, DWORD PTR [esi+172]
  002aa	89 86 b0 00 00
	00		 mov	 DWORD PTR [esi+176], eax
  002b0	89 00		 mov	 DWORD PTR [eax], eax
  002b2	8d 86 b4 00 00
	00		 lea	 eax, DWORD PTR [esi+180]
  002b8	89 86 b8 00 00
	00		 mov	 DWORD PTR [esi+184], eax
  002be	89 00		 mov	 DWORD PTR [eax], eax
  002c0	8d 86 bc 00 00
	00		 lea	 eax, DWORD PTR [esi+188]
  002c6	89 86 c0 00 00
	00		 mov	 DWORD PTR [esi+192], eax
  002cc	89 00		 mov	 DWORD PTR [eax], eax
  002ce	8d 86 2c 05 00
	00		 lea	 eax, DWORD PTR [esi+1324]
  002d4	89 86 30 05 00
	00		 mov	 DWORD PTR [esi+1328], eax
  002da	89 00		 mov	 DWORD PTR [eax], eax
  002dc	8d 86 40 05 00
	00		 lea	 eax, DWORD PTR [esi+1344]
  002e2	50		 push	 eax
  002e3	ff d7		 call	 edi

; 294  :    ExInitializeFastMutex(&pDevExt->CloseMutex);

  002e5	83 a6 5c 05 00
	00 00		 and	 DWORD PTR [esi+1372], 0
  002ec	6a 00		 push	 0
  002ee	8d 86 60 05 00
	00		 lea	 eax, DWORD PTR [esi+1376]
  002f4	53		 push	 ebx
  002f5	50		 push	 eax
  002f6	89 9e 54 05 00
	00		 mov	 DWORD PTR [esi+1364], ebx
  002fc	ff d7		 call	 edi

; 295  : 
; 296  :    KeInitializeEvent(&pDevExt->PendingIRPEvent, SynchronizationEvent, FALSE);

  002fe	6a 00		 push	 0
  00300	8d 86 d0 04 00
	00		 lea	 eax, DWORD PTR [esi+1232]
  00306	53		 push	 ebx
  00307	50		 push	 eax
  00308	ff d7		 call	 edi

; 297  :    KeInitializeEvent(&pDevExt->PendingDpcEvent, SynchronizationEvent, FALSE);

  0030a	6a 00		 push	 0
  0030c	8d 86 34 06 00
	00		 lea	 eax, DWORD PTR [esi+1588]
  00312	53		 push	 ebx
  00313	50		 push	 eax
  00314	ff d7		 call	 edi

; 298  :    KeInitializeEvent(&pDevExt->PowerD0Event, SynchronizationEvent, FALSE);

  00316	6a 00		 push	 0
  00318	81 c6 1c 05 00
	00		 add	 esi, 1308		; 0000051cH
  0031e	53		 push	 ebx
  0031f	56		 push	 esi
  00320	ff d7		 call	 edi

; 299  : 
; 300  : 
; 301  :    deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

  00322	8b 45 fc	 mov	 eax, DWORD PTR _deviceObject$[ebp]
  00325	80 60 1c 7f	 and	 BYTE PTR [eax+28], 127	; 0000007fH

; 302  : 
; 303  :    *NewDeviceObject = deviceObject;

  00329	8b 45 0c	 mov	 eax, DWORD PTR _NewDeviceObject$[ebp]
  0032c	8b 4d fc	 mov	 ecx, DWORD PTR _deviceObject$[ebp]

; 304  : 
; 305  :    ExFreePool(deviceObjName.Buffer);

  0032f	ff 75 f4	 push	 DWORD PTR _deviceObjName$[ebp+4]
  00332	89 08		 mov	 DWORD PTR [eax], ecx
  00334	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExFreePool@4

; 306  : 
; 307  :    SerialDump (SERTRACECALLS,("SERIAL: Leave SerialCreateDevObj\n") );
; 308  :    return STATUS_SUCCESS;

  0033a	33 c0		 xor	 eax, eax
$L14782:
  0033c	5f		 pop	 edi
  0033d	5e		 pop	 esi
  0033e	5b		 pop	 ebx

; 340  : }

  0033f	c9		 leave
  00340	c2 08 00	 ret	 8
_SerialCreateDevObj@8 ENDP
PAGESRP0	ENDS
PUBLIC	_SerialAddDevice@8
EXTRN	__imp__IoAttachDeviceToDeviceStack@8:NEAR
; Function compile flags: /Ogsy
;	COMDAT _SerialAddDevice@8
PAGESRP0	SEGMENT
_DriverObject$ = 8
_PPdo$ = 12
_pNewDevObj$ = -4
_SerialAddDevice@8 PROC NEAR				; COMDAT

; 366  : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	51		 push	 ecx

; 367  :    PDEVICE_OBJECT pNewDevObj = NULL;

  00004	83 65 fc 00	 and	 DWORD PTR _pNewDevObj$[ebp], 0
  00008	53		 push	 ebx
  00009	57		 push	 edi

⌨️ 快捷键说明

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