TDI Dispatch table error on Win 98

Hi Everybody,

I am trying to get Tdi Dispatch table on Windows 98.
But VTDI_Get_Info function is returning 0 in eax.

I have set Load order of my vxd properly so that it will be loaded
after vtdi.386. But what is the error I am not able to trace.

See some of my code as follows ------

Waiting for your comments.

Cheers
Rajesh

// ===== mytdi.h =====
#define VMM_Init_Order VMM_INIT_ORDER
#include <netvxd.h>

#define MYTDI_Major 1
#define MYTDI_Minor 0
#define MYTDI_DeviceID UNDEFINED_DEVICE_ID
#define MYTDI_Init_Order (0xF000 + VTDI_Init_Order)

//===== mytdi.c =======

// function in xmytdi.asm file
extern DWORD __stdcall Hook_TdiDispatchTable () ;

// Device parameters
Declare_Virtual_Device(MYTDI)

// Declare prototypes for control message handlers
DefineControlHandler(DEVICE_INIT, OnDeviceInit) ;

// This is the control message dispatcher
BOOL ControlDispatcher(
DWORD dwControlMessage,
DWORD EBX,
DWORD EDX,
DWORD ESI,
DWORD EDI,
DWORD ECX)
{
START_CONTROL_DISPATCH

ON_DEVICE_INIT(OnDeviceInit) ;

END_CONTROL_DISPATCH

return TRUE;
}

// This is the handler for control message DEVICE_INIT
BOOL OnDeviceInit(VMHANDLE hVM, PCHAR CommandTail)
{

dprintf (“OnDeviceInit: Before Hook_TdiDispatchTable\n”) ;

Hook_TdiDispatchTable () ;

dprintf (“OnDeviceInit: After Hook_TdiDispatchTable\n”) ;

return TRUE ;
}

VOID__stdcall MyDbgPrint (PCHAR s)
{
dprintf (“MyTdi: %s\n”, s) ;
}

VOID __stdcall MyDbgPrintInt (int dwAddr)
{
dprintf (“%08X\n”, dwAddr) ;
}

//===== xmytdi.asm =======

VTDI_Device_ID equ 0488h

INCLUDE VTDI.INC

//
// functions declaraed in mytdi.c
//
EXTSFUNC MyDbgPrint, 4
EXTSFUNC MyDbgPrintInt, 4

VxD_LOCKED_DATA_SEG

TCPName db ‘MSTCP’, 0
TdiDispatchTable dd 0

dbgHKDisp db “Hook_TdiDispatchTable Called.”, 0
dbgHKDisp1 db “Hook_TdiDispatchTable Success.”, 0
dbgHKDisp0 db “Hook_TdiDispatchTable Failed.”, 0
dbgDisp db "TdiDispatch Table : ", 0

VxD_LOCKED_DATA_ENDS

VxD_LOCKED_CODE_SEG

DEFSPROC Hook_TdiDispatchTable

; Make sure VTDI is present

push offset32 dbgHKDisp
call MyDbgPrint ; this function prints passed string

VxDcall VTDI_Get_Version
jc Abort

; Get a pointer to the TCP dispatch table

push offset32 TCPName
VxDcall VTDI_Get_Info
add esp, 4

mov TdiDispatchTable, eax ; Save the address of TdiDispatchTable

push offset32 dbgDisp
call MyDbgPrint

push eax
call MyDbgPrintInt

cmp eax, 0
je Abort

push offset32 dbgHKDisp1
call MyDbgPrint

ret

Abort :

push offset32 dbgHKDisp0
call MyDbgPrint

ret
ENDSPROC Hook_TdiDispatchTable

VXD_LOCKED_CODE_ENDS

End</netvxd.h>

I’m not sure if this is your problem or not – but one thing to keep in mind is that you want to match a free build of your driver with the free build of vtdi.386 and the same with the debug version. Otherwise, you’ll hit the wrong entry point.

This is because of the two debug ordinals that were inserted in the middle of the service table:

Begin_Service_Table VTDI

VTDI_Service VTDI_Get_Version, LOCAL
VTDI_Service VTDI_Start_Timer
VTDI_Service VTDI_Stop_Timer
>> ifdef DEBUG
>> VTDI_Service VTDI_Get_Lock
>> VTDI_Service VTDI_Free_Lock
>> endif
VTDI_Service VTDI_Schedule_Event
VTDI_Service VTDI_Cancel_Event
VTDI_Service VTDI_Block
VTDI_Service VTDI_Signal
VTDI_Service VTDI_Register
VTDI_Service VTDI_Get_Info
VTDI_Service VTDI_Unload
VTDI_Service VTDI_Initialize
VTDI_Service VTDI_Register_UnloadProc
VTDI_Service VTDI_Register_LoadProc
VTDI_Service VTDI_Block1
VTDI_Service VTDI_Schedule_Event_N

End_Service_Table VTDI

Instead of hitting VTDI_Get_Info, you might be hitting VTDI_Signal or VTDI_Initialize by mistake depending on which way there’s a mismatch – if any.

There are ways to get around this at runtime and make adjustments on the fly

Bryan S. Burgin
xxxxx@microsoft.com

This posting is provided “AS IS” with no warranties, and confers no rights.


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Rajesh Nikam
Sent: Thursday, April 08, 2004 12:39 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] TDI Dispatch table error on Win 98

Hi Everybody,
?
I am trying to get Tdi Dispatch table on Windows 98.
But VTDI_Get_Info function is returning 0 in eax.
?
I have set Load order of my vxd properly so that it will be loaded
after vtdi.386. But what is the error I am not able to trace.
?
See some of my code as follows ------
?
Waiting for your comments.
?
Cheers
Rajesh
?
// =====? mytdi.h =====
#define VMM_Init_Order VMM_INIT_ORDER
#include <netvxd.h>
?
#define MYTDI_Major???1
#define MYTDI_Minor???0
#define MYTDI_DeviceID? ?UNDEFINED_DEVICE_ID
#define MYTDI_Init_Order ?(0xF000 + VTDI_Init_Order)
?

//===== mytdi.c =======
?
// function in xmytdi.asm file???
extern DWORD __stdcall Hook_TdiDispatchTable () ;
?
// Device parameters
Declare_Virtual_Device(MYTDI)
?
// Declare prototypes for control message handlers
DefineControlHandler(DEVICE_INIT, OnDeviceInit) ;
?
// This is the control message dispatcher
BOOL ControlDispatcher(
?DWORD dwControlMessage,
?DWORD EBX,
?DWORD EDX,
?DWORD ESI,
?DWORD EDI,
?DWORD ECX)
{
?START_CONTROL_DISPATCH
?
?ON_DEVICE_INIT(OnDeviceInit) ;
?
?END_CONTROL_DISPATCH
?
?return TRUE;
}
?
// This is the handler for control message DEVICE_INIT
BOOL OnDeviceInit(VMHANDLE hVM, PCHAR CommandTail)
{
?
?dprintf (“OnDeviceInit: Before Hook_TdiDispatchTable\n”) ;
?
?Hook_TdiDispatchTable () ;
?
?dprintf (“OnDeviceInit: After Hook_TdiDispatchTable\n”) ;
?
?return TRUE ;
}
?
VOID__stdcall MyDbgPrint (PCHAR s)
{
?dprintf (“MyTdi: %s\n”, s) ;
}
?
VOID __stdcall MyDbgPrintInt (int dwAddr)
{
?dprintf (“%08X\n”, dwAddr) ;
}
?

