Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3. /*
  4.  * Copyright (c) 2001-2004 Vaclav Slavik
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a copy
  7.  * of this software and associated documentation files (the "Software"), to
  8.  * deal in the Software without restriction, including without limitation the
  9.  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10.  * sell copies of the Software, and to permit persons to whom the Software is
  11.  * furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice shall be included in
  14.  * all copies or substantial portions of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19.  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  22.  * IN THE SOFTWARE.
  23.  *
  24.  * $Id: unicows_import.c,v 1.14 2005/01/02 13:30:37 vaclavslavik Exp $
  25.  *
  26.  */
  27. /************************************************************************
  28.  Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht
  29.  
  30.    This file is part of TZipMaster Version 1.9.
  31.  
  32.     TZipMaster is free software: you can redistribute it and/or modify
  33.     it under the terms of the GNU Lesser General Public License as published by
  34.     the Free Software Foundation, either version 3 of the License, or
  35.     (at your option) any later version.
  36.  
  37.     TZipMaster is distributed in the hope that it will be useful,
  38.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  39.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  40.     GNU Lesser General Public License for more details.
  41.  
  42.     You should have received a copy of the GNU Lesser General Public License
  43.     along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
  44.  
  45.     contact: problems@delphizip.org (include ZipMaster in the subject).
  46.     updates: http://www.delphizip.org
  47.     DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
  48. ************************************************************************/
  49. #if defined(UNICODE) && defined(ALLOW_WIN98)
  50.  
  51. //#include <windows.h>
  52.  /*
  53. char *func_names[] =
  54. {
  55.     "0CreateDirectoryW",
  56. "0CreateFileW",
  57. "0DeleteFileW",
  58. "0FindFirstFileW",
  59. "0FindNextFileW",
  60. "0FindResourceW",
  61. "0GetCurrentDirectoryW",
  62. "0GetDriveTypeW",
  63. "0GetFileAttributesW",
  64. "0GetFullPathNameW",
  65. "0GetModuleHandleW",
  66. "0GetShortPathNameW",
  67. "0GetStringTypeW",
  68. "0GetTempPathW",
  69. "0GetVolumeInformationW",
  70. "0LCMapStringW",
  71. "0MoveFileWithProgressW",
  72. "0RemoveDirectoryW",
  73. "0SetFileAttributesW",
  74. //"2SHChangeNotify",
  75. "2SHFileOperationW",
  76. "1CharToOemW",
  77. "1LoadStringW",
  78. "1MessageBoxW",
  79. "1OemToCharW",
  80. "0lstrlenW",
  81. "0OutputDebugStringW",
  82. 0
  83. }; */
  84.              
  85. extern const char *func_names[];
  86.  
  87. #define DLL_KERNEL32        0
  88. #define DLL_USER32          1
  89. #define DLL_SHELL32         2
  90.  
  91. #define DLLS_COUNT         3
  92.  
  93. static HMODULE dllHandles[DLLS_COUNT] = {0};
  94.  
  95. static const char *dllNames[DLLS_COUNT] =
  96.     {
  97.       "kernel32.dll", "user32.dll", "shell32.dll"
  98.     };
  99.                          
  100. //typedef void WINAPI (SHChangeNotifyPtr*)(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2);
  101.  
  102. //SHChangeNotifyPtr OrigSHChangeNotify;
  103.  
  104. extern void *u_jmps[];
  105.  
  106. int Init_Imports(void)
  107. {
  108.     const char **fn;
  109.     const char *n;
  110.     int dll;//, i;
  111.     void *pf;
  112.     void **uj = u_jmps;
  113.     for (fn = func_names; *fn; fn++)
  114.     {
  115.         n = *fn;
  116.         dll = *n++ - '0';
  117.         if (dll < 0 || dll >= DLLS_COUNT)
  118.         {
  119.             return -1;
  120.         }
  121.         if (!dllHandles[dll])
  122.         {
  123.             dllHandles[dll] = LoadLibraryA(dllNames[dll]);
  124.             if (!dllHandles[dll])
  125.                 return -2;
  126.     //            UnicowsImportError(dllNames[dll], NULL);
  127.         }                                            
  128.         pf = GetProcAddress(dllHandles[dll], n);
  129.         if (pf)
  130.             *uj++ = pf;
  131.     }
  132.     return 0;
  133. }
  134.  
  135. void FreeDLLs(void)
  136. {
  137.     size_t i;
  138.  
  139. //    if (!dllsLoaded)
  140. //        return;
  141. //    if (useUnicows)
  142. //    {
  143. ////        FreeLibrary(dllUnicowsHandle);
  144. //        dllUnicowsHandle = 0;
  145. //    }
  146. //    else
  147. //    {
  148.         for (i = 0; i < DLLS_COUNT; i++)
  149.         {
  150.             if (dllHandles[i])
  151.                 FreeLibrary(dllHandles[i]);
  152.             dllHandles[i] = 0;
  153.         }
  154. //    }
  155. /*
  156.     if (dllHandleKernel32)
  157.     {
  158.         FreeLibrary(dllHandleKernel32);
  159.         dllHandleKernel32 = 0;
  160.     }
  161. */
  162. //    dllsLoaded = 0;
  163. }
  164. #endif
  165.  
  166.