⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 power.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 4 页
字号:
  0003c	50		 push	 eax
  0003d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeWaitForSingleObject@20

; 650  :       status = STATUS_SUCCESS;

  00043	33 c0		 xor	 eax, eax
$L15047:
  00045	5e		 pop	 esi

; 651  :    }
; 652  : 
; 653  : #if DBG
; 654  :    if (!NT_SUCCESS(status)) {
; 655  :       SerialDump(SERPNPPOWER, ("SERIAL: SerialGotoPowerState FAILED\n"));
; 656  :    }
; 657  : #endif
; 658  : 
; 659  :    SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialGotoPowerState\n"));
; 660  : 
; 661  :    return status;
; 662  : }

  00046	c9		 leave
  00047	c2 0c 00	 ret	 12			; 0000000cH
_SerialGotoPowerState@12 ENDP
PAGESRP0	ENDS
PUBLIC	_SerialSendWaitWake@4
EXTRN	_SerialDisableUART@4:NEAR
EXTRN	_SerialDrainUART@8:NEAR
EXTRN	_SerialGetCharTime@4:NEAR
; Function compile flags: /Ogsy
;	COMDAT _SerialSetPowerD3@8
PAGESRP0	SEGMENT
_PDevObj$ = 8
_PIrp$ = 12
_charTime$15064 = -8
_SerialSetPowerD3@8 PROC NEAR				; COMDAT

; 687  : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	51		 push	 ecx
  00004	51		 push	 ecx

; 688  :    NTSTATUS status = STATUS_SUCCESS;
; 689  :    PSERIAL_DEVICE_EXTENSION pDevExt = PDevObj->DeviceExtension;

  00005	8b 45 08	 mov	 eax, DWORD PTR _PDevObj$[ebp]
  00008	53		 push	 ebx
  00009	56		 push	 esi
  0000a	57		 push	 edi
  0000b	8b 70 28	 mov	 esi, DWORD PTR [eax+40]

; 690  :    PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(PIrp);

  0000e	8b 7d 0c	 mov	 edi, DWORD PTR _PIrp$[ebp]

; 691  : 
; 692  :    PAGED_CODE();
; 693  : 
; 694  :    SerialDump(SERDIAG3, ("SERIAL: In SerialSetPowerD3\n"));
; 695  : 
; 696  :    //
; 697  :    // Send the wait wake now, just in time
; 698  :    //
; 699  : 
; 700  : 
; 701  :    if (pDevExt->SendWaitWake) {

  00011	80 be 84 05 00
	00 00		 cmp	 BYTE PTR [esi+1412], 0
  00018	8b 5f 60	 mov	 ebx, DWORD PTR [edi+96]
  0001b	74 06		 je	 SHORT $L15062

; 702  :       SerialSendWaitWake(pDevExt);

  0001d	56		 push	 esi
  0001e	e8 00 00 00 00	 call	 _SerialSendWaitWake@4
$L15062:

; 703  :    }
; 704  :    //
; 705  :    // Before we power down, call PoSetPowerState
; 706  :    //
; 707  : 
; 708  :    PoSetPowerState(PDevObj, pIrpStack->Parameters.Power.Type,
; 709  :                    pIrpStack->Parameters.Power.State);

  00023	ff 73 0c	 push	 DWORD PTR [ebx+12]
  00026	ff 73 08	 push	 DWORD PTR [ebx+8]
  00029	ff 75 08	 push	 DWORD PTR _PDevObj$[ebp]
  0002c	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__PoSetPowerState@12

