📄 openclos.cod
字号:
; 225 : extension->BufferSize = 128;
00289 b8 80 00 00 00 mov eax, 128 ; 00000080H
; 226 : extension->InterruptReadBuffer = ExAllocatePool(
; 227 : NonPagedPool,
; 228 : extension->BufferSize
; 229 : );
0028e 68 43 4f 4d 58 push 1481461571 ; 584d4f43H
00293 50 push eax
00294 53 push ebx
00295 89 86 04 01 00
00 mov DWORD PTR [esi+260], eax
0029b ff 15 00 00 00
00 call DWORD PTR __imp__ExAllocatePoolWithTag@12
002a1 89 86 e8 00 00
00 mov DWORD PTR [esi+232], eax
$L14891:
; 230 :
; 231 : }
; 232 :
; 233 : }
; 234 :
; 235 : if (!extension->InterruptReadBuffer) {
002a7 39 9e e8 00 00
00 cmp DWORD PTR [esi+232], ebx
002ad 75 48 jne SHORT $L14899
; 236 : ExReleaseFastMutex(&extension->OpenMutex);
002af 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
002b5 ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
; 237 :
; 238 : extension->BufferSize = 0;
002bb 89 9e 04 01 00
00 mov DWORD PTR [esi+260], ebx
; 239 : Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
002c1 c7 47 18 9a 00
00 c0 mov DWORD PTR [edi+24], -1073741670 ; c000009aH
; 240 : Irp->IoStatus.Information = 0;
002c8 89 5f 1c mov DWORD PTR [edi+28], ebx
; 241 :
; 242 : SerialDump(
; 243 : SERIRPPATH,
; 244 : ("SERIAL: Complete Irp: %x\n",Irp)
; 245 : );
002cb f6 05 00 00 00
00 20 test BYTE PTR _SerialDebugLevel, 32 ; 00000020H
002d2 74 0d je SHORT $L14902
002d4 57 push edi
002d5 68 00 00 00 00 push OFFSET FLAT:$SG14907
002da e8 00 00 00 00 call _DbgPrint
002df 59 pop ecx
002e0 59 pop ecx
$L14902:
; 246 :
; 247 : InterlockedDecrement(&extension->OpenCount);
002e1 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
002e7 ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedDecrement@4
002ed bb 9a 00 00 c0 mov ebx, -1073741670 ; c000009aH
002f2 e9 56 01 00 00 jmp $L15318
$L14899:
; 248 : SerialCompleteRequest(extension, Irp, IO_NO_INCREMENT);
; 249 :
; 250 : return STATUS_INSUFFICIENT_RESOURCES;
; 251 :
; 252 : }
; 253 :
; 254 : //
; 255 : // Ok, it looks like we really are going to open. Lock down the
; 256 : // driver.
; 257 : //
; 258 : SerialLockPagableSectionByHandle(SerialGlobals.PAGESER_Handle);
002f7 ff 35 08 00 00
00 push DWORD PTR _SerialGlobals+8
002fd ff 15 00 00 00
00 call DWORD PTR __imp__MmLockPagableSectionByHandle@4
00303 b9 14 00 00 00 mov ecx, OFFSET FLAT:_SerialGlobals+20
00308 ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedIncrement@4
; 259 :
; 260 : //
; 261 : // Power up the stack
; 262 : //
; 263 :
; 264 : (void)SerialGotoPowerState(DeviceObject, extension, PowerDeviceD0);
0030e 6a 01 push 1
00310 56 push esi
00311 ff 75 08 push DWORD PTR _DeviceObject$[ebp]
00314 e8 00 00 00 00 call _SerialGotoPowerState@12
; 265 :
; 266 : //
; 267 : // Not currently waiting for wake up
; 268 : //
; 269 :
; 270 : extension->SendWaitWake = FALSE;
; 271 :
; 272 : //
; 273 : // On a new open we "flush" the read queue by initializing the
; 274 : // count of characters.
; 275 : //
; 276 :
; 277 : extension->CharsInInterruptBuffer = 0;
; 278 : extension->LastCharSlot = extension->InterruptReadBuffer +
; 279 : (extension->BufferSize - 1);
00319 8b 86 04 01 00
00 mov eax, DWORD PTR [esi+260]
0031f 8b 8e e8 00 00
00 mov ecx, DWORD PTR [esi+232]
; 280 :
; 281 : extension->ReadBufferBase = extension->InterruptReadBuffer;
00325 89 8e ec 00 00
00 mov DWORD PTR [esi+236], ecx
; 282 : extension->CurrentCharSlot = extension->InterruptReadBuffer;
0032b 89 8e f4 00 00
00 mov DWORD PTR [esi+244], ecx
00331 8d 54 01 ff lea edx, DWORD PTR [ecx+eax-1]
; 283 : extension->FirstReadableChar = extension->InterruptReadBuffer;
00335 89 8e fc 00 00
00 mov DWORD PTR [esi+252], ecx
; 284 :
; 285 : extension->TotalCharsQueued = 0;
; 286 :
; 287 : //
; 288 : // We set up the default xon/xoff limits.
; 289 : //
; 290 :
; 291 : extension->HandFlow.XoffLimit = extension->BufferSize >> 3;
0033b 8b c8 mov ecx, eax
0033d 89 96 f8 00 00
00 mov DWORD PTR [esi+248], edx
00343 c1 e9 03 shr ecx, 3
00346 89 8e 80 01 00
00 mov DWORD PTR [esi+384], ecx
; 292 : extension->HandFlow.XonLimit = extension->BufferSize >> 1;
; 293 :
; 294 : extension->WmiCommData.XoffXmitThreshold = extension->HandFlow.XoffLimit;
0034c 89 8e cc 05 00
00 mov DWORD PTR [esi+1484], ecx
; 295 : extension->WmiCommData.XonXmitThreshold = extension->HandFlow.XonLimit;
; 296 :
; 297 : extension->BufferSizePt8 = ((3*(extension->BufferSize>>2))+
; 298 : (extension->BufferSize>>4));
00352 8b c8 mov ecx, eax
00354 8b d0 mov edx, eax
00356 c1 e9 02 shr ecx, 2
00359 c1 e8 04 shr eax, 4
0035c 8d 0c 49 lea ecx, DWORD PTR [ecx+ecx*2]
0035f 88 9e 84 05 00
00 mov BYTE PTR [esi+1412], bl
00365 d1 ea shr edx, 1
00367 03 c8 add ecx, eax
; 299 :
; 300 : //
; 301 : // Mark the device as busy for WMI
; 302 : //
; 303 :
; 304 : extension->WmiCommData.IsBusy = TRUE;
; 305 :
; 306 : extension->IrpMaskLocation = NULL;
; 307 : extension->HistoryMask = 0;
; 308 : extension->IsrWaitMask = 0;
; 309 :
; 310 : extension->SendXonChar = FALSE;
; 311 : extension->SendXoffChar = FALSE;
; 312 :
; 313 : #if !DBG
; 314 : //
; 315 : // Clear out the statistics.
; 316 : //
; 317 :
; 318 : KeSynchronizeExecution(
; 319 : extension->Interrupt,
; 320 : SerialClearStats,
; 321 : extension
; 322 : );
; 323 : #endif
; 324 :
; 325 : //
; 326 : // The escape char replacement must be reset upon every open.
; 327 : //
; 328 :
; 329 : extension->EscapeChar = 0;
; 330 :
; 331 : if (!extension->PermitShare) {
00369 39 9e 54 01 00
00 cmp DWORD PTR [esi+340], ebx
0036f 89 9e f0 00 00
00 mov DWORD PTR [esi+240], ebx
00375 89 9e 28 01 00
00 mov DWORD PTR [esi+296], ebx
0037b 89 96 7c 01 00
00 mov DWORD PTR [esi+380], edx
00381 89 96 d4 05 00
00 mov DWORD PTR [esi+1492], edx
00387 89 8e 08 01 00
00 mov DWORD PTR [esi+264], ecx
0038d c6 86 f0 05 00
00 01 mov BYTE PTR [esi+1520], 1
00394 89 9e 18 01 00
00 mov DWORD PTR [esi+280], ebx
0039a 89 9e 14 01 00
00 mov DWORD PTR [esi+276], ebx
003a0 89 9e 10 01 00
00 mov DWORD PTR [esi+272], ebx
003a6 88 9e db 01 00
00 mov BYTE PTR [esi+475], bl
003ac 88 9e dc 01 00
00 mov BYTE PTR [esi+476], bl
003b2 88 9e da 01 00
00 mov BYTE PTR [esi+474], bl
003b8 75 28 jne SHORT $L14917
; 332 :
; 333 : if (!extension->InterruptShareable) {
003ba 38 9e e0 01 00
00 cmp BYTE PTR [esi+480], bl
003c0 75 20 jne SHORT $L14917
; 334 :
; 335 : checkOpen.Extension = extension;
; 336 : checkOpen.StatusOfOpen = &Irp->IoStatus.Status;
003c2 8d 47 18 lea eax, DWORD PTR [edi+24]
003c5 89 75 f8 mov DWORD PTR _checkOpen$[ebp], esi
003c8 89 45 fc mov DWORD PTR _checkOpen$[ebp+4], eax
; 337 :
; 338 : KeSynchronizeExecution(
; 339 : extension->Interrupt,
; 340 : SerialCheckOpen,
; 341 : &checkOpen
; 342 : );
003cb 8d 45 f8 lea eax, DWORD PTR _checkOpen$[ebp]
003ce 50 push eax
003cf 68 00 00 00 00 push OFFSET FLAT:_SerialCheckOpen@4
003d4 ff b6 a0 00 00
00 push DWORD PTR [esi+160]
003da ff 15 00 00 00
00 call DWORD PTR __imp__KeSynchronizeExecution@12
; 343 :
; 344 : } else {
003e0 eb 15 jmp SHORT $L14921
$L14917:
; 345 :
; 346 : KeSynchronizeExecution(
; 347 : extension->Interrupt,
; 348 : SerialMarkOpen,
; 349 : extension
; 350 : );
; 351 :
; 352 : Irp->IoStatus.Status = STATUS_SUCCESS;
; 353 :
; 354 : }
; 355 :
; 356 : } else {
; 357 :
; 358 : //
; 359 : // Synchronize with the ISR and let it know that the device
; 360 : // has been successfully opened.
; 361 : //
; 362 :
; 363 : KeSynchronizeExecution(
; 364 : extension->Interrupt,
; 365 : SerialMarkOpen,
; 366 : extension
; 367 : );
003e2 56 push esi
003e3 68 00 00 00 00 push OFFSET FLAT:_SerialMarkOpen@4
003e8 ff b6 a0 00 00
00 push DWORD PTR [esi+160]
003ee ff 15 00 00 00
00 call DWORD PTR __imp__KeSynchronizeExecution@12
; 368 :
; 369 : Irp->IoStatus.Status = STATUS_SUCCESS;
003f4 89 5f 18 mov DWORD PTR [edi+24], ebx
$L14921:
; 370 :
; 371 : }
; 372 :
; 373 : //
; 374 : // We have been marked open, so now the PnP state can change
; 375 : //
; 376 :
; 377 : ExReleaseFastMutex(&extension->OpenMutex);
003f7 8d 8e 34 05 00
00 lea ecx, DWORD PTR [esi+1332]
003fd ff 15 00 00 00
00 call DWORD PTR __imp_@ExReleaseFastMutex@4
; 378 :
; 379 : localStatus = Irp->IoStatus.Status;
00403 8b 47 18 mov eax, DWORD PTR [edi+24]
; 380 : Irp->IoStatus.Information=0L;
00406 89 5f 1c mov DWORD PTR [edi+28], ebx
; 381 :
; 382 : SerialDump(
; 383 : SERIRPPATH,
; 384 : ("SERIAL: Complete Irp: %x\n",Irp)
; 385 : );
00409 f6 05 00 00 00
00 20 test BYTE PTR _SerialDebugLevel, 32 ; 00000020H
00410 89 45 0c mov DWORD PTR _localStatus$[ebp], eax
00413 74 0d je SHORT $L14924
00415 57 push edi
00416 68 00 00 00 00 push OFFSET FLAT:$SG14929
0041b e8 00 00 00 00 call _DbgPrint
00420 59 pop ecx
00421 59 pop ecx
$L14924:
; 386 :
; 387 : if (!NT_SUCCESS(localStatus)) {
00422 39 5d 0c cmp DWORD PTR _localStatus$[ebp], ebx
00425 7d 23 jge SHORT $L14937
; 388 : if (extension->InterruptReadBuffer != NULL) {
00427 8b 86 e8 00 00
00 mov eax, DWORD PTR [esi+232]
0042d 3b c3 cmp eax, ebx
0042f 74 0d je SHORT $L14939
; 389 : ExFreePool(extension->InterruptReadBuffer);
00431 50 push eax
00432 ff 15 00 00 00
00 call DWORD PTR __imp__ExFreePool@4
; 390 : extension->InterruptReadBuffer = NULL;
00438 89 9e e8 00 00
00 mov DWORD PTR [esi+232], ebx
$L14939:
; 391 : }
; 392 :
; 393 : InterlockedDecrement(&extension->OpenCount);
0043e 8d 8e e8 04 00
00 lea ecx, DWORD PTR [esi+1256]
00444 ff 15 00 00 00
00 call DWORD PTR __imp_@InterlockedDecrement@4
$L14937:
0044a 8b 5d 0c mov ebx, DWORD PTR _localStatus$[ebp]
$L15318:
; 394 : }
; 395 :
; 396 : SerialCompleteRequest(extension, Irp, IO_NO_INCREMENT);
0044d 32 d2 xor dl, dl
0044f 8b cf mov ecx, edi
00451 ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
00457 56 push esi
00458 e8 00 00 00 00 call _SerialIRPEpilogue@4
; 397 :
; 398 : return localStatus;
0045d 8b c3 mov eax, ebx
$L14829:
0045f 5f pop edi
00460 5e pop esi
00461 5b pop ebx
; 399 :
; 400 : }
00462 c9 leave
00463 c2 08 00 ret 8
_SerialCreateOpen@8 ENDP
PAGESRP0 ENDS
PUBLIC _SerialDrainUART@8
EXTRN __imp__KeDelayExecutionThread@12:NEAR
EXTRN __imp__READ_PORT_UCHAR@4:NEAR
; COMDAT _SerialDrainUART@8
PAGESRP0 SEGMENT
$SG14947 DB 'EX: Pageable code called at IRQL %d', 0aH, 00H
ORG $+3
$SG14950 DB 'f:\w2ddk\src\kernel\serial\openclos.c', 00H
ORG $+2
$SG14951 DB 'FALSE', 00H
; Function compile flags: /Ogs
_PDevExt$ = 8
_PDrainTime$ = 12
_SerialDrainUART@8 PROC NEAR ; COMDAT
; 405 : {
00056 55 push ebp
00057 8b ec mov ebp, esp
00059 56 push esi
; 406 : PAGED_CODE();
0005a 8b 35 00 00 00
00 mov esi, DWORD PTR __imp__KeGetCurrentIrql@0
00060 57 push edi
00061 ff d6 call esi
00063 3c 01 cmp al, 1
00065 76 29 jbe SHORT $L15322
00067 ff d6 call esi
00069 0f b6 c0 movzx eax, al
0006c 50 push eax
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -