📄 power.cod
字号:
; 350 :
; 351 : default:
; 352 : status = STATUS_SUCCESS;
; 353 : goto PowerExit;
; 354 : break;
; 355 : }
; 356 :
; 357 :
; 358 : status = STATUS_SUCCESS;
; 359 :
; 360 : PoSetPowerState(PDevObj, pIrpStack->Parameters.Power.Type,
; 361 : pIrpStack->Parameters.Power.State);
00142 ff 73 0c push DWORD PTR [ebx+12]
00145 52 push edx
00146 ff 75 08 push DWORD PTR _PDevObj$[ebp]
00149 ff 15 00 00 00
00 call DWORD PTR __imp__PoSetPowerState@12
; 362 :
; 363 : //
; 364 : // Send IRP to change device state if we should change
; 365 : //
; 366 :
; 367 : //
; 368 : // We only power up the stack if the device is open. This is based
; 369 : // on our policy of keeping the device powered down unless it is
; 370 : // open.
; 371 : //
; 372 :
; 373 : if (((powerState.DeviceState < pDevExt->PowerState)
; 374 : && pDevExt->OpenCount)) {
0014f 8b 86 a4 04 00
00 mov eax, DWORD PTR [esi+1188]
00155 8b 4d 0c mov ecx, DWORD PTR _powerState$14918[ebp]
00158 33 d2 xor edx, edx
0015a 3b c8 cmp ecx, eax
0015c 7d 0c jge SHORT $L15177
0015e 39 96 e8 04 00
00 cmp DWORD PTR [esi+1256], edx
; 375 : PoRequestPowerIrp(pPdo, IRP_MN_SET_POWER, powerState, NULL, NULL,
; 376 : NULL);
; 377 : }else {
00164 75 1d jne SHORT $L14943
; 378 : //
; 379 : // If powering down, we can't go past wake state
; 380 : // if wait-wake pending
; 381 : //
; 382 :
; 383 : if (powerState.DeviceState >= pDevExt->PowerState) {
00166 3b c8 cmp ecx, eax
00168 7c 28 jl SHORT $PowerExit$14924
$L15177:
; 384 :
; 385 : //
; 386 : // Power down -- ensure there is no wake-wait pending OR
; 387 : // we can do down to that level and still wake the machine
; 388 : //
; 389 :
; 390 : if ((pDevExt->PendingWakeIrp == NULL && !pDevExt->SendWaitWake)
; 391 : || powerState.DeviceState <= pDevExt->DeviceWake) {
0016a 39 96 88 05 00
00 cmp DWORD PTR [esi+1416], edx
00170 75 09 jne SHORT $L14944
00172 80 be 84 05 00
00 00 cmp BYTE PTR [esi+1412], 0
00179 74 08 je SHORT $L14943
$L14944:
0017b 3b 8e 7c 05 00
00 cmp ecx, DWORD PTR [esi+1404]
00181 7f 0f jg SHORT $PowerExit$14924
$L14943:
; 392 : PoRequestPowerIrp(pPdo, IRP_MN_SET_POWER, powerState, NULL,
; 393 : NULL, NULL);
00183 52 push edx
00184 52 push edx
00185 52 push edx
00186 51 push ecx
00187 6a 02 push 2
00189 ff 75 fc push DWORD PTR _pPdo$[ebp]
0018c ff 15 00 00 00
00 call DWORD PTR __imp__PoRequestPowerIrp@24
$PowerExit$14924:
; 480 :
; 481 : } // switch (pIrpStack->MinorFunction)
; 482 :
; 483 :
; 484 : PowerExit:;
; 485 :
; 486 : PoStartNextPowerIrp(PIrp);
00192 57 push edi
00193 ff 15 00 00 00
00 call DWORD PTR __imp__PoStartNextPowerIrp@4
; 487 :
; 488 :
; 489 : //
; 490 : // Pass to the lower driver
; 491 : //
; 492 : IoSkipCurrentIrpStackLocation(PIrp);
00199 83 47 60 24 add DWORD PTR [edi+96], 36 ; 00000024H
0019d fe 47 23 inc BYTE PTR [edi+35]
; 493 : status = SerialPoCallDriver(pDevExt, pLowerDevObj, PIrp);
001a0 57 push edi
001a1 ff 75 f8 push DWORD PTR _pLowerDevObj$[ebp]
001a4 56 push esi
001a5 e8 00 00 00 00 call _SerialPoCallDriver@12
$L14887:
001aa 5f pop edi
001ab 5e pop esi
001ac 5b pop ebx
; 494 :
; 495 : return status;
; 496 : }
001ad c9 leave
001ae c2 08 00 ret 8
_SerialPowerDispatch@8 ENDP
PAGESRP0 ENDS
EXTRN __imp__KeClearEvent@4:NEAR
EXTRN __imp__KeWaitForSingleObject@20:NEAR
EXTRN _SerialSyncCompletion@12:NEAR
EXTRN __imp__PoCallDriver@8:NEAR
; Function compile flags: /Ogsy
; COMDAT _SerialSetPowerD0@8
PAGESRP0 SEGMENT
_PDevObj$ = 8
_PIrp$ = 12
_pDevExt$ = -4
_pIrpStack$ = -8
_status$ = 12
_SerialSetPowerD0@8 PROC NEAR ; COMDAT
; 527 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 51 push ecx
00004 51 push ecx
; 528 : PSERIAL_DEVICE_EXTENSION pDevExt = PDevObj->DeviceExtension;
00005 8b 45 08 mov eax, DWORD PTR _PDevObj$[ebp]
00008 53 push ebx
; 529 : PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(PIrp);
00009 8b 5d 0c mov ebx, DWORD PTR _PIrp$[ebp]
0000c 56 push esi
0000d 8b 40 28 mov eax, DWORD PTR [eax+40]
00010 57 push edi
00011 8b 4b 60 mov ecx, DWORD PTR [ebx+96]
00014 89 45 fc mov DWORD PTR _pDevExt$[ebp], eax
; 530 : NTSTATUS status;
; 531 :
; 532 : PAGED_CODE();
; 533 :
; 534 : SerialDump(SERTRACECALLS, ("SERIAL: In SerialSetPowerD0\n"));
; 535 : SerialDump(SERPNPPOWER, ("SERIAL: SetPowerD0 has IRP %x\n", PIrp));
; 536 :
; 537 : ASSERT(pDevExt->LowerDeviceObject);
; 538 :
; 539 : //
; 540 : // Set up completion to init device when it is on
; 541 : //
; 542 :
; 543 : KeClearEvent(&pDevExt->PowerD0Event);
00017 05 1c 05 00 00 add eax, 1308 ; 0000051cH
0001c 89 4d f8 mov DWORD PTR _pIrpStack$[ebp], ecx
0001f 50 push eax
00020 ff 15 00 00 00
00 call DWORD PTR __imp__KeClearEvent@4
; 544 :
; 545 :
; 546 : IoCopyCurrentIrpStackLocationToNext(PIrp);
00026 8b 73 60 mov esi, DWORD PTR [ebx+96]
00029 6a 07 push 7
0002b 59 pop ecx
0002c 8d 46 dc lea eax, DWORD PTR [esi-36]
; 547 : IoSetCompletionRoutine(PIrp, SerialSyncCompletion, &pDevExt->PowerD0Event,
; 548 : TRUE, TRUE, TRUE);
; 549 :
; 550 : SerialDump(SERPNPPOWER, ("SERIAL: Calling next driver\n"));
; 551 :
; 552 : status = PoCallDriver(pDevExt->LowerDeviceObject, PIrp);
0002f 53 push ebx
00030 8b f8 mov edi, eax
00032 f3 a5 rep movsd
00034 80 60 03 00 and BYTE PTR [eax+3], 0
00038 8b 43 60 mov eax, DWORD PTR [ebx+96]
0003b 8b 4d fc mov ecx, DWORD PTR _pDevExt$[ebp]
0003e 83 e8 24 sub eax, 36 ; 00000024H
00041 8b f9 mov edi, ecx
00043 8d b1 1c 05 00
00 lea esi, DWORD PTR [ecx+1308]
00049 c7 40 1c 00 00
00 00 mov DWORD PTR [eax+28], OFFSET FLAT:_SerialSyncCompletion@12
00050 89 70 20 mov DWORD PTR [eax+32], esi
00053 c6 40 03 e0 mov BYTE PTR [eax+3], 224 ; 000000e0H
00057 ff b7 a0 04 00
00 push DWORD PTR [edi+1184]
0005d ff 15 00 00 00
00 call DWORD PTR __imp__PoCallDriver@8
; 553 :
; 554 : if (status == STATUS_PENDING) {
00063 3d 03 01 00 00 cmp eax, 259 ; 00000103H
00068 89 45 0c mov DWORD PTR _status$[ebp], eax
0006b 75 2f jne SHORT $L15015
; 555 : SerialDump(SERPNPPOWER, ("SERIAL: Waiting for next driver\n"));
; 556 : KeWaitForSingleObject (&pDevExt->PowerD0Event, Executive, KernelMode,
; 557 : FALSE, NULL);
0006d 33 c0 xor eax, eax
0006f 50 push eax
00070 50 push eax
00071 50 push eax
00072 50 push eax
00073 56 push esi
00074 ff 15 00 00 00
00 call DWORD PTR __imp__KeWaitForSingleObject@20
$L15022:
; 564 : }
; 565 : }
; 566 :
; 567 : if (!NT_SUCCESS(PIrp->IoStatus.Status)) {
0007a 8b 73 18 mov esi, DWORD PTR [ebx+24]
0007d 85 f6 test esi, esi
0007f 7d 24 jge SHORT $L15024
; 568 : status = PIrp->IoStatus.Status;
; 569 : PoStartNextPowerIrp(PIrp);
00081 53 push ebx
00082 ff 15 00 00 00
00 call DWORD PTR __imp__PoStartNextPowerIrp@4
; 570 : SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);
00088 32 d2 xor dl, dl
0008a 8b cb mov ecx, ebx
0008c ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
00092 57 push edi
00093 e8 00 00 00 00 call _SerialIRPEpilogue@4
; 571 : return status;
00098 8b c6 mov eax, esi
0009a eb 4c jmp SHORT $L14992
$L15015:
; 558 : } else {
; 559 : if (!NT_SUCCESS(status)) {
0009c 85 c0 test eax, eax
0009e 7d da jge SHORT $L15022
; 560 : PIrp->IoStatus.Status = status;
000a0 89 43 18 mov DWORD PTR [ebx+24], eax
; 561 : PoStartNextPowerIrp(PIrp);
; 562 : SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);
; 563 : return status;
000a3 eb 29 jmp SHORT $L15187
$L15024:
; 572 : }
; 573 :
; 574 : //
; 575 : // Restore the device
; 576 : //
; 577 :
; 578 : pDevExt->PowerState = PowerDeviceD0;
000a5 33 c0 xor eax, eax
000a7 40 inc eax
; 579 :
; 580 : //
; 581 : // Theoretically we could change states in the middle of processing
; 582 : // the restore which would result in a bad PKINTERRUPT being used
; 583 : // in SerialRestoreDeviceState().
; 584 : //
; 585 :
; 586 : if (pDevExt->PNPState == SERIAL_PNP_STARTED) {
000a8 39 87 e0 04 00
00 cmp DWORD PTR [edi+1248], eax
000ae 89 87 a4 04 00
00 mov DWORD PTR [edi+1188], eax
000b4 75 06 jne SHORT $L15025
; 587 : SerialRestoreDeviceState(pDevExt);
000b6 57 push edi
000b7 e8 00 00 00 00 call _SerialRestoreDeviceState@4
$L15025:
; 588 : }
; 589 :
; 590 : //
; 591 : // Now that we are powered up, call PoSetPowerState
; 592 : //
; 593 :
; 594 : PoSetPowerState(PDevObj, pIrpStack->Parameters.Power.Type,
; 595 : pIrpStack->Parameters.Power.State);
000bc 8b 45 f8 mov eax, DWORD PTR _pIrpStack$[ebp]
000bf ff 70 0c push DWORD PTR [eax+12]
000c2 ff 70 08 push DWORD PTR [eax+8]
000c5 ff 75 08 push DWORD PTR _PDevObj$[ebp]
000c8 ff 15 00 00 00
00 call DWORD PTR __imp__PoSetPowerState@12
$L15187:
; 596 :
; 597 : PoStartNextPowerIrp(PIrp);
000ce 53 push ebx
000cf ff 15 00 00 00
00 call DWORD PTR __imp__PoStartNextPowerIrp@4
; 598 : SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);
000d5 8b cb mov ecx, ebx
000d7 32 d2 xor dl, dl
000d9 ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
000df 57 push edi
000e0 e8 00 00 00 00 call _SerialIRPEpilogue@4
; 599 :
; 600 :
; 601 : SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialSetPowerD0\n"));
; 602 : return status;
000e5 8b 45 0c mov eax, DWORD PTR _status$[ebp]
$L14992:
000e8 5f pop edi
000e9 5e pop esi
000ea 5b pop ebx
; 603 : }
000eb c9 leave
000ec c2 08 00 ret 8
_SerialSetPowerD0@8 ENDP
PAGESRP0 ENDS
PUBLIC _SerialGotoPowerState@12
EXTRN __imp__KeInitializeEvent@12:NEAR
; Function compile flags: /Ogsy
; COMDAT _SerialGotoPowerState@12
PAGESRP0 SEGMENT
_PDevObj$ = 8
_DevPowerState$ = 16
_gotoPowEvent$ = -16
_SerialGotoPowerState@12 PROC NEAR ; COMDAT
; 631 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 83 ec 10 sub esp, 16 ; 00000010H
00006 56 push esi
; 632 : KEVENT gotoPowEvent;
; 633 : NTSTATUS status;
; 634 : POWER_STATE powerState;
; 635 :
; 636 : PAGED_CODE();
; 637 :
; 638 : SerialDump(SERTRACECALLS, ("SERIAL: In SerialGotoPowerState\n"));
; 639 :
; 640 : powerState.DeviceState = DevPowerState;
; 641 :
; 642 : KeInitializeEvent(&gotoPowEvent, SynchronizationEvent, FALSE);
00007 33 f6 xor esi, esi
00009 56 push esi
0000a 8d 45 f0 lea eax, DWORD PTR _gotoPowEvent$[ebp]
0000d 6a 01 push 1
0000f 50 push eax
00010 ff 15 00 00 00
00 call DWORD PTR __imp__KeInitializeEvent@12
; 643 :
; 644 : status = PoRequestPowerIrp(PDevObj, IRP_MN_SET_POWER, powerState,
; 645 : SerialSystemPowerCompletion, &gotoPowEvent,
; 646 : NULL);
00016 8d 45 f0 lea eax, DWORD PTR _gotoPowEvent$[ebp]
00019 56 push esi
0001a 50 push eax
0001b 68 00 00 00 00 push OFFSET FLAT:_SerialSystemPowerCompletion@20
00020 ff 75 10 push DWORD PTR _DevPowerState$[ebp]
00023 6a 02 push 2
00025 ff 75 08 push DWORD PTR _PDevObj$[ebp]
00028 ff 15 00 00 00
00 call DWORD PTR __imp__PoRequestPowerIrp@24
; 647 :
; 648 : if (status == STATUS_PENDING) {
0002e 3d 03 01 00 00 cmp eax, 259 ; 00000103H
00033 75 10 jne SHORT $L15047
; 649 : KeWaitForSingleObject(&gotoPowEvent, Executive, KernelMode, FALSE, NULL);
00035 56 push esi
00036 56 push esi
00037 56 push esi
00038 8d 45 f0 lea eax, DWORD PTR _gotoPowEvent$[ebp]
0003b 56 push esi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -