Exception 0xC0000008 in NTDLL.DLL

James_Clements
James_Clements used Ask the Experts™
on
I was trying following solution posted on site

http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_10117764.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?

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
jkr
Top Expert 2012

Commented:
>>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);
jkr
Top Expert 2012

Commented:
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);
jkr
Top Expert 2012

Commented:
BTW, that exception in question is

#define STATUS_INVALID_HANDLE            ((NTSTATUS)0xC0000008L)
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Author

Commented:
Now I am getting error below

 error C2373: 'TestWithSEH' : redefinition; different type modifiers
jkr
Top Expert 2012

Commented:
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);

Author

Commented:
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.
jkr
Top Expert 2012

Commented:
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

Author

Commented:
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.
jkr
Top Expert 2012

Commented:
>>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?

Author

Commented:
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.
Top Expert 2012
Commented:
>>At this point it's taking me to [break]-[Disassembly] screen.
>>After this I can not execute any line of code.

Which version of VC++ are you using? All you need to do is to set the debugger *not* to stop at first chance exceptions, but only unhandled exceptions. With VC6, go to 'Debug|Exceptions', type 'c0000008' in the 'Number' field, set 'Name' to 'Invalid Handle' and select 'Stop if not handled'. That must be done while running the debugee. In VC7.x, select 'Debug|Exceptions' (at any time) and locate 'Invalid Handle'. If it is not there, pick 'Add...' , enter the exception code and the name and under 'When the exception is thrown', set 'Continue', under 'When the exception is not handled', set 'Break into the Debugger'.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial