Home › Forums › Discussions › Support › Error in running list
- This topic has 3 replies, 2 voices, and was last updated 15 years, 9 months ago by bakhtiar.
-
AuthorPosts
-
February 23, 2009 at 2:58 pm #5268
I have started to study some of the sample codes with Winpkfilter like listadapters, I’m using Visual Studio 2008 but I got the following error:
1>adapter.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: virtual __thiscall CNdisApi::~CNdisApi(void)” (__imp_??1CNdisApi@@UAE@XZ) referenced in function _main
1>adapter.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: int __thiscall CNdisApi::GetAdapterMode(struct _ADAPTER_MODE *)” (__imp_?GetAdapterMode@CNdisApi@@QAEHPAU_ADAPTER_MODE@@@Z) referenced in function _mainthe code is :
The following is the code:
#include “stdafx.h”
int main(int argc, char* argv[])
{
CNdisApi api;
TCP_AdapterList AdList;
OSVERSIONINFO verInfo;
char szFriendlyName[MAX_PATH*4];
ADAPTER_MODE Mode;
verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx ( &verInfo );
DWORD dwMTUDec = api.GetMTUDecrement();
DWORD dwAdapterStartupMode = api.GetAdaptersStartupMode();
if(api.IsDriverLoaded())
{
printf(“The following network interfaces are available to MSTCP:n”);
api.GetTcpipBoundAdaptersInfo (&AdList);
for (UINT i = 0; i < AdList.m_nAdapterCount; ++i)
{
if (verInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
if (verInfo.dwMajorVersion > 4)
{
// Windows 2000 or XP
CNdisApi::ConvertWindows2000AdapterName((const char*)AdList.m_szAdapterNameList, szFriendlyName, MAX_PATH*4);
}
else if (verInfo.dwMajorVersion == 4)
{
// Windows NT 4.0
CNdisApi::ConvertWindowsNTAdapterName((const char*)AdList.m_szAdapterNameList, szFriendlyName, MAX_PATH*4);
}
}
else
{
// Windows 9x/ME
CNdisApi::ConvertWindows9xAdapterName((const char*)AdList.m_szAdapterNameList, szFriendlyName, MAX_PATH*4);
}
printf (“%d) %s.n”,i+1, szFriendlyName);
printf (“tInternal Name:t %sn”, AdList.m_szAdapterNameList);printf (
“tCurrent MAC:t %.2X%.2X%.2X%.2X%.2X%.2Xn”,
AdList.m_czCurrentAddress[0],
AdList.m_czCurrentAddress[1],
AdList.m_czCurrentAddress[2],
AdList.m_czCurrentAddress[3],
AdList.m_czCurrentAddress[4],
AdList.m_czCurrentAddress[5]
);
printf (“tMedium:t 0x%.8Xn”, AdList.m_nAdapterMediumList);
printf (“tCurrent MTU:t %dn”, AdList.m_usMTU);
RtlZeroMemory(&Mode, sizeof(ADAPTER_MODE));
Mode.hAdapterHandle = AdList.m_nAdapterHandle;
if (api.GetAdapterMode (&Mode))
printf(“tCurrent adapter mode = 0x%Xn”, Mode.dwFlags);
}
printf (“nCurrent system wide MTU decrement = %dn”, dwMTUDec);
printf (“nDefault adapter startup mode = 0x%X”, dwAdapterStartupMode);
}
else
printf(“Helper driver failed to load or was not installed.n”);
return 0;
}Can any one help me.
Rgerads
February 23, 2009 at 8:20 pm #6779that kind of errors occurs in c/c++ when a library is missing, by default, the sample projects add this library references, maybe you get off this library reference. try this:
find in samples the requiered library:
WinpkFilterkernelbindlli386ndisapi.lib
then link to your source code in this way,
#pragma comment(lib,”WinpkFilterkernelbindlli386ndisapi.lib”)
use your real paths to ndisapi.lib,
try this, or in project settings add the library reference, is the same but in two diferent ways..
bye.
February 23, 2009 at 8:23 pm #6780by example try this:
// this is your real code:
#include “stdafx.h”
// include this..
#pragma comment(lib,’path to your nsdisapi.lib including ndisapi.lib’)int main(int argc, char* argv[])
{
CNdisApi api;
TCP_AdapterList AdList;
OSVERSIONINFO verInfo;…
}OR, maybe you change the calling convention on your compiler, first try this
February 24, 2009 at 12:02 am #6781Hi;
I have added the line, but now I got the following errors:
1>c:university datafirewallwinpkfilterwinpkfilteradapter.cpp(2) : warning C4129: ‘P’ : unrecognized character escape sequence
1>c:university datafirewallwinpkfilterwinpkfilteradapter.cpp(2) : warning C4129: ‘W’ : unrecognized character escape sequence
1>c:university datafirewallwinpkfilterwinpkfilteradapter.cpp(2) : warning C4129: ‘k’ : unrecognized character escape sequence
1>c:university datafirewallwinpkfilterwinpkfilteradapter.cpp(2) : warning C4129: ‘d’ : unrecognized character escape sequence
1>c:university datafirewallwinpkfilterwinpkfilteradapter.cpp(2) : warning C4129: ‘i’ : unrecognized character escape sequence
1>Linking…
1>LINK : fatal error LNK1104: cannot open file ‘c:Program FilesWinpkFilterkernelindlli386
1>disapi.lib’Regards
@master.asc wrote:
by example try this:
// this is your real code:
#include “stdafx.h”
// include this..
#pragma comment(lib,’path to your nsdisapi.lib including ndisapi.lib’)int main(int argc, char* argv[])
{
CNdisApi api;
TCP_AdapterList AdList;
OSVERSIONINFO verInfo;…
}OR, maybe you change the calling convention on your compiler, first try this
-
AuthorPosts
- You must be logged in to reply to this topic.