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

📄 initunlo.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\initunlo.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
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _RtlConvertLongToLargeInteger@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _DriverEntry@8
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _SerialCleanLists@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialReleaseResources@4
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialPrepareRemove@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialDisableInterfacesResources@8
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialRemoveDevObj@4
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialKillPendingIrps@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialSingleToMulti@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialAddToMulti@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialInitMultiPort@12
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialInitController@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialInitOneController@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialDoesPortExist@16
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialReset@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialGetDivisorFromBaud@12
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialUnload@4
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialGetMappedAddress@28
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialMemCompare@24
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialBecomeSharer@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialFindInitController@8
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif

INCLUDELIB LIBC
INCLUDELIB OLDNAMES

_DATA	SEGMENT
COMM	_driverDefaults:BYTE:04cH
COMM	_SerialGlobals:BYTE:014H
_DATA	ENDS
CONST	SEGMENT
_SerialPhysicalZero DD 00H
	ORG $+4
CONST	ENDS
PUBLIC	_DriverEntry@8
PUBLIC	_SerialUnload@4
PUBLIC	_SerialReset@4
EXTRN	__imp__MmLockPagableDataSection@4:NEAR
EXTRN	__imp__MmUnlockPagableImageSection@4:NEAR
EXTRN	_SerialAddDevice@8:NEAR
EXTRN	__imp__memmove:NEAR
EXTRN	__imp__RtlQueryRegistryValues@20:NEAR
EXTRN	_SerialSystemControlDispatch@8:NEAR
EXTRN	__imp__RtlInitUnicodeString@8:NEAR
EXTRN	_SerialInternalIoControl@8:NEAR
EXTRN	__imp__ExAllocatePoolWithTag@12:NEAR
EXTRN	__imp__RtlEqualUnicodeString@12:NEAR
EXTRN	__imp__ExFreePool@4:NEAR
EXTRN	_DbgBreakPoint@0:NEAR
EXTRN	_SerialRead@8:NEAR
EXTRN	_SerialFlush@8:NEAR
EXTRN	_SerialWrite@8:NEAR
EXTRN	_SerialCleanup@8:NEAR
EXTRN	_SerialCreateOpen@8:NEAR
EXTRN	_SerialClose@8:NEAR
EXTRN	_SerialIoControl@8:NEAR
EXTRN	_SerialQueryInformationFile@8:NEAR
EXTRN	_SerialSetInformationFile@8:NEAR
EXTRN	_SerialPnpDispatch@8:NEAR
EXTRN	_SerialPowerDispatch@8:NEAR
EXTRN	_SerialGetConfigDefaults@8:NEAR
EXTRN	_SerialEnumerateLegacy@12:NEAR
;	COMDAT _DriverEntry@8
; File f:\w2ddk\src\kernel\serial\initunlo.c
INIT	SEGMENT
$SG14789 DB	'J', 00H, 'e', 00H, 'n', 00H, 's', 00H, 'e', 00H, 'n', 00H
	DB	00H, 00H
	ORG $+2
$SG14795 DB	'\', 00H, 'R', 00H, 'E', 00H, 'G', 00H, 'I', 00H, 'S', 00H
	DB	'T', 00H, 'R', 00H, 'Y', 00H, '\', 00H, 'M', 00H, 'A', 00H, 'C'
	DB	00H, 'H', 00H, 'I', 00H, 'N', 00H, 'E', 00H, '\', 00H, 'H', 00H
	DB	'A', 00H, 'R', 00H, 'D', 00H, 'W', 00H, 'A', 00H, 'R', 00H, 'E'
	DB	00H, '\', 00H, 'D', 00H, 'E', 00H, 'S', 00H, 'C', 00H, 'R', 00H
	DB	'I', 00H, 'P', 00H, 'T', 00H, 'I', 00H, 'O', 00H, 'N', 00H, '\'
	DB	00H, 'S', 00H, 'Y', 00H, 'S', 00H, 'T', 00H, 'E', 00H, 'M', 00H
	DB	00H, 00H
$SG14790 DB	'I', 00H, 'd', 00H, 'e', 00H, 'n', 00H, 't', 00H, 'i', 00H
	DB	'f', 00H, 'i', 00H, 'e', 00H, 'r', 00H, 00H, 00H
; Function compile flags: /Ogsy
_DriverObject$ = 8
_RegistryPath$ = 12
_jensenTable$ = -76
_jensenData$ = -12
_jensenValue$ = -20
_jensenDetected$ = 15
_jensenBuffer$ = 8
_lockPtr$ = -4
_DriverEntry@8 PROC NEAR				; COMDAT

