1 | /* $Id: initterm.cpp,v 1.20 2003-01-21 11:20:35 sandervl Exp $
|
---|
2 | *
|
---|
3 | * DDRAW 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 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
14 | #include <stdlib.h>
|
---|
15 | #include <stdio.h>
|
---|
16 | #include <string.h>
|
---|
17 | #include <odin.h>
|
---|
18 | #include <win32type.h>
|
---|
19 | #include <winconst.h>
|
---|
20 | #include <odinlx.h>
|
---|
21 | #include <dbglog.h>
|
---|
22 | #include <exitlist.h>
|
---|
23 | #include <misc.h> /*PLF Wed 98-03-18 23:18:15*/
|
---|
24 | #include <initdll.h>
|
---|
25 |
|
---|
26 | #ifdef FULLSCREEN_DDRAW
|
---|
27 | #include "os2fsdd.h" // For RestorePM()
|
---|
28 | #endif
|
---|
29 | #include "divewrap.h"
|
---|
30 |
|
---|
31 | // Win32 resource table (produced by wrc)
|
---|
32 | extern DWORD ddraw_PEResTab;
|
---|
33 |
|
---|
34 | char ddrawPath[CCHMAXPATH] = "";
|
---|
35 | static HMODULE dllHandle = 0;
|
---|
36 |
|
---|
37 | #if 0 // not currently needed
|
---|
38 | BOOL WINAPI LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
---|
39 | {
|
---|
40 | switch (fdwReason)
|
---|
41 | {
|
---|
42 | case DLL_PROCESS_ATTACH:
|
---|
43 | return TRUE;
|
---|
44 |
|
---|
45 | case DLL_THREAD_ATTACH:
|
---|
46 | case DLL_THREAD_DETACH:
|
---|
47 | return TRUE;
|
---|
48 |
|
---|
49 | case DLL_PROCESS_DETACH:
|
---|
50 | return TRUE;
|
---|
51 | }
|
---|
52 | return FALSE;
|
---|
53 | }
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | ULONG SYSTEM DLL_InitDDraw(ULONG hModule)
|
---|
57 | {
|
---|
58 | APIRET rc;
|
---|
59 |
|
---|
60 | DosQueryModuleName(hModule, CCHMAXPATH, ddrawPath);
|
---|
61 | char *endofpath = strrchr(ddrawPath, '\\');
|
---|
62 | if (endofpath)
|
---|
63 | *(endofpath+1) = '\0';
|
---|
64 |
|
---|
65 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
---|
66 |
|
---|
67 | dllHandle = RegisterLxDll(hModule, NULL, (PVOID)&ddraw_PEResTab,
|
---|
68 | DDRAW_MAJORIMAGE_VERSION, DDRAW_MINORIMAGE_VERSION,
|
---|
69 | IMAGE_SUBSYSTEM_WINDOWS_GUI);
|
---|
70 | if (dllHandle == 0)
|
---|
71 | return -1;
|
---|
72 |
|
---|
73 | DiveLoad();
|
---|
74 |
|
---|
75 | #ifdef FULLSCREEN_DDRAW
|
---|
76 | return EXITLIST_NONCOREDLL;
|
---|
77 | #else
|
---|
78 | return 0;
|
---|
79 | #endif
|
---|
80 | }
|
---|
81 |
|
---|
82 | void SYSTEM DLL_TermDDraw(ULONG hModule)
|
---|
83 | {
|
---|
84 | #ifdef FULLSCREEN_DDRAW
|
---|
85 | dprintf(("DDRAW processing exitlist"));
|
---|
86 | RestorePM();
|
---|
87 | dprintf(("DDRAW exitlist done"));
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | DiveUnload();
|
---|
91 |
|
---|
92 | if (dllHandle)
|
---|
93 | UnregisterLxDll(dllHandle);
|
---|
94 | }
|
---|
95 |
|
---|
96 | ULONG SYSTEM DLL_Init(ULONG hModule)
|
---|
97 | {
|
---|
98 | if (DLL_InitDefault(hModule) == -1)
|
---|
99 | return -1;
|
---|
100 | return DLL_InitDDraw(hModule);
|
---|
101 | }
|
---|
102 |
|
---|
103 | void SYSTEM DLL_Term(ULONG hModule)
|
---|
104 | {
|
---|
105 | DLL_TermDDraw(hModule);
|
---|
106 | DLL_TermDefault(hModule);
|
---|
107 | }
|
---|