Ignore:
Timestamp:
Jun 23, 2011, 3:06:59 PM (14 years ago)
Author:
dmik
Message:

kernel32: Show a message box if DLL initializaiton fails to make sure the user gets acceptable feedback in low memory conditions and in case of other unexpected runtime errors. See #23 for details.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/initkernel32.cpp

    r21650 r21651  
    100100/* calling this function.                                                   */
    101101/****************************************************************************/
    102 ULONG APIENTRY inittermKernel32(ULONG hModule, ULONG ulFlag)
     102static ULONG APIENTRY inittermKernel32_internal(ULONG hModule, ULONG ulFlag)
    103103{
    104104    size_t i;
     
    295295//******************************************************************************
    296296//******************************************************************************
     297ULONG APIENTRY inittermKernel32(ULONG hModule, ULONG ulFlag)
     298{
     299    ULONG rc = inittermKernel32_internal(hModule, ulFlag);
     300
     301    if (ulFlag == 0 && rc == 0)
     302    {
     303        static const char msg[] =
     304            "Failed to initialize the KERNEL32 library.\n\r"
     305            "\n\r"
     306            "It is possible that there is not enough memory in the system to "
     307            "run this application. Please close other applications and try "
     308            "again. If the problem persists, please report the details by "
     309            "creating a ticket at http://svn.netlabs.org/odin32/.\n\r";
     310
     311        // Initialization has failed. Try to be nice and show an error message
     312        // to the user.
     313        WinMessageBox(HWND_DESKTOP, NULL, msg, "Odin: Fatal Error", 0,
     314                      MB_APPLMODAL | MB_MOVEABLE | MB_ERROR | MB_OK);
     315
     316        // duplicate the message to the console just in case (PM may be not
     317        // available)
     318        ULONG dummy;
     319        DosWrite((HFILE)1, (PVOID)msg, sizeof(msg), &dummy);
     320    }
     321
     322    return rc;
     323}
     324//******************************************************************************
     325//******************************************************************************
    297326void APIENTRY cleanupKernel32(ULONG ulReason)
    298327{
Note: See TracChangeset for help on using the changeset viewer.