; 710  : 
; 711  :    //
; 712  :    // If the device is not closed, disable interrupts and allow the fifo's
; 713  :    // to flush.
; 714  :    //
; 715  : 
; 716  :    if (pDevExt->DeviceIsOpened == TRUE) {

  00032	8d 86 9d 01 00
	00		 lea	 eax, DWORD PTR [esi+413]
  00038	80 38 01	 cmp	 BYTE PTR [eax], 1
  0003b	75 33		 jne	 SHORT $L15063

; 717  :       LARGE_INTEGER charTime;
; 718  : 
; 719  :       pDevExt->DeviceIsOpened = FALSE;

  0003d	80 20 00	 and	 BYTE PTR [eax], 0

; 720  :       pDevExt->DeviceState.Reopen = TRUE;
; 721  : 
; 722  :       charTime.QuadPart = -SerialGetCharTime(pDevExt).QuadPart;

  00040	56		 push	 esi
  00041	c6 86 fc 04 00
	00 01		 mov	 BYTE PTR [esi+1276], 1
  00048	e8 00 00 00 00	 call	 _SerialGetCharTime@4
  0004d	f7 d8		 neg	 eax
  0004f	83 d2 00	 adc	 edx, 0

; 723  : 
; 724  :       //
; 725  :       // Shut down the chip
; 726  :       //
; 727  : 
; 728  :       SerialDisableUART(pDevExt);

  00052	56		 push	 esi
  00053	f7 da		 neg	 edx
  00055	89 45 f8	 mov	 DWORD PTR _charTime$15064[ebp], eax
  00058	89 55 fc	 mov	 DWORD PTR _charTime$15064[ebp+4], edx
  0005b	e8 00 00 00 00	 call	 _SerialDisableUART@4

; 729  : 
; 730  :       //
; 731  :       // Drain the device
; 732  :       //
; 733  : 
; 734  :       SerialDrainUART(pDevExt, &charTime);

  00060	8d 45 f8	 lea	 eax, DWORD PTR _charTime$15064[ebp]
  00063	50		 push	 eax
  00064	56		 push	 esi
  00065	e8 00 00 00 00	 call	 _SerialDrainUART@8

; 735  : 
; 736  :       //
; 737  :       // Save the device state
; 738  :       //
; 739  : 
; 740  :       SerialSaveDeviceState(pDevExt);

  0006a	56		 push	 esi
  0006b	e8 00 00 00 00	 call	 _SerialSaveDeviceState@4
$L15063:

; 741  :    }
; 742  : 
; 743  :    //
; 744  :    // If the device is not open, we don't need to save the state;
; 745  :    // we can just reset the device on power-up
; 746  :    //
; 747  : 
; 748  : 
; 749  :    PIrp->IoStatus.Status = STATUS_SUCCESS;
; 750  : 
; 751  :    pDevExt->PowerState = PowerDeviceD3;

  00070	c7 86 a4 04 00
	00 04 00 00 00	 mov	 DWORD PTR [esi+1188], 4

; 752  : 
; 753  :    //
; 754  :    // For what we are doing, we don't need a completion routine
; 755  :    // since we don't race on the power requests.
; 756  :    //
; 757  : 
; 758  :    PIrp->IoStatus.Status = STATUS_SUCCESS;

  0007a	83 67 18 00	 and	 DWORD PTR [edi+24], 0

; 759  : 
; 760  :    PoStartNextPowerIrp(PIrp);

  0007e	57		 push	 edi
  0007f	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__PoStartNextPowerIrp@4

; 761  :    IoSkipCurrentIrpStackLocation(PIrp);

  00085	fe 47 23	 inc	 BYTE PTR [edi+35]
  00088	83 47 60 24	 add	 DWORD PTR [edi+96], 36	; 00000024H

; 762  : 
; 763  :    return SerialPoCallDriver(pDevExt, pDevExt->LowerDeviceObject, PIrp);

  0008c	57		 push	 edi
  0008d	ff b6 a0 04 00
	00		 push	 DWORD PTR [esi+1184]
  00093	56		 push	 esi
  00094	e8 00 00 00 00	 call	 _SerialPoCallDriver@12
  00099	5f		 pop	 edi
  0009a	5e		 pop	 esi
  0009b	5b		 pop	 ebx

; 764  : }

  0009c	c9		 leave
  0009d	c2 08 00	 ret	 8
_SerialSetPowerD3@8 ENDP
PAGESRP0	ENDS
PUBLIC	_SerialWakeCompletion@20
EXTRN	__imp_@InterlockedIncrement@4:NEAR
; Function compile flags: /Ogsy
;	COMDAT _SerialSendWaitWake@4
PAGESRP0	SEGMENT
_PDevExt$ = 8
_pIrp$ = 8
_SerialSendWaitWake@4 PROC NEAR				; COMDAT

; 786  : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	56		 push	 esi

; 787  :    NTSTATUS status;
; 788  :    PIRP pIrp;
; 789  :    POWER_STATE powerState;
; 790  : 
; 791  :    PAGED_CODE();
; 792  : 
; 793  :    //
; 794  :    // Make sure one isn't pending already -- serial will only handle one at
; 795  :    // a time.
; 796  :    //
; 797  : 
; 798  :    if (PDevExt->PendingWakeIrp != NULL) {

  00004	8b 75 08	 mov	 esi, DWORD PTR _PDevExt$[ebp]
  00007	83 be 88 05 00
	00 00		 cmp	 DWORD PTR [esi+1416], 0

; 799  :       return STATUS_INVALID_DEVICE_STATE;

  0000e	75 12		 jne	 SHORT $L15202

; 800  :    }
; 801  : 
; 802  :    //
; 803  :    // Make sure we are capable of waking the machine
; 804  :    //
; 805  : 
; 806  :    if (PDevExt->SystemWake <= PowerSystemWorking) {

  00010	83 be 78 05 00
	00 01		 cmp	 DWORD PTR [esi+1400], 1

; 807  :       return STATUS_INVALID_DEVICE_STATE;

  00017	7e 09		 jle	 SHORT $L15202

; 808  :    }
; 809  : 
; 810  :    if (PDevExt->DeviceWake == PowerDeviceUnspecified) {

  00019	83 be 7c 05 00
	00 00		 cmp	 DWORD PTR [esi+1404], 0
  00020	75 07		 jne	 SHORT $L15078
$L15202:

; 811  :       return STATUS_INVALID_DEVICE_STATE;

  00022	b8 84 01 00 c0	 mov	 eax, -1073741436	; c0000184H
  00027	eb 50		 jmp	 SHORT $L15069
$L15078:
  00029	57		 push	 edi

; 812  :    }
; 813  : 
; 814  :    //
; 815  :    // Send IRP to request wait wake and add a pending irp flag
; 816  :    //
; 817  :    //
; 818  : 
; 819  :    InterlockedIncrement(&PDevExt->PendingIRPCnt);

  0002a	8d 8e c8 04 00
	00		 lea	 ecx, DWORD PTR [esi+1224]
  00030	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@InterlockedIncrement@4

; 820  : 
; 821  :    powerState.SystemState = PDevExt->SystemWake;

  00036	8b 86 78 05 00
	00		 mov	 eax, DWORD PTR [esi+1400]

; 822  : 
; 823  :    status = PoRequestPowerIrp(PDevExt->Pdo, IRP_MN_WAIT_WAKE,
; 824  :                               powerState, SerialWakeCompletion, PDevExt, &pIrp);

  0003c	8d 4d 08	 lea	 ecx, DWORD PTR _pIrp$[ebp]
  0003f	51		 push	 ecx
  00040	56		 push	 esi
  00041	68 00 00 00 00	 push	 OFFSET FLAT:_SerialWakeCompletion@20
  00046	50		 push	 eax
  00047	6a 00		 push	 0
  00049	ff b6 80 05 00
	00		 push	 DWORD PTR [esi+1408]
  0004f	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__PoRequestPowerIrp@24
  00055	8b f8		 mov	 edi, eax

; 825  : 
; 826  :    if (status == STATUS_PENDING) {

  00057	81 ff 03 01 00
	00		 cmp	 edi, 259		; 00000103H
  0005d	75 0d		 jne	 SHORT $L15081

; 827  :       status = STATUS_SUCCESS;
; 828  :       PDevExt->PendingWakeIrp = pIrp;

  0005f	8b 45 08	 mov	 eax, DWORD PTR _pIrp$[ebp]
  00062	33 ff		 xor	 edi, edi
  00064	89 86 88 05 00
	00		 mov	 DWORD PTR [esi+1416], eax

; 829  :    } else if (!NT_SUCCESS(status)) {

  0006a	eb 0a		 jmp	 SHORT $L15085
$L15081:
  0006c	85 ff		 test	 edi, edi
  0006e	7d 06		 jge	 SHORT $L15085

; 830  :       SerialIRPEpilogue(PDevExt);

  00070	56		 push	 esi
  00071	e8 00 00 00 00	 call	 _SerialIRPEpilogue@4
$L15085:

; 831  :    }
; 832  : 
; 833  :    return status;

  00076	8b c7		 mov	 eax, edi
  00078	5f		 pop	 edi
$L15069:
  00079	5e		 pop	 esi

; 834  : }

  0007a	5d		 pop	 ebp
  0007b	c2 04 00	 ret	 4
_SerialSendWaitWake@4 ENDP
; Function compile flags: /Ogsy
PAGESRP0	ENDS
;	COMDAT _SerialWakeCompletion@20
_TEXT	SEGMENT
_Context$ = 20
_IoStatus$ = 24
_SerialWakeCompletion@20 PROC NEAR			; COMDAT

; 866  :    NTSTATUS status;
; 867  :    PSERIAL_DEVICE_EXTENSION pDevExt = (PSERIAL_DEVICE_EXTENSION)Context;
; 868  :    POWER_STATE powerState;
; 869  : 
; 870  :    status = IoStatus->Status;

  00000	8b 44 24 14	 mov	 eax, DWORD PTR _IoStatus$[esp-4]
  00004	56		 push	 esi

; 871  : 
; 872  :    if (NT_SUCCESS(status)) {

  00005	8b 74 24 14	 mov	 esi, DWORD PTR _Context$[esp]
  00009	57		 push	 edi
  0000a	8b 38		 mov	 edi, DWORD PTR [eax]
  0000c	85 ff		 test	 edi, edi
  0000e	7c 18		 jl	 SHORT $L15102

; 873  :       //
; 874  :       // A wakeup has occurred -- powerup our stack
; 875  :       //
; 876  : 
; 877  :       powerState.DeviceState = PowerDeviceD0;

  00010	33 c0		 xor	 eax, eax

; 878  : 
; 879  :       PoRequestPowerIrp(pDevExt->Pdo, IRP_MN_SET_POWER, powerState, NULL,
; 880  :                         NULL, NULL);

  00012	6a 00		 push	 0
  00014	40		 inc	 eax
  00015	6a 00		 push	 0
  00017	6a 00		 push	 0
  00019	50		 push	 eax
  0001a	6a 02		 push	 2
  0001c	ff b6 80 05 00
	00		 push	 DWORD PTR [esi+1408]
  00022	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__PoRequestPowerIrp@24
$L15102:

; 881  : 
; 882  :    }
; 883  : 
; 884  :    pDevExt->PendingWakeIrp = NULL;

  00028	83 a6 88 05 00
	00 00		 and	 DWORD PTR [esi+1416], 0

; 885  :    SerialIRPEpilogue(pDevExt);

  0002f	56		 push	 esi
  00030	e8 00 00 00 00	 call	 _SerialIRPEpilogue@4

; 886  : 
; 887  :    return status;

  00035	8b c7		 mov	 eax, edi
  00037	5f		 pop	 edi
  00038	5e		 pop	 esi

; 888  : }

  00039	c2 14 00	 ret	 20			; 00000014H
_SerialWakeCompletion@20 ENDP
_TEXT	ENDS
END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -