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
1.04k stars 203 forks source link

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

Closed movedaccount-droid closed 1 year ago

movedaccount-droid commented 1 year 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 1 year 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 1 year ago

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