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

📄 pnp.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 5 页
字号:
  002ad	50		 push	 eax
  002ae	51		 push	 ecx
  002af	50		 push	 eax
  002b0	51		 push	 ecx
  002b1	56		 push	 esi
  002b2	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  002b5	e8 00 00 00 00	 call	 _SerialLogError@64

; 145  :       SerialDump(SERERRORS, ("SERIAL: Couldn't allocate memory for device name"
; 146  :                              "\n"));

  002ba	f6 05 03 00 00
	00 40		 test	 BYTE PTR _SerialDebugLevel+3, 64 ; 00000040H
  002c1	74 0b		 je	 SHORT $L14877
  002c3	68 00 00 00 00	 push	 OFFSET FLAT:$SG14882
  002c8	e8 00 00 00 00	 call	 _DbgPrint
  002cd	59		 pop	 ecx
$L14877:

; 147  : 
; 148  :       return STATUS_INSUFFICIENT_RESOURCES;

  002ce	b8 9a 00 00 c0	 mov	 eax, -1073741670	; c000009aH
  002d3	e9 67 03 00 00	 jmp	 $L14836
$L14870:

; 149  : 
; 150  :    }
; 151  : 
; 152  :    RtlZeroMemory(deviceObjName.Buffer, deviceObjName.MaximumLength
; 153  :                  + sizeof(WCHAR));

  002d8	0f b7 4d f2	 movzx	 ecx, WORD PTR _deviceObjName$[ebp+2]
  002dc	41		 inc	 ecx
  002dd	33 c0		 xor	 eax, eax
  002df	41		 inc	 ecx

; 154  : 
; 155  : 
; 156  :    RtlAppendUnicodeToString(&deviceObjName, L"\\Device\\Serial");

  002e0	68 00 00 00 00	 push	 OFFSET FLAT:$SG14891
  002e5	8b d1		 mov	 edx, ecx
  002e7	c1 e9 02	 shr	 ecx, 2
  002ea	f3 ab		 rep stosd
  002ec	8b ca		 mov	 ecx, edx
  002ee	83 e1 03	 and	 ecx, 3
  002f1	f3 aa		 rep stosb
  002f3	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  002f6	50		 push	 eax
  002f7	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAppendUnicodeToString@8

; 157  : 
; 158  :    RtlInitUnicodeString(&instanceStr, NULL);

  002fd	8d 45 e8	 lea	 eax, DWORD PTR _instanceStr$[ebp]
  00300	56		 push	 esi
  00301	50		 push	 eax
  00302	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlInitUnicodeString@8

; 159  : 
; 160  :    instanceStr.MaximumLength = sizeof(instanceNumberBuffer);
; 161  :    instanceStr.Buffer = instanceNumberBuffer;

  00308	8d 45 c0	 lea	 eax, DWORD PTR _instanceNumberBuffer$[ebp]

; 162  : 
; 163  :    RtlIntegerToUnicodeString(currentInstance++, 10, &instanceStr);

  0030b	8d 4d e8	 lea	 ecx, DWORD PTR _instanceStr$[ebp]
  0030e	89 45 ec	 mov	 DWORD PTR _instanceStr$[ebp+4], eax
  00311	a1 00 00 00 00	 mov	 eax, DWORD PTR ?currentInstance@?1??SerialCreateDevObj@@9@9
  00316	ff 05 00 00 00
	00		 inc	 DWORD PTR ?currentInstance@?1??SerialCreateDevObj@@9@9
  0031c	51		 push	 ecx
  0031d	6a 0a		 push	 10			; 0000000aH
  0031f	50		 push	 eax
  00320	66 c7 45 ea 28
	00		 mov	 WORD PTR _instanceStr$[ebp+2], 40 ; 00000028H
  00326	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlIntegerToUnicodeString@12

; 164  : 
; 165  :    RtlAppendUnicodeStringToString(&deviceObjName, &instanceStr);

  0032c	8d 45 e8	 lea	 eax, DWORD PTR _instanceStr$[ebp]
  0032f	50		 push	 eax
  00330	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  00333	50		 push	 eax
  00334	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAppendUnicodeStringToString@8

; 166  : 
; 167  : 
; 168  :    //
; 169  :    // Create the device object
; 170  :    //
; 171  : 
; 172  :    status = IoCreateDevice(DriverObject, sizeof(SERIAL_DEVICE_EXTENSION),
; 173  :                            &deviceObjName, FILE_DEVICE_SERIAL_PORT,
; 174  :                            FILE_DEVICE_SECURE_OPEN, TRUE, &deviceObject);

  0033a	8d 45 fc	 lea	 eax, DWORD PTR _deviceObject$[ebp]
  0033d	50		 push	 eax
  0033e	53		 push	 ebx
  0033f	68 00 01 00 00	 push	 256			; 00000100H
  00344	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  00347	6a 1b		 push	 27			; 0000001bH
  00349	50		 push	 eax
  0034a	68 48 06 00 00	 push	 1608			; 00000648H
  0034f	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  00352	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoCreateDevice@28

; 175  : 
; 176  : 
; 177  :    if (!NT_SUCCESS(status)) {

  00358	3b c6		 cmp	 eax, esi
  0035a	89 45 f8	 mov	 DWORD PTR _status$[ebp], eax
  0035d	0f 8d 85 00 00
	00		 jge	 $L14895

; 178  :       SerialDump(SERERRORS, ("SerialAddDevice: Create device failed - %x \n",
; 179  :                              status));

  00363	bb 00 00 00 40	 mov	 ebx, 1073741824		; 40000000H
  00368	85 1d 00 00 00
	00		 test	 DWORD PTR _SerialDebugLevel, ebx
  0036e	74 0d		 je	 SHORT $L17395
  00370	50		 push	 eax
  00371	68 00 00 00 00	 push	 OFFSET FLAT:$SG14902
  00376	e8 00 00 00 00	 call	 _DbgPrint
  0037b	59		 pop	 ecx
  0037c	59		 pop	 ecx
$L17395:

; 180  :       goto SerialCreateDevObjError;

  0037d	8b 75 08	 mov	 esi, DWORD PTR _pDevExt$[ebp]
$L17396:
  00380	33 ff		 xor	 edi, edi
$SerialCreateDevObjError$14909:

; 309  : 
; 310  : 
; 311  :    SerialCreateDevObjError:
; 312  : 
; 313  :    SerialDump (SERERRORS,("SERIAL: SerialCreateDevObj Error, Cleaning up\n") );

  00382	85 1d 00 00 00
	00		 test	 DWORD PTR _SerialDebugLevel, ebx
  00388	74 0b		 je	 SHORT $L14971
  0038a	68 00 00 00 00	 push	 OFFSET FLAT:$SG14976
  0038f	e8 00 00 00 00	 call	 _DbgPrint
  00394	59		 pop	 ecx
$L14971:

; 314  : 
; 315  :    //
; 316  :    // Free the allocated strings for the NT and symbolic names if they exist.
; 317  :    //
; 318  : 
; 319  :    if (deviceObjName.Buffer != NULL) {

  00395	39 7d f4	 cmp	 DWORD PTR _deviceObjName$[ebp+4], edi
  00398	8b 1d 00 00 00
	00		 mov	 ebx, DWORD PTR __imp__ExFreePool@4
  0039e	74 05		 je	 SHORT $L14984

; 320  :       ExFreePool(deviceObjName.Buffer);

  003a0	ff 75 f4	 push	 DWORD PTR _deviceObjName$[ebp+4]
  003a3	ff d3		 call	 ebx
$L14984:

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

  003a5	39 7d fc	 cmp	 DWORD PTR _deviceObject$[ebp], edi
  003a8	74 1d		 je	 SHORT $L14985

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

  003aa	8b 46 74	 mov	 eax, DWORD PTR [esi+116]
  003ad	3b c7		 cmp	 eax, edi
  003af	74 03		 je	 SHORT $L14987

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

  003b1	50		 push	 eax
  003b2	ff d3		 call	 ebx
$L14987:

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

  003b4	8b 76 64	 mov	 esi, DWORD PTR [esi+100]
  003b7	3b f7		 cmp	 esi, edi
  003b9	74 03		 je	 SHORT $L14989

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

  003bb	56		 push	 esi
  003bc	ff d3		 call	 ebx
$L14989:

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

  003be	ff 75 fc	 push	 DWORD PTR _deviceObject$[ebp]
  003c1	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoDeleteDevice@4
$L14985:

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

  003c7	8b 45 0c	 mov	 eax, DWORD PTR _NewDeviceObject$[ebp]
  003ca	89 38		 mov	 DWORD PTR [eax], edi

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

  003cc	f6 05 00 00 00
	00 40		 test	 BYTE PTR _SerialDebugLevel, 64 ; 00000040H
  003d3	74 0b		 je	 SHORT $L14992
  003d5	68 00 00 00 00	 push	 OFFSET FLAT:$SG14997
  003da	e8 00 00 00 00	 call	 _DbgPrint
  003df	59		 pop	 ecx
$L14992:

; 339  :    return status;

  003e0	8b 45 f8	 mov	 eax, DWORD PTR _status$[ebp]
  003e3	e9 57 02 00 00	 jmp	 $L14836
$L14895:

; 181  :    }
; 182  : 
; 183  :    ASSERT(deviceObject != NULL);

  003e8	39 75 fc	 cmp	 DWORD PTR _deviceObject$[ebp], esi
  003eb	75 16		 jne	 SHORT $L14911
  003ed	56		 push	 esi
  003ee	68 b7 00 00 00	 push	 183			; 000000b7H
  003f3	68 00 00 00 00	 push	 OFFSET FLAT:$SG14913
  003f8	68 00 00 00 00	 push	 OFFSET FLAT:$SG14914
  003fd	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
$L14911:

; 184  : 
; 185  : 
; 186  :    //
; 187  :    // The device object has a pointer to an area of non-paged
; 188  :    // pool allocated for this device.  This will be the device
; 189  :    // extension. Zero it out.
; 190  :    //
; 191  : 
; 192  :    pDevExt = deviceObject->DeviceExtension;

  00403	8b 45 fc	 mov	 eax, DWORD PTR _deviceObject$[ebp]

; 193  :    RtlZeroMemory(pDevExt, sizeof(SERIAL_DEVICE_EXTENSION));

  00406	b9 92 01 00 00	 mov	 ecx, 402		; 00000192H

; 194  : 
; 195  :    //
; 196  :    // Initialize the count of IRP's pending
; 197  :    //
; 198  : 
; 199  :    pDevExt->PendingIRPCnt = 1;
; 200  : 
; 201  : 
; 202  :    //
; 203  :    // Initialize the count of DPC's pending
; 204  :    //
; 205  : 
; 206  :    pDevExt->DpcCount = 1;
; 207  : 
; 208  :    //
; 209  :    // Allocate Pool and save the nt device name in the device extension.
; 210  :    //
; 211  : 
; 212  :    pDevExt->DeviceName.Buffer =
; 213  :       ExAllocatePool(PagedPool, deviceObjName.Length + sizeof(WCHAR));

  0040b	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  00410	8b 70 28	 mov	 esi, DWORD PTR [eax+40]
  00413	33 c0		 xor	 eax, eax
  00415	8b fe		 mov	 edi, esi
  00417	f3 ab		 rep stosd
  00419	89 9e c8 04 00
	00		 mov	 DWORD PTR [esi+1224], ebx
  0041f	89 9e 30 06 00
	00		 mov	 DWORD PTR [esi+1584], ebx
  00425	0f b7 45 f0	 movzx	 eax, WORD PTR _deviceObjName$[ebp]
  00429	40		 inc	 eax
  0042a	40		 inc	 eax
  0042b	50		 push	 eax
  0042c	53		 push	 ebx
  0042d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12
  00433	8b d0		 mov	 edx, eax

; 214  : 
; 215  :    if (!pDevExt->DeviceName.Buffer) {

  00435	33 ff		 xor	 edi, edi
  00437	3b d7		 cmp	 edx, edi
  00439	89 56 64	 mov	 DWORD PTR [esi+100], edx
  0043c	75 4b		 jne	 SHORT $L14917

; 216  : 
; 217  :       SerialLogError(
; 218  :                     DriverObject,
; 219  :                     NULL,
; 220  :                     SerialPhysicalZero,
; 221  :                     SerialPhysicalZero,
; 222  :                     0,
; 223  :                     0,
; 224  :                     0,
; 225  :                     19,
; 226  :                     STATUS_SUCCESS,
; 227  :                     SERIAL_INSUFFICIENT_RESOURCES,
; 228  :                     0,
; 229  :                     NULL,
; 230  :                     0,
; 231  :                     NULL
; 232  :                     );

  0043e	57		 push	 edi
  0043f	a1 04 00 00 00	 mov	 eax, DWORD PTR _SerialPhysicalZero+4
  00444	57		 push	 edi
  00445	8b 0d 00 00 00
	00		 mov	 ecx, DWORD PTR _SerialPhysicalZero
  0044b	57		 push	 edi
  0044c	57		 push	 edi
  0044d	68 08 00 06 c0	 push	 -1073348600		; c0060008H
  00452	57		 push	 edi
  00453	6a 13		 push	 19			; 00000013H
  00455	57		 push	 edi
  00456	57		 push	 edi
  00457	57		 push	 edi
  00458	50		 push	 eax
  00459	51		 push	 ecx
  0045a	50		 push	 eax
  0045b	51		 push	 ecx
  0045c	57		 push	 edi
  0045d	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  00460	e8 00 00 00 00	 call	 _SerialLogError@64

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

  00465	bb 00 00 00 40	 mov	 ebx, 1073741824		; 40000000H
  0046a	85 1d 00 00 00
	00		 test	 DWORD PTR _SerialDebugLevel, ebx
  00470	74 0b		 je	 SHORT $L14924
  00472	68 00 00 00 00	 push	 OFFSET FLAT:$SG14929
  00477	e8 00 00 00 00	 call	 _DbgPrint
  0047c	59		 pop	 ecx
$L14924:

; 236  : 
; 237  :       status = STATUS_INSUFFICIENT_RESOURCES;

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

; 238  :       goto SerialCreateDevObjError;

  00484	e9 f9 fe ff ff	 jmp	 $SerialCreateDevObjError$14909
$L14917:

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

  00489	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);

  0048c	8b fa		 mov	 edi, edx
  0048e	83 c0 02	 add	 eax, 2
  00491	0f b7 c8	 movzx	 ecx, ax
  00494	8b d1		 mov	 edx, ecx
  00496	66 89 46 62	 mov	 WORD PTR [esi+98], ax
  0049a	33 c0		 xor	 eax, eax
  0049c	c1 e9 02	 shr	 ecx, 2
  0049f	f3 ab		 rep stosd
  004a1	8b ca		 mov	 ecx, edx
  004a3	83 e1 03	 and	 ecx, 3
  004a6	f3 aa		 rep stosb

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

  004a8	8b 3d 00 00 00
	00		 mov	 edi, DWORD PTR __imp__RtlAppendUnicodeStringToString@8
  004ae	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  004b1	50		 push	 eax
  004b2	8d 46 60	 lea	 eax, DWORD PTR [esi+96]
  004b5	50		 push	 eax
  004b6	ff d7		 call	 edi

⌨️ 快捷键说明

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