Added launcher

This commit is contained in:
AeonLucid
2021-10-25 05:40:20 +02:00
parent 079e57b29b
commit 377b99b4a6
24 changed files with 2399 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
using System;
using System.Runtime.InteropServices;
using Prospect.Launcher.Invoke.Structs;
namespace Prospect.Launcher.Invoke
{
internal static class Kernel32
{
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern bool CreateProcess(string lpApplicationName,
string lpCommandLine, IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
bool bInheritHandles, ProcessCreationFlags dwCreationFlags,
IntPtr lpEnvironment, string lpCurrentDirectory,
ref StartupInfo lpStartupInfo,
out ProcessInformation lpProcessInformation);
public static bool CreateProcess(
string lpApplicationName,
string lpCommandLine,
ProcessCreationFlags dwCreationFlags,
ref StartupInfo lpStartupInfo,
out ProcessInformation lpProcessInformation) => CreateProcess(lpApplicationName, lpCommandLine, IntPtr.Zero,
IntPtr.Zero, false, dwCreationFlags, IntPtr.Zero, null, ref lpStartupInfo, out lpProcessInformation);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
byte[] lpBuffer,
Int32 nSize,
out IntPtr lpNumberOfBytesRead);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern unsafe bool WriteProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
byte* lpBuffer,
Int32 nSize,
out IntPtr lpNumberOfBytesWritten
);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, uint flNewProtect, out uint lpflOldProtect);
}
}
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using Prospect.Launcher.Invoke.Structs;
namespace Prospect.Launcher.Invoke
{
public class PSAPI
{
[DllImport("psapi.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern int EnumProcessModules(IntPtr hProcess, [Out] IntPtr lphModule, uint cb, out uint lpcbNeeded);
[DllImport("psapi.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern bool GetModuleInformation(IntPtr hProcess, IntPtr hModule, out ModuleInfo lpModInfo, int cb);
[DllImport("psapi.dll")]
public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName, [In] [MarshalAs(UnmanagedType.U4)] int nSize);
}
}
@@ -0,0 +1,13 @@
using System;
using System.Runtime.InteropServices;
namespace Prospect.Launcher.Invoke.Structs
{
[StructLayout(LayoutKind.Sequential)]
public struct ModuleInfo
{
public IntPtr lpBaseOfDll;
public uint SizeOfImage;
public IntPtr EntryPoint;
}
}
@@ -0,0 +1,26 @@
using System;
namespace Prospect.Launcher.Invoke.Structs
{
[Flags]
internal enum ProcessCreationFlags : uint
{
ZERO_FLAG = 0x00000000,
CREATE_BREAKAWAY_FROM_JOB = 0x01000000,
CREATE_DEFAULT_ERROR_MODE = 0x04000000,
CREATE_NEW_CONSOLE = 0x00000010,
CREATE_NEW_PROCESS_GROUP = 0x00000200,
CREATE_NO_WINDOW = 0x08000000,
CREATE_PROTECTED_PROCESS = 0x00040000,
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000,
CREATE_SEPARATE_WOW_VDM = 0x00001000,
CREATE_SHARED_WOW_VDM = 0x00001000,
CREATE_SUSPENDED = 0x00000004,
CREATE_UNICODE_ENVIRONMENT = 0x00000400,
DEBUG_ONLY_THIS_PROCESS = 0x00000002,
DEBUG_PROCESS = 0x00000001,
DETACHED_PROCESS = 0x00000008,
EXTENDED_STARTUPINFO_PRESENT = 0x00080000,
INHERIT_PARENT_AFFINITY = 0x00010000
}
}
@@ -0,0 +1,14 @@
using System;
using System.Runtime.InteropServices;
namespace Prospect.Launcher.Invoke.Structs
{
[StructLayout(LayoutKind.Sequential)]
internal struct ProcessInformation
{
public IntPtr hProcess;
public IntPtr hThread;
public uint dwProcessId;
public uint dwThreadId;
}
}
@@ -0,0 +1,28 @@
using System;
using System.Runtime.InteropServices;
namespace Prospect.Launcher.Invoke.Structs
{
[StructLayout(LayoutKind.Sequential)]
internal struct StartupInfo
{
public uint cb;
public string lpReserved;
public string lpDesktop;
public string lpTitle;
public uint dwX;
public uint dwY;
public uint dwXSize;
public uint dwYSize;
public uint dwXCountChars;
public uint dwYCountChars;
public uint dwFillAttribute;
public uint dwFlags;
public short wShowWindow;
public short cbReserved2;
public IntPtr lpReserved2;
public IntPtr hStdInput;
public IntPtr hStdOutput;
public IntPtr hStdError;
}
}