diff --git a/qrenderdoc/renderdocui_stub.cpp b/qrenderdoc/renderdocui_stub.cpp new file mode 100644 index 000000000..767911756 --- /dev/null +++ b/qrenderdoc/renderdocui_stub.cpp @@ -0,0 +1,84 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2018 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include + +int WINAPI wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, + _In_ int nShowCmd) +{ + size_t len = wcslen(lpCmdLine) + 64; + + wchar_t *paramsAlloc = new wchar_t[len + 1]; + + ZeroMemory(paramsAlloc, sizeof(wchar_t) * (len + 1)); + + // get the path to this file + wchar_t curFile[512] = {0}; + GetModuleFileNameW(NULL, curFile, 511); + + // find the last / or \ and erase everything after that to get the folder + wchar_t *w = curFile + wcslen(curFile); + + while(w > curFile && *w != '/' && *w != '\\') + w--; + + if(w > curFile) + *(w + 1) = 0; + else + curFile[0] = 0; + + // transform / to \ just in case + w = curFile; + while(*w) + { + if(*w == '/') + *w = '\\'; + w++; + } + + wcscat_s(curFile, 511, L"qrenderdoc.exe"); + + wcscpy_s(paramsAlloc, len, curFile); + + wcscat_s(paramsAlloc, len, L" "); + + wcscat_s(paramsAlloc, len, lpCmdLine); + + PROCESS_INFORMATION pi; + STARTUPINFOW si; + ZeroMemory(&pi, sizeof(pi)); + ZeroMemory(&si, sizeof(si)); + + CreateProcessW(curFile, paramsAlloc, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); + + if(pi.dwProcessId != 0) + { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + } + + delete[] paramsAlloc; + + return 0; +} \ No newline at end of file diff --git a/qrenderdoc/renderdocui_stub.vcxproj b/qrenderdoc/renderdocui_stub.vcxproj new file mode 100644 index 000000000..555aaa8c7 --- /dev/null +++ b/qrenderdoc/renderdocui_stub.vcxproj @@ -0,0 +1,87 @@ + + + + + Development + Win32 + + + Release + Win32 + + + Development + x64 + + + Release + x64 + + + + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4} + Win32Proj + renderdocui_stub + 8.1 + renderdocui_stub + + + + Application + true + v140 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\obj\$(ProjectName)\ + Unicode + renderdocui + renderdocui + + + $(SolutionDir)$(SolutionRelativeIntDir) + $(IntDir) + $(OutputDirectory)\ + + + + + + + + + + + + false + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + Default + ProgramDatabase + + + Windows + true + true + true + + + $(SolutionDir)renderdoc\api\replay + + + + + + + + + + + + \ No newline at end of file diff --git a/qrenderdoc/renderdocui_stub.vcxproj.filters b/qrenderdoc/renderdocui_stub.vcxproj.filters new file mode 100644 index 000000000..98f658ca8 --- /dev/null +++ b/qrenderdoc/renderdocui_stub.vcxproj.filters @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/renderdoc.sln b/renderdoc.sln index b91521c82..b6046f0bb 100644 --- a/renderdoc.sln +++ b/renderdoc.sln @@ -74,6 +74,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qrenderdoc_module", "qrende EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "version", "renderdoc\renderdoc_version.vcxproj", "{257FD75C-4D17-4A23-A754-23BFD85887A0}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderdocui_stub", "qrenderdoc\renderdocui_stub.vcxproj", "{37955C79-D91D-423F-8C6C-8F5BCF4F28D4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Development|x64 = Development|x64 @@ -242,6 +244,14 @@ Global {257FD75C-4D17-4A23-A754-23BFD85887A0}.Release|x64.Build.0 = Release|x64 {257FD75C-4D17-4A23-A754-23BFD85887A0}.Release|x86.ActiveCfg = Release|Win32 {257FD75C-4D17-4A23-A754-23BFD85887A0}.Release|x86.Build.0 = Release|Win32 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Development|x64.ActiveCfg = Development|x64 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Development|x64.Build.0 = Development|x64 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Development|x86.ActiveCfg = Development|Win32 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Development|x86.Build.0 = Development|Win32 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Release|x64.ActiveCfg = Release|x64 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Release|x64.Build.0 = Release|x64 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Release|x86.ActiveCfg = Release|Win32 + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -273,5 +283,6 @@ Global {A8998B2D-652A-47F8-955B-5654B222B4EB} = {A0E6051E-4374-42E0-9F3C-28DFC64A1029} {61157930-78C3-4355-8B49-4CC91B98F17B} = {A0E6051E-4374-42E0-9F3C-28DFC64A1029} {257FD75C-4D17-4A23-A754-23BFD85887A0} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C} + {37955C79-D91D-423F-8C6C-8F5BCF4F28D4} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C} EndGlobalSection EndGlobal