source: branches/gcc-kmk/src/gdi32/initterm.cpp@ 21816

Last change on this file since 21816 was 21816, checked in by dmik, 13 years ago

Port GDI32 to GCC.

File size: 2.7 KB
Line 
1/* $Id: initterm.cpp,v 1.21 2002-07-29 11:26:49 sandervl Exp $
2 *
3 * GDI32 DLL entry point
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
13#define INCL_GPI
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>
19#include <win32api.h>
20#include <winconst.h>
21#include <odinlx.h>
22#include <cpuhlp.h>
23#include <dbglog.h>
24#include <initdll.h>
25#include <stats.h>
26#include <exitlist.h>
27
28#include "region.h"
29#include "dibsect.h"
30#include "rgbcvt.h"
31
32#define DBG_LOCALLOG DBG_initterm
33#include "dbglocal.h"
34
35// Win32 resource table (produced by wrc)
36extern DWORD gdi32_PEResTab;
37
38static HMODULE dllHandle = 0;
39void (_Optlink *pRGB555to565)(WORD *dest, WORD *src, ULONG num) = NULL;
40void (_Optlink *pRGB565to555)(WORD *dest, WORD *src, ULONG num) = NULL;
41
42BOOL WINAPI GdiLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
43{
44 switch (fdwReason)
45 {
46 case DLL_PROCESS_ATTACH:
47 return TRUE;
48
49 case DLL_THREAD_ATTACH:
50 case DLL_THREAD_DETACH:
51 return TRUE;
52
53 case DLL_PROCESS_DETACH:
54 STATS_DumpStatsGDI32();
55 return TRUE;
56 }
57 return FALSE;
58}
59
60ULONG SYSTEM DLL_InitGdi32(ULONG hModule)
61{
62 STATS_InitializeGDI32 ();
63
64 ParseLogStatusGDI32();
65
66 if (!InitializeKernel32())
67 return 0;
68
69 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
70 if(InitRegionSpace() == FALSE)
71 {
72 return 0UL;
73 }
74
75 DIBSection::initDIBSection();
76 if(CPUFeatures & CPUID_MMX)
77 {
78 pRGB555to565 = RGB555to565MMX;
79 pRGB565to555 = RGB565to555MMX;
80 }
81 else
82 {
83 pRGB555to565 = RGB555to565;
84 pRGB565to555 = RGB565to555;
85 }
86
87 dllHandle = RegisterLxDll(hModule, GdiLibMain, (PVOID)&gdi32_PEResTab,
88 GDI32_MAJORIMAGE_VERSION, GDI32_MINORIMAGE_VERSION,
89 IMAGE_SUBSYSTEM_NATIVE);
90 if(dllHandle == 0)
91 return 0UL;
92
93 dprintf(("gdi32 init %s %s (%x)", __DATE__, __TIME__, inittermGdi32));
94
95 RasEntry (RAS_EVENT_Gdi32InitComplete, &dllHandle, sizeof (dllHandle));
96
97
98 return EXITLIST_GDI32;
99}
100
101void SYSTEM DLL_TermGdi32(ULONG hModule)
102{
103 dprintf(("gdi32 exit"));
104
105 if (dllHandle)
106 {
107 DestroyRegionSpace();
108 UnregisterLxDll(dllHandle);
109 }
110
111 STATS_UninitializeGDI32();
112}
113
114ULONG SYSTEM DLL_Init(ULONG hModule)
115{
116 if (DLL_InitDefault(hModule) == -1)
117 return -1;
118 return DLL_InitGdi32(hModule);
119}
120
121void SYSTEM DLL_Term(ULONG hModule)
122{
123 DLL_TermGdi32(hModule);
124 DLL_TermDefault(hModule);
125}
Note: See TracBrowser for help on using the repository browser.