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

📄 protocol.cod

📁 James Antognini和Tom Divine提供的PASSTHRU的编成实例。
💻 COD
📖 第 1 页 / 共 5 页
字号:
; 116  : 
; 117  :         if (*Status != NDIS_STATUS_SUCCESS)

  002b9	8b 4d 08	 mov	 ecx, DWORD PTR _Status$[ebp]
  002bc	83 39 00	 cmp	 DWORD PTR [ecx], 0
  002bf	74 05		 je	 SHORT $L16047

; 118  :         {
; 119  :             break;

  002c1	e9 21 02 00 00	 jmp	 $L16044
$L16047:

; 120  :         }
; 121  : 
; 122  :         //
; 123  :         // Read the "UpperBindings" reserved key that contains a list
; 124  :         // of device names representing our miniport instances corresponding
; 125  :         // to this lower binding. Since this is a 1:1 IM driver, this key
; 126  :         // contains exactly one name.
; 127  :         //
; 128  :         // If we want to implement a N:1 mux driver (N adapter instances
; 129  :         // over a single lower binding), then UpperBindings will be a
; 130  :         // MULTI_SZ containing a list of device names - we would loop through
; 131  :         // this list, calling NdisIMInitializeDeviceInstanceEx once for
; 132  :         // each name in it.
; 133  :         //
; 134  :         NdisReadConfiguration(Status,
; 135  :                               &Param,
; 136  :                               ConfigHandle,
; 137  :                               &DeviceStr,
; 138  :                               NdisParameterString);

  002c6	6a 02		 push	 2
  002c8	8d 55 d8	 lea	 edx, DWORD PTR _DeviceStr$[ebp]
  002cb	52		 push	 edx
  002cc	8b 45 d4	 mov	 eax, DWORD PTR _ConfigHandle$[ebp]
  002cf	50		 push	 eax
  002d0	8d 4d e4	 lea	 ecx, DWORD PTR _Param$[ebp]
  002d3	51		 push	 ecx
  002d4	8b 55 08	 mov	 edx, DWORD PTR _Status$[ebp]
  002d7	52		 push	 edx
  002d8	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisReadConfiguration@20

; 139  :         if (*Status != NDIS_STATUS_SUCCESS)

  002de	8b 45 08	 mov	 eax, DWORD PTR _Status$[ebp]
  002e1	83 38 00	 cmp	 DWORD PTR [eax], 0
  002e4	74 05		 je	 SHORT $L16050

; 140  :         {
; 141  :             break;

  002e6	e9 fc 01 00 00	 jmp	 $L16044
$L16050:

; 142  :         }
; 143  : 
; 144  :         //
; 145  :         // Allocate memory for the Adapter structure. This represents both the
; 146  :         // protocol context as well as the adapter structure when the miniport
; 147  :         // is initialized.
; 148  :         //
; 149  :         // In addition to the base structure, allocate space for the device
; 150  :         // instance string.
; 151  :         //
; 152  :         TotalSize = sizeof(ADAPT) + Param->ParameterData.StringData.MaximumLength;

  002eb	8b 4d e4	 mov	 ecx, DWORD PTR _Param$[ebp]
  002ee	0f b7 51 06	 movzx	 edx, WORD PTR [ecx+6]
  002f2	81 c2 fc 02 00
	00		 add	 edx, 764		; 000002fcH
  002f8	89 55 e0	 mov	 DWORD PTR _TotalSize$[ebp], edx

; 153  :         NdisAllocateMemoryWithTag(&pAdapt, TotalSize, TAG);

  002fb	68 61 50 6d 49	 push	 1231900769		; 496d5061H
  00300	8b 45 e0	 mov	 eax, DWORD PTR _TotalSize$[ebp]
  00303	50		 push	 eax
  00304	8d 4d f0	 lea	 ecx, DWORD PTR _pAdapt$[ebp]
  00307	51		 push	 ecx
  00308	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisAllocateMemoryWithTag@12

; 154  : 
; 155  :         if (pAdapt == NULL)

  0030e	83 7d f0 00	 cmp	 DWORD PTR _pAdapt$[ebp], 0
  00312	75 0e		 jne	 SHORT $L16053

; 156  :         {
; 157  :             *Status = NDIS_STATUS_RESOURCES;

  00314	8b 55 08	 mov	 edx, DWORD PTR _Status$[ebp]
  00317	c7 02 9a 00 00
	c0		 mov	 DWORD PTR [edx], -1073741670 ; c000009aH

; 158  :             break;

  0031d	e9 c5 01 00 00	 jmp	 $L16044
$L16053:

; 159  :         }
; 160  : 
; 161  :         //
; 162  :         // Initialize the adapter structure. We copy in the IM device
; 163  :         // name as well, because we may need to use it in a call to
; 164  :         // NdisIMCancelInitializeDeviceInstance. The string returned
; 165  :         // by NdisReadConfiguration is active (i.e. available) only
; 166  :         // for the duration of this call to our BindAdapter handler.
; 167  :         //
; 168  :         NdisZeroMemory(pAdapt, TotalSize);

  00322	8b 4d e0	 mov	 ecx, DWORD PTR _TotalSize$[ebp]
  00325	33 c0		 xor	 eax, eax
  00327	8b 7d f0	 mov	 edi, DWORD PTR _pAdapt$[ebp]
  0032a	8b d1		 mov	 edx, ecx
  0032c	c1 e9 02	 shr	 ecx, 2
  0032f	f3 ab		 rep stosd
  00331	8b ca		 mov	 ecx, edx
  00333	83 e1 03	 and	 ecx, 3
  00336	f3 aa		 rep stosb

; 169  :         pAdapt->DeviceName.MaximumLength = Param->ParameterData.StringData.MaximumLength;

  00338	8b 45 f0	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  0033b	8b 4d e4	 mov	 ecx, DWORD PTR _Param$[ebp]
  0033e	66 8b 51 06	 mov	 dx, WORD PTR [ecx+6]
  00342	66 89 90 aa 00
	00 00		 mov	 WORD PTR [eax+170], dx

; 170  :         pAdapt->DeviceName.Length = Param->ParameterData.StringData.Length;

  00349	8b 45 f0	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  0034c	8b 4d e4	 mov	 ecx, DWORD PTR _Param$[ebp]
  0034f	66 8b 51 04	 mov	 dx, WORD PTR [ecx+4]
  00353	66 89 90 a8 00
	00 00		 mov	 WORD PTR [eax+168], dx

; 171  :         pAdapt->DeviceName.Buffer = (PWCHAR)((ULONG_PTR)pAdapt + sizeof(ADAPT));

  0035a	8b 45 f0	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  0035d	05 fc 02 00 00	 add	 eax, 764		; 000002fcH
  00362	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00365	89 81 ac 00 00
	00		 mov	 DWORD PTR [ecx+172], eax

; 172  :         NdisMoveMemory(pAdapt->DeviceName.Buffer,
; 173  :                        Param->ParameterData.StringData.Buffer,
; 174  :                        Param->ParameterData.StringData.MaximumLength);

  0036b	8b 55 e4	 mov	 edx, DWORD PTR _Param$[ebp]
  0036e	0f b7 4a 06	 movzx	 ecx, WORD PTR [edx+6]
  00372	8b 45 e4	 mov	 eax, DWORD PTR _Param$[ebp]
  00375	8b 70 08	 mov	 esi, DWORD PTR [eax+8]
  00378	8b 55 f0	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  0037b	8b ba ac 00 00
	00		 mov	 edi, DWORD PTR [edx+172]
  00381	8b c1		 mov	 eax, ecx
  00383	c1 e9 02	 shr	 ecx, 2
  00386	f3 a5		 rep movsd
  00388	8b c8		 mov	 ecx, eax
  0038a	83 e1 03	 and	 ecx, 3
  0038d	f3 a4		 rep movsb

; 175  : 
; 176  :         NdisInitializeEvent(&pAdapt->Event);

  0038f	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00392	83 c1 18	 add	 ecx, 24			; 00000018H
  00395	51		 push	 ecx
  00396	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisInitializeEvent@4

; 177  :         NdisAllocateSpinLock(&pAdapt->Lock);

  0039c	8b 55 f0	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  0039f	81 c2 98 00 00
	00		 add	 edx, 152		; 00000098H
  003a5	52		 push	 edx
  003a6	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisAllocateSpinLock@4

