
Loader? by DJFender
By: a guest on
Jun 29th, 2010 | syntax:
C++ | size: 1.23 KB | hits: 155 | expires: Never
using System;
using System.Diagnostics;
using System.IO;
namespace ZuneBoards.DevelopmentFront.NativeAppLauncher.SD
{
static class Program
{
const string SourceDirectory = @"\gametitle\584E07D1\";
const string Payload = @"Content\nativeapp.exe";
static void Main(string[] args)
{
Run();
}
public static void Run()
{
// launch process
Trace.Write("Launching payload");
NativeMethods.PROCESS_INFORMATION pi = new NativeMethods.PROCESS_INFORMATION();
NativeMethods.CreateProcess(Path.Combine(SourceDirectory, Payload), string.Empty, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, IntPtr.Zero, null, ref pi);
Trace.WriteLine("...ok.");
// wait for exit
NativeMethods.WaitForSingleObject(pi.hProcess, -1);
// display exit code
int ecode;
NativeMethods.GetExitCodeProcess(pi.hProcess, out ecode);
Trace.WriteLine(string.Format("Payload exited with code {0}", ecode));
// clean up
NativeMethods.CloseHandle(pi.hThread);
NativeMethods.CloseHandle(pi.hProcess);
}
}
}