lhmouse / mcfgthread

Cornerstone of the MOST efficient std::thread on Windows for mingw-w64
https://gcc-mcf.lhmouse.com/
Other
277 stars 28 forks source link

Modernize `__MCF_runtime_failure()` #263

Closed lhmouse closed 1 month ago

lhmouse commented 1 month ago

This should show a message box.

  1. It may be called in a DLL entry-point routine or a TLS callback. So we are not allowed to call MessageBox()
  2. The message should be localized.

For 1, there is

ULONG response = 0;
ULONG_PTR params[4] = { (ULONG_PTR) text, (ULONG_PTR) caption, MB_OK | MB_ICONSTOP, 0 };
NtRaiseHardError(0x50000018, 4, 0b0011, params, 1, &response);

For 2, I think we can rip text from these messages

#define ERROR_UNHANDLED_EXCEPTION        574L

en-US:

{Application Error} The exception %s (0x%08lx) occurred in the application at location 0x%08lx.

zh-CN:

{应用程序错误} 应用程序发生异常 %s (0x%08lx),位置为 0x%08lx。

ja-JP:

{アプリケーション エラー} 例外 %s (0x%08lx) がアプリケーションの 0x%08lx で発生しました。

#define ERROR_DEBUG_ATTACH_FAILED        590L

en-US:

{Unexpected Failure in DebugActiveProcess} An unexpected failure occurred while processing a DebugActiveProcess API request. You may choose OK to terminate the process, or Cancel to ignore the error.

zh-CN:

{DebugActiveProcess 中的意外失败} 处理一个 DebugActiveProcess API 请求时发生意外失败。可以选择“确定”终止过程,或“取消”忽略错误。

ja-JP:

{DebugActiveProcess で予期しないエラーが発生} DebugActiveProcess API 要求の処理で予期しないエラーが発生しました。プロセスを終了するときは [OK] をクリックし、エラーを無視するときは [キャンセル] をクリックしてください。

  • 'ときは' looks weird. It should be 'には'.