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

📄 passthru.cod

📁 James Antognini和Tom Divine提供的PASSTHRU的编成实例。
💻 COD
📖 第 1 页 / 共 3 页
字号:

  002da	c7 85 60 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _MChars$[ebp+104], OFFSET FLAT:_MPAdapterShutdown@4

; 158  : #endif // NDIS51_MINIPORT
; 159  : 
; 160  :         //
; 161  :         // We will disable the check for hang timeout so we do not
; 162  :         // need a check for hang handler!
; 163  :         //
; 164  :         MChars.CheckForHangHandler = NULL;

  002e4	c7 85 00 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _MChars$[ebp+8], 0

; 165  :         MChars.ReturnPacketHandler = MPReturnPacket;

  002ee	c7 85 34 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _MChars$[ebp+60], OFFSET FLAT:_MPReturnPacket@8

; 166  : 
; 167  :         //
; 168  :         // Either the Send or the SendPackets handler should be specified.
; 169  :         // If SendPackets handler is specified, SendHandler is ignored
; 170  :         //
; 171  :         MChars.SendHandler = NULL;    // MPSend;

  002f8	c7 85 28 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _MChars$[ebp+48], 0

; 172  :         MChars.SendPacketsHandler = MPSendPackets;

  00302	c7 85 38 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _MChars$[ebp+64], OFFSET FLAT:_MPSendPackets@12

; 173  : 
; 174  :         Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,
; 175  :                                                   &MChars,
; 176  :                                                   sizeof(MChars),
; 177  :                                                   &DriverHandle);

  0030c	68 00 00 00 00	 push	 OFFSET FLAT:_DriverHandle
  00311	6a 7c		 push	 124			; 0000007cH
  00313	8d 85 f8 fe ff
	ff		 lea	 eax, DWORD PTR _MChars$[ebp]
  00319	50		 push	 eax
  0031a	8b 0d 00 00 00
	00		 mov	 ecx, DWORD PTR _NdisWrapperHandle
  00320	51		 push	 ecx
  00321	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisIMRegisterLayeredMiniport@16
  00327	89 85 f4 fe ff
	ff		 mov	 DWORD PTR _Status$[ebp], eax

; 178  :         if (Status != NDIS_STATUS_SUCCESS)

  0032d	83 bd f4 fe ff
	ff 00		 cmp	 DWORD PTR _Status$[ebp], 0
  00334	74 05		 je	 SHORT $L15897

; 179  :         {
; 180  :             break;

  00336	e9 00 01 00 00	 jmp	 $L15890
$L15897:

; 181  :         }
; 182  : 
; 183  : #ifndef WIN9X
; 184  :         NdisMRegisterUnloadHandler(NdisWrapperHandle, PtUnload);

  0033b	68 00 00 00 00	 push	 OFFSET FLAT:_PtUnload@4
  00340	8b 15 00 00 00
	00		 mov	 edx, DWORD PTR _NdisWrapperHandle
  00346	52		 push	 edx
  00347	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisMRegisterUnloadHandler@8

; 185  : #endif
; 186  : 
; 187  :         //
; 188  :         // Now register the protocol.
; 189  :         //
; 190  :         NdisZeroMemory(&PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));

  0034d	b9 1b 00 00 00	 mov	 ecx, 27			; 0000001bH
  00352	33 c0		 xor	 eax, eax
  00354	8d 7d 80	 lea	 edi, DWORD PTR _PChars$[ebp]
  00357	f3 ab		 rep stosd

; 191  :         PChars.MajorNdisVersion = PASSTHRU_PROT_MAJOR_NDIS_VERSION;

  00359	c6 45 80 05	 mov	 BYTE PTR _PChars$[ebp], 5

; 192  :         PChars.MinorNdisVersion = PASSTHRU_PROT_MINOR_NDIS_VERSION;

  0035d	c6 45 81 00	 mov	 BYTE PTR _PChars$[ebp+1], 0

; 193  : 
; 194  :         //
; 195  :         // Make sure the protocol-name matches the service-name
; 196  :         // (from the INF) under which this protocol is installed.
; 197  :         // This is needed to ensure that NDIS can correctly determine
; 198  :         // the binding and call us to bind to miniports below.
; 199  :         //
; 200  :         NdisInitUnicodeString(&Name, L"Passthru");    // Protocol name

  00361	68 00 00 00 00	 push	 OFFSET FLAT:$SG15899
  00366	8d 85 78 ff ff
	ff		 lea	 eax, DWORD PTR _Name$[ebp]
  0036c	50		 push	 eax
  0036d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisInitUnicodeString@8

