好友
阅读权限10
听众
最后登录1970-1-1
|
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
namespace netz
{
// Token: 0x02000002 RID: 2
public class NetzStarter
{
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
[STAThread]
public static int Main(string[] args)
{
int result;
try
{
NetzStarter.InitXR();
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += NetzStarter.NetzResolveEventHandler;
result = NetzStarter.StartApp(args);
}
catch (Exception ex)
{
string text = " .NET Runtime: ";
NetzStarter.Log(string.Concat(new object[]
{
"#Error: ",
ex.GetType().ToString(),
Environment.NewLine,
ex.Message,
Environment.NewLine,
ex.StackTrace,
Environment.NewLine,
ex.InnerException,
Environment.NewLine,
"Using",
text,
Environment.Version.ToString(),
Environment.NewLine,
"Created with",
text,
"4.0.30319.42000"
}));
result = -1;
}
return result;
}
// Token: 0x06000002 RID: 2 RVA: 0x00002154 File Offset: 0x00000354
private static void InitXR()
{
try
{
string text = "file:\\";
string text2 = "-netz.resources";
string text3 = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
if (text3.StartsWith(text))
{
text3 = text3.Substring(text.Length, text3.Length - text.Length);
}
string[] files = Directory.GetFiles(text3, "*" + text2);
if (files != null && files.Length > 0)
{
NetzStarter.xrRm = new ArrayList();
for (int i = 0; i < files.Length; i++)
{
string text4 = Path.GetFileName(files[i]);
text4 = text4.Substring(0, text4.Length - text2.Length);
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(text4 + "-netz", text3, null);
if (resourceManager != null)
{
NetzStarter.xrRm.Add(resourceManager);
}
}
}
}
catch
{
}
}
// Token: 0x06000003 RID: 3 RVA: 0x00002238 File Offset: 0x00000438
public static int StartApp(string[] args)
{
byte[] resource = NetzStarter.GetResource("A6C24BF5-3690-4982-887E-11E1B159B249");
if (resource == null)
{
throw new Exception("application data cannot be found");
}
Assembly assembly = NetzStarter.GetAssembly(resource);
return NetzStarter.InvokeApp(assembly, args);
}
// Token: 0x06000004 RID: 4 RVA: 0x00002270 File Offset: 0x00000470
private static Assembly GetAssembly(byte[] data)
{
MemoryStream memoryStream = null;
Assembly result = null;
try
{
memoryStream = NetzStarter.UnZip(data);
memoryStream.Seek(0L, SeekOrigin.Begin);
result = Assembly.Load(memoryStream.ToArray());
}
finally
{
if (memoryStream != null)
{
memoryStream.Close();
}
memoryStream = null;
}
return result;
}
// Token: 0x06000005 RID: 5 RVA: 0x000022C0 File Offset: 0x000004C0
private static Assembly LoadZipDll()
{
Assembly result = null;
MemoryStream memoryStream = null;
try
{
byte[] resource = NetzStarter.GetResource("zip.dll");
if (resource == null)
{
return null;
}
memoryStream = new MemoryStream(resource);
result = Assembly.Load(memoryStream.ToArray());
}
catch
{
result = null;
}
finally
{
if (memoryStream != null)
{
memoryStream.Close();
}
memoryStream = null;
}
return result;
}
// Token: 0x06000006 RID: 6 RVA: 0x0000232C File Offset: 0x0000052C
private static int InvokeApp(Assembly assembly, string[] args)
{
MethodInfo entryPoint = assembly.EntryPoint;
ParameterInfo[] parameters = entryPoint.GetParameters();
object[] parameters2 = null;
if (parameters != null && parameters.Length > 0)
{
parameters2 = new object[] { args };
}
object obj = entryPoint.Invoke(null, parameters2);
if (obj == null)
{
return 0;
}
if (obj is int)
{
return (int)obj;
}
return 0;
}
// Token: 0x06000007 RID: 7 RVA: 0x00002380 File Offset: 0x00000580
private static Assembly NetzResolveEventHandler(object sender, ResolveEventArgs args)
{
if (NetzStarter.inResourceResolveFlag)
{
return null;
}
return NetzStarter.GetAssemblyByName(args.Name);
}
// Token: 0x06000008 RID: 8 RVA: 0x00002398 File Offset: 0x00000598
private static byte[] GetResource(string id)
{
byte[] array = null;
if (NetzStarter.rm == null)
{
NetzStarter.rm = new ResourceManager("app", Assembly.GetExecutingAssembly());
}
try
{
NetzStarter.inResourceResolveFlag = true;
string name = NetzStarter.MangleDllName(id);
if (array == null && NetzStarter.xrRm != null)
{
for (int i = 0; i < NetzStarter.xrRm.Count; i++)
{
try
{
ResourceManager resourceManager = (ResourceManager)NetzStarter.xrRm[i];
if (resourceManager != null)
{
array = (byte[])resourceManager.GetObject(name);
}
}
catch
{
}
if (array != null)
{
break;
}
}
}
if (array == null)
{
array = (byte[])NetzStarter.rm.GetObject(name);
}
}
finally
{
NetzStarter.inResourceResolveFlag = false;
}
return array;
}
// Token: 0x06000009 RID: 9 RVA: 0x00002454 File Offset: 0x00000654
private static string MangleDllName(string dll)
{
string text = dll.Replace(" ", "!1");
text = text.Replace(",", "!2");
text = text.Replace(".Resources", "!3");
text = text.Replace(".resources", "!3");
return text.Replace("Culture", "!4");
}
// Token: 0x0600000A RID: 10 RVA: 0x000024BC File Offset: 0x000006BC
private static MemoryStream UnZip(byte[] data)
{
if (data == null)
{
return null;
}
MemoryStream memoryStream = null;
MemoryStream memoryStream2 = null;
InflaterInputStream inflaterInputStream = null;
try
{
memoryStream = new MemoryStream(data);
memoryStream2 = new MemoryStream();
inflaterInputStream = new InflaterInputStream(memoryStream);
byte[] array = new byte[data.Length];
for (;;)
{
int num = inflaterInputStream.Read(array, 0, array.Length);
if (num <= 0)
{
break;
}
memoryStream2.Write(array, 0, num);
}
memoryStream2.Flush();
memoryStream2.Seek(0L, SeekOrigin.Begin);
}
finally
{
if (memoryStream != null)
{
memoryStream.Close();
}
if (inflaterInputStream != null)
{
inflaterInputStream.Close();
}
memoryStream = null;
inflaterInputStream = null;
}
return memoryStream2;
}
// Token: 0x0600000B RID: 11 RVA: 0x0000254C File Offset: 0x0000074C
private static void Log(string s)
{
MessageBox.Show(null, s, "Error");
}
// Token: 0x0600000C RID: 12 RVA: 0x0000255C File Offset: 0x0000075C
private static Assembly GetAssemblyByName(string name)
{
if (name == null)
{
return null;
}
if (NetzStarter.cache == null)
{
NetzStarter.cache = new HybridDictionary();
}
name = name.Trim();
string key = name.ToLower();
if (NetzStarter.cache[key] != null)
{
return (Assembly)NetzStarter.cache[key];
}
StringDictionary stringDictionary = NetzStarter.ParseAssName(name);
string text = stringDictionary[NetzStarter.Name];
if (text == null)
{
return null;
}
if (text.ToLower().Equals("zip"))
{
Assembly assembly = NetzStarter.LoadZipDll();
NetzStarter.cache[key] = assembly;
return assembly;
}
byte[] resource = NetzStarter.GetResource(name);
if (resource == null)
{
resource = NetzStarter.GetResource(name.ToLower());
}
if (resource == null)
{
resource = NetzStarter.GetResource(text);
}
if (resource == null)
{
resource = NetzStarter.GetResource(text.ToLower());
}
if (resource == null)
{
resource = NetzStarter.GetResource(Path.GetFileNameWithoutExtension(text).ToLower());
}
if (resource == null)
{
return null;
}
Assembly assembly2 = NetzStarter.GetAssembly(resource);
NetzStarter.cache[key] = assembly2;
return assembly2;
}
// Token: 0x0600000D RID: 13 RVA: 0x00002650 File Offset: 0x00000850
private static StringDictionary ParseAssName(string fullAssName)
{
StringDictionary stringDictionary = new StringDictionary();
string[] array = fullAssName.Split(new char[] { ',' });
for (int i = 0; i < array.Length; i++)
{
string[] array2 = array[i].Trim(new char[] { ' ', ',' }).Split(new char[] { '=' });
if (array2.Length < 2)
{
stringDictionary.Add(NetzStarter.Name, array2[0]);
}
else
{
stringDictionary.Add(array2[0].Trim(new char[] { ' ', '=' }), array2[1].Trim(new char[] { ' ', '=' }));
}
}
return stringDictionary;
}
// Token: 0x04000001 RID: 1
private static readonly string Name = "Name";
// Token: 0x04000002 RID: 2
private static readonly string Culture = "Culture";
// Token: 0x04000003 RID: 3
private static readonly string NetzSuffix = "z.dll";
// Token: 0x04000004 RID: 4
private static HybridDictionary cache = null;
// Token: 0x04000005 RID: 5
private static ResourceManager rm = null;
// Token: 0x04000006 RID: 6
private static ArrayList xrRm = null;
// Token: 0x04000007 RID: 7
private static bool inResourceResolveFlag = false;
}
}
|
免费评分
-
查看全部评分
|