I want to get the miniport and protocol handles from within my IM adapter

0 Likes

Problem:

I am writing an NDIS IM miniport and I have some DDK functions which require the NDIS_HANDLE for the protocol and miniport. How do I get these?

Resolution:

To do this there is a relatively undocumented method which will return a binding member from which you can access the protocol handle from within the adapter. The line reads like this:

NDIS_HANDLE myProtocolHandle = GetBinding()->GetContainerHandle();

If you want to return the miniport handle it requires a few additional steps:

1. In the DriverNetworks library, go to the file KNdisFilterBinding.h and directly under the function:

inline NDIS_HANDLE KNdisFilterBinding::GetContainerHandle()

{

// Assumes the driver uses KNdisIMiniDriver-derived for driver singleton

return static_cast<KNDISIMINIDRIVER*>(KNdisMiniDriver::DriverInstance())->GetProtocolHandle();

}

Add in:

// function to return the Miniport handle to the adapter

inline NDIS_HANDLE KNdisFilterBinding::GetContainerHandleMini()

{

// Assumes the driver uses KNdisIMiniDriver-derived for driver singleton

return static_cast<KNDISIMINIDRIVER*>(KNdisMiniDriver::DriverInstance())->GetMiniportHandle();

}

2. In the same KNdisFilterBinding.h file add the line:

static NDIS_HANDLE GetContainerHandleMini(); // added function for miniport handle

directly under:

static NDIS_HANDLE GetContainerHandle();

3. Now recompile the libraries.

Now in your adapter you can call:

hMiniPortAdapterHandle = GetBinding()->GetContainerHandleMini();

to get the miniport handle

Old KB# 11901
Comment List
Anonymous
Related Discussions
Recommended