This commit is contained in:
Nguyen Anh Quynh 2016-10-26 17:06:59 +08:00
commit 23ffa91cee

View file

@ -8,20 +8,20 @@
int main() int main()
{ {
uc_engine *uc; uc_engine *uc = NULL;
uint8_t *buf, *buf2; uint8_t *buf = NULL, *buf2 = NULL;
int i; int i;
uc_err err; uc_err err;
err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc); err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc);
if (err) { if (err) {
printf ("uc_open %d\n", err); printf ("uc_open %d\n", err);
return 1; goto exit;
} }
err = uc_mem_map (uc, ADDR, SIZE, UC_PROT_ALL); err = uc_mem_map (uc, ADDR, SIZE, UC_PROT_ALL);
if (err) { if (err) {
printf ("uc_mem_map %d\n", err); printf ("uc_mem_map %d\n", err);
return 1; goto exit;
} }
buf = calloc (SIZE*2, 1); buf = calloc (SIZE*2, 1);
buf2 = calloc (SIZE, 1); buf2 = calloc (SIZE, 1);
@ -31,20 +31,24 @@ int main()
/* crash here */ /* crash here */
err = uc_mem_write (uc, ADDR, buf, SIZE+OVERFLOW); err = uc_mem_write (uc, ADDR, buf, SIZE+OVERFLOW);
if (err) { if (err) {
printf ("uc_mem_map %d\n", err); printf ("uc_mem_write %d\n", err);
return 1; goto exit;
} }
err = uc_mem_read (uc, ADDR+10, buf2, 4); err = uc_mem_read (uc, ADDR+10, buf2, 4);
if (err) { if (err) {
printf ("uc_mem_map %d\n", err); printf ("uc_mem_read %d\n", err);
return 1; goto exit;
} }
if (buf2[0] != 0xa) { if (buf2[0] != 0xa) {
printf ("mem contents are wrong\n"); printf ("mem contents are wrong\n");
return 1; goto exit;
} }
printf ("OK\n"); printf ("OK\n");
exit:
if (uc)
uc_close (uc);
free (buf); free (buf);
free (buf2); free (buf2);
return 0; return err ? 1 : 0;
} }