From the code you showed it seems that you are just using invalid pointer, it's normal to crash. You must give it proper value in h_export.cpp. Here is code sample from one "stub" metamod plugin:
Code:
//! Holds engine functionality callbacks
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
// Receive engine function table from engine.
// This appears to be the _first_ DLL routine called by the engine, so we
// do some setup operations here.
void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals;
}
Now you can do extern the variable in any header or source file to use it(hint don't declare the pointer in to the header files, just extern it, it must be declared only once in a .cpp file and after that only "externed").
Sinse I see that you don't have much expirience in C++ I will give you little example that is explained well, lets say that you already declared and initalized the gpGlobals pointer in h_export.cpp and after that you want to use it in other source file like for example "my_plugin_source.cpp". You must put this
Code:
extern globalvars_t *gpGlobals;
after the include line or if you have header "my_plugin_source.h" that is included by "my_plugin_source.cpp" better put it there. Anyway I recommend other better practice for such global variables/pointers. Make two files like "globals.cpp" and "globals.h", declare the variable/pointer in to the "globals.cpp" and do the extern in "globals.h", then include "globals.h" in any source file that you want to use the variables/pointers that you declared there, in h_export.cpp leave just the function GiveFnptrsToDll() to give your global pointer proper value.
Here is code examples:
globals.h file
Code:
#include <extdll.h>
#include <h_export.h>
extern enginefuncs_t g_engfuncs;
extern globalvars_t *gpGlobals;
globals.cpp file
Code:
#include "globals.h"
//! Holds engine functionality callbacks
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
h_export.cpp file
Code:
#include "globals.h"
// Receive engine function table from engine.
// This appears to be the _first_ DLL routine called by the engine, so we
// do some setup operations here.
void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals;
}