mirror of
https://github.com/Vita3K/unicorn.git
synced 2024-11-30 16:50:56 +00:00
commit
2a6f1f471f
@ -1,7 +1,9 @@
|
||||
CFLAGS += -I../include
|
||||
LDFLAGS = -L.. -lunicorn
|
||||
|
||||
TESTS = map_crash sigill sigill2 block_test
|
||||
TESTS = map_crash map_write
|
||||
TESTS += sigill sigill2
|
||||
TESTS += block_test
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
|
49
regress/map_write.c
Normal file
49
regress/map_write.c
Normal file
@ -0,0 +1,49 @@
|
||||
#include <unicorn/unicorn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ADDR 0x00400000
|
||||
#define SIZE 1024*64
|
||||
#define OVERFLOW 1
|
||||
|
||||
int main() {
|
||||
uch uh;
|
||||
char *buf, *buf2;
|
||||
int i;
|
||||
uc_err err;
|
||||
|
||||
err = uc_open (UC_ARCH_X86, UC_MODE_64, &uh);
|
||||
if (err) {
|
||||
printf ("uc_open %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
err = uc_mem_map (uh, ADDR, SIZE);
|
||||
if (err) {
|
||||
printf ("uc_mem_map %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
buf = calloc (SIZE*2, 1);
|
||||
buf2 = calloc (SIZE, 1);
|
||||
for (i=0;i<SIZE; i++) {
|
||||
buf[i] = i & 0xff;
|
||||
}
|
||||
/* crash here */
|
||||
err = uc_mem_write (uh, ADDR, buf, SIZE+OVERFLOW);
|
||||
if (err) {
|
||||
printf ("uc_mem_map %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
err = uc_mem_read (uh, ADDR+10, buf2, 4);
|
||||
if (err) {
|
||||
printf ("uc_mem_map %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
if (buf2[0] != 0xa) {
|
||||
printf ("mem contents are wrong\n");
|
||||
return 1;
|
||||
}
|
||||
printf ("OK\n");
|
||||
free (buf);
|
||||
free (buf2);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user