📄 initunlo.cod
字号:
; 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
PUBLIC _SerialDebugLevel
_BSS SEGMENT
_SerialDebugLevel DD 01H DUP (?)
_BSS ENDS
_DATA SEGMENT
COMM _driverDefaults:BYTE:04cH
COMM _SerialGlobals:BYTE:018H
_DATA ENDS
CONST SEGMENT
_SerialPhysicalZero DD 00H
ORG $+4
CONST ENDS
PUBLIC _DriverEntry@8
PUBLIC _SerialUnload@4
PUBLIC _SerialReset@4
EXTRN _SerialGetConfigDefaults@8:NEAR
EXTRN _SerialEnumerateLegacy@12:NEAR
EXTRN __imp__MmLockPagableDataSection@4:NEAR
EXTRN __imp__MmUnlockPagableImageSection@4:NEAR
EXTRN _SerialAddDevice@8:NEAR
EXTRN __imp_@InterlockedIncrement@4:NEAR
EXTRN __imp_@InterlockedDecrement@4:NEAR
EXTRN __imp__memmove:NEAR
EXTRN __imp__KeGetCurrentIrql@0:NEAR
EXTRN __imp__RtlAssert@16:NEAR
EXTRN __imp__RtlQueryRegistryValues@20:NEAR
EXTRN _SerialSystemControlDispatch@8:NEAR
EXTRN __imp__RtlInitUnicodeString@8:NEAR
EXTRN __imp__ExAllocatePoolWithTag@12:NEAR
EXTRN __imp__RtlEqualUnicodeString@12:NEAR
EXTRN _SerialInternalIoControl@8:NEAR
EXTRN __imp__ExFreePool@4:NEAR
EXTRN _DbgBreakPoint@0:NEAR
EXTRN _DbgPrint:NEAR
EXTRN _SerialLogInit@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
; COMDAT _DriverEntry@8
; File f:\w2ddk\src\kernel\serial\initunlo.c
INIT SEGMENT
$SG14818 DB 'EX: Pageable code called at IRQL %d', 0aH, 00H
ORG $+3
$SG14821 DB 'f:\w2ddk\src\kernel\serial\initunlo.c', 00H
ORG $+2
$SG14822 DB 'FALSE', 00H
ORG $+2
$SG14826 DB 'f:\w2ddk\src\kernel\serial\initunlo.c', 00H
ORG $+2
$SG14827 DB 'SerialGlobals.PAGESER_Handle == NULL', 00H
ORG $+3
$SG14839 DB 'SERIAL: The number of bytes in the extension is: %d', 0aH
DB 00H
ORG $+3
$SG14849 DB 'J', 00H, 'e', 00H, 'n', 00H, 's', 00H, 'e', 00H, 'n', 00H
DB 00H, 00H
ORG $+2
$SG14855 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
$SG14850 DB 'I', 00H, 'd', 00H, 'e', 00H, 'n', 00H, 't', 00H, 'i', 00H
DB 'f', 00H, 'i', 00H, 'e', 00H, 'r', 00H, 00H, 00H
ORG $+2
$SG14871 DB 'SERIAL: Jensen Detected', 0aH, 00H
; Function compile flags: /Ogs
_DriverObject$ = 8
_RegistryPath$ = 12
_jensenTable$ = -76
_jensenData$ = -12
_jensenValue$ = -20
_jensenDetected$ = 15
_jensenBuffer$ = 8
_lockPtr$ = -4
_DriverEntry@8 PROC NEAR ; COMDAT
; 130 : {
0017d 55 push ebp
0017e 8b ec mov ebp, esp
00180 83 ec 4c sub esp, 76 ; 0000004cH
00183 53 push ebx
00184 56 push esi
00185 57 push edi
; 131 : RTL_QUERY_REGISTRY_TABLE jensenTable[2] = {0};
00186 6a 0d push 13 ; 0000000dH
00188 33 f6 xor esi, esi
0018a 59 pop ecx
0018b 33 c0 xor eax, eax
0018d 8d 7d b8 lea edi, DWORD PTR _jensenTable$[ebp+4]
00190 89 75 b4 mov DWORD PTR _jensenTable$[ebp], esi
; 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);
00193 68 00 00 00 00 push OFFSET FLAT:_SerialReset@4
00198 f3 ab rep stosd
0019a ff 15 00 00 00
00 call DWORD PTR __imp__MmLockPagableDataSection@4
; 142 :
; 143 : PAGED_CODE();
001a0 8b 3d 00 00 00
00 mov edi, DWORD PTR __imp__KeGetCurrentIrql@0
001a6 89 45 fc mov DWORD PTR _lockPtr$[ebp], eax
001a9 ff d7 call edi
001ab 8b 1d 00 00 00
00 mov ebx, DWORD PTR __imp__RtlAssert@16
001b1 3c 01 cmp al, 1
001b3 76 24 jbe SHORT $L14819
001b5 ff d7 call edi
001b7 0f b6 c0 movzx eax, al
001ba 50 push eax
001bb 68 00 00 00 00 push OFFSET FLAT:$SG14818
001c0 e8 00 00 00 00 call _DbgPrint
001c5 59 pop ecx
001c6 59 pop ecx
001c7 56 push esi
001c8 68 8f 00 00 00 push 143 ; 0000008fH
001cd 68 00 00 00 00 push OFFSET FLAT:$SG14821
001d2 68 00 00 00 00 push OFFSET FLAT:$SG14822
001d7 ff d3 call ebx
$L14819:
; 144 :
; 145 :
; 146 : ASSERT(SerialGlobals.PAGESER_Handle == NULL);
001d9 39 35 08 00 00
00 cmp DWORD PTR _SerialGlobals+8, esi
001df 74 12 je SHORT $L14824
001e1 56 push esi
001e2 68 92 00 00 00 push 146 ; 00000092H
001e7 68 00 00 00 00 push OFFSET FLAT:$SG14826
001ec 68 00 00 00 00 push OFFSET FLAT:$SG14827
001f1 ff d3 call ebx
$L14824:
; 147 : #if DBG
; 148 : SerialGlobals.PAGESER_Count = 0;
001f3 89 35 14 00 00
00 mov DWORD PTR _SerialGlobals+20, esi
; 149 : SerialLogInit();
001f9 e8 00 00 00 00 call _SerialLogInit@0
; 150 : #endif
; 151 : SerialGlobals.PAGESER_Handle = lockPtr;
001fe 8b 45 fc mov eax, DWORD PTR _lockPtr$[ebp]
; 152 :
; 153 : SerialGlobals.RegistryPath.MaximumLength = RegistryPath->MaximumLength;
00201 8b 5d 0c mov ebx, DWORD PTR _RegistryPath$[ebp]
00204 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);
00209 68 43 4f 4d 58 push 1481461571 ; 584d4f43H
0020e 66 8b 43 02 mov ax, WORD PTR [ebx+2]
00212 66 a3 0e 00 00
00 mov WORD PTR _SerialGlobals+14, ax
00218 66 8b 0b mov cx, WORD PTR [ebx]
0021b 0f b7 c0 movzx eax, ax
0021e 50 push eax
0021f 6a 01 push 1
00221 66 89 0d 0c 00
00 00 mov WORD PTR _SerialGlobals+12, cx
00228 ff 15 00 00 00
00 call DWORD PTR __imp__ExAllocatePoolWithTag@12
0022e 8b f8 mov edi, eax
; 157 :
; 158 : if (SerialGlobals.RegistryPath.Buffer == NULL) {
00230 3b fe cmp edi, esi
00232 89 3d 10 00 00
00 mov DWORD PTR _SerialGlobals+16, edi
00238 75 0a jne SHORT $L14829
0023a be 9a 00 00 c0 mov esi, -1073741670 ; c000009aH
0023f e9 e4 01 00 00 jmp $L16515
$L14829:
; 159 : MmUnlockPagableImageSection(lockPtr);
; 160 : return STATUS_INSUFFICIENT_RESOURCES;
; 161 : }
; 162 :
; 163 : RtlZeroMemory(SerialGlobals.RegistryPath.Buffer,
; 164 : SerialGlobals.RegistryPath.MaximumLength);
00244 0f b7 0d 0e 00
00 00 movzx ecx, WORD PTR _SerialGlobals+14
0024b 8b d1 mov edx, ecx
0024d 33 c0 xor eax, eax
0024f c1 e9 02 shr ecx, 2
00252 f3 ab rep stosd
00254 8b ca mov ecx, edx
00256 83 e1 03 and ecx, 3
00259 f3 aa rep stosb
; 165 : RtlMoveMemory(SerialGlobals.RegistryPath.Buffer,
; 166 : RegistryPath->Buffer, RegistryPath->Length);
0025b 0f b7 03 movzx eax, WORD PTR [ebx]
0025e 50 push eax
0025f ff 73 04 push DWORD PTR [ebx+4]
00262 ff 35 10 00 00
00 push DWORD PTR _SerialGlobals+16
00268 ff 15 00 00 00
00 call DWORD PTR __imp__memmove
0026e 83 c4 0c add esp, 12 ; 0000000cH
; 167 :
; 168 : //
; 169 : // Initialize all our globals
; 170 : //
; 171 :
; 172 : InitializeListHead(&SerialGlobals.AllDevObjs);
00271 b8 00 00 00 00 mov eax, OFFSET FLAT:_SerialGlobals
00276 a3 04 00 00 00 mov DWORD PTR _SerialGlobals+4, eax
0027b 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);
00280 53 push ebx
00281 68 00 00 00 00 push OFFSET FLAT:_driverDefaults
00286 e8 00 00 00 00 call _SerialGetConfigDefaults@8
; 180 :
; 181 : #if DBG
; 182 : //
; 183 : // Set global debug output level
; 184 : //
; 185 : SerialDebugLevel = driverDefaults.DebugLevel;
0028b a1 0c 00 00 00 mov eax, DWORD PTR _driverDefaults+12
; 186 : #endif
; 187 :
; 188 : //
; 189 : // Break on entry if requested via registry
; 190 : //
; 191 :
; 192 : if (driverDefaults.ShouldBreakOnEntry) {
00290 39 35 10 00 00
00 cmp DWORD PTR _driverDefaults+16, esi
00296 a3 00 00 00 00 mov DWORD PTR _SerialDebugLevel, eax
0029b 74 05 je SHORT $L14832
; 193 : DbgBreakPoint();
0029d e8 00 00 00 00 call _DbgBreakPoint@0
$L14832:
; 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)));
002a2 f6 05 00 00 00
00 01 test BYTE PTR _SerialDebugLevel, 1
002a9 74 11 je SHORT $L14833
002ab 68 48 06 00 00 push 1608 ; 00000648H
002b0 68 00 00 00 00 push OFFSET FLAT:$SG14839
002b5 e8 00 00 00 00 call _DbgPrint
002ba 59 pop ecx
002bb 59 pop ecx
$L14833:
; 203 :
; 204 :
; 205 : //
; 206 : // Initialize the Driver Object with driver's entry points
; 207 : //
; 208 :
; 209 : DriverObject->DriverUnload = SerialUnload;
002bc 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 : ))) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -