Added DLLMain() function + changed the fatal_exit() function's parameters from "char*" to "wchar_t*" type.

This commit is contained in:
LoRd_MuldeR 2014-11-25 18:33:15 +01:00
parent 9537d9005a
commit 2df2b2dce6
6 changed files with 57 additions and 8 deletions

View 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" />

View 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">

View 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)

View 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);
}
}

43
src/DLLMain.cpp Normal file
View File

@ -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

View 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();