; 130  : {

  00082	55		 push	 ebp
  00083	8b ec		 mov	 ebp, esp
  00085	83 ec 4c	 sub	 esp, 76			; 0000004cH

; 131  :    RTL_QUERY_REGISTRY_TABLE jensenTable[2] = {0};

  00088	83 65 b4 00	 and	 DWORD PTR _jensenTable$[ebp], 0
  0008c	53		 push	 ebx
  0008d	56		 push	 esi
  0008e	57		 push	 edi
  0008f	6a 0d		 push	 13			; 0000000dH
  00091	33 c0		 xor	 eax, eax
  00093	59		 pop	 ecx
  00094	8d 7d b8	 lea	 edi, DWORD PTR _jensenTable$[ebp+4]
  00097	f3 ab		 rep stosd

; 132  :    UNICODE_STRING jensenData;
; 133  :    UNICODE_STRING jensenValue;
; 134  :    BOOLEAN jensenDetected;
; 135  :    PUCHAR jensenBuffer;
; 136  : 
; 137  :    //
; 138  :    // Lock the paged code in their frames
; 139  :    //
; 140  : 
; 141  :    PVOID lockPtr = MmLockPagableCodeSection(SerialReset);

  00099	68 00 00 00 00	 push	 OFFSET FLAT:_SerialReset@4
  0009e	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__MmLockPagableDataSection@4

; 142  : 
; 143  :    PAGED_CODE();
; 144  : 
; 145  : 
; 146  :    ASSERT(SerialGlobals.PAGESER_Handle == NULL);
; 147  : #if DBG
; 148  :    SerialGlobals.PAGESER_Count = 0;
; 149  :    SerialLogInit();
; 150  : #endif
; 151  :    SerialGlobals.PAGESER_Handle = lockPtr;
; 152  : 
; 153  :    SerialGlobals.RegistryPath.MaximumLength = RegistryPath->MaximumLength;

  000a4	8b 5d 0c	 mov	 ebx, DWORD PTR _RegistryPath$[ebp]
  000a7	89 45 fc	 mov	 DWORD PTR _lockPtr$[ebp], eax
  000aa	a3 08 00 00 00	 mov	 DWORD PTR _SerialGlobals+8, eax

; 154  :    SerialGlobals.RegistryPath.Length = RegistryPath->Length;
; 155  :    SerialGlobals.RegistryPath.Buffer
; 156  :       = ExAllocatePool(PagedPool, SerialGlobals.RegistryPath.MaximumLength);

  000af	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  000b4	66 8b 43 02	 mov	 ax, WORD PTR [ebx+2]
  000b8	66 a3 0e 00 00
	00		 mov	 WORD PTR _SerialGlobals+14, ax
  000be	66 8b 0b	 mov	 cx, WORD PTR [ebx]
  000c1	0f b7 c0	 movzx	 eax, ax
  000c4	50		 push	 eax
  000c5	6a 01		 push	 1
  000c7	66 89 0d 0c 00
	00 00		 mov	 WORD PTR _SerialGlobals+12, cx
  000ce	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12
  000d4	8b f8		 mov	 edi, eax

; 157  : 
; 158  :    if (SerialGlobals.RegistryPath.Buffer == NULL) {

  000d6	85 ff		 test	 edi, edi
  000d8	89 3d 10 00 00
	00		 mov	 DWORD PTR _SerialGlobals+16, edi
  000de	75 0a		 jne	 SHORT $L14780
  000e0	be 9a 00 00 c0	 mov	 esi, -1073741670	; c000009aH
  000e5	e9 91 01 00 00	 jmp	 $L15837
$L14780:

; 159  :       MmUnlockPagableImageSection(lockPtr);
; 160  :       return STATUS_INSUFFICIENT_RESOURCES;
; 161  :    }
; 162  : 
; 163  :    RtlZeroMemory(SerialGlobals.RegistryPath.Buffer,
; 164  :                  SerialGlobals.RegistryPath.MaximumLength);

  000ea	0f b7 0d 0e 00
	00 00		 movzx	 ecx, WORD PTR _SerialGlobals+14
  000f1	8b d1		 mov	 edx, ecx
  000f3	33 c0		 xor	 eax, eax
  000f5	c1 e9 02	 shr	 ecx, 2
  000f8	f3 ab		 rep stosd
  000fa	8b ca		 mov	 ecx, edx
  000fc	83 e1 03	 and	 ecx, 3
  000ff	f3 aa		 rep stosb

; 165  :    RtlMoveMemory(SerialGlobals.RegistryPath.Buffer,
; 166  :                  RegistryPath->Buffer, RegistryPath->Length);

  00101	0f b7 03	 movzx	 eax, WORD PTR [ebx]
  00104	50		 push	 eax
  00105	ff 73 04	 push	 DWORD PTR [ebx+4]
  00108	ff 35 10 00 00
	00		 push	 DWORD PTR _SerialGlobals+16
  0010e	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__memmove
  00114	83 c4 0c	 add	 esp, 12			; 0000000cH

; 167  : 
; 168  :    //
; 169  :    // Initialize all our globals
; 170  :    //
; 171  : 
; 172  :    InitializeListHead(&SerialGlobals.AllDevObjs);

  00117	b8 00 00 00 00	 mov	 eax, OFFSET FLAT:_SerialGlobals
  0011c	a3 04 00 00 00	 mov	 DWORD PTR _SerialGlobals+4, eax
  00121	a3 00 00 00 00	 mov	 DWORD PTR _SerialGlobals, eax

; 173  : 
; 174  :    //
; 175  :    // Call to find out default values to use for all the devices that the
; 176  :    // driver controls, including whether or not to break on entry.
; 177  :    //
; 178  : 
; 179  :    SerialGetConfigDefaults(&driverDefaults, RegistryPath);

  00126	53		 push	 ebx
  00127	68 00 00 00 00	 push	 OFFSET FLAT:_driverDefaults
  0012c	e8 00 00 00 00	 call	 _SerialGetConfigDefaults@8

; 180  : 
; 181  : #if DBG
; 182  :    //
; 183  :    // Set global debug output level
; 184  :    //
; 185  :    SerialDebugLevel = driverDefaults.DebugLevel;
; 186  : #endif
; 187  : 
; 188  :    //
; 189  :    // Break on entry if requested via registry
; 190  :    //
; 191  : 
; 192  :    if (driverDefaults.ShouldBreakOnEntry) {

  00131	83 3d 10 00 00
	00 00		 cmp	 DWORD PTR _driverDefaults+16, 0
  00138	74 05		 je	 SHORT $L14783

; 193  :       DbgBreakPoint();

  0013a	e8 00 00 00 00	 call	 _DbgBreakPoint@0
$L14783:

; 194  :    }
; 195  : 
; 196  : 
; 197  :    //
; 198  :    // Just dump out how big the extension is.
; 199  :    //
; 200  : 
; 201  :    SerialDump(SERDIAG1, ("SERIAL: The number of bytes in the extension is: %d"
; 202  :                          "\n", sizeof(SERIAL_DEVICE_EXTENSION)));
; 203  : 
; 204  : 
; 205  :    //
; 206  :    // Initialize the Driver Object with driver's entry points
; 207  :    //
; 208  : 
; 209  :    DriverObject->DriverUnload                          = SerialUnload;

  0013f	8b 75 08	 mov	 esi, DWORD PTR _DriverObject$[ebp]

; 210  :    DriverObject->DriverExtension->AddDevice            = SerialAddDevice;
; 211  : 
; 212  :    DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS]   = SerialFlush;
; 213  :    DriverObject->MajorFunction[IRP_MJ_WRITE]           = SerialWrite;
; 214  :    DriverObject->MajorFunction[IRP_MJ_READ]            = SerialRead;
; 215  :    DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]  = SerialIoControl;
; 216  :    DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL]
; 217  :       = SerialInternalIoControl;
; 218  :    DriverObject->MajorFunction[IRP_MJ_CREATE]          = SerialCreateOpen;
; 219  :    DriverObject->MajorFunction[IRP_MJ_CLOSE]           = SerialClose;
; 220  :    DriverObject->MajorFunction[IRP_MJ_CLEANUP]         = SerialCleanup;
; 221  :    DriverObject->MajorFunction[IRP_MJ_PNP]             = SerialPnpDispatch;
; 222  :    DriverObject->MajorFunction[IRP_MJ_POWER]           = SerialPowerDispatch;
; 223  : 
; 224  :    DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION]
; 225  :       = SerialQueryInformationFile;
; 226  :    DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION]
; 227  :       = SerialSetInformationFile;
; 228  : 
; 229  :    DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL]
; 230  :       = SerialSystemControlDispatch;
; 231  : 
; 232  :    if (!(jensenBuffer = ExAllocatePool(
; 233  :                                       PagedPool,
; 234  :                                       512
; 235  :                                       ))) {

  00142	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  00147	68 00 02 00 00	 push	 512			; 00000200H
  0014c	6a 01		 push	 1
  0014e	8b 46 18	 mov	 eax, DWORD PTR [esi+24]
  00151	c7 46 34 00 00
	00 00		 mov	 DWORD PTR [esi+52], OFFSET FLAT:_SerialUnload@4
  00158	c7 40 04 00 00
	00 00		 mov	 DWORD PTR [eax+4], OFFSET FLAT:_SerialAddDevice@8
  0015f	c7 46 5c 00 00
	00 00		 mov	 DWORD PTR [esi+92], OFFSET FLAT:_SerialFlush@8
  00166	c7 46 48 00 00
	00 00		 mov	 DWORD PTR [esi+72], OFFSET FLAT:_SerialWrite@8
  0016d	c7 46 44 00 00
	00 00		 mov	 DWORD PTR [esi+68], OFFSET FLAT:_SerialRead@8
  00174	c7 46 70 00 00
	00 00		 mov	 DWORD PTR [esi+112], OFFSET FLAT:_SerialIoControl@8
  0017b	c7 46 74 00 00
	00 00		 mov	 DWORD PTR [esi+116], OFFSET FLAT:_SerialInternalIoControl@8
  00182	c7 46 38 00 00
	00 00		 mov	 DWORD PTR [esi+56], OFFSET FLAT:_SerialCreateOpen@8
  00189	c7 46 40 00 00
	00 00		 mov	 DWORD PTR [esi+64], OFFSET FLAT:_SerialClose@8
  00190	c7 86 80 00 00
	00 00 00 00 00	 mov	 DWORD PTR [esi+128], OFFSET FLAT:_SerialCleanup@8
  0019a	c7 86 a4 00 00
	00 00 00 00 00	 mov	 DWORD PTR [esi+164], OFFSET FLAT:_SerialPnpDispatch@8
  001a4	c7 86 90 00 00
	00 00 00 00 00	 mov	 DWORD PTR [esi+144], OFFSET FLAT:_SerialPowerDispatch@8
  001ae	c7 46 4c 00 00
	00 00		 mov	 DWORD PTR [esi+76], OFFSET FLAT:_SerialQueryInformationFile@8
  001b5	c7 46 50 00 00
	00 00		 mov	 DWORD PTR [esi+80], OFFSET FLAT:_SerialSetInformationFile@8
  001bc	c7 86 94 00 00
	00 00 00 00 00	 mov	 DWORD PTR [esi+148], OFFSET FLAT:_SerialSystemControlDispatch@8
  001c6	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12
  001cc	8b f8		 mov	 edi, eax
  001ce	85 ff		 test	 edi, edi
  001d0	89 7d 08	 mov	 DWORD PTR _jensenBuffer$[ebp], edi
  001d3	75 07		 jne	 SHORT $L14786

; 236  : 
; 237  :       //
; 238  :       // We couldn't allocate 512 bytes of paged pool.  If that's
; 239  :       // so, then it's likely that the least of this machine's problems
; 240  :       // is that it's a Jensen.
; 241  :       //
; 242  : 
; 243  :       jensenDetected = FALSE;

  001d5	32 c0		 xor	 al, al

; 244  : 
; 245  :    } else {

  001d7	e9 8c 00 00 00	 jmp	 $L14807
$L14786:

; 246  : 
; 247  :       //
; 248  :       // Check to see if this is a Jensen alpha.  If it is, then
; 249  :       // we'll have to change the way we enable and disable interrupts
; 250  :       //
; 251  : 
; 252  :       jensenData.Length = 0;

  001dc	66 83 65 f4 00	 and	 WORD PTR _jensenData$[ebp], 0

; 253  :       jensenData.MaximumLength = 512;
; 254  :       jensenData.Buffer = (PWCHAR)&jensenBuffer[0];
; 255  :       RtlInitUnicodeString(
; 256  :                           &jensenValue,
; 257  :                           L"Jensen"
; 258  :                           );

  001e1	8d 45 ec	 lea	 eax, DWORD PTR _jensenValue$[ebp]
  001e4	68 00 00 00 00	 push	 OFFSET FLAT:$SG14789
  001e9	50		 push	 eax
  001ea	66 c7 45 f6 00
	02		 mov	 WORD PTR _jensenData$[ebp+2], 512 ; 00000200H
  001f0	89 7d f8	 mov	 DWORD PTR _jensenData$[ebp+4], edi
  001f3	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlInitUnicodeString@8

; 259  :       jensenTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT
; 260  :                              | RTL_QUERY_REGISTRY_REQUIRED;
; 261  :       jensenTable[0].Name = L"Identifier";
; 262  :       jensenTable[0].EntryContext = &jensenData;

⌨️ 快捷键说明

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