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

📄 read.cod

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

	TITLE	F:\W2DDK\src\kernel\serial\read.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 _SerialRead@8
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialStartRead@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialCompleteRead@16
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialCancelCurrentRead@8
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialGrabReadFromIsr@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialReadTimeout@16
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialUpdateReadByIsr@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialIntervalReadTimeout@16
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialGetCharsFromIntBuffer@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialUpdateInterruptBuffer@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialUpdateAndSwitchToUser@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialResizeBuffer@4
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialMoveToNewIntBuffer@8
PAGESER	SEGMENT PARA USE32 PUBLIC ''
PAGESER	ENDS
;	COMDAT _SerialUpdateAndSwitchToNew@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	_SerialRead@8
PUBLIC	_SerialStartRead@4
EXTRN	_SerialIRPPrologue@8:NEAR
EXTRN	_SerialIRPEpilogue@4:NEAR
EXTRN	__imp_@IofCompleteRequest@8:NEAR
EXTRN	_SerialStartOrQueue@20:NEAR
EXTRN	_SerialCompleteIfError@8:NEAR
; Function compile flags: /Ogsy
; File f:\w2ddk\src\kernel\serial\read.c
;	COMDAT _SerialRead@8
PAGESER	SEGMENT
_DeviceObject$ = 8
_Irp$ = 12
_SerialRead@8 PROC NEAR					; COMDAT

; 117  : {

  00000	53		 push	 ebx

; 118  : 
; 119  :     PSERIAL_DEVICE_EXTENSION extension = DeviceObject->DeviceExtension;

  00001	8b 5c 24 08	 mov	 ebx, DWORD PTR _DeviceObject$[esp]
  00005	56		 push	 esi

; 120  :     BOOLEAN acceptingIRPs;
; 121  :     NTSTATUS status;
; 122  : 
; 123  :     SERIAL_LOCKED_PAGED_CODE();
; 124  : 
; 125  :     SerialDump(SERTRACECALLS, ("SERIAL: Entering SerialRead\n"));
; 126  : 
; 127  :     if ((status = SerialIRPPrologue(Irp, extension)) != STATUS_SUCCESS) {

  00006	8b 74 24 10	 mov	 esi, DWORD PTR _Irp$[esp+4]
  0000a	57		 push	 edi
  0000b	8b 7b 28	 mov	 edi, DWORD PTR [ebx+40]
  0000e	57		 push	 edi
  0000f	56		 push	 esi
  00010	e8 00 00 00 00	 call	 _SerialIRPPrologue@8
  00015	85 c0		 test	 eax, eax
  00017	74 04		 je	 SHORT $L14812
  00019	8b d8		 mov	 ebx, eax
  0001b	eb 3e		 jmp	 SHORT $L15136
$L14812:

; 128  :       SerialCompleteRequest(extension, Irp, IO_NO_INCREMENT);
; 129  :       SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialRead (1)\n"));
; 130  :       return status;
; 131  :     }
; 132  : 
; 133  :     SerialDump(
; 134  :         SERIRPPATH,
; 135  :         ("SERIAL: Dispatch entry for: %x\n",Irp)
; 136  :         );
; 137  :     if (SerialCompleteIfError(
; 138  :             DeviceObject,
; 139  :             Irp
; 140  :             ) != STATUS_SUCCESS) {

  0001d	56		 push	 esi
  0001e	53		 push	 ebx
  0001f	e8 00 00 00 00	 call	 _SerialCompleteIfError@8
  00024	85 c0		 test	 eax, eax
  00026	74 07		 je	 SHORT $L14816

; 141  : 
; 142  : 
; 143  :        SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialRead (2)\n"));
; 144  : 
; 145  :         return STATUS_CANCELLED;

  00028	b8 20 01 00 c0	 mov	 eax, -1073741536	; c0000120H
  0002d	eb 3e		 jmp	 SHORT $L14825
$L14816:

; 146  : 
; 147  :     }
; 148  : 
; 149  :     Irp->IoStatus.Information = 0L;
; 150  : 
; 151  :     //
; 152  :     // Quick check for a zero length read.  If it is zero length
; 153  :     // then we are already done!
; 154  :     //
; 155  : 
; 156  :     if (IoGetCurrentIrpStackLocation(Irp)->Parameters.Read.Length) {

  0002f	8b 46 60	 mov	 eax, DWORD PTR [esi+96]
  00032	33 db		 xor	 ebx, ebx
  00034	89 5e 1c	 mov	 DWORD PTR [esi+28], ebx
  00037	39 58 04	 cmp	 DWORD PTR [eax+4], ebx
  0003a	74 1c		 je	 SHORT $L14821

; 157  : 
; 158  :         //
; 159  :         // Well it looks like we actually have to do some
; 160  :         // work.  Put the read on the queue so that we can
; 161  :         // process it when our previous reads are done.
; 162  :         //
; 163  : 
; 164  : 
; 165  :        SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialRead (3)\n"));
; 166  :         return SerialStartOrQueue(
; 167  :                    extension,
; 168  :                    Irp,
; 169  :                    &extension->ReadQueue,
; 170  :                    &extension->CurrentReadIrp,
; 171  :                    SerialStartRead
; 172  :                    );

  0003c	8d 87 c4 00 00
	00		 lea	 eax, DWORD PTR [edi+196]
  00042	68 00 00 00 00	 push	 OFFSET FLAT:_SerialStartRead@4
  00047	50		 push	 eax
  00048	8d 87 a4 00 00
	00		 lea	 eax, DWORD PTR [edi+164]
  0004e	50		 push	 eax
  0004f	56		 push	 esi
  00050	57		 push	 edi
  00051	e8 00 00 00 00	 call	 _SerialStartOrQueue@20
  00056	eb 15		 jmp	 SHORT $L14825
$L14821:

; 173  : 
; 174  :     } else {
; 175  : 
; 176  :         Irp->IoStatus.Status = STATUS_SUCCESS;

  00058	89 5e 18	 mov	 DWORD PTR [esi+24], ebx
$L15136:

; 177  :         SerialDump(
; 178  :             SERIRPPATH,
; 179  :             ("SERIAL: Complete Irp: %x\n",Irp)
; 180  :             );
; 181  :         SerialCompleteRequest(extension, Irp, 0);

  0005b	32 d2		 xor	 dl, dl
  0005d	8b ce		 mov	 ecx, esi
  0005f	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@IofCompleteRequest@8
  00065	57		 push	 edi
  00066	e8 00 00 00 00	 call	 _SerialIRPEpilogue@4

; 182  : 
; 183  : 
; 184  :         SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialRead (4)\n"));
; 185  : 
; 186  :         return STATUS_SUCCESS;

  0006b	8b c3		 mov	 eax, ebx
$L14825:
  0006d	5f		 pop	 edi
  0006e	5e		 pop	 esi
  0006f	5b		 pop	 ebx

; 187  : 
; 188  :     }
; 189  : 
; 190  : }

  00070	c2 08 00	 ret	 8
_SerialRead@8 ENDP
PAGESER	ENDS
PUBLIC	_SerialGetCharsFromIntBuffer@4
PUBLIC	_SerialUpdateInterruptBuffer@4
PUBLIC	_SerialUpdateAndSwitchToUser@4
PUBLIC	_SerialResizeBuffer@4
EXTRN	__imp__KeSynchronizeExecution@12:NEAR
EXTRN	__imp_@KfAcquireSpinLock@4:NEAR
EXTRN	__imp_@KfReleaseSpinLock@8:NEAR
EXTRN	__imp__KeQuerySystemTime@4:NEAR
EXTRN	__imp__IoAcquireCancelSpinLock@4:NEAR
EXTRN	_SerialSetTimer@20:NEAR
EXTRN	_SerialCancelTimer@8:NEAR
EXTRN	_SerialGetNextIrp@20:NEAR
EXTRN	__imp__IoReleaseCancelSpinLock@4:NEAR
EXTRN	__allmul:NEAR
; Function compile flags: /Ogsy
;	COMDAT _SerialStartRead@4
PAGESER	SEGMENT
_Extension$ = 8
_updateChar$ = -40
_newIrp$ = -20
_oldIrql$ = -16
_controlIrql$ = -2
_returnWithWhatsPresent$ = -4
_os2ssreturn$ = -3
_crunchDownToOne$ = -5
_useTotalTimer$ = 11
_useIntervalTimer$ = -6
_totalTime$ = -28
_timeoutsForIrp$ = -60
_setFirstStatus$ = -1
_firstStatus$ = -12
_SerialStartRead@4 PROC NEAR				; COMDAT

; 222  : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	83 ec 3c	 sub	 esp, 60			; 0000003cH

; 223  : 
; 224  :     SERIAL_UPDATE_CHAR updateChar;
; 225  : 
; 226  :     PIRP newIrp;
; 227  :     KIRQL oldIrql;
; 228  :     KIRQL controlIrql;
; 229  : 
; 230  :     BOOLEAN returnWithWhatsPresent;
; 231  :     BOOLEAN os2ssreturn;
; 232  :     BOOLEAN crunchDownToOne;
; 233  :     BOOLEAN useTotalTimer;
; 234  :     BOOLEAN useIntervalTimer;
; 235  : 
; 236  :     ULONG multiplierVal;
; 237  :     ULONG constantVal;
; 238  : 
; 239  :     LARGE_INTEGER totalTime;
; 240  : 
; 241  :     SERIAL_TIMEOUTS timeoutsForIrp;
; 242  : 
; 243  :     BOOLEAN setFirstStatus = FALSE;

  00006	80 65 ff 00	 and	 BYTE PTR _setFirstStatus$[ebp], 0
  0000a	53		 push	 ebx

; 244  :     NTSTATUS firstStatus;
; 245  : 
; 246  :     SERIAL_LOCKED_PAGED_CODE();
; 247  : 
; 248  : 
; 249  :     SerialDump(SERTRACECALLS, ("SERIAL: SerialStartRead\n"));
; 250  : 
; 251  :     updateChar.Extension = Extension;

  0000b	8b 5d 08	 mov	 ebx, DWORD PTR _Extension$[ebp]
  0000e	56		 push	 esi
  0000f	57		 push	 edi
  00010	89 5d d8	 mov	 DWORD PTR _updateChar$[ebp], ebx
  00013	8d b3 c4 00 00
	00		 lea	 esi, DWORD PTR [ebx+196]
$L14855:

; 252  : 
; 253  :     do {
; 254  : 
; 255  :         //
; 256  :         // Check to see if this is a resize request.  If it is
; 257  :         // then go to a routine that specializes in that.
; 258  :         //
; 259  : 
; 260  :         if (IoGetCurrentIrpStackLocation(Extension->CurrentReadIrp)
; 261  :             ->MajorFunction != IRP_MJ_READ) {

  00019	8b 06		 mov	 eax, DWORD PTR [esi]

; 262  : 
; 263  :             NTSTATUS localStatus = SerialResizeBuffer(Extension);

  0001b	53		 push	 ebx
  0001c	8b 40 60	 mov	 eax, DWORD PTR [eax+96]
  0001f	80 38 03	 cmp	 BYTE PTR [eax], 3
  00022	74 0a		 je	 SHORT $L14858
  00024	e8 00 00 00 00	 call	 _SerialResizeBuffer@4

; 264  : 
; 265  :             if (!setFirstStatus) {
; 266  : 
; 267  :                 firstStatus = localStatus;
; 268  :                 setFirstStatus = TRUE;
; 269  : 
; 270  :             }
; 271  : 
; 272  :         } else {

  00029	e9 8c 01 00 00	 jmp	 $L15164
$L14858:

; 273  : 
; 274  :             Extension->NumberNeededForRead =
; 275  :                 IoGetCurrentIrpStackLocation(Extension->CurrentReadIrp)
; 276  :                     ->Parameters.Read.Length;

  0002e	8b 40 04	 mov	 eax, DWORD PTR [eax+4]

; 277  : 
; 278  :             //
; 279  :             // Calculate the timeout value needed for the
; 280  :             // request.  Note that the values stored in the
; 281  :             // timeout record are in milliseconds.
; 282  :             //
; 283  : 
; 284  :             useTotalTimer = FALSE;

  00031	80 65 0b 00	 and	 BYTE PTR _useTotalTimer$[ebp], 0

; 285  :             returnWithWhatsPresent = FALSE;

  00035	80 65 fc 00	 and	 BYTE PTR _returnWithWhatsPresent$[ebp], 0

; 286  :             os2ssreturn = FALSE;

  00039	80 65 fd 00	 and	 BYTE PTR _os2ssreturn$[ebp], 0

; 287  :             crunchDownToOne = FALSE;

  0003d	80 65 fb 00	 and	 BYTE PTR _crunchDownToOne$[ebp], 0

; 288  :             useIntervalTimer = FALSE;

  00041	80 65 fa 00	 and	 BYTE PTR _useIntervalTimer$[ebp], 0
  00045	89 83 0c 01 00
	00		 mov	 DWORD PTR [ebx+268], eax

; 289  : 
; 290  :             //
; 291  :             //
; 292  :             // CIMEXCIMEX -- this is a lie
; 293  :             //
; 294  :             // Always initialize the timer objects so that the
; 295  :             // completion code can tell when it attempts to
; 296  :             // cancel the timers whether the timers had ever
; 297  :             // been Set.
; 298  :             //
; 299  :             // CIMEXCIMEX -- this is the truth
; 300  :             //
; 301  :             // What we want to do is just make sure the timers are
; 302  :             // cancelled to the best of our ability and move on with
; 303  :             // life.
; 304  :             //
; 305  : 
; 306  :             SerialCancelTimer(&Extension->ReadRequestTotalTimer, Extension);

⌨️ 快捷键说明

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