📄 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: /Ogsy
; 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 __imp_@InterlockedDecrement@4: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 _SerialGlobals:BYTE
EXTRN __imp_@IofCompleteRequest@8:NEAR
EXTRN __imp__MmQuerySystemSize@0:NEAR
EXTRN _SerialClearStats@4:NEAR
; Function compile flags: /Ogsy
; COMDAT _SerialCreateOpen@8
PAGESRP0 SEGMENT
_DeviceObject$ = 8
_Irp$ = 12
_checkOpen$ = -8
_localStatus$ = 12
_SerialCreateOpen@8 PROC NEAR ; COMDAT
; 113 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 51 push ecx
00004 51 push ecx
; 114 :
; 115 : PSERIAL_DEVICE_EXTENSION extension = DeviceObject->DeviceExtension;
00005 8b 45 08 mov eax, DWORD PTR _DeviceObject$[ebp]
00008 56 push esi
00009 8b 70 28 mov esi, DWORD PTR [eax+40]
; 116 : SERIAL_CHECK_OPEN checkOpen;
; 117 : NTSTATUS localStatus;
; 118 :
; 119 : PAGED_CODE();
; 120 :
; 121 : if (extension->PNPState != SERIAL_PNP_STARTED) {
0000c 83 be e0 04 00
00 01 cmp DWORD PTR [esi+1248], 1
00013 74 1a je SHORT $L14795
; 122 : Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
00015 8b 4d 0c mov ecx, DWORD PTR _Irp$[ebp]
00018 be 9a 00 00 c0 mov esi, -1073741670 ; c000009aH
; 123 : IoCompleteRequest(Irp, IO_NO_INCREMENT);
0001d 32 d2 xor dl, dl
0001f 89 71 18 mov DWORD PTR [ecx+24], esi
00022 ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
; 124 : return STATUS_INSUFFICIENT_RESOURCES;
00028 8b c6 mov eax, esi
0002a e9 b1 02 00 00 jmp $L14791
$L14795:
0002f 53 push ebx
00030 57 push edi
; 125 : }
; 126 :
; 127 : //
; 128 : // Lock out changes to PnP state until we have our open state decided
; 129 : //
; 130 :
; 131 : ExAcquireFastMutex(&extension->OpenMutex);
00031 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
00037 ff 15 00 00 00
00 call DWORD PTR __imp_@ExAcquireFastMutex@4
; 132 :
; 133 : if ((localStatus = SerialIRPPrologue(Irp, extension)) != STATUS_SUCCESS) {
0003d 8b 7d 0c mov edi, DWORD PTR _Irp$[ebp]
00040 56 push esi
00041 57 push edi
00042 e8 00 00 00 00 call _SerialIRPPrologue@8
00047 33 db xor ebx, ebx
00049 89 45 0c mov DWORD PTR _localStatus$[ebp], eax
0004c 3b c3 cmp eax, ebx
0004e 74 11 je SHORT $L14799
; 134 : ExReleaseFastMutex(&extension->OpenMutex);
00050 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
00056 ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
0005c e9 68 02 00 00 jmp $L14843
$L14799:
; 135 : SerialCompleteRequest(extension, Irp, IO_NO_INCREMENT);
; 136 : return localStatus;
; 137 : }
; 138 :
; 139 : if (InterlockedIncrement(&extension->OpenCount) != 1) {
00061 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
00067 ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedIncrement@4
0006d 83 f8 01 cmp eax, 1
00070 74 27 je SHORT $L14803
; 140 : ExReleaseFastMutex(&extension->OpenMutex);
00072 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
00078 ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
; 141 : InterlockedDecrement(&extension->OpenCount);
0007e 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
00084 ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedDecrement@4
; 142 : Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
0008a b8 22 00 00 c0 mov eax, -1073741790 ; c0000022H
0008f 89 47 18 mov DWORD PTR [edi+24], eax
00092 8b d8 mov ebx, eax
00094 e9 33 02 00 00 jmp $L15092
$L14803:
; 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 : );
; 151 : SerialDump(
; 152 : SERDIAG3,
; 153 : ("SERIAL: In SerialCreateOpen\n")
; 154 : );
; 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) {
00099 8b 47 60 mov eax, DWORD PTR [edi+96]
0009c f6 40 08 01 test BYTE PTR [eax+8], 1
000a0 74 2c je SHORT $L14809
; 163 : ExReleaseFastMutex(&extension->OpenMutex);
000a2 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
000a8 ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
; 164 :
; 165 : Irp->IoStatus.Status = STATUS_NOT_A_DIRECTORY;
; 166 : Irp->IoStatus.Information = 0;
; 167 :
; 168 : SerialDump(
; 169 : SERIRPPATH,
; 170 : ("SERIAL: Complete Irp: %x\n",Irp)
; 171 : );
; 172 :
; 173 :
; 174 :
; 175 : InterlockedDecrement(&extension->OpenCount);
000ae 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
000b4 c7 47 18 03 01
00 c0 mov DWORD PTR [edi+24], -1073741565 ; c0000103H
000bb 89 5f 1c mov DWORD PTR [edi+28], ebx
000be ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedDecrement@4
000c4 bb 03 01 00 c0 mov ebx, -1073741565 ; c0000103H
000c9 e9 fe 01 00 00 jmp $L15092
$L14809:
; 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;
000ce 89 9e e8 00 00
00 mov DWORD PTR [esi+232], ebx
; 187 : extension->BufferSize = 0;
000d4 89 9e 04 01 00
00 mov DWORD PTR [esi+260], ebx
; 188 :
; 189 : switch (MmQuerySystemSize()) {
000da ff 15 00 00 00
00 call DWORD PTR __imp__MmQuerySystemSize@0
000e0 2b c3 sub eax, ebx
000e2 74 4a je SHORT $L14823
000e4 48 dec eax
000e5 74 25 je SHORT $L14821
000e7 48 dec eax
000e8 75 62 jne SHORT $L14817
; 190 :
; 191 : case MmLargeSystem: {
; 192 :
; 193 : extension->BufferSize = 4096;
000ea b8 00 10 00 00 mov eax, 4096 ; 00001000H
; 194 : extension->InterruptReadBuffer = ExAllocatePool(
; 195 : NonPagedPool,
; 196 : extension->BufferSize
; 197 : );
000ef 68 43 4f 4d 58 push 1481461571 ; 584d4f43H
000f4 50 push eax
000f5 53 push ebx
000f6 89 86 04 01 00
00 mov DWORD PTR [esi+260], eax
000fc ff 15 00 00 00
00 call DWORD PTR __imp__ExAllocatePoolWithTag@12
; 198 :
; 199 : if (extension->InterruptReadBuffer) {
00102 3b c3 cmp eax, ebx
00104 89 86 e8 00 00
00 mov DWORD PTR [esi+232], eax
0010a 75 40 jne SHORT $L14817
$L14821:
; 200 :
; 201 : break;
; 202 :
; 203 : }
; 204 :
; 205 : }
; 206 :
; 207 : case MmMediumSystem: {
; 208 :
; 209 : extension->BufferSize = 1024;
0010c b8 00 04 00 00 mov eax, 1024 ; 00000400H
; 210 : extension->InterruptReadBuffer = ExAllocatePool(
; 211 : NonPagedPool,
; 212 : extension->BufferSize
; 213 : );
00111 68 43 4f 4d 58 push 1481461571 ; 584d4f43H
00116 50 push eax
00117 53 push ebx
00118 89 86 04 01 00
00 mov DWORD PTR [esi+260], eax
0011e ff 15 00 00 00
00 call DWORD PTR __imp__ExAllocatePoolWithTag@12
; 214 :
; 215 : if (extension->InterruptReadBuffer) {
00124 3b c3 cmp eax, ebx
00126 89 86 e8 00 00
00 mov DWORD PTR [esi+232], eax
0012c 75 1e jne SHORT $L14817
$L14823:
; 216 :
; 217 : break;
; 218 :
; 219 : }
; 220 :
; 221 : }
; 222 :
; 223 : case MmSmallSystem: {
; 224 :
; 225 : extension->BufferSize = 128;
0012e b8 80 00 00 00 mov eax, 128 ; 00000080H
; 226 : extension->InterruptReadBuffer = ExAllocatePool(
; 227 : NonPagedPool,
; 228 : extension->BufferSize
; 229 : );
00133 68 43 4f 4d 58 push 1481461571 ; 584d4f43H
00138 50 push eax
00139 53 push ebx
0013a 89 86 04 01 00
00 mov DWORD PTR [esi+260], eax
00140 ff 15 00 00 00
00 call DWORD PTR __imp__ExAllocatePoolWithTag@12
00146 89 86 e8 00 00
00 mov DWORD PTR [esi+232], eax
$L14817:
; 230 :
; 231 : }
; 232 :
; 233 : }
; 234 :
; 235 : if (!extension->InterruptReadBuffer) {
0014c 39 9e e8 00 00
00 cmp DWORD PTR [esi+232], ebx
00152 75 32 jne SHORT $L14825
; 236 : ExReleaseFastMutex(&extension->OpenMutex);
00154 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
0015a ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
; 237 :
; 238 : extension->BufferSize = 0;
00160 89 9e 04 01 00
00 mov DWORD PTR [esi+260], ebx
; 239 : Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
; 240 : Irp->IoStatus.Information = 0;
; 241 :
; 242 : SerialDump(
; 243 : SERIRPPATH,
; 244 : ("SERIAL: Complete Irp: %x\n",Irp)
; 245 : );
; 246 :
; 247 : InterlockedDecrement(&extension->OpenCount);
00166 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
0016c c7 47 18 9a 00
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -