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

📄 miniport.cod

📁 James Antognini和Tom Divine提供的PASSTHRU的编成实例。
💻 COD
📖 第 1 页 / 共 5 页
字号:
  002db	89 45 fc	 mov	 DWORD PTR _pAdapt$[ebp], eax

; 160  :         pAdapt->MiniportHandle = MiniportAdapterHandle;

  002de	8b 55 fc	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  002e1	8b 45 18	 mov	 eax, DWORD PTR _MiniportAdapterHandle$[ebp]
  002e4	89 42 08	 mov	 DWORD PTR [edx+8], eax

; 161  : 
; 162  :         DBGPRINT(("==> Miniport Initialize:  Adapt %p\n", pAdapt));

  002e7	68 00 00 00 00	 push	 OFFSET FLAT:$SG16055
  002ec	e8 00 00 00 00	 call	 _DbgPrint
  002f1	83 c4 04	 add	 esp, 4
  002f4	8b 4d fc	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  002f7	51		 push	 ecx
  002f8	68 00 00 00 00	 push	 OFFSET FLAT:$SG16056
  002fd	e8 00 00 00 00	 call	 _DbgPrint
  00302	83 c4 08	 add	 esp, 8

; 163  : 
; 164  :         //
; 165  :         // Usually we export the medium type of the adapter below as our
; 166  :         // virtual miniport's medium type. However if the adapter below us
; 167  :         // is a WAN device, then we claim to be of medium type 802.3.
; 168  :         //
; 169  :         Medium = pAdapt->Medium;

  00305	8b 55 fc	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  00308	8b 42 28	 mov	 eax, DWORD PTR [edx+40]
  0030b	89 45 f4	 mov	 DWORD PTR _Medium$[ebp], eax

; 170  : 
; 171  :         if (Medium == NdisMediumWan)

  0030e	83 7d f4 03	 cmp	 DWORD PTR _Medium$[ebp], 3
  00312	75 07		 jne	 SHORT $L16057

; 172  :         {
; 173  :             Medium = NdisMedium802_3;

  00314	c7 45 f4 00 00
	00 00		 mov	 DWORD PTR _Medium$[ebp], 0
$L16057:

; 174  :         }
; 175  : 
; 176  :         for (i = 0; i < MediumArraySize; i++)

  0031b	c7 45 f8 00 00
	00 00		 mov	 DWORD PTR _i$[ebp], 0
  00322	eb 09		 jmp	 SHORT $L16058
$L16059:
  00324	8b 4d f8	 mov	 ecx, DWORD PTR _i$[ebp]
  00327	83 c1 01	 add	 ecx, 1
  0032a	89 4d f8	 mov	 DWORD PTR _i$[ebp], ecx
$L16058:
  0032d	8b 55 f8	 mov	 edx, DWORD PTR _i$[ebp]
  00330	3b 55 14	 cmp	 edx, DWORD PTR _MediumArraySize$[ebp]
  00333	73 1a		 jae	 SHORT $L16060

; 177  :         {
; 178  :             if (MediumArray[i] == Medium)

  00335	8b 45 f8	 mov	 eax, DWORD PTR _i$[ebp]
  00338	8b 4d 10	 mov	 ecx, DWORD PTR _MediumArray$[ebp]
  0033b	8b 14 81	 mov	 edx, DWORD PTR [ecx+eax*4]
  0033e	3b 55 f4	 cmp	 edx, DWORD PTR _Medium$[ebp]
  00341	75 0a		 jne	 SHORT $L16061

; 179  :             {
; 180  :                 *SelectedMediumIndex = i;

  00343	8b 45 0c	 mov	 eax, DWORD PTR _SelectedMediumIndex$[ebp]
  00346	8b 4d f8	 mov	 ecx, DWORD PTR _i$[ebp]
  00349	89 08		 mov	 DWORD PTR [eax], ecx

; 181  :                 break;

  0034b	eb 02		 jmp	 SHORT $L16060
$L16061:

; 182  :             }
; 183  :         }

  0034d	eb d5		 jmp	 SHORT $L16059
$L16060:

; 184  : 
; 185  :         if (i == MediumArraySize)

  0034f	8b 55 f8	 mov	 edx, DWORD PTR _i$[ebp]
  00352	3b 55 14	 cmp	 edx, DWORD PTR _MediumArraySize$[ebp]
  00355	75 0c		 jne	 SHORT $L16062

; 186  :         {
; 187  :             Status = NDIS_STATUS_UNSUPPORTED_MEDIA;

  00357	c7 45 f0 19 00
	01 c0		 mov	 DWORD PTR _Status$[ebp], -1073676263 ; c0010019H

; 188  :             break;

  0035e	e9 c5 00 00 00	 jmp	 $L16045
$L16062:

; 189  :         }
; 190  : 
; 191  : 
; 192  :         //
; 193  :         // Set the attributes now. NDIS_ATTRIBUTE_DESERIALIZE enables us
; 194  :         // to make up-calls to NDIS without having to call NdisIMSwitchToMiniport
; 195  :         // or NdisIMQueueCallBack. This also forces us to protect our data using
; 196  :         // spinlocks where appropriate. Also in this case NDIS does not queue
; 197  :         // packets on our behalf. Since this is a very simple pass-thru
; 198  :         // miniport, we do not have a need to protect anything. However in
; 199  :         // a general case there will be a need to use per-adapter spin-locks
; 200  :         // for the packet queues at the very least.
; 201  :         //
; 202  :         NdisMSetAttributesEx(MiniportAdapterHandle,
; 203  :                              pAdapt,
; 204  :                              0,                                        // CheckForHangTimeInSeconds
; 205  :                              NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT    |
; 206  :                                 NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT|
; 207  :                                 NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER |
; 208  :                                 NDIS_ATTRIBUTE_DESERIALIZE |
; 209  :                                 NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND,
; 210  :                              0);

  00363	6a 00		 push	 0
  00365	6a 73		 push	 115			; 00000073H
  00367	6a 00		 push	 0
  00369	8b 45 fc	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  0036c	50		 push	 eax
  0036d	8b 4d 18	 mov	 ecx, DWORD PTR _MiniportAdapterHandle$[ebp]
  00370	51		 push	 ecx
  00371	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisMSetAttributesEx@20

; 211  : 
; 212  :         //
; 213  :         // Initialize LastIndicatedStatus to be NDIS_STATUS_MEDIA_CONNECT
; 214  :         //
; 215  :         pAdapt->LastIndicatedStatus = NDIS_STATUS_MEDIA_CONNECT;

  00377	8b 55 fc	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  0037a	c7 82 c4 00 00
	00 0b 00 01 40	 mov	 DWORD PTR [edx+196], 1073807371 ; 4001000bH

; 216  :         
; 217  :         //
; 218  :         // Initialize the power states for both the lower binding (PTDeviceState)
; 219  :         // and our miniport edge to Powered On.
; 220  :         //
; 221  :         pAdapt->MPDeviceState = NdisDeviceStateD0;

  00384	8b 45 fc	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  00387	c7 80 a0 00 00
	00 01 00 00 00	 mov	 DWORD PTR [eax+160], 1

; 222  :         pAdapt->PTDeviceState = NdisDeviceStateD0;

  00391	8b 4d fc	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  00394	c7 81 a4 00 00
	00 01 00 00 00	 mov	 DWORD PTR [ecx+164], 1

; 223  : 
; 224  :         //
; 225  :         // Add this adapter to the global pAdapt List
; 226  :         //
; 227  :         NdisAcquireSpinLock(&GlobalLock);

  0039e	68 00 00 00 00	 push	 OFFSET FLAT:_GlobalLock
  003a3	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisAcquireSpinLock@4

; 228  : 
; 229  :         pAdapt->Next = pAdaptList;

  003a9	8b 55 fc	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  003ac	a1 00 00 00 00	 mov	 eax, DWORD PTR _pAdaptList
  003b1	89 02		 mov	 DWORD PTR [edx], eax

; 230  :         pAdaptList = pAdapt;

  003b3	8b 4d fc	 mov	 ecx, DWORD PTR _pAdapt$[ebp]
  003b6	89 0d 00 00 00
	00		 mov	 DWORD PTR _pAdaptList, ecx

; 231  : 
; 232  :         NdisReleaseSpinLock(&GlobalLock);

  003bc	68 00 00 00 00	 push	 OFFSET FLAT:_GlobalLock
  003c1	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisReleaseSpinLock@4

; 233  :         
; 234  :         //
; 235  :         // Create an ioctl interface
; 236  :         //
; 237  :         (VOID)PtRegisterDevice();

  003c7	e8 00 00 00 00	 call	 _PtRegisterDevice@0

; 238  : 
; 239  :         // Set up empty IP-address array.             // ja, 28.09.2003.
; 240  : 
; 241  :         NdisInitializeReadWriteLock(&pAdapt->IPAddrArrLock);

  003cc	8b 55 fc	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  003cf	81 c2 d0 00 00
	00		 add	 edx, 208		; 000000d0H
  003d5	52		 push	 edx
  003d6	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisInitializeReadWriteLock@4

; 242  : 
; 243  :         Status =
; 244  :           PassthruWMISetAddrArray(
; 245  :                                   pAdapt,
; 246  :                                   0,                  // No elements.
; 247  :                                   NULL                // No structure of elements.
; 248  :                                  );

  003dc	6a 00		 push	 0
  003de	6a 00		 push	 0
  003e0	8b 45 fc	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  003e3	50		 push	 eax
  003e4	e8 00 00 00 00	 call	 _PassthruWMISetAddrArray@12
  003e9	89 45 f0	 mov	 DWORD PTR _Status$[ebp], eax

; 249  : 
; 250  :         if (NDIS_STATUS_SUCCESS!=Status)

  003ec	83 7d f0 00	 cmp	 DWORD PTR _Status$[ebp], 0
  003f0	74 25		 je	 SHORT $L16069

; 251  :           {
; 252  :            DBGPRINT(("MPInitialize():  Failed inPassthruWMISetAddrArray(), status 0x%08x!\n", Status));

  003f2	68 00 00 00 00	 push	 OFFSET FLAT:$SG16070
  003f7	e8 00 00 00 00	 call	 _DbgPrint
  003fc	83 c4 04	 add	 esp, 4
  003ff	8b 4d f0	 mov	 ecx, DWORD PTR _Status$[ebp]
  00402	51		 push	 ecx
  00403	68 00 00 00 00	 push	 OFFSET FLAT:$SG16071
  00408	e8 00 00 00 00	 call	 _DbgPrint
  0040d	83 c4 08	 add	 esp, 8

; 253  :            Status = NDIS_STATUS_RESOURCES;

  00410	c7 45 f0 9a 00
	00 c0		 mov	 DWORD PTR _Status$[ebp], -1073741670 ; c000009aH
$L16069:

; 254  :           }
; 255  : 
; 256  :         Status = NDIS_STATUS_SUCCESS;

  00417	c7 45 f0 00 00
	00 00		 mov	 DWORD PTR _Status$[ebp], 0

; 257  :     }
; 258  :     while (FALSE);

  0041e	33 d2		 xor	 edx, edx
  00420	85 d2		 test	 edx, edx
  00422	0f 85 45 fd ff
	ff		 jne	 $L16043
$L16045:

; 259  : 
; 260  :     //
; 261  :     // If we had received an UnbindAdapter notification on the underlying
; 262  :     // adapter, we would have blocked that thread waiting for the IM Init
; 263  :     // process to complete. Wake up any such thread.
; 264  :     //
; 265  :     ASSERT(pAdapt->MiniportInitPending == TRUE);

  00428	8b 45 fc	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  0042b	0f b6 88 c0 00
	00 00		 movzx	 ecx, BYTE PTR [eax+192]
  00432	83 f9 01	 cmp	 ecx, 1
  00435	74 20		 je	 SHORT $L16584
  00437	6a 00		 push	 0
  00439	68 09 01 00 00	 push	 265			; 00000109H
  0043e	68 00 00 00 00	 push	 OFFSET FLAT:$SG16077
  00443	68 00 00 00 00	 push	 OFFSET FLAT:$SG16078
  00448	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
  0044e	c7 45 a4 00 00
	00 00		 mov	 DWORD PTR tv206[ebp], 0
  00455	eb 07		 jmp	 SHORT $L16585
$L16584:
  00457	c7 45 a4 01 00
	00 00		 mov	 DWORD PTR tv206[ebp], 1
$L16585:

; 266  :     pAdapt->MiniportInitPending = FALSE;

  0045e	8b 55 fc	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  00461	c6 82 c0 00 00
	00 00		 mov	 BYTE PTR [edx+192], 0

; 267  :     NdisSetEvent(&pAdapt->MiniportInitEvent);

  00468	8b 45 fc	 mov	 eax, DWORD PTR _pAdapt$[ebp]
  0046b	05 b0 00 00 00	 add	 eax, 176		; 000000b0H
  00470	50		 push	 eax
  00471	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisSetEvent@4

; 268  : 
; 269  :     DBGPRINT(("<== Miniport Initialize: Adapt %p, Status %x\n", pAdapt, Status));

  00477	68 00 00 00 00	 push	 OFFSET FLAT:$SG16079
  0047c	e8 00 00 00 00	 call	 _DbgPrint
  00481	83 c4 04	 add	 esp, 4
  00484	8b 4d f0	 mov	 ecx, DWORD PTR _Status$[ebp]
  00487	51		 push	 ecx
  00488	8b 55 fc	 mov	 edx, DWORD PTR _pAdapt$[ebp]
  0048b	52		 push	 edx
  0048c	68 00 00 00 00	 push	 OFFSET FLAT:$SG16080
  00491	e8 00 00 00 00	 call	 _DbgPrint
  00496	83 c4 0c	 add	 esp, 12			; 0000000cH

; 270  : 
; 271  :     *OpenErrorStatus = Status;

  00499	8b 45 08	 mov	 eax, DWORD PTR _OpenErrorStatus$[ebp]
  0049c	8b 4d f0	 mov	 ecx, DWORD PTR _Status$[ebp]
  0049f	89 08		 mov	 DWORD PTR [eax], ecx

; 272  :     
; 273  :     return Status;

  004a1	8b 45 f0	 mov	 eax, DWORD PTR _Status$[ebp]

; 274  : }

  004a4	5f		 pop	 edi
  004a5	5e		 pop	 esi
  004a6	8b e5		 mov	 esp, ebp
  004a8	5d		 pop	 ebp
  004a9	c2 18 00	 ret	 24			; 00000018H
_MPInitialize@24 ENDP
_TEXT	ENDS
PUBLIC	_MPSend@12
EXTRN	__imp__NdisIMCopySendPerPacketInfo@8:NEAR
EXTRN	__imp__NdisIMCopySendCompletePerPacketInfo@8:NEAR
EXTRN	_NdisSend@12:NEAR
EXTRN	__imp__NdisIMGetCurrentPacketStack@8:NEAR
EXTRN	__imp__NdisFreePacket@4:NEAR
EXTRN	__imp__NdisAllocatePacket@12:NEAR
;	COMDAT _MPSend@12
_TEXT	SEGMENT
$SG16102 DB	'g:\pcadev\ndisim\passthruex\part2\james\james\sys\minipo'
	DB	'rt.c', 00H
	ORG $+3
$SG16103 DB	'pStack', 00H
; Function compile flags: /Odt
tv76 = -36
_SendRsvd$16116 = -32
_Remaining$16099 = -25
_pStack$16098 = -24
_MediaSpecificInfo$ = -20
_MyPacket$ = -16
_Status$ = -12
_MediaSpecificInfoSize$ = -8
_pAdapt$ = -4
_MiniportAdapterContext$ = 8
_Packet$ = 12
_Flags$ = 16
_MPSend@12 PROC NEAR					; COMDAT

; 301  : {

  00047	55		 push	 ebp
  00048	8b ec		 mov	 ebp, esp
  0004a	83 ec 24	 sub	 esp, 36			; 00000024H
  0004d	56		 push	 esi
  0004e	57		 push	 edi

; 302  :     PADAPT              pAdapt = (PADAPT)MiniportAdapterContext;

  0004f	8b 45 08	 mov	 eax, DWORD PTR _MiniportAdapterContext$[ebp]
  00052	89 45 fc	 mov	 DWORD PTR _pAdapt$[ebp], eax

; 303  :     NDIS_STATUS         Status;
; 304  :     PNDIS_PACKET        MyPacket;
; 305  :     PVOID               MediaSpecificInfo = NULL;

⌨️ 快捷键说明

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