OSDN Git Service

Remove dllproxy.*
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 2 Jan 2017 06:23:11 +0000 (15:23 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 2 Jan 2017 06:23:11 +0000 (15:23 +0900)
Src/Common/dllproxy.c [deleted file]
Src/Common/dllproxy.h [deleted file]
Src/Common/lwdisp.c
Src/Merge.vcxproj
Src/Merge.vcxproj.filters
Testing/FolderCompare/FolderCompare.vcxproj
Testing/FolderCompare/FolderCompare.vcxproj.filters
Testing/FolderCompare/Makefile
Testing/GoogleTest/UnitTests/UnitTests.vcxproj
Testing/GoogleTest/UnitTests/UnitTests.vcxproj.filters

diff --git a/Src/Common/dllproxy.c b/Src/Common/dllproxy.c
deleted file mode 100644 (file)
index 4bb271b..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/* File:       dllproxy.c
- * Author:     Jochen Tucht 2003/01/11
- *                     Copyright (C) 2003 herbert dahm datensysteme GmbH
- *
- * Purpose:    Provide a prototyped proxy object for a DLL to be loaded on demand.
- *                     Load the DLL when the proxy object is accessed for the first time.
- *                     If the DLL lacks a function which is declared in the proxy object,
- *                     issue an error message at load time, but allow program execution to
- *                     continue. If the program tries to call a missing function, issue an
- *                     error message, tell the user that it may be unsafe to continue
- *                     program execution, but still allow program execution to continue.
- *
- * Remarks:    requires Win32
- *                     
- * Options:    -DALLOCA_RECOVERY generates additional code to fix the stack pointer
- *                     after an attempt to call a missing function. This is the default for
- *                     MSC. Specify -DNO_ALLOCA_RECOVERY to explicitly cancel this option.
- *                     The option makes use of _alloca(), which is intrinsic in MSC, but
- *                     may not be supported by other compilers. Since _alloca() is not
- *                     exactly designed for the given purpose, the approach may fail. In
- *                     case of doubt, just cancel the option.
- *
- * License:    THIS FILE CONTAINS FREE SOURCE CODE. IT IS PROVIDED *AS IS*, WITHOUT
- *                     WARRANTY OF ANY KIND. YOU MAY USE IT AT YOUR OWN RISK, AS LONG AS
- *                     YOU KEEP IT IN A SEPARATE FILE AND PRESERVE THIS COMMENT.
- *                     CHANGES MUST BE RECORDED IN THE MODIFICATION HISTORY BELOW SO THERE
- *                     IS EVIDENCE THAT THE FILE DIFFERS FROM EARLIER RELEASES. THE LEVEL
- *                     OF DETAIL IS UP TO YOU. YOU MAY SET THE BY: ENTRY TO "NOBODY@ALL"
- *                     IF YOU DON'T WANT TO EXPOSE YOUR NAME. SUBSEQUENT CHANGES MAY BE
- *                     REFLECTED BY A SINGLE RECORD CARRYING THE DATE OF THE LATEST CHANGE.
- *
-
-DATE:          BY:                                     DESCRIPTION:
-==========     ==================      ================================================
-2003/03/15     J.Tucht                         module itself & DLL proxies may reside in a DLL
-2003/03/16     J.Tucht                         DLL proxies may reside in stack frame
-2003/03/29     J.Tucht                         ALLOCA_RECOVERY now thread safe; does no longer
-                                                               rely on _alloca(); may also work with GCC
-2007/08/11     Kimmo Varis                     Add ifdef removing inline assembly from 64-bit
-                                                               builds. I know it breaks plugins but its more
-                                                               important to be able to build 64-bit now.
-
-*/
-
-#if defined(_MSC_VER)&&!defined(NO_ALLOCA_RECOVERY)||defined(ALLOCA_RECOVERY)
-#undef ALLOCA_RECOVERY
-#define ALLOCA_RECOVERY(X) X
-#else
-#undef ALLOCA_RECOVERY
-#define ALLOCA_RECOVERY(X)
-#endif
-
-#ifdef _MSC_VER
-#pragma warning(disable: 4100)
-#define UNUSED(ARG) ARG
-#else
-#define UNUSED(ARG)
-#endif
-
-//#define _WIN32_IE            0x0300
-//#define _WIN32_WINNT 0x0400  
-
-#define NONAMELESSUNION                // avoid warning C4201
-
-struct IShellView;                     // avoid MSC warning C4115
-struct _RPC_ASYNC_STATE;       // avoid MSC warning C4115
-
-#include <shlobj.h>
-#include <shlwapi.h>
-#include "dllproxy.h"
-
-#define IS_PTR(p) ((p) != (LPVOID)0)
-
-#define MB_DLLPROXY MB_TASKMODAL | MB_TOPMOST | MB_ICONSTOP
-
-static VOID NTAPI Complain(LPCSTR complain, LPCSTR caption)
-{
-       if (MessageBoxA(0, complain, caption, MB_DLLPROXY | MB_YESNO) != IDYES)
-       {
-               ExitProcess(3);
-       }
-}
-
-#if ALLOCA_RECOVERY(TRUE)-0
-#ifdef _MSC_VER
-#pragma message("ALLOCA_RECOVERY(TRUE)")
-#endif
-
-static DWORD ThreadTopOfStack = 0xFFFFFFFF;
-
-static LPVOID NTAPI ComplainUnresolved()
-{
-       Complain(DllProxy_ModuleState.Complain.Invoke, "DLLPROXY");
-       return TlsGetValue(ThreadTopOfStack);
-}
-
-static INT_PTR NTAPI Unresolved()
-{
-       // declare a variable to produce a stack frame
-       int Unresolved = 0;
-
-#ifndef _WIN64 // 64-bit compiler errors at inline asm
-#ifdef _MSC_VER
-       __asm
-       {
-               call ComplainUnresolved
-               mov esp, ebp
-               pop ebp
-               pop edx
-               mov esp, eax
-               xor eax, eax
-               jmp edx
-       }
-#endif
-#ifdef __MINGW_H
-       asm
-       (
-               "\n     call *%0"                               // call ComplainUnresolved
-               "\n     mov %%ebp, %%esp"
-               "\n     pop %%ebp"
-               "\n     pop %%edx"
-               "\n     mov %%eax, %%esp"
-               "\n     xor %%eax, %%eax"
-               "\n     push %%edx"                             // as warns about jmp %edx
-               "\n     ret"
-       :       /* no explicit outputs */
-       :       "o" (ComplainUnresolved)
-       );
-#endif
-#endif // _WIN64
-       return Unresolved;
-}
-
-#else
-#ifdef _MSC_VER
-#pragma message("ALLOCA_RECOVERY(FALSE)")
-#endif
-
-static INT_PTR NTAPI Unresolved()
-{
-       Complain(DllProxy_ModuleState.Complain.Invoke, "DLLPROXY");
-       return 0;
-}
-
-#endif
-
-static VOID NTAPI Load(HMODULE *phModule)
-{
-#if ALLOCA_RECOVERY(TRUE)-0
-       if (ThreadTopOfStack == 0xFFFFFFFF)
-               ThreadTopOfStack = TlsAlloc();
-       TlsSetValue(ThreadTopOfStack, &phModule + 1);
-#endif
-       if (*phModule == 0)
-       {
-               LPCSTR p = (LPCSTR)(phModule + 1);
-               LPCSTR cModule = StrRChrA(p, 0, ';');
-               FARPROC *ppfn = (FARPROC *)p;
-               HMODULE hModule = LoadLibraryA(cModule + 1);
-               CHAR cPath[260];
-               GetModuleFileNameA(hModule, cPath, sizeof cPath);
-               if (hModule == 0)
-               {
-                       Complain(DllProxy_ModuleState.Complain.LoadLibrary, cModule);
-               }
-               cModule = PathFindFileNameA(cPath);
-               while IS_PTR(p = StrChrA(p,'*'))
-               {
-                       CHAR cExport[260];
-                       LPCSTR q = StrChrA(p,')');
-                       FARPROC pfn = GetProcAddress(hModule, lstrcpynA(cExport, p + 1, (int)(q - p)));
-                       p = StrChrA(q,';') + 1;
-                       if (pfn == 0)
-                       {
-                               pfn = Unresolved;
-                               if (hModule)
-                               {
-                                       CHAR cMsg[2600];
-                                       wsprintfA(cMsg, "%s:\n%s%s", cPath, cExport,
-                                               DllProxy_ModuleState.Complain.GetProcAddress);
-                                       Complain(cMsg, cModule);
-                               }
-                       }
-                       *ppfn++ = pfn;
-               }
-               *phModule = GetModuleHandleA(cPath);
-       }
-}
-
-struct DllProxy_ModuleState DllProxy_ModuleState =
-{
-       {
-               // Complain.LoadLibrary
-               "Failed to load library!\n"
-               "Continue anyway?",
-               // Complain.GetProcAddress
-               "() unresolved!\n"
-               "Continue anyway?",
-               // Complain.Invoke
-               "Attempt to call unresolved external!\n"
-               "It may be unsafe to continue!\n"
-               "Continue anyway?"
-       },
-       // Load()
-       Load,
-       // Unresolved()
-       Unresolved,
-};
diff --git a/Src/Common/dllproxy.h b/Src/Common/dllproxy.h
deleted file mode 100644 (file)
index d8a3ccb..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#pragma once
-
-struct DllProxy_ModuleState
-{
-//     error messages exposed here just in case anybody desires localization...
-       struct
-       {
-               LPCSTR LoadLibrary;             // the DLL could not be loaded
-               LPCSTR GetProcAddress;  // the DLL is lacking a function
-               LPCSTR Invoke;                  // attempt to call a missing function
-       } Complain;
-       VOID(NTAPI*Load)(HMODULE*);
-       FARPROC Unresolved;                     // placeholder for missing functions
-};
-
-#ifndef POLARITY
-#define POLARITY
-#endif
-
-EXTERN_C struct DllProxy_ModuleState POLARITY DllProxy_ModuleState;
-
-#define DLLPROXY(NAME) (DllProxy_ModuleState.Load(&NAME.DLL),(struct NAME*)&NAME)
-
-#define EXPORT_DLLPROXY(NAME,MODULE,P) \
-       struct NAME{HMODULE DLL;P}; \
-       struct {HMODULE DLL;CHAR SIG[sizeof#P MODULE + (sizeof MODULE == 1 ? MAX_PATH : 0)];} NAME = {0, #P MODULE};
-
-#define IMPORT_DLLPROXY(NAME,MODULE,P) \
-       struct NAME{HMODULE DLL;P}; \
-       extern struct {HMODULE DLL;CHAR SIG[sizeof#P MODULE + (sizeof MODULE == 1 ? MAX_PATH : 0)];} NAME;
-
-#define DLL_EXPORT_DLLPROXY(NAME,MODULE,P) \
-       struct NAME {HMODULE DLL;P}; \
-       struct {HMODULE DLL;CHAR SIG[sizeof#P MODULE + (sizeof MODULE == 1 ? MAX_PATH : 0)];} __declspec(dllexport) NAME = {0, #P MODULE};
-
-#define DLL_IMPORT_DLLPROXY(NAME,MODULE,P) \
-       struct NAME{HMODULE DLL;P}; \
-       extern struct {HMODULE DLL;CHAR SIG[sizeof#P MODULE + (sizeof MODULE == 1 ? MAX_PATH : 0)];} __declspec(dllimport) NAME;
-
-#undef POLARITY
index 76a3a38..1a03510 100644 (file)
@@ -54,7 +54,6 @@ struct _RPC_ASYNC_STATE;      // avoid MSC warning C4115
 #include <stdarg.h>
 #include <strsafe.h>
 #include "lwdisp.h"
-#include "dllproxy.h"
 
 /**
 * @brief Display or return error message string (from
@@ -184,21 +183,24 @@ LPDISPATCH CreatDispatchBy32BitProxy(LPCTSTR source, LPCWSTR progid)
 
 LPDISPATCH CreateDispatchBySourceAndCLSID(LPCTSTR source, CLSID *pObjectCLSID)
 {
-       SCODE sc;
        LPDISPATCH pv = NULL;
-       IClassFactory *piClassFactory;
-       EXPORT_DLLPROXY
-       (
-               Dll, "",
-               HRESULT(NTAPI*DllGetClassObject)(REFCLSID,REFIID,IClassFactory**);
-       );
-       mycpyt2a(source, Dll.SIG+strlen(Dll.SIG), sizeof(Dll.SIG)-strlen(Dll.SIG));
-       if ((FARPROC)DLLPROXY(Dll)->DllGetClassObject != DllProxy_ModuleState.Unresolved)
-               if (SUCCEEDED(sc=DLLPROXY(Dll)->DllGetClassObject(pObjectCLSID, &IID_IClassFactory, &piClassFactory)))
+       HMODULE hLibrary = LoadLibrary(source);
+       if (hLibrary)
+       {
+               HRESULT (NTAPI*DllGetClassObject)(REFCLSID,REFIID,IClassFactory**)
+                       = (HRESULT(NTAPI*)(REFCLSID, REFIID, IClassFactory**))GetProcAddress(hLibrary, "DllGetClassObject");
+               if (DllGetClassObject)
                {
-                       sc=piClassFactory->lpVtbl->CreateInstance(piClassFactory, 0, &IID_IDispatch, &pv);
+                       SCODE sc;
+                       IClassFactory *piClassFactory;
+                       if (SUCCEEDED(sc = DllGetClassObject(pObjectCLSID, &IID_IClassFactory, &piClassFactory)))
+                       {
+                               sc = piClassFactory->lpVtbl->CreateInstance(piClassFactory, 0, &IID_IDispatch, &pv);
+                       }
                }
-
+               if (!pv)
+                       FreeLibrary(hLibrary);
+       }
        return pv;
 }
 
index 4155938..4241604 100644 (file)
     <ClCompile Include="DirViewColItems.cpp">\r
       <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
-    <ClCompile Include="Common\dllproxy.c">\r
-      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
-    </ClCompile>\r
     <ClCompile Include="dllpstub.cpp">\r
       <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
     <ClInclude Include="DirTravel.h" />\r
     <ClInclude Include="DirView.h" />\r
     <ClInclude Include="DirViewColItems.h" />\r
-    <ClInclude Include="Common\dllproxy.h" />\r
     <ClInclude Include="dllpstub.h" />\r
     <ClInclude Include="EditorFilepathBar.h" />\r
     <ClInclude Include="EncodingErrorBar.h" />\r
index bf055a5..8f4a091 100644 (file)
     <ClCompile Include="DirTravel.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="Common\dllproxy.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="dllpstub.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClInclude Include="DirTravel.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="Common\dllproxy.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="dllpstub.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
index 5690dd3..398b1b0 100644 (file)
     <ClCompile Include="..\..\Src\DirItem.cpp" />\r
     <ClCompile Include="..\..\Src\DirScan.cpp" />\r
     <ClCompile Include="..\..\Src\DirTravel.cpp" />\r
-    <ClCompile Include="..\..\Src\Common\dllproxy.c" />\r
     <ClCompile Include="..\..\Src\Environment.cpp" />\r
     <ClCompile Include="..\..\Src\FileFilter.cpp" />\r
     <ClCompile Include="..\..\Src\FileFilterHelper.cpp" />\r
     <ClInclude Include="..\..\Src\DirItem.h" />\r
     <ClInclude Include="..\..\Src\DirScan.h" />\r
     <ClInclude Include="..\..\Src\DirTravel.h" />\r
-    <ClInclude Include="..\..\Src\Common\dllproxy.h" />\r
     <ClInclude Include="..\..\Src\Environment.h" />\r
     <ClInclude Include="..\..\Src\FileFilter.h" />\r
     <ClInclude Include="..\..\Src\FileFilterHelper.h" />\r
index 7865809..9faef43 100644 (file)
@@ -69,9 +69,6 @@
     <ClCompile Include="..\..\Src\DirTravel.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="..\..\Src\Common\dllproxy.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="..\..\Src\Environment.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClInclude Include="..\..\Src\DirTravel.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\Src\Common\dllproxy.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\Src\Environment.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
index d8b82ca..e056199 100644 (file)
@@ -6,7 +6,6 @@ TARGET=FolderCompare.exe
 \r
 OBJS=\\r
 ../../Src/Common/coretools.o \\r
-../../Src/Common/dllproxy.o \\r
 ../../Src/Common/lwdisp.o \\r
 ../../Src/Common/multiformatText.o \\r
 ../../Src/Common/OptionsMgr.o \\r
index 234717e..b90b5c3 100644 (file)
     <ClCompile Include="..\..\..\Src\DiffItem.cpp" />\r
     <ClCompile Include="..\..\..\Src\diffutils\src\Diff.cpp" />\r
     <ClCompile Include="..\..\..\Src\DirItem.cpp" />\r
-    <ClCompile Include="..\..\..\Src\Common\dllproxy.c" />\r
     <ClCompile Include="..\..\..\Src\Environment.cpp" />\r
     <ClCompile Include="..\..\..\Src\Common\ExConverter.cpp" />\r
     <ClCompile Include="..\..\..\Src\FileFilter.cpp" />\r
     <ClInclude Include="..\..\..\Src\CompareEngines\DiffUtils.h" />\r
     <ClInclude Include="..\..\..\Src\DiffItem.h" />\r
     <ClInclude Include="..\..\..\Src\DirItem.h" />\r
-    <ClInclude Include="..\..\..\Src\Common\dllproxy.h" />\r
     <ClInclude Include="..\..\..\Src\Environment.h" />\r
     <ClInclude Include="..\..\..\Src\Common\ExConverter.h" />\r
     <ClInclude Include="..\..\..\Src\FileFilter.h" />\r
index 914e4f7..c89a602 100644 (file)
@@ -48,9 +48,6 @@
     <ClCompile Include="..\..\..\Src\DirItem.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="..\..\..\Src\Common\dllproxy.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="..\..\..\Src\Environment.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClInclude Include="..\..\..\Src\DirItem.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\Src\Common\dllproxy.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\Src\Environment.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r