Jump to content

I disassembled Assembly-CSharp. What do I need to compile it?


Crystalmir

Recommended Posts

I tried to open one of the file in visual studio 2010 and the IDE is confused because of characters like this: private bool ᢅᙃ; private bool ᢆᙃ = true; private bool ᢇᙃ = true; private Clipping ᡱᙃ; private Material ᢂᙃ; private Material ᢃᙃ; private Material ᡬᙃ; private Mesh ᡭᙃ; private Mesh ᡮᙃ; private MeshFilter ᡯᙃ; private MeshRenderer ᡰᙃ; private int[] ᢄᙃ; private Transform ᡫᙃ; private Vector2 ᢵᙃ; private Vector4 ᡲᙃ; do I need to create an Unity project and rename all the variables manually?
Link to comment
Share on other sites

The names are obfuscated, so you would need to 'deobfuscate' it before you decompile it by giving everything an individual name (keep in mind that virtual function names must be compatible to their parent virtual functions). The decompiler itself will most likely do some bugs. As an example, .NET Reflector directly references the getter/setter function names instead of the property name. I would not recommend you to recompile it that way (apart from that an IDE like MonoDevelop (aka Xamarin Studio) that allows you to reference to 7 Days to Die's mscorlib.dll would be a better choice than Visual Studio as some conflicts between Microsoft's .NET Framework and Mono (which is used by Unity) might occur). Instead, I prefer to use a decompiler plugin like Reflexil that allows you to directly modify Assembly-CSharp (by modifying the IL code). You can modify Assembly-CSharp to make it call methods of an external C# dll so you don't have to write everything in IL and start over when they release a new update. If you aren't experienced in reading/writing assembler languages (like x86 MASM/IL) it probably isn't easy to learn IL. Apart from that, writing IL code is very time-consuming.
Link to comment
Share on other sites

Any idea what the main function or a function that is called often that I could hook into before the game load so I could load an external dll first then call it from the blockmanager again and different other places to make something like minecraft "Custom Stuff" Mod ?
Link to comment
Share on other sites

I usually hook in MainMenuMono.Awake. It's a decent place at startup. Also, may I suggest using this place to add to the debug log that the DLL is modified, I usually place something like this at the end of that function to tell the Devs if they get a bug complaint using one of my DLL mods. [CODE]Debug.Log("[Mod Loaded] Reload Reset");[/CODE]I also only work with decompiled IL code. I can do anything with IL that you could do with C#, plus my modified code is identical to the original code except for my changes. If you decompile to C# and recompile it can make totally different code. I know some people have it working, and kudos to them, but I prefer to keep everything as close to original as I can.
Link to comment
Share on other sites

I'm not going to decompile and recompile directly , I was planning on using an external DLL and/or an external .EXE that would be referenced by Assembly-Csharp and called from somewhere. This is all new to me so I have to spend some time to digest it. I guess what I would mainly need to do is: 1) Overrides some constructors/methods so that the constructors/methods in my external DLL get called instead of the one in Assembly-CSharp (when I need to add additional properties/variable to a Class, such as 'public int value' for creating a basic economy for example 2) Add some methods to which some list of the data managed by the game would be passed by reference so that the method could modify the data or add things to it. 3) Use structural design patterns, such as facade, to make it easier to code a mod ex: by wrapping the class named ᠙ in a class named ForgeController
Link to comment
Share on other sites

DerPopo I think has done more work in that area, but I don't think a simple code injector will work for what you are suggesting. Changing variables to public is easy when you decompile to IL. I often make variables public, but doing so requires a modified DLL. For adding a DLL, can't you just call your prefered C# function on start up to load the DLL? There are a few ways to do it. Any valid C# library should work. That's what dotNet managed code is about, isn't it? LoadLibary or whatever? I've kind of strayed away from DLL modding, but that should work. That said, I inject everything with IL. Sometime I compile complex functions in C# to IL, and copy them over, but always in IL. DerPopo can probably answer better about a DLL injector, he's done it before with his Survival Kit. I'm not home so I can't really test any of this.
Link to comment
Share on other sites

I patch Assembly-CSharp using [URL=http://www.mono-project.com/Cecil]Mono.Cecil[/URL]. It allows you to change properties/IL code but the changes don't affect the running application. You have to save the modificated assembly instead (AssemblyDefinition.Write allows you to do that). I don't think that there are any tools out that modify running assemblies for .NET/Mono. To make Assembly-CSharp load an external assembly, you simply need a call to a function in it somewhere. The decompiler plugin Reflexil adds the reference to your dll automatically. Mono.Cecil requires you to use ModuleDefinition.Import(xyzDefinition/Reference) as opcode parameter if you reference something (like methods/fields) with opcodes like call/ldfld, even if it's not in your own dll. By the way, I use GameManager.cctor to initialize SurvivalKit and the plugins. As mono is open source, you can modify it to make changing loaded types possible. However, unity uses a modified mono (as far as I know) so you might have to modify the unity mono version using a x86/x64 disassembler and assembler. This is much more complicated than IL and therefore I don't think it's worth the effort.
Link to comment
Share on other sites

I used ILMerge to merge my DLL and the game DLL. New methods and class were added by it into the game DLL, by merging my definition and the game DLL définitions of the same class. BUT it doesn't merge methods. I'd like a tool that would let me merge this: public class Groups { static Groups() { Groups.debugthings(); } } with this: static Groups() { Groups.ᡣᙃ = new List(); } and would let me insert my compiled code (so my DLL, same class, same method) into the game DLL (same class, same method) and let me decide to add it before or after the Game DLL code so I'd end up with this: static Groups() { Groups.debugthings(); Groups.ᡣᙃ = new List(); } That's PROBLEM #1. PROBLEM #2 is how do I debug the game DLL(can't without source?) without paying 200$ for Reflector Pro? Are there alternative Tools? I'd like to see how the game manage blocks for example and actually see the list of blocks live while the game is running in a _human-readable format_.
Link to comment
Share on other sites

My Assembly-CSharp patcher for SurvivalKit also deobfuscates it. If you want a deobfuscated dll (with SurvivalKit integrated), here is one : [url]http://7daystodie.com/forums/showthread.php?6701-MOD-SurvivalKit-plugin-system[/url] Here's the source code of my (outdated) Assembly-CSharp patcher for the unity engine fixes : [url]https://mega.co.nz/#!DIZy3LZD!wQG6_r599_HL4qrP8wObpQ3pBvATgeMF5BiooN1lnks[/url] It inserts a call to my patcher function at the beginning of GameManager..cctor() . Maybe this debugger plugin for .NET Reflector helps you : [url]http://deblector.codeplex.com/[/url]
Link to comment
Share on other sites

The 2nd link just contains binaries and no source code, so it might be interesting for someone else if you correct the link. After several weeks with no results I decided to just do something else. I'll come back in a year or so and see what state the game is at and wheter it support mods.
Link to comment
Share on other sites

[QUOTE=Crystalmir;89468]After several weeks with no results I decided to just do something else. I'll come back in a year or so and see what state the game is at and wheter it support mods.[/QUOTE] See, there's the difference between modders like you, and modders like DerPopo and I. We thrive on what hasn't been figured out. If it's figured out, it's boring. I love modding new games because there are things to still figure out. That's the thrill for me. Can I do something no one else has done yet? I love it. When modding becomes mainstream I lose interest. For example, I made the first Night Eye spell in Skyrim that functioned like every other in game spell. Other people added it, but I made it work like regular spells. Once the creation kit came out there were 50 different versions of what I had done in HEX. You're right though. If you want instant gratification from modding, you should wait for us explorers to figure it out.
Link to comment
Share on other sites

[QUOTE=grimreefer24601;92133]See, there's the difference between modders like you, and modders like DerPopo and I. We thrive on what hasn't been figured out. If it's figured out, it's boring. I love modding new games because there are things to still figure out. That's the thrill for me. Can I do something no one else has done yet? I love it. When modding becomes mainstream I lose interest. For example, I made the first Night Eye spell in Skyrim that functioned like every other in game spell. Other people added it, but I made it work like regular spells. Once the creation kit came out there were 50 different versions of what I had done in HEX. You're right though. If you want instant gratification from modding, you should wait for us explorers to figure it out.[/QUOTE] Let's says you bought a car. After one month you still haven't figured out how to make it start. That's why I gave up. I wasted 1 month of my life I'm never ever getting back with absolutely no progress at all. Why would I keep wasting my time when I obviously don't have the required skills to make this work? I'm not very interested in beating a dead horse.... Second reason is that I lost two houses when the patch came because the block ids got switched around and my cement blocks were now Canned tuna. With no edit tools around, I'm certainly not going to lose another week redoing the same houses over and over again block by block.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...