//
// Copyright (c) Johnny Shaw. All rights reserved.
//
// File: source/ProcessHerpaderping/herpaderp.hpp
// Author: Johnny Shaw
// Abstract: Herpaderping Functionality
//
#pragma once
namespace Herpaderp
{
#pragma warning(push)
#pragma warning(disable : 4634) // xmldoc: discarding XML document comment for invalid target
///
/// Waits for process to exit before returning.
///
constexpr static uint32_t FlagWaitForProcess = 0x00000001ul;
///
/// Opens and hold the target file handle exclusive for as long as
/// reasonable. This flag is incompatible with FlagCloseFileEarly.
///
constexpr static uint32_t FlagHoldHandleExclusive = 0x00000002ul;
///
/// Flushes file buffers of target file.
///
constexpr static uint32_t FlagFlushFile = 0x00000004ul;
///
/// Closes the file handle early, before creating the initial thread
/// (before process notification would fire in the kernel). This flag is
/// not compatible with FlagHoldHandleExclusive.
///
constexpr static uint32_t FlagCloseFileEarly = 0x00000008ul;
///
/// Terminates the spawned process on success, this can be useful in some
/// automation environments. Not compatible with FlagWaitForProcess.
///
constexpr static uint32_t FlagKillSpawnedProcess = 0x00000010ul;
#pragma warning(pop)
///
/// Executes process herpaderping.
///
///
/// Source binary to execute.
///
///
/// File name to copy source to and obfuscate.
///
///
/// Optional, if provided the file is replaced with the content of this
/// file. If not provided the file is overwritten with a pattern.
///
///
/// Pattern used for obfuscation.
///
///
/// Flags controlling behavior of herpaderping (Herpaderp::FlagXxx).
///
///
/// Success if the herpaderping executed. Failure otherwise.
///
_Must_inspect_result_ HRESULT ExecuteProcess(
_In_ const std::wstring& SourceFileName,
_In_ const std::wstring& TargetFileName,
_In_opt_ const std::optional& ReplaceWithFileName,
_In_ std::span Pattern,
_In_ uint32_t Flags);
}