Link to home
Start Free TrialLog in
Avatar of James_Clements
James_Clements

asked on

Exception 0xC0000008 in NTDLL.DLL

I was trying following solution posted on site

https://www.experts-exchange.com/questions/10117764/Exception-0xC0000008-in-NTDLL-DLL.html?query=first+handle+0xc0000008&clearTAFilter=true#1182280

//Code is
      __try
      {
      // TODO: Add your control notification handler code here
      short ret;
      _clsACD WinDLL;
      EnableWindow(FALSE);
      WinDLL.CreateDispatch("WinDLL.clsACD");
      ret = WinDLL.GetCassStatus();
      }
      __except(EXCEPTION_CONTINUE_EXECUTION){
            puts ( "We knew that this would go wrong...");
      }
               EnableWindow(TRUE);


but am getting following errors.


C:\Projects\WinDemo\VC6WinDemoVB6\WinDemoDlg.cpp(269) : error C2712: Cannot use __try in functions that require object unwinding

What do U suggest should I do?

Avatar of jkr
jkr
Flag of Germany image

>>What do U suggest should I do?

Don't use objct instnces here, use pointers, e.g.

short TestWithSEH(_clsACD* pWinDLL)
{
     short ret;

     __try
     {
     // TODO: Add your control notification handler code here


     EnableWindow(FALSE);
     pWinDLL->CreateDispatch("WinDLL.clsACD");
     ret = pWinDLL->GetCassStatus();
     }
     __except(EXCEPTION_CONTINUE_EXECUTION){
          puts ( "We knew that this would go wrong...");
     }

    return ret;
}

And call it like

    _clsACD WinDLL;
    TestWithSEH(&WinDLL);
Sorry, make that

short TestWithSEH(_clsACD* pWinDLL)
{
     short ret;

     __try
     {
     // TODO: Add your control notification handler code here


     pWinDLL->CreateDispatch("WinDLL.clsACD");
     ret = pWinDLL->GetCassStatus();
     }
     __except(EXCEPTION_CONTINUE_EXECUTION){
          puts ( "We knew that this would go wrong...");
     }

    return ret;
}

and

    EnableWindow(FALSE);
    _clsACD WinDLL;
    short ret = TestWithSEH(&WinDLL);
    EnableWindow(TRUE);
BTW, that exception in question is

#define STATUS_INVALID_HANDLE            ((NTSTATUS)0xC0000008L)
Avatar of James_Clements
James_Clements

ASKER

Now I am getting error below

 error C2373: 'TestWithSEH' : redefinition; different type modifiers
What is your exact code? If should be something like

// foward declaration
short TestWithSEH(_clsACD* pWinDLL);

//... some other code

short TestWithSEH(_clsACD* pWinDLL)
{
     short ret;

     __try
     {
     // TODO: Add your control notification handler code here


     pWinDLL->CreateDispatch("WinDLL.clsACD");
     ret = pWinDLL->GetCassStatus();
     }
     __except(EXCEPTION_CONTINUE_EXECUTION){
          puts ( "We knew that this would go wrong...");
     }

    return ret;
}

//... some more code

    EnableWindow(FALSE);
    _clsACD WinDLL;
    short ret = TestWithSEH(&WinDLL);
    EnableWindow(TRUE);
ok my bad, Now it's working

but I am back to original problem that I can't Step through any further,
Write after executing this code
    ret = pWinDLL->GetCassStatus();

Error I get is

First-chance exception in WinDemo.exe (NTDLL.Dll): 0xC0000008: Invalid Handle.
You can ignore first-chance exceptions. See http://support.microsoft.com/support/kb/articles/q105/6/75.asp

A first chance exception is called so as it is passed to a debugger before the application 'sees' it. This is done by sending a 'EXCEPTION_DEBUG_EVENT' to the debugger, which can now decide whether it is passed to the apllication to handle it or 'ignore' it (e.g. like an 'EXCEPTION_BREAKPOINT' aka 'int 3'). If the exception isn't handled, it becomes a '2nd chance' exception, the debugger 'sees' it the 2nd time and will usually terminate the program (without using a debugger, these exceptions end up at 'UnhandledExceptionFilter()' which will also signal the exception to the user with one of these 'nice' message boxes and terminate the program, also...)
>>>> but I am back to original problem that I can't Step through any further

If you have the source code and a debug version of the dll, you might add the dll in Project-Settings-Debug Tab-Category Additional Dlls. Then, you should be able to step into the function GetCassStatus.

As jkr explained, the 'First Chance Exception' doesn't prevent your prog to go on. If it hangs at that call, you need to check the dll code if available or check the docs.

Regards, Alex
I don't have code for Dll that has function(GetCassStatus). and I am trying to debug in Visual C++ 6.0.
It's only creates exception when I am in debug mode and doesn't let me step forward.
so do you have any other suggestions.
>>It's only creates exception when I am in debug mode and doesn't let me step forward.

That's what I wrote - what you are seeing is an exception that has already been handled successfully, no need to worry about that. Where exactly in the code do you get stuck?
when call is made to function and after it's finished that's when I get error for First-Chance.
At this point it's taking me to [break]-[Disassembly] screen.
After this I can not execute any line of code.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial