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

📄 power.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 4 页
字号:
	00 01		 cmp	 BYTE PTR [esi+1276], 1
  00113	75 39		 jne	 SHORT $L14877

; 225  :       SerialDump(SERPNPPOWER, ("SERIAL: Reopening device\n"));
; 226  : 
; 227  :       PDevExt->DeviceIsOpened = TRUE;

  00115	c6 86 9d 01 00
	00 01		 mov	 BYTE PTR [esi+413], 1

; 228  :       PDevExt->DeviceState.Reopen = FALSE;

  0011c	88 9e fc 04 00
	00		 mov	 BYTE PTR [esi+1276], bl

; 229  : 
; 230  :       //
; 231  :       // This enables interrupts on the device!
; 232  :       //
; 233  : 
; 234  :       WRITE_MODEM_CONTROL(PDevExt->Controller,
; 235  :                           (UCHAR)(pDevState->MCR | SERIAL_MCR_OUT2));

  00122	8a 86 ff 04 00
	00		 mov	 al, BYTE PTR [esi+1279]
  00128	0c 08		 or	 al, 8
  0012a	50		 push	 eax
  0012b	8b 86 98 00 00
	00		 mov	 eax, DWORD PTR [esi+152]
  00131	83 c0 04	 add	 eax, 4
  00134	50		 push	 eax
  00135	ff d7		 call	 edi

; 236  : 
; 237  :       //
; 238  :       // Refire the state machine
; 239  :       //
; 240  : 
; 241  :       DISABLE_ALL_INTERRUPTS(PDevExt->Controller);

  00137	8b 86 98 00 00
	00		 mov	 eax, DWORD PTR [esi+152]
  0013d	53		 push	 ebx
  0013e	40		 inc	 eax
  0013f	50		 push	 eax
  00140	ff d7		 call	 edi

; 242  :       ENABLE_ALL_INTERRUPTS(PDevExt->Controller);

  00142	8b 86 98 00 00
	00		 mov	 eax, DWORD PTR [esi+152]
  00148	6a 0f		 push	 15			; 0000000fH
  0014a	40		 inc	 eax
  0014b	50		 push	 eax
  0014c	ff d7		 call	 edi
$L14877:
  0014e	5f		 pop	 edi
  0014f	5e		 pop	 esi
  00150	5d		 pop	 ebp
  00151	5b		 pop	 ebx

; 243  :    }
; 244  : 
; 245  : }

  00152	59		 pop	 ecx
  00153	59		 pop	 ecx
  00154	c2 04 00	 ret	 4
_SerialRestoreDeviceState@4 ENDP
PAGESRP0	ENDS
PUBLIC	_SerialPowerDispatch@8
PUBLIC	_SerialSetPowerD0@8
PUBLIC	_SerialSetPowerD3@8
EXTRN	_SerialIRPPrologue@8:NEAR
EXTRN	_SerialIRPEpilogue@4:NEAR
EXTRN	_SerialPoCallDriver@12:NEAR
EXTRN	__imp__PoRequestPowerIrp@24:NEAR
EXTRN	__imp__PoSetPowerState@12:NEAR
EXTRN	__imp__PoStartNextPowerIrp@4:NEAR
EXTRN	__imp_@IofCompleteRequest@8:NEAR
; Function compile flags: /Ogsy
;	COMDAT _SerialPowerDispatch@8
PAGESRP0	SEGMENT
_PDevObj$ = 8
_PIrp$ = 12
_status$ = 12
_pLowerDevObj$ = -8
_pPdo$ = -4
_powerState$14918 = 12
_SerialPowerDispatch@8 PROC NEAR			; COMDAT

; 271  : {

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

; 272  : 
; 273  :    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]

; 274  :    PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(PIrp);

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

