Changeset 21654 for trunk/src


Ignore:
Timestamp:
Jun 27, 2011, 2:27:23 AM (14 years ago)
Author:
dmik
Message:

kernel32: Show an error message box if WGSS50.DLL initialization fails too. See also r21651.

Location:
trunk/src/kernel32
Files:
2 edited

Legend:

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

    r21653 r21654  
    300300
    301301    if (ulFlag == 0 && rc == 0)
    302     {
    303         static const char msg1[] =
    304             "Failed to initialize the KERNEL32 library while starting \"";
    305 
    306         static const char msg2[] =
    307             "\".\n\r"
    308             "\n\r"
    309             "It is possible that there is not enough memory in the system to "
    310             "run this application. Please close other applications and try "
    311             "again. If the problem persists, please report the details by "
    312             "creating a ticket at http://svn.netlabs.org/odin32/.\n\r";
    313 
    314         char msg[sizeof(msg1) + CCHMAXPATH + sizeof(msg2)];
    315 
    316         strcpy(msg, msg1);
    317 
    318         PPIB ppib;
    319         DosGetInfoBlocks(NULL, &ppib);
    320         if (DosQueryModuleName(ppib->pib_hmte, CCHMAXPATH,
    321                                msg + sizeof(msg1) - 1) != NO_ERROR)
    322             strcat(msg, "<unknown executable>");
    323         strcat(msg, msg2);
    324 
    325         // Initialization has failed. Try to be nice and show an error message
    326         // to the user.
    327         WinMessageBox(HWND_DESKTOP, NULL, msg, "Odin: Fatal Error", 0,
    328                       MB_APPLMODAL | MB_MOVEABLE | MB_ERROR | MB_OK);
    329 
    330         // duplicate the message to the console just in case (PM may be not
    331         // available)
    332         ULONG dummy;
    333         DosWrite((HFILE)1, (PVOID)&msg, strlen(msg), &dummy);
    334     }
     302        ReportFatalDllInitError("KERNEL32");
    335303
    336304    return rc;
  • trunk/src/kernel32/initterm.cpp

    r21649 r21654  
    157157        loadNr = globLoadNr++;
    158158
     159    BOOL WGSS_OK = FALSE;
     160
    159161    if (DosQueryModuleHandleStrict("WGSS50", &hModule) == NO_ERROR)
     162    {
    160163        if (_O32__DLL_InitTerm(hModule, 0) != 0)
     164        {
     165            WGSS_OK = TRUE;
     166
    161167            if (DosQueryModuleHandleStrict("KERNEL32", &hModule) == NO_ERROR)
    162168                return DLLENTRYPOINT_NAME(hModule, 0);
     169            else
     170                ReportFatalDllInitError("KERNEL32");
     171        }
     172    }
     173
     174    if (!WGSS_OK)
     175        ReportFatalDllInitError("WGSS50");
    163176
    164177    return 0; // failure
     
    166179//******************************************************************************
    167180//******************************************************************************
     181VOID APIENTRY ReportFatalDllInitError(CHAR *pszModName)
     182{
     183    static const char msg1[] =
     184        "Failed to initialize the ";
     185    static const char msg2[] =
     186        " library while starting \"";
     187    static const char msg3[] =
     188        "\".\n\r"
     189        "\n\r"
     190        "It is possible that there is not enough memory in the system to "
     191        "run this application. Please close other applications and try "
     192        "again. If the problem persists, please report the details by "
     193        "creating a ticket at http://svn.netlabs.org/odin32/.\n\r";
     194
     195    char msg[sizeof(msg1) + 8 + sizeof(msg2) + CCHMAXPATH + sizeof(msg3)];
     196
     197    strcpy(msg, msg1);
     198    strncat(msg, pszModName, 8);
     199    strcat(msg, msg2);
     200
     201    PPIB ppib;
     202    DosGetInfoBlocks(NULL, &ppib);
     203    if (DosQueryModuleName(ppib->pib_hmte, CCHMAXPATH,
     204                           msg + strlen(msg)) != NO_ERROR)
     205        strcat(msg, "<unknown executable>");
     206    strcat(msg, msg3);
     207
     208    BOOL haveHMQ = FALSE;
     209    MQINFO mqinfo;
     210    if (WinQueryQueueInfo(1 /*HMQ_CURRENT*/, &mqinfo, sizeof(mqinfo)) == FALSE)
     211    {
     212        // attempt to initialize PM and try again
     213        HAB hab = WinInitialize(0);
     214        if (hab)
     215        {
     216            HMQ hmq = WinCreateMsgQueue(hab, 0);
     217            if (hmq)
     218                haveHMQ = TRUE;
     219        }
     220    }
     221    else
     222        haveHMQ = TRUE;
     223
     224    WinMessageBox(HWND_DESKTOP, NULL, msg, "Odin: Fatal Error", 0,
     225                  MB_APPLMODAL | MB_MOVEABLE | MB_ERROR | MB_OK);
     226
     227    // duplicate the message to the console just in case (PM may be not
     228    // available)
     229    ULONG dummy;
     230    DosWrite((HFILE)1, (PVOID)&msg, strlen(msg), &dummy);
     231}
     232
     233//******************************************************************************
     234//******************************************************************************
     235
Note: See TracChangeset for help on using the changeset viewer.