forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request xbmc#6402 from Karlson2k/w32_setloc_01
Locale fixes
- Loading branch information
Showing
13 changed files
with
229 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright (C) 2015 Team Kodi | ||
* http://kodi.tv | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
/** | ||
* \file win32\crts_caller.h | ||
* \brief Implements crts_caller class for calling same function for all loaded CRTs. | ||
* \author Karlson2k | ||
*/ | ||
|
||
#include "crts_caller.h" | ||
#ifndef WIN32_LEAN_AND_MEAN | ||
#define WIN32_LEAN_AND_MEAN 1 | ||
#endif // WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
#include <cassert> | ||
|
||
namespace win32_utils | ||
{ | ||
|
||
static const wchar_t* const s_listOfCrts[] = | ||
{ | ||
{ L"msvcrt.dll" }, // Visual Studio 6.0 / MinGW[-w64] | ||
{ L"msvcr70.dll" }, // Visual Studio 2002 | ||
{ L"msvcr71.dll" }, // Visual Studio 2003 | ||
{ L"msvcr80.dll" }, // Visual Studio 2005 | ||
{ L"msvcr90.dll" }, // Visual Studio 2008 | ||
#ifdef _DEBUG | ||
{ L"msvcr90d.dll" }, // Visual Studio 2008 (debug) | ||
#endif | ||
{ L"msvcr100.dll" }, // Visual Studio 2010 | ||
#ifdef _DEBUG | ||
{ L"msvcr100d.dll" },// Visual Studio 2010 (debug) | ||
#endif | ||
{ L"msvcr110.dll" }, // Visual Studio 2012 | ||
#ifdef _DEBUG | ||
{ L"msvcr110d.dll" },// Visual Studio 2012 (debug) | ||
#endif | ||
{ L"msvcr120.dll" }, // Visual Studio 2013 | ||
#ifdef _DEBUG | ||
{ L"msvcr120d.dll" },// Visual Studio 2013 (debug) | ||
#endif | ||
}; | ||
|
||
std::vector<std::wstring> crts_caller::getCrtNames() | ||
{ | ||
return std::vector<std::wstring>(s_listOfCrts, s_listOfCrts + (sizeof(s_listOfCrts) / sizeof(s_listOfCrts[0]))); | ||
} | ||
|
||
|
||
crts_caller::crts_caller(const char* func_name) | ||
{ | ||
assert(func_name); | ||
assert(func_name[0]); | ||
if (func_name == NULL) | ||
return; | ||
|
||
for (const wchar_t* const crtName : s_listOfCrts) | ||
{ | ||
HMODULE hCrt = NULL; | ||
if (!GetModuleHandleExW(0, crtName, &hCrt) || hCrt == NULL) // Flag 0 ensures that CRL will not be unloaded while we are using it here | ||
continue; // Module not loaded | ||
|
||
void* func_ptr = GetProcAddress(hCrt, func_name); | ||
if (func_ptr != NULL) | ||
{ | ||
m_crts.push_back(hCrt); | ||
m_funcPointers.push_back(func_ptr); | ||
} | ||
else | ||
FreeLibrary(hCrt); // this CRT will not be used | ||
} | ||
} | ||
|
||
crts_caller::~crts_caller() | ||
{ | ||
for (void* hCrt : m_crts) | ||
FreeLibrary((HMODULE)hCrt); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2015 Team Kodi | ||
* http://kodi.tv | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
/** | ||
* \file win32\crts_caller.h | ||
* \brief Declares crts_caller class for calling same function for all loaded CRTs. | ||
* \author Karlson2k | ||
*/ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include <boost/preprocessor/stringize.hpp> | ||
|
||
namespace win32_utils | ||
{ | ||
|
||
class crts_caller | ||
{ | ||
public: | ||
crts_caller(const char* func_name); | ||
const std::vector<void*>& get_pointers(void) | ||
{ return m_funcPointers; } | ||
~crts_caller(); | ||
|
||
template <typename ret_type, typename... param_types> | ||
static typename ret_type call_in_all_crts(const char* func_name, ret_type(*cur_fnc_ptr) (param_types...), param_types... params) | ||
{ | ||
typedef ret_type(*ptr_type)(param_types...); | ||
|
||
if (cur_fnc_ptr == NULL) | ||
return (ret_type)0; // cur_fnc_ptr must point to process default CRT function | ||
|
||
crts_caller crts(func_name); | ||
for (void* func_ptr : crts.m_funcPointers) | ||
{ | ||
ptr_type func = (ptr_type)func_ptr; | ||
if (func != cur_fnc_ptr) | ||
(void)func(params...); // ignoring result of function call | ||
} | ||
|
||
return cur_fnc_ptr(params...); // return result of calling process's CRT function | ||
} | ||
|
||
static std::vector<std::wstring> getCrtNames(); | ||
private: | ||
std::vector<void*> m_funcPointers; | ||
std::vector<void*> m_crts; // actually contains HMODULE | ||
}; | ||
|
||
// Call function in all loaded CRTs | ||
// Function must have same return type and same parameters in all CRTs | ||
#define CALL_IN_CRTS(function,...) ::win32_utils::crts_caller::call_in_all_crts(BOOST_PP_STRINGIZE(function),&(function),##__VA_ARGS__) | ||
|
||
|
||
} |