Support for variable size structure array in decompiler

Abierto
#3,530 1 comentario 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
c, cpp

Línea de trabajo

Start with the supplied C reproduction and compare its current HLIL output with the expected indexed structure-array accesses. Trace the decompiler path responsible for structure-member and pointer-array indexing, then add coverage demonstrating the expected output and verify that both the allocation loop and print_persons example decompile correctly.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Component: Core Effort: Medium Impact: Medium

I've a structure which have a variable sized structure array in it. After importing and setting types it decompiled like this in HLIL:

people people
people.count = 0
people.arr = malloc(0x30)

... (memset )

for (int32_t i = 0; i s<= 3; i = i + 1)
    //expected: people.arr[i].age = i
    people.arr[sx.q(i) * 4] = i
    //expected: people.arr[i].name = "test name"
    *(people.arr + sx.q(i) * 0x10 + 8) = "test name"
    people.count = people.count + 1

print_persons(people: &people)

print_persons

for (int32_t i = 0; i s< 3; i = i + 1)
    printf("Person: %s, Age:%d\n", people->arr[sx.q(i)].name, zx.q(people->arr[sx.q(i)].age))

I guess this is not a bug, but a feature not implemented yet. I could not find an issue for it so creating one for tracking it.

Test code:

typedef struct _person
{
	int age;
	char* name;
}person;

typedef struct _people
{
	int count;
	person* arr;
}people;


void print_persons(people *people)
{
	for (int i = 0; i < 3; i++)
	{
		printf("Person: %s, Age:%d\n", people->arr[i].name, people->arr[i].age);
	}
}

int main()
{
	people people;

	people.count = 0;
	people.arr = malloc(sizeof(person) * 3);

	memset(people.arr, 0, sizeof(person) * 3);

	for (int i = 0; i <= 3; i++)
	{
		people.arr[i].age = i;
		people.arr[i].name = "test name";
		people.count++;
	}

	print_persons(&people);
}
Lenguaje dominante
C++
Estrellas
1.3k
Forks
298
Merge medio
5 d 5 h
PR fusionados (30 d)
19

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Vector35/binaryninja-api

Todos los issues de Vector35/binaryninja-api

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.