mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Reduce usage of exceptions from Boot (#2373)
* wip * make pretty * Remove CRT version check from IM * fix * Simplify IsDebuggerPresent hook
This commit is contained in:
parent
f613b177a2
commit
9092e36b33
16 changed files with 494 additions and 295 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "logging.h"
|
||||
#include "utils.h"
|
||||
#include "resource.h"
|
||||
|
||||
HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue);
|
||||
|
||||
|
|
@ -379,12 +380,50 @@ extern "C" void WINAPI RewrittenEntryPoint_AdjustedStack(RewrittenEntryPointPara
|
|||
auto desc = err.Description();
|
||||
if (desc.length() == 0)
|
||||
desc = err.ErrorMessage();
|
||||
if (MessageBoxW(nullptr, std::format(
|
||||
L"Failed to load Dalamud. Load game without Dalamud(yes) or abort(no)?\n\n{}\n{}",
|
||||
last_operation,
|
||||
desc.GetBSTR()).c_str(),
|
||||
L"Dalamud.Boot", MB_OK | MB_YESNO) == IDNO)
|
||||
ExitProcess(-1);
|
||||
|
||||
enum IdTaskDialogAction {
|
||||
IdTaskDialogActionAbort = 101,
|
||||
IdTaskDialogActionContinue,
|
||||
};
|
||||
|
||||
const TASKDIALOG_BUTTON buttons[]{
|
||||
{IdTaskDialogActionAbort, MAKEINTRESOURCEW(IDS_INITIALIZEFAIL_ACTION_ABORT)},
|
||||
{IdTaskDialogActionContinue, MAKEINTRESOURCEW(IDS_INITIALIZEFAIL_ACTION_CONTINUE)},
|
||||
};
|
||||
|
||||
const auto hru32 = static_cast<uint32_t>(hr);
|
||||
const auto footer = std::vformat(
|
||||
utils::get_string_resource(IDS_INITIALIZEFAIL_DIALOG_FOOTER),
|
||||
std::make_wformat_args(
|
||||
last_operation,
|
||||
hru32,
|
||||
desc.GetBSTR()));
|
||||
|
||||
const TASKDIALOGCONFIG config{
|
||||
.cbSize = sizeof config,
|
||||
.hInstance = g_hModule,
|
||||
.dwFlags = TDF_CAN_BE_MINIMIZED | TDF_ALLOW_DIALOG_CANCELLATION | TDF_USE_COMMAND_LINKS | TDF_EXPAND_FOOTER_AREA,
|
||||
.pszWindowTitle = MAKEINTRESOURCEW(IDS_APPNAME),
|
||||
.pszMainIcon = MAKEINTRESOURCEW(IDI_ICON1),
|
||||
.pszMainInstruction = MAKEINTRESOURCEW(IDS_INITIALIZEFAIL_DIALOG_MAININSTRUCTION),
|
||||
.pszContent = MAKEINTRESOURCEW(IDS_INITIALIZEFAIL_DIALOG_CONTENT),
|
||||
.cButtons = _countof(buttons),
|
||||
.pButtons = buttons,
|
||||
.nDefaultButton = IdTaskDialogActionAbort,
|
||||
.pszFooter = footer.c_str(),
|
||||
};
|
||||
|
||||
int buttonPressed;
|
||||
if (utils::scoped_dpi_awareness_context ctx;
|
||||
FAILED(TaskDialogIndirect(&config, &buttonPressed, nullptr, nullptr)))
|
||||
buttonPressed = IdTaskDialogActionAbort;
|
||||
|
||||
switch (buttonPressed) {
|
||||
case IdTaskDialogActionAbort:
|
||||
ExitProcess(-1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (hMainThreadContinue) {
|
||||
CloseHandle(hMainThreadContinue);
|
||||
hMainThreadContinue = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue