Rev 357 | Rev 411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
259 | daniel-mar | 1 | /* |
268 | daniel-mar | 2 | This file is part of a common library |
259 | daniel-mar | 3 | Copyright (C) 2002-6 Toby Thain, toby@telegraphics.com.au |
4 | |||
5 | This program is free software; you can redistribute it and/or modify |
||
6 | it under the terms of the GNU General Public License as published by |
||
7 | the Free Software Foundation; either version 2 of the License, or |
||
8 | (at your option) any later version. |
||
9 | |||
10 | This program is distributed in the hope that it will be useful, |
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
13 | GNU General Public License for more details. |
||
14 | |||
15 | You should have received a copy of the GNU General Public License |
||
16 | along with this program; if not, write to the Free Software |
||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | */ |
||
19 | |||
20 | #include <windows.h> |
||
21 | |||
22 | #include "compat_win.h" |
||
402 | daniel-mar | 23 | #include "compat_win_resource.h" |
259 | daniel-mar | 24 | |
25 | Boolean isWin32NT(void){ |
||
311 | daniel-mar | 26 | #ifdef _WIN64 |
27 | // 64 bit OS is never Win9x, so it must be WinNT |
||
28 | return true; |
||
29 | #else |
||
259 | daniel-mar | 30 | OSVERSIONINFO osv; |
31 | osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
||
32 | #pragma warning(suppress : 4996 28159) |
||
33 | return GetVersionEx(&osv) && osv.dwPlatformId == VER_PLATFORM_WIN32_NT; |
||
311 | daniel-mar | 34 | #endif |
259 | daniel-mar | 35 | } |
36 | |||
37 | // --------------------------------- |
||
38 | |||
39 | typedef ULONGLONG(__stdcall* f_GetTickCount64)(); |
||
40 | ULONGLONG _GetTickCount64() { |
||
41 | HMODULE hLib; |
||
42 | f_GetTickCount64 fGetTickCount64; |
||
43 | ULONGLONG res; |
||
44 | |||
45 | hLib = LoadLibraryA("KERNEL32.DLL"); |
||
46 | if (!hLib) return 0; |
||
47 | fGetTickCount64 = (f_GetTickCount64)(void*)GetProcAddress(hLib, "GetTickCount64"); |
||
48 | if (fGetTickCount64 != 0) { |
||
49 | res = fGetTickCount64(); |
||
50 | FreeLibrary(hLib); |
||
51 | } else { |
||
52 | #pragma warning(suppress : 28159) |
||
53 | res = (ULONGLONG)GetTickCount(); |
||
54 | } |
||
55 | |||
56 | return res; |
||
57 | } |
||
58 | |||
402 | daniel-mar | 59 | // --------------------------------- |
60 | |||
259 | daniel-mar | 61 | HANDLE _BeginUpdateResource/*A*/( |
268 | daniel-mar | 62 | LPCSTR pFileName, |
63 | BOOL bDeleteExistingResources |
||
259 | daniel-mar | 64 | ) { |
402 | daniel-mar | 65 | if (isWin32NT()) { |
66 | return BeginUpdateResourceA(pFileName, bDeleteExistingResources); |
||
67 | } else { |
||
68 | return WineBeginUpdateResourceA(pFileName, bDeleteExistingResources); |
||
69 | } |
||
259 | daniel-mar | 70 | } |
71 | |||
72 | // --------------------------------- |
||
73 | |||
74 | BOOL _EndUpdateResource/*A*/( |
||
268 | daniel-mar | 75 | HANDLE hUpdate, |
76 | BOOL fDiscard |
||
259 | daniel-mar | 77 | ) { |
402 | daniel-mar | 78 | if (isWin32NT()) { |
79 | return EndUpdateResourceA(hUpdate, fDiscard); |
||
259 | daniel-mar | 80 | |
402 | daniel-mar | 81 | } else { |
82 | return WineEndUpdateResourceA(hUpdate, fDiscard); |
||
83 | } |
||
259 | daniel-mar | 84 | } |
85 | |||
86 | // --------------------------------- |
||
87 | |||
88 | BOOL _UpdateResource/*A*/( |
||
268 | daniel-mar | 89 | HANDLE hUpdate, |
90 | LPCSTR lpType, |
||
91 | LPCSTR lpName, |
||
92 | WORD wLanguage, |
||
93 | LPVOID lpData, |
||
94 | DWORD cb |
||
259 | daniel-mar | 95 | ) { |
402 | daniel-mar | 96 | if (isWin32NT()) { |
97 | return UpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb); |
||
259 | daniel-mar | 98 | |
99 | |||
402 | daniel-mar | 100 | } else { |
101 | return WineUpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb); |
||
102 | } |
||
259 | daniel-mar | 103 | } |
274 | daniel-mar | 104 | |
105 | typedef void(__stdcall* f_GetNativeSystemInfo)(LPSYSTEM_INFO lpSystemInfo); |
||
106 | void _GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo) { |
||
107 | HMODULE hLib; |
||
108 | f_GetNativeSystemInfo fGetNativeSystemInfo; |
||
109 | |||
110 | hLib = LoadLibraryA("KERNEL32.DLL"); |
||
111 | if (!hLib) return; |
||
112 | fGetNativeSystemInfo = (f_GetNativeSystemInfo)(void*)GetProcAddress(hLib, "GetNativeSystemInfo"); |
||
113 | if (fGetNativeSystemInfo != 0) { |
||
114 | fGetNativeSystemInfo(lpSystemInfo); |
||
115 | FreeLibrary(hLib); |
||
116 | } |
||
117 | else { |
||
118 | GetSystemInfo(lpSystemInfo); |
||
119 | } |
||
120 | } |
||
357 | daniel-mar | 121 | |
122 | typedef BOOL(__stdcall* f_ImageRemoveCertificate)(HANDLE FileHandle, DWORD Index); |
||
123 | BOOL _ImageRemoveCertificate(HANDLE FileHandle, DWORD Index) { |
||
124 | HMODULE hLib; |
||
125 | f_ImageRemoveCertificate fImageRemoveCertificate; |
||
126 | BOOL res = FALSE; |
||
127 | |||
128 | hLib = LoadLibraryA("IMAGEHLP.DLL"); |
||
129 | if (!hLib) return FALSE; |
||
130 | fImageRemoveCertificate = (f_ImageRemoveCertificate)(void*)GetProcAddress(hLib, "ImageRemoveCertificate"); |
||
131 | if (fImageRemoveCertificate != 0) { |
||
132 | res = fImageRemoveCertificate(FileHandle, Index); |
||
133 | FreeLibrary(hLib); |
||
134 | } |
||
135 | |||
136 | return res; |
||
137 | } |