简体   繁体   中英

Reverse engineering a DLL

I'm in the process of creating a profile editor for a game. Main issue is to deal with figuring out the structure of a binary file that is used to store all the data.

To do so, I decompiled the source code and I'm going through the code that deals with saving (and reading) to/from the save-file. However, I ran into a wall. I have code similar to this:

if (this.entity == Q.FG(45768))
{
//read data in one manner
}

else if (this.entity == Q.FG(96583))
{
//read data in another manner
}

This appears in more places and can have quite a few if then else statements.

Now, I know the value of this.entity since it's value has been read from the save-file earlier in the code. However, I don't know the value of Q.FG(int num) . The code is written in C#.

Q is an internal static class and FG(int num) is an internal static method that returns a string type object. In order to continue, I need to know the output of that method for at least a few numbers.

Another problem is that the method is using dlls resource files and names and providing those manually has given me invalid results. I can check the output since the output for one of the numbers must match this.entity .

Is there a way I can call this method from somewhere and see the result that it returns?

I'm open to any way of doing so, be it with programming and invoking the method, or using a tool and trying to catch the value during the games execution.

Is there any way to do so?

public class Program
{
    static void Main(string[] args)
    {
        MethodInfo info2 = Type.GetType("A.PW, Assembly-CSharp").GetMethod("G", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(int) }, null);

        System.Diagnostics.Debug.WriteLine("");
        System.Diagnostics.Debug.WriteLine("");
        System.Diagnostics.Debug.WriteLine((string) info2.Invoke(null, new object[] {75432}));
        System.Diagnostics.Debug.WriteLine((string)info2.Invoke(null, new object[] {45634}));
        System.Diagnostics.Debug.WriteLine((string)info2.Invoke(null, new object[] {70345}));
        System.Diagnostics.Debug.WriteLine((string)info2.Invoke(null, new object[] {3456}));
        System.Diagnostics.Debug.WriteLine((string)info2.Invoke(null, new object[] {4734}));
        System.Diagnostics.Debug.WriteLine("");
        System.Diagnostics.Debug.WriteLine("");
    } 
}

This does it if the assembly is referenced in the solution. Had trouble with getting the names exactly right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM