Ignore:
Timestamp:
Nov 11, 2011, 9:14:11 PM (14 years ago)
Author:
dmik
Message:

Start porting USER32 to GCC.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/gcc-kmk/src/user32/initterm.cpp

    r21796 r21802  
    1 /* $Id: inituser32.cpp,v 1.19 2004-05-03 12:09:01 sandervl Exp $ */
    2 /*
     1/* $Id: initterm.cpp,v 1.34 2003-01-21 11:22:08 sandervl Exp $
     2 *
    33 * USER32 DLL entry point
    44 *
     
    66 * Copyright 1998 Peter Fitzsimmons
    77 *
    8  *
    98 * Project Odin Software License can be found in LICENSE.TXT
    10  *
    119 */
    1210
    13 /*-------------------------------------------------------------*/
    14 /* INITERM.C -- Source for a custom dynamic link library       */
    15 /*              initialization and termination (_DLL_InitTerm) */
    16 /*              function.                                      */
    17 /*                                                             */
    18 /* When called to perform initialization, this sample function */
    19 /* gets storage for an array of integers, and initializes its  */
    20 /* elements with random integers.  At termination time, it     */
    21 /* frees the array.  Substitute your own special processing.   */
    22 /*-------------------------------------------------------------*/
    23 
    24 
    25 /* Include files */
    2611#define  INCL_DOSMODULEMGR
    2712#define  INCL_DOSPROCESS
     
    3015#define  INCL_DOSERRORS
    3116#define  INCL_WINSHELLDATA
    32 #define  INCL_GPI
    3317#define  INCL_WINERRORS
    3418#include <os2wrap.h>    //Odin32 OS/2 api wrappers
     
    4428#include <spy.h>
    4529#include <monitor.h>
    46 #include <kbdhook.h>
     30#include <exitlist.h>
     31#include <initdll.h>
     32#include <stats.h>
     33
    4734#include "pmwindow.h"
    4835#include "win32wdesktop.h"
     
    5138#include "initterm.h"
    5239#include "auxthread.h"
    53 #include <exitlist.h>
    54 #include <initdll.h>
    55 #include <stats.h>
    5640
    5741#define DBG_LOCALLOG    DBG_initterm
    5842#include "dbglocal.h"
    5943
    60 /*-------------------------------------------------------------------*/
    61 /* A clean up routine registered with DosExitList must be used if    */
    62 /* runtime calls are required and the runtime is dynamically linked. */
    63 /* This will guarantee that this clean up routine is run before the  */
    64 /* library DLL is terminated.                                        */
    65 /*-------------------------------------------------------------------*/
    66 static void APIENTRY cleanup(ULONG reason);
    67 
    68 extern "C" {
    69  //Win32 resource table (produced by wrc)
    70  extern DWORD user32_PEResTab;
    71 }
     44extern INT __cdecl wsnprintfA(LPSTR,UINT,LPCSTR,...);
     45
     46// Win32 resource table (produced by wrc)
     47extern DWORD user32_PEResTab;
     48
    7249DWORD hInstanceUser32 = 0;
    7350
    74 extern INT __cdecl wsnprintfA(LPSTR,UINT,LPCSTR,...);
    75 
    76 //******************************************************************************
     51BOOL  fVersionWarp3 = FALSE;
     52
    7753#define FONTSDIRECTORY "Fonts"
    7854#define REGPATH "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"
    79 //******************************************************************************
     55
    8056static void MigrateWindowsFonts()
    8157{
     
    148124}
    149125
    150 /****************************************************************************/
    151 /* _DLL_InitTerm is the function that gets called by the operating system   */
    152 /* loader when it loads and frees this DLL for each process that accesses   */
    153 /* this DLL.  However, it only gets called the first time the DLL is loaded */
    154 /* and the last time it is freed for a particular process.  The system      */
    155 /* linkage convention MUST be used because the operating system loader is   */
    156 /* calling this function.                                                   */
    157 /****************************************************************************/
    158 ULONG APIENTRY inittermUser32(ULONG hModule, ULONG ulFlag)
    159 {
    160    size_t i;
    161    APIRET rc;
    162    ULONG  version[2];
    163 
    164    /*-------------------------------------------------------------------------*/
    165    /* If ulFlag is zero then the DLL is being loaded so initialization should */
    166    /* be performed.  If ulFlag is 1 then the DLL is being freed so            */
    167    /* termination should be performed.                                        */
    168    /*-------------------------------------------------------------------------*/
    169 
    170    switch (ulFlag) {
    171       case 0 :
    172          STATS_InitializeUSER32 ();
    173 
    174          ParseLogStatusUSER32();
    175 
    176          if (!InitializeKernel32())
    177              return 0;
    178 
    179          CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    180 
    181          hInstanceUser32 = RegisterLxDll(hModule, DllMain, (PVOID)&user32_PEResTab,
    182                                          USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
    183                                          IMAGE_SUBSYSTEM_WINDOWS_GUI);
    184          if(hInstanceUser32 == 0)
    185                 return 0UL;
    186 
    187          dprintf(("user32 init %s %s (%x)", __DATE__, __TIME__, inittermUser32));
    188 
    189          //SvL: Try to start communication with our message spy queue server
    190          InitSpyQueue();
    191 
    192          //SvL: Init win32 PM classes
    193          //PH:  initializes HAB!
    194          if (FALSE == InitPM())
     126ULONG SYSTEM DLL_InitUser32(ULONG hModule)
     127{
     128    APIRET rc;
     129
     130    ULONG version[2];
     131    rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, version, sizeof(version));
     132    if (rc == 0)
     133    {
     134         if (version[0] >= 20 && version[1] <= 30)
     135             fVersionWarp3 = TRUE;
     136    }
     137
     138    STATS_InitializeUSER32();
     139
     140    ParseLogStatusUSER32();
     141
     142    if (!InitializeKernel32())
     143        return 0;
     144
     145    CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
     146
     147    hInstanceUser32 = RegisterLxDll(hModule, DllMain, (PVOID)&user32_PEResTab,
     148                                    USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
     149                                    IMAGE_SUBSYSTEM_WINDOWS_GUI);
     150    if(hInstanceUser32 == 0)
    195151           return 0UL;
    196152
    197          InitializeWindowHandles();
    198 
    199          //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
    200          //CB: register internal classes
    201          RegisterSystemClasses(hModule);
    202 
    203          //CB: initialize PM monitor driver
    204          MONITOR_Initialize(&MONITOR_PrimaryMonitor);
    205 
    206          //PF: migrate windows fonts
    207          MigrateWindowsFonts();
    208 
    209          InitClipboardFormats();
    210 
    211          RasEntry (RAS_EVENT_User32InitComplete, &hInstanceUser32, sizeof (hInstanceUser32));
    212 
    213          break;
    214 
    215 
    216        case 1 :
    217          if(hInstanceUser32) {
    218             UnregisterLxDll(hInstanceUser32);
    219          }
    220          STATS_UninitializeUSER32 ();
    221          break;
    222       default  :
    223          return 0UL;
    224    }
    225 
    226    /***********************************************************/
    227    /* A non-zero value must be returned to indicate success.  */
    228    /***********************************************************/
    229    return 1UL;
    230 }
    231 //******************************************************************************
    232 //******************************************************************************
    233 void APIENTRY cleanupUser32(ULONG ulReason)
    234 {
    235   dprintf(("user32 exit\n"));
    236 
    237 //SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
    238 ////   RestoreCursor();
    239 
    240    //Destroy CD notification window
    241    WinDestroyWindow(hwndCD);
    242    DestroyDesktopWindow();
    243    Win32BaseWindow::DestroyAll();
    244    UnregisterSystemClasses();
    245    Win32WndClass::DestroyAll();
    246    MONITOR_Finalize(&MONITOR_PrimaryMonitor);
    247    SYSCOLOR_Save();
    248    CloseSpyQueue();
    249    FinalizeWindowHandles();
    250    STATS_DumpStatsUSER32();
    251    dprintf(("user32 exit done\n"));
    252 }
    253 //******************************************************************************
    254 //******************************************************************************
     153    dprintf(("user32 init %s %s (%x)", __DATE__, __TIME__, inittermUser32));
     154
     155    //SvL: Try to start communication with our message spy queue server
     156    InitSpyQueue();
     157
     158    //SvL: Init win32 PM classes
     159    //PH:  initializes HAB!
     160    if (FALSE == InitPM())
     161      return 0UL;
     162
     163    InitializeWindowHandles();
     164
     165    //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
     166    //CB: register internal classes
     167    RegisterSystemClasses(hModule);
     168
     169    //CB: initialize PM monitor driver
     170    MONITOR_Initialize(&MONITOR_PrimaryMonitor);
     171
     172    //PF: migrate windows fonts
     173    MigrateWindowsFonts();
     174
     175    InitClipboardFormats();
     176
     177    RasEntry (RAS_EVENT_User32InitComplete, &hInstanceUser32, sizeof (hInstanceUser32));
     178
     179    return EXITLIST_USER32;
     180}
     181
     182void SYSTEM DLL_TermUser32(ULONG hModule)
     183{
     184    dprintf(("user32 exit\n"));
     185
     186 //SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
     187 ////   RestoreCursor();
     188
     189    //Destroy CD notification window
     190    WinDestroyWindow(hwndCD);
     191    DestroyDesktopWindow();
     192    Win32BaseWindow::DestroyAll();
     193    UnregisterSystemClasses();
     194    Win32WndClass::DestroyAll();
     195    MONITOR_Finalize(&MONITOR_PrimaryMonitor);
     196    SYSCOLOR_Save();
     197    CloseSpyQueue();
     198    FinalizeWindowHandles();
     199    STATS_DumpStatsUSER32();
     200    dprintf(("user32 exit done\n"));
     201
     202    if (hInstanceUser32) {
     203        UnregisterLxDll(hInstanceUser32);
     204    }
     205    STATS_UninitializeUSER32();
     206}
     207
     208ULONG SYSTEM DLL_Init(ULONG hModule)
     209{
     210    if (DLL_InitDefault(hModule) == -1)
     211        return -1;
     212    return DLL_InitUser32(hModule);
     213}
     214
     215void SYSTEM DLL_Term(ULONG hModule)
     216{
     217    DLL_TermUser32(hModule);
     218    DLL_TermDefault(hModule);
     219}
Note: See TracChangeset for help on using the changeset viewer.