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

📄 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_@KfAcquireSpinLock@4:NEAR
EXTRN	__imp_@KfReleaseSpinLock@8:NEAR
EXTRN	_SerialKillAllReadsOrWrites@12:NEAR
EXTRN	_SerialGetNextIrp@20:NEAR
; Function compile flags: /Ogsy
; File f:\w2ddk\src\kernel\serial\purge.c
;	COMDAT _SerialStartPurge@4
PAGESER	SEGMENT
_Extension$ = 8
_NewIrp$ = -4
_Mask$14772 = 8
_SerialStartPurge@4 PROC NEAR				; COMDAT

; 59   : {

  00000	51		 push	 ecx
  00001	53		 push	 ebx
  00002	55		 push	 ebp
  00003	56		 push	 esi
  00004	8b 74 24 14	 mov	 esi, DWORD PTR _Extension$[esp+12]
  00008	57		 push	 edi
  00009	8d be d0 00 00
	00		 lea	 edi, DWORD PTR [esi+208]
$L14769:

; 60   : 
; 61   :     PIRP NewIrp;
; 62   : 
; 63   :     SERIAL_LOCKED_PAGED_CODE();
; 64   : 
; 65   :     do {
; 66   : 
; 67   :         ULONG Mask;
; 68   : 
; 69   :         Mask = *((ULONG *)
; 70   :                  (Extension->CurrentPurgeIrp->AssociatedIrp.SystemBuffer));

  0000f	8b 07		 mov	 eax, DWORD PTR [edi]
  00011	8b 40 0c	 mov	 eax, DWORD PTR [eax+12]
  00014	8b 18		 mov	 ebx, DWORD PTR [eax]

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

  00016	f6 c3 01	 test	 bl, 1
  00019	89 5c 24 18	 mov	 DWORD PTR _Mask$14772[esp+16], ebx
  0001d	74 30		 je	 SHORT $L14774

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

  0001f	8d 86 c8 00 00
	00		 lea	 eax, DWORD PTR [esi+200]
  00025	8d 9e ac 00 00
	00		 lea	 ebx, DWORD PTR [esi+172]
  0002b	8d ae 8c 00 00
	00		 lea	 ebp, DWORD PTR [esi+140]
  00031	50		 push	 eax
  00032	53		 push	 ebx
  00033	ff 75 00	 push	 DWORD PTR [ebp]
  00036	e8 00 00 00 00	 call	 _SerialKillAllReadsOrWrites@12

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

  0003b	8d 86 dc 00 00
	00		 lea	 eax, DWORD PTR [esi+220]
  00041	50		 push	 eax
  00042	53		 push	 ebx
  00043	ff 75 00	 push	 DWORD PTR [ebp]
  00046	e8 00 00 00 00	 call	 _SerialKillAllReadsOrWrites@12
  0004b	8b 5c 24 18	 mov	 ebx, DWORD PTR _Mask$14772[esp+16]
$L14774:

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

  0004f	f6 c3 02	 test	 bl, 2
  00052	74 19		 je	 SHORT $L14775

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

  00054	8d 86 c4 00 00
	00		 lea	 eax, DWORD PTR [esi+196]
  0005a	50		 push	 eax
  0005b	8d 86 a4 00 00
	00		 lea	 eax, DWORD PTR [esi+164]
  00061	50		 push	 eax
  00062	ff b6 8c 00 00
	00		 push	 DWORD PTR [esi+140]
  00068	e8 00 00 00 00	 call	 _SerialKillAllReadsOrWrites@12
$L14775:

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

  0006d	f6 c3 08	 test	 bl, 8
  00070	74 2c		 je	 SHORT $L14776

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

  00072	8d ae e4 01 00
	00		 lea	 ebp, DWORD PTR [esi+484]
  00078	8b cd		 mov	 ecx, ebp
  0007a	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfAcquireSpinLock@4

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

  00080	56		 push	 esi
  00081	68 00 00 00 00	 push	 OFFSET FLAT:_SerialPurgeInterruptBuff@4
  00086	ff b6 a0 00 00
	00		 push	 DWORD PTR [esi+160]
  0008c	8a d8		 mov	 bl, al
  0008e	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__KeSynchronizeExecution@12

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

  00094	8a d3		 mov	 dl, bl
  00096	8b cd		 mov	 ecx, ebp
  00098	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@KfReleaseSpinLock@8
$L14776:

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

  0009e	8b 07		 mov	 eax, DWORD PTR [edi]
  000a0	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  :             );

  000a2	56		 push	 esi
  000a3	6a 01		 push	 1
  000a5	89 58 18	 mov	 DWORD PTR [eax+24], ebx
  000a8	8b 07		 mov	 eax, DWORD PTR [edi]
  000aa	89 58 1c	 mov	 DWORD PTR [eax+28], ebx
  000ad	8d 44 24 18	 lea	 eax, DWORD PTR _NewIrp$[esp+28]
  000b1	50		 push	 eax
  000b2	8d 86 bc 00 00
	00		 lea	 eax, DWORD PTR [esi+188]
  000b8	50		 push	 eax
  000b9	57		 push	 edi
  000ba	e8 00 00 00 00	 call	 _SerialGetNextIrp@20

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

  000bf	39 5c 24 10	 cmp	 DWORD PTR _NewIrp$[esp+20], ebx
  000c3	0f 85 46 ff ff
	ff		 jne	 $L14769
  000c9	5f		 pop	 edi
  000ca	5e		 pop	 esi
  000cb	5d		 pop	 ebp

; 141  : 
; 142  :     return STATUS_SUCCESS;

  000cc	33 c0		 xor	 eax, eax
  000ce	5b		 pop	 ebx

; 143  : 
; 144  : }

  000cf	59		 pop	 ecx
  000d0	c2 04 00	 ret	 4
