Standard Trek.exe IDA Database

Standard Trek.exe IDA Database; support/discussion/questions

Moderator: thunderchero

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: Standard Trek.exe IDA Database

Post by QuasarDonkey » Tue Aug 30, 2011 5:10 pm

Thanks for links TC. But I haven't made a whole lot of progress yet. And I got side-tracked reverse engineering something that had already been done :x

So I'm gonna go through the UE source and the old posts here, and feed all known data on BotF into IDA. I think we'll be in a much better position to figure out the code when I input the data structures from edifice.bst, etc.

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 6072
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Standard Trek.exe IDA Database

Post by thunderchero » Tue Aug 30, 2011 8:47 pm

If you have not already you should review links in this post

viewtopic.php?f=4&t=1284

thunderchero

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: Standard Trek.exe IDA Database

Post by QuasarDonkey » Tue Aug 30, 2011 8:51 pm

Cheers. I had quickly flicked through it before, but I missed all the stuff on game mechanics. That's gonna save me quite a bit of time :D

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 6072
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Standard Trek.exe IDA Database

Post by thunderchero » Fri Sep 02, 2011 6:09 pm

Ok after playing/testing a few MP game lol

I would like to see a keyboard shortcut created if possible. During multi-player game you can use a chat window you must click on send message button I would like to be able to use keyboard enter key.

thunderchero

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: Standard Trek.exe IDA Database

Post by QuasarDonkey » Fri Sep 02, 2011 7:27 pm

Yeah I'll take a look. But the enter key is already used for closing dialog windows, so there may be a conflict. Sure we can worry about that after I figure it out. I probably won't be able to test it myself since I haven't gotten a multiplayer game to work anytime recently. I'll start on it now.

User avatar
xDx
Commander
Commander
Posts: 275
Joined: Sat May 10, 2008 2:00 am
Location: East Coast, USA

Re: Standard Trek.exe IDA Database

Post by xDx » Fri Sep 02, 2011 8:23 pm

I'm sorry to post another topic but not sure how easy this might be. I always found it annoying especially in epic games that there was no notification that a fleet has arrived at its location. It would be nice specifically for colony vessels arriving at a system to terraform but in general any fleet arriving at location and possibly a goto double click like when a system queue is empty.

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 6072
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Standard Trek.exe IDA Database

Post by thunderchero » Fri Sep 02, 2011 9:37 pm

QuasarDonkey wrote:Yeah I'll take a look. But the enter key is already used for closing dialog windows, so there may be a conflict. Sure we can worry about that after I figure it out. I probably won't be able to test it myself since I haven't gotten a multiplayer game to work anytime recently. I'll start on it now.
I did some early tests

1. if summery window is up no chat window can be brought up (no shortcut).

2. if chat window is up shortcut for summery window can not be used.

thunderchero

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: Standard Trek.exe IDA Database

Post by QuasarDonkey » Fri Sep 02, 2011 11:45 pm

Good news! I got it working in single player mode!

However, there are a few caveats:
  • Using the return key (or many other keys) would cause problems, so I use the ` key (under Escape).
  • BUG The ` symbol will be printed at the start of the message.
  • BUG If you hit the key while a game is NOT loaded, BotF crashes out -- but otherwise it works from any screen (even the options screen!) when a game is loaded/started.
  • BUG Hitting the key while the Chat window is already up will trigger it to reshow, losing your message.
  • BUG? It works in single-player mode 8)
I'll try to iron out the bugs by adding more complex code, and I'll get it uploaded to you ASAP. The way I injected the new code to handle the keystroke is that our key is checked before any other. This means it takes priority over other keys. If you would like to use a different key (other than the ` symbol under Esc), you'll have to pick one that's not ever used in the game. So that means no A-Z, 0-9, Esc, Enter, Tab, F keys, and possibly more.
xDx wrote:It would be nice specifically for colony vessels arriving at a system to terraform but in general any fleet arriving at location and possibly a goto double click like when a system queue is empty.
I agree, that would be pretty sweet. But I'm not sure how easy it would be. I'll take a look at it.

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 6072
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Standard Trek.exe IDA Database

Post by thunderchero » Fri Sep 02, 2011 11:58 pm

QuasarDonkey wrote:Good news! I got it working in single player mode!

However, there are a few caveats:
  • Using the return key (or many other keys) would cause problems, so I use the ` key (under Escape).
  • BUG The ` symbol will be printed at the start of the message.
  • BUG If you hit the key while a game is NOT loaded, BotF crashes out -- but otherwise it works from any screen (even the options screen!) when a game is loaded/started.
  • BUG Hitting the key while the Chat window is already up will trigger it to reshow, losing your message.
  • BUG? It works in single-player mode 8)
I'll try to iron out the bugs by adding more complex code, and I'll get it uploaded to you ASAP. The way I injected the new code to handle the keystroke is that our key is checked before any other. This means it takes priority over other keys. If you would like to use a different key (other than the ` symbol under Esc), you'll have to pick one that's not ever used in the game. So that means no A-Z, 0-9, Esc, Enter, Tab, F keys, and possibly more.
Great work,

But I am afraid you may have miss understood what I was looking for I did not want a shortcut to bring up the chat window. I was looking for a shortcut to send the current message that is in the typed area. (chat window should remain up)

sorry for any confusion

thunderchero

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: Standard Trek.exe IDA Database

Post by QuasarDonkey » Sat Sep 03, 2011 12:10 am

thunderchero wrote:But I am afraid you may have miss understood what I was looking for I did not want a shortcut to bring up the chat window. I was looking for a shortcut to send the current message that is in the typed area. (chat window should remain up)
Argghh! My bad. You want it to act like an instant message client. I'll take a look tomorrow. It might take a while to find the chat windows' keyboard event handler.

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 6072
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Standard Trek.exe IDA Database

Post by thunderchero » Sat Sep 03, 2011 5:06 pm

QuasarDonkey wrote:
thunderchero wrote:But I am afraid you may have miss understood what I was looking for I did not want a shortcut to bring up the chat window. I was looking for a shortcut to send the current message that is in the typed area. (chat window should remain up)
Argghh! My bad. You want it to act like an instant message client. I'll take a look tomorrow. It might take a while to find the chat windows' keyboard event handler.
great news QuasarDonkey has got this to work, I have moved the posts over to Solutions; Bug fixes and recoding of game

How to change chat to use return key to send message

once again great job

thunderchero

User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2065
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Standard Trek.exe IDA Database

Post by Tethys » Sat Sep 03, 2011 9:09 pm

Oh what a nice feature! I still press enter to this day and it pisses me off when it goes to the next line :P
Not for the weak of heart...
Image
GALM <--- GALM/Galaxies Mod

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: Standard Trek.exe IDA Database

Post by QuasarDonkey » Thu Sep 08, 2011 1:44 pm

I think we're due on update on the IDA database.

For this release, I've mainly focused on deciphering three source files: gdllist.c, hash.c, and gheap.c. The functions in these implement algorithms for dealing with doubly-linked lists, hash tables, and heaps respectively. The data structures and algorithms are very important as they used throughout Trek.exe. I've managed to figure out all the data structures, function names and signatures. This should pave the way for much more analysis.

The relevant functions start at offset 51A230, and the functions are prefixed gdlList_, HashTable_, and gHeap_. If anyone with knowledge of data structures / algorithms would double-check to see if it looks right, it'd be much appreciated (I'm a doctor Jim, not a computer scientist!).

I've also identified more library functions, etc.

As usual, you can get the latest version here:
http://sourceforge.net/projects/botftrekidb/files/

If anyone would like details on how these important data structures are implemented, feel free to ask.

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: Standard Trek.exe IDA Database

Post by QuasarDonkey » Thu Sep 08, 2011 2:30 pm

Oh yeah, forgot to mention: I discovered a neat feature in IDA -- "Take Memory Snapshot". Basically here's what I did: set a breakpoint at 00458260 Game_Turn_Turn_ProcessTurn. Start the debugger.

The debugger might stop with a software breakpoint exception or something, but just resume execution and click No when it asks you to pass the exception to the application. If you get access violation exceptions, set up the the rule not to stop the app, and do pass the exceptions.

Now you should be in BotF. Start/load a game and take a turn. The program will stop at the ProcessTurn breakpoint. Continue execution, and take another turn. This time when it stops, go the debugger menu, and hit "Take Memory Snapshot". Then you can stop the debugger / quit BotF.

The "Take Memory Snapshot" will fill out all those unknown dynamic variables in IDA (the ones with "dd ?", etc.) with the values from when you ran Trek.exe. This should make it easier to identify new "Key dynamic variables" as Gowron called them.

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 6072
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Standard Trek.exe IDA Database

Post by thunderchero » Thu Sep 08, 2011 9:33 pm

QuasarDonkey wrote:Oh yeah, forgot to mention: I discovered a neat feature in IDA -- "Take Memory Snapshot". Basically here's what I did: set a breakpoint at 00458260 Game_Turn_Turn_ProcessTurn. Start the debugger.

The debugger might stop with a software breakpoint exception or something, but just resume execution and click No when it asks you to pass the exception to the application. If you get access violation exceptions, set up the the rule not to stop the app, and do pass the exceptions.

Now you should be in BotF. Start/load a game and take a turn. The program will stop at the ProcessTurn breakpoint. Continue execution, and take another turn. This time when it stops, go the debugger menu, and hit "Take Memory Snapshot". Then you can stop the debugger / quit BotF.

The "Take Memory Snapshot" will fill out all those unknown dynamic variables in IDA (the ones with "dd ?", etc.) with the values from when you ran Trek.exe. This should make it easier to identify new "Key dynamic variables" as Gowron called them.
Great work QuasarDonkey,

I love looking at these IDA Databases, While I know very little it does give me some insight to some of the changes that have been made.

I have also tried to run debugger before and doubt if this will help but I always open stbof.ini and change MOVIEON=ON to MOVIEON=OFF to get past the second exception.

thunderchero
AKA - often wrong Soong (when it come to assembly coding) :D

Post Reply

Return to “Standard Trek.exe IDA Database”

Who is online

Users browsing this forum: No registered users