mirror of
https://github.com/Perfare/Il2CppDumper.git
synced 2025-01-25 02:03:02 -03:00
修复DummyDll泛型参数错误
This commit is contained in:
parent
8d1a77ddda
commit
1e837a05b5
3 changed files with 57 additions and 16 deletions
|
@ -15,7 +15,7 @@ namespace Il2CppDumper
|
|||
public List<AssemblyDefinition> Assemblies = new List<AssemblyDefinition>();
|
||||
private Dictionary<long, TypeDefinition> typeDefinitionDic = new Dictionary<long, TypeDefinition>();
|
||||
private Dictionary<int, MethodDefinition> methodDefinitionDic = new Dictionary<int, MethodDefinition>();
|
||||
private Dictionary<Il2CppType, GenericParameter> genericParameterDic = new Dictionary<Il2CppType, GenericParameter>();
|
||||
private Dictionary<long, GenericParameter> genericParameterDic = new Dictionary<long, GenericParameter>();
|
||||
|
||||
|
||||
public DummyAssemblyCreator(Metadata metadata, Il2Cpp il2cpp)
|
||||
|
@ -169,10 +169,24 @@ namespace Il2CppDumper
|
|||
var genericContainer = metadata.genericContainers[methodDef.genericContainerIndex];
|
||||
if (genericContainer.type_argc > methodDefinition.GenericParameters.Count)
|
||||
{
|
||||
for (int j = methodDefinition.GenericParameters.Count + 1; j <= genericContainer.type_argc; j++)
|
||||
for (int j = 0; j < genericContainer.type_argc; j++)
|
||||
{
|
||||
var genericParameter = new GenericParameter("T" + j, methodDefinition);
|
||||
methodDefinition.GenericParameters.Add(genericParameter);
|
||||
var genericParameterIndex = genericContainer.genericParameterStart + j;
|
||||
var param = metadata.genericParameters[genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
if (!genericParameterDic.TryGetValue(genericParameterIndex, out var genericParameter))
|
||||
{
|
||||
genericParameter = new GenericParameter(genericName, methodDefinition);
|
||||
methodDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(genericParameterIndex, genericParameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!methodDefinition.GenericParameters.Contains(genericParameter))
|
||||
{
|
||||
methodDefinition.GenericParameters.Add(genericParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,10 +252,24 @@ namespace Il2CppDumper
|
|||
var genericContainer = metadata.genericContainers[typeDef.genericContainerIndex];
|
||||
if (genericContainer.type_argc > typeDefinition.GenericParameters.Count)
|
||||
{
|
||||
for (int j = typeDefinition.GenericParameters.Count + 1; j <= genericContainer.type_argc; j++)
|
||||
for (int i = 0; i < genericContainer.type_argc; i++)
|
||||
{
|
||||
var genericParameter = new GenericParameter("T" + j, typeDefinition);
|
||||
typeDefinition.GenericParameters.Add(genericParameter);
|
||||
var genericParameterIndex = genericContainer.genericParameterStart + i;
|
||||
var param = metadata.genericParameters[genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
if (!genericParameterDic.TryGetValue(genericParameterIndex, out var genericParameter))
|
||||
{
|
||||
genericParameter = new GenericParameter(genericName, typeDefinition);
|
||||
typeDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(genericParameterIndex, genericParameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!typeDefinition.GenericParameters.Contains(genericParameter))
|
||||
{
|
||||
typeDefinition.GenericParameters.Add(genericParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -367,36 +395,37 @@ namespace Il2CppDumper
|
|||
}
|
||||
case Il2CppTypeEnum.IL2CPP_TYPE_VAR:
|
||||
{
|
||||
if (genericParameterDic.TryGetValue(il2CppType, out var genericParameter))
|
||||
if (genericParameterDic.TryGetValue(il2CppType.data.genericParameterIndex, out var genericParameter))
|
||||
{
|
||||
return genericParameter;
|
||||
}
|
||||
var param = metadata.genericParameters[il2CppType.data.genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
if (memberReference is MethodDefinition methodDefinition)
|
||||
{
|
||||
var genericName = "T" + (methodDefinition.DeclaringType.GenericParameters.Count + 1);
|
||||
genericParameter = new GenericParameter(genericName, methodDefinition.DeclaringType);
|
||||
methodDefinition.DeclaringType.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(il2CppType, genericParameter);
|
||||
genericParameterDic.Add(il2CppType.data.genericParameterIndex, genericParameter);
|
||||
return genericParameter;
|
||||
}
|
||||
var typeDefinition = (TypeDefinition)memberReference;
|
||||
var genericName2 = "T" + (typeDefinition.GenericParameters.Count + 1);
|
||||
genericParameter = new GenericParameter(genericName2, typeDefinition);
|
||||
genericParameter = new GenericParameter(genericName, typeDefinition);
|
||||
typeDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(il2CppType, genericParameter);
|
||||
genericParameterDic.Add(il2CppType.data.genericParameterIndex, genericParameter);
|
||||
return genericParameter;
|
||||
}
|
||||
case Il2CppTypeEnum.IL2CPP_TYPE_MVAR:
|
||||
{
|
||||
if (genericParameterDic.TryGetValue(il2CppType, out var genericParameter))
|
||||
if (genericParameterDic.TryGetValue(il2CppType.data.genericParameterIndex, out var genericParameter))
|
||||
{
|
||||
return genericParameter;
|
||||
}
|
||||
var methodDefinition = (MethodDefinition)memberReference;
|
||||
var genericName = "T" + (methodDefinition.GenericParameters.Count + 1);
|
||||
var param = metadata.genericParameters[il2CppType.data.genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
genericParameter = new GenericParameter(genericName, methodDefinition);
|
||||
methodDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(il2CppType, genericParameter);
|
||||
genericParameterDic.Add(il2CppType.data.genericParameterIndex, genericParameter);
|
||||
return genericParameter;
|
||||
}
|
||||
case Il2CppTypeEnum.IL2CPP_TYPE_PTR:
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace Il2CppDumper
|
|||
public Il2CppEventDefinition[] eventDefs;
|
||||
public Il2CppGenericContainer[] genericContainers;
|
||||
public Il2CppFieldRef[] fieldRefs;
|
||||
public Il2CppGenericParameter[] genericParameters;
|
||||
|
||||
public Metadata(Stream stream, float version) : base(stream)
|
||||
{
|
||||
|
@ -63,6 +64,7 @@ namespace Il2CppDumper
|
|||
nestedTypeIndices = ReadClassArray<int>(metadataHeader.nestedTypesOffset, metadataHeader.nestedTypesCount / 4);
|
||||
eventDefs = ReadMetadataClassArray<Il2CppEventDefinition>(metadataHeader.eventsOffset, metadataHeader.eventsCount);
|
||||
genericContainers = ReadMetadataClassArray<Il2CppGenericContainer>(metadataHeader.genericContainersOffset, metadataHeader.genericContainersCount);
|
||||
genericParameters = ReadMetadataClassArray<Il2CppGenericParameter>(metadataHeader.genericParametersOffset, metadataHeader.genericParametersCount);
|
||||
if (version > 16)
|
||||
{
|
||||
stringLiterals = ReadMetadataClassArray<Il2CppStringLiteral>(metadataHeader.stringLiteralOffset, metadataHeader.stringLiteralCount);
|
||||
|
|
|
@ -307,4 +307,14 @@ namespace Il2CppDumper
|
|||
public int typeIndex;
|
||||
public int fieldIndex; // local offset into type fields
|
||||
}
|
||||
|
||||
public class Il2CppGenericParameter
|
||||
{
|
||||
public int ownerIndex; /* Type or method this parameter was defined in. */
|
||||
public int nameIndex;
|
||||
public short constraintsStart;
|
||||
public short constraintsCount;
|
||||
public ushort num;
|
||||
public ushort flags;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue