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

📄 purge.cod

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

	TITLE	F:\W2DDK\src\kernel\serial\purge.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 _SerialStartPurge@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialPurgeInterruptBuff@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	_SerialStartPurge@4
PUBLIC	_SerialPurgeInterruptBuff@4
EXTRN	__imp__KeSynchronizeExecution@12:NEAR
EXTRN	__imp__KeGetCurrentIrql@0:NEAR
EXTRN	__imp__RtlAssert@16:NEAR
EXTRN	__imp_@KfAcquireSpinLock@4:NEAR
EXTRN	__imp_@KfReleaseSpinLock@8:NEAR
EXTRN	_DbgPrint:NEAR
EXTRN	_SerialGlobals:BYTE
EXTRN	_SerialKillAllReadsOrWrites@12:NEAR
EXTRN	_SerialGetNextIrp@20:NEAR
;	COMDAT _SerialStartPurge@4
; File f:\w2ddk\src\kernel\serial\purge.c
PAGESER	SEGMENT
$SG14808 DB	'SERIAL: Pageable code called at IRQL %d without lock ', 0aH
	DB	00H
	ORG $+1
$SG14811 DB	'f:\w2ddk\src\kernel\serial\purge.c', 00H
	ORG $+1
$SG14812 DB	'FALSE', 00H
; Function compile flags: /Ogs
_Extension$ = 8
_NewIrp$ = -4
_Mask$14816 = 8
_SerialStartPurge@4 PROC NEAR				; COMDAT

; 59   : {

  00062	55		 push	 ebp
  00063	8b ec		 mov	 ebp, esp
  00065	51		 push	 ecx
  00066	53		 push	 ebx
  00067	56		 push	 esi

; 60   : 
; 61   :     PIRP NewIrp;
; 62   : 
; 63   :     SERIAL_LOCKED_PAGED_CODE();

  00068	8b 35 00 00 00
	00		 mov	 esi, DWORD PTR __imp__KeGetCurrentIrql@0
  0006e	57		 push	 edi
  0006f	ff d6		 call	 esi
  00071	3c 01		 cmp	 al, 1
  00073	76 2f		 jbe	 SHORT $L14852
  00075	83 3d 14 00 00
	00 00		 cmp	 DWORD PTR _SerialGlobals+20, 0
  0007c	75 26		 jne	 SHORT $L14852
  0007e	ff d6		 call	 esi
  00080	0f b6 c0	 movzx	 eax, al
  00083	50		 push	 eax
  00084	68 00 00 00 00	 push	 OFFSET FLAT:$SG14808
  00089	e8 00 00 00 00	 call	 _DbgPrint
  0008e	59		 pop	 ecx
  0008f	59		 pop	 ecx
  00090	6a 00		 push	 0
  00092	6a 3f		 push	 63			; 0000003fH
  00094	68 00 00 00 00	 push	 OFFSET FLAT:$SG14811
  00099	68 00 00 00 00	 push	 OFFSET FLAT:$SG14812
  0009e	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
$L14852:
  000a4	8b 75 08	 mov	 esi, DWORD PTR _Extension$[ebp]
  000a7	8d be d0 00 00
	00		 lea	 edi, DWORD PTR [esi+208]
$L14813:

; 64   : 
; 65   :     do {
; 66   : 
; 67   :         ULONG Mask;
; 68   : 
; 69   :         Mask = *((ULONG *)
; 70   :                  (Extension->CurrentPurgeIrp->AssociatedIrp.SystemBuffer));

  000ad	8b 07		 mov	 eax, DWORD PTR [edi]
  000af	8b 40 0c	 mov	 eax, DWORD PTR [eax+12]
  000b2	8b 00		 mov	 eax, DWORD PTR [eax]

; 71   : 
; 72   :         if (Mask & SERIAL_PURGE_TXABORT) {

  000b4	a8 01		 test	 al, 1
  000b6	89 45 08	 mov	 DWORD PTR _Mask$14816[ebp], eax
  000b9	74 30		 je	 SHORT $L14818

; 73   : 
; 74   :             SerialKillAllReadsOrWrites(
; 75   :                 Extension->DeviceObject,
; 76   :                 &Extension->WriteQueue,
; 77   :                 &Extension->CurrentWriteIrp
; 78   :                 );

  000bb	8d 8e c8 00 00
	00		 lea	 ecx, DWORD PTR [esi+200]
  000c1	8d 86 ac 00 00
	00		 lea	 eax, DWORD PTR [esi+172]
  000c7	8d 9e 8c 00 00
	00		 lea	 ebx, DWORD PTR [esi+140]
  000cd	51		 push	 ecx
  000ce	50		 push	 eax
  000cf	ff 33		 push	 DWORD PTR [ebx]
  000d1	e8 00 00 00 00	 call	 _SerialKillAllReadsOrWrites@12

; 79   : 
; 80   :             SerialKillAllReadsOrWrites(
; 81   :                 Extension->DeviceObject,
; 82   :                 &Extension->WriteQueue,
; 83   :                 &Extension->CurrentXoffIrp
; 84   :                 );

  000d6	8d 86 dc 00 00
	00		 lea	 eax, DWORD PTR [esi+220]
  000dc	50		 push	 eax
  000dd	8d 86 ac 00 00
	00		 lea	 eax, DWORD PTR [esi+172]
  000e3	50		 push	 eax
  000e4	ff 33		 push	 DWORD PTR [ebx]
  000e6	e8 00 00 00 00	 call	 _SerialKillAllReadsOrWrites@12
$L14818:

; 85   : 
; 86   :         }
; 87   : 
; 88   :         if (Mask & SERIAL_PURGE_RXABORT) {

  000eb	f6 45 08 02	 test	 BYTE PTR _Mask$14816[ebp], 2
  000ef	74 19		 je	 SHORT $L14819

; 89   : 
; 90   :             SerialKillAllReadsOrWrites(
; 91   :                 Extension->DeviceObject,
; 92   :                 &Extension->ReadQueue,
; 93   :                 &Extension->CurrentReadIrp
; 94   :                 );

  000f1	8d 86 c4 00 00
	00		 lea	 eax, DWORD PTR [esi+196]
  000f7	50		 push	 eax
  000f8	8d 86 a4 00 00
	00		 lea	 eax, DWORD PTR [esi+164]
  000fe	50		 push	 eax
  000ff	ff b6 8c 00 00
	00		 push	 DWORD PTR [esi+140]
  00105	e8 00 00 00 00	 call	 _SerialKillAllReadsOrWrites@12
$L14819:

; 95   : 
; 96   :         }
; 97   : 
; 98   :         if (Mask & SERIAL_PURGE_RXCLEAR) {

  0010a	f6 45 08 08	 test	 BYTE PTR _Mask$14816[ebp], 8
  0010e	74 2e		 je	 SHORT $L14820

; 99   : 
; 100  :             KIRQL OldIrql;
; 101  : 
; 102  :             //
; 103  :             // Clean out the interrupt buffer.
; 104  :             //
; 105  :             // Note that we do this under protection of the
; 106  :             // the drivers control lock so that we don't hose
; 107  :             // the pointers if there is currently a read that
; 108  :             // is reading out of the buffer.
; 109  :             //
; 110  : 
; 111  :             KeAcquireSpinLock(
; 112  :                 &Extension->ControlLock,
; 113  :                 &OldIrql
; 114  :                 );

  00110	8d 8e e4 01 00
	00		 lea	 ecx, DWORD PTR [esi+484]
  00116	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfAcquireSpinLock@4

; 115  : 
; 116  :             KeSynchronizeExecution(
; 117  :                 Extension->Interrupt,
; 118  :                 SerialPurgeInterruptBuff,
; 119  :                 Extension
; 120  :                 );

  0011c	56		 push	 esi
  0011d	68 00 00 00 00	 push	 OFFSET FLAT:_SerialPurgeInterruptBuff@4
  00122	ff b6 a0 00 00
	00		 push	 DWORD PTR [esi+160]
  00128	8a d8		 mov	 bl, al
  0012a	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeSynchronizeExecution@12

; 121  : 
; 122  :             KeReleaseSpinLock(
; 123  :                 &Extension->ControlLock,
; 124  :                 OldIrql
; 125  :                 );

  00130	8a d3		 mov	 dl, bl
  00132	8d 8e e4 01 00
	00		 lea	 ecx, DWORD PTR [esi+484]
  00138	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfReleaseSpinLock@8
$L14820:

; 126  : 
; 127  :         }
; 128  : 
; 129  :         Extension->CurrentPurgeIrp->IoStatus.Status = STATUS_SUCCESS;

  0013e	8b 07		 mov	 eax, DWORD PTR [edi]
  00140	33 db		 xor	 ebx, ebx

; 130  :         Extension->CurrentPurgeIrp->IoStatus.Information = 0;
; 131  : 
; 132  :         SerialGetNextIrp(
; 133  :             &Extension->CurrentPurgeIrp,
; 134  :             &Extension->PurgeQueue,
; 135  :             &NewIrp,
; 136  :             TRUE,
; 137  :             Extension
; 138  :             );

  00142	56		 push	 esi
  00143	6a 01		 push	 1
  00145	89 58 18	 mov	 DWORD PTR [eax+24], ebx
  00148	8b 07		 mov	 eax, DWORD PTR [edi]
  0014a	89 58 1c	 mov	 DWORD PTR [eax+28], ebx
  0014d	8d 45 fc	 lea	 eax, DWORD PTR _NewIrp$[ebp]
  00150	50		 push	 eax
  00151	8d 86 bc 00 00
	00		 lea	 eax, DWORD PTR [esi+188]
  00157	50		 push	 eax
  00158	57		 push	 edi
  00159	e8 00 00 00 00	 call	 _SerialGetNextIrp@20

; 139  : 
; 140  :     } while (NewIrp);

  0015e	39 5d fc	 cmp	 DWORD PTR _NewIrp$[ebp], ebx
  00161	0f 85 46 ff ff
	ff		 jne	 $L14813
  00167	5f		 pop	 edi
  00168	5e		 pop	 esi

; 141  : 
; 142  :     return STATUS_SUCCESS;

  00169	33 c0		 xor	 eax, eax
  0016b	5b		 pop	 ebx

; 143  : 
; 144  : }

  0016c	c9		 leave
  0016d	c2 04 00	 ret	 4
_SerialStartPurge@4 ENDP
PAGESER	ENDS
EXTRN	_SerialHandleReducedIntBuffer@4:NEAR
;	COMDAT _SerialPurgeInterruptBuff@4
PAGESER	SEGMENT
$SG14829 DB	'SERIAL: Pageable code called at IRQL %d without lock ', 0aH
	DB	00H
	ORG $+1
$SG14832 DB	'f:\w2ddk\src\kernel\serial\purge.c', 00H
	ORG $+1
$SG14833 DB	'FALSE', 00H
; Function compile flags: /Ogs
_Context$ = 8
_SerialPurgeInterruptBuff@4 PROC NEAR			; COMDAT

; 169  : {

  00062	55		 push	 ebp
  00063	8b ec		 mov	 ebp, esp
  00065	56		 push	 esi

; 170  : 
; 171  :     PSERIAL_DEVICE_EXTENSION Extension = Context;
; 172  :     SERIAL_LOCKED_PAGED_CODE();

  00066	8b 35 00 00 00
	00		 mov	 esi, DWORD PTR __imp__KeGetCurrentIrql@0
  0006c	ff d6		 call	 esi
  0006e	3c 01		 cmp	 al, 1
  00070	76 32		 jbe	 SHORT $L14830
  00072	83 3d 14 00 00
	00 00		 cmp	 DWORD PTR _SerialGlobals+20, 0
  00079	75 29		 jne	 SHORT $L14830
  0007b	ff d6		 call	 esi
  0007d	0f b6 c0	 movzx	 eax, al
  00080	50		 push	 eax
  00081	68 00 00 00 00	 push	 OFFSET FLAT:$SG14829
  00086	e8 00 00 00 00	 call	 _DbgPrint
  0008b	59		 pop	 ecx
  0008c	59		 pop	 ecx
  0008d	6a 00		 push	 0
  0008f	68 ac 00 00 00	 push	 172			; 000000acH
  00094	68 00 00 00 00	 push	 OFFSET FLAT:$SG14832
  00099	68 00 00 00 00	 push	 OFFSET FLAT:$SG14833
  0009e	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
$L14830:

; 173  : 
; 174  :     //
; 175  :     // The typeahead buffer is by definition empty if there
; 176  :     // currently is a read owned by the isr.
; 177  :     //
; 178  : 
; 179  : 
; 180  :     if (Extension->ReadBufferBase == Extension->InterruptReadBuffer) {

  000a4	8b 45 08	 mov	 eax, DWORD PTR _Context$[ebp]
  000a7	5e		 pop	 esi
  000a8	8b 88 e8 00 00
	00		 mov	 ecx, DWORD PTR [eax+232]
  000ae	39 88 ec 00 00
	00		 cmp	 DWORD PTR [eax+236], ecx
  000b4	75 29		 jne	 SHORT $L14834

; 181  : 
; 182  :         Extension->CurrentCharSlot = Extension->InterruptReadBuffer;
; 183  :         Extension->FirstReadableChar = Extension->InterruptReadBuffer;
; 184  :         Extension->LastCharSlot = Extension->InterruptReadBuffer +
; 185  :                                       (Extension->BufferSize - 1);

  000b6	8b 90 04 01 00
	00		 mov	 edx, DWORD PTR [eax+260]

; 186  :         Extension->CharsInInterruptBuffer = 0;

  000bc	83 a0 f0 00 00
	00 00		 and	 DWORD PTR [eax+240], 0
  000c3	89 88 f4 00 00
	00		 mov	 DWORD PTR [eax+244], ecx
  000c9	89 88 fc 00 00
	00		 mov	 DWORD PTR [eax+252], ecx
  000cf	8d 4c 0a ff	 lea	 ecx, DWORD PTR [edx+ecx-1]

; 187  : 
; 188  :         SerialHandleReducedIntBuffer(Extension);

  000d3	50		 push	 eax
  000d4	89 88 f8 00 00
	00		 mov	 DWORD PTR [eax+248], ecx
  000da	e8 00 00 00 00	 call	 _SerialHandleReducedIntBuffer@4
$L14834:

; 189  : 
; 190  :     }
; 191  : 
; 192  :     return FALSE;

  000df	32 c0		 xor	 al, al

; 193  : 
; 194  : }

  000e1	5d		 pop	 ebp
  000e2	c2 04 00	 ret	 4
_SerialPurgeInterruptBuff@4 ENDP
PAGESER	ENDS
END

⌨️ 快捷键说明

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