📄 legacy.cod
字号:
; Listing generated by Microsoft (R) Optimizing Compiler Version 12.00.9044.0
TITLE F:\W2DDK\src\kernel\serial\legacy.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
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _RtlConvertLongToLargeInteger@4
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _SerialTranslateResourceList@24
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _SerialBuildRequirementsList@12
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _SerialBuildResourceList@12
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _SerialMigrateLegacyRegistry@12
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _SerialIsUserDataValid@20
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _SerialEnumerateLegacy@12
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
INCLUDELIB LIBC
INCLUDELIB OLDNAMES
CONST SEGMENT
_SerialPhysicalZero DD 00H
ORG $+4
CONST ENDS
PUBLIC _SerialTranslateResourceList@24
EXTRN _SerialLogError@64:NEAR
EXTRN _SerialDebugLevel:DWORD
EXTRN __imp__KeGetCurrentIrql@0:NEAR
EXTRN __imp__RtlAssert@16:NEAR
EXTRN _DbgPrint:NEAR
EXTRN __imp__HalGetInterruptVector@24:NEAR
EXTRN __imp__HalTranslateBusAddress@24:NEAR
; COMDAT _SerialTranslateResourceList@24
; File f:\w2ddk\src\kernel\serial\legacy.c
INIT SEGMENT
$SG14825 DB 'EX: Pageable code called at IRQL %d', 0aH, 00H
ORG $+3
$SG14828 DB 'f:\w2ddk\src\kernel\serial\legacy.c', 00H
$SG14829 DB 'FALSE', 00H
ORG $+2
$SG14836 DB 'SERIAL: Enter SerialTranslateResourceList', 0aH, 00H
ORG $+1
$SG14858 DB 'SERIAL: Port map failed attempt was ', 0aH, '------- Int'
DB 'erface: %x', 0aH, '------- Bus Number: %x', 0aH, '------- us'
DB 'erPort: %x', 0aH, '------- AddrSpace: %x', 0aH, '------- Ph'
DB 'ysAddr: %x', 0aH, 00H
$SG14888 DB 'SERIAL: ISR map failed attempt was ', 0aH, '------- Inte'
DB 'rface: %x', 0aH, '------- Bus Number: %x', 0aH, '------- Int'
DB 'Status: %x', 0aH, '------- AddrSpace: %x', 0aH, '------- Ph'
DB 'ysAddr: %x', 0aH, 00H
$SG14902 DB 'SERIAL: ISR map was %x', 0aH, 00H
$SG14916 DB 'SERIAL: Enter SerialTranslateResourceList', 0aH, 00H
; Function compile flags: /Ogs
_DriverObject$ = 8
_UserSubKey$ = 12
_PTrResourceList$ = 16
_PResourceList$ = 20
_PartialCount$ = 24
_PUserData$ = 28
_outIrql$ = -1
_outAffinity$ = -16
_outAddrSpace$ = -8
_outPhysAddr$ = -24
_status$ = -12
_SerialTranslateResourceList@24 PROC NEAR ; COMDAT
; 77 : {
001f3 55 push ebp
001f4 8b ec mov ebp, esp
001f6 83 ec 18 sub esp, 24 ; 00000018H
; 78 : KIRQL outIrql;
; 79 : KAFFINITY outAffinity = (KAFFINITY)-1;
001f9 83 4d f0 ff or DWORD PTR _outAffinity$[ebp], -1
; 80 : ULONG outAddrSpace;
; 81 : PHYSICAL_ADDRESS outPhysAddr;
; 82 : NTSTATUS status = STATUS_SUCCESS;
001fd 83 65 f4 00 and DWORD PTR _status$[ebp], 0
00201 53 push ebx
00202 56 push esi
; 83 :
; 84 : PAGED_CODE();
00203 8b 35 00 00 00
00 mov esi, DWORD PTR __imp__KeGetCurrentIrql@0
00209 57 push edi
0020a ff d6 call esi
0020c 3c 01 cmp al, 1
0020e 76 26 jbe SHORT $L14830
00210 ff d6 call esi
00212 0f b6 c0 movzx eax, al
00215 50 push eax
00216 68 00 00 00 00 push OFFSET FLAT:$SG14825
0021b e8 00 00 00 00 call _DbgPrint
00220 59 pop ecx
00221 59 pop ecx
00222 6a 00 push 0
00224 6a 54 push 84 ; 00000054H
00226 68 00 00 00 00 push OFFSET FLAT:$SG14828
0022b 68 00 00 00 00 push OFFSET FLAT:$SG14829
00230 ff 15 00 00 00
00 call DWORD PTR __imp__RtlAssert@16
$L14830:
; 85 :
; 86 : SerialDump(SERTRACECALLS, ("SERIAL: Enter SerialTranslateResourceList\n"));
00236 f6 05 00 00 00
00 40 test BYTE PTR _SerialDebugLevel, 64 ; 00000040H
0023d 74 0b je SHORT $L14831
0023f 68 00 00 00 00 push OFFSET FLAT:$SG14836
00244 e8 00 00 00 00 call _DbgPrint
00249 59 pop ecx
$L14831:
; 87 :
; 88 : outIrql = (KIRQL)(PUserData->UserLevel ? PUserData->UserLevel
; 89 : : PUserData->UserVector);
0024a 8b 5d 1c mov ebx, DWORD PTR _PUserData$[ebp]
0024d 8b 43 38 mov eax, DWORD PTR [ebx+56]
00250 85 c0 test eax, eax
00252 75 03 jne SHORT $L16242
00254 8a 43 10 mov al, BYTE PTR [ebx+16]
$L16242:
; 90 :
; 91 : //
; 92 : // Copy the list over to the translated buffer and fixup and translate
; 93 : // what we need.
; 94 : //
; 95 : RtlCopyMemory(PTrResourceList, PResourceList, sizeof(CM_RESOURCE_LIST)
; 96 : + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * 2);
00257 8b 75 14 mov esi, DWORD PTR _PResourceList$[ebp]
0025a 88 45 ff mov BYTE PTR _outIrql$[ebp], al
0025d 8b 45 10 mov eax, DWORD PTR _PTrResourceList$[ebp]
00260 6a 11 push 17 ; 00000011H
00262 59 pop ecx
00263 8b f8 mov edi, eax
00265 f3 a5 rep movsd
; 97 :
; 98 : outAddrSpace = PTrResourceList->List[0].PartialResourceList
; 99 : .PartialDescriptors[0].Flags;
00267 0f b7 48 16 movzx ecx, WORD PTR [eax+22]
0026b 89 4d f8 mov DWORD PTR _outAddrSpace$[ebp], ecx
; 100 : outPhysAddr = PTrResourceList->List[0].PartialResourceList
; 101 : .PartialDescriptors[0].u.Port.Start;
0026e 8b 48 18 mov ecx, DWORD PTR [eax+24]
00271 8b 40 1c mov eax, DWORD PTR [eax+28]
00274 89 4d e8 mov DWORD PTR _outPhysAddr$[ebp], ecx
00277 89 45 ec mov DWORD PTR _outPhysAddr$[ebp+4], eax
; 102 :
; 103 :
; 104 : if (HalTranslateBusAddress(PUserData->UserInterfaceType,
; 105 : PUserData->UserBusNumber, PUserData->UserPort,
; 106 : &outAddrSpace, &outPhysAddr)
; 107 : == 0) {
0027a 8d 45 e8 lea eax, DWORD PTR _outPhysAddr$[ebp]
0027d 50 push eax
0027e 8d 45 f8 lea eax, DWORD PTR _outAddrSpace$[ebp]
00281 50 push eax
00282 ff 73 04 push DWORD PTR [ebx+4]
00285 ff 33 push DWORD PTR [ebx]
00287 ff 73 20 push DWORD PTR [ebx+32]
0028a ff 73 24 push DWORD PTR [ebx+36]
0028d ff 15 00 00 00
00 call DWORD PTR __imp__HalTranslateBusAddress@24
00293 84 c0 test al, al
00295 75 66 jne SHORT $L14846
; 108 : SerialLogError(DriverObject, NULL, PUserData->UserPort,
; 109 : SerialPhysicalZero, 0, 0, 0, 60, STATUS_SUCCESS,
; 110 : SERIAL_NO_TRANSLATE_PORT, UserSubKey->NameLength
; 111 : + sizeof(WCHAR), &UserSubKey->Name[0], 0, NULL);
00297 8b 4d 0c mov ecx, DWORD PTR _UserSubKey$[ebp]
0029a 33 c0 xor eax, eax
0029c 50 push eax
0029d 50 push eax
0029e 8d 51 10 lea edx, DWORD PTR [ecx+16]
002a1 8b 49 0c mov ecx, DWORD PTR [ecx+12]
002a4 41 inc ecx
002a5 52 push edx
002a6 41 inc ecx
002a7 51 push ecx
002a8 68 25 00 06 c0 push -1073348571 ; c0060025H
002ad 50 push eax
002ae 6a 3c push 60 ; 0000003cH
002b0 50 push eax
002b1 50 push eax
002b2 50 push eax
002b3 ff 35 04 00 00
00 push DWORD PTR _SerialPhysicalZero+4
002b9 ff 35 00 00 00
00 push DWORD PTR _SerialPhysicalZero
002bf ff 73 04 push DWORD PTR [ebx+4]
002c2 ff 33 push DWORD PTR [ebx]
002c4 50 push eax
002c5 ff 75 08 push DWORD PTR _DriverObject$[ebp]
002c8 e8 00 00 00 00 call _SerialLogError@64
; 112 :
; 113 : SerialDump(SERERRORS, ("SERIAL: Port map failed attempt was \n"
; 114 : "------- Interface: %x\n"
; 115 : "------- Bus Number: %x\n"
; 116 : "------- userPort: %x\n"
; 117 : "------- AddrSpace: %x\n"
; 118 : "------- PhysAddr: %x\n",
; 119 : PUserData->UserInterfaceType,
; 120 : PUserData->UserBusNumber,
; 121 : PUserData->UserPort,
; 122 : PTrResourceList->List[0].
; 123 : PartialResourceList.PartialDescriptors[0]
; 124 : .Flags,
; 125 : PTrResourceList->List[0].
; 126 : PartialResourceList.PartialDescriptors[0]
; 127 : .u.Port.Start.QuadPart));
002cd f6 05 03 00 00
00 40 test BYTE PTR _SerialDebugLevel+3, 64 ; 00000040H
002d4 0f 84 49 01 00
00 je $L14883
002da 8b 45 10 mov eax, DWORD PTR _PTrResourceList$[ebp]
002dd ff 70 1c push DWORD PTR [eax+28]
002e0 ff 70 18 push DWORD PTR [eax+24]
002e3 0f b7 40 16 movzx eax, WORD PTR [eax+22]
002e7 50 push eax
002e8 ff 73 04 push DWORD PTR [ebx+4]
002eb ff 33 push DWORD PTR [ebx]
002ed ff 73 20 push DWORD PTR [ebx+32]
002f0 ff 73 24 push DWORD PTR [ebx+36]
002f3 68 00 00 00 00 push OFFSET FLAT:$SG14858
; 128 :
; 129 : status = STATUS_NONE_MAPPED;
; 130 : goto SerialTranslateError;
002f8 e9 1e 01 00 00 jmp $L16243
$L14846:
; 131 : }
; 132 :
; 133 : PTrResourceList->List[0].PartialResourceList.PartialDescriptors[0].Flags
; 134 : = (USHORT)outAddrSpace;
002fd 8b 75 10 mov esi, DWORD PTR _PTrResourceList$[ebp]
00300 66 8b 45 f8 mov ax, WORD PTR _outAddrSpace$[ebp]
; 135 : PTrResourceList->List[0].PartialResourceList.PartialDescriptors[0]
; 136 : .u.Port.Start = outPhysAddr;
; 137 :
; 138 : if ((PTrResourceList->List[0].PartialResourceList
; 139 : .PartialDescriptors[1].u.Interrupt.Vector
; 140 : = HalGetInterruptVector(PUserData->UserInterfaceType,
; 141 : PUserData->UserBusNumber, PUserData->UserLevel
; 142 : ? PUserData->UserLevel
; 143 : : PUserData->UserVector,
; 144 : PUserData->UserVector, &outIrql,
; 145 : &outAffinity)) == 0) {
00304 33 ff xor edi, edi
00306 66 89 46 16 mov WORD PTR [esi+22], ax
0030a 8b 45 e8 mov eax, DWORD PTR _outPhysAddr$[ebp]
0030d 89 46 18 mov DWORD PTR [esi+24], eax
00310 8b 45 ec mov eax, DWORD PTR _outPhysAddr$[ebp+4]
00313 89 46 1c mov DWORD PTR [esi+28], eax
00316 8b 43 38 mov eax, DWORD PTR [ebx+56]
00319 3b c7 cmp eax, edi
0031b 75 03 jne SHORT $L16233
0031d 8b 43 10 mov eax, DWORD PTR [ebx+16]
$L16233:
00320 8d 4d f0 lea ecx, DWORD PTR _outAffinity$[ebp]
00323 51 push ecx
00324 8d 4d ff lea ecx, DWORD PTR _outIrql$[ebp]
00327 51 push ecx
00328 ff 73 10 push DWORD PTR [ebx+16]
0032b 50 push eax
0032c ff 73 20 push DWORD PTR [ebx+32]
0032f ff 73 24 push DWORD PTR [ebx+36]
00332 ff 15 00 00 00
00 call DWORD PTR __imp__HalGetInterruptVector@24
00338 3b c7 cmp eax, edi
0033a 89 46 2c mov DWORD PTR [esi+44], eax
0033d 75 39 jne SHORT $L14868
; 146 :
; 147 : SerialLogError(DriverObject, NULL, PUserData->UserPort,
; 148 : SerialPhysicalZero, 0, 0, 0, 61, STATUS_SUCCESS,
; 149 : SERIAL_NO_GET_INTERRUPT, UserSubKey->NameLength
; 150 : + sizeof(WCHAR), &UserSubKey->Name[0], 0, NULL);
0033f 8b 45 0c mov eax, DWORD PTR _UserSubKey$[ebp]
00342 57 push edi
00343 57 push edi
00344 8d 48 10 lea ecx, DWORD PTR [eax+16]
00347 8b 40 0c mov eax, DWORD PTR [eax+12]
0034a 40 inc eax
0034b 51 push ecx
0034c 40 inc eax
0034d 50 push eax
0034e 68 26 00 06 c0 push -1073348570 ; c0060026H
00353 57 push edi
00354 6a 3d push 61 ; 0000003dH
00356 57 push edi
00357 57 push edi
00358 57 push edi
00359 ff 35 04 00 00
00 push DWORD PTR _SerialPhysicalZero+4
0035f ff 35 00 00 00
00 push DWORD PTR _SerialPhysicalZero
00365 ff 73 04 push DWORD PTR [ebx+4]
00368 ff 33 push DWORD PTR [ebx]
0036a 57 push edi
0036b ff 75 08 push DWORD PTR _DriverObject$[ebp]
0036e e8 00 00 00 00 call _SerialLogError@64
; 151 :
; 152 : status = STATUS_NONE_MAPPED;
; 153 : goto SerialTranslateError;
00373 e9 ab 00 00 00 jmp $L14883
$L14868:
; 154 : }
; 155 :
; 156 : PTrResourceList->List[0].PartialResourceList
; 157 : .PartialDescriptors[1].u.Interrupt.Level = outIrql;
00378 0f b6 45 ff movzx eax, BYTE PTR _outIrql$[ebp]
0037c 89 46 28 mov DWORD PTR [esi+40], eax
; 158 :
; 159 : PTrResourceList->List[0].PartialResourceList
; 160 : .PartialDescriptors[1].u.Interrupt.Affinity = outAffinity;
0037f 8b 45 f0 mov eax, DWORD PTR _outAffinity$[ebp]
00382 89 46 30 mov DWORD PTR [esi+48], eax
; 161 :
; 162 : outAddrSpace = PTrResourceList->List[0].PartialResourceList
; 163 : .PartialDescriptors[2].Flags;
; 164 : outPhysAddr = PTrResourceList->List[0].PartialResourceList
; 165 : .PartialDescriptors[2].u.Port.Start;
; 166 :
; 167 :
; 168 : if (PartialCount == 3) {
00385 83 7d 18 03 cmp DWORD PTR _PartialCount$[ebp], 3
00389 0f b7 46 36 movzx eax, WORD PTR [esi+54]
0038d 89 45 f8 mov DWORD PTR _outAddrSpace$[ebp], eax
00390 8b 46 38 mov eax, DWORD PTR [esi+56]
00393 89 45 e8 mov DWORD PTR _outPhysAddr$[ebp], eax
00396 8b 46 3c mov eax, DWORD PTR [esi+60]
00399 89 45 ec mov DWORD PTR _outPhysAddr$[ebp+4], eax
0039c 0f 85 ba 00 00
00 jne $SerialTranslateError$14866
; 169 : if (HalTranslateBusAddress(PUserData->UserInterfaceType,
; 170 : PUserData->UserBusNumber,
; 171 : PUserData->UserInterruptStatus,
; 172 : &outAddrSpace, &outPhysAddr) == 0) {
003a2 8d 45 e8 lea eax, DWORD PTR _outPhysAddr$[ebp]
003a5 50 push eax
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -