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

📄 immediat.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 2 页
字号:
; Listing generated by Microsoft (R) Optimizing Compiler Version 12.00.9044.0 

	TITLE	F:\W2DDK\src\kernel\serial\immediat.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
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _RtlConvertLongToLargeInteger@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialStartImmediate@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialCompleteImmediate@16
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialTimeoutImmediate@16
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialGetNextImmediate@20
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialCancelImmediate@8
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialGiveImmediateToIsr@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialGrabImmediateFromIsr@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	_SerialCancelImmediate@8
PUBLIC	_SerialGiveImmediateToIsr@4
PUBLIC	_SerialStartImmediate@4
EXTRN	__imp__KeSynchronizeExecution@12:NEAR
EXTRN	__imp_@InterlockedExchange@8:NEAR
EXTRN	__imp_@KfAcquireSpinLock@4:NEAR
EXTRN	__imp_@KfReleaseSpinLock@8:NEAR
EXTRN	_SerialIRPEpilogue@4:NEAR
EXTRN	__imp__IoAcquireCancelSpinLock@4:NEAR
EXTRN	_SerialSetTimer@20:NEAR
EXTRN	__imp_@IofCompleteRequest@8:NEAR
EXTRN	__allmul:NEAR
EXTRN	__imp__IoReleaseCancelSpinLock@4:NEAR
; Function compile flags: /Ogsy
; File f:\w2ddk\src\kernel\serial\immediat.c
;	COMDAT _SerialStartImmediate@4
PAGESER	SEGMENT
_Extension$ = 8
_OldIrql$ = 8
_TotalTime$ = -12
_UseATimer$ = -1
_Timeouts$ = -32
_SerialStartImmediate@4 PROC NEAR			; COMDAT

; 94   : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	83 ec 20	 sub	 esp, 32			; 00000020H
  00006	53		 push	 ebx

; 95   : 
; 96   :     KIRQL OldIrql;
; 97   :     LARGE_INTEGER TotalTime;
; 98   :     BOOLEAN UseATimer;
; 99   :     SERIAL_TIMEOUTS Timeouts;
; 100  : 
; 101  :     SERIAL_LOCKED_PAGED_CODE();
; 102  : 
; 103  : 
; 104  :     SerialDump(SERTRACECALLS, ("SERIAL: SerialStartImmediate\n"));
; 105  : 
; 106  : 
; 107  :     UseATimer = FALSE;
; 108  :     Extension->CurrentImmediateIrp->IoStatus.Status = STATUS_PENDING;

  00007	8b 5d 08	 mov	 ebx, DWORD PTR _Extension$[ebp]
  0000a	80 65 ff 00	 and	 BYTE PTR _UseATimer$[ebp], 0
  0000e	56		 push	 esi
  0000f	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  00015	57		 push	 edi

; 109  :     IoMarkIrpPending(Extension->CurrentImmediateIrp);
; 110  : 
; 111  :     //
; 112  :     // Calculate the timeout value needed for the
; 113  :     // request.  Note that the values stored in the
; 114  :     // timeout record are in milliseconds.  Note that
; 115  :     // if the timeout values are zero then we won't start
; 116  :     // the timer.
; 117  :     //
; 118  : 
; 119  :     KeAcquireSpinLock(
; 120  :         &Extension->ControlLock,
; 121  :         &OldIrql
; 122  :         );

  00016	8d 8b e4 01 00
	00		 lea	 ecx, DWORD PTR [ebx+484]
  0001c	c7 40 18 03 01
	00 00		 mov	 DWORD PTR [eax+24], 259	; 00000103H
  00023	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  00029	8b 40 60	 mov	 eax, DWORD PTR [eax+96]
  0002c	80 48 03 01	 or	 BYTE PTR [eax+3], 1
  00030	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfAcquireSpinLock@4

; 123  : 
; 124  :     Timeouts = Extension->Timeouts;

  00036	6a 05		 push	 5
  00038	8d b3 58 01 00
	00		 lea	 esi, DWORD PTR [ebx+344]
  0003e	59		 pop	 ecx
  0003f	8d 7d e0	 lea	 edi, DWORD PTR _Timeouts$[ebp]
  00042	f3 a5		 rep movsd

; 125  : 
; 126  :     KeReleaseSpinLock(
; 127  :         &Extension->ControlLock,
; 128  :         OldIrql
; 129  :         );

  00044	8a d0		 mov	 dl, al
  00046	8d 8b e4 01 00
	00		 lea	 ecx, DWORD PTR [ebx+484]
  0004c	88 45 08	 mov	 BYTE PTR _OldIrql$[ebp], al
  0004f	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfReleaseSpinLock@8

; 130  : 
; 131  :     if (Timeouts.WriteTotalTimeoutConstant ||
; 132  :         Timeouts.WriteTotalTimeoutMultiplier) {

  00055	8b 45 ec	 mov	 eax, DWORD PTR _Timeouts$[ebp+12]
  00058	33 ff		 xor	 edi, edi
  0005a	39 7d f0	 cmp	 DWORD PTR _Timeouts$[ebp+16], edi
  0005d	75 04		 jne	 SHORT $L14803
  0005f	3b c7		 cmp	 eax, edi
  00061	74 21		 je	 SHORT $L14802
$L14803:

; 133  : 
; 134  :         UseATimer = TRUE;
; 135  : 
; 136  :         //
; 137  :         // We have some timer values to calculate.
; 138  :         //
; 139  : 
; 140  :         TotalTime.QuadPart = (LONGLONG)((ULONG)Timeouts.WriteTotalTimeoutMultiplier);
; 141  : 
; 142  :         TotalTime.QuadPart += Timeouts.WriteTotalTimeoutConstant;
; 143  : 
; 144  :         TotalTime.QuadPart *= -10000;

  00063	33 c9		 xor	 ecx, ecx
  00065	33 d2		 xor	 edx, edx
  00067	03 45 f0	 add	 eax, DWORD PTR _Timeouts$[ebp+16]
  0006a	6a ff		 push	 -1
  0006c	68 f0 d8 ff ff	 push	 -10000			; ffffd8f0H
  00071	c6 45 ff 01	 mov	 BYTE PTR _UseATimer$[ebp], 1
  00075	13 ca		 adc	 ecx, edx
  00077	51		 push	 ecx
  00078	50		 push	 eax
  00079	e8 00 00 00 00	 call	 __allmul
  0007e	89 45 f4	 mov	 DWORD PTR _TotalTime$[ebp], eax
  00081	89 55 f8	 mov	 DWORD PTR _TotalTime$[ebp+4], edx
$L14802:

; 145  : 
; 146  :     }
; 147  : 
; 148  :     //
; 149  :     // As the irp might be going to the isr, this is a good time
; 150  :     // to initialize the reference count.
; 151  :     //
; 152  : 
; 153  :     SERIAL_INIT_REFERENCE(Extension->CurrentImmediateIrp);

  00084	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  0008a	8b 40 60	 mov	 eax, DWORD PTR [eax+96]
  0008d	89 78 10	 mov	 DWORD PTR [eax+16], edi

; 154  : 
; 155  :     //
; 156  :     // We need to see if this irp should be canceled.
; 157  :     //
; 158  : 
; 159  :     IoAcquireCancelSpinLock(&OldIrql);

  00090	8d 45 08	 lea	 eax, DWORD PTR _OldIrql$[ebp]
  00093	50		 push	 eax
  00094	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoAcquireCancelSpinLock@4

; 160  :     if (Extension->CurrentImmediateIrp->Cancel) {

  0009a	8b b3 d8 00 00
	00		 mov	 esi, DWORD PTR [ebx+216]
  000a0	80 7e 24 00	 cmp	 BYTE PTR [esi+36], 0
  000a4	74 2b		 je	 SHORT $L14807

; 161  : 
; 162  :         PIRP OldIrp = Extension->CurrentImmediateIrp;
; 163  : 
; 164  :         Extension->CurrentImmediateIrp = NULL;
; 165  :         IoReleaseCancelSpinLock(OldIrql);

  000a6	ff 75 08	 push	 DWORD PTR _OldIrql$[ebp]
  000a9	89 bb d8 00 00
	00		 mov	 DWORD PTR [ebx+216], edi
  000af	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoReleaseCancelSpinLock@4

; 166  : 
; 167  :         OldIrp->IoStatus.Status = STATUS_CANCELLED;
; 168  :         OldIrp->IoStatus.Information = 0;
; 169  : 
; 170  :         SerialDump(
; 171  :             SERIRPPATH,
; 172  :             ("SERIAL: Complete Irp: %x\n",OldIrp)
; 173  :             );
; 174  :         SerialCompleteRequest(Extension, OldIrp, 0);

  000b5	32 d2		 xor	 dl, dl
  000b7	8b ce		 mov	 ecx, esi
  000b9	c7 46 18 20 01
	00 c0		 mov	 DWORD PTR [esi+24], -1073741536 ; c0000120H
  000c0	89 7e 1c	 mov	 DWORD PTR [esi+28], edi
  000c3	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@IofCompleteRequest@8
  000c9	53		 push	 ebx
  000ca	e8 00 00 00 00	 call	 _SerialIRPEpilogue@4

; 175  : 
; 176  :     } else {

  000cf	eb 67		 jmp	 SHORT $L14814
$L14807:

; 177  : 
; 178  :         //
; 179  :         // We give the irp to to the isr to write out.
; 180  :         // We set a cancel routine that knows how to
; 181  :         // grab the current write away from the isr.
; 182  :         //
; 183  : 
; 184  :         IoSetCancelRoutine(
; 185  :             Extension->CurrentImmediateIrp,
; 186  :             SerialCancelImmediate
; 187  :             );

  000d1	8d 4e 38	 lea	 ecx, DWORD PTR [esi+56]
  000d4	ba 00 00 00 00	 mov	 edx, OFFSET FLAT:_SerialCancelImmediate@8
  000d9	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@InterlockedExchange@8

; 188  : 
; 189  :         //
; 190  :         // Since the cancel routine knows about the irp we
; 191  :         // increment the reference count.
; 192  :         //
; 193  : 
; 194  :         SERIAL_SET_REFERENCE(
; 195  :             Extension->CurrentImmediateIrp,
; 196  :             SERIAL_REF_CANCEL
; 197  :             );

  000df	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  000e5	8b 40 60	 mov	 eax, DWORD PTR [eax+96]
  000e8	83 c0 10	 add	 eax, 16			; 00000010H
  000eb	83 08 02	 or	 DWORD PTR [eax], 2

; 198  : 
; 199  :         if (UseATimer) {

  000ee	80 7d ff 00	 cmp	 BYTE PTR _UseATimer$[ebp], 0
  000f2	74 29		 je	 SHORT $L14830

; 200  : 
; 201  :             SerialSetTimer(
; 202  :                 &Extension->ImmediateTotalTimer,
; 203  :                 TotalTime,
; 204  :                 &Extension->TotalImmediateTimeoutDpc,
; 205  :                 Extension
; 206  :                 );

  000f4	8d 83 ec 02 00
	00		 lea	 eax, DWORD PTR [ebx+748]
  000fa	53		 push	 ebx
  000fb	50		 push	 eax
  000fc	8d 83 28 04 00
	00		 lea	 eax, DWORD PTR [ebx+1064]
  00102	ff 75 f8	 push	 DWORD PTR _TotalTime$[ebp+4]
  00105	ff 75 f4	 push	 DWORD PTR _TotalTime$[ebp]
  00108	50		 push	 eax
  00109	e8 00 00 00 00	 call	 _SerialSetTimer@20

; 207  : 
; 208  :             //
; 209  :             // Since the timer knows about the irp we increment
; 210  :             // the reference count.
; 211  :             //
; 212  : 
; 213  :             SERIAL_SET_REFERENCE(
; 214  :                 Extension->CurrentImmediateIrp,
; 215  :                 SERIAL_REF_TOTAL_TIMER
; 216  :                 );

  0010e	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  00114	8b 40 60	 mov	 eax, DWORD PTR [eax+96]
  00117	83 c0 10	 add	 eax, 16			; 00000010H
  0011a	83 08 04	 or	 DWORD PTR [eax], 4
$L14830:

; 217  : 
; 218  :         }
; 219  : 
; 220  :         KeSynchronizeExecution(
; 221  :             Extension->Interrupt,
; 222  :             SerialGiveImmediateToIsr,
; 223  :             Extension
; 224  :             );

  0011d	53		 push	 ebx
  0011e	68 00 00 00 00	 push	 OFFSET FLAT:_SerialGiveImmediateToIsr@4
  00123	ff b3 a0 00 00
	00		 push	 DWORD PTR [ebx+160]
  00129	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeSynchronizeExecution@12

; 225  : 
; 226  :         IoReleaseCancelSpinLock(OldIrql);

  0012f	ff 75 08	 push	 DWORD PTR _OldIrql$[ebp]
  00132	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoReleaseCancelSpinLock@4
$L14814:
  00138	5f		 pop	 edi
  00139	5e		 pop	 esi
  0013a	5b		 pop	 ebx

; 227  : 
; 228  :     }
; 229  : 
; 230  : }

  0013b	c9		 leave
  0013c	c2 04 00	 ret	 4
_SerialStartImmediate@4 ENDP
PAGESER	ENDS
PUBLIC	_SerialGetNextImmediate@20
PUBLIC	_SerialCompleteImmediate@16
EXTRN	_SerialDpcEpilogue@8:NEAR
EXTRN	_SerialTryToCompleteCurrent@44:NEAR
; Function compile flags: /Ogsy
;	COMDAT _SerialCompleteImmediate@16
_TEXT	SEGMENT
_Dpc$ = 8
_DeferredContext$ = 12
_OldIrql$ = -4
_SerialCompleteImmediate@16 PROC NEAR			; COMDAT

; 240  : {

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

; 241  : 
; 242  :     PSERIAL_DEVICE_EXTENSION Extension = DeferredContext;
; 243  :     KIRQL OldIrql;
; 244  : 
; 245  :     UNREFERENCED_PARAMETER(SystemContext1);
; 246  :     UNREFERENCED_PARAMETER(SystemContext2);
; 247  : 
; 248  : 
; 249  :     SerialDump(SERTRACECALLS, ("SERIAL: SerialCompleteImmediate\n"));
; 250  : 
; 251  :     IoAcquireCancelSpinLock(&OldIrql);

  00004	8d 45 fc	 lea	 eax, DWORD PTR _OldIrql$[ebp]
  00007	56		 push	 esi
  00008	50		 push	 eax
  00009	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoAcquireCancelSpinLock@4

; 252  : 
; 253  :     SerialTryToCompleteCurrent(
; 254  :         Extension,
; 255  :         NULL,
; 256  :         OldIrql,
; 257  :         STATUS_SUCCESS,
; 258  :         &Extension->CurrentImmediateIrp,
; 259  :         NULL,
; 260  :         NULL,
; 261  :         &Extension->ImmediateTotalTimer,
; 262  :         NULL,
; 263  :         SerialGetNextImmediate,
; 264  :         SERIAL_REF_ISR
; 265  :         );

  0000f	8b 75 0c	 mov	 esi, DWORD PTR _DeferredContext$[ebp]
  00012	6a 01		 push	 1
  00014	33 c0		 xor	 eax, eax
  00016	68 00 00 00 00	 push	 OFFSET FLAT:_SerialGetNextImmediate@20
  0001b	8d 8e 28 04 00
	00		 lea	 ecx, DWORD PTR [esi+1064]
  00021	50		 push	 eax

⌨️ 快捷键说明

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