Jump to content

Customize Easter Egg Hero Characters


Kaldreth88

Recommended Posts

I just saw your post about the offset problems in the UPK utils thread and posted a response there! :smile:

 

[EDIT: Moved here because you removed the original post in that thread so things were kind of disconnected]

 

The offsets are off because there is a difference between the code size and the memory size. You've maintained the same code size wtih the 0Bs, but any time you replace an index with four 0Bs you reduce the in-memory size by 4 because they are actually 8 bytes long in-game. Hence the offset mismatch.

 

You need to make sure both sizes remain fixed. An easy way to do this is to inject some index references to your replacement code with 00 <4 bytes of some index of a local variable in the function>. Each one of these consumes 5 bytes of 0Bs, so reduce that count appropriately. In my hacks that did this before I injected a JMP at the top of my replacement code to skip over the index references, but I think expressions that just reference a local variable (00 <index>) are no-ops, so you don't need to jump over it.

 

Thanks! That explains a lot. I understand what's wrong now, but I'm still not sure what you mean by injecting index references into the replacement code. I learn best by example and reviewing the work of others, so do you happen to have something similar I could look over?

Link to comment
Share on other sites

Kaldreth88, suppose you have a function call you need to get rid of which looks like this:

//SomeValue=SomeFunction(SomeParameter);
0F 00 <.SomeValue> 1B <SomeFunction> 00 <.SomeParameter> 16
You need to turn it into this:

//SomeValue=5;
0F 00 <.SomeValue> 2C 05
A usual filler code to keep script file size looks like:

0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B
But it won't keep script memory size, which will result in jump offsets being shifted.

 

Each variable reference has 4 bytes of file size (the reference itself) and 8 bytes of memory size (probably some additional internal object data). This means that for your filler code to have the same memory size as the original one, you have to replace some of the 0B's with filler variable(s). Like this:

//SomeValue=5;
0F 00 <.SomeValue> 2C 05
//SomeParameter; filler code, this does nothing
00 <.SomeParameter> 0B 0B 0B 0B 0B 0B 0B 0B
Link to comment
Share on other sites

Awesome. I've got it to work, although it does look messy. Thank you wghost81 and tracktwo! I really appreciate the help.

 

 

 

 

0F 35 03 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 0D

m_kSoldier.m_kSoldier.kAppearance.iVoice = 13;

 

06 FB 03
// End:0x3FB

break;

 

00 EE 2C 00 00 0B 0B 0B 0B 0B 0B 0B 0B
kLoadout

00 EE 2C 00 00 0B 0B 0B 0B 0B 0B 0B 0B
kLoadout

00 EE 2C 00 00 0B 0B 0B 0B 0B 0B 0B 0B
kLoadout

 

 

 

 

It's not obvious to me if this will create issues, but I'm going to test it out some more.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...