📄 openclos.cod
字号:
; Listing generated by Microsoft (R) Optimizing Compiler Version 12.00.9044.0
TITLE F:\W2DDK\src\kernel\serial\openclos.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
PAGESER SEGMENT PARA USE32 PUBLIC ''
PAGESER ENDS
; COMDAT _RtlConvertLongToLargeInteger@4
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _SerialNullSynch@4
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _SerialCreateOpen@8
PAGESRP0 SEGMENT PARA USE32 PUBLIC ''
PAGESRP0 ENDS
; COMDAT _SerialDrainUART@8
PAGESRP0 SEGMENT PARA USE32 PUBLIC ''
PAGESRP0 ENDS
; COMDAT _SerialClose@8
PAGESER SEGMENT PARA USE32 PUBLIC ''
PAGESER ENDS
; COMDAT _SerialCheckOpen@4
PAGESER SEGMENT PARA USE32 PUBLIC ''
PAGESER ENDS
; COMDAT _SerialMarkOpen@4
PAGESER SEGMENT PARA USE32 PUBLIC ''
PAGESER ENDS
; COMDAT _SerialDisableUART@4
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _SerialMarkClose@4
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _SerialCleanup@8
PAGESER SEGMENT PARA USE32 PUBLIC ''
PAGESER ENDS
; COMDAT _SerialGetCharTime@4
PAGESER SEGMENT PARA USE32 PUBLIC ''
PAGESER ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
INCLUDELIB LIBC
INCLUDELIB OLDNAMES
PUBLIC _SerialNullSynch@4
; Function compile flags: /Ogs
; File f:\w2ddk\src\kernel\serial\openclos.c
; COMDAT _SerialNullSynch@4
_TEXT SEGMENT
_SerialNullSynch@4 PROC NEAR ; COMDAT
; 83 :
; 84 : UNREFERENCED_PARAMETER(Context);
; 85 : return FALSE;
00000 32 c0 xor al, al
; 86 : }
00002 c2 04 00 ret 4
_SerialNullSynch@4 ENDP
_TEXT ENDS
PUBLIC _SerialMarkOpen@4
PUBLIC _SerialCheckOpen@4
PUBLIC _SerialCreateOpen@8
EXTRN __imp__KeSynchronizeExecution@12:NEAR
EXTRN __imp__MmLockPagableSectionByHandle@4:NEAR
EXTRN __imp_@InterlockedIncrement@4:NEAR
EXTRN _SerialDebugLevel:DWORD
EXTRN __imp_@InterlockedDecrement@4:NEAR
EXTRN __imp__KeGetCurrentIrql@0:NEAR
EXTRN __imp__RtlAssert@16:NEAR
EXTRN _SerialIRPPrologue@8:NEAR
EXTRN _SerialIRPEpilogue@4:NEAR
EXTRN _SerialGotoPowerState@12:NEAR
EXTRN __imp__ExAllocatePoolWithTag@12:NEAR
EXTRN __imp__ExFreePool@4:NEAR
EXTRN __imp_@ExAcquireFastMutex@4:NEAR
EXTRN __imp_@ExReleaseFastMutex@4:NEAR
EXTRN _DbgPrint:NEAR
EXTRN _SerialGlobals:BYTE
EXTRN __imp_@IofCompleteRequest@8:NEAR
EXTRN __imp__MmQuerySystemSize@0:NEAR
; COMDAT _SerialCreateOpen@8
PAGESRP0 SEGMENT
$SG14834 DB 'EX: Pageable code called at IRQL %d', 0aH, 00H
ORG $+3
$SG14837 DB 'f:\w2ddk\src\kernel\serial\openclos.c', 00H
ORG $+2
$SG14838 DB 'FALSE', 00H
ORG $+2
$SG14853 DB 'SERIAL: Dispatch entry for: %x', 0aH, 00H
$SG14866 DB 'SERIAL: In SerialCreateOpen', 0aH, 00H
ORG $+3
$SG14881 DB 'SERIAL: Complete Irp: %x', 0aH, 00H
ORG $+2
$SG14907 DB 'SERIAL: Complete Irp: %x', 0aH, 00H
ORG $+2
$SG14929 DB 'SERIAL: Complete Irp: %x', 0aH, 00H
; Function compile flags: /Ogs
_DeviceObject$ = 8
_Irp$ = 12
_checkOpen$ = -8
_localStatus$ = 12
_SerialCreateOpen@8 PROC NEAR ; COMDAT
; 113 : {
000ea 55 push ebp
000eb 8b ec mov ebp, esp
000ed 51 push ecx
000ee 51 push ecx
; 114 :
; 115 : PSERIAL_DEVICE_EXTENSION extension = DeviceObject->DeviceExtension;
000ef 8b 45 08 mov eax, DWORD PTR _DeviceObject$[ebp]
000f2 53 push ebx
000f3 56 push esi
000f4 57 push edi
; 116 : SERIAL_CHECK_OPEN checkOpen;
; 117 : NTSTATUS localStatus;
; 118 :
; 119 : PAGED_CODE();
000f5 8b 3d 00 00 00
00 mov edi, DWORD PTR __imp__KeGetCurrentIrql@0
000fb 8b 70 28 mov esi, DWORD PTR [eax+40]
000fe ff d7 call edi
00100 33 db xor ebx, ebx
00102 3c 01 cmp al, 1
00104 76 25 jbe SHORT $L14835
00106 ff d7 call edi
00108 0f b6 c0 movzx eax, al
0010b 50 push eax
0010c 68 00 00 00 00 push OFFSET FLAT:$SG14834
00111 e8 00 00 00 00 call _DbgPrint
00116 59 pop ecx
00117 59 pop ecx
00118 53 push ebx
00119 6a 77 push 119 ; 00000077H
0011b 68 00 00 00 00 push OFFSET FLAT:$SG14837
00120 68 00 00 00 00 push OFFSET FLAT:$SG14838
00125 ff 15 00 00 00
00 call DWORD PTR __imp__RtlAssert@16
$L14835:
; 120 :
; 121 : if (extension->PNPState != SERIAL_PNP_STARTED) {
0012b 83 be e0 04 00
00 01 cmp DWORD PTR [esi+1248], 1
00132 74 1a je SHORT $L14839
; 122 : Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
00134 8b 4d 0c mov ecx, DWORD PTR _Irp$[ebp]
00137 be 9a 00 00 c0 mov esi, -1073741670 ; c000009aH
; 123 : IoCompleteRequest(Irp, IO_NO_INCREMENT);
0013c 32 d2 xor dl, dl
0013e 89 71 18 mov DWORD PTR [ecx+24], esi
00141 ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
; 124 : return STATUS_INSUFFICIENT_RESOURCES;
00147 8b c6 mov eax, esi
00149 e9 11 03 00 00 jmp $L14829
$L14839:
; 125 : }
; 126 :
; 127 : //
; 128 : // Lock out changes to PnP state until we have our open state decided
; 129 : //
; 130 :
; 131 : ExAcquireFastMutex(&extension->OpenMutex);
0014e 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
00154 ff 15 00 00 00
00 call DWORD PTR __imp_@ExAcquireFastMutex@4
; 132 :
; 133 : if ((localStatus = SerialIRPPrologue(Irp, extension)) != STATUS_SUCCESS) {
0015a 8b 7d 0c mov edi, DWORD PTR _Irp$[ebp]
0015d 56 push esi
0015e 57 push edi
0015f e8 00 00 00 00 call _SerialIRPPrologue@8
00164 3b c3 cmp eax, ebx
00166 89 45 0c mov DWORD PTR _localStatus$[ebp], eax
00169 74 11 je SHORT $L14843
; 134 : ExReleaseFastMutex(&extension->OpenMutex);
0016b 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
00171 ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
00177 e9 ce 02 00 00 jmp $L14937
$L14843:
; 135 : SerialCompleteRequest(extension, Irp, IO_NO_INCREMENT);
; 136 : return localStatus;
; 137 : }
; 138 :
; 139 : if (InterlockedIncrement(&extension->OpenCount) != 1) {
0017c 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
00182 ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedIncrement@4
00188 83 f8 01 cmp eax, 1
0018b 74 27 je SHORT $L14847
; 140 : ExReleaseFastMutex(&extension->OpenMutex);
0018d 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
00193 ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
; 141 : InterlockedDecrement(&extension->OpenCount);
00199 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
0019f ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedDecrement@4
; 142 : Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
001a5 b8 22 00 00 c0 mov eax, -1073741790 ; c0000022H
001aa 89 47 18 mov DWORD PTR [edi+24], eax
001ad 8b d8 mov ebx, eax
001af e9 99 02 00 00 jmp $L15318
$L14847:
; 143 : SerialCompleteRequest(extension, Irp, IO_NO_INCREMENT);
; 144 : return STATUS_ACCESS_DENIED;
; 145 : }
; 146 :
; 147 : SerialDump(
; 148 : SERIRPPATH,
; 149 : ("SERIAL: Dispatch entry for: %x\n",Irp)
; 150 : );
001b4 f6 05 00 00 00
00 20 test BYTE PTR _SerialDebugLevel, 32 ; 00000020H
001bb 74 0d je SHORT $L14848
001bd 57 push edi
001be 68 00 00 00 00 push OFFSET FLAT:$SG14853
001c3 e8 00 00 00 00 call _DbgPrint
001c8 59 pop ecx
001c9 59 pop ecx
$L14848:
; 151 : SerialDump(
; 152 : SERDIAG3,
; 153 : ("SERIAL: In SerialCreateOpen\n")
; 154 : );
001ca f6 05 00 00 00
00 04 test BYTE PTR _SerialDebugLevel, 4
001d1 74 0b je SHORT $L14861
001d3 68 00 00 00 00 push OFFSET FLAT:$SG14866
001d8 e8 00 00 00 00 call _DbgPrint
001dd 59 pop ecx
$L14861:
; 155 :
; 156 : //
; 157 : // Before we do anything, let's make sure they aren't trying
; 158 : // to create a directory. This is a silly, but what's a driver to do!?
; 159 : //
; 160 :
; 161 : if (IoGetCurrentIrpStackLocation(Irp)->Parameters.Create.Options &
; 162 : FILE_DIRECTORY_FILE) {
001de 8b 47 60 mov eax, DWORD PTR [edi+96]
001e1 f6 40 08 01 test BYTE PTR [eax+8], 1
001e5 74 42 je SHORT $L14873
; 163 : ExReleaseFastMutex(&extension->OpenMutex);
001e7 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
001ed ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
; 164 :
; 165 : Irp->IoStatus.Status = STATUS_NOT_A_DIRECTORY;
001f3 c7 47 18 03 01
00 c0 mov DWORD PTR [edi+24], -1073741565 ; c0000103H
; 166 : Irp->IoStatus.Information = 0;
001fa 89 5f 1c mov DWORD PTR [edi+28], ebx
; 167 :
; 168 : SerialDump(
; 169 : SERIRPPATH,
; 170 : ("SERIAL: Complete Irp: %x\n",Irp)
; 171 : );
001fd f6 05 00 00 00
00 20 test BYTE PTR _SerialDebugLevel, 32 ; 00000020H
00204 74 0d je SHORT $L14876
00206 57 push edi
00207 68 00 00 00 00 push OFFSET FLAT:$SG14881
0020c e8 00 00 00 00 call _DbgPrint
00211 59 pop ecx
00212 59 pop ecx
$L14876:
; 172 :
; 173 :
; 174 :
; 175 : InterlockedDecrement(&extension->OpenCount);
00213 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
00219 ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedDecrement@4
0021f bb 03 01 00 c0 mov ebx, -1073741565 ; c0000103H
00224 e9 24 02 00 00 jmp $L15318
$L14873:
; 176 : SerialCompleteRequest(extension, Irp, IO_NO_INCREMENT);
; 177 :
; 178 : return STATUS_NOT_A_DIRECTORY;
; 179 :
; 180 : }
; 181 :
; 182 : //
; 183 : // Create a buffer for the RX data when no reads are outstanding.
; 184 : //
; 185 :
; 186 : extension->InterruptReadBuffer = NULL;
00229 89 9e e8 00 00
00 mov DWORD PTR [esi+232], ebx
; 187 : extension->BufferSize = 0;
0022f 89 9e 04 01 00
00 mov DWORD PTR [esi+260], ebx
; 188 :
; 189 : switch (MmQuerySystemSize()) {
00235 ff 15 00 00 00
00 call DWORD PTR __imp__MmQuerySystemSize@0
0023b 2b c3 sub eax, ebx
0023d 74 4a je SHORT $L14897
0023f 48 dec eax
00240 74 25 je SHORT $L14895
00242 48 dec eax
00243 75 62 jne SHORT $L14891
; 190 :
; 191 : case MmLargeSystem: {
; 192 :
; 193 : extension->BufferSize = 4096;
00245 b8 00 10 00 00 mov eax, 4096 ; 00001000H
; 194 : extension->InterruptReadBuffer = ExAllocatePool(
; 195 : NonPagedPool,
; 196 : extension->BufferSize
; 197 : );
0024a 68 43 4f 4d 58 push 1481461571 ; 584d4f43H
0024f 50 push eax
00250 53 push ebx
00251 89 86 04 01 00
00 mov DWORD PTR [esi+260], eax
00257 ff 15 00 00 00
00 call DWORD PTR __imp__ExAllocatePoolWithTag@12
; 198 :
; 199 : if (extension->InterruptReadBuffer) {
0025d 3b c3 cmp eax, ebx
0025f 89 86 e8 00 00
00 mov DWORD PTR [esi+232], eax
00265 75 40 jne SHORT $L14891
$L14895:
; 200 :
; 201 : break;
; 202 :
; 203 : }
; 204 :
; 205 : }
; 206 :
; 207 : case MmMediumSystem: {
; 208 :
; 209 : extension->BufferSize = 1024;
00267 b8 00 04 00 00 mov eax, 1024 ; 00000400H
; 210 : extension->InterruptReadBuffer = ExAllocatePool(
; 211 : NonPagedPool,
; 212 : extension->BufferSize
; 213 : );
0026c 68 43 4f 4d 58 push 1481461571 ; 584d4f43H
00271 50 push eax
00272 53 push ebx
00273 89 86 04 01 00
00 mov DWORD PTR [esi+260], eax
00279 ff 15 00 00 00
00 call DWORD PTR __imp__ExAllocatePoolWithTag@12
; 214 :
; 215 : if (extension->InterruptReadBuffer) {
0027f 3b c3 cmp eax, ebx
00281 89 86 e8 00 00
00 mov DWORD PTR [esi+232], eax
00287 75 1e jne SHORT $L14891
$L14897:
; 216 :
; 217 : break;
; 218 :
; 219 : }
; 220 :
; 221 : }
; 222 :
; 223 : case MmSmallSystem: {
; 224 :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -