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

📄 immediat.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 3 页
字号:
; 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	_SerialDebugLevel:DWORD
EXTRN	__imp_@InterlockedExchange@8:NEAR
EXTRN	__imp__KeGetCurrentIrql@0:NEAR
EXTRN	__imp__RtlAssert@16: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	_DbgPrint:NEAR
EXTRN	_SerialGlobals:BYTE
EXTRN	__imp_@IofCompleteRequest@8:NEAR
EXTRN	__imp__IoReleaseCancelSpinLock@4:NEAR
EXTRN	__allmul:NEAR
;	COMDAT _SerialStartImmediate@4
; File f:\w2ddk\src\kernel\serial\immediat.c
PAGESER	SEGMENT
$SG14837 DB	'SERIAL: Pageable code called at IRQL %d without lock ', 0aH
	DB	00H
	ORG $+1
$SG14840 DB	'f:\w2ddk\src\kernel\serial\immediat.c', 00H
	ORG $+2
$SG14841 DB	'FALSE', 00H
	ORG $+2
$SG14848 DB	'SERIAL: SerialStartImmediate', 0aH, 00H
	ORG $+2
$SG14877 DB	'SERIAL: Complete Irp: %x', 0aH, 00H
	ORG $+2
$SG14899 DB	'f:\w2ddk\src\kernel\serial\immediat.c', 00H
	ORG $+2
$SG14900 DB	'!(*_arg4 & _refType)', 00H
	ORG $+3
$SG14910 DB	'f:\w2ddk\src\kernel\serial\immediat.c', 00H
	ORG $+2
$SG14911 DB	'!(*_arg4 & _refType)', 00H
; Function compile flags: /Ogs
_Extension$ = 8
_OldIrql$ = -5
_TotalTime$ = -16
_UseATimer$ = -1
_Timeouts$ = -36
_SerialStartImmediate@4 PROC NEAR			; COMDAT

; 94   : {

  00121	55		 push	 ebp
  00122	8b ec		 mov	 ebp, esp
  00124	83 ec 24	 sub	 esp, 36			; 00000024H
  00127	53		 push	 ebx
  00128	56		 push	 esi

; 95   : 
; 96   :     KIRQL OldIrql;
; 97   :     LARGE_INTEGER TotalTime;
; 98   :     BOOLEAN UseATimer;
; 99   :     SERIAL_TIMEOUTS Timeouts;
; 100  : 
; 101  :     SERIAL_LOCKED_PAGED_CODE();

  00129	8b 35 00 00 00
	00		 mov	 esi, DWORD PTR __imp__KeGetCurrentIrql@0
  0012f	57		 push	 edi
  00130	ff d6		 call	 esi
  00132	3c 01		 cmp	 al, 1
  00134	76 2f		 jbe	 SHORT $L14842
  00136	83 3d 14 00 00
	00 00		 cmp	 DWORD PTR _SerialGlobals+20, 0
  0013d	75 26		 jne	 SHORT $L14842
  0013f	ff d6		 call	 esi
  00141	0f b6 c0	 movzx	 eax, al
  00144	50		 push	 eax
  00145	68 00 00 00 00	 push	 OFFSET FLAT:$SG14837
  0014a	e8 00 00 00 00	 call	 _DbgPrint
  0014f	59		 pop	 ecx
  00150	59		 pop	 ecx
  00151	6a 00		 push	 0
  00153	6a 65		 push	 101			; 00000065H
  00155	68 00 00 00 00	 push	 OFFSET FLAT:$SG14840
  0015a	68 00 00 00 00	 push	 OFFSET FLAT:$SG14841
  0015f	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
$L14842:

; 102  : 
; 103  : 
; 104  :     SerialDump(SERTRACECALLS, ("SERIAL: SerialStartImmediate\n"));

  00165	f6 05 00 00 00
	00 40		 test	 BYTE PTR _SerialDebugLevel, 64 ; 00000040H
  0016c	74 0b		 je	 SHORT $L14843
  0016e	68 00 00 00 00	 push	 OFFSET FLAT:$SG14848
  00173	e8 00 00 00 00	 call	 _DbgPrint
  00178	59		 pop	 ecx
$L14843:

; 105  : 
; 106  : 
; 107  :     UseATimer = FALSE;
; 108  :     Extension->CurrentImmediateIrp->IoStatus.Status = STATUS_PENDING;

  00179	8b 5d 08	 mov	 ebx, DWORD PTR _Extension$[ebp]
  0017c	80 65 ff 00	 and	 BYTE PTR _UseATimer$[ebp], 0
  00180	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]

; 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  :         );

  00186	8d 8b e4 01 00
	00		 lea	 ecx, DWORD PTR [ebx+484]
  0018c	c7 40 18 03 01
	00 00		 mov	 DWORD PTR [eax+24], 259	; 00000103H
  00193	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  00199	8b 40 60	 mov	 eax, DWORD PTR [eax+96]
  0019c	80 48 03 01	 or	 BYTE PTR [eax+3], 1
  001a0	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfAcquireSpinLock@4

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

  001a6	6a 05		 push	 5
  001a8	8d b3 58 01 00
	00		 lea	 esi, DWORD PTR [ebx+344]
  001ae	59		 pop	 ecx
  001af	8d 7d dc	 lea	 edi, DWORD PTR _Timeouts$[ebp]
  001b2	f3 a5		 rep movsd

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

  001b4	8a d0		 mov	 dl, al
  001b6	8d 8b e4 01 00
	00		 lea	 ecx, DWORD PTR [ebx+484]
  001bc	88 45 fb	 mov	 BYTE PTR _OldIrql$[ebp], al
  001bf	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfReleaseSpinLock@8

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

  001c5	8b 45 e8	 mov	 eax, DWORD PTR _Timeouts$[ebp+12]
  001c8	33 ff		 xor	 edi, edi
  001ca	39 7d ec	 cmp	 DWORD PTR _Timeouts$[ebp+16], edi
  001cd	75 04		 jne	 SHORT $L14857
  001cf	3b c7		 cmp	 eax, edi
  001d1	74 21		 je	 SHORT $L14856
$L14857:

; 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;

  001d3	33 c9		 xor	 ecx, ecx
  001d5	33 d2		 xor	 edx, edx
  001d7	03 45 ec	 add	 eax, DWORD PTR _Timeouts$[ebp+16]
  001da	6a ff		 push	 -1
  001dc	68 f0 d8 ff ff	 push	 -10000			; ffffd8f0H
  001e1	c6 45 ff 01	 mov	 BYTE PTR _UseATimer$[ebp], 1
  001e5	13 ca		 adc	 ecx, edx
  001e7	51		 push	 ecx
  001e8	50		 push	 eax
  001e9	e8 00 00 00 00	 call	 __allmul
  001ee	89 45 f0	 mov	 DWORD PTR _TotalTime$[ebp], eax
  001f1	89 55 f4	 mov	 DWORD PTR _TotalTime$[ebp+4], edx
$L14856:

; 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);

  001f4	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  001fa	8b 40 60	 mov	 eax, DWORD PTR [eax+96]
  001fd	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);

  00200	8d 45 fb	 lea	 eax, DWORD PTR _OldIrql$[ebp]
  00203	50		 push	 eax
  00204	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoAcquireCancelSpinLock@4

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

  0020a	8b b3 d8 00 00
	00		 mov	 esi, DWORD PTR [ebx+216]
  00210	80 7e 24 00	 cmp	 BYTE PTR [esi+36], 0
  00214	74 44		 je	 SHORT $L14867

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

  00216	ff 75 fb	 push	 DWORD PTR _OldIrql$[ebp]
  00219	89 bb d8 00 00
	00		 mov	 DWORD PTR [ebx+216], edi
  0021f	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoReleaseCancelSpinLock@4

; 166  : 
; 167  :         OldIrp->IoStatus.Status = STATUS_CANCELLED;

  00225	c7 46 18 20 01
	00 c0		 mov	 DWORD PTR [esi+24], -1073741536 ; c0000120H

; 168  :         OldIrp->IoStatus.Information = 0;

  0022c	89 7e 1c	 mov	 DWORD PTR [esi+28], edi

; 169  : 
; 170  :         SerialDump(
; 171  :             SERIRPPATH,
; 172  :             ("SERIAL: Complete Irp: %x\n",OldIrp)
; 173  :             );

  0022f	f6 05 00 00 00
	00 20		 test	 BYTE PTR _SerialDebugLevel, 32 ; 00000020H
  00236	74 0d		 je	 SHORT $L14872
  00238	56		 push	 esi
  00239	68 00 00 00 00	 push	 OFFSET FLAT:$SG14877
  0023e	e8 00 00 00 00	 call	 _DbgPrint
  00243	59		 pop	 ecx
  00244	59		 pop	 ecx
$L14872:

; 174  :         SerialCompleteRequest(Extension, OldIrp, 0);

  00245	32 d2		 xor	 dl, dl
  00247	8b ce		 mov	 ecx, esi
  00249	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@IofCompleteRequest@8
  0024f	53		 push	 ebx
  00250	e8 00 00 00 00	 call	 _SerialIRPEpilogue@4

; 175  : 
; 176  :     } else {

  00255	e9 9d 00 00 00	 jmp	 $L14884
$L14867:

; 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  :             );

  0025a	8d 4e 38	 lea	 ecx, DWORD PTR [esi+56]
  0025d	ba 00 00 00 00	 mov	 edx, OFFSET FLAT:_SerialCancelImmediate@8
  00262	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  :             );

  00268	8b 83 d8 00 00
	00		 mov	 eax, DWORD PTR [ebx+216]
  0026e	8b 70 60	 mov	 esi, DWORD PTR [eax+96]
  00271	83 c6 10	 add	 esi, 16			; 00000010H
  00274	f6 06 02	 test	 BYTE PTR [esi], 2
  00277	74 16		 je	 SHORT $L14897
  00279	57		 push	 edi
  0027a	68 c5 00 00 00	 push	 197			; 000000c5H
  0027f	68 00 00 00 00	 push	 OFFSET FLAT:$SG14899
  00284	68 00 00 00 00	 push	 OFFSET FLAT:$SG14900
  00289	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
$L14897:
  0028f	83 0e 02	 or	 DWORD PTR [esi], 2

; 198  : 
; 199  :         if (UseATimer) {

  00292	80 7d ff 00	 cmp	 BYTE PTR _UseATimer$[ebp], 0
  00296	74 44		 je	 SHORT $L14904

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

  00298	8d 83 ec 02 00
	00		 lea	 eax, DWORD PTR [ebx+748]

⌨️ 快捷键说明

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