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() {
|
||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||
|
||||
if (!RawEnableColorfulConsole(stdout)) return false;
|
||||
if (!RawEnableColorfulConsole(stderr)) return false;
|
||||
return true;
|
||||
bool ret = true;
|
||||
ret &= RawEnableColorfulConsole(stdout);
|
||||
ret &= RawEnableColorfulConsole(stderr);
|
||||
return ret;
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ namespace YYCC::ExceptionHelper {
|
|||
std::string module_name_raw;
|
||||
DWORD64 module_base;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace YYCC::WinFctHelper {
|
|||
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.
|
||||
std::wstring wpath(MAX_PATH + 1u, L'\0');
|
||||
DWORD copied_size;
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace YYCC::WinFctHelper {
|
|||
* The variable receiving UTF8 encoded file name of given module.
|
||||
* @return True if success, otherwise false.
|
||||
*/
|
||||
bool GetModuleName(HINSTANCE hModule, std::string& ret);
|
||||
bool GetModuleFileName(HINSTANCE hModule, std::string& ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,5 +15,6 @@
|
|||
#undef GetClassName
|
||||
#undef LoadImage
|
||||
#undef GetTempPath
|
||||
#undef GetModuleFileName
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user