Closed NetCKRiters closed 1 year ago
PD. Im just having issue on the calls, also pls share me how to pull a code, cause im new to github. But i made a custom hook class to just def: ADD_HOO(funtion, target, name).
After some time i confirm i can get the method, and the instance correct:
[INFO - SOF - get_image] get_image(): Sons.dll [INFO - SOF - get_new_class] get_new_class(): LocalPlayer [INFO - SOF - get_class_method] get_class_method(): AddItemsByType [INFO - SOF - get_image] get_image(): Sons.dll [INFO - SOF - get_new_class] get_new_class(): LocalPlayer [INFO - SOF - get_class_method] get_class_method(): AddItemsByType [INFO - SOF - get_class_method] Parameters in Method: 3 [INFO - SOF - get_class_method] [!]typeMask [INFO - SOF - get_class_method] [!]amount [INFO - SOF - get_class_method] [!]preventAutoEquip
At this point, i get the Image, the Class, the Method that i want to invoke. Also i founding the Instance correct: [INFO - SOF - get_image] get_image(): Sons.dll [INFO - SOF - get_new_class] get_new_class(): LocalPlayer [INFO - SOF - get_new_field_static] field_static: ### _instance found [INFO - SOF - CallAddItems] Instance Found Correct it
But im getting the crash still.
Now the crash is just in invoke:
get_add_items_types->invoke(
instance, // instance/object pointer
¶ms // either a void * of params or nullptr
);
Can Anyone see the issue?
In regards to how you're invoking the method, don't use a ref to params
Look at the last two lines in this snippet to see what I'm talking about.
const auto transformClass = Fleiya::Engine::unity_engine_image->get_class( "Transform", "UnityEngine" );
const auto transformGetPos = transformClass->get_method( "get_position" );
const auto playerTransform = instance->fields.Character->fields.thisTransform;
void * params[] = { &new_x, &new_y, &avoid_pos, &script, &ignore_collision, nullptr };
return reinterpret_cast<Vector3 *>( transformClass->invoke_method( transformGetPos, playerTransform, params ) );
In this example, I'm getting the transform class then getting the method pointer to the get_position method then getting the player's transform obj and finally setting method params and then invoking the non-static method
this code works for me on a game that i've played
if it continues to crash due to accessing an invalid address, then i'd verify that you're getting a correct method pointer for whatever function you're trying to call
Closing as the issue has been resolved over Discord.
Steps to reproduce
Game: Sons of the Forest. Class Def:
Issue:
The last info that i go from the dll is: GetLastError: 'Attempt to access invalid address.' (Address: 00007FFF15CC06DE) Anone see a issue in the code?
Expected behaviour
No crashing.
Game
Sons of ther Forest
Relevant log output