JB3DG
Resource contributor
- Messages
- 1,325
- Country

Hi guys
Again using a modded ESP example....all the work being done here however is in the GaugeDeclarations.cpp.
First off, the code:
Under the module_init/deinit functions are the register/unregister_key_event_handler functions. If I comment them out the gauge runs fine except the event system doesnt work so clicking on a switch does nothing. If i bring them back in however the sim crashes on load with a NULL pointer exception. So something here: ((GAUGE_KEY_EVENT_HANDLER)EventHandler
is not happening....and it just dont make sense. So...any ideas?
Another thing, I would really like to be able to solve such problems on my own but i have no idea on how to get a detailed output from the C++ debugger. All i get when the dll crashes is this:
First-chance exception at 0x00000000 in fsx.exe: 0xC0000005: Access violation.
So is there any way to output what functions/vars/objects or whatever are involved in the exception?
Again using a modded ESP example....all the work being done here however is in the GaugeDeclarations.cpp.
First off, the code:
Code:
void FSAPI module_init(void);
void FSAPI module_deinit(void);
void EventHandler(ID32 event, UINT32 evdata, PVOID userdata);
eventsdata events;
void FSAPI module_init(void)
{
register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, NULL);
// Initialize the Singleton class that holds the SimConnect data
SimConnectData = CSimConnectData::Instance();
SimConnectData->NavData = new NavData();
SimConnectData->Populated = false;
// Instantiate SimConnect
hr = SimConnect_Open(&hSimConnect, ("//Not for you guys to know yet....."), NULL, 0, 0, 0);
// Define a callback in this dll so that the simulation can be notified of SimConnect events
if( hr == S_OK )
hr = SimConnect_CallDispatch(hSimConnect, SampleGauge_DispatchProcDLL, NULL);
}
void FSAPI module_deinit(void)
{
unregister_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, NULL);
// Dispose of SimConnect
hr = SimConnect_Close(hSimConnect);
};
void EventHandler(ID32 event, UINT32 evdata, PVOID userdata)
{
switch(event)
{
case 0x11000:
if(events.batt == 1)
{
events.batt --;
}
if(events.batt == 0)
{
trigger_key_event(KEY_TOGGLE_MASTER_BATTERY, 0);
events.batt += 2;
}
break;
case 0x11001:
if(events.batt == 2)
{
events.batt -= 2;
trigger_key_event(KEY_TOGGLE_MASTER_BATTERY, 0);
}
if(events.batt == 0)
{
if(events.eng_master == true)
{
trigger_key_event(KEY_TOGGLE_STARTER1, 0);
}
events.batt ++;
}
break;
case 0x11002:
events.eng_master = !events.eng_master;
trigger_key_event(KEY_TOGGLE_MASTER_IGNITION_SWITCH, 0);
break;
case 0x11003:
events.stop_start = !events.stop_start;
break;
default:
break;
}
return;
}
Under the module_init/deinit functions are the register/unregister_key_event_handler functions. If I comment them out the gauge runs fine except the event system doesnt work so clicking on a switch does nothing. If i bring them back in however the sim crashes on load with a NULL pointer exception. So something here: ((GAUGE_KEY_EVENT_HANDLER)EventHandler
is not happening....and it just dont make sense. So...any ideas?
Another thing, I would really like to be able to solve such problems on my own but i have no idea on how to get a detailed output from the C++ debugger. All i get when the dll crashes is this:
First-chance exception at 0x00000000 in fsx.exe: 0xC0000005: Access violation.
So is there any way to output what functions/vars/objects or whatever are involved in the exception?
Last edited:

