Jump to content

Where is the script file that deals with the journal?


squareinc

Recommended Posts

This is indeed hardcoded in old BG2. Journal formatting is done by the function at 0x0056FC9A. What it does is the following:

* fetch tlk entry for requested journal entry

* find first newline character

* everything before that becomes "caption" in the next gui entry (slightly different color, etc.)

* build timestamp string based on 15980 format pattern (replacing <DAY> etc with actual values for the entry)

* append everything starting from first newline character to the timestamp string - it becomes "text" in the next gui entry

 

So depending on what exactly you want to achieve, you might need to modify the code.

 

If all you need is to add space between caption and date string, you can modify 15980 tlk entry by adding newline character at the very beginning (but note that it might cause some unexpected changes in other places 15980 is used).

Link to comment

This is indeed hardcoded in old BG2. Journal formatting is done by the function at 0x0056FC9A. What it does is the following:

* fetch tlk entry for requested journal entry

* find first newline character

* everything before that becomes "caption" in the next gui entry (slightly different color, etc.)

* build timestamp string based on 15980 format pattern (replacing <DAY> etc with actual values for the entry)

* append everything starting from first newline character to the timestamp string - it becomes "text" in the next gui entry

 

So depending on what exactly you want to achieve, you might need to modify the code.

 

If all you need is to add space between caption and date string, you can modify 15980 tlk entry by adding newline character at the very beginning (but note that it might cause some unexpected changes in other places 15980 is used).

 

Thanks for your response! Let's say I wanted to edit the function. What will I need to use to do that? I'm thinking of changing it so the date is on top and then the quest, so there wouldn't be a cutoff. Also, what is the newline character in case I go that direction instead? Thanks again.

Link to comment

This is indeed hardcoded in old BG2. Journal formatting is done by the function at 0x0056FC9A. What it does is the following:

* fetch tlk entry for requested journal entry

* find first newline character

* everything before that becomes "caption" in the next gui entry (slightly different color, etc.)

* build timestamp string based on 15980 format pattern (replacing <DAY> etc with actual values for the entry)

* append everything starting from first newline character to the timestamp string - it becomes "text" in the next gui entry

 

So depending on what exactly you want to achieve, you might need to modify the code.

 

If all you need is to add space between caption and date string, you can modify 15980 tlk entry by adding newline character at the very beginning (but note that it might cause some unexpected changes in other places 15980 is used).

 

Sorry to bother, but can you also confirm that it is the bgmain.exe that has to be edited? I opened that file in a hex editor but it did not find the exact match you mentioned. 0056FC98, I think, is the closest match for that value. It has something to do with the journal as well, but the text is really not structured. Can you give me any pointers or maybe a screenshot of how it looks from your end? Thanks much!

Link to comment

The address is the function VA (memory address when executable is loaded and being executed), file offset would be different. You would need some specialized tools and knowledge to actually modify executable...

 

Anyway, I've made two simple patches - try either out (but don't apply both at the same time, that would be useless) - see if any of them works. Note that I currently don't have BG installed, so I didn't test them.

test1.txt

test2.txt

Link to comment

The address is the function VA (memory address when executable is loaded and being executed), file offset would be different. You would need some specialized tools and knowledge to actually modify executable...

 

Anyway, I've made two simple patches - try either out (but don't apply both at the same time, that would be useless) - see if any of them works. Note that I currently don't have BG installed, so I didn't test them.

 

Thank you. How would I insert this to the .exe? Can I just copy and paste it. I should also mention I have TobEx installed which I believe makes some changes to the bgmain.exe as well. Would this be compatible?

Link to comment

It lists the bytes in the executable you have to patch. I imagine it would be compatible with tobex.

 

I tried the second test and it worked! Thanks a lot. One final question (you can ignore the one above since I got a program to edit the exe). How can I see the syntax that you mentioned about the newline and what not? I've attached a screenshot that shows how the text looks in the hex editor I have. I have IDA as well, if that is what I need to use. The text is garbled as you can see. How do I view it? How did you know that that was the values which affected the datestamp? I ask because this might be useful in the future if there are further problems. I'd like to be able to make the first line of each quest in the journal red again for example. Is there anyway to translate or learn to make sense of the char set? Thanks again for your patience.

post-9686-0-51304800-1487729976_thumb.jpg

Link to comment

Yeah, you need to use some disassembler to make sense of the executables - IDA is one such program (and it's a very good one - that's what I use). I recommend looking up some tutorials if you wish to learn how to use it (google "reverse engineering") - but note that it's a big and complex topic, learning it will take some time and effort, it can't really be explained in one post :) After learning the basics, you'll be able to start analyzing the game executable - this is a long process, you essentially need to figure out how the game works - but once you understand the key structures and functions, you'll be able to find the answers you need quite quickly.

Link to comment

Yeah, you need to use some disassembler to make sense of the executables - IDA is one such program (and it's a very good one - that's what I use). I recommend looking up some tutorials if you wish to learn how to use it (google "reverse engineering") - but note that it's a big and complex topic, learning it will take some time and effort, it can't really be explained in one post :) After learning the basics, you'll be able to start analyzing the game executable - this is a long process, you essentially need to figure out how the game works - but once you understand the key structures and functions, you'll be able to find the answers you need quite quickly.

 

 

Hey veyn, is there any resource (written, online, paid or free,) that you would recommend to me to start to learn? I have found a lot of stuff with reverse engineering but they focus more on a protected program and how to bypass it. Any start or pointer would be greatly appreciated. Thank you :)

Link to comment

This is getting really off-topic for this forum :)

 

Can't recommend any resource off the top of my head unfortunately. First page on google gives these:

* http://www.foo.be/cours/dess-20122013/b/Eldad_Eilam-Reversing__Secrets_of_Reverse_Engineering-Wiley(2005).pdf

* https://beginners.re/RE4B-EN.pdf

Looked through a bit and they seemed reasonable, though I can't say anything more about them.

 

Generally, things like copy protection removal and malware analysis (or writing) are indeed common goals for RE, so it's not surprising that it's a focus of many articles. I'd say, however, that it's a step above "beginner" level - you might want to delve into that after you learn the basics.

 

Other than reading books, compiling small test programs, looking at the binaries that compiler produces, and understanding why it did exactly that way is the best approach to learning I think. Focus on one language, compiler and platform first (for example, C++, MSVC compiler, x86/windows) - once you understand that, adapting to others would be simple.

Link to comment

This is getting really off-topic for this forum :)

 

Can't recommend any resource off the top of my head unfortunately. First page on google gives these:

* http://www.foo.be/cours/dess-20122013/b/Eldad_Eilam-Reversing__Secrets_of_Reverse_Engineering-Wiley(2005).pdf

* https://beginners.re/RE4B-EN.pdf

Looked through a bit and they seemed reasonable, though I can't say anything more about them.

 

Generally, things like copy protection removal and malware analysis (or writing) are indeed common goals for RE, so it's not surprising that it's a focus of many articles. I'd say, however, that it's a step above "beginner" level - you might want to delve into that after you learn the basics.

 

Other than reading books, compiling small test programs, looking at the binaries that compiler produces, and understanding why it did exactly that way is the best approach to learning I think. Focus on one language, compiler and platform first (for example, C++, MSVC compiler, x86/windows) - once you understand that, adapting to others would be simple.

 

 

Okay thank you a lot. I know a bit of C++ so I'll go that route, but another (annoying, I know) question (at least on topic): Would it be difficult to change the first line of the journal entry, the title, back to red? The solution in test2 that you sent works great but now the quest title is the same black color as the rest of the entry. Is it possible to change the first line to red (the first line after the datestamp)?

 

(Also, through my fiddling, I managed to find that the red used is B72010. This isn't really important, but I was proud that I was able to figure that out through the IDA disassembled code and I wanted to share :). Once again, you have the patient of a saint. )

Link to comment

Archived

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

×
×
  • Create New...