UScript debug helper library
Posted: Thu Oct 10, 2019 9:31 pm
I created this debug helper mainly to make it easier for myself to find script errors (accessed nones and such).
When the binary is hooked, it'll display the name of the variable/function that was accessed through a none, as well as the entire stack leading to the null pointer (casts, variables...).
I thought it might be of use to others, so I'm posting it here, as well as the full C++ source code for it.
Here is an example of how it might look:
Where the name in the first quoute is the name of the variable or function (including native functions).
The quote after Next Op is the next opcode index to be executed.
The context fetch is the member access operator "." or dot. After that, you'll get a list of all the variable reference / casting opcodes, property name, and whether any of them are null so you know where the issue lies.
An instance variable is an object defined variable, i.e defined in a class scope.
A Local variable is a local function variable, or a parameter.
A default variable is a class default variable (accessed using .default.)
The library is fairly simple. It replaces some of the variable reference opcodes, cast opcodes, context opcodes, assign opcode and so on in the dll.
The UScript class is empty, it's only there as a dummy reference to make the engine load it and bind the dll.
Due to the extra bookkeeping and lookups, they will take slightly longer to execute.
In order to use it, just load it as a mutator or spawn the DebugDummy.
When the binary is hooked, it'll display the name of the variable/function that was accessed through a none, as well as the entire stack leading to the null pointer (casts, variables...).
I thought it might be of use to others, so I'm posting it here, as well as the full C++ source code for it.
Here is an example of how it might look:
Code: Select all
ScriptWarning: TeamSpawnpoint MH-LostSouls.TeamSpawnpoint9 (Function TeamMonster.TeamSpawnpoint.Create:0032) Accessed None 'prototype' Next Op '1' Stack: Try Fetching context >> , Instance variable: Factory Null
ScriptWarning: SkaarjWarrior MH-LostSouls.SkaarjWarrior2 (Function UnrealShare.Skaarj.SpinDamageTarget:002D) Accessed None 'Location' Next Op '1' Stack: Try Fetching context >> , Instance variable: Target Null
The quote after Next Op is the next opcode index to be executed.
The context fetch is the member access operator "." or dot. After that, you'll get a list of all the variable reference / casting opcodes, property name, and whether any of them are null so you know where the issue lies.
An instance variable is an object defined variable, i.e defined in a class scope.
A Local variable is a local function variable, or a parameter.
A default variable is a class default variable (accessed using .default.)
The library is fairly simple. It replaces some of the variable reference opcodes, cast opcodes, context opcodes, assign opcode and so on in the dll.
The UScript class is empty, it's only there as a dummy reference to make the engine load it and bind the dll.
Due to the extra bookkeeping and lookups, they will take slightly longer to execute.
In order to use it, just load it as a mutator or spawn the DebugDummy.