Jump to content

Modpatcher


dreadylein

Recommended Posts

  • Replies 249
  • Created
  • Last Reply

Top Posters In This Topic

Does anyone know if the ModPatcher author ever made his code open-source? ModPatcher was pretty convenient. However, if I have to instruct people to copy over the DefaultGameCore.ini file in the local folder and patch their EXE then that solution will work as well.

 

I never bothered with it and the code was a damn mess anyway ;)

But there is no Obfuscation so decompiling it should yield pretty proper code.

 

 

But the only intresting parts are this:


        [DllImport("kernel32", CharSet = CharSet.Unicode)]
        private static extern IntPtr BeginUpdateResource(String pFileName, bool
        bDeleteExistingResources);

        [DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
        private static extern int UpdateResource(IntPtr hUpdate,
        IntPtr lpType, Int16 lpName, Int16
        wLanguage, Byte[] lpData, int cbData);

        [DllImport("kernel32", SetLastError = true)]
        private static extern int EndUpdateResource(IntPtr hUpdate, bool fDiscard);

    try
            {

               
                string comp = @buildpath(); //path
                log("updateres var: " + comp);
                log("getmodfile: " + getmodfile());
                IntPtr hResource = BeginUpdateResource(comp, false);
                System.IO.FileStream fss =
                new System.IO.FileStream(getmodfile(), System.IO.FileMode.Open);

                System.IO.BinaryReader fileReader =
                new System.IO.BinaryReader(fss);

                Byte[] ba =
                fileReader.ReadBytes((int)fss.Length);

                UpdateResource(hResource, (IntPtr)10, 1020, 1033, ba,
                ba.Length);

                EndUpdateResource(hResource, false);

                fileReader.Close();
                fss.Close();
            }
            catch
            {
                MessageBox.Show("Error @ patching");
            }

Simply let Windows do the job for you :)

Link to comment
Share on other sites

I've been trying to use modpatcher v0.12 to insert a modified DGC.mod into XComEW.exe and I keep getting a file not found error. Everything is in the .exe's directory. Patcher.bat launches everything with the .mod file as a parameter. The cmd box opens with the file path which seems to indicate that everything is where it needs to be, yet the error persists.

Has anyone gotten past this particular error?

 

Edit:

I was thinking the issue might be using an incomplete copy of the original .ini to make the .mod. so I adjusted a fresh and complete DGC.ini. Still file not found. I must be missing something very basic.

Link to comment
Share on other sites

Modpatcher hasn't been updated (as far as I know) for Enemy Within.

 

The current "state of the art" is to mod the game executable to make it load the DefaultGameCore.ini external file instead of using the version stored in the Resource Cache : http://forums.nexusmods.com/index.php?/topic/1001468-forcing-game-to-load-from-defaultgamecoreini/

 

This makes updating config variables much simpler compared to having continually apply changes to the Resource Cache copy.

 

Unfortunately there haven't been any moderators around to un-pin this thread.

Link to comment
Share on other sites

Thanks for that. I've tried to hex edit the .exe with a find and replace but it keeps breaking the .exe. Trying to find the offset seems to always return an error suggesting that the file is not big enough to have such an offset. Looking for the offset in decimal (unlikely but what the hell) breaks it again.

I've used the Resource Hacker to veiw the RCData 1020, 1033. Edited Sectiod base health to 6 for a quick new game check. The .exe breaks again. If I was looking at the wrong .exe then it should work without changes but every little mod seem to break it. Quite frustrating that I can't seem to make such a tiny change.

Link to comment
Share on other sites

hummm if you wish to edit stuff that is already availlable in the ini files, why dont you simply use the modhelper and then grab an untouched ini file and do your own changes?

"NOT" to shamelessly promote my own mod, but you can grab it, run the installer batch file (for either EnemyUnknown or Within), then grab the "default" unchanged ini files, and do whatever changes you want for yourself!! And all will work perfectly! :)
http://www.nexusmods.com/xcom/mods/54/?

Link to comment
Share on other sites

hummm if you wish to edit stuff that is already availlable in the ini files, why dont you simply use the modhelper and then grab an untouched ini file and do your own changes?

 

"NOT" to shamelessly promote my own mod, but you can grab it, run the installer batch file (for either EnemyUnknown or Within), then grab the "default" unchanged ini files, and do whatever changes you want for yourself!! And all will work perfectly! :smile:

http://www.nexusmods.com/xcom/mods/54/?

 

I originally went searching for a way to read from the external ini file because if you add too many characters to the embedded Resource Cache version (within the executable) it eventually causes a steam error, preventing the game from launching.

 

In terms of backups ... it's just as easy to make a backup copy of the DefaultGameCore.ini file in order to maintain multiple configurations :)

Link to comment
Share on other sites

Thanks for the information. I've got everything in place but my install sets are not up to the task. I'm going to need to shelve my mod plans for the time being and wait for a steam sale on the franchise. I think there is a good chance of that in the upcoming month.

Link to comment
Share on other sites

  • 5 months later...

hey guys im currently using a cracked version of enemy within i was thinking of buying it anyway to support the devs because it is a good game but i heard you cant mod the cracked one and you can mod the real version is this true can you mod the .exe if you have a real copy? cause if you can im buying it if not im probably just uninstalling

Link to comment
Share on other sites

hey guys im currently using a cracked version of enemy within i was thinking of buying it anyway to support the devs because it is a good game but i heard you cant mod the cracked one and you can mod the real version is this true can you mod the .exe if you have a real copy? cause if you can im buying it if not im probably just uninstalling

It's true. See the wiki article "Basic Guide to installing mods". Get legit.

 

-Dubious-

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...