Jump to content


Photo

Where is the script file that deals with the journal?


28 replies to this topic

#16 veyn

veyn
  • Members
  • 45 posts

Posted 18 February 2017 - 10:01 AM

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).



#17 squareinc

squareinc
  • Members
  • 18 posts

Posted 19 February 2017 - 06:31 PM

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.



#18 squareinc

squareinc
  • Members
  • 18 posts

Posted 20 February 2017 - 02:53 PM

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!



#19 veyn

veyn
  • Members
  • 45 posts

Posted 20 February 2017 - 03:33 PM

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.

Attached Files


Edited by veyn, 20 February 2017 - 03:33 PM.


#20 squareinc

squareinc
  • Members
  • 18 posts

Posted 20 February 2017 - 05:10 PM

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?



#21 veyn

veyn
  • Members
  • 45 posts

Posted 21 February 2017 - 06:36 AM

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



#22 squareinc

squareinc
  • Members
  • 18 posts

Posted 21 February 2017 - 09:25 AM

Thank you very much! I will try it when I get home. Can you tell me what it will do gameplay wise though? Will it move the date stamp?



#23 squareinc

squareinc
  • Members
  • 18 posts

Posted 21 February 2017 - 09:27 AM

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

 

Also (sorry again for pestering), what program can I use to add these into the executable. Is there a hex editor (or other program) you recommend?



#24 squareinc

squareinc
  • Members
  • 18 posts

Posted 21 February 2017 - 06:03 PM

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.

Attached Thumbnails

  • bghex.JPG

Edited by squareinc, 21 February 2017 - 06:24 PM.


#25 veyn

veyn
  • Members
  • 45 posts

Posted 22 February 2017 - 05:22 AM

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.



#26 squareinc

squareinc
  • Members
  • 18 posts

Posted 22 February 2017 - 12:28 PM

Thank you again for your help and patience. I will learn how to use IDA no matter how difficult it is. I may occasionally nag you again if I really, really need help, but I'll try to do it without too much pestering. Again, I really appreciate you helping me :)



#27 squareinc

squareinc
  • Members
  • 18 posts

Posted 23 February 2017 - 09:55 AM

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 :)



#28 veyn

veyn
  • Members
  • 45 posts

Posted 24 February 2017 - 03:22 AM

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/co...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.



#29 squareinc

squareinc
  • Members
  • 18 posts

Posted 24 February 2017 - 10:34 AM

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/co...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. )





Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users