Skip to content

Commit

Permalink
Use standard .NET naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Jan 19, 2013
1 parent fa6c10b commit 211d1b6
Show file tree
Hide file tree
Showing 319 changed files with 10,068 additions and 10,068 deletions.
32 changes: 16 additions & 16 deletions AssemblyData/AssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ class AssemblyResolver {
List<string> assemblySearchPaths = new List<string>();

public AssemblyResolver() {
AppDomain.CurrentDomain.AssemblyResolve += assemblyResolve;
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;
}

void addAssemblySearchPath(string path) {
void AddAssemblySearchPath(string path) {
if (assemblySearchPathsDict.ContainsKey(path))
return;
assemblySearchPathsDict[path] = true;
assemblySearchPaths.Add(path);
}

Assembly get(string assemblyFullName) {
Assembly Get(string assemblyFullName) {
var asmName = new AssemblyName(assemblyFullName);

Assembly assembly;
Expand All @@ -53,8 +53,8 @@ Assembly get(string assemblyFullName) {
}

static string[] assemblyExtensions = new string[] { ".dll", ".exe" };
Assembly assemblyResolve(object sender, ResolveEventArgs args) {
var assembly = get(args.Name);
Assembly AssemblyResolve(object sender, ResolveEventArgs args) {
var assembly = Get(args.Name);
if (assembly != null)
return assembly;

Expand All @@ -65,8 +65,8 @@ Assembly assemblyResolve(object sender, ResolveEventArgs args) {
var filename = Path.Combine(path, asmName.Name + ext);
if (!new FileInfo(filename).Exists)
continue;
addConfigFile(filename + ".config");
return addAssembly(Assembly.LoadFile(filename));
AddConfigFile(filename + ".config");
return AddAssembly(Assembly.LoadFile(filename));
}
catch (IOException) {
}
Expand All @@ -86,12 +86,12 @@ Assembly assemblyResolve(object sender, ResolveEventArgs args) {
return null;
}

public Assembly load(string filename) {
addConfigFile(filename + ".config");
return addAssembly(loadFile(filename));
public Assembly Load(string filename) {
AddConfigFile(filename + ".config");
return AddAssembly(LoadFile(filename));
}

Assembly loadFile(string filename) {
Assembly LoadFile(string filename) {
try {
return Assembly.LoadFrom(filename);
}
Expand All @@ -101,16 +101,16 @@ Assembly loadFile(string filename) {
}
}

Assembly addAssembly(Assembly assembly) {
Assembly AddAssembly(Assembly assembly) {
var asmName = assembly.GetName();
assemblies[asmName.FullName] = assembly;
assemblies[asmName.Name] = assembly;
return assembly;
}

void addConfigFile(string configFilename) {
var dirName = Utils.getDirName(Utils.getFullPath(configFilename));
addAssemblySearchPath(dirName);
void AddConfigFile(string configFilename) {
var dirName = Utils.GetDirName(Utils.GetFullPath(configFilename));
AddAssemblySearchPath(dirName);

try {
using (var xmlStream = new FileStream(configFilename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
Expand All @@ -124,7 +124,7 @@ void addConfigFile(string configFilename) {
if (string.IsNullOrEmpty(privatePath))
continue;
foreach (var path in privatePath.Split(';'))
addAssemblySearchPath(Path.Combine(dirName, path));
AddAssemblySearchPath(Path.Combine(dirName, path));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions AssemblyData/AssemblyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ You should have received a copy of the GNU General Public License

namespace AssemblyServer {
public static class Start {
public static int main(string[] args) {
public static int Main2(string[] args) {
if (args.Length != 2)
Environment.Exit(1);
var channelName = args[0];
var uri = args[1];

var service = new AssemblyService();
startServer(service, channelName, uri);
service.waitExit();
StartServer(service, channelName, uri);
service.WaitExit();
return 0;
}

static void startServer(AssemblyService service, string name, string uri) {
static void StartServer(AssemblyService service, string name, string uri) {
var props = new Hashtable();
props["portName"] = name;
var provider = new BinaryServerFormatterSinkProvider();
Expand Down
62 changes: 31 additions & 31 deletions AssemblyData/AssemblyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,43 @@ public class AssemblyService : MarshalByRefObject, IAssemblyService {
AssemblyResolver assemblyResolver = new AssemblyResolver();
bool installCompileMethodCalled = false;

public void doNothing() {
public void DoNothing() {
}

public void exit() {
public void Exit() {
exitEvent.Set();
}

public void waitExit() {
public void WaitExit() {
exitEvent.WaitOne();
}

public override object InitializeLifetimeService() {
return null;
}

void checkStringDecrypter() {
void CheckStringDecrypter() {
if (stringDecrypter == null)
throw new ApplicationException("setStringDecrypterType() hasn't been called yet.");
}

void checkAssembly() {
void CheckAssembly() {
if (assembly == null)
throw new ApplicationException("loadAssembly() hasn't been called yet.");
}

public void loadAssembly(string filename) {
public void LoadAssembly(string filename) {
if (assembly != null)
throw new ApplicationException("Only one assembly can be explicitly loaded");
try {
assembly = assemblyResolver.load(filename);
assembly = assemblyResolver.Load(filename);
}
catch (BadImageFormatException) {
throw new ApplicationException(string.Format("Could not load assembly {0}. Maybe it's 32-bit or 64-bit only?", filename));
}
}

public void setStringDecrypterType(StringDecrypterType type) {
public void SetStringDecrypterType(StringDecrypterType type) {
if (stringDecrypter != null)
throw new ApplicationException("StringDecrypterType already set");

Expand All @@ -87,25 +87,25 @@ public void setStringDecrypterType(StringDecrypterType type) {
}
}

public int defineStringDecrypter(int methodToken) {
checkStringDecrypter();
var methodInfo = findMethod(methodToken);
public int DefineStringDecrypter(int methodToken) {
CheckStringDecrypter();
var methodInfo = FindMethod(methodToken);
if (methodInfo == null)
throw new ApplicationException(string.Format("Could not find method {0:X8}", methodToken));
if (methodInfo.ReturnType != typeof(string) && methodInfo.ReturnType != typeof(object))
throw new ApplicationException(string.Format("Method return type must be string or object: {0}", methodInfo));
return stringDecrypter.defineStringDecrypter(methodInfo);
return stringDecrypter.DefineStringDecrypter(methodInfo);
}

public object[] decryptStrings(int stringDecrypterMethod, object[] args, int callerToken) {
checkStringDecrypter();
var caller = getCaller(callerToken);
public object[] DecryptStrings(int stringDecrypterMethod, object[] args, int callerToken) {
CheckStringDecrypter();
var caller = GetCaller(callerToken);
foreach (var arg in args)
SimpleData.unpack((object[])arg);
return SimpleData.pack(stringDecrypter.decryptStrings(stringDecrypterMethod, args, caller));
SimpleData.Unpack((object[])arg);
return SimpleData.Pack(stringDecrypter.DecryptStrings(stringDecrypterMethod, args, caller));
}

MethodBase getCaller(int callerToken) {
MethodBase GetCaller(int callerToken) {
try {
return assembly.GetModules()[0].ResolveMethod(callerToken);
}
Expand All @@ -114,8 +114,8 @@ MethodBase getCaller(int callerToken) {
}
}

MethodInfo findMethod(int methodToken) {
checkAssembly();
MethodInfo FindMethod(int methodToken) {
CheckAssembly();

foreach (var module in assembly.GetModules()) {
var method = module.ResolveMethod(methodToken) as MethodInfo;
Expand All @@ -126,28 +126,28 @@ MethodInfo findMethod(int methodToken) {
return null;
}

public void installCompileMethod(DecryptMethodsInfo decryptMethodsInfo) {
public void InstallCompileMethod(DecryptMethodsInfo decryptMethodsInfo) {
if (installCompileMethodCalled)
throw new ApplicationException("installCompileMethod() has already been called");
installCompileMethodCalled = true;
DynamicMethodsDecrypter.Instance.DecryptMethodsInfo = decryptMethodsInfo;
DynamicMethodsDecrypter.Instance.installCompileMethod();
DynamicMethodsDecrypter.Instance.InstallCompileMethod();
}

public void loadObfuscator(string filename) {
loadAssembly(filename);
public void LoadObfuscator(string filename) {
LoadAssembly(filename);
DynamicMethodsDecrypter.Instance.Module = assembly.ManifestModule;
DynamicMethodsDecrypter.Instance.loadObfuscator();
DynamicMethodsDecrypter.Instance.LoadObfuscator();
}

public bool canDecryptMethods() {
checkAssembly();
return DynamicMethodsDecrypter.Instance.canDecryptMethods();
public bool CanDecryptMethods() {
CheckAssembly();
return DynamicMethodsDecrypter.Instance.CanDecryptMethods();
}

public DumpedMethods decryptMethods() {
checkAssembly();
return DynamicMethodsDecrypter.Instance.decryptMethods();
public DumpedMethods DecryptMethods() {
CheckAssembly();
return DynamicMethodsDecrypter.Instance.DecryptMethods();
}
}
}
10 changes: 5 additions & 5 deletions AssemblyData/DelegateStringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class DelegateStringDecrypter : IStringDecrypter {
delegate string DecryptString(object[] args);
List<DecryptString> stringDecryptMethods = new List<DecryptString>();

public int defineStringDecrypter(MethodInfo method) {
stringDecryptMethods.Add(buildDynamicMethod(method));
public int DefineStringDecrypter(MethodInfo method) {
stringDecryptMethods.Add(BuildDynamicMethod(method));
return stringDecryptMethods.Count - 1;
}

public object[] decryptStrings(int stringDecrypterMethod, object[] args, MethodBase caller) {
public object[] DecryptStrings(int stringDecrypterMethod, object[] args, MethodBase caller) {
if (stringDecrypterMethod > stringDecryptMethods.Count)
throw new ApplicationException("Invalid string decrypter method");

Expand All @@ -43,9 +43,9 @@ public object[] decryptStrings(int stringDecrypterMethod, object[] args, MethodB
return rv;
}

DecryptString buildDynamicMethod(MethodInfo method) {
DecryptString BuildDynamicMethod(MethodInfo method) {
var dm = new DynamicMethod("", typeof(string), new Type[] { typeof(object[]) }, typeof(DelegateStringDecrypter), true);
Utils.addCallStringDecrypterMethodInstructions(method, dm.GetILGenerator());
Utils.AddCallStringDecrypterMethodInstructions(method, dm.GetILGenerator());
return (DecryptString)dm.CreateDelegate(typeof(DecryptString));
}
}
Expand Down
14 changes: 7 additions & 7 deletions AssemblyData/EmuStringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ public DecryptInfo(MethodInfo method) {
}
}

public int defineStringDecrypter(MethodInfo method) {
public int DefineStringDecrypter(MethodInfo method) {
decryptInfos.Add(new DecryptInfo(method));
return decryptInfos.Count - 1;
}

public object[] decryptStrings(int stringDecrypterMethod, object[] args, MethodBase caller) {
public object[] DecryptStrings(int stringDecrypterMethod, object[] args, MethodBase caller) {
var decryptInfo = decryptInfos[stringDecrypterMethod];
if (decryptInfo.decryptString == null)
decryptInfo.decryptString = createDecryptString(decryptInfo.method);
decryptInfo.decryptString = CreateDecryptString(decryptInfo.method);

methodsRewriter.setCaller(decryptInfo.decryptString, caller);
methodsRewriter.SetCaller(decryptInfo.decryptString, caller);
var result = new object[args.Length];
for (int i = 0; i < args.Length; i++)
result[i] = decryptInfo.decryptString((object[])args[i]);
return result;
}

RewrittenMethod createDecryptString(MethodInfo method) {
methodsRewriter.createMethod(method);
return methodsRewriter.createDelegate(method);
RewrittenMethod CreateDecryptString(MethodInfo method) {
methodsRewriter.CreateMethod(method);
return methodsRewriter.CreateDelegate(method);
}
}
}
20 changes: 10 additions & 10 deletions AssemblyData/IAssemblyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ public enum StringDecrypterType {
}

public interface IAssemblyService {
void doNothing();
void exit();
void DoNothing();
void Exit();

void loadAssembly(string filename);
void LoadAssembly(string filename);

void setStringDecrypterType(StringDecrypterType type);
int defineStringDecrypter(int methodToken);
object[] decryptStrings(int stringDecrypterMethod, object[] args, int callerToken);
void SetStringDecrypterType(StringDecrypterType type);
int DefineStringDecrypter(int methodToken);
object[] DecryptStrings(int stringDecrypterMethod, object[] args, int callerToken);

void installCompileMethod(DecryptMethodsInfo decryptMethodsInfo);
void loadObfuscator(string filename);
bool canDecryptMethods();
DumpedMethods decryptMethods();
void InstallCompileMethod(DecryptMethodsInfo decryptMethodsInfo);
void LoadObfuscator(string filename);
bool CanDecryptMethods();
DumpedMethods DecryptMethods();
}
}
4 changes: 2 additions & 2 deletions AssemblyData/IStringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You should have received a copy of the GNU General Public License

namespace AssemblyData {
interface IStringDecrypter {
int defineStringDecrypter(MethodInfo method);
object[] decryptStrings(int stringDecrypterMethod, object[] args, MethodBase caller);
int DefineStringDecrypter(MethodInfo method);
object[] DecryptStrings(int stringDecrypterMethod, object[] args, MethodBase caller);
}
}
4 changes: 2 additions & 2 deletions AssemblyData/SimpleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override string ToString() {
}

public static class SimpleData {
public static object[] pack(object[] args) {
public static object[] Pack(object[] args) {
for (int i = 0; i < args.Length; i++) {
var s = args[i] as string;
if (s != null)
Expand All @@ -60,7 +60,7 @@ public static object[] pack(object[] args) {
return args;
}

public static object[] unpack(object[] args) {
public static object[] Unpack(object[] args) {
for (int i = 0; i < args.Length; i++) {
var s = args[i] as MyString;
if (s != null)
Expand Down
Loading

0 comments on commit 211d1b6

Please sign in to comment.