//===== xmytdi.asm =======
?
VTDI_Device_ID??? equ 0488h
?
INCLUDE VTDI.INC
?
//
// functions declaraed in mytdi.c???
//
?EXTSFUNC MyDbgPrint, 4
?EXTSFUNC MyDbgPrintInt, 4
?
VxD_LOCKED_DATA_SEG
?
TCPName??? db ‘MSTCP’, 0
TdiDispatchTable??? dd 0
?
dbgHKDisp ??db “Hook_TdiDispatchTable Called.”, 0
dbgHKDisp1 ??db “Hook_TdiDispatchTable Success.”, 0
dbgHKDisp0 ??db “Hook_TdiDispatchTable Failed.”, 0
dbgDisp???db "TdiDispatch Table : ", 0
?
VxD_LOCKED_DATA_ENDS
?

VxD_LOCKED_CODE_SEG
?
DEFSPROC Hook_TdiDispatchTable
?
? ; Make sure VTDI is present
?
? push ?offset32 dbgHKDisp
? call ?MyDbgPrint?? ; this function prints passed string
?
? VxDcall VTDI_Get_Version
? jc Abort
?
? ; Get a pointer to the TCP dispatch table
?
? push offset32 TCPName
? VxDcall VTDI_Get_Info
? add esp, 4
?
? mov TdiDispatchTable, eax ; Save the address of TdiDispatchTable
?
? push ?offset32 dbgDisp
? call ?MyDbgPrint
?
? push ?eax
? call ?MyDbgPrintInt
?
? cmp eax, 0
? je? Abort
?
? push ?offset32 dbgHKDisp1
? call MyDbgPrint
?
? ret
?
Abort :
?
? push ?offset32 dbgHKDisp0
? call MyDbgPrint
?
? ret
ENDSPROC Hook_TdiDispatchTable
?

VXD_LOCKED_CODE_ENDS
?
End
?
?

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</netvxd.h>

Dear Bryan,

Thank for your reply.
I have commented

> ifdef DEBUG
> VTDI_Service VTDI_Get_Lock
> VTDI_Service VTDI_Free_Lock
> endif

as indicated by in vtdi.inc.

VTDI_Get_Version returns 00000100. It may be OK.
But VTDI_Get_Info still returns 0.

What care I have to take to get TdiDispatch table ?

What do you mean by following, please clarify.

>ere are ways to get around this at runtime and make adjustments on the fly

Waiting for reply.
Cheers
Rajesh

----- Original Message -----
From: “Bryan Burgin”
To: “Windows System Software Devs Interest List”
Cc:
Sent: Thursday, April 08, 2004 1:22 PM
Subject: RE: [ntdev] TDI Dispatch table error on Win 98

I’m not sure if this is your problem or not – but one thing to keep in mind
is that you want to match a free build of your driver with the free build of
vtdi.386 and the same with the debug version. Otherwise, you’ll hit the
wrong entry point.

This is because of the two debug ordinals that were inserted in the middle
of the service table:

Begin_Service_Table VTDI

VTDI_Service VTDI_Get_Version, LOCAL
VTDI_Service VTDI_Start_Timer
VTDI_Service VTDI_Stop_Timer
>> ifdef DEBUG
>> VTDI_Service VTDI_Get_Lock
>> VTDI_Service VTDI_Free_Lock
>> endif
VTDI_Service VTDI_Schedule_Event
VTDI_Service VTDI_Cancel_Event
VTDI_Service VTDI_Block
VTDI_Service VTDI_Signal
VTDI_Service VTDI_Register
VTDI_Service VTDI_Get_Info
VTDI_Service VTDI_Unload
VTDI_Service VTDI_Initialize
VTDI_Service VTDI_Register_UnloadProc
VTDI_Service VTDI_Register_LoadProc
VTDI_Service VTDI_Block1
VTDI_Service VTDI_Schedule_Event_N

End_Service_Table VTDI

Instead of hitting VTDI_Get_Info, you might be hitting VTDI_Signal or
VTDI_Initialize by mistake depending on which way there’s a mismatch – if
any.

There are ways to get around this at runtime and make adjustments on the fly

Bryan S. Burgin
xxxxx@microsoft.com

This posting is provided “AS IS” with no warranties, and confers no rights.

________________________________________
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Rajesh Nikam
Sent: Thursday, April 08, 2004 12:39 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] TDI Dispatch table error on Win 98

Hi Everybody,

I am trying to get Tdi Dispatch table on Windows 98.
But VTDI_Get_Info function is returning 0 in eax.

I have set Load order of my vxd properly so that it will be loaded
after vtdi.386. But what is the error I am not able to trace.

See some of my code as follows ------

Waiting for your comments.

Cheers
Rajesh

// ===== mytdi.h =====
#define VMM_Init_Order VMM_INIT_ORDER
#include <netvxd.h>

#define MYTDI_Major 1
#define MYTDI_Minor 0
#define MYTDI_DeviceID UNDEFINED_DEVICE_ID
#define MYTDI_Init_Order (0xF000 + VTDI_Init_Order)

//===== mytdi.c =======

// function in xmytdi.asm file
extern DWORD__stdcall Hook_TdiDispatchTable () ;

// Device parameters
Declare_Virtual_Device(MYTDI)

// Declare prototypes for control message handlers
DefineControlHandler(DEVICE_INIT, OnDeviceInit) ;

// This is the control message dispatcher
BOOL ControlDispatcher(
DWORD dwControlMessage,
DWORD EBX,
DWORD EDX,
DWORD ESI,
DWORD EDI,
DWORD ECX)
{
START_CONTROL_DISPATCH

ON_DEVICE_INIT(OnDeviceInit) ;

END_CONTROL_DISPATCH

return TRUE;
}

// This is the handler for control message DEVICE_INIT
BOOL OnDeviceInit(VMHANDLE hVM, PCHAR CommandTail)
{

dprintf (“OnDeviceInit: Before Hook_TdiDispatchTable\n”) ;

Hook_TdiDispatchTable () ;

dprintf (“OnDeviceInit: After Hook_TdiDispatchTable\n”) ;

return TRUE ;
}

VOID __stdcall MyDbgPrint (PCHAR s)
{
dprintf (“MyTdi: %s\n”, s) ;
}

VOID__stdcall MyDbgPrintInt (int dwAddr)
{
dprintf (“%08X\n”, dwAddr) ;
}

//===== xmytdi.asm =======

VTDI_Device_ID equ 0488h

INCLUDE VTDI.INC

//
// functions declaraed in mytdi.c
//
EXTSFUNC MyDbgPrint, 4
EXTSFUNC MyDbgPrintInt, 4

VxD_LOCKED_DATA_SEG

TCPName db ‘MSTCP’, 0
TdiDispatchTable dd 0

dbgHKDisp db “Hook_TdiDispatchTable Called.”, 0
dbgHKDisp1 db “Hook_TdiDispatchTable Success.”, 0
dbgHKDisp0 db “Hook_TdiDispatchTable Failed.”, 0
dbgDisp db "TdiDispatch Table : ", 0

VxD_LOCKED_DATA_ENDS

VxD_LOCKED_CODE_SEG

DEFSPROC Hook_TdiDispatchTable

; Make sure VTDI is present

push offset32 dbgHKDisp
call MyDbgPrint ; this function prints passed string

VxDcall VTDI_Get_Version
jc Abort

; Get a pointer to the TCP dispatch table

push offset32 TCPName
VxDcall VTDI_Get_Info
add esp, 4

mov TdiDispatchTable, eax ; Save the address of TdiDispatchTable

push offset32 dbgDisp
call MyDbgPrint

push eax
call MyDbgPrintInt

cmp eax, 0
je Abort

push offset32 dbgHKDisp1
call MyDbgPrint

ret

Abort :

push offset32 dbgHKDisp0
call MyDbgPrint

ret
ENDSPROC Hook_TdiDispatchTable

VXD_LOCKED_CODE_ENDS

End


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</netvxd.h>