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

📄 pnp.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 5 页
字号:
; Listing generated by Microsoft (R) Optimizing Compiler Version 12.00.9044.0 

	TITLE	F:\W2DDK\src\kernel\serial\pnp.c
	.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
_DATA	SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA	ENDS
CONST	SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST	ENDS
_BSS	SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS	ENDS
$$SYMBOLS	SEGMENT BYTE USE32 'DEBSYM'
$$SYMBOLS	ENDS
$$TYPES	SEGMENT BYTE USE32 'DEBTYP'
$$TYPES	ENDS
_TLS	SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS	ENDS
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _RtlConvertLongToLargeInteger@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialSyncCompletion@12
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialCreateDevObj@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialAddDevice@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialPnpDispatch@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialReportMaxBaudRate@4
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialFinishStartDevice@16
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialStartDevice@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialItemCallBack@44
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialControllerCallBack@44
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialGetPortInfo@20
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialDoExternalNaming@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialUndoExternalNaming@4
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _GUID_CLASS_COMPORT
CONST	SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif

INCLUDELIB LIBC
INCLUDELIB OLDNAMES

PUBLIC	_GUID_CLASS_COMPORT
_BSS	SEGMENT
?currentInstance@?1??SerialCreateDevObj@@9@9 DD 01H DUP (?) ; currentInstance
_BSS	ENDS
CONST	SEGMENT
_SerialPhysicalZero DD 00H
	ORG $+4
CONST	ENDS
;	COMDAT _GUID_CLASS_COMPORT
CONST	SEGMENT
_GUID_CLASS_COMPORT DD 086e0d1e0H
	DW	08089H
	DW	011d0H
	DB	09cH
	DB	0e4H
	DB	08H
	DB	00H
	DB	03eH
	DB	030H
	DB	01fH
	DB	073H
CONST	ENDS
PUBLIC	_SerialSyncCompletion@12
EXTRN	__imp__KeSetEvent@12:NEAR
; Function compile flags: /Ogsy
; File f:\w2ddk\src\kernel\serial\pnp.c
;	COMDAT _SerialSyncCompletion@12
_TEXT	SEGMENT
_SerialSyncEvent$ = 16
_SerialSyncCompletion@12 PROC NEAR			; COMDAT

; 88   :    KeSetEvent(SerialSyncEvent, IO_NO_INCREMENT, FALSE);

  00000	6a 00		 push	 0
  00002	6a 00		 push	 0
  00004	ff 74 24 14	 push	 DWORD PTR _SerialSyncEvent$[esp+4]
  00008	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeSetEvent@12

; 89   :    return STATUS_MORE_PROCESSING_REQUIRED;

  0000e	b8 16 00 00 c0	 mov	 eax, -1073741802	; c0000016H

; 90   : }

  00013	c2 0c 00	 ret	 12			; 0000000cH
_SerialSyncCompletion@12 ENDP
_TEXT	ENDS
PUBLIC	_SerialCreateDevObj@8
EXTRN	__imp__KeInitializeEvent@12:NEAR
EXTRN	_SerialLogError@64:NEAR
EXTRN	__imp__RtlIntegerToUnicodeString@12:NEAR
EXTRN	__imp__RtlInitUnicodeString@8:NEAR
EXTRN	__imp__ExAllocatePoolWithTag@12:NEAR
EXTRN	__imp__ExFreePool@4:NEAR
EXTRN	__imp__RtlAppendUnicodeStringToString@8:NEAR
EXTRN	__imp__RtlAppendUnicodeToString@8:NEAR
EXTRN	_driverDefaults:BYTE
EXTRN	__imp__IoCreateDevice@28:NEAR
EXTRN	__imp__IoDeleteDevice@4:NEAR
;	COMDAT _SerialCreateDevObj@8
PAGESRP0	SEGMENT
$SG14811 DB	'\', 00H, 'D', 00H, 'e', 00H, 'v', 00H, 'i', 00H, 'c', 00H
	DB	'e', 00H, '\', 00H, 'S', 00H, 'e', 00H, 'r', 00H, 'i', 00H, 'a'
	DB	00H, 'l', 00H, 00H, 00H
