Function from function ptr crashes in hook

BlitzMax Forums/BlitzMax Programming/Function from function ptr crashes in hook

JoshK(Posted 2006) [#1]
This is an odd error, but when I have an event hook like that below, it crashes with an Unhandled Memory Exception Error if a function gotten from a function pointer is called.
Function MainWindowHook:Object(id:Int,data:Object,context:Object)

	Local event:TEvent=TEvent(data)
	If event=Null Return data
	Select event.id
		Case EVENT_WINDOWSIZE
			GetVersion()
		Return Null
	EndSelect
	Return data
EndFunction


GetVersion() is a global function, loaded from a dll, like this. I used this one for testing, because it is a simple benign function.
Global GetVersion:Int() "win32"
GetVersion=getprocaddress(HLIB_ENGINE,"GetVersion")


This only happens if a function is called in the dll which creates a MaxGUI window. For instance, my Graphics() function in the dll creates a window with an OpenGL viewport drawn on it.

Any ideas?


JoshK(Posted 2006) [#2]
I was able to eliminate this by using only pure Windows handles to create viewports with. Previously, I was trying to mix gadgets in the dll and the exe, and who knows what errors that might have caused.