ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Windows/kernel_windows.cpp
Revision: 1.1
Committed: 2004-12-05T16:54:14Z (19 years, 11 months ago) by gbeauche
Branch: MAIN
CVS Tags: nigel-build-19, nigel-build-17
Log Message:
Import some extra functions from Win32 libraries. Expose OS versions.

File Contents

# User Rev Content
1 gbeauche 1.1 /*
2     * kernel_windows.cpp
3     *
4     * Basilisk II (C) 1997-1999 Christian Bauer
5     *
6     * Windows platform specific code copyright (C) Lauri Pesonen
7     *
8     * This program is free software; you can redistribute it and/or modify
9     * it under the terms of the GNU General Public License as published by
10     * the Free Software Foundation; either version 2 of the License, or
11     * (at your option) any later version.
12     *
13     * This program is distributed in the hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     * GNU General Public License for more details.
17     *
18     * You should have received a copy of the GNU General Public License
19     * along with this program; if not, write to the Free Software
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21     */
22    
23     #include "sysdeps.h"
24     #include "prefs.h"
25     #include "kernel_windows.h"
26    
27     // From main_windows.cpp
28     extern DWORD win_os;
29     extern DWORD win_os_major;
30    
31     static HMODULE hKernel32 = 0;
32     static HMODULE hUser32 = 0;
33     static HMODULE hB2Win32 = 0;
34    
35     UINT (WINAPI *pfnGetWriteWatch) (DWORD,PVOID,SIZE_T,PVOID *,LPDWORD,LPDWORD) = 0;
36     BOOL (WINAPI *pfnInitializeCriticalSectionAndSpinCount) (LPCRITICAL_SECTION,DWORD) = 0;
37     BOOL (WINAPI *pfnCancelIo) (HANDLE) = 0;
38     BOOL (WINAPI *pfnGETCDSECTORS) (BYTE,DWORD,WORD,LPBYTE) = 0;
39     UINT (WINAPI *pfnSendInput) (UINT,LPVOID,int) = 0;
40     BOOL (WINAPI *pfnGetDiskFreeSpaceEx) (LPCSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER) = 0;
41    
42     void KernelInit( void )
43     {
44     hKernel32 = LoadLibrary( "kernel32.dll" );
45     hUser32 = LoadLibrary( "user32.dll" );
46     if(hKernel32) {
47     if(win_os == VER_PLATFORM_WIN32_WINDOWS) {
48     // NT5 RC2 Kernel exports GetWriteWatch(), but VirtualAlloc(MEM_WRITE_WATCH) fails
49     pfnGetWriteWatch = (UINT (WINAPI *)(DWORD,PVOID,SIZE_T,PVOID *,LPDWORD,LPDWORD))GetProcAddress( hKernel32, "GetWriteWatch" );
50     }
51     pfnInitializeCriticalSectionAndSpinCount = (BOOL (WINAPI *)(LPCRITICAL_SECTION,DWORD))GetProcAddress( hKernel32, "InitializeCriticalSectionAndSpinCount" );
52     pfnCancelIo = (BOOL (WINAPI *)(HANDLE))GetProcAddress( hKernel32, "CancelIo" );
53     pfnGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER))GetProcAddress( hKernel32, "GetDiskFreeSpaceExA" );
54     }
55     if(hUser32) {
56     // Win98 has this one too.
57     // if(win_os == VER_PLATFORM_WIN32_NT) {
58     pfnSendInput = (UINT (WINAPI *)(UINT,LPVOID,int))GetProcAddress( hUser32, "SendInput" );
59     // }
60     }
61     if(win_os == VER_PLATFORM_WIN32_WINDOWS) {
62     hB2Win32 = LoadLibrary( "B2Win32.dll" );
63     if(hB2Win32) {
64     pfnGETCDSECTORS = (BOOL (WINAPI *)(BYTE,DWORD,WORD,LPBYTE))GetProcAddress( hB2Win32, "GETCDSECTORS" );
65     }
66     }
67     }
68    
69     void KernelExit( void )
70     {
71     if(hKernel32) {
72     FreeLibrary( hKernel32 );
73     hKernel32 = 0;
74     }
75     if(hUser32) {
76     FreeLibrary( hUser32 );
77     hUser32 = 0;
78     }
79     if(hB2Win32) {
80     FreeLibrary( hB2Win32 );
81     hB2Win32 = 0;
82     }
83     pfnGetWriteWatch = 0;
84     pfnInitializeCriticalSectionAndSpinCount = 0;
85     pfnCancelIo = 0;
86     pfnSendInput = 0;
87     pfnGETCDSECTORS = 0;
88     }