fix: rename function. update console function
- Update implementation of EnsureColorfulConsole. - previous implementation will exit if one of the process to stdout and stderr failed. so if it exit at the process of stdout, the process of stderr will not be run. - current implementation will always do process for both of stdout and stderr. the return value will be false if any process of them are failed. - rename GetModuleName to GetModuleFileName and disable annoy Windows macro GetModuleFileName in WinImportSuffix.hpp.
This commit is contained in:
parent
d0a8733379
commit
e7b13768ec
|
@ -163,9 +163,10 @@ namespace YYCC::ConsoleHelper {
|
||||||
bool EnableColorfulConsole() {
|
bool EnableColorfulConsole() {
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||||
|
|
||||||
if (!RawEnableColorfulConsole(stdout)) return false;
|
bool ret = true;
|
||||||
if (!RawEnableColorfulConsole(stderr)) return false;
|
ret &= RawEnableColorfulConsole(stdout);
|
||||||
return true;
|
ret &= RawEnableColorfulConsole(stderr);
|
||||||
|
return ret;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ namespace YYCC::ExceptionHelper {
|
||||||
std::string module_name_raw;
|
std::string module_name_raw;
|
||||||
DWORD64 module_base;
|
DWORD64 module_base;
|
||||||
if (module_base = SymGetModuleBase64(process, frame.AddrPC.Offset)) {
|
if (module_base = SymGetModuleBase64(process, frame.AddrPC.Offset)) {
|
||||||
if (WinFctHelper::GetModuleName((HINSTANCE)module_base, module_name_raw)) {
|
if (WinFctHelper::GetModuleFileName((HINSTANCE)module_base, module_name_raw)) {
|
||||||
module_name = module_name_raw.c_str();
|
module_name = module_name_raw.c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace YYCC::WinFctHelper {
|
||||||
return YYCC::EncodingHelper::WcharToUTF8(wpath.c_str(), ret);
|
return YYCC::EncodingHelper::WcharToUTF8(wpath.c_str(), ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetModuleName(HINSTANCE hModule, std::string& ret) {
|
bool GetModuleFileName(HINSTANCE hModule, std::string& ret) {
|
||||||
// create wchar buffer for receiving the temp path.
|
// create wchar buffer for receiving the temp path.
|
||||||
std::wstring wpath(MAX_PATH + 1u, L'\0');
|
std::wstring wpath(MAX_PATH + 1u, L'\0');
|
||||||
DWORD copied_size;
|
DWORD copied_size;
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace YYCC::WinFctHelper {
|
||||||
* The variable receiving UTF8 encoded file name of given module.
|
* The variable receiving UTF8 encoded file name of given module.
|
||||||
* @return True if success, otherwise false.
|
* @return True if success, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool GetModuleName(HINSTANCE hModule, std::string& ret);
|
bool GetModuleFileName(HINSTANCE hModule, std::string& ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,5 +15,6 @@
|
||||||
#undef GetClassName
|
#undef GetClassName
|
||||||
#undef LoadImage
|
#undef LoadImage
|
||||||
#undef GetTempPath
|
#undef GetTempPath
|
||||||
|
#undef GetModuleFileName
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user