Closed Alireza-Razavi closed 3 years ago
It is the pointer to the buffer that contains the assembled instructions/machine code.
Thanks for your answer. How should i write it in Qt/Cpp ? Could you leave me an example code ?
char decoded[128];
vle_t *instr = NULL;
vle_handle handle = {0};
if (vle_init(&handle, buffer, buffer_size, start_address) != 0) {
// do something since it errored
}
while((instr = vle_next(&handle))) {
vle_snprint(decoded, sizeof(decoded), instr);
printf("decoded: %s\n", decoded);
vle_free(instr);
}
You have not initialized the 'buffer' but you passed to the function. How is it possible to pass an argument which is not declared?!
because you are the one that is supposed to pass the buffer to a .text
segment; this library does not implement any executable parser like ELF, PE, etc..
If you use capstone or any similar libraries, is the same
So we couldn't disassemble a Dump file which is compiled for the Power PC with VLE processors ? I have a dump file that i have read from a micro controller (SPC5 with Power architecture) and i wanted to disassemble it using this library.
if the dump is raw binary section, yes you can, if it is not, then you need to parse the container.
You can find which format is the file by using file
or binwalk
or rz-bin
(from https://rizin.re)
ut8 buffer[256]; // Read bytes from dump and load into buffer
ut8 *p = &buffer[0]; // Pointer to the first element of array
ut32 start_address = 0x08004000;
vle_t* instr = NULL;
vle_handle handle;
if (vle_init(&handle, p, 256, start_address)) {
printf("failed to initialize handle\n");
return;
}
This is correct ?
yes
Thanks a lot.
I have compiled the project using make.exe and it gave me a static library (.a file extension) Then i imported the static library into my Qt project. I wanna paste the code that you have written in 'example' section in your README file but there is one argument 'buffer' is missed. What is the 'buffer' argument in vle_init(...) and what should i pass ??