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

📄 registry.cod

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

	TITLE	F:\W2DDK\src\kernel\serial\registry.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
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _RtlConvertLongToLargeInteger@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _SerialGetConfigDefaults@8
INIT	SEGMENT PARA USE32 PUBLIC ''
INIT	ENDS
;	COMDAT _SerialGetRegistryKeyValue@20
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
;	COMDAT _SerialPutRegistryKeyValue@24
PAGESRP0	SEGMENT PARA USE32 PUBLIC ''
PAGESRP0	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif

INCLUDELIB LIBC
INCLUDELIB OLDNAMES

PUBLIC	_SerialGetConfigDefaults@8
EXTRN	__imp__memmove:NEAR
EXTRN	__imp__RtlQueryRegistryValues@20:NEAR
EXTRN	__imp__RtlWriteRegistryValue@24:NEAR
EXTRN	__imp__ExAllocatePoolWithTag@12:NEAR
EXTRN	__imp__ExFreePool@4:NEAR
;	COMDAT _SerialGetConfigDefaults@8
; File f:\w2ddk\src\kernel\serial\registry.c
INIT	SEGMENT
$SG14783 DB	'B', 00H, 'r', 00H, 'e', 00H, 'a', 00H, 'k', 00H, 'O', 00H
	DB	'n', 00H, 'E', 00H, 'n', 00H, 't', 00H, 'r', 00H, 'y', 00H, 00H
	DB	00H
	ORG $+2
$SG14785 DB	'D', 00H, 'e', 00H, 'b', 00H, 'u', 00H, 'g', 00H, 'L', 00H
	DB	'e', 00H, 'v', 00H, 'e', 00H, 'l', 00H, 00H, 00H
	ORG $+2
$SG14787 DB	'F', 00H, 'o', 00H, 'r', 00H, 'c', 00H, 'e', 00H, 'F', 00H
	DB	'i', 00H, 'f', 00H, 'o', 00H, 'E', 00H, 'n', 00H, 'a', 00H, 'b'
	DB	00H, 'l', 00H, 'e', 00H, 00H, 00H
$SG14789 DB	'R', 00H, 'x', 00H, 'F', 00H, 'I', 00H, 'F', 00H, 'O', 00H
	DB	00H, 00H
	ORG $+2
$SG14791 DB	'T', 00H, 'x', 00H, 'F', 00H, 'I', 00H, 'F', 00H, 'O', 00H
	DB	00H, 00H
	ORG $+2
$SG14793 DB	'P', 00H, 'e', 00H, 'r', 00H, 'm', 00H, 'i', 00H, 't', 00H
	DB	'S', 00H, 'h', 00H, 'a', 00H, 'r', 00H, 'e', 00H, 00H, 00H
$SG14795 DB	'L', 00H, 'o', 00H, 'g', 00H, 'F', 00H, 'i', 00H, 'f', 00H
	DB	'o', 00H, 00H, 00H
$SG14803 DB	'F', 00H, 'o', 00H, 'r', 00H, 'c', 00H, 'e', 00H, 'F', 00H
	DB	'i', 00H, 'f', 00H, 'o', 00H, 'E', 00H, 'n', 00H, 'a', 00H, 'b'
	DB	00H, 'l', 00H, 'e', 00H, 00H, 00H
$SG14806 DB	'R', 00H, 'x', 00H, 'F', 00H, 'I', 00H, 'F', 00H, 'O', 00H
	DB	00H, 00H
	ORG $+2
$SG14809 DB	'T', 00H, 'x', 00H, 'F', 00H, 'I', 00H, 'F', 00H, 'O', 00H
	DB	00H, 00H
	ORG $+2
$SG14812 DB	'P', 00H, 'e', 00H, 'r', 00H, 'm', 00H, 'i', 00H, 't', 00H
	DB	'S', 00H, 'h', 00H, 'a', 00H, 'r', 00H, 'e', 00H, 00H, 00H
$SG14815 DB	'L', 00H, 'o', 00H, 'g', 00H, 'F', 00H, 'i', 00H, 'f', 00H
	DB	'o', 00H, 00H, 00H
; Function compile flags: /Ogsy
_DriverDefaultsPtr$ = 8
_RegistryPath$ = 12
_Status$ = 8
_paramTable$ = -236
_path$ = 12
_zero$ = -8
_DbgDefault$ = -12
_notThereDefault$ = -4
_SerialGetConfigDefaults@8 PROC NEAR			; COMDAT

; 67   : {

  00104	55		 push	 ebp
  00105	8b ec		 mov	 ebp, esp
  00107	81 ec ec 00 00
	00		 sub	 esp, 236		; 000000ecH

; 68   : 
; 69   :     NTSTATUS Status = STATUS_SUCCESS;    // return value
; 70   : 
; 71   :     //
; 72   :     // We use this to query into the registry for defaults
; 73   :     //
; 74   : 
; 75   :     RTL_QUERY_REGISTRY_TABLE paramTable[8];
; 76   :     
; 77   :     PWCHAR  path;
; 78   :     ULONG   zero            = 0;

  0010d	83 65 f8 00	 and	 DWORD PTR _zero$[ebp], 0

; 79   :     ULONG   DbgDefault      = 0;//SER_DBG_DEFAULT;

  00111	83 65 f4 00	 and	 DWORD PTR _DbgDefault$[ebp], 0
  00115	56		 push	 esi

; 80   :     ULONG   notThereDefault = SERIAL_UNINITIALIZED_DEFAULT;
; 81   : 
; 82   :     PAGED_CODE();
; 83   : 
; 84   :     //
; 85   :     // Since the registry path parameter is a "counted" UNICODE string, it
; 86   :     // might not be zero terminated.  For a very short time allocate memory
; 87   :     // to hold the registry path zero terminated so that we can use it to
; 88   :     // delve into the registry.
; 89   :     //
; 90   :     // NOTE NOTE!!!! This is not an architected way of breaking into
; 91   :     // a driver.  It happens to work for this driver because the author
; 92   :     // likes to do things this way.
; 93   :     //
; 94   : 
; 95   :     path = ExAllocatePool (PagedPool, RegistryPath->Length+sizeof(WCHAR));

  00116	8b 75 0c	 mov	 esi, DWORD PTR _RegistryPath$[ebp]
  00119	68 43 4f 4d 58	 push	 1481461571		; 584d4f43H
  0011e	c7 45 fc 87 d6
	12 00		 mov	 DWORD PTR _notThereDefault$[ebp], 1234567 ; 0012d687H
  00125	0f b7 06	 movzx	 eax, WORD PTR [esi]
  00128	40		 inc	 eax
  00129	40		 inc	 eax
  0012a	50		 push	 eax
  0012b	6a 01		 push	 1
  0012d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12

; 96   :     
; 97   :     if (!path) {

  00133	85 c0		 test	 eax, eax
  00135	89 45 0c	 mov	 DWORD PTR _path$[ebp], eax
  00138	75 0a		 jne	 SHORT $L14779

; 98   :         Status = STATUS_INSUFFICIENT_RESOURCES;
; 99   :         return (Status);

  0013a	b8 9a 00 00 c0	 mov	 eax, -1073741670	; c000009aH
  0013f	e9 31 02 00 00	 jmp	 $L14770
$L14779:
  00144	53		 push	 ebx

; 100  :     }
; 101  :     
; 102  :     RtlZeroMemory (DriverDefaultsPtr, sizeof(SERIAL_FIRMWARE_DATA));

  00145	8b 5d 08	 mov	 ebx, DWORD PTR _DriverDefaultsPtr$[ebp]
  00148	57		 push	 edi
  00149	6a 13		 push	 19			; 00000013H
  0014b	59		 pop	 ecx
  0014c	33 c0		 xor	 eax, eax
  0014e	8b fb		 mov	 edi, ebx

; 103  :     RtlZeroMemory (&paramTable[0], sizeof(paramTable));

  00150	6a 38		 push	 56			; 00000038H
  00152	f3 ab		 rep stosd
  00154	59		 pop	 ecx
  00155	8d bd 14 ff ff
	ff		 lea	 edi, DWORD PTR _paramTable$[ebp]
  0015b	f3 ab		 rep stosd

; 104  :     RtlZeroMemory (path, RegistryPath->Length+sizeof(WCHAR));

  0015d	0f b7 0e	 movzx	 ecx, WORD PTR [esi]
  00160	8b 7d 0c	 mov	 edi, DWORD PTR _path$[ebp]
  00163	41		 inc	 ecx
  00164	41		 inc	 ecx
  00165	8b d1		 mov	 edx, ecx
  00167	c1 e9 02	 shr	 ecx, 2
  0016a	f3 ab		 rep stosd
  0016c	8b ca		 mov	 ecx, edx
  0016e	83 e1 03	 and	 ecx, 3
  00171	f3 aa		 rep stosb

; 105  :     RtlMoveMemory (path, RegistryPath->Buffer, RegistryPath->Length);

  00173	0f b7 06	 movzx	 eax, WORD PTR [esi]
  00176	50		 push	 eax
  00177	ff 76 04	 push	 DWORD PTR [esi+4]
  0017a	ff 75 0c	 push	 DWORD PTR _path$[ebp]
  0017d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__memmove

; 106  : 
; 107  :     paramTable[0].Flags         = RTL_QUERY_REGISTRY_DIRECT;
; 108  :     paramTable[0].Name          = L"BreakOnEntry";
; 109  :     paramTable[0].EntryContext  = &DriverDefaultsPtr->ShouldBreakOnEntry;

  00183	8d 4b 10	 lea	 ecx, DWORD PTR [ebx+16]
  00186	83 c4 0c	 add	 esp, 12			; 0000000cH
  00189	89 8d 20 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+12], ecx

; 110  :     paramTable[0].DefaultType   = REG_DWORD;
; 111  :     paramTable[0].DefaultData   = &zero;

  0018f	8d 4d f8	 lea	 ecx, DWORD PTR _zero$[ebp]
  00192	89 8d 28 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+20], ecx

; 112  :     paramTable[0].DefaultLength = sizeof(ULONG);
; 113  :     
; 114  :     paramTable[1].Flags         = RTL_QUERY_REGISTRY_DIRECT;
; 115  :     paramTable[1].Name          = L"DebugLevel";
; 116  :     paramTable[1].EntryContext  = &DriverDefaultsPtr->DebugLevel;

  00198	8d 4b 0c	 lea	 ecx, DWORD PTR [ebx+12]
  0019b	89 8d 3c ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+40], ecx

; 117  :     paramTable[1].DefaultType   = REG_DWORD;
; 118  :     paramTable[1].DefaultData   = &DbgDefault;

  001a1	8d 4d f4	 lea	 ecx, DWORD PTR _DbgDefault$[ebp]
  001a4	89 8d 44 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+48], ecx

; 119  :     paramTable[1].DefaultLength = sizeof(ULONG);
; 120  :     
; 121  :     paramTable[2].Flags         = RTL_QUERY_REGISTRY_DIRECT;
; 122  :     paramTable[2].Name          = L"ForceFifoEnable";
; 123  :     paramTable[2].EntryContext  = &DriverDefaultsPtr->ForceFifoEnableDefault;
; 124  :     paramTable[2].DefaultType   = REG_DWORD;
; 125  :     paramTable[2].DefaultData   = &notThereDefault;

  001aa	8d 4d fc	 lea	 ecx, DWORD PTR _notThereDefault$[ebp]
  001ad	89 8d 60 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+76], ecx

; 126  :     paramTable[2].DefaultLength = sizeof(ULONG);
; 127  :     
; 128  :     paramTable[3].Flags         = RTL_QUERY_REGISTRY_DIRECT;
; 129  :     paramTable[3].Name          = L"RxFIFO";
; 130  :     paramTable[3].EntryContext  = &DriverDefaultsPtr->RxFIFODefault;

  001b3	8d 4b 14	 lea	 ecx, DWORD PTR [ebx+20]
  001b6	89 8d 74 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+96], ecx

; 131  :     paramTable[3].DefaultType   = REG_DWORD;
; 132  :     paramTable[3].DefaultData   = &notThereDefault;

  001bc	8d 4d fc	 lea	 ecx, DWORD PTR _notThereDefault$[ebp]
  001bf	89 8d 7c ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+104], ecx

; 133  :     paramTable[3].DefaultLength = sizeof(ULONG);
; 134  :     
; 135  :     paramTable[4].Flags         = RTL_QUERY_REGISTRY_DIRECT;
; 136  :     paramTable[4].Name          = L"TxFIFO";
; 137  :     paramTable[4].EntryContext  = &DriverDefaultsPtr->TxFIFODefault;

  001c5	8d 4b 18	 lea	 ecx, DWORD PTR [ebx+24]
  001c8	89 4d 90	 mov	 DWORD PTR _paramTable$[ebp+124], ecx
  001cb	6a 20		 push	 32			; 00000020H

; 138  :     paramTable[4].DefaultType   = REG_DWORD;
; 139  :     paramTable[4].DefaultData   = &notThereDefault;

  001cd	8d 4d fc	 lea	 ecx, DWORD PTR _notThereDefault$[ebp]
  001d0	58		 pop	 eax
  001d1	89 4d 98	 mov	 DWORD PTR _paramTable$[ebp+132], ecx

; 140  :     paramTable[4].DefaultLength = sizeof(ULONG);
; 141  :     
; 142  :     paramTable[5].Flags         = RTL_QUERY_REGISTRY_DIRECT;
; 143  :     paramTable[5].Name          = L"PermitShare";
; 144  :     paramTable[5].EntryContext  = &DriverDefaultsPtr->PermitShareDefault;

  001d4	8d 4b 1c	 lea	 ecx, DWORD PTR [ebx+28]
  001d7	6a 04		 push	 4
  001d9	89 4d ac	 mov	 DWORD PTR _paramTable$[ebp+152], ecx
  001dc	5e		 pop	 esi
  001dd	8d 7b 08	 lea	 edi, DWORD PTR [ebx+8]

; 145  :     paramTable[5].DefaultType   = REG_DWORD;
; 146  :     paramTable[5].DefaultData   = &notThereDefault;

  001e0	8d 4d fc	 lea	 ecx, DWORD PTR _notThereDefault$[ebp]
  001e3	89 85 18 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+4], eax
  001e9	c7 85 1c ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _paramTable$[ebp+8], OFFSET FLAT:$SG14783
  001f3	89 b5 24 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+16], esi
  001f9	89 b5 2c ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+24], esi
  001ff	89 85 34 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+32], eax
  00205	c7 85 38 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _paramTable$[ebp+36], OFFSET FLAT:$SG14785
  0020f	89 b5 40 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+44], esi
  00215	89 b5 48 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+52], esi
  0021b	89 85 50 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+60], eax
  00221	c7 85 54 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _paramTable$[ebp+64], OFFSET FLAT:$SG14787
  0022b	89 bd 58 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+68], edi
  00231	89 b5 5c ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+72], esi
  00237	89 b5 64 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+80], esi
  0023d	89 85 6c ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+88], eax
  00243	c7 85 70 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _paramTable$[ebp+92], OFFSET FLAT:$SG14789
  0024d	89 b5 78 ff ff
	ff		 mov	 DWORD PTR _paramTable$[ebp+100], esi
  00253	89 75 80	 mov	 DWORD PTR _paramTable$[ebp+108], esi
  00256	89 45 88	 mov	 DWORD PTR _paramTable$[ebp+116], eax
  00259	c7 45 8c 00 00
	00 00		 mov	 DWORD PTR _paramTable$[ebp+120], OFFSET FLAT:$SG14791
  00260	89 75 94	 mov	 DWORD PTR _paramTable$[ebp+128], esi
  00263	89 75 9c	 mov	 DWORD PTR _paramTable$[ebp+136], esi
  00266	89 45 a4	 mov	 DWORD PTR _paramTable$[ebp+144], eax
  00269	c7 45 a8 00 00
	00 00		 mov	 DWORD PTR _paramTable$[ebp+148], OFFSET FLAT:$SG14793
  00270	89 75 b0	 mov	 DWORD PTR _paramTable$[ebp+156], esi
  00273	89 4d b4	 mov	 DWORD PTR _paramTable$[ebp+160], ecx

; 147  :     paramTable[5].DefaultLength = sizeof(ULONG);

  00276	89 75 b8	 mov	 DWORD PTR _paramTable$[ebp+164], esi

; 148  :     
; 149  :     paramTable[6].Flags         = RTL_QUERY_REGISTRY_DIRECT;

  00279	89 45 c0	 mov	 DWORD PTR _paramTable$[ebp+172], eax

; 150  :     paramTable[6].Name          = L"LogFifo";
; 151  :     paramTable[6].EntryContext  = &DriverDefaultsPtr->LogFifoDefault;

  0027c	8d 43 24	 lea	 eax, DWORD PTR [ebx+36]

; 152  :     paramTable[6].DefaultType   = REG_DWORD;
; 153  :     paramTable[6].DefaultData   = &notThereDefault;
; 154  :     paramTable[6].DefaultLength = sizeof(ULONG);
; 155  : 
; 156  :     Status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
; 157  :                                      path,
; 158  :                                      &paramTable[0],
; 159  :                                      NULL,
; 160  :                                      NULL);

  0027f	6a 00		 push	 0
  00281	89 45 c8	 mov	 DWORD PTR _paramTable$[ebp+180], eax
  00284	8d 45 fc	 lea	 eax, DWORD PTR _notThereDefault$[ebp]
  00287	89 45 d0	 mov	 DWORD PTR _paramTable$[ebp+188], eax
  0028a	8d 85 14 ff ff
	ff		 lea	 eax, DWORD PTR _paramTable$[ebp]
  00290	6a 00		 push	 0
  00292	50		 push	 eax
  00293	ff 75 0c	 push	 DWORD PTR _path$[ebp]
  00296	c7 45 c4 00 00
	00 00		 mov	 DWORD PTR _paramTable$[ebp+176], OFFSET FLAT:$SG14795
  0029d	89 75 cc	 mov	 DWORD PTR _paramTable$[ebp+184], esi
  002a0	89 75 d4	 mov	 DWORD PTR _paramTable$[ebp+192], esi
  002a3	68 00 00 00 80	 push	 -2147483648		; 80000000H
  002a8	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlQueryRegistryValues@20

; 161  :        
; 162  :     if (!NT_SUCCESS(Status)) {

  002ae	33 c9		 xor	 ecx, ecx
  002b0	89 45 08	 mov	 DWORD PTR _Status$[ebp], eax
  002b3	3b c1		 cmp	 eax, ecx
  002b5	7d 06		 jge	 SHORT $L14800

; 163  :             DriverDefaultsPtr->ShouldBreakOnEntry   = 0;

  002b7	89 4b 10	 mov	 DWORD PTR [ebx+16], ecx

; 164  :             DriverDefaultsPtr->DebugLevel           = 0;

  002ba	89 4b 0c	 mov	 DWORD PTR [ebx+12], ecx
$L14800:

; 165  :     }
; 166  : 
; 167  :     //
; 168  :     // Check to see if there was a forcefifo or an rxfifo size.
; 169  :     // If there isn't then write out values so that they could
; 170  :     // be adjusted later.
; 171  :     //
; 172  : 
; 173  :     if (DriverDefaultsPtr->ForceFifoEnableDefault == notThereDefault) {

  002bd	8b 07		 mov	 eax, DWORD PTR [edi]
  002bf	3b 45 fc	 cmp	 eax, DWORD PTR _notThereDefault$[ebp]
  002c2	75 1c		 jne	 SHORT $L14887

; 174  : 
; 175  :         DriverDefaultsPtr->ForceFifoEnableDefault = SERIAL_FORCE_FIFO_DEFAULT;
; 176  :         RtlWriteRegistryValue(
; 177  :             RTL_REGISTRY_ABSOLUTE,
; 178  :             path,
; 179  :             L"ForceFifoEnable",
; 180  :             REG_DWORD,
; 181  :             &DriverDefaultsPtr->ForceFifoEnableDefault,
; 182  :             sizeof(ULONG)
; 183  :             );

  002c4	56		 push	 esi
  002c5	57		 push	 edi
  002c6	56		 push	 esi
  002c7	68 00 00 00 00	 push	 OFFSET FLAT:$SG14803
  002cc	ff 75 0c	 push	 DWORD PTR _path$[ebp]
  002cf	c7 07 01 00 00
	00		 mov	 DWORD PTR [edi], 1
  002d5	8b 3d 00 00 00
	00		 mov	 edi, DWORD PTR __imp__RtlWriteRegistryValue@24
  002db	51		 push	 ecx
  002dc	ff d7		 call	 edi

⌨️ 快捷键说明

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