SetUnhandledExceptionFilter problem

Hi Guys,

Have a question regarding the exception filter.

I have a MiniDump class which looks like this:




I'm really stuck, would really appreciate help, thanks in advance!!

z00mit

Comments

  • : Hi Guys,
    :
    : Have a question regarding the exception filter.
    :
    : I have a MiniDump class which looks like this:
    :
    : class MiniDumpHelper
    : {
    : public:
    :
    : MiniDumpHelper()
    : {
    : ...
    : }
    :
    :
    : LONG WINAPI exitWithDump(struct _EXCEPTION_POINTERS*
    : exceptionInfo)
    : {
    : ...
    : return EXCEPTION_CONTINUE_SEARCH;
    : }
    : }
    :
    : then i have a host.cpp class where i have a main()
    : I try this:
    :
    : MiniDump *miniDump = new MiniDump();
    : SetUnhandledExceptionFilter(miniDump->exitWithDump);
    :
    : Then I get this:
    :
    : error C3867: 'MiniDump::exitWithDump': function call missing
    : argument list;
    : use '&MiniDump::exitWithDump' to create a pointer to member
    :
    : So I do:
    :
    : MiniDump *miniDump = new MiniDump();
    : SetUnhandledExceptionFilter(&MiniDump::exitWithDump);
    :
    : And I get this:
    :
    : 'SetUnhandledExceptionFilter' : cannot convert parameter 1 from
    : 'LONG (__stdcall :MiniDump::* )
    : (_EXCEPTION_POINTERS *)' to 'LPTOP_LEVEL_EXCEPTION_FILTER'
    :
    :
    :
    : I'm really stuck, would really appreciate help, thanks in advance!!
    :
    : z00mit
    :

    The real problem is that your member function is actually a thiscall function: it 'belongs' to a particular instance. As such, it can not be used in a more global way.
    I found a quite excellent site on this: [link=http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2]http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2[/link]

    What you do is you take the pointer of a member function, but that pointer is meaningless without specifying the instance to use.
    [code]
    class A
    {
    int val;
    ...
    int f() { return val; }
    };

    // You can take the address of f
    int (*pf)(void) = &A::f;

    // But if you want to call f, then you ofcourse need to say which
    // instance of A to use, because if there are 3 instances of A, each
    // with a different value for val, then it's not at all clear which
    // value f is supposed to return
    A a, b, c;
    a.val = 1;
    b.val = 2;
    c.val = 3;

    // What you can do now is specify which instance to 'use f on'
    // You do this which the .* operator
    cout << a.*pf() << endl;
    // or
    cout << b.*pf();

    //This would print first 1 and then 2
    [/code]

    The best thing I can think of is to create the instance of the class, and also define a specific exception handling function to use specifically with that instance: you set the SetUnhandledExceptionFilter to point to this non-member function, and this non-member function then calls the MiniDump instance associated with it.
    Having 2 MiniDump instances 'alive' at the same time has no use anyway.

    Good luck with your project.
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • thanks so much!
    really appreciated
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories