| 1 | /* $Id: inituser32.cpp,v 1.5 2001-09-05 13:53:50 bird Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * USER32 DLL entry point
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998 Sander van Leeuwen
|
|---|
| 6 | * Copyright 1998 Peter Fitzsimmons
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 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 */
|
|---|
| 26 | #define INCL_DOSMODULEMGR
|
|---|
| 27 | #define INCL_DOSPROCESS
|
|---|
| 28 | #define INCL_DOSSEMAPHORES
|
|---|
| 29 | #define INCL_DOSMISC
|
|---|
| 30 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 31 | #include <stdlib.h>
|
|---|
| 32 | #include <stdio.h>
|
|---|
| 33 | #include <string.h>
|
|---|
| 34 | #include <odin.h>
|
|---|
| 35 | #include <misc.h> /*PLF Wed 98-03-18 23:18:29*/
|
|---|
| 36 | #include <win32type.h>
|
|---|
| 37 | #include <win32api.h>
|
|---|
| 38 | #include <winconst.h>
|
|---|
| 39 | #include <odinlx.h>
|
|---|
| 40 | #include <spy.h>
|
|---|
| 41 | #include <monitor.h>
|
|---|
| 42 | #include "pmwindow.h"
|
|---|
| 43 | #include "win32wdesktop.h"
|
|---|
| 44 | #include "syscolor.h"
|
|---|
| 45 | #include "initterm.h"
|
|---|
| 46 | #include <exitlist.h>
|
|---|
| 47 | #include <initdll.h>
|
|---|
| 48 |
|
|---|
| 49 | #define DBG_LOCALLOG DBG_initterm
|
|---|
| 50 | #include "dbglocal.h"
|
|---|
| 51 |
|
|---|
| 52 | /*-------------------------------------------------------------------*/
|
|---|
| 53 | /* A clean up routine registered with DosExitList must be used if */
|
|---|
| 54 | /* runtime calls are required and the runtime is dynamically linked. */
|
|---|
| 55 | /* This will guarantee that this clean up routine is run before the */
|
|---|
| 56 | /* library DLL is terminated. */
|
|---|
| 57 | /*-------------------------------------------------------------------*/
|
|---|
| 58 | static void APIENTRY cleanup(ULONG reason);
|
|---|
| 59 |
|
|---|
| 60 | extern "C" {
|
|---|
| 61 | //Win32 resource table (produced by wrc)
|
|---|
| 62 | extern DWORD user32_PEResTab;
|
|---|
| 63 | }
|
|---|
| 64 | DWORD hInstanceUser32 = 0;
|
|---|
| 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 APIENTRY inittermUser32(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 | ParseLogStatusUSER32();
|
|---|
| 89 |
|
|---|
| 90 | InitializeKernel32();
|
|---|
| 91 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
|---|
| 92 |
|
|---|
| 93 | hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&user32_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__, inittermUser32));
|
|---|
| 100 |
|
|---|
| 101 | //SvL: Try to start communication with our message spy queue server
|
|---|
| 102 | InitSpyQueue();
|
|---|
| 103 |
|
|---|
| 104 | //SvL: Init win32 PM classes
|
|---|
| 105 | if(InitPM() == FALSE) {
|
|---|
| 106 | return 0UL;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
|
|---|
| 110 | //CB: register internal classes
|
|---|
| 111 | RegisterSystemClasses(hModule);
|
|---|
| 112 |
|
|---|
| 113 | //CB: initialize PM monitor driver
|
|---|
| 114 | MONITOR_Initialize(&MONITOR_PrimaryMonitor);
|
|---|
| 115 |
|
|---|
| 116 | break;
|
|---|
| 117 | case 1 :
|
|---|
| 118 | if(hInstanceUser32) {
|
|---|
| 119 | UnregisterLxDll(hInstanceUser32);
|
|---|
| 120 | }
|
|---|
| 121 | break;
|
|---|
| 122 | default :
|
|---|
| 123 | return 0UL;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | /***********************************************************/
|
|---|
| 127 | /* A non-zero value must be returned to indicate success. */
|
|---|
| 128 | /***********************************************************/
|
|---|
| 129 | return 1UL;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | void APIENTRY cleanupUser32(ULONG ulReason)
|
|---|
| 133 | {
|
|---|
| 134 | dprintf(("user32 exit\n"));
|
|---|
| 135 | //SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
|
|---|
| 136 | //// RestoreCursor();
|
|---|
| 137 | DestroyDesktopWindow();
|
|---|
| 138 | Win32BaseWindow::DestroyAll();
|
|---|
| 139 | UnregisterSystemClasses();
|
|---|
| 140 | Win32WndClass::DestroyAll();
|
|---|
| 141 | MONITOR_Finalize(&MONITOR_PrimaryMonitor);
|
|---|
| 142 | SYSCOLOR_Save();
|
|---|
| 143 | CloseSpyQueue();
|
|---|
| 144 | dprintf(("user32 exit done\n"));
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|