; 178  : 
; 179  :         //
; 180  :         // Allocate a packet pool for sends. We need this to pass sends down.
; 181  :         // We cannot use the same packet descriptor that came down to our send
; 182  :         // handler (see also NDIS 5.1 packet stacking).
; 183  :         //
; 184  :         NdisAllocatePacketPoolEx(Status,
; 185  :                                    &pAdapt->SendPacketPoolHandle,
; 186  :                                    MIN_PACKET_POOL_SIZE,
; 187  :                                    MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
; 188  :                                    sizeof(SEND_RSVD));

  003ac	6a 04		 push	 4
  003ae	68 00 ff 00 00	 push	 65280			; 0000ff00H
  003b3	68 ff 00 00 00	 push	 255			; 000000ffH
  003b8	8b 45 f0	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  003bb	83 c0 0c	 add	 eax, 12			; 0000000cH
  003be	50		 push	 eax
  003bf	8b 4d 08	 mov	 ecx, DWORD PTR _Status$[ebp]
  003c2	51		 push	 ecx
  003c3	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisAllocatePacketPoolEx@20

; 189  : 
; 190  :         if (*Status != NDIS_STATUS_SUCCESS)

  003c9	8b 55 08	 mov	 edx, DWORD PTR _Status$[ebp]
  003cc	83 3a 00	 cmp	 DWORD PTR [edx], 0
  003cf	74 05		 je	 SHORT $L16062

; 191  :         {
; 192  :             break;

  003d1	e9 11 01 00 00	 jmp	 $L16044
$L16062:

; 193  :         }
; 194  : 
; 195  :         //
; 196  :         // Allocate a packet pool for receives. We need this to indicate receives.
; 197  :         // Same consideration as sends (see also NDIS 5.1 packet stacking).
; 198  :         //
; 199  :         NdisAllocatePacketPoolEx(Status,
; 200  :                                    &pAdapt->RecvPacketPoolHandle,
; 201  :                                    MIN_PACKET_POOL_SIZE,
; 202  :                                    MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
; 203  :                                    PROTOCOL_RESERVED_SIZE_IN_PACKET);

  003d6	6a 10		 push	 16			; 00000010H
  003d8	68 00 ff 00 00	 push	 65280			; 0000ff00H
  003dd	68 ff 00 00 00	 push	 255			; 000000ffH
  003e2	8b 45 f0	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  003e5	83 c0 10	 add	 eax, 16			; 00000010H
  003e8	50		 push	 eax
  003e9	8b 4d 08	 mov	 ecx, DWORD PTR _Status$[ebp]
  003ec	51		 push	 ecx
  003ed	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisAllocatePacketPoolEx@20

; 204  : 
; 205  :         if (*Status != NDIS_STATUS_SUCCESS)

  003f3	8b 55 08	 mov	 edx, DWORD PTR _Status$[ebp]
  003f6	83 3a 00	 cmp	 DWORD PTR [edx], 0
  003f9	74 05		 je	 SHORT $L16066

; 206  :         {
; 207  :             break;

  003fb	e9 e7 00 00 00	 jmp	 $L16044
$L16066:

; 208  :         }
; 209  : 
; 210  :         //
; 211  :         // Now open the adapter below and complete the initialization
; 212  :         //
; 213  :         NdisOpenAdapter(Status,
; 214  :                           &Sts,
; 215  :                           &pAdapt->BindingHandle,
; 216  :                           &MediumIndex,
; 217  :                           MediumArray,
; 218  :                           sizeof(MediumArray)/sizeof(NDIS_MEDIUM),
; 219  :                           ProtHandle,
; 220  :                           pAdapt,
; 221  :                           DeviceName,
; 222  :                           0,
; 223  :                           NULL);

  00400	6a 00		 push	 0
  00402	6a 00		 push	 0
  00404	8b 45 10	 mov	 eax, DWORD PTR _DeviceName$[ebp]
  00407	50		 push	 eax
  00408	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  0040b	51		 push	 ecx
  0040c	8b 15 00 00 00
	00		 mov	 edx, DWORD PTR _ProtHandle
  00412	52		 push	 edx
  00413	6a 04		 push	 4
  00415	68 00 00 00 00	 push	 OFFSET FLAT:_MediumArray
  0041a	8d 45 ec	 lea	 eax, DWORD PTR _MediumIndex$[ebp]
  0041d	50		 push	 eax
  0041e	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00421	83 c1 04	 add	 ecx, 4
  00424	51		 push	 ecx
  00425	8d 55 e8	 lea	 edx, DWORD PTR _Sts$[ebp]
  00428	52		 push	 edx
  00429	8b 45 08	 mov	 eax, DWORD PTR _Status$[ebp]
  0042c	50		 push	 eax
  0042d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisOpenAdapter@44

; 224  : 
; 225  :         if (*Status == NDIS_STATUS_PENDING)

  00433	8b 4d 08	 mov	 ecx, DWORD PTR _Status$[ebp]
  00436	81 39 03 01 00
	00		 cmp	 DWORD PTR [ecx], 259	; 00000103H
  0043c	75 1a		 jne	 SHORT $L16071

; 226  :         {
; 227  :             NdisWaitEvent(&pAdapt->Event, 0);

  0043e	6a 00		 push	 0
  00440	8b 55 f0	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  00443	83 c2 18	 add	 edx, 24			; 00000018H
  00446	52		 push	 edx
  00447	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisWaitEvent@8

; 228  :             *Status = pAdapt->Status;

  0044d	8b 45 08	 mov	 eax, DWORD PTR _Status$[ebp]
  00450	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00453	8b 51 14	 mov	 edx, DWORD PTR [ecx+20]
  00456	89 10		 mov	 DWORD PTR [eax], edx
$L16071:

; 229  :         }
; 230  : 
; 231  :         if (*Status != NDIS_STATUS_SUCCESS)

  00458	8b 45 08	 mov	 eax, DWORD PTR _Status$[ebp]
  0045b	83 38 00	 cmp	 DWORD PTR [eax], 0
  0045e	74 05		 je	 SHORT $L16074

; 232  :         {
; 233  :             break;

  00460	e9 82 00 00 00	 jmp	 $L16044
$L16074:

; 234  :         }
; 235  : 
; 236  :         pAdapt->Medium = MediumArray[MediumIndex];

  00465	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00468	8b 55 ec	 mov	 edx, DWORD PTR _MediumIndex$[ebp]
  0046b	8b 04 95 00 00
	00 00		 mov	 eax, DWORD PTR _MediumArray[edx*4]
  00472	89 41 28	 mov	 DWORD PTR [ecx+40], eax

; 237  : 
; 238  :         //
; 239  :         // Now ask NDIS to initialize our miniport (upper) edge.
; 240  :         // Set the flag below to synchronize with a possible call
; 241  :         // to our protocol Unbind handler that may come in before
; 242  :         // our miniport initialization happens.
; 243  :         //
; 244  :         pAdapt->MiniportInitPending = TRUE;

  00475	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00478	c6 81 c0 00 00
	00 01		 mov	 BYTE PTR [ecx+192], 1

; 245  :         NdisInitializeEvent(&pAdapt->MiniportInitEvent);

  0047f	8b 55 f0	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  00482	81 c2 b0 00 00
	00		 add	 edx, 176		; 000000b0H
  00488	52		 push	 edx
  00489	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisInitializeEvent@4

; 246  : 
; 247  :         *Status = NdisIMInitializeDeviceInstanceEx(DriverHandle,
; 248  :                                            &pAdapt->DeviceName,
; 249  :                                            pAdapt);

  0048f	8b 45 f0	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  00492	50		 push	 eax
  00493	8b 4d f0	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00496	81 c1 a8 00 00
	00		 add	 ecx, 168		; 000000a8H
  0049c	51		 push	 ecx
  0049d	8b 15 00 00 00
	00		 mov	 edx, DWORD PTR _DriverHandle
  004a3	52		 push	 edx
  004a4	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisIMInitializeDeviceInstanceEx@12
  004aa	8b 4d 08	 mov	 ecx, DWORD PTR _Status$[ebp]
  004ad	89 01		 mov	 DWORD PTR [ecx], eax

; 250  : 
; 251  :         if (*Status != NDIS_STATUS_SUCCESS)

  004af	8b 55 08	 mov	 edx, DWORD PTR _Status$[ebp]
  004b2	83 3a 00	 cmp	 DWORD PTR [edx], 0
  004b5	74 26		 je	 SHORT $L16043

; 252  :         {
; 253  :             DBGPRINT(("BindAdapter: Adapt %p, IMInitializeDeviceInstance error %x\n",
; 254  :                 pAdapt, *Status));

  004b7	68 00 00 00 00	 push	 OFFSET FLAT:$SG16078
  004bc	e8 00 00 00 00	 call	 _DbgPrint
  004c1	83 c4 04	 add	 esp, 4
  004c4	8b 45 08	 mov	 eax, DWORD PTR _Status$[ebp]
  004c7	8b 08		 mov	 ecx, DWORD PTR [eax]
  004c9	51		 push	 ecx
  004ca	8b 55 f0	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  004cd	52		 push	 edx
  004ce	68 00 00 00 00	 push	 OFFSET FLAT:$SG16079
  004d3	e8 00 00 00 00	 call	 _DbgPrint

⌨️ 快捷键说明

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