Skip to content

Commit

Permalink
Add a hack stub renderdocui.exe for auto-updated builds from v0.x
Browse files Browse the repository at this point in the history
* This is a temporary fix, in future we want to actually update
  shortcuts etc, but this is a low risk fix right before we release.
  • Loading branch information
baldurk committed Mar 5, 2018
1 parent dd7fd45 commit 8f565ca
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 0 deletions.
84 changes: 84 additions & 0 deletions qrenderdoc/renderdocui_stub.cpp
Original file line number Diff line number Diff line change
@@ -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 <windows.h>

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;
}
87 changes: 87 additions & 0 deletions qrenderdoc/renderdocui_stub.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Development|Win32">
<Configuration>Development</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Development|x64">
<Configuration>Development</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{37955C79-D91D-423F-8C6C-8F5BCF4F28D4}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>renderdocui_stub</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>renderdocui_stub</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<OutputDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</OutputDirectory>
<SolutionRelativeIntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</SolutionRelativeIntDir>
<CharacterSet>Unicode</CharacterSet>
<PrimaryOutput>renderdocui</PrimaryOutput>
<TargetName>renderdocui</TargetName>
</PropertyGroup>
<PropertyGroup>
<IntDir>$(SolutionDir)$(SolutionRelativeIntDir)</IntDir>
<IntermediateDirectory>$(IntDir)</IntermediateDirectory>
<OutDir>$(OutputDirectory)\</OutDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup>
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SolutionDir)renderdoc\api\replay</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="renderdocui_stub.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\renderdoccmd\renderdoccmd.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
9 changes: 9 additions & 0 deletions qrenderdoc/renderdocui_stub.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="renderdocui_stub.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\renderdoccmd\renderdoccmd.rc" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions renderdoc.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 8f565ca

Please sign in to comment.