diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index 8cd55e22d..ab23446bc 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -1516,7 +1516,7 @@ bool IsRunningAsAdmin() } bool RunProcessAsAdmin(const QString &fullExecutablePath, const QStringList ¶ms, - QWidget *parent, std::function finishedCallback) + QWidget *parent, bool hidden, std::function finishedCallback) { #if defined(Q_OS_WIN32) @@ -1536,7 +1536,7 @@ bool RunProcessAsAdmin(const QString &fullExecutablePath, const QStringList &par info.lpVerb = L"runas"; info.lpFile = wideExe.c_str(); info.lpParameters = wideParams.c_str(); - info.nShow = SW_SHOWNORMAL; + info.nShow = hidden ? SW_HIDE : SW_SHOWNORMAL; ShellExecuteExW(&info); diff --git a/qrenderdoc/Code/QRDUtils.h b/qrenderdoc/Code/QRDUtils.h index b9dc02dc7..4859623f6 100644 --- a/qrenderdoc/Code/QRDUtils.h +++ b/qrenderdoc/Code/QRDUtils.h @@ -585,7 +585,7 @@ typedef std::function ProgressFinishedMethod; QStringList ParseArgsList(const QString &args); bool IsRunningAsAdmin(); bool RunProcessAsAdmin(const QString &fullExecutablePath, const QStringList ¶ms, - QWidget *parent = NULL, + QWidget *parent = NULL, bool hidden = false, std::function finishedCallback = std::function()); void RevealFilenameInExternalFileBrowser(const QString &filePath); diff --git a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp index aec1ff8a6..453ec5a5f 100644 --- a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp @@ -431,11 +431,11 @@ void CaptureDialog::vulkanLayerWarn_mouseClick() } RunProcessAsAdmin(cmd, QStringList() << lit("vulkanregister") << lit("--system"), this, - [this]() { ui->vulkanLayerWarn->setVisible(false); }); + true, [this]() { ui->vulkanLayerWarn->setVisible(false); }); #else RunProcessAsAdmin(qApp->applicationFilePath(), QStringList() << lit("--install_vulkan_layer") << lit("root"), this, - [this]() { ui->vulkanLayerWarn->setVisible(false); }); + false, [this]() { ui->vulkanLayerWarn->setVisible(false); }); #endif return; } diff --git a/qrenderdoc/Windows/Dialogs/UpdateDialog.cpp b/qrenderdoc/Windows/Dialogs/UpdateDialog.cpp index a9c091139..940e18de0 100644 --- a/qrenderdoc/Windows/Dialogs/UpdateDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/UpdateDialog.cpp @@ -252,9 +252,9 @@ void UpdateDialog::on_update_clicked() QDir::setCurrent(dir.absolutePath()); - success = RunProcessAsAdmin(dir.absoluteFilePath(cmd), QStringList() - << lit("upgrade") << lit("--path") - << appDir.absolutePath()); + success = RunProcessAsAdmin( + dir.absoluteFilePath(cmd), + QStringList() << lit("upgrade") << lit("--path") << appDir.absolutePath(), NULL, true); exit(0); diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index 6fe38e761..ac9a31aba 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -1019,6 +1019,9 @@ void MainWindow::SetTitle(const QString &filename) .arg(lit(FULL_VERSION_STRING)) .arg(QString::fromLatin1(GitVersionHash)); + if(IsRunningAsAdmin()) + text += tr(" (Administrator)"); + if(QString::fromLatin1(RENDERDOC_GetVersionString()) != lit(MAJOR_MINOR_VERSION_STRING)) text += tr(" - !! VERSION MISMATCH DETECTED !!"); diff --git a/renderdoc/core/crash_handler.h b/renderdoc/core/crash_handler.h index 76e5b1395..ea54103fb 100644 --- a/renderdoc/core/crash_handler.h +++ b/renderdoc/core/crash_handler.h @@ -124,6 +124,11 @@ public: RDCEraseEl(pi); RDCEraseEl(si); + // hide the console window + si.cb = sizeof(si); + si.dwFlags |= STARTF_USESHOWWINDOW; + si.wShowWindow = SW_HIDE; + HANDLE waitEvent = CreateEventA(NULL, TRUE, FALSE, "RENDERDOC_CRASHHANDLE"); wchar_t radpath[MAX_PATH] = {0}; @@ -157,7 +162,8 @@ public: wcscpy_s(paramsAlloc, 511, cmdline.c_str()); - BOOL ret = CreateProcessW(NULL, paramsAlloc, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); + BOOL ret = CreateProcessW(NULL, paramsAlloc, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, + &si, &pi); if(!ret) RDCERR("Failed to create crashhandle server: %d", GetLastError()); diff --git a/renderdoc/os/win32/win32_process.cpp b/renderdoc/os/win32/win32_process.cpp index f267269f2..164ee94ab 100644 --- a/renderdoc/os/win32/win32_process.cpp +++ b/renderdoc/os/win32/win32_process.cpp @@ -781,6 +781,11 @@ ExecuteResult Process::InjectIntoProcess(uint32_t pid, const rdcarrayProgramDatabase - Windows + Console true psapi.lib;ws2_32.lib;Wininet.lib;%(AdditionalDependencies) @@ -128,7 +128,7 @@ ProgramDatabase - Windows + Console true psapi.lib;ws2_32.lib;Wininet.lib;%(AdditionalDependencies) @@ -149,7 +149,7 @@ true - Windows + Console true true true @@ -172,7 +172,7 @@ true - Windows + Console true true true diff --git a/renderdoccmd/renderdoccmd_win32.cpp b/renderdoccmd/renderdoccmd_win32.cpp index be2bcd611..e264d32e9 100644 --- a/renderdoccmd/renderdoccmd_win32.cpp +++ b/renderdoccmd/renderdoccmd_win32.cpp @@ -752,21 +752,12 @@ std::string getParentExe() return ""; } -int WINAPI wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, - _In_ int nShowCmd) +// ignore the argc/argv we get here, convert from wide to be sure we're unicode safe. +int main(int, char *) { LPWSTR *wargv; int argc; - if(AttachConsole(ATTACH_PARENT_PROCESS)) - { - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - - std::cout.sync_with_stdio(); - std::cerr.sync_with_stdio(); - } - wargv = CommandLineToArgvW(GetCommandLine(), &argc); std::vector argv; @@ -789,13 +780,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInstance, _In_ parent[i] = '/'; } - if(strstr(parent.c_str(), "/cmd.exe") && AttachConsole(ATTACH_PARENT_PROCESS)) - { - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - } - - hInstance = hInst; + hInstance = GetModuleHandleA(NULL); WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX);