Il2CppImage.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {NativeStruct} from "./NativeStruct";
  2. import {il2cppApi} from "../il2cppApi";
  3. import {getStructOffset, StructItem} from "./structItem";
  4. import {FromTypeDefinition_Addr, soName, UNITY_VER, UnityVer} from "../../config";
  5. import {Il2CppClass} from "./Il2CppClass";
  6. import {log} from "../../logger";
  7. let il2CppImage_struct = new Array();
  8. il2CppImage_struct.push(new StructItem("name", Process.pointerSize));
  9. il2CppImage_struct.push(new StructItem("nameNoExt", Process.pointerSize));
  10. il2CppImage_struct.push(new StructItem("assemblyIndex", Process.pointerSize));
  11. il2CppImage_struct.push(new StructItem("typeStart", 4));
  12. il2CppImage_struct.push(new StructItem("typeCount", 4));
  13. il2CppImage_struct.push(new StructItem("exportedTypeStart", 4));
  14. export class Il2CppImage extends NativeStruct {
  15. name() {
  16. return il2cppApi.il2cpp_image_get_name(this).readCString();
  17. }
  18. nameNoExt() {
  19. let name1 = this.name();
  20. return name1.replace(".dll", "");
  21. }
  22. typeStart() {
  23. return this.get("typeStart").readPointer().toInt32();
  24. }
  25. typeCount() {
  26. return il2cppApi.il2cpp_image_get_class_count(this);
  27. // return this.getOffsetTypeCount();
  28. }
  29. getOffsetTypeCount(){
  30. if (UNITY_VER===UnityVer.V_2020){
  31. return this.add(24).readPointer().toInt32();
  32. }else {
  33. return this.get("typeCount").readPointer().toInt32();
  34. }
  35. }
  36. getClass(index) {
  37. return il2cppApi.il2cpp_image_get_class(this, index);
  38. }
  39. get(params) {
  40. return this.add(getStructOffset(il2CppImage_struct, params));
  41. }
  42. }