; 201  :         PChars.Name = Name;

  00373	8b 8d 78 ff ff
	ff		 mov	 ecx, DWORD PTR _Name$[ebp]
  00379	89 4d b0	 mov	 DWORD PTR _PChars$[ebp+48], ecx
  0037c	8b 95 7c ff ff
	ff		 mov	 edx, DWORD PTR _Name$[ebp+4]
  00382	89 55 b4	 mov	 DWORD PTR _PChars$[ebp+52], edx

; 202  :         PChars.OpenAdapterCompleteHandler = PtOpenAdapterComplete;

  00385	c7 45 88 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+8], OFFSET FLAT:_PtOpenAdapterComplete@12

; 203  :         PChars.CloseAdapterCompleteHandler = PtCloseAdapterComplete;

  0038c	c7 45 8c 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+12], OFFSET FLAT:_PtCloseAdapterComplete@8

; 204  :         PChars.SendCompleteHandler = PtSendComplete;

  00393	c7 45 90 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+16], OFFSET FLAT:_PtSendComplete@12

; 205  :         PChars.TransferDataCompleteHandler = PtTransferDataComplete;

  0039a	c7 45 94 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+20], OFFSET FLAT:_PtTransferDataComplete@16

; 206  :     
; 207  :         PChars.ResetCompleteHandler = PtResetComplete;

  003a1	c7 45 98 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+24], OFFSET FLAT:_PtResetComplete@8

; 208  :         PChars.RequestCompleteHandler = PtRequestComplete;

  003a8	c7 45 9c 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+28], OFFSET FLAT:_PtRequestComplete@12

; 209  :         PChars.ReceiveHandler = PtReceive;

  003af	c7 45 a0 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+32], OFFSET FLAT:_PtReceive@28

; 210  :         PChars.ReceiveCompleteHandler = PtReceiveComplete;

  003b6	c7 45 a4 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+36], OFFSET FLAT:_PtReceiveComplete@4

; 211  :         PChars.StatusHandler = PtStatus;

  003bd	c7 45 a8 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+40], OFFSET FLAT:_PtStatus@16

; 212  :         PChars.StatusCompleteHandler = PtStatusComplete;

  003c4	c7 45 ac 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+44], OFFSET FLAT:_PtStatusComplete@4

; 213  :         PChars.BindAdapterHandler = PtBindAdapter;

  003cb	c7 45 bc 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+60], OFFSET FLAT:_PtBindAdapter@20

; 214  :         PChars.UnbindAdapterHandler = PtUnbindAdapter;

  003d2	c7 45 c0 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+64], OFFSET FLAT:_PtUnbindAdapter@12

; 215  :         PChars.UnloadHandler = PtUnloadProtocol;

  003d9	c7 45 c8 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+72], OFFSET FLAT:_PtUnloadProtocol@0

; 216  : 
; 217  :         PChars.ReceivePacketHandler = PtReceivePacket;

  003e0	c7 45 b8 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+56], OFFSET FLAT:_PtReceivePacket@8

; 218  :         PChars.PnPEventHandler= PtPNPHandler;

  003e7	c7 45 c4 00 00
	00 00		 mov	 DWORD PTR _PChars$[ebp+68], OFFSET FLAT:_PtPNPHandler@8

; 219  : 
; 220  :         NdisRegisterProtocol(&Status,
; 221  :                              &ProtHandle,
; 222  :                              &PChars,
; 223  :                              sizeof(NDIS_PROTOCOL_CHARACTERISTICS));

  003ee	6a 6c		 push	 108			; 0000006cH
  003f0	8d 45 80	 lea	 eax, DWORD PTR _PChars$[ebp]
  003f3	50		 push	 eax
  003f4	68 00 00 00 00	 push	 OFFSET FLAT:_ProtHandle
  003f9	8d 8d f4 fe ff
	ff		 lea	 ecx, DWORD PTR _Status$[ebp]
  003ff	51		 push	 ecx
  00400	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisRegisterProtocol@16

; 224  : 
; 225  :         if (Status != NDIS_STATUS_SUCCESS)

  00406	83 bd f4 fe ff
	ff 00		 cmp	 DWORD PTR _Status$[ebp], 0
  0040d	74 0f		 je	 SHORT $L15903

; 226  :         {
; 227  :             NdisIMDeregisterLayeredMiniport(DriverHandle);

  0040f	8b 15 00 00 00
	00		 mov	 edx, DWORD PTR _DriverHandle
  00415	52		 push	 edx
  00416	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisIMDeregisterLayeredMiniport@4

; 228  :             break;

  0041c	eb 1d		 jmp	 SHORT $L15890
$L15903:

; 229  :         }
; 230  : 
; 231  :         NdisIMAssociateMiniport(DriverHandle, ProtHandle);

  0041e	a1 00 00 00 00	 mov	 eax, DWORD PTR _ProtHandle
  00423	50		 push	 eax
  00424	8b 0d 00 00 00
	00		 mov	 ecx, DWORD PTR _DriverHandle
  0042a	51		 push	 ecx
  0042b	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisIMAssociateMiniport@8