; Function compile flags: /Ogsy
_DriverObject$ = 8
_NewDeviceObject$ = 12
_deviceObjName$ = -16
_deviceObject$ = -4
_pDevExt$ = 8
_status$ = -8
_instanceStr$ = -24
_instanceNumberBuffer$ = -64
_SerialCreateDevObj@8 PROC NEAR				; COMDAT

; 116  : {

  0001e	55		 push	 ebp
  0001f	8b ec		 mov	 ebp, esp
  00021	83 ec 40	 sub	 esp, 64			; 00000040H
  00024	53		 push	 ebx
  00025	56		 push	 esi
  00026	57		 push	 edi

; 117  :    UNICODE_STRING deviceObjName;
; 118  :    PDEVICE_OBJECT deviceObject = NULL;
; 119  :    PSERIAL_DEVICE_EXTENSION pDevExt;
; 120  :    NTSTATUS status = STATUS_SUCCESS;
; 121  :    static ULONG currentInstance = 0;
; 122  :    UNICODE_STRING instanceStr;
; 123  :    WCHAR instanceNumberBuffer[20];
; 124  : 
; 125  : 
; 126  :    PAGED_CODE();
; 127  : 
; 128  :    SerialDump (SERTRACECALLS,("SERIAL: Enter SerialCreateDevObj\n"));
; 129  : 
; 130  :    //
; 131  :    // Zero out allocated memory pointers so we know if they must be freed
; 132  :    //
; 133  : 
; 134  :    RtlZeroMemory(&deviceObjName, sizeof(UNICODE_STRING));

  00027	33 c0		 xor	 eax, eax
  00029	8d 7d f0	 lea	 edi, DWORD PTR _deviceObjName$[ebp]

; 135  : 
; 136  :    deviceObjName.MaximumLength = DEVICE_OBJECT_NAME_LENGTH * sizeof(WCHAR);
; 137  :    deviceObjName.Buffer = ExAllocatePool(PagedPool, deviceObjName.MaximumLength
; 138  :                                      + sizeof(WCHAR));

  0002c	33 db		 xor	 ebx, ebx
  0002e	ab		 stosd
  0002f	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  00034	43		 inc	 ebx
  00035	33 f6		 xor	 esi, esi
  00037	68 02 01 00 00	 push	 258			; 00000102H
  0003c	ab		 stosd
  0003d	53		 push	 ebx
  0003e	89 75 fc	 mov	 DWORD PTR _deviceObject$[ebp], esi
  00041	66 c7 45 f2 00
	01		 mov	 WORD PTR _deviceObjName$[ebp+2], 256 ; 00000100H
  00047	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12
  0004d	8b f8		 mov	 edi, eax

; 139  : 
; 140  : 
; 141  :    if (deviceObjName.Buffer == NULL) {

  0004f	3b fe		 cmp	 edi, esi
  00051	89 7d f4	 mov	 DWORD PTR _deviceObjName$[ebp+4], edi
  00054	75 31		 jne	 SHORT $L14800

; 142  :       SerialLogError(DriverObject, NULL, SerialPhysicalZero, SerialPhysicalZero,
; 143  :                      0, 0, 0, 19, STATUS_SUCCESS, SERIAL_INSUFFICIENT_RESOURCES,
; 144  :                      0, NULL, 0, NULL);

  00056	56		 push	 esi
  00057	a1 04 00 00 00	 mov	 eax, DWORD PTR _SerialPhysicalZero+4
  0005c	56		 push	 esi
  0005d	8b 0d 00 00 00
	00		 mov	 ecx, DWORD PTR _SerialPhysicalZero
  00063	56		 push	 esi
  00064	56		 push	 esi
  00065	68 08 00 06 c0	 push	 -1073348600		; c0060008H
  0006a	56		 push	 esi
  0006b	6a 13		 push	 19			; 00000013H
  0006d	56		 push	 esi
  0006e	56		 push	 esi
  0006f	56		 push	 esi
  00070	50		 push	 eax
  00071	51		 push	 ecx
  00072	50		 push	 eax
  00073	51		 push	 ecx
  00074	56		 push	 esi
  00075	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  00078	e8 00 00 00 00	 call	 _SerialLogError@64

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

  0007d	b8 9a 00 00 c0	 mov	 eax, -1073741670	; c000009aH
  00082	e9 b5 02 00 00	 jmp	 $L14782
$L14800:

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

  00087	0f b7 4d f2	 movzx	 ecx, WORD PTR _deviceObjName$[ebp+2]
  0008b	41		 inc	 ecx
  0008c	33 c0		 xor	 eax, eax
  0008e	41		 inc	 ecx

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

  0008f	68 00 00 00 00	 push	 OFFSET FLAT:$SG14811
  00094	8b d1		 mov	 edx, ecx
  00096	c1 e9 02	 shr	 ecx, 2
  00099	f3 ab		 rep stosd
  0009b	8b ca		 mov	 ecx, edx
  0009d	83 e1 03	 and	 ecx, 3
  000a0	f3 aa		 rep stosb
  000a2	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  000a5	50		 push	 eax
  000a6	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAppendUnicodeToString@8

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

  000ac	8d 45 e8	 lea	 eax, DWORD PTR _instanceStr$[ebp]
  000af	56		 push	 esi
  000b0	50		 push	 eax
  000b1	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlInitUnicodeString@8

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

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

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

  000ba	8d 4d e8	 lea	 ecx, DWORD PTR _instanceStr$[ebp]
  000bd	89 45 ec	 mov	 DWORD PTR _instanceStr$[ebp+4], eax
  000c0	a1 00 00 00 00	 mov	 eax, DWORD PTR ?currentInstance@?1??SerialCreateDevObj@@9@9
  000c5	ff 05 00 00 00
	00		 inc	 DWORD PTR ?currentInstance@?1??SerialCreateDevObj@@9@9
  000cb	51		 push	 ecx
  000cc	6a 0a		 push	 10			; 0000000aH
  000ce	50		 push	 eax
  000cf	66 c7 45 ea 28
	00		 mov	 WORD PTR _instanceStr$[ebp+2], 40 ; 00000028H
  000d5	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlIntegerToUnicodeString@12

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

  000db	8d 45 e8	 lea	 eax, DWORD PTR _instanceStr$[ebp]
  000de	50		 push	 eax
  000df	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  000e2	50		 push	 eax
  000e3	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);

  000e9	8d 45 fc	 lea	 eax, DWORD PTR _deviceObject$[ebp]
  000ec	50		 push	 eax
  000ed	53		 push	 ebx
  000ee	68 00 01 00 00	 push	 256			; 00000100H
  000f3	8d 45 f0	 lea	 eax, DWORD PTR _deviceObjName$[ebp]
  000f6	6a 1b		 push	 27			; 0000001bH
  000f8	50		 push	 eax
  000f9	68 48 06 00 00	 push	 1608			; 00000648H
  000fe	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  00101	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoCreateDevice@28

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

  00107	3b c6		 cmp	 eax, esi
  00109	89 45 f8	 mov	 DWORD PTR _status$[ebp], eax
  0010c	0f 8c bb 00 00
	00		 jl	 $L16127

; 178  :       SerialDump(SERERRORS, ("SerialAddDevice: Create device failed - %x \n",
; 179  :                              status));
; 180  :       goto SerialCreateDevObjError;
; 181  :    }
; 182  : 
; 183  :    ASSERT(deviceObject != NULL);
; 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;

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

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

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

  0011a	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  0011f	8b 70 28	 mov	 esi, DWORD PTR [eax+40]
  00122	33 c0		 xor	 eax, eax
  00124	8b fe		 mov	 edi, esi
  00126	f3 ab		 rep stosd
  00128	89 9e c8 04 00
	00		 mov	 DWORD PTR [esi+1224], ebx
  0012e	89 9e 30 06 00
	00		 mov	 DWORD PTR [esi+1584], ebx
  00134	0f b7 45 f0	 movzx	 eax, WORD PTR _deviceObjName$[ebp]
  00138	40		 inc	 eax
  00139	40		 inc	 eax
  0013a	50		 push	 eax
  0013b	53		 push	 ebx
  0013c	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12
  00142	8b d0		 mov	 edx, eax

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

  00144	33 ff		 xor	 edi, edi
  00146	3b d7		 cmp	 edx, edi
  00148	89 56 64	 mov	 DWORD PTR [esi+100], edx
  0014b	75 30		 jne	 SHORT $L14822

; 216  : 
; 217  :       SerialLogError(
; 218  :                     DriverObject,
; 219  :                     NULL,
; 220  :                     SerialPhysicalZero,
; 221  :                     SerialPhysicalZero,

⌨️ 快捷键说明

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