Wireshark-dev: [Wireshark-dev] Using a dll in a custom dissector
Date: Mon, 2 Mar 2009 16:23:52 +0000
hello,

I'm just learning about dll's and have created a custom dissector. I was hoping someone could help clear up using a dll with my dissector. I'm currently using LoadLibrary() and i have just started trying to use the dll. My dll will be using 2 other .lib's. Is it possible to create a variable in the dll and have functions that can be used by the dissector plugin to set it and manipulate it without having direct access to it? I have tried to do so since it is a class that i am trying to manipulate, which you cant do in c. The dll is written in c++. Also, i'm having a bit of trouble using the functions in my dissector. Here is some sample. 

after the #includes:
typedef void  (*CreateProxy)( const BYTE*, int );
typedef char * (*GetMsgName)( void );
GetMsgName			_GetMsgName;
CreateProxy			_CreateProxy;
HINSTANCE			LoadProxy;

void
load_DLL(void)
{

	LoadProxy = LoadLibrary(TEXT("IComProxy.dll"));
	if (LoadProxy != NULL) /** then load functions */
	{	
		_CreateProxy = (CreateProxy)GetProcAddress(LoadProxy, "CreateProxy");
		_GetMsgName = (GetMsgName)GetProcAddress(LoadProxy, "GetMsgName");
	}

}

void
unload_DLL(void)
{
	FreeLibrary(LoadProxy);
}

//in static void dissect_icom
void *target;
char *msg;
target = tvb_memdup(tvb, offset, data_length);
(_CreateProxy)( (const BYTE*)target, data_length); //creates an object in the dll
msg = (_GetMsgName)( void ); //should call a function in the object created in the dll to return a char *

but i get:
packet-foo.c(234) : error C2143: syntax error : missing ')' before 'type'
packet-foo.c(234) : error C2059: syntax error : ')'

Thanks for any help,
Greg