OSDN Git Service

Added DLLMain() function + changed the fatal_exit() function's parameters from "char...
authorLoRd_MuldeR <mulder2@gmx.de>
Tue, 25 Nov 2014 17:33:15 +0000 (18:33 +0100)
committerLoRd_MuldeR <mulder2@gmx.de>
Tue, 25 Nov 2014 17:33:15 +0000 (18:33 +0100)
MUtilities_VS2013.vcxproj
MUtilities_VS2013.vcxproj.filters
include/MUtils/Exception.h
include/MUtils/OSSupport.h
src/DLLMain.cpp [new file with mode: 0644]
src/OSSupport_Win32.cpp

index d832154..8aa4ecb 100644 (file)
@@ -16,6 +16,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\CPUFeatures_Win32.cpp" />
+    <ClCompile Include="src\DLLMain.cpp" />
     <ClCompile Include="src\Global.cpp" />
     <ClCompile Include="src\KeccakHash.cpp" />
     <ClCompile Include="src\OSSupport_Win32.cpp" />
index d48f878..ff32638 100644 (file)
@@ -42,6 +42,9 @@
     <ClCompile Include="src\CPUFeatures_Win32.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\DLLMain.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="src\CriticalSection_Win32.h">
index ede846c..a9b256d 100644 (file)
@@ -40,12 +40,12 @@ while(0)
        catch(const std::exception &error) \
        { \
                MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what()); \
-               MUtils::OS::fatal_exit("Unhandeled C++ exception error, application will exit!"); \
+               MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!"); \
        } \
        catch(...) \
        { \
                MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n"); \
-               MUtils::OS::fatal_exit("Unhandeled C++ exception error, application will exit!"); \
+               MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!"); \
        } \
 } \
 while(0)
index 5b674e1..3fce410 100644 (file)
@@ -114,7 +114,7 @@ namespace MUtils
                MUTILS_API int network_status(void);
 
                //Error handling
-               MUTILS_API void fatal_exit(const char* const errorMessage);
+               MUTILS_API void fatal_exit(const wchar_t* const errorMessage);
        }
 }
 
diff --git a/src/DLLMain.cpp b/src/DLLMain.cpp
new file mode 100644 (file)
index 0000000..7c94ca8
--- /dev/null
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// MuldeR's Utilities for Qt
+// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// http://www.gnu.org/licenses/lgpl-2.1.txt
+//////////////////////////////////////////////////////////////////////////////////
+
+#ifdef _MSC_VER
+#ifndef MUTILS_STATIC_LIB
+
+//Win32 API
+#define WIN32_LEAN_AND_MEAN 1
+#include <Windows.h>
+
+BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
+{
+       switch (ul_reason_for_call)
+       {
+       case DLL_PROCESS_ATTACH:
+       case DLL_THREAD_ATTACH:
+       case DLL_THREAD_DETACH:
+       case DLL_PROCESS_DETACH:
+               break;
+       }
+       return TRUE;
+}
+
+#endif //MUTILS_STATIC_LIB
+#endif //_MSC_VER
index 48976e7..5b201ae 100644 (file)
@@ -46,19 +46,21 @@ static const DWORD g_main_thread_id = GetCurrentThreadId();
 // SYSTEM MESSAGE
 ///////////////////////////////////////////////////////////////////////////////
 
+static const UINT g_msgBoxFlags = MB_TOPMOST | MB_TASKMODAL | MB_SETFOREGROUND;
+
 void MUtils::OS::system_message_nfo(const wchar_t *const title, const wchar_t *const text)
 {
-       MessageBoxW(NULL, text, title, MB_TOPMOST | MB_TASKMODAL | MB_ICONINFORMATION);
+       MessageBoxW(NULL, text, title, g_msgBoxFlags | MB_ICONINFORMATION);
 }
 
 void MUtils::OS::system_message_wrn(const wchar_t *const title, const wchar_t *const text)
 {
-       MessageBoxW(NULL, text, title, MB_TOPMOST | MB_TASKMODAL | MB_ICONWARNING);
+       MessageBoxW(NULL, text, title, g_msgBoxFlags | MB_ICONWARNING);
 }
 
 void MUtils::OS::system_message_err(const wchar_t *const title, const wchar_t *const text)
 {
-       MessageBoxW(NULL, text, title, MB_TOPMOST | MB_TASKMODAL | MB_ICONERROR);
+       MessageBoxW(NULL, text, title, g_msgBoxFlags | MB_ICONERROR);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -432,11 +434,11 @@ static volatile bool g_fatal_exit_flag = true;
 
 static DWORD WINAPI fatal_exit_helper(LPVOID lpParameter)
 {
-       MessageBoxA(NULL, ((LPCSTR) lpParameter), "GURU MEDITATION", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST | MB_SETFOREGROUND);
+       MUtils::OS::system_message_err((LPWSTR) lpParameter, L"GURU MEDITATION");
        return 0;
 }
 
-void MUtils::OS::fatal_exit(const char* const errorMessage)
+void MUtils::OS::fatal_exit(const wchar_t* const errorMessage)
 {
        g_fatal_exit_lock.enter();