Ignore:
Timestamp:
Jul 20, 2001, 5:42:38 PM (24 years ago)
Author:
sandervl
Message:

initterm update

File:
1 edited

Legend:

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

    r6340 r6375  
    5858#include "dbglocal.h"
    5959
    60 PVOID   SYSTEM _O32_GetEnvironmentStrings( VOID );
    6160BOOL  fVersionWarp3 = FALSE;
    6261
     
    6867/*-------------------------------------------------------------------*/
    6968static void APIENTRY cleanup(ULONG reason);
    70 
    71 extern "C" {
    72  //Win32 resource table (produced by wrc)
    73  extern DWORD _Resource_PEResTab;
    74 }
    75 
    76 //Global DLL Data
    77 #pragma data_seg(_GLOBALDATA)
    78 int globLoadNr = 0;
    79 #pragma data_seg()
    80 
    81 /* Tue 03.03.1998: knut */
    82 ULONG flAllocMem = 0;    /* flag to optimize DosAllocMem to use all the memory on SMP machines */
    83 ULONG ulMaxAddr = 0x20000000; /* end of user address space. */
    84 int   loadNr = 0;
    85 char  kernel32Path[CCHMAXPATH] = "";
    86 static HMODULE dllHandle = 0;
    8769
    8870/****************************************************************************/
     
    11092        case 0 :
    11193        {
    112             ParseLogStatus();
    113 
    114             /*
    115              * Init the win32k library.
    116              * We will also need to tell win32k where the Odin32 environment is
    117              * located. Currently that is within Open32. I'm quite sure that it's
    118              * not relocated during run, so we're pretty well off.
    119              */
    120             if (!libWin32kInit())
    121             {
    122                 rc = libWin32kSetEnvironment((PSZ)_O32_GetEnvironmentStrings(), 0, 0);
    123                 if (rc)
    124                 {
    125                     dprintf(("KERNEL32: initterm: libWin32kSetEnvironment failed with rc=%d\n", rc));
    126                 }
    127             }
    128 
    129             loadNr = globLoadNr++;
    130 
    131             strcpy(kernel32Path, OSLibGetDllName(hModule));
    132             char *endofpath = strrchr(kernel32Path, '\\');
    133             *(endofpath+1) = 0;
    134             dprintf(("kernel32 init %s %s (%x) Win32k - %s", __DATE__, __TIME__, DLLENTRYPOINT_NAME,
    135                      libWin32kInstalled() ? "Installed" : "Not Installed"));
    13694            ctordtorInit();
    13795
    13896            CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    139 
    140             OpenPrivateLogFiles();
    141 
    142             if (InitializeSharedHeap() == FALSE)
    143                 return 0UL;
    144 
    145             if (InitializeCodeHeap() == FALSE)
    146                 return 0UL;
    147 
    148             PROFILE_LoadOdinIni();
    149             dllHandle = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab);
    150             if (dllHandle == 0)
    151                 return 0UL;
    152 
    153             //SvL: Kernel32 is a special case; pe.exe loads it, so increase
    154             //     the reference count here
    155             Win32DllBase *module = Win32DllBase::findModule(dllHandle);
    156             if (module)
    157             {
    158                 module->AddRef();
    159                 module->DisableUnload();
    160             }
    16197
    16298            /*******************************************************************/
     
    169105                return 0UL;
    170106
    171             /* knut: check for high memory support */
    172             rc = DosQuerySysInfo(QSV_VIRTUALADDRESSLIMIT, QSV_VIRTUALADDRESSLIMIT, &ulSysinfo, sizeof(ulSysinfo));
    173             if (rc == 0 && ulSysinfo > 512)   //VirtualAddresslimit is in MB
    174             {
    175                 flAllocMem = PAG_ANY;      // high memory support. Let's use it!
    176                 ulMaxAddr = ulSysinfo * (1024*1024);
    177                 OSLibInitWSeBFileIO();
    178             if (PROFILE_GetOdinIniInt(ODINSYSTEM_SECTION, HIGHMEM_KEY, 1) == 0) {
    179                     dprintf(("WARNING: OS/2 kernel supports high memory, but support is DISABLED because of HIGHMEM odin.ini key"));
    180                     flAllocMem = 0;
    181                 }
    182             }
    183             else
    184                 flAllocMem = 0;        // no high memory support
    185 
    186             OSLibDosSetInitialMaxFileHandles(ODIN_DEFAULT_MAX_FILEHANDLES);
    187 
    188             //SvL: Do it here instead of during the exe object creation
    189             //(std handles can be used in win32 dll initialization routines
    190             HMInitialize();             /* store standard handles within HandleManager */
    191             InitDirectories();      //Must be done before InitializeTIB (which loads NTDLL -> USER32)
    192             InitializeTIB(TRUE);        //Must be done after HMInitialize!
    193             RegisterDevices();
    194             Win32DllBase::setDefaultRenaming();
    195             rc = DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &ulSysinfo, sizeof(ulSysinfo));
    196             if (rc != 0)
    197                 ulSysinfo = 1;
    198 
    199107            rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, version, sizeof(version));
    200108            if(rc == 0){
     
    203111                }
    204112            }
    205 
    206             /* Setup codepage info */
    207             CODEPAGE_Init();
    208 
    209             InitSystemInfo(ulSysinfo);
    210             //Set up environment as found in NT
    211             InitEnvironment(ulSysinfo);
    212 
    213             //InitDynamicRegistry creates/changes keys that may change (i.e. odin.ini
    214             //keys that affect windows version)
    215             InitDynamicRegistry();
     113           
     114            rc = inittermKernel32(hModule, ulFlag);
    216115            break;
    217116        }
    218117
    219118        case 1 :
    220             if (dllHandle)
    221             {
    222                 UnregisterLxDll(dllHandle);
    223             }
     119            rc = inittermKernel32(hModule, ulFlag);
    224120            break;
    225121
     
    237133static void APIENTRY cleanup(ULONG ulReason)
    238134{
    239     dprintf(("kernel32 exit %d\n", ulReason));
    240     //Flush and delete all open memory mapped files
    241     Win32MemMap::deleteAll();
    242     WinExe = NULL;
     135    cleanupKernel32(ulReason);
    243136
    244     WriteOutProfiles();
    245     DestroyTIB();
    246     DestroySharedHeap();
    247     DestroyCodeHeap();
    248137    ctordtorTerm();
    249 
    250     //NOTE: Must be done after DestroyTIB
    251     ClosePrivateLogFiles();
    252     CloseLogFile();
    253 
    254     /*
    255      * Terminate win32k library.
    256      */
    257     libWin32kSetEnvironment(NULL, 0, 0);
    258     libWin32kTerm();
    259138
    260139    DosExitList(EXLST_EXIT, cleanup);
Note: See TracChangeset for help on using the changeset viewer.