Eliot's Forum

Full Version: Function Headers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am attempting to understand the function header so as to determine if anything in it needs to be updated if I re-write bytes. In my function I have used an instance variable to act as a loop count and guard. This modifies the amount of index's that are read.

Now I understand that the last 16 bytes in the 48 byte header have size and position information.

Code:
DWORD LineNumber 'in class'. In UE Explorer this can be confirmed lines however do not match perfectly..

DWORD unknown

DWORD TextPos ??? I am assuming 'text' to be data loaded in memory. In my short analysis this always seems to be higher than EndOffset and the cave size (endoffset - TextPos) seems to always be a multiple of 4. So I am thinking this has something to do with scripts virtual size. I believe that if you rewrite a script and change the amount of index reads that you must recalculate this..

DWORD EndOffset This is the 'size' of the script from the end of the header to the start of the End of Script token 0x53. Note this size does not include actual load size. Some tokens get expanded to 8 bytes rather than 4.

BYTEs Script Script Code

BYTES 0x53 plus 15 more. There seems to be some flags in this part. I do not understand the bytes at the end of a function

The reason I am asking is because I have re written bytes to do a while loop instead of adding an item manually one by one so I can edit the amount added to a dynamic array rather than get stuck with the hardcoded size.

I am still getting a little stuck on which INDEX objects get 8 bytes and when to add e.g: in jump code.

Anyway, so what is this header and footer information and do I need to adjust anything when Index reads change?[/code][/quote]
The 16 last bytes are two 32bit integers, the former one represents the bytecode size in memory(when loaded) and the latter the bytes written in the file.

You only have to modify the former integer when editing the bytecodes.
Every token that references an object counts an additional 4 bytes.

All the other data is not relevant, TextPos and Line just means the character position and line the function was declared before it was compiled.

Generated output:
Code:
0x00000000 : CharToCorpse                    :UFunction                        => CharToCorpse(72)
0x00000000 : ExportSize                      :Int32                            => 230
0x00000000 : NetIndex                        :UIntProperty                     => iChar(71)
0x00000004 : NameIndex                       :String                           => None
0x0000000C : NextField                       :UScriptStruct                    => XGUnitVisibilityInformation(69)
Super
ScriptText
0x00000018 : Children                        :UIntProperty                     => iChar(71)
CppText
0x00000020 : Line                            :UInt32                           => 1712
0x00000024 : TextPos                         :UInt32                           => 41209
0x00000028 : ByteScriptSize                  :Int32                            => 179
0x0000002C : DataScriptSize                  :Int32                            => 167
0x000000D7 : NativeToken                     :UInt16                           => 0
0x000000D7 : OperPrecedence                  :Byte                             => 0
0x000000DA : FunctionFlags                   :FunctionFlags                    => Defined, Static, Public
0x000000DE : FriendlyNameIndex               :UNameTableItem                   => CharToCorpse
(12-23-2012, 03:37 AM)eliot Wrote: [ -> ]The 16 last bytes are two 32bit integers, the former one represents the bytecode size in memory(when loaded) and the latter the bytes written in the file.

You only have to modify the former integer when editing the bytecodes.
Every token that references an object counts an additional 4 bytes.

All the other data is not relevant, TextPos and Line just means the character position and line the function was declared before it was compiled.

Generated output:
Code:
0x00000000 : CharToCorpse                    :UFunction                        => CharToCorpse(72)
0x00000000 : ExportSize                      :Int32                            => 230
0x00000000 : NetIndex                        :UIntProperty                     => iChar(71)
0x00000004 : NameIndex                       :String                           => None
0x0000000C : NextField                       :UScriptStruct                    => XGUnitVisibilityInformation(69)
Super
ScriptText
0x00000018 : Children                        :UIntProperty                     => iChar(71)
CppText
0x00000020 : Line                            :UInt32                           => 1712
0x00000024 : TextPos                         :UInt32                           => 41209
0x00000028 : ByteScriptSize                  :Int32                            => 179
0x0000002C : DataScriptSize                  :Int32                            => 167
0x000000D7 : NativeToken                     :UInt16                           => 0
0x000000D7 : OperPrecedence                  :Byte                             => 0
0x000000DA : FunctionFlags                   :FunctionFlags                    => Defined, Static, Public
0x000000DE : FriendlyNameIndex               :UNameTableItem                   => CharToCorpse

I eventually came to this understanding! Thanks for the reply however as it confirms my current work.

When fixing the load size of a script do I have to account for this anywhere else in the upk other than the function itself? as I am having difficulty getting code to work when I change the load size. For now I am working around this by keeping the load size the same when rewriting bytes?

(12-23-2012, 03:34 PM)twinj Wrote: [ -> ]
(12-23-2012, 03:37 AM)eliot Wrote: [ -> ]The 16 last bytes are two 32bit integers, the former one represents the bytecode size in memory(when loaded) and the latter the bytes written in the file.

You only have to modify the former integer when editing the bytecodes.
Every token that references an object counts an additional 4 bytes.

All the other data is not relevant, TextPos and Line just means the character position and line the function was declared before it was compiled.

Generated output:
Code:
0x00000000 : CharToCorpse                    :UFunction                        => CharToCorpse(72)
0x00000000 : ExportSize                      :Int32                            => 230
0x00000000 : NetIndex                        :UIntProperty                     => iChar(71)
0x00000004 : NameIndex                       :String                           => None
0x0000000C : NextField                       :UScriptStruct                    => XGUnitVisibilityInformation(69)
Super
ScriptText
0x00000018 : Children                        :UIntProperty                     => iChar(71)
CppText
0x00000020 : Line                            :UInt32                           => 1712
0x00000024 : TextPos                         :UInt32                           => 41209
0x00000028 : ByteScriptSize                  :Int32                            => 179
0x0000002C : DataScriptSize                  :Int32                            => 167
0x000000D7 : NativeToken                     :UInt16                           => 0
0x000000D7 : OperPrecedence                  :Byte                             => 0
0x000000DA : FunctionFlags                   :FunctionFlags                    => Defined, Static, Public
0x000000DE : FriendlyNameIndex               :UNameTableItem                   => CharToCorpse

I eventually came to this understanding! Thanks for the reply however as it confirms my current work.

When fixing the load size of a script do I have to account for this anywhere else in the upk other than the function itself? as I am having difficulty getting code to work when I change the load size. For now I am working around this by keeping the load size the same when rewriting bytes?