| 1 | /*
|
|---|
| 2 | * USER32 DLL entry point
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright 1998 Sander van Leeuwen
|
|---|
| 5 | * Copyright 1998 Peter Fitzsimmons
|
|---|
| 6 | *
|
|---|
| 7 | *
|
|---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 9 | *
|
|---|
| 10 | */
|
|---|
| 11 |
|
|---|
| 12 | /*-------------------------------------------------------------*/
|
|---|
| 13 | /* INITERM.C -- Source for a custom dynamic link library */
|
|---|
| 14 | /* initialization and termination (_DLL_InitTerm) */
|
|---|
| 15 | /* function. */
|
|---|
| 16 | /* */
|
|---|
| 17 | /* When called to perform initialization, this sample function */
|
|---|
| 18 | /* gets storage for an array of integers, and initializes its */
|
|---|
| 19 | /* elements with random integers. At termination time, it */
|
|---|
| 20 | /* frees the array. Substitute your own special processing. */
|
|---|
| 21 | /*-------------------------------------------------------------*/
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | /* Include files */
|
|---|
| 25 | #define INCL_DOSMODULEMGR
|
|---|
| 26 | #define INCL_DOSPROCESS
|
|---|
| 27 | #define INCL_DOSSEMAPHORES
|
|---|
| 28 | #define INCL_DOSMISC
|
|---|
| 29 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 30 | #include <stdlib.h>
|
|---|
| 31 | #include <stdio.h>
|
|---|
| 32 | #include <string.h>
|
|---|
| 33 | #include <odin.h>
|
|---|
| 34 | #include <misc.h> /*PLF Wed 98-03-18 23:18:29*/
|
|---|
| 35 | #include <win32type.h>
|
|---|
| 36 | #include <win32api.h>
|
|---|
| 37 | #include <winconst.h>
|
|---|
| 38 | #include <odinlx.h>
|
|---|
| 39 | #include <spy.h>
|
|---|
| 40 | #include <monitor.h>
|
|---|
| 41 | #include "pmwindow.h"
|
|---|
| 42 | #include "win32wdesktop.h"
|
|---|
| 43 | #include "syscolor.h"
|
|---|
| 44 | #include "initterm.h"
|
|---|
| 45 | #include <exitlist.h>
|
|---|
| 46 | #include <initdll.h>
|
|---|
| 47 |
|
|---|
| 48 | #define DBG_LOCALLOG DBG_initterm
|
|---|
| 49 | #include "dbglocal.h"
|
|---|
| 50 |
|
|---|
| 51 | /*-------------------------------------------------------------------*/
|
|---|
| 52 | /* A clean up routine registered with DosExitList must be used if */
|
|---|
| 53 | /* runtime calls are required and the runtime is dynamically linked. */
|
|---|
| 54 | /* This will guarantee that this clean up routine is run before the */
|
|---|
| 55 | /* library DLL is terminated. */
|
|---|
| 56 | /*-------------------------------------------------------------------*/
|
|---|
| 57 | static void APIENTRY cleanup(ULONG reason);
|
|---|
| 58 |
|
|---|
| 59 | extern "C" {
|
|---|
| 60 | //Win32 resource table (produced by wrc)
|
|---|
| 61 | extern DWORD _Resource_PEResTab;
|
|---|
| 62 | }
|
|---|
| 63 | DWORD hInstanceUser32 = 0;
|
|---|
| 64 | BOOL fVersionWarp3 = FALSE;
|
|---|
| 65 |
|
|---|
| 66 | /****************************************************************************/
|
|---|
| 67 | /* _DLL_InitTerm is the function that gets called by the operating system */
|
|---|
| 68 | /* loader when it loads and frees this DLL for each process that accesses */
|
|---|
| 69 | /* this DLL. However, it only gets called the first time the DLL is loaded */
|
|---|
| 70 | /* and the last time it is freed for a particular process. The system */
|
|---|
| 71 | /* linkage convention MUST be used because the operating system loader is */
|
|---|
| 72 | /* calling this function. */
|
|---|
| 73 | /****************************************************************************/
|
|---|
| 74 | ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG ulFlag)
|
|---|
| 75 | {
|
|---|
| 76 | size_t i;
|
|---|
| 77 | APIRET rc;
|
|---|
| 78 | ULONG version[2];
|
|---|
| 79 |
|
|---|
| 80 | /*-------------------------------------------------------------------------*/
|
|---|
| 81 | /* If ulFlag is zero then the DLL is being loaded so initialization should */
|
|---|
| 82 | /* be performed. If ulFlag is 1 then the DLL is being freed so */
|
|---|
| 83 | /* termination should be performed. */
|
|---|
| 84 | /*-------------------------------------------------------------------------*/
|
|---|
| 85 |
|
|---|
| 86 | switch (ulFlag) {
|
|---|
| 87 | case 0 :
|
|---|
| 88 | ctordtorInit();
|
|---|
| 89 | ParseLogStatus();
|
|---|
| 90 |
|
|---|
| 91 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
|---|
| 92 |
|
|---|
| 93 | hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab,
|
|---|
| 94 | USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
|
|---|
| 95 | IMAGE_SUBSYSTEM_WINDOWS_GUI);
|
|---|
| 96 | if(hInstanceUser32 == 0)
|
|---|
| 97 | return 0UL;
|
|---|
| 98 |
|
|---|
| 99 | dprintf(("user32 init %s %s (%x)", __DATE__, __TIME__, DLLENTRYPOINT_NAME));
|
|---|
| 100 |
|
|---|
| 101 | rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, version, sizeof(version));
|
|---|
| 102 | if(rc == 0){
|
|---|
| 103 | if(version[0] >= 20 && version[1] <= 30) {
|
|---|
| 104 | fVersionWarp3 = TRUE;
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | /*******************************************************************/
|
|---|
| 109 | /* A DosExitList routine must be used to clean up if runtime calls */
|
|---|
| 110 | /* are required and the runtime is dynamically linked. */
|
|---|
| 111 | /*******************************************************************/
|
|---|
| 112 |
|
|---|
| 113 | rc = DosExitList(EXITLIST_USER32|EXLST_ADD, cleanup);
|
|---|
| 114 | if(rc)
|
|---|
| 115 | return 0UL;
|
|---|
| 116 |
|
|---|
| 117 | //SvL: Try to start communication with our message spy queue server
|
|---|
| 118 | InitSpyQueue();
|
|---|
| 119 |
|
|---|
| 120 | //SvL: Init win32 PM classes
|
|---|
| 121 | if(InitPM() == FALSE) {
|
|---|
| 122 | return 0UL;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
|
|---|
| 126 | //CB: register internal classes
|
|---|
| 127 | RegisterSystemClasses(hModule);
|
|---|
| 128 |
|
|---|
| 129 | //CB: initialize PM monitor driver
|
|---|
| 130 | MONITOR_Initialize(&MONITOR_PrimaryMonitor);
|
|---|
| 131 |
|
|---|
| 132 | break;
|
|---|
| 133 | case 1 :
|
|---|
| 134 | if(hInstanceUser32) {
|
|---|
| 135 | UnregisterLxDll(hInstanceUser32);
|
|---|
| 136 | }
|
|---|
| 137 | break;
|
|---|
| 138 | default :
|
|---|
| 139 | return 0UL;
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | /***********************************************************/
|
|---|
| 143 | /* A non-zero value must be returned to indicate success. */
|
|---|
| 144 | /***********************************************************/
|
|---|
| 145 | return 1UL;
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | static void APIENTRY cleanup(ULONG ulReason)
|
|---|
| 149 | {
|
|---|
| 150 | dprintf(("user32 exit\n"));
|
|---|
| 151 | //SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
|
|---|
| 152 | //// RestoreCursor();
|
|---|
| 153 | DestroyDesktopWindow();
|
|---|
| 154 | Win32BaseWindow::DestroyAll();
|
|---|
| 155 | UnregisterSystemClasses();
|
|---|
| 156 | Win32WndClass::DestroyAll();
|
|---|
| 157 | MONITOR_Finalize(&MONITOR_PrimaryMonitor);
|
|---|
| 158 | SYSCOLOR_Save();
|
|---|
| 159 | CloseSpyQueue();
|
|---|
| 160 | ctordtorTerm();
|
|---|
| 161 | dprintf(("user32 exit done\n"));
|
|---|
| 162 |
|
|---|
| 163 | DosExitList(EXLST_EXIT, cleanup);
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|