[21816] | 1 | /* $Id: initterm.cpp,v 1.21 2002-07-29 11:26:49 sandervl Exp $
|
---|
[6646] | 2 | *
|
---|
[21816] | 3 | * GDI32 DLL entry point
|
---|
[6375] | 4 | *
|
---|
| 5 | * Copyright 1998 Sander van Leeuwen
|
---|
| 6 | * Copyright 1998 Peter Fitzsimmons
|
---|
| 7 | *
|
---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #define INCL_DOSMODULEMGR
|
---|
| 12 | #define INCL_DOSPROCESS
|
---|
[7717] | 13 | #define INCL_GPI
|
---|
[6375] | 14 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
| 15 | #include <stdlib.h>
|
---|
| 16 | #include <stdio.h>
|
---|
| 17 | #include <string.h>
|
---|
| 18 | #include <odin.h>
|
---|
[7717] | 19 | #include <win32api.h>
|
---|
[6375] | 20 | #include <winconst.h>
|
---|
| 21 | #include <odinlx.h>
|
---|
[10167] | 22 | #include <cpuhlp.h>
|
---|
| 23 | #include <dbglog.h>
|
---|
[6375] | 24 | #include <initdll.h>
|
---|
[7635] | 25 | #include <stats.h>
|
---|
[21816] | 26 | #include <exitlist.h>
|
---|
| 27 |
|
---|
| 28 | #include "region.h"
|
---|
[7717] | 29 | #include "dibsect.h"
|
---|
[10167] | 30 | #include "rgbcvt.h"
|
---|
[6375] | 31 |
|
---|
[7717] | 32 | #define DBG_LOCALLOG DBG_initterm
|
---|
| 33 | #include "dbglocal.h"
|
---|
| 34 |
|
---|
[21816] | 35 | // Win32 resource table (produced by wrc)
|
---|
| 36 | extern DWORD gdi32_PEResTab;
|
---|
[10167] | 37 |
|
---|
[6375] | 38 | static HMODULE dllHandle = 0;
|
---|
[10167] | 39 | void (_Optlink *pRGB555to565)(WORD *dest, WORD *src, ULONG num) = NULL;
|
---|
| 40 | void (_Optlink *pRGB565to555)(WORD *dest, WORD *src, ULONG num) = NULL;
|
---|
| 41 |
|
---|
[8099] | 42 | BOOL WINAPI GdiLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
---|
[6375] | 43 | {
|
---|
| 44 | switch (fdwReason)
|
---|
| 45 | {
|
---|
| 46 | case DLL_PROCESS_ATTACH:
|
---|
[8934] | 47 | return TRUE;
|
---|
[6375] | 48 |
|
---|
| 49 | case DLL_THREAD_ATTACH:
|
---|
| 50 | case DLL_THREAD_DETACH:
|
---|
[8934] | 51 | return TRUE;
|
---|
[6375] | 52 |
|
---|
| 53 | case DLL_PROCESS_DETACH:
|
---|
[8934] | 54 | STATS_DumpStatsGDI32();
|
---|
| 55 | return TRUE;
|
---|
[6375] | 56 | }
|
---|
| 57 | return FALSE;
|
---|
| 58 | }
|
---|
[21816] | 59 |
|
---|
| 60 | ULONG SYSTEM DLL_InitGdi32(ULONG hModule)
|
---|
[6375] | 61 | {
|
---|
[21816] | 62 | STATS_InitializeGDI32 ();
|
---|
[6375] | 63 |
|
---|
[21816] | 64 | ParseLogStatusGDI32();
|
---|
[6375] | 65 |
|
---|
[21816] | 66 | if (!InitializeKernel32())
|
---|
[21976] | 67 | return -1;
|
---|
[21304] | 68 |
|
---|
[21816] | 69 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
---|
[21976] | 70 | if (InitRegionSpace() == FALSE)
|
---|
| 71 | return -1;
|
---|
[6375] | 72 |
|
---|
[21816] | 73 | DIBSection::initDIBSection();
|
---|
[21976] | 74 | if (CPUFeatures & CPUID_MMX)
|
---|
[21816] | 75 | {
|
---|
| 76 | pRGB555to565 = RGB555to565MMX;
|
---|
| 77 | pRGB565to555 = RGB565to555MMX;
|
---|
| 78 | }
|
---|
| 79 | else
|
---|
| 80 | {
|
---|
| 81 | pRGB555to565 = RGB555to565;
|
---|
| 82 | pRGB565to555 = RGB565to555;
|
---|
| 83 | }
|
---|
[21649] | 84 |
|
---|
[21816] | 85 | dllHandle = RegisterLxDll(hModule, GdiLibMain, (PVOID)&gdi32_PEResTab,
|
---|
| 86 | GDI32_MAJORIMAGE_VERSION, GDI32_MINORIMAGE_VERSION,
|
---|
| 87 | IMAGE_SUBSYSTEM_NATIVE);
|
---|
[21976] | 88 | if (dllHandle == 0)
|
---|
| 89 | return -1;
|
---|
[6375] | 90 |
|
---|
[21824] | 91 | dprintf(("gdi32 init %s %s (%x)", __DATE__, __TIME__, DLL_InitGdi32));
|
---|
[6375] | 92 |
|
---|
[21816] | 93 | RasEntry (RAS_EVENT_Gdi32InitComplete, &dllHandle, sizeof (dllHandle));
|
---|
[21304] | 94 |
|
---|
[6375] | 95 |
|
---|
[21816] | 96 | return EXITLIST_GDI32;
|
---|
[6375] | 97 | }
|
---|
[21816] | 98 |
|
---|
| 99 | void SYSTEM DLL_TermGdi32(ULONG hModule)
|
---|
| 100 | {
|
---|
| 101 | dprintf(("gdi32 exit"));
|
---|
| 102 |
|
---|
| 103 | if (dllHandle)
|
---|
| 104 | {
|
---|
| 105 | DestroyRegionSpace();
|
---|
| 106 | UnregisterLxDll(dllHandle);
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | STATS_UninitializeGDI32();
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | ULONG SYSTEM DLL_Init(ULONG hModule)
|
---|
| 113 | {
|
---|
| 114 | if (DLL_InitDefault(hModule) == -1)
|
---|
| 115 | return -1;
|
---|
| 116 | return DLL_InitGdi32(hModule);
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | void SYSTEM DLL_Term(ULONG hModule)
|
---|
| 120 | {
|
---|
| 121 | DLL_TermGdi32(hModule);
|
---|
| 122 | DLL_TermDefault(hModule);
|
---|
| 123 | }
|
---|