Access Violation when DLL's Load??

Posted on 2006-06-02
Last Modified: 2008-02-07
'Program.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', Symbols loaded.
'Program.exe': Loaded 'C:\WINDOWS\system32\MFC71.dll', Symbols loaded.
'Program.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'Program.exe': Loaded 'C:\WINDOWS\system32\MFC71ENU.DLL', No symbols loaded.
First-chance exception at 0x7c910370 (ntdll.dll) in Program.exe: 0xC0000005: Access violation reading location 0x02086000.

Does this mean that the access violation happened when MFC71ENU.DLL loaded??  I don't think it does because I took that dll away and it had the same error on shlwapi.dll??  The problem is this access violation occurs before any code of mine appears to be hit.  My program.exe loads many DLL's tho, so my question is what happens when a DLL loads?  What code gets executed if any?

I also don't want to hear anything about this being a first-chance execption so it's not important.  This needs to be fixed and I'm trying to get the general idea of whats wrong.
Question by:cophi
    LVL 48

    Assisted Solution

    When Dll is loaded, it's DllMain function is called. If Dll is yours, see what code runs in this function. I guess that MFC71ENU.DLL is not yours, so that there is nothing to do.
    First-chance exception message means: there was exception, but it successfully handled. I don't think that you can do something in this situation to fix this - except of using Run command instead of Go :)
    LVL 86

    Expert Comment

    >>Does this mean that the access violation happened when MFC71ENU.DLL loaded??

    Yes, as AlexFM described, the entry point is called. But, *stop* focusing on First Chance exceptions. They're normal, you will encounter a *lot* of them when debugging. That's part of the control flow of Windows.
    LVL 86

    Expert Comment

    Oh, as a side note to First Chance access violations - you might just see a call of 'IsBadReadPtr()' ( whic e.g. can be written like

    BOOL IsBadReadPtr(CONST VOID *lp, UINT ucb)
        BYTE b;

        _try {

            for (UINT un = 0; un < uncb; un++) b = *(BYTE*)(lp + un);

        __except(1) {

            return TRUE;

        return FALSE;

    which would cause such a First Chance exception, but not do any damage. As I already mentioned in an earlier Q of yours, ("First and second chance exception handling") describes that really good.
    LVL 86

    Assisted Solution

    Oh, if you absolutely want to find out what function that is, you might want to install the symbol files for your OS/SP, so you can see the exact function in ntdll.dll which is causing that problem.
    LVL 39

    Accepted Solution

    If you could run the prog in the VC debugger you should go the Debug Exceptions ... menu while running. Select "access violation" from listbox and check "Stop immediately" checkbox. Restart program. When it crashes it will show you the source where the access violation happened provided it's your code ...

    Regards, Alex

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now