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

📄 openclos.cod

📁 怎样在win2000下构造驱动程序znsoft_Serial2000_demo.ZIP
💻 COD
📖 第 1 页 / 共 5 页
字号:
; 770  : 
; 771  :     //
; 772  :     // Reset for next open
; 773  :     //
; 774  : 
; 775  :     InterlockedIncrement(&extension->DpcCount);

  0054b	8b cf		 mov	 ecx, edi
  0054d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@InterlockedIncrement@4

; 776  :     LOGENTRY(LOG_CNT, 'DpI6', 0, extension->DpcCount, 0);

  00553	53		 push	 ebx
  00554	ff 37		 push	 DWORD PTR [edi]
  00556	53		 push	 ebx
  00557	68 36 49 70 44	 push	 1148209462		; 44704936H
  0055c	6a 02		 push	 2
  0055e	e8 00 00 00 00	 call	 _SerialDebugLogEntry@20

; 777  : 
; 778  :     openCount = InterlockedDecrement(&extension->OpenCount);

  00563	8b 4d f4	 mov	 ecx, DWORD PTR -12+[ebp]
  00566	8b 35 00 00 00
	00		 mov	 esi, DWORD PTR __imp_@InterlockedDecrement@4
  0056c	ff d6		 call	 esi

; 779  : 
; 780  :     ASSERT(openCount == 0);

  0056e	85 c0		 test	 eax, eax
  00570	74 16		 je	 SHORT $L15133
  00572	53		 push	 ebx
  00573	68 0c 03 00 00	 push	 780			; 0000030cH
  00578	68 00 00 00 00	 push	 OFFSET FLAT:$SG15135
  0057d	68 00 00 00 00	 push	 OFFSET FLAT:$SG15136
  00582	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
$L15133:

; 781  :     SerialUnlockPagableImageSection(SerialGlobals.PAGESER_Handle);

  00588	b9 14 00 00 00	 mov	 ecx, OFFSET FLAT:_SerialGlobals+20
  0058d	ff d6		 call	 esi
  0058f	ff 35 08 00 00
	00		 push	 DWORD PTR _SerialGlobals+8
  00595	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__MmUnlockPagableImageSection@4

; 782  : 
; 783  :     return STATUS_SUCCESS;

  0059b	33 c0		 xor	 eax, eax
$L14960:
  0059d	5f		 pop	 edi
  0059e	5e		 pop	 esi
  0059f	5b		 pop	 ebx

; 784  : 
; 785  : }

  005a0	c9		 leave
  005a1	c2 08 00	 ret	 8
_SerialClose@8 ENDP
; Function compile flags: /Ogs
PAGESER	ENDS
;	COMDAT _SerialCheckOpen@4
PAGESER	SEGMENT
_Context$ = 8
_SerialCheckOpen@4 PROC NEAR				; COMDAT

; 833  : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp

; 834  : 
; 835  :     PSERIAL_DEVICE_EXTENSION extensionToOpen =
; 836  :         ((PSERIAL_CHECK_OPEN)Context)->Extension;

  00003	8b 4d 08	 mov	 ecx, DWORD PTR _Context$[ebp]
  00006	53		 push	 ebx
  00007	56		 push	 esi

; 837  :     NTSTATUS *status = ((PSERIAL_CHECK_OPEN)Context)->StatusOfOpen;
; 838  :     PLIST_ENTRY firstEntry = &extensionToOpen->CommonInterruptObject;
; 839  :     PLIST_ENTRY currentEntry = firstEntry;

  00008	33 db		 xor	 ebx, ebx
  0000a	8b 01		 mov	 eax, DWORD PTR [ecx]
  0000c	8b 51 04	 mov	 edx, DWORD PTR [ecx+4]
  0000f	8d 70 10	 lea	 esi, DWORD PTR [eax+16]
  00012	8b ce		 mov	 ecx, esi
$L15148:

; 840  :     PSERIAL_DEVICE_EXTENSION currentExtension;
; 841  : 
; 842  :     do {
; 843  : 
; 844  :         currentExtension = CONTAINING_RECORD(
; 845  :                                currentEntry,
; 846  :                                SERIAL_DEVICE_EXTENSION,
; 847  :                                CommonInterruptObject
; 848  :                                );
; 849  : 
; 850  :         if (currentExtension->DeviceIsOpened) {

  00014	38 99 8d 01 00
	00		 cmp	 BYTE PTR [ecx+397], bl
  0001a	75 08		 jne	 SHORT $L15150

; 851  : 
; 852  :             break;
; 853  : 
; 854  :         }
; 855  : 
; 856  :         currentEntry = currentExtension->CommonInterruptObject.Flink;

  0001c	8b 09		 mov	 ecx, DWORD PTR [ecx]

; 857  : 
; 858  :     } while (currentEntry != firstEntry);

  0001e	3b ce		 cmp	 ecx, esi
  00020	75 f2		 jne	 SHORT $L15148
  00022	eb 1c		 jmp	 SHORT $L15162
$L15150:

; 859  : 
; 860  :     if (currentEntry == firstEntry) {

  00024	3b ce		 cmp	 ecx, esi

; 861  : 
; 862  :         //
; 863  :         // We searched the whole list and found no other opens
; 864  :         // mark the status as successful and call the regular
; 865  :         // opening routine.
; 866  :         //
; 867  : 
; 868  :         *status = STATUS_SUCCESS;
; 869  :         SerialMarkOpen(extensionToOpen);
; 870  : 
; 871  :     } else {

  00026	74 18		 je	 SHORT $L15162

; 872  : 
; 873  :         if (!extensionToOpen->PortOnAMultiportCard) {

  00028	38 98 a3 01 00
	00		 cmp	 BYTE PTR [eax+419], bl
  0002e	75 08		 jne	 SHORT $L15159
$L15365:

; 874  : 
; 875  :             *status = STATUS_SHARED_IRQ_BUSY;

  00030	c7 02 6c 01 00
	c0		 mov	 DWORD PTR [edx], -1073741460 ; c000016cH

; 876  : 
; 877  :         } else {

  00036	eb 10		 jmp	 SHORT $L15164
$L15159:

; 878  : 
; 879  :             if (!currentExtension->PortOnAMultiportCard) {

  00038	38 99 93 01 00
	00		 cmp	 BYTE PTR [ecx+403], bl

; 880  : 
; 881  :                 *status = STATUS_SHARED_IRQ_BUSY;
; 882  : 
; 883  :             } else {

  0003e	74 f0		 je	 SHORT $L15365
$L15162:

; 884  : 
; 885  :                 *status = STATUS_SUCCESS;
; 886  :                 SerialMarkOpen(extensionToOpen);

  00040	50		 push	 eax
  00041	89 1a		 mov	 DWORD PTR [edx], ebx
  00043	e8 00 00 00 00	 call	 _SerialMarkOpen@4
$L15164:
  00048	5e		 pop	 esi

; 887  : 
; 888  :             }
; 889  : 
; 890  :         }
; 891  : 
; 892  :     }
; 893  : 
; 894  :     return FALSE;

  00049	32 c0		 xor	 al, al
  0004b	5b		 pop	 ebx

; 895  : 
; 896  : }

  0004c	5d		 pop	 ebp
  0004d	c2 04 00	 ret	 4
_SerialCheckOpen@4 ENDP
PAGESER	ENDS
EXTRN	_SerialReset@4:NEAR
; Function compile flags: /Ogs
;	COMDAT _SerialMarkOpen@4
PAGESER	SEGMENT
_Context$ = 8
_SerialMarkOpen@4 PROC NEAR				; COMDAT

; 921  : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	56		 push	 esi

; 922  : 
; 923  :     PSERIAL_DEVICE_EXTENSION extension = Context;
; 924  : 
; 925  :     SerialReset(extension);

  00004	8b 75 08	 mov	 esi, DWORD PTR _Context$[ebp]
  00007	57		 push	 edi
  00008	56		 push	 esi
  00009	e8 00 00 00 00	 call	 _SerialReset@4

; 926  : 
; 927  :     //
; 928  :     // Prepare for the opening by re-enabling interrupts.
; 929  :     //
; 930  :     // We do this my modifying the OUT2 line in the modem control.
; 931  :     // In PC's this bit is "anded" with the interrupt line.
; 932  :     //
; 933  :     // For the Jensen, we will ALWAYS leave the line high.  That's
; 934  :     // the way the hardware engineers want it.
; 935  :     //
; 936  : 
; 937  :     WRITE_MODEM_CONTROL(
; 938  :         extension->Controller,
; 939  :         (UCHAR)(READ_MODEM_CONTROL(extension->Controller) | SERIAL_MCR_OUT2)
; 940  :         );

  0000e	8d be 98 00 00
	00		 lea	 edi, DWORD PTR [esi+152]
  00014	8b 07		 mov	 eax, DWORD PTR [edi]
  00016	83 c0 04	 add	 eax, 4
  00019	50		 push	 eax
  0001a	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__READ_PORT_UCHAR@4
  00020	0c 08		 or	 al, 8
  00022	50		 push	 eax
  00023	8b 07		 mov	 eax, DWORD PTR [edi]
  00025	83 c0 04	 add	 eax, 4
  00028	50		 push	 eax
  00029	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__WRITE_PORT_UCHAR@8

; 941  : 
; 942  :     extension->DeviceIsOpened = TRUE;
; 943  :     extension->ErrorWord = 0;

  0002f	83 a6 24 01 00
	00 00		 and	 DWORD PTR [esi+292], 0
  00036	c6 86 9d 01 00
	00 01		 mov	 BYTE PTR [esi+413], 1
  0003d	5f		 pop	 edi

; 944  : 
; 945  :     return FALSE;

  0003e	32 c0		 xor	 al, al
  00040	5e		 pop	 esi

; 946  : 
; 947  : }

  00041	5d		 pop	 ebp
  00042	c2 04 00	 ret	 4
_SerialMarkOpen@4 ENDP
PAGESER	ENDS
PUBLIC	_SerialDisableUART@4
; Function compile flags: /Ogs
;	COMDAT _SerialDisableUART@4
_TEXT	SEGMENT
_Context$ = 8
_SerialDisableUART@4 PROC NEAR				; COMDAT

; 970  : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	57		 push	 edi

; 971  :    PSERIAL_DEVICE_EXTENSION extension = Context;
; 972  : 
; 973  :    //
; 974  :    // Prepare for the closing by stopping interrupts.
; 975  :    //
; 976  :    // We do this by adjusting the OUT2 line in the modem control.
; 977  :    // In PC's this bit is "anded" with the interrupt line.
; 978  :    //
; 979  :    // The line should stay high on the Jensen because that's the
; 980  :    // way the hardware engineers did it.
; 981  :    //
; 982  : 
; 983  :    if (!extension->Jensen) {

  00004	8b 7d 08	 mov	 edi, DWORD PTR _Context$[ebp]
  00007	80 bf de 01 00
	00 00		 cmp	 BYTE PTR [edi+478], 0
  0000e	75 23		 jne	 SHORT $L15183
  00010	56		 push	 esi

; 984  :       WRITE_MODEM_CONTROL(extension->Controller,
; 985  :                           (UCHAR)(READ_MODEM_CONTROL(extension->Controller)
; 986  :                                   & ~SERIAL_MCR_OUT2));

  00011	8d b7 98 00 00
	00		 lea	 esi, DWORD PTR [edi+152]
  00017	8b 06		 mov	 eax, DWORD PTR [esi]
  00019	83 c0 04	 add	 eax, 4
  0001c	50		 push	 eax
  0001d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__READ_PORT_UCHAR@4
  00023	24 f7		 and	 al, 247			; 000000f7H
  00025	50		 push	 eax
  00026	8b 06		 mov	 eax, DWORD PTR [esi]
  00028	83 c0 04	 add	 eax, 4
  0002b	50		 push	 eax
  0002c	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__WRITE_PORT_UCHAR@8
  00032	5e		 pop	 esi
$L15183:

; 987  :    }
; 988  : 
; 989  :    if (extension->FifoPresent) {

  00033	80 bf dd 01 00
	00 00		 cmp	 BYTE PTR [edi+477], 0
  0003a	74 11		 je	 SHORT $L15190

; 990  :       WRITE_FIFO_CONTROL(extension->Controller, (UCHAR)0);

  0003c	8b 87 98 00 00
	00		 mov	 eax, DWORD PTR [edi+152]
  00042	6a 00		 push	 0
  00044	40		 inc	 eax
  00045	40		 inc	 eax
  00046	50		 push	 eax
  00047	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__WRITE_PORT_UCHAR@8
$L15190:
  0004d	5f		 pop	 edi

; 991  :     }
; 992  : }

  0004e	5d		 pop	 ebp
  0004f	c2 04 00	 ret	 4
_SerialDisableUART@4 ENDP
; Function compile flags: /Ogs
_TEXT	ENDS
;	COMDAT _SerialMarkClose@4
_TEXT	SEGMENT
_Context$ = 8
_SerialMarkClose@4 PROC NEAR				; COMDAT

; 1018 : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	56		 push	 esi

; 1019 : 
; 1020 :     PSERIAL_DEVICE_EXTENSION extension = Context;
; 1021 : 
; 1022 :     SerialDisableUART(Context);

  00004	8b 75 08	 mov	 esi, DWORD PTR _Context$[ebp]
  00007	56		 push	 esi
  00008	e8 00 00 00 00	 call	 _SerialDisableUART@4

; 1023 :     extension->DeviceIsOpened = FALSE;

  0000d	80 a6 9d 01 00
	00 00		 and	 BYTE PTR [esi+413], 0

; 1024 : 
; 1025 :     return FALSE;

  00014	32 c0		 xor	 al, al
  00016	5e		 pop	 esi

; 1026 : 
; 1027 : }

  00017	5d		 pop	 ebp
  00018	c2 04 00	 ret	 4
_SerialMarkClose@4 ENDP
_TEXT	ENDS
PUBLIC	_SerialCleanup@8
EXTRN	_SerialKillPendingIrps@4:NEAR
;	COMDAT _SerialCleanup@8
PAGESER	SEGMENT
$SG15205 DB	'EX: Pageable code called at IRQL %d', 0aH, 00H
	ORG $+3
$SG15208 DB	'f:\w2ddk\src\kernel\serial\openclos.c', 00H
	ORG $+2
$SG15209 DB	'FALSE', 00H
	ORG $+2
$SG15221 DB	'SERIAL: Dispatch entry for: %x', 0aH, 00H
$SG15235 DB	'SERIAL: Complete Irp: %x', 0aH, 00H
; Function compile flags: /Ogs
_DeviceObject$ = 8
_Irp$ = 12
_extension$ = 8
_SerialCleanup@8 PROC NEAR				; COMDAT

; 1054 : {

  00092	55		 push	 ebp
  00093	8b ec		 mov	 ebp, esp
  00095	53		 push	 ebx

; 1055 : 
; 1056 :     PSERIAL_DEVICE_EXTENSION extension = DeviceObject->DeviceExtension;

  00096	8b 5d 08	 mov	 ebx, DWORD PTR _DeviceObject$[ebp]
  00099	56		 push	 esi

; 1057 :     NTSTATUS status;
; 1058 : 
; 1059 : 
; 1060 :     PAGED_CODE();

  0009a	8b 35 00 00 00
	00		 mov	 esi, DWORD PTR __imp__KeGetCurrentIrql@0
  000a0	8b 43 28	 mov	 eax, DWORD PTR [ebx+40]
  000a3	57		 push	 edi
  000a4	89 45 08	 mov	 DWORD PTR _extension$[ebp], eax
  000a7	ff d6		 call	 esi
  000a9	33 ff		 xor	 edi, edi
  000ab	3c 01		 cmp	 al, 1
  000ad	76 28		 jbe	 SHORT $L15206
  000af	ff d6		 call	 esi
  000b1	0f b6 c0	 movzx	 eax, al
  000b4	50		 push	 eax
  000b5	68 00 00 00 00	 push	 OFFSET FLAT:$SG15205
  000ba	e8 00 00 00 00	 call	 _DbgPrint
  00

⌨️ 快捷键说明

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