_SerialStartPurge@4 ENDP
PAGESER	ENDS
EXTRN	_SerialHandleReducedIntBuffer@4:NEAR
; Function compile flags: /Ogsy
;	COMDAT _SerialPurgeInterruptBuff@4
PAGESER	SEGMENT
_Context$ = 8
_SerialPurgeInterruptBuff@4 PROC NEAR			; COMDAT

; 170  : 
; 171  :     PSERIAL_DEVICE_EXTENSION Extension = Context;
; 172  :     SERIAL_LOCKED_PAGED_CODE();
; 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) {

  00000	8b 44 24 04	 mov	 eax, DWORD PTR _Context$[esp-4]
  00004	8b 88 e8 00 00
	00		 mov	 ecx, DWORD PTR [eax+232]
  0000a	39 88 ec 00 00
	00		 cmp	 DWORD PTR [eax+236], ecx
  00010	75 29		 jne	 SHORT $L14784

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

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

; 186  :         Extension->CharsInInterruptBuffer = 0;

  00018	83 a0 f0 00 00
	00 00		 and	 DWORD PTR [eax+240], 0
  0001f	89 88 f4 00 00
	00		 mov	 DWORD PTR [eax+244], ecx
  00025	89 88 fc 00 00
	00		 mov	 DWORD PTR [eax+252], ecx
  0002b	8d 4c 0a ff	 lea	 ecx, DWORD PTR [edx+ecx-1]

; 187  : 
; 188  :         SerialHandleReducedIntBuffer(Extension);

  0002f	50		 push	 eax
  00030	89 88 f8 00 00
	00		 mov	 DWORD PTR [eax+248], ecx
  00036	e8 00 00 00 00	 call	 _SerialHandleReducedIntBuffer@4
$L14784:

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

  0003b	32 c0		 xor	 al, al

; 193  : 
; 194  : }

  0003d	c2 04 00	 ret	 4
_SerialPurgeInterruptBuff@4 ENDP
PAGESER	ENDS
END

⌨️ 快捷键说明

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