可以通过如下方法获得Il2CppImageDefinition数组,并且进行遍历。
Il2CppGlobalMetadataHeader
*
header
=
(Il2CppGlobalMetadataHeader
*
)ptr;
if
(header
-
>sanity!
=
0xFAB11BAF
|| header
-
>stringLiteralOffset!
=
sizeof(Il2CppGlobalMetadataHeader))
{
printf(
"invalid file..\n"
);
return
0
;
}
int
image_count
=
header
-
>imagesSize
/
sizeof(Il2CppImageDefinition);
for
(
int
i
=
0
;i<image_count;i
+
+
)
{
const Il2CppImageDefinition
*
image
=
&image_arr[i];
}
Il2CppGlobalMetadataHeader
*
header
=
(Il2CppGlobalMetadataHeader
*
)ptr;
if
(header
-
>sanity!
=
0xFAB11BAF
|| header
-
>stringLiteralOffset!
=
sizeof(Il2CppGlobalMetadataHeader))
{
printf(
"invalid file..\n"
);
return
0
;
}
int
image_count
=
header
-
>imagesSize
/
sizeof(Il2CppImageDefinition);
for
(
int
i
=
0
;i<image_count;i
+
+
)
{
const Il2CppImageDefinition
*
image
=
&image_arr[i];
}
static const char
*
GetStringFromIndex(StringIndex index)
{
return
(const char
*
)(((Il2CppGlobalMetadataHeader
*
)ptr)
-
>stringOffset
+
ptr
+
index);
}
static const char
*
GetStringFromIndex(StringIndex index)
{
return
(const char
*
)(((Il2CppGlobalMetadataHeader
*
)ptr)
-
>stringOffset
+
ptr
+
index);
}
static const Il2CppTypeDefinition
*
GetTypeDefinitionFromIndex(TypeDefinitionIndex index)
{
return
(const Il2CppTypeDefinition
*
)(ptr
+
((Il2CppGlobalMetadataHeader
*
)ptr)
-
>typeDefinitionsOffset)
+
index;
}
static const Il2CppTypeDefinition
*
GetTypeDefinitionFromIndex(TypeDefinitionIndex index)
{
return
(const Il2CppTypeDefinition
*
)(ptr
+
((Il2CppGlobalMetadataHeader
*
)ptr)
-
>typeDefinitionsOffset)
+
index;
}
const Il2CppImageDefinition
*
image
=
&image_arr[i];
printf(
"image: %s\n"
,GetStringFromIndex(image
-
>nameIndex));
for
(
int
j
=
0
;j<image
-
>typeCount;j
+
+
)
{
const Il2CppTypeDefinition
*
type
=
GetTypeDefinitionFromIndex(image
-
>typeStart
+
j);
printf(
"class: %s:%s\n"
,GetStringFromIndex(
type
-
>namespaceIndex),GetStringFromIndex(
type
-
>nameIndex));
}
const Il2CppImageDefinition
*
image
=
&image_arr[i];
printf(
"image: %s\n"
,GetStringFromIndex(image
-
>nameIndex));
for
(
int
j
=
0
;j<image
-
>typeCount;j
+
+
)
{
const Il2CppTypeDefinition
*
type
=
GetTypeDefinitionFromIndex(image
-
>typeStart
+
j);
printf(
"class: %s:%s\n"
,GetStringFromIndex(
type
-
>namespaceIndex),GetStringFromIndex(
type
-
>nameIndex));
}
static const Il2CppMethodDefinition
*
GetMethodDefinitionFromIndex(MethodIndex index)
{
return
(const Il2CppMethodDefinition
*
)(((Il2CppGlobalMetadataHeader
*
)ptr)
-
>methodsOffset
+
ptr)
+
index;
}
static const Il2CppFieldDefinition
*
GetFieldDefinitionFromIndex(FieldIndex index)
{
return
(const Il2CppFieldDefinition
*
)(ptr
+
((Il2CppGlobalMetadataHeader
*
)ptr)
-
>fieldsOffset)
+
index;
}
static const Il2CppMethodDefinition
*
GetMethodDefinitionFromIndex(MethodIndex index)
{
return
(const Il2CppMethodDefinition
*
)(((Il2CppGlobalMetadataHeader
*
)ptr)
-
>methodsOffset
+
ptr)
+
index;
}
static const Il2CppFieldDefinition
*
GetFieldDefinitionFromIndex(FieldIndex index)
{
return
(const Il2CppFieldDefinition
*
)(ptr
+
((Il2CppGlobalMetadataHeader
*
)ptr)
-
>fieldsOffset)
+
index;
}
uint32_t GetMethodPointer(const Il2CppImageDefinition
*
image,uint32_t token)
{
for
(
int
i
=
0
;i<CodeRegistration
-
>codeGenModulesCount;i
+
+
)
{
const Il2CppCodeGenModule
*
module
=
CodeRegistration
-
>codeGenModules[i];
if
(!strcmp(module
-
>moduleName,GetStringFromIndex(image
-
>nameIndex)))
{
return
module
-
>methodPointers[GetTokenRowId(token)
-
1
];
}
}
printf(
"invalid!\n"
);
return
0
;
}
uint32_t GetMethodPointer(const Il2CppImageDefinition
*
image,uint32_t token)
{
for
(
int
i
=
0
;i<CodeRegistration
-
>codeGenModulesCount;i
+
+
)
{
const Il2CppCodeGenModule
*
module
=
CodeRegistration
-
>codeGenModules[i];
if
(!strcmp(module
-
>moduleName,GetStringFromIndex(image
-
>nameIndex)))
{
return
module
-
>methodPointers[GetTokenRowId(token)
-
1
];
}
}
printf(
"invalid!\n"
);
return
0
;
}
static TypeDefinitionIndex GetIndexForTypeDefinitionInternal(const Il2CppTypeDefinition
*
typeDefinition)
{
const Il2CppTypeDefinition
*
typeDefinitions
=
(const Il2CppTypeDefinition
*
)(ptr
+
((Il2CppGlobalMetadataHeader
*
)ptr)
-
>typeDefinitionsOffset);
ptrdiff_t index
=
typeDefinition
-
typeDefinitions;
return
(TypeDefinitionIndex)index;
}
static TypeDefinitionIndex GetIndexForTypeDefinitionInternal(const Il2CppTypeDefinition
*
typeDefinition)
{
const Il2CppTypeDefinition
*
typeDefinitions
=
(const Il2CppTypeDefinition
*
)(ptr
+
((Il2CppGlobalMetadataHeader
*
)ptr)
-
>typeDefinitionsOffset);
ptrdiff_t index
=
typeDefinition
-
typeDefinitions;
return
(TypeDefinitionIndex)index;
}
uint32_t GetFieldOffset(TypeDefinitionIndex typeIndex,uint32_t index)
{
return
MetadataRegistration
-
>fieldOffsets[typeIndex][index];
}
uint32_t GetFieldOffset(TypeDefinitionIndex typeIndex,uint32_t index)
{
return
MetadataRegistration
-
>fieldOffsets[typeIndex][index];
}
[招生]系统0day安全班,企业级设备固件漏洞挖掘,Linux平台漏洞挖掘!