2015-08-24 13:00:54 +02:00
|
|
|
#include <unicorn/unicorn.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define UC_BUG_WRITE_SIZE 13000
|
2015-08-28 12:21:36 +02:00
|
|
|
#define UC_BUG_WRITE_ADDR 0x1000
|
2015-08-24 13:00:54 +02:00
|
|
|
|
2015-08-28 12:21:36 +02:00
|
|
|
int main()
|
|
|
|
{
|
2015-08-24 14:21:57 +02:00
|
|
|
int size;
|
|
|
|
uint8_t *buf;
|
2015-09-05 05:20:32 +02:00
|
|
|
uc_engine *uc;
|
2015-08-26 15:29:28 +02:00
|
|
|
uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc);
|
2015-08-24 14:21:57 +02:00
|
|
|
if (err) {
|
|
|
|
fprintf (stderr, "Cannot initialize unicorn\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
size = UC_BUG_WRITE_SIZE;
|
|
|
|
buf = malloc (size);
|
|
|
|
if (!buf) {
|
|
|
|
fprintf (stderr, "Cannot allocate\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
memset (buf, 0, size);
|
2015-08-30 06:02:33 +02:00
|
|
|
if (!uc_mem_map (uc, UC_BUG_WRITE_ADDR, size, UC_PROT_ALL)) {
|
|
|
|
uc_mem_write (uc, UC_BUG_WRITE_ADDR, buf, size);
|
2015-08-24 14:21:57 +02:00
|
|
|
}
|
2015-08-26 15:29:28 +02:00
|
|
|
uc_close(uc);
|
2015-08-24 14:21:57 +02:00
|
|
|
return 0;
|
2015-08-24 13:00:54 +02:00
|
|
|
}
|