From f2902217b38cf2e16e851ae84d61247f8e828180 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 25 Mar 2019 17:53:14 +0100 Subject: Update the 7z installer stub source to 18.05. Tag #1022 --- other-licenses/7zstub/src/CPP/Windows/DLL.h | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 other-licenses/7zstub/src/CPP/Windows/DLL.h (limited to 'other-licenses/7zstub/src/CPP/Windows/DLL.h') diff --git a/other-licenses/7zstub/src/CPP/Windows/DLL.h b/other-licenses/7zstub/src/CPP/Windows/DLL.h new file mode 100644 index 000000000..58bcf1954 --- /dev/null +++ b/other-licenses/7zstub/src/CPP/Windows/DLL.h @@ -0,0 +1,58 @@ +// Windows/DLL.h + +#ifndef __WINDOWS_DLL_H +#define __WINDOWS_DLL_H + +#include "../Common/MyString.h" + +namespace NWindows { +namespace NDLL { + +#ifdef UNDER_CE +#define My_GetProcAddress(module, procName) ::GetProcAddressA(module, procName) +#else +#define My_GetProcAddress(module, procName) ::GetProcAddress(module, procName) +#endif + +/* Win32: Don't call CLibrary::Free() and FreeLibrary() from another + FreeLibrary() code: detaching code in DLL entry-point or in + destructors of global objects in DLL module. */ + +class CLibrary +{ + HMODULE _module; + + // CLASS_NO_COPY(CLibrary); +public: + CLibrary(): _module(NULL) {}; + ~CLibrary() { Free(); } + + operator HMODULE() const { return _module; } + HMODULE* operator&() { return &_module; } + bool IsLoaded() const { return (_module != NULL); } + + void Attach(HMODULE m) + { + Free(); + _module = m; + } + HMODULE Detach() + { + HMODULE m = _module; + _module = NULL; + return m; + } + + bool Free() throw(); + bool LoadEx(CFSTR path, DWORD flags = LOAD_LIBRARY_AS_DATAFILE) throw(); + bool Load(CFSTR path) throw(); + FARPROC GetProc(LPCSTR procName) const { return My_GetProcAddress(_module, procName); } +}; + +bool MyGetModuleFileName(FString &path); + +FString GetModuleDirPrefix(); + +}} + +#endif -- cgit v1.2.3