Subversion Repositories filter_foundry

Rev

Rev 357 | Rev 411 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.     This file is part of a common library
  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"
  23. #include "compat_win_resource.h"
  24.  
  25. Boolean isWin32NT(void){
  26. #ifdef _WIN64
  27.         // 64 bit OS is never Win9x, so it must be WinNT
  28.         return true;
  29. #else
  30.         OSVERSIONINFO osv;
  31.         osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  32.         #pragma warning(suppress : 4996 28159)
  33.         return GetVersionEx(&osv) && osv.dwPlatformId == VER_PLATFORM_WIN32_NT;
  34. #endif
  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.  
  59. // ---------------------------------
  60.  
  61. HANDLE _BeginUpdateResource/*A*/(
  62.         LPCSTR pFileName,
  63.         BOOL   bDeleteExistingResources
  64. ) {
  65.         if (isWin32NT()) {
  66.                 return BeginUpdateResourceA(pFileName, bDeleteExistingResources);
  67.         } else {
  68.                 return WineBeginUpdateResourceA(pFileName, bDeleteExistingResources);
  69.         }
  70. }
  71.  
  72. // ---------------------------------
  73.  
  74. BOOL _EndUpdateResource/*A*/(
  75.         HANDLE hUpdate,
  76.         BOOL   fDiscard
  77. ) {
  78.         if (isWin32NT()) {
  79.                 return EndUpdateResourceA(hUpdate, fDiscard);
  80.  
  81.         } else {
  82.                 return WineEndUpdateResourceA(hUpdate, fDiscard);
  83.         }
  84. }
  85.  
  86. // ---------------------------------
  87.  
  88. BOOL _UpdateResource/*A*/(
  89.         HANDLE hUpdate,
  90.         LPCSTR lpType,
  91.         LPCSTR lpName,
  92.         WORD   wLanguage,
  93.         LPVOID lpData,
  94.         DWORD  cb
  95. ) {
  96.         if (isWin32NT()) {
  97.                 return UpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb);
  98.  
  99.  
  100.         } else {
  101.                 return WineUpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb);
  102.         }
  103. }
  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. }
  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. }
  138.