vfsfitvnm / frida-il2cpp-bridge

A Frida module to dump, trace or hijack any Il2Cpp application at runtime, without needing the global-metadata.dat file.
https://github.com/vfsfitvnm/frida-il2cpp-bridge/wiki
MIT License
1k stars 200 forks source link

implementation error: Type 'number' is not assignable to type 'boolean'. #428

Closed movedaccount-droid closed 11 months ago

movedaccount-droid commented 11 months ago

minimal example:

Il2Cpp.perform(function() {
    // getting assembly image
    const AssemblyCSharp = Il2Cpp.domain.assembly("Assembly-CSharp-firstpass").image;
    const GSFGetItemByIdSvc = AssemblyCSharp.class("GSFGetPublicItemsByOIDsSvc");
    const ctor = GSFGetItemByIdSvc.method(".ctor");
    ctor.implementation = function (
        isPreviewEnabled: boolean,
    ) {
        this.method(".const").invoke();
    };
});

results in:

src/index.ts(11,5): error TS2322: Type '(this: Class | ValueType | Object, isPreviewEnabled: boolean) => void' is not assignable to type '(this: Class | ValueType | Object, ...parameters: Type[]) => ReturnType'.
  Types of parameters 'isPreviewEnabled' and 'parameters' are incompatible.
    Type 'Type' is not assignable to type 'boolean'.
      Type 'number' is not assignable to type 'boolean'.

seems to happen with any data type including il2cpp.{x} types, will error with "Type 'number' is not assignable to type '{x}'". using a number switches to "Type 'boolean' is not assignable to type 'number'". assumin this is some kind of external typescript/frida issue since the minimal example reads like other snippets here, but where is best to start in fixing that?

vfsfitvnm commented 11 months ago

This is a TS "limitation", please use ts-ignore to suppress the complaint:

// @ts-ignore
ctor.implementation = function (isPreviewEnabled: boolean) {
    this.method(".ctor").invoke();
};

More info here

movedaccount-droid commented 11 months ago

that was it, ty ty! very useful tool so far, thanks for workin on it