rendered paste bodypublic class Launcher
{
[DllImport( "uog.dll", EntryPoint = "UOG_Launch", ExactSpelling = true, CallingConvention = CallingConvention.StdCall )]
public static extern bool UOG_Launch( int client );
[DllImport( "uog.dll", EntryPoint = "UOG_Client_Launch", ExactSpelling = true, CallingConvention = CallingConvention.StdCall )]
public static extern bool UOG_Client_Launch( string clientPath );
[DllImport( "uog.dll", EntryPoint = "UOG_Client_Terminate", ExactSpelling = true, CallingConvention = CallingConvention.StdCall )]
public static extern bool UOG_Client_Terminate();
[DllImport( "uog.dll", EntryPoint = "UOG_Client_Patch", ExactSpelling = true, CallingConvention = CallingConvention.StdCall )]
public static extern bool UOG_Client_Patch();
[DllImport( "uog.dll", EntryPoint = "UOG_Client_Resume", ExactSpelling = true, CallingConvention = CallingConvention.StdCall )]
public static extern bool UOG_Client_Resume();
public static void Launch()
{
string path = GetExePath( "Ultima Online" );
Directory.SetCurrentDirectory( path );
LaunchDecryptedClient( "client.exe" );
}
private static string GetExePath( string subName )
{
try
{
using( RegistryKey key = Registry.LocalMachine.OpenSubKey( String.Format( @"SOFTWARE\Origin Worlds Online\{0}\1.0", subName ) ) )
{
if( key == null )
return null;
string v = key.GetValue( "ExePath" ) as string;
if( v == null || v.Length <= 0 )
return null;
if( !File.Exists( v ) )
return null;
v = Path.GetDirectoryName( v );
if( v == null )
return null;
return v;
}
}
catch
{
return null;
}
}
public static void LaunchDecryptedClient( string path )
{
if( !UOG_Client_Launch( path ) )
throw new ApplicationException( "UOG_Client_Launch error" );
if( !UOG_Client_Patch() )
{
UOG_Client_Terminate();
throw new ApplicationException( "UOG_Client_Patch error" );
}
if( !UOG_Client_Resume() )
{
UOG_Client_Terminate();
throw new ApplicationException( "UOG_Client_Resume error" );
}
}
}