Ignore:
Timestamp:
Jun 23, 2011, 2:02:58 PM (14 years ago)
Author:
dmik
Message:

general: Exit gracefully instead of crashing if KERNEL32.DLL initialization fails. Note that "gracefully" means "silently" in this case since it seems that the only way how the OS/2 loader reports a failure to initialize a required DLL for a started EXE is by returning a non-zero exit code.

File:
1 edited

Legend:

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

    r21626 r21649  
    112112    /*-------------------------------------------------------------------------*/
    113113
    114     if(fInit == TRUE && ulFlag == 0) {
    115         return 1; //already initialized
    116     }
    117     fInit = TRUE;
    118 
    119114    switch (ulFlag)
    120115    {
    121         case 0 :
     116        case 0:
    122117        {
     118            if (fInit)
     119                return 1; // already initialized
     120
    123121            // This always must be the first thing to do.
    124122            RasInitialize (hModule);
     
    257255            RasEntry (RAS_EVENT_Kernel32InitComplete, &dllHandle, sizeof (dllHandle));
    258256
     257            fInit = TRUE;
     258
    259259            break;
    260260        }
    261261
    262         case 1 :
     262        case 1:
    263263            if (dllHandle)
    264264            {
     
    267267            break;
    268268
    269         default  :
    270             return 0UL;
     269        default:
     270            return 0;
    271271    }
    272272
     
    280280void APIENTRY cleanupKernel32(ULONG ulReason)
    281281{
    282     dprintf(("kernel32 exit %d\n", ulReason));
     282    if (!fInit)
     283    {
     284        // The initialization sequence was not complete; attempting to
     285        // uninitialize some things may crash (yeah, dirty code that doesn't
     286        // analyze its own state)
     287        return;
     288    }
     289
     290    dprintf(("kernel32 exit %d", ulReason));
    283291
    284292    TEB *teb = GetThreadTEB();
Note: See TracChangeset for help on using the changeset viewer.