-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
213 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers | ||
#include <Windows.h> | ||
#include <tchar.h> | ||
|
||
#define SKIP_UNTIL_HERE TEXT("--skip-until-here") | ||
#define IGNORE_ME TEXT("--ignore-me") | ||
|
||
int _tmain() | ||
{ | ||
DWORD dwExitCode = ERROR_SUCCESS; | ||
STARTUPINFO startupInfo; | ||
PROCESS_INFORMATION processInfo; | ||
_TCHAR* szCmdLine = nullptr; | ||
_TCHAR* szSkipArg = nullptr; | ||
_TCHAR* szIgnoreArg = nullptr; | ||
BOOL bRes = TRUE; | ||
|
||
::memset(&processInfo, 0, sizeof(processInfo)); | ||
::memset(&startupInfo, 0, sizeof(startupInfo)); | ||
startupInfo.cb = sizeof(startupInfo); | ||
|
||
szCmdLine = ::GetCommandLine(); | ||
if ((szCmdLine == nullptr) || (szCmdLine[0] == NULL)) | ||
{ | ||
goto LExit; | ||
} | ||
_tprintf(TEXT("\nParsing command line '%s'\n"), szCmdLine); //TODO Does that reveal passwords? It isn't logged by burn anyway | ||
|
||
// Search for first arg in full command line | ||
szSkipArg = _tcsstr(szCmdLine, SKIP_UNTIL_HERE); | ||
szIgnoreArg = _tcsstr(szCmdLine, IGNORE_ME); | ||
if (szIgnoreArg && (!szSkipArg || (szIgnoreArg < szSkipArg))) | ||
{ | ||
_tprintf(TEXT("Empty run requested: %s\n"), ::GetCommandLine()); | ||
goto LExit; | ||
} | ||
if (!szSkipArg) | ||
{ | ||
_tprintf(TEXT("Unidentified command line: '%s'\n"), szCmdLine); | ||
dwExitCode = ERROR_BAD_ARGUMENTS; | ||
goto LExit; | ||
} | ||
|
||
szCmdLine = szSkipArg + ::_tcsclen(SKIP_UNTIL_HERE); | ||
while ((szCmdLine[0] != NULL) && ::_istspace(szCmdLine[0])) | ||
{ | ||
++szCmdLine; | ||
} | ||
if (szCmdLine[0] == NULL) | ||
{ | ||
_tprintf(TEXT("Command line after skip is empty: %s\n"), ::GetCommandLine()); | ||
dwExitCode = ERROR_BAD_ARGUMENTS; | ||
goto LExit; | ||
} | ||
|
||
bRes = ::CreateProcess(nullptr, szCmdLine, nullptr, nullptr, FALSE, CREATE_NEW_PROCESS_GROUP, nullptr, nullptr, &startupInfo, &processInfo); | ||
if (!bRes) | ||
{ | ||
dwExitCode = ::GetLastError(); | ||
_tprintf(TEXT("Failed to launch process with command line '%s'. Exit code is %u\n"), szCmdLine, dwExitCode); | ||
goto LExit; | ||
} | ||
|
||
dwExitCode = ::WaitForSingleObject(processInfo.hProcess, INFINITE); | ||
if (dwExitCode != WAIT_OBJECT_0) | ||
{ | ||
_tprintf(TEXT("Failed to wait on process with command line '%s'. Wait error code is %u\n"), szCmdLine, dwExitCode); | ||
goto LExit; | ||
} | ||
|
||
bRes = ::GetExitCodeProcess(processInfo.hProcess, &dwExitCode); | ||
if (!bRes) | ||
{ | ||
dwExitCode = ::GetLastError(); | ||
_tprintf(TEXT("Failed to get exit code of process with command line '%s'. Error code is %u\n"), szCmdLine, dwExitCode); | ||
goto LExit; | ||
} | ||
|
||
_tprintf(TEXT("Process exit code is %u\n"), dwExitCode); | ||
|
||
LExit: | ||
if (processInfo.hThread != NULL) | ||
{ | ||
::CloseHandle(processInfo.hThread); | ||
} | ||
if (processInfo.hProcess != NULL) | ||
{ | ||
::CloseHandle(processInfo.hProcess); | ||
} | ||
|
||
return dwExitCode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectCapability Include="PackageReferences" /> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == ''">native,Version=v0.0</NuGetTargetMoniker> | ||
<ProjectGuid>{b729fb3c-25cf-4216-940d-69ea78779cd7}</ProjectGuid> | ||
<RootNamespace>DeferredExePackage</RootNamespace> | ||
<TargetName>DeferredExePackage</TargetName> | ||
<Keyword>Win32Proj</Keyword> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<CharacterSet>Unicode</CharacterSet> | ||
<LinkIncremental Condition="'$(Configuration)'=='Release'">false</LinkIncremental> | ||
<ResolveNuGetPackages>false</ResolveNuGetPackages> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<ConformanceMode>true</ConformanceMode> | ||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="DeferredExePackage.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="TidyBuild" /> | ||
</ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="DeferredExePackage.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ResourceCompile Include="$(IntDir)\Version.rc"> | ||
<Filter>Resource Files</Filter> | ||
</ResourceCompile> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters