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

📄 legacy.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\legacy.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
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _RtlConvertLongToLargeInteger@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialTranslateResourceList@24
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _SerialBuildRequirementsList@12
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _SerialBuildResourceList@12
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _SerialMigrateLegacyRegistry@12
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _SerialIsUserDataValid@20
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _SerialEnumerateLegacy@12
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif

INCLUDELIB LIBC
INCLUDELIB OLDNAMES

CONST	SEGMENT
_SerialPhysicalZero DD 00H
	ORG $+4
CONST	ENDS
PUBLIC	_SerialTranslateResourceList@24
EXTRN	_SerialLogError@64:NEAR
EXTRN	__imp__HalGetInterruptVector@24:NEAR
EXTRN	__imp__HalTranslateBusAddress@24:NEAR
; Function compile flags: /Ogsy
; File f:\w2ddk\src\kernel\serial\legacy.c
;	COMDAT _SerialTranslateResourceList@24
INIT	SEGMENT
_DriverObject$ = 8
_UserSubKey$ = 12
_PTrResourceList$ = 16
_PResourceList$ = 20
_PartialCount$ = 24
_PUserData$ = 28
_outIrql$ = 31
_outAffinity$ = -8
_outAddrSpace$ = 20
_outPhysAddr$ = -16
_status$ = -4
_SerialTranslateResourceList@24 PROC NEAR		; COMDAT

