source: trunk/src/kernel32/initterm.cpp@ 6411

Last change on this file since 6411 was 6411, checked in by sandervl, 24 years ago

custom build fixes

File size: 5.5 KB
Line 
1/*
2 * KERNEL32 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_DOSMISC
27#define INCL_DOSPROCESS
28#define INCL_DOSSEMAPHORES
29#include <os2wrap.h> //Odin32 OS/2 api wrappers
30#include <stdlib.h>
31#include <stdio.h>
32#include <string.h>
33#include <misc.h>
34#include <wprocess.h>
35#include "handlemanager.h"
36#include "profile.h"
37#include <options.h>
38#include "initterm.h"
39#include <win32type.h>
40#include <odinlx.h>
41#include "oslibmisc.h"
42#include <heapshared.h>
43#include <heapcode.h>
44#include "mmap.h"
45#include "directory.h"
46#include "hmdevio.h"
47#include <windllbase.h>
48#include "winexepe2lx.h"
49#include <exitlist.h>
50#include "oslibdos.h"
51#include <cpuhlp.h>
52#include <Win32k.h>
53#include <initdll.h>
54#include <codepage.h>
55#include <process.h>
56
57#define DBG_LOCALLOG DBG_initterm
58#include "dbglocal.h"
59
60BOOL fVersionWarp3 = FALSE;
61
62/*-------------------------------------------------------------------*/
63/* A clean up routine registered with DosExitList must be used if */
64/* runtime calls are required and the runtime is dynamically linked. */
65/* This will guarantee that this clean up routine is run before the */
66/* library DLL is terminated. */
67/*-------------------------------------------------------------------*/
68static void APIENTRY cleanup(ULONG reason);
69
70/****************************************************************************/
71/* _DLL_InitTerm is the function that gets called by the operating system */
72/* loader when it loads and frees this DLL for each process that accesses */
73/* this DLL. However, it only gets called the first time the DLL is loaded */
74/* and the last time it is freed for a particular process. The system */
75/* linkage convention MUST be used because the operating system loader is */
76/* calling this function. */
77/****************************************************************************/
78ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG ulFlag)
79{
80 size_t i;
81 APIRET rc;
82 ULONG ulSysinfo, version[2];
83
84 /*-------------------------------------------------------------------------*/
85 /* If ulFlag is zero then the DLL is being loaded so initialization should */
86 /* be performed. If ulFlag is 1 then the DLL is being freed so */
87 /* termination should be performed. */
88 /*-------------------------------------------------------------------------*/
89
90 switch (ulFlag)
91 {
92 case 0 :
93 {
94 ctordtorInit();
95
96 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
97
98 /*******************************************************************/
99 /* A DosExitList routine must be used to clean up if runtime calls */
100 /* are required and the runtime is dynamically linked. */
101 /*******************************************************************/
102
103 rc = DosExitList(EXITLIST_KERNEL32|EXLST_ADD, cleanup);
104 if (rc)
105 return 0UL;
106
107 rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, version, sizeof(version));
108 if(rc == 0){
109 if(version[0] >= 20 && version[1] <= 30) {
110 fVersionWarp3 = TRUE;
111 }
112 }
113
114 rc = inittermKernel32(hModule, ulFlag);
115 break;
116 }
117
118 case 1 :
119 rc = inittermKernel32(hModule, ulFlag);
120 break;
121
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//******************************************************************************
133static void APIENTRY cleanup(ULONG ulReason)
134{
135 cleanupKernel32(ulReason);
136
137 ctordtorTerm();
138
139 DosExitList(EXLST_EXIT, cleanup);
140 return ;
141}
142//******************************************************************************
143ULONG APIENTRY O32__DLL_InitTerm(ULONG handle, ULONG flag);
144//******************************************************************************
145ULONG APIENTRY InitializeKernel32()
146{
147 HMODULE hModule;
148
149 DosQueryModuleHandle("WGSS50", &hModule);
150 O32__DLL_InitTerm(hModule, 0);
151 DosQueryModuleHandle("KERNEL32", &hModule);
152 return inittermKernel32(hModule, 0);
153}
154//******************************************************************************
155//******************************************************************************
Note: See TracBrowser for help on using the repository browser.