编译不过
Opened this issue · 34 comments
/riru_unity_example/module/src/main/cpp/whale/src/interceptor.h:26:20: error: no member named 'unique_ptr' in namespace 'std'
what is ale
?
updated
And this
/riru_unity_example/module/src/main/cpp/soinfo.h:224:5: error: unknown type name 'Elf32_Relr'
/riru_unity_example/module/src/main/cpp/soinfo.h:40:9: error: use of undeclared identifier 'assert'
These errors are from the output of commnad : gralde build
- Use
./gradlew :module:assembleRelease
instead ofgradle build
- soinfo.h is deprecated and i forgot to delete it
Try with latest commit?
ok.
Now I have a question about il2cpp .
if it is possible to hook one method ,which can tell a button is clicked event and fetch the name of the current scene this button is on .
afaik every object is a MonoBehavior
, maybe try to hook one of the call back in MonoBehavior
class?
so, should I hook libunity.so or libil2cpp.so?
everything compiled from C# world is in libil2cpp.so. libunity.so provides only Unity runtime.
I have tried this command ./gradlew :module:assembleRelease
Also gives out some errors.
i.e
/riru_unity_example/module/src/main/cpp/whale/src/base/logging.h:216:9: error: use of undeclared identifier 'abort'
/riru_unity_example/module/src/main/cpp/whale/src/platform/linux/process_map.h:36:16: error: expected unqualified-id
try to upgrade your NDK version?
upgrade to which version ?
And what is the use of this method:nativeForkAndSpecializePre,I have not find anywhere references it.
upgrade to which version ?
I'm currently using "NDK (Side by side)" showes in Sdk Manager, idk why it doesn't shows the version number. So I can only recommand you to upgrade with Sdk Manager.
And what is the use of this method:nativeForkAndSpecializePre
it is an export function, called by Riru-Core
ok. I will try .
///////////////////////////
const Il2CppImage* image = il2cpp_assembly_get_image(assembly_list);
Il2CppClass clazz = il2cpp_class_from_name(image, "UnityEngine.UI", "Button");
hook_each((unsigned long)il2cpp_class_get_method_from_name(clazz, "onClick", 1)->methodPointer, (void*)hook, (void**)&backup);
///////
COuld I use this code to get notified when button is clicked?
TRY BEFORE ASKING
afaik every object is a
MonoBehavior
, maybe try to hook one of the call back inMonoBehavior
class?
could you give a example?
Il2CppClass* clazz = il2cpp_class_from_name(image, "UnityEngine", "MonoBehaviour");
here print clazz is null.
struct cSharpByteArray {
size_t idkwhatisthis[3];
size_t length;
char buf[4096];
};
what is the use of this?
thanks
Parse C# byte array
Il2CppClass* clazz = il2cpp_class_from_name(image, "UnityEngine.SceneManagement", "SceneManager");
LOGI("hack game begin step2 clazz %p",clazz);
void* monitorfunc=il2cpp_class_get_method_from_name(clazz, "GetActiveScene", 0,0)->methodPointer;
I have successfully got GetActiveScene of class UnityEngine.SceneManagement.Next step, I want to manually call this monitorfunc, how can I achive this in c++?May you give me some hints?
DO i need to dive into the c# class of SceneManagement
Parse C# byte array
size_t hook(char* instance, cSharpByteArray *src){
I do not know why it need C# byte array here
can you please explain this code:
hook_each((unsigned long)il2cpp_class_get_method_from_name(clazz, "Your Method", 1)->methodPointer, (void*)hook, (void**)&backup);
why hook takes a cSharpByteArray* param? what does it mean?
That's the exact same params as the hooked C# function. If your hooked function takes no parameter, leave it blank.
that sounds strange,
in my idea , il2cpp_class_get_method_from_name returns function point of unity c++ library function , what is the matter of c# ?
please tell me if I am wrong
All Unity games are written in C#, il2cpp coverts C# to C++ code. In il2cpp arrays have special structure, instead of C array.
where did you find this two struct:
struct cSharpByteArray {
size_t idkwhatisthis[3];
size_t length;
char buf[4096];
};
struct cSharpString {
size_t address;
size_t nothing;
int length;
char buf[4096];
};
printing memory and guessing
Can this repo used with substrate hook library?
Never tried. If you want to check it out you should use static linking.
Does il2cpp generate c++ code for each c# script?
yes
I am curious that why this hook into c# layer?
could you give a practice hook example of this
Are unity MonoBehaviour api written in c# ? for example SceneManager.GetActiveScene
Please check Unity's source code
EVERYTHING you need is in C#, or C# with C bindings. You should only care about the C# part.
thanks.