; 275  :    NTSTATUS status;
; 276  :    PDEVICE_OBJECT pLowerDevObj = pDevExt->LowerDeviceObject;
; 277  :    PDEVICE_OBJECT pPdo = pDevExt->Pdo;
; 278  :    BOOLEAN acceptingIRPs;
; 279  : 
; 280  :    PAGED_CODE();
; 281  : 
; 282  :    if ((status = SerialIRPPrologue(PIrp, pDevExt)) != STATUS_SUCCESS) {

  00011	56		 push	 esi
  00012	57		 push	 edi
  00013	8b 86 a0 04 00
	00		 mov	 eax, DWORD PTR [esi+1184]
  00019	8b 5f 60	 mov	 ebx, DWORD PTR [edi+96]
  0001c	89 45 f8	 mov	 DWORD PTR _pLowerDevObj$[ebp], eax
  0001f	8b 86 80 05 00
	00		 mov	 eax, DWORD PTR [esi+1408]
  00025	89 45 fc	 mov	 DWORD PTR _pPdo$[ebp], eax
  00028	e8 00 00 00 00	 call	 _SerialIRPPrologue@8
  0002d	33 d2		 xor	 edx, edx
  0002f	89 45 0c	 mov	 DWORD PTR _status$[ebp], eax
  00032	3b c2		 cmp	 eax, edx
  00034	74 1f		 je	 SHORT $L14895

; 283  :       PoStartNextPowerIrp(PIrp);

  00036	57		 push	 edi
  00037	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__PoStartNextPowerIrp@4

; 284  :       SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);

  0003d	32 d2		 xor	 dl, dl
  0003f	8b cf		 mov	 ecx, edi
  00041	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@IofCompleteRequest@8
  00047	56		 push	 esi
  00048	e8 00 00 00 00	 call	 _SerialIRPEpilogue@4

; 285  :       return status;

  0004d	8b 45 0c	 mov	 eax, DWORD PTR _status$[ebp]
  00050	e9 55 01 00 00	 jmp	 $L14887
$L14895:

; 286  :    }
; 287  : 
; 288  :    status = STATUS_SUCCESS;
; 289  : 
; 290  :    switch (pIrpStack->MinorFunction) {

  00055	0f b6 43 01	 movzx	 eax, BYTE PTR [ebx+1]
  00059	2b c2		 sub	 eax, edx
  0005b	0f 84 31 01 00
	00		 je	 $PowerExit$14924
  00061	48		 dec	 eax
  00062	0f 84 2a 01 00
	00		 je	 $PowerExit$14924
  00068	48		 dec	 eax
  00069	74 57		 je	 SHORT $L14910
  0006b	48		 dec	 eax
  0006c	0f 85 20 01 00
	00		 jne	 $PowerExit$14924

; 442  : 
; 443  :       default:
; 444  :          break;
; 445  :       }
; 446  :       break;
; 447  : 
; 448  : 
; 449  : 
; 450  :    case IRP_MN_QUERY_POWER:
; 451  : 
; 452  :       SerialDump (SERPNPPOWER, ("SERIAL: Got IRP_MN_QUERY_POWER Irp\n"));
; 453  : 
; 454  :       //
; 455  :       // Check if we have a wait-wake pending and if so,
; 456  :       // ensure we don't power down too far.
; 457  :       //
; 458  : 
; 459  : 
; 460  :       if (pDevExt->PendingWakeIrp != NULL || pDevExt->SendWaitWake) {

  00072	39 96 88 05 00
	00		 cmp	 DWORD PTR [esi+1416], edx
  00078	75 09		 jne	 SHORT $L14983
  0007a	80 be 84 05 00
	00 00		 cmp	 BYTE PTR [esi+1412], 0
  00081	74 37		 je	 SHORT $L14984
$L14983:

; 461  :          if (pIrpStack->Parameters.Power.Type == DevicePowerState
; 462  :              && pIrpStack->Parameters.Power.State.DeviceState
; 463  :              > pDevExt->DeviceWake) {

  00083	83 7b 08 01	 cmp	 DWORD PTR [ebx+8], 1
  00087	75 31		 jne	 SHORT $L14984
  00089	8b 43 0c	 mov	 eax, DWORD PTR [ebx+12]
  0008c	3b 86 7c 05 00
	00		 cmp	 eax, DWORD PTR [esi+1404]
  00092	7e 26		 jle	 SHORT $L14984

; 464  :             status = PIrp->IoStatus.Status = STATUS_INVALID_DEVICE_STATE;

  00094	bb 84 01 00 c0	 mov	 ebx, -1073741436	; c0000184H

; 465  :             PoStartNextPowerIrp(PIrp);

  00099	57		 push	 edi
  0009a	89 5f 18	 mov	 DWORD PTR [edi+24], ebx
  0009d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__PoStartNextPowerIrp@4

; 466  :             SerialCompleteRequest(pDevExt, PIrp, IO_NO_INCREMENT);

  000a3	32 d2		 xor	 dl, dl
  000a5	8b cf		 mov	 ecx, edi
  000a7	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@IofCompleteRequest@8
  000ad	56		 push	 esi
  000ae	e8 00 00 00 00	 call	 _SerialIRPEpilogue@4

; 467  :             return status;

  000b3	8b c3		 mov	 eax, ebx
  000b5	e9 f0 00 00 00	 jmp	 $L14887
$L14984:

; 468  :          }
; 469  :       }
; 470  : 
; 471  :       //
; 472  :       // If no wait-wake, always successful
; 473  :       //
; 474  : 
; 475  :       PIrp->IoStatus.Status = STATUS_SUCCESS;

  000ba	89 57 18	 mov	 DWORD PTR [edi+24], edx

; 476  :       status = STATUS_SUCCESS;
; 477  :       PoStartNextPowerIrp(PIrp);
; 478  :       IoSkipCurrentIrpStackLocation(PIrp);
; 479  :       return SerialPoCallDriver(pDevExt, pLowerDevObj, PIrp);

  000bd	e9 d0 00 00 00	 jmp	 $PowerExit$14924
$L14910:

; 291  : 
; 292  :    case IRP_MN_WAIT_WAKE:
; 293  :       SerialDump(SERPNPPOWER, ("SERIAL: Got IRP_MN_WAIT_WAKE Irp\n"));
; 294  :       break;
; 295  : 
; 296  : 
; 297  :    case IRP_MN_POWER_SEQUENCE:
; 298  :       SerialDump(SERPNPPOWER, ("SERIAL: Got IRP_MN_POWER_SEQUENCE Irp\n"));
; 299  :       break;
; 300  : 
; 301  : 
; 302  :    case IRP_MN_SET_POWER:
; 303  :       SerialDump(SERPNPPOWER, ("SERIAL: Got IRP_MN_SET_POWER Irp\n"));
; 304  : 
; 305  :       //
; 306  :       // Perform different ops if it was system or device
; 307  :       //
; 308  : 
; 309  :       switch (pIrpStack->Parameters.Power.Type) {

  000c2	8b 43 08	 mov	 eax, DWORD PTR [ebx+8]
  000c5	2b c2		 sub	 eax, edx
  000c7	74 48		 je	 SHORT $L14919
  000c9	48		 dec	 eax
  000ca	0f 85 c2 00 00
	00		 jne	 $PowerExit$14924

; 394  :                   } else {
; 395  :                      //
; 396  :                      // Fail the request
; 397  :                      //
; 398  : 
; 399  :                      status = STATUS_INVALID_DEVICE_STATE;
; 400  :                   }
; 401  :                }
; 402  :             }
; 403  : 
; 404  :             goto PowerExit;
; 405  :          }
; 406  : 
; 407  :       case DevicePowerState:
; 408  :          SerialDump(SERPNPPOWER, ("------: DevicePowerState\n"));
; 409  :          break;
; 410  : 
; 411  :       default:
; 412  :          SerialDump(SERPNPPOWER, ("------: UNKNOWN PowerState\n"));
; 413  :          status = STATUS_SUCCESS;
; 414  :          goto PowerExit;
; 415  :       }
; 416  : 
; 417  : 
; 418  :       //
; 419  :       // If we are already in the requested state, just pass the IRP down
; 420  :       //
; 421  : 
; 422  :       if (pDevExt->PowerState
; 423  :           == pIrpStack->Parameters.Power.State.DeviceState) {

  000d0	8b 5b 0c	 mov	 ebx, DWORD PTR [ebx+12]
  000d3	39 9e a4 04 00
	00		 cmp	 DWORD PTR [esi+1188], ebx
  000d9	0f 84 b3 00 00
	00		 je	 $PowerExit$14924

; 424  :          SerialDump(SERPNPPOWER, ("SERIAL: Already in requested power state\n")
; 425  :                     );
; 426  :          status = STATUS_SUCCESS;
; 427  :          break;
; 428  :       }
; 429  : 
; 430  : 
; 431  :       switch (pIrpStack->Parameters.Power.State.DeviceState) {

  000df	33 c9		 xor	 ecx, ecx
  000e1	41		 inc	 ecx
  000e2	3b d9		 cmp	 ebx, ecx
  000e4	74 1d		 je	 SHORT $L14969
  000e6	0f 8e a6 00 00
	00		 jle	 $PowerExit$14924
  000ec	83 fb 04	 cmp	 ebx, 4
  000ef	0f 8f 9d 00 00
	00		 jg	 $PowerExit$14924

; 436  : 
; 437  :       case PowerDeviceD1:
; 438  :       case PowerDeviceD2:
; 439  :       case PowerDeviceD3:
; 440  :          SerialDump(SERPNPPOWER, ("SERIAL: Going to power state D3\n"));
; 441  :          return SerialSetPowerD3(PDevObj, PIrp);

  000f5	57		 push	 edi
  000f6	ff 75 08	 push	 DWORD PTR _PDevObj$[ebp]
  000f9	e8 00 00 00 00	 call	 _SerialSetPowerD3@8
  000fe	e9 a7 00 00 00	 jmp	 $L14887
$L14969:

; 432  : 
; 433  :       case PowerDeviceD0:
; 434  :          SerialDump(SERPNPPOWER, ("SERIAL: Going to power state D0\n"));
; 435  :          return SerialSetPowerD0(PDevObj, PIrp);

  00103	57		 push	 edi
  00104	ff 75 08	 push	 DWORD PTR _PDevObj$[ebp]
  00107	e8 00 00 00 00	 call	 _SerialSetPowerD0@8
  0010c	e9 99 00 00 00	 jmp	 $L14887
$L14919:

; 310  :       case SystemPowerState: {
; 311  :             POWER_STATE powerState;
; 312  : 
; 313  :             //
; 314  :             // They asked for a system power state change
; 315  :             //
; 316  : 
; 317  :             SerialDump(SERPNPPOWER, ("------: SystemPowerState\n"));
; 318  : 
; 319  :             //
; 320  :             // We will only service this if we are policy owner -- we
; 321  :             // don't need to lock on this value since we only service
; 322  :             // one power request at a time.
; 323  :             //
; 324  : 
; 325  :             if (pDevExt->OwnsPowerPolicy != TRUE) {

  00111	33 c9		 xor	 ecx, ecx
  00113	41		 inc	 ecx
  00114	38 8e 74 05 00
	00		 cmp	 BYTE PTR [esi+1396], cl
  0011a	75 76		 jne	 SHORT $PowerExit$14924

; 326  :                status = STATUS_SUCCESS;
; 327  :                goto PowerExit;
; 328  :             }
; 329  : 
; 330  : 
; 331  :             switch (pIrpStack->Parameters.Power.State.SystemState) {

  0011c	8b 43 0c	 mov	 eax, DWORD PTR [ebx+12]
  0011f	3b c2		 cmp	 eax, edx
  00121	74 1c		 je	 SHORT $L14929
  00123	3b c1		 cmp	 eax, ecx
  00125	74 13		 je	 SHORT $L14930
  00127	7e 69		 jle	 SHORT $PowerExit$14924
  00129	83 f8 07	 cmp	 eax, 7
  0012c	7f 64		 jg	 SHORT $PowerExit$14924

; 339  : 
; 340  :             case PowerSystemSleeping1:
; 341  :             case PowerSystemSleeping2:
; 342  :             case PowerSystemSleeping3:
; 343  :             case PowerSystemHibernate:
; 344  :             case PowerSystemShutdown:
; 345  :             case PowerSystemMaximum:
; 346  :                powerState.DeviceState
; 347  :                   = pDevExt->DeviceStateMap[pIrpStack->
; 348  :                                             Parameters.Power.State.SystemState];

  0012e	8b 84 86 00 05
	00 00		 mov	 eax, DWORD PTR [esi+eax*4+1280]
  00135	89 45 0c	 mov	 DWORD PTR _powerState$14918[ebp], eax

; 349  :                break;

  00138	eb 08		 jmp	 SHORT $L14926
$L14930:

; 334  :                break;
; 335  : 
; 336  :             case PowerSystemWorking:
; 337  :                powerState.DeviceState = PowerDeviceD0;

  0013a	89 4d 0c	 mov	 DWORD PTR _powerState$14918[ebp], ecx

; 338  :                break;

  0013d	eb 03		 jmp	 SHORT $L14926
$L14929:

; 332  :             case PowerSystemUnspecified:
; 333  :                powerState.DeviceState = PowerDeviceUnspecified;

  0013f	89 55 0c	 mov	 DWORD PTR _powerState$14918[ebp], edx
$L14926:

⌨️ 快捷键说明

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