; 77   : {

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	83 ec 10	 sub	 esp, 16			; 00000010H

; 78   :    KIRQL outIrql;
; 79   :    KAFFINITY outAffinity = (KAFFINITY)-1;

  00006	83 4d f8 ff	 or	 DWORD PTR _outAffinity$[ebp], -1

; 80   :    ULONG outAddrSpace;
; 81   :    PHYSICAL_ADDRESS outPhysAddr;
; 82   :    NTSTATUS status = STATUS_SUCCESS;

  0000a	83 65 fc 00	 and	 DWORD PTR _status$[ebp], 0
  0000e	53		 push	 ebx

; 83   : 
; 84   :    PAGED_CODE();
; 85   : 
; 86   :    SerialDump(SERTRACECALLS, ("SERIAL: Enter SerialTranslateResourceList\n"));
; 87   : 
; 88   :    outIrql = (KIRQL)(PUserData->UserLevel ? PUserData->UserLevel
; 89   :       : PUserData->UserVector);

  0000f	8b 5d 1c	 mov	 ebx, DWORD PTR _PUserData$[ebp]
  00012	56		 push	 esi
  00013	57		 push	 edi
  00014	8b 43 38	 mov	 eax, DWORD PTR [ebx+56]
  00017	85 c0		 test	 eax, eax
  00019	75 03		 jne	 SHORT $L15550
  0001b	8a 43 10	 mov	 al, BYTE PTR [ebx+16]
$L15550:

; 90   : 
; 91   :    //
; 92   :    // Copy the list over to the translated buffer and fixup and translate
; 93   :    // what we need.
; 94   :    //
; 95   :    RtlCopyMemory(PTrResourceList, PResourceList, sizeof(CM_RESOURCE_LIST)
; 96   :                  + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * 2);

  0001e	8b 75 14	 mov	 esi, DWORD PTR _PResourceList$[ebp]
  00021	88 45 1f	 mov	 BYTE PTR _outIrql$[ebp], al
  00024	8b 45 10	 mov	 eax, DWORD PTR _PTrResourceList$[ebp]
  00027	6a 11		 push	 17			; 00000011H
  00029	59		 pop	 ecx
  0002a	8b f8		 mov	 edi, eax
  0002c	f3 a5		 rep movsd

; 97   : 
; 98   :    outAddrSpace = PTrResourceList->List[0].PartialResourceList
; 99   :                   .PartialDescriptors[0].Flags;

  0002e	0f b7 48 16	 movzx	 ecx, WORD PTR [eax+22]
  00032	89 4d 14	 mov	 DWORD PTR _outAddrSpace$[ebp], ecx

; 100  :    outPhysAddr = PTrResourceList->List[0].PartialResourceList
; 101  :                  .PartialDescriptors[0].u.Port.Start;

  00035	8b 48 18	 mov	 ecx, DWORD PTR [eax+24]
  00038	8b 40 1c	 mov	 eax, DWORD PTR [eax+28]
  0003b	89 4d f0	 mov	 DWORD PTR _outPhysAddr$[ebp], ecx
  0003e	89 45 f4	 mov	 DWORD PTR _outPhysAddr$[ebp+4], eax

; 102  : 
; 103  : 
; 104  :    if (HalTranslateBusAddress(PUserData->UserInterfaceType,
; 105  :                               PUserData->UserBusNumber, PUserData->UserPort,
; 106  :                               &outAddrSpace, &outPhysAddr)
; 107  :        == 0) {

  00041	8d 45 f0	 lea	 eax, DWORD PTR _outPhysAddr$[ebp]
  00044	50		 push	 eax
  00045	8d 45 14	 lea	 eax, DWORD PTR _outAddrSpace$[ebp]
  00048	50		 push	 eax
  00049	ff 73 04	 push	 DWORD PTR [ebx+4]
  0004c	ff 33		 push	 DWORD PTR [ebx]
  0004e	ff 73 20	 push	 DWORD PTR [ebx+32]
  00051	ff 73 24	 push	 DWORD PTR [ebx+36]
  00054	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__HalTranslateBusAddress@24
  0005a	84 c0		 test	 al, al
  0005c	75 1e		 jne	 SHORT $L14792

; 108  :       SerialLogError(DriverObject, NULL, PUserData->UserPort,
; 109  :                      SerialPhysicalZero, 0, 0, 0, 60, STATUS_SUCCESS,
; 110  :                      SERIAL_NO_TRANSLATE_PORT, UserSubKey->NameLength
; 111  :                      + sizeof(WCHAR), &UserSubKey->Name[0], 0, NULL);

  0005e	8b 4d 0c	 mov	 ecx, DWORD PTR _UserSubKey$[ebp]
  00061	33 c0		 xor	 eax, eax
  00063	50		 push	 eax
  00064	50		 push	 eax
  00065	8d 51 10	 lea	 edx, DWORD PTR [ecx+16]
  00068	8b 49 0c	 mov	 ecx, DWORD PTR [ecx+12]
  0006b	41		 inc	 ecx
  0006c	52		 push	 edx
  0006d	41		 inc	 ecx
  0006e	51		 push	 ecx
  0006f	68 25 00 06 c0	 push	 -1073348571		; c0060025H
  00074	50		 push	 eax
  00075	6a 3c		 push	 60			; 0000003cH

; 112  : 
; 113  :       SerialDump(SERERRORS, ("SERIAL: Port map failed attempt was \n"
; 114  :                              "------- Interface:  %x\n"
; 115  :                              "------- Bus Number: %x\n"
; 116  :                              "------- userPort:  %x\n"
; 117  :                              "------- AddrSpace:  %x\n"
; 118  :                              "------- PhysAddr:   %x\n",
; 119  :                              PUserData->UserInterfaceType,
; 120  :                              PUserData->UserBusNumber,
; 121  :                              PUserData->UserPort,
; 122  :                              PTrResourceList->List[0].
; 123  :                              PartialResourceList.PartialDescriptors[0]
; 124  :                              .Flags,
; 125  :                              PTrResourceList->List[0].
; 126  :                              PartialResourceList.PartialDescriptors[0]
; 127  :                              .u.Port.Start.QuadPart));
; 128  : 
; 129  :       status = STATUS_NONE_MAPPED;
; 130  :       goto SerialTranslateError;

  00077	e9 cd 00 00 00	 jmp	 $L15552
$L14792:

; 131  :    }
; 132  : 
; 133  :    PTrResourceList->List[0].PartialResourceList.PartialDescriptors[0].Flags
; 134  :       = (USHORT)outAddrSpace;

  0007c	8b 75 10	 mov	 esi, DWORD PTR _PTrResourceList$[ebp]
  0007f	66 8b 45 14	 mov	 ax, WORD PTR _outAddrSpace$[ebp]

; 135  :    PTrResourceList->List[0].PartialResourceList.PartialDescriptors[0]
; 136  :       .u.Port.Start = outPhysAddr;
; 137  : 
; 138  :    if ((PTrResourceList->List[0].PartialResourceList
; 139  :         .PartialDescriptors[1].u.Interrupt.Vector
; 140  :         = HalGetInterruptVector(PUserData->UserInterfaceType,
; 141  :                                 PUserData->UserBusNumber, PUserData->UserLevel
; 142  :                                 ? PUserData->UserLevel
; 143  :                                 : PUserData->UserVector,
; 144  :                                 PUserData->UserVector, &outIrql,
; 145  :                                 &outAffinity)) == 0) {

  00083	33 ff		 xor	 edi, edi
  00085	66 89 46 16	 mov	 WORD PTR [esi+22], ax
  00089	8b 45 f0	 mov	 eax, DWORD PTR _outPhysAddr$[ebp]
  0008c	89 46 18	 mov	 DWORD PTR [esi+24], eax
  0008f	8b 45 f4	 mov	 eax, DWORD PTR _outPhysAddr$[ebp+4]
  00092	89 46 1c	 mov	 DWORD PTR [esi+28], eax
  00095	8b 43 38	 mov	 eax, DWORD PTR [ebx+56]
  00098	3b c7		 cmp	 eax, edi
  0009a	75 03		 jne	 SHORT $L15541
  0009c	8b 43 10	 mov	 eax, DWORD PTR [ebx+16]
$L15541:
  0009f	8d 4d f8	 lea	 ecx, DWORD PTR _outAffinity$[ebp]
  000a2	51		 push	 ecx
  000a3	8d 4d 1f	 lea	 ecx, DWORD PTR _outIrql$[ebp]
  000a6	51		 push	 ecx
  000a7	ff 73 10	 push	 DWORD PTR [ebx+16]
  000aa	50		 push	 eax
  000ab	ff 73 20	 push	 DWORD PTR [ebx+32]
  000ae	ff 73 24	 push	 DWORD PTR [ebx+36]
  000b1	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__HalGetInterruptVector@24
  000b7	3b c7		 cmp	 eax, edi
  000b9	89 46 2c	 mov	 DWORD PTR [esi+44], eax
  000bc	75 2e		 jne	 SHORT $L14804

; 146  : 
; 147  :       SerialLogError(DriverObject, NULL, PUserData->UserPort,
; 148  :                      SerialPhysicalZero, 0, 0, 0, 61, STATUS_SUCCESS,
; 149  :                      SERIAL_NO_GET_INTERRUPT, UserSubKey->NameLength
; 150  :                      + sizeof(WCHAR), &UserSubKey->Name[0], 0, NULL);

  000be	8b 45 0c	 mov	 eax, DWORD PTR _UserSubKey$[ebp]
  000c1	57		 push	 edi
  000c2	57		 push	 edi
  000c3	8d 48 10	 lea	 ecx, DWORD PTR [eax+16]
  000c6	8b 40 0c	 mov	 eax, DWORD PTR [eax+12]
  000c9	40		 inc	 eax
  000ca	51		 push	 ecx
  000cb	40		 inc	 eax
  000cc	50		 push	 eax
  000cd	68 26 00 06 c0	 push	 -1073348570		; c0060026H
  000d2	57		 push	 edi
  000d3	6a 3d		 push	 61			; 0000003dH
  000d5	57		 push	 edi
  000d6	57		 push	 edi
  000d7	57		 push	 edi
  000d8	ff 35 04 00 00
	00		 push	 DWORD PTR _SerialPhysicalZero+4
  000de	ff 35 00 00 00
	00		 push	 DWORD PTR _SerialPhysicalZero
  000e4	ff 73 04	 push	 DWORD PTR [ebx+4]
  000e7	ff 33		 push	 DWORD PTR [ebx]
  000e9	57		 push	 edi

; 151  : 
; 152  :       status = STATUS_NONE_MAPPED;
; 153  :       goto SerialTranslateError;

  000ea	eb 72		 jmp	 SHORT $L15551
$L14804:

; 154  :    }
; 155  : 
; 156  :    PTrResourceList->List[0].PartialResourceList
; 157  :       .PartialDescriptors[1].u.Interrupt.Level = outIrql;

  000ec	0f b6 45 1f	 movzx	 eax, BYTE PTR _outIrql$[ebp]
  000f0	89 46 28	 mov	 DWORD PTR [esi+40], eax

; 158  : 
; 159  :    PTrResourceList->List[0].PartialResourceList
; 160  :       .PartialDescriptors[1].u.Interrupt.Affinity = outAffinity;

  000f3	8b 45 f8	 mov	 eax, DWORD PTR _outAffinity$[ebp]
  000f6	89 46 30	 mov	 DWORD PTR [esi+48], eax

; 161  : 
; 162  :    outAddrSpace = PTrResourceList->List[0].PartialResourceList
; 163  :                   .PartialDescriptors[2].Flags;
; 164  :    outPhysAddr = PTrResourceList->List[0].PartialResourceList
; 165  :                  .PartialDescriptors[2].u.Port.Start;
; 166  : 
; 167  : 
; 168  :    if (PartialCount == 3) {

  000f9	83 7d 18 03	 cmp	 DWORD PTR _PartialCount$[ebp], 3
  000fd	0f b7 46 36	 movzx	 eax, WORD PTR [esi+54]
  00101	89 45 14	 mov	 DWORD PTR _outAddrSpace$[ebp], eax
  00104	8b 46 38	 mov	 eax, DWORD PTR [esi+56]
  00107	89 45 f0	 mov	 DWORD PTR _outPhysAddr$[ebp], eax
  0010a	8b 46 3c	 mov	 eax, DWORD PTR [esi+60]
  0010d	89 45 f4	 mov	 DWORD PTR _outPhysAddr$[ebp+4], eax
  00110	75 71		 jne	 SHORT $SerialTranslateError$14802

; 169  :       if (HalTranslateBusAddress(PUserData->UserInterfaceType,
; 170  :                                  PUserData->UserBusNumber,
; 171  :                                  PUserData->UserInterruptStatus,
; 172  :                                  &outAddrSpace, &outPhysAddr) == 0) {

  00112	8d 45 f0	 lea	 eax, DWORD PTR _outPhysAddr$[ebp]
  00115	50		 push	 eax
  00116	8d 45 14	 lea	 eax, DWORD PTR _outAddrSpace$[ebp]
  00119	50		 push	 eax
  0011a	ff 73 0c	 push	 DWORD PTR [ebx+12]
  0011d	ff 73 08	 push	 DWORD PTR [ebx+8]
  00120	ff 73 20	 push	 DWORD PTR [ebx+32]
  00123	ff 73 24	 push	 DWORD PTR [ebx+36]
  00126	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__HalTranslateBusAddress@24
  0012c	84 c0		 test	 al, al
  0012e	75 3f		 jne	 SHORT $L14822

; 173  : 
; 174  :          SerialLogError(DriverObject, NULL, PUserData->UserPort,
; 175  :                         SerialPhysicalZero, 0, 0, 0, 62, STATUS_SUCCESS,
; 176  :                         SERIAL_NO_TRANSLATE_ISR, UserSubKey->NameLength
; 177  :                         + sizeof(WCHAR), &UserSubKey->Name[0], 0, NULL);

  00130	8b 4d 0c	 mov	 ecx, DWORD PTR _UserSubKey$[ebp]
  00133	33 c0		 xor	 eax, eax
  00135	50		 push	 eax
  00136	50		 push	 eax
  00137	8d 51 10	 lea	 edx, DWORD PTR [ecx+16]
  0013a	8b 49 0c	 mov	 ecx, DWORD PTR [ecx+12]
  0013d	41		 inc	 ecx
  0013e	52		 push	 edx
  0013f	41		 inc	 ecx
  00140	51		 push	 ecx
  00141	68 27 00 06 c0	 push	 -1073348569		; c0060027H
  00146	50		 push	 eax
  00147	6a 3e		 push	 62			; 0000003eH
$L15552:
  00149	50		 push	 eax
  0014a	50		 push	 eax
  0014b	50		 push	 eax
  0014c	ff 35 04 00 00
	00		 push	 DWORD PTR _SerialPhysicalZero+4
  00152	ff 35 00 00 00
	00		 push	 DWORD PTR _SerialPhysicalZero
  00158	ff 73 04	 push	 DWORD PTR [ebx+4]
  0015b	ff 33		 push	 DWORD PTR [ebx]
  0015d	50		 push	 eax
$L15551:
  0015e	ff 75 08	 push	 DWORD PTR _DriverObject$[ebp]
  00161	e8 00 00 00 00	 call	 _SerialLogError@64

; 178  : 
; 179  : 
; 180  :          SerialDump(SERERRORS, ("SERIAL: ISR map failed attempt was \n"
; 181  :                                 "------- Interface:  %x\n"
; 182  :                                 "------- Bus Number: %x\n"
; 183  :                                 "------- IntStatus:  %x\n"
; 184  :                                 "------- AddrSpace:  %x\n"
; 185  :                                 "------- PhysAddr:   %x\n",
; 186  :                                 PUserData->UserInterfaceType,
; 187  :                                 PUserData->UserBusNumber,
; 188  :                                 PUserData->UserInterruptStatus,
; 189  :                                 PTrResourceList->List[0].
; 190  :                                 PartialResourceList.PartialDescriptors[2]
; 191  :                                 .Flags,
; 192  :                                 PTrResourceList->List[0].
; 193  :                                 PartialResourceList.PartialDescriptors[2]
; 194  :                                 .u.Port.Start.QuadPart));
; 195  : 
; 196  :         status = STATUS_NONE_MAPPED;

  00166	c7 45 fc 73 00
	00 c0		 mov	 DWORD PTR _status$[ebp], -1073741709 ; c0000073H

; 197  :         goto SerialTranslateError;

  0016d	eb 14		 jmp	 SHORT $SerialTranslateError$14802
$L14822:

; 198  :       }

⌨️ 快捷键说明

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