Getting started modding the EXE

Information, How-to's, and discussion about mod'ing Master of Orion II.
Hearteater
Posts: 3
Joined: Wed Nov 02, 2016 9:53 am

Getting started modding the EXE

Postby Hearteater » Wed Nov 02, 2016 11:00 am

I'm interested in making some mods to the EXE, but I've got several questions in a kinda random order.

  • I've tried the free version of IDA 5.0, but I'm not certain that's the best tool. Are there other recommendations that still translate the EXE into assembly? This may just be user error of a complicated tool. For example, I can't jump to A6221 in IDA, which makes no sense.
  • What is the best way to find the starting point of a change? Are there some techniques for setting break points or catching mouse events? (see Areas of Interest below)
  • If I make a change that increases/decreases the EXE size, does that present additional issues that need to be resolved, or does the patcher handle that?
  • Are the offsets mentioned like A6221 (dos / 140) just the byte offset in hexadecimal into the DOS 1.40 EXE version?
  • If I create a patch for the EXE, what's the preferred format? Binary block and offset into the 140 EXE?

Areas of Interest
Here are the areas I'm interested in making some changes to. Any help in how to start tracking down where in the code I need to start looking for any of these would be great.

Main Screen:
Add tax % to the BC box when tax rate is greater than 0. I'm assuming this is the easiest of all of these and probably what I'd start with. I'd need to find the code for displaying text in the boxes and the location of the current tax rate.

Build Queue:
I want to make a change on the build queue screen so that CONTROL+Click puts the item on top of the queue, pushing the rest down.

Update all ships pop-up after designing a ship (update all ships in all queues if you answer yes). Similar concept to the pop-up for when you make androids on a nearly full planet.

Colony List:
Add a Cloning Center icon next to each colonies name if it has a Cloning Center and is at max population.

Diplomacy:
Add a spy icon to opponent portrait if they are spying, along with a count.

Add a spy count to all stacks of spies, along with the % spying modifier the stack confers.

Alex
Posts: 17
Joined: Mon Oct 10, 2016 9:09 am

Re: Getting started modding the EXE

Postby Alex » Fri Nov 04, 2016 12:55 am

That's a rather long shot for someone with only a vague idea of the process. What makes you think you are qualified? Because there is quite a lot to learn and there's hardly any demand for 'DOS program patching' skills on the market.

Hearteater
Posts: 3
Joined: Wed Nov 02, 2016 9:53 am

Re: Getting started modding the EXE

Postby Hearteater » Fri Nov 04, 2016 10:34 am

I appreciate the concern over my abilities to accomplish my goals. If it helps, I have over 25 years experience with software development. I started in BASIC, and have used more than a dozen languages in a business environment. My assembly is rusty, but I did work in it back in the 90s. I'm not concerned with my market skills as I am already well employed in software development, and have been for more than a decade. This project is recreational fun.

So what I'm looking for is for any assistance in what tools are good for this task. I can keep trying different tools until I find something that works, but if someone can suggest good places to start that would be very helpful. I don't normally debug applications running inside emulators.

I just found DosBox has a debug mode, so I'll try that next, although it appears I might need to build DosBox from source (which isn't a problem, just another step).

Alex
Posts: 17
Joined: Mon Oct 10, 2016 9:09 am

Re: Getting started modding the EXE

Postby Alex » Fri Nov 04, 2016 8:13 pm

Hearteater wrote:I appreciate the concern over my abilities to accomplish my goals. If it helps, I have over 25 years experience with software development.


What concerns me is if answering your questions would do any good. Your answer doesn't quite clear my doubts, I would expect someone with such coding background to do a little more research before asking questions. Not only that, but most of your questions belong to specialized asm (and DOS) programming forums. I'll answer what I can since I am writing this already, but I don't want to dwell deep into assembly/DOS.

Hearteater wrote:I just found DosBox has a debug mode, so I'll try that next, although it appears I might need to build DosBox from source (which isn't a problem, just another step).


You can download a precompiled version from dosbox authors http://www.vogons.org/viewtopic.php?t=7323

Hearteater wrote:I've tried the free version of IDA 5.0, but I'm not certain that's the best tool. Are there other recommendations that still translate the EXE into assembly? This may just be user error of a complicated tool. For example, I can't jump to A6221 in IDA, which makes no sense.


Never used IDA version 5, but it should be okay. My guess you've used "jump to address" instead of "jump to exe offset" command.

Hearteater wrote:What is the best way to find the starting point of a change? Are there some techniques for setting break points or catching mouse events? (see Areas of Interest below)


MoO2 exe has debug information not stripped, it gives functions and global variables names. Knowing this and knowing the game well you can guess which part of the code does what. Extracting this information and feeding it to IDA would simplify things immensely. The format is binary and I don't know how it is structured but people have done it before.

Hearteater wrote:If I make a change that increases/decreases the EXE size, does that present additional issues that need to be resolved, or does the patcher handle that?


You can't just insert bytes into exe, it will break. For how to change executable file size see LB's 1.40 patcher's source. However for tasks you describe you have more than enough space right after LB's patch.

About "does the patcher handle that" part, what's the patcher here? IDA does not do this AFAIK.

Hearteater wrote:Are the offsets mentioned like A6221 (dos / 140) just the byte offset in hexadecimal into the DOS 1.40 EXE version?


You must ask whoever gave you this offset obviously.

Hearteater wrote:If I create a patch for the EXE, what's the preferred format? Binary block and offset into the 140 EXE?


Format for what purpose? Most modders dessiminate their work as a patched executable so users can just run it.

Hearteater wrote:Areas of Interest
Main Screen:
Add tax % to the BC box when tax rate is greater than 0. I'm assuming this is the easiest of all of these and probably what I'd start with. I'd need to find the code for displaying text in the boxes and the location of the current tax rate.


I'd study Draw_Main_Screen function, it has to draw BCs at some point. If I were your I would stay focused on this one for the first task.

Hearteater
Posts: 3
Joined: Wed Nov 02, 2016 9:53 am

Re: Getting started modding the EXE

Postby Hearteater » Fri Nov 04, 2016 8:23 pm

Thank you, that was very helpful, I think you answered all my questions. Sorry if it seemed like a waste of your time, but I appreciate it a lot.

Alex
Posts: 17
Joined: Mon Oct 10, 2016 9:09 am

Re: Getting started modding the EXE

Postby Alex » Sat Nov 05, 2016 12:59 am

Glad to help. Do let know if you have problems with actual patching, I am no assembler guru but may have suggestions related to how moo2 works.


Return to “Game Modifications”

Who is online

Users browsing this forum: No registered users and 1 guest