Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6635631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:04:43+00:00 2026-05-25T23:04:43+00:00

I’m experiencing an access violation error when I try to call non static function.

  • 0

I’m experiencing an access violation error when I try to call non static function.

my .h file looks like this.

class World
{
public:
    World();
    virtual ~World();
    static void CALLBACK DispatchCallback(
        SIMCONNECT_RECV *pData,
        DWORD cbData,
        void *pContext
    );
    void Process(SIMCONNECT_RECV *pData, DWORD cbData);
    virtual void frameEvent();
    virtual void init();
};

Now in my .cpp file the init() function I call a function that return data to my callback function.

SimConnect_CallDispatch(hSimConnect, DispatchCallback, NULL);

Which sends data to the DisPatchCallback function.

In this function the following code resides:

void CALLBACK World::DispatchCallback(
    SIMCONNECT_RECV *pData,
    DWORD cbData,
    void *pContext)
{
    World *pThis = reinterpret_cast<World*>(pContext);
    pThis->Process(pData, cbData);
}

this function is a static function which creates a World object to call the Process function.

This works but it break on the line where it wants to access the frameEvent function.

void World::Process(SIMCONNECT_RECV *pData, DWORD cbData)
{
    HRESULT hr;

    switch(pData->dwID)
    {
    case SIMCONNECT_RECV_ID_EVENT_FRAME:
        frameEvent(); //it breaks here frameEvent is a non static function
        break;
    }
}

Access violation reading location 0x00000000.

Can someone point me to the right direction as to solve this issue.?

If you wonder I’m writing a plugin for Microsoft Flight Simulator X.

I’m trying to implement simconnect.h in a oo way. Msdn shows an example that I’m trying to implement.

class CName
{
    void Dispatch();
    static void DispatchCallback(
        SIMCONNECT_RECV *pData,
        DWORD cbData,
        void *pContext
    );
    void Process(SIMCONNECT_RECV *pData, DWORD cbData);

    HANDLE hSimConnect; // use SimConnect_Open to set this value.
};

void CName::Dispatch()
{
    ::SimConnect_Dispatch(hSimConnect, &CName;::DispatchCallback, this);
}

// static function
void CName::DispatchCallback(
    SIMCONNECT_RECV *pData,
    DWORD cbData,
    void *pContext)
{
    CName *pThis = reinterpret_cast<CName*>(pContext);
    pThis->Process(pData, cbData);
}

void CName::Process(SIMCONNECT_RECV *pData, DWORD cbData)
{
    // do processing of SimConnect data
}

I hope I gave enough information.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:04:44+00:00Added an answer on May 25, 2026 at 11:04 pm

    You’re passing NULL as the context parameter to SimConnect_CallDispatch, so your callback has no idea which World object to call Process on — how could it possibly if you don’t tell it? Change the call to pass in this as the context parameter, like the example does:

    SimConnect_CallDispatch(hSimConnect, DispatchCallback, this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.