; 232  :     }
; 233  :     while (FALSE);

  00431	33 d2		 xor	 edx, edx
  00433	85 d2		 test	 edx, edx
  00435	0f 85 32 fe ff
	ff		 jne	 $L15888
$L15890:

; 234  : 
; 235  :     if (Status != NDIS_STATUS_SUCCESS)

  0043b	83 bd f4 fe ff
	ff 00		 cmp	 DWORD PTR _Status$[ebp], 0
  00442	74 0e		 je	 SHORT $L15906

; 236  :     {
; 237  :         NdisTerminateWrapper(NdisWrapperHandle, NULL);

  00444	6a 00		 push	 0
  00446	a1 00 00 00 00	 mov	 eax, DWORD PTR _NdisWrapperHandle
  0044b	50		 push	 eax
  0044c	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisTerminateWrapper@8
$L15906:

; 238  :     }
; 239  : 
; 240  :     return(Status);

  00452	8b 85 f4 fe ff
	ff		 mov	 eax, DWORD PTR _Status$[ebp]

; 241  : }

  00458	5f		 pop	 edi
  00459	5e		 pop	 esi
  0045a	8b e5		 mov	 esp, ebp
  0045c	5d		 pop	 ebp
  0045d	c2 08 00	 ret	 8
_DriverEntry@8 ENDP
INIT	ENDS
PUBLIC	_PtDispatch@8
PUBLIC	_PtRegisterDevice@0
EXTRN	__imp__NdisMRegisterDevice@24:NEAR
EXTRN	__imp__NdisMSleep@4:NEAR
EXTRN	__imp__NdisAcquireSpinLock@4:NEAR
EXTRN	__imp__NdisReleaseSpinLock@4:NEAR
EXTRN	__imp__RtlAssert@16:NEAR
;	COMDAT _PtRegisterDevice@0
_TEXT	SEGMENT
$SG15916 DB	'Passthru: ', 00H
	ORG $+1
$SG15917 DB	'==>PtRegisterDevice', 0aH, 00H
	ORG $+3
$SG15920 DB	'g:\pcadev\ndisim\passthruex\part2\james\james\sys\passth'
	DB	'ru.c', 00H
	ORG $+3
$SG15921 DB	'ControlDeviceState != PS_DEVICE_STATE_CREATING', 00H
	ORG $+1
$SG15926 DB	'\', 00H, 'D', 00H, 'e', 00H, 'v', 00H, 'i', 00H, 'c', 00H
	DB	'e', 00H, '\', 00H, 'P', 00H, 'a', 00H, 's', 00H, 's', 00H, 't'
	DB	00H, 'h', 00H, 'r', 00H, 'u', 00H, 00H, 00H
	ORG $+2
$SG15927 DB	'\', 00H, 'D', 00H, 'o', 00H, 's', 00H, 'D', 00H, 'e', 00H
	DB	'v', 00H, 'i', 00H, 'c', 00H, 'e', 00H, 's', 00H, '\', 00H, 'P'
	DB	00H, 'a', 00H, 's', 00H, 's', 00H, 't', 00H, 'h', 00H, 'r', 00H
	DB	'u', 00H, 00H, 00H
	ORG $+2
$SG15928 DB	'Passthru: ', 00H
	ORG $+1
$SG15929 DB	'<==PtRegisterDevice: %x', 0aH, 00H
; Function compile flags: /Odt
tv74 = -140
_DispatchTable$ = -136
_DeviceLinkUnicodeString$ = -20
_DeviceName$ = -12
_Status$ = -4
_PtRegisterDevice@0 PROC NEAR				; COMDAT

; 273  : {

  00109	55		 push	 ebp
  0010a	8b ec		 mov	 ebp, esp
  0010c	81 ec 8c 00 00
	00		 sub	 esp, 140		; 0000008cH
  00112	57		 push	 edi

; 274  :     NDIS_STATUS            Status = NDIS_STATUS_SUCCESS;

  00113	c7 45 fc 00 00
	00 00		 mov	 DWORD PTR _Status$[ebp], 0

; 275  :     UNICODE_STRING         DeviceName;
; 276  :     UNICODE_STRING         DeviceLinkUnicodeString;
; 277  :     PDRIVER_DISPATCH       DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1];
; 278  : 
; 279  :     DBGPRINT(("==>PtRegisterDevice\n"));

  0011a	68 00 00 00 00	 push	 OFFSET FLAT:$SG15916
  0011f	e8 00 00 00 00	 call	 _DbgPrint
  00124	83 c4 04	 add	 esp, 4
  00127	68 00 00 00 00	 push	 OFFSET FLAT:$SG15917
  0012c	e8 00 00 00 00	 call	 _DbgPrint
  00131	83 c4 04	 add	 esp, 4

; 280  : 
; 281  :     NdisAcquireSpinLock(&GlobalLock);

  00134	68 00 00 00 00	 push	 OFFSET FLAT:_GlobalLock
  00139	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisAcquireSpinLock@4

; 282  : 
; 283  :     ++MiniportCount;

  0013f	a1 00 00 00 00	 mov	 eax, DWORD PTR _MiniportCount
  00144	83 c0 01	 add	 eax, 1
  00147	a3 00 00 00 00	 mov	 DWORD PTR _MiniportCount, eax

; 284  :     
; 285  :     if (1 == MiniportCount)

  0014c	83 3d 00 00 00
	00 01		 cmp	 DWORD PTR _MiniportCount, 1
  00153	0f 85 fd 00 00
	00		 jne	 $L15918

; 286  :     {
; 287  :         ASSERT(ControlDeviceState != PS_DEVICE_STATE_CREATING);

  00159	83 3d 00 00 00
	00 01		 cmp	 DWORD PTR _ControlDeviceState, 1
  00160	75 23		 jne	 SHORT $L16010
  00162	6a 00		 push	 0
  00164	68 1f 01 00 00	 push	 287			; 0000011fH
  00169	68 00 00 00 00	 push	 OFFSET FLAT:$SG15920
  0016e	68 00 00 00 00	 push	 OFFSET FLAT:$SG15921
  00173	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__RtlAssert@16
  00179	c7 85 74 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR tv74[ebp], 0
  00183	eb 0a		 jmp	 SHORT $L15923
$L16010:
  00185	c7 85 74 ff ff
	ff 01 00 00 00	 mov	 DWORD PTR tv74[ebp], 1
$L15923:

; 288  : 
; 289  :         //
; 290  :         // Another thread could be running PtDeregisterDevice on
; 291  :         // behalf of another miniport instance. If so, wait for
; 292  :         // it to exit.
; 293  :         //
; 294  :         while (ControlDeviceState != PS_DEVICE_STATE_READY)

  0018f	83 3d 00 00 00
	00 00		 cmp	 DWORD PTR _ControlDeviceState, 0
  00196	74 20		 je	 SHORT $L15924

; 295  :         {
; 296  :             NdisReleaseSpinLock(&GlobalLock);

  00198	68 00 00 00 00	 push	 OFFSET FLAT:_GlobalLock
  0019d	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisReleaseSpinLock@4

; 297  :             NdisMSleep(1);

  001a3	6a 01		 push	 1
  001a5	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisMSleep@4

; 298  :             NdisAcquireSpinLock(&GlobalLock);

  001ab	68 00 00 00 00	 push	 OFFSET FLAT:_GlobalLock
  001b0	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisAcquireSpinLock@4

; 299  :         }

  001b6	eb d7		 jmp	 SHORT $L15923
$L15924:

; 300  : 
; 301  :         ControlDeviceState = PS_DEVICE_STATE_CREATING;

  001b8	c7 05 00 00 00
	00 01 00 00 00	 mov	 DWORD PTR _ControlDeviceState, 1

; 302  : 
; 303  :         NdisReleaseSpinLock(&GlobalLock);

  001c2	68 00 00 00 00	 push	 OFFSET FLAT:_GlobalLock
  001c7	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__NdisReleaseSpinLock@4

; 304  : 
; 305  :     
; 306  :         NdisZeroMemory(DispatchTable, (IRP_MJ_MAXIMUM_FUNCTION+1) * sizeof(PDRIVER_DISPATCH));

  001cd	b9 1c 00 00 00	 mov	 ecx, 28			; 0000001cH
  001d2	33 c0		 xor	 eax, eax
  001d4	8d bd 78 ff ff
	ff		 lea	 edi, DWORD PTR _DispatchTable$[ebp]
  001da	f3 ab		 rep stosd

; 307  : 
; 308  :         DispatchTable[IRP_MJ_CREATE] = PtDispatch;

  001dc	c7 85 78 ff ff
	ff 00 00 00 00	 mov	 DWORD PTR _DispatchTable$[ebp], OFFSET FLAT:_PtDispatch@8

; 309  :         DispatchTable[IRP_MJ_CLEANUP] = PtDispatch;

  001e6	c7 45 c0 00 00
	00 00		 mov	 DWORD PTR _DispatchTable$[ebp+72], OFFSET FLAT:_PtDispatch@8

; 310  :         DispatchTable[IRP_MJ_CLOSE] = PtDispatch;

⌨️ 快捷键说明

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