-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Hi. I am dealing with the problem of mapping local variables and arguments with returned arguments at functions in IDA Pro. That is, type mapping.
My goal is that when I load a binary into IDA Pro, it will automatically get all the type information it needs in a .pdb file, without having to manually convert pointers to structures from the developer. For example:
What's happening now:
public class Person
{
public int Id { get; set; }
public int Age { get; set; }
public string Name { get; set; }
}
internal class Program
{
static void Main(string[] args)
{
Person person = new Person
{
Id = 1,
Name = "Test",
Age = 15
};
PrintPersonAge(person);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void PrintPersonAge(Person person)
{
Console.WriteLine(person.Age);
}
}
In the decompiled version from IDA, the arguments are not automatically inserted, although they are specified in Local Types.
repro_Program__PrintPersonAge proc near
var_8= byte ptr -8
push rbp
push rdi
sub rsp, 28h
lea rbp, [rsp+38h+var_8]
mov [rbp+10h], rcx
nop
mov rcx, [rbp+10h]
call repro_Person__get_Age
mov [rbp-0Ch], eax
mov ecx, [rbp-0Ch]
call System_Console_System_Console__WriteLine_7
nop
nop
add rsp, 28h
pop rdi
pop rbp
retn
repro_Program__PrintPersonAge endp
I decided to use cvdump.exe to see what data is generated, and saw a strange thing:
The type of the process was not specified. I decided to find out what the problem was and it was because the methodTypeIndex variable was not used in the EmitSubprogramInfo method in the “ILCompiler.Compiler\Compiler\ObjectWriter\CodeView\CodeViewSymbolsBuilder.cs” file.
I made the variable write but an additional problem appeared. In the following dump I saw this:
The reference pointed to a completely empty forward ref type, when the full type was under a completely different number:
BUT! Some structures and classes are successfully caught by IDA Pro and shown in the disassembler. That is, after my change, this structure arguments were successfully inserted automatically.
I think the problem is in the file "ILCompiler.Compiler\Compiler\UserDefinedTypeDescriptor.cs" and it has something to do with:
private Dictionary<TypeDesc, uint> _knownTypes = new Dictionary<TypeDesc, uint>();
private Dictionary<TypeDesc, uint> _completeKnownTypes = new Dictionary<TypeDesc, uint>();
Most likely, an empty copy of the class is generated initially, so methodTypeIndex may point to it, but I could be wrong. I would be grateful if you could look into this problem.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status