Merge pull request #229 from practicalswift/typos

Fix typos. Remove trailing whitespace.
This commit is contained in:
Nguyen Anh Quynh
2015-10-31 10:39:35 +08:00
5 changed files with 12 additions and 12 deletions

View File

@ -205,7 +205,7 @@ Unicorn requires few dependent packages as follows.
[5] Cross-compile for iOS from Mac OSX. [5] Cross-compile for iOS from Mac OSX.
To cross-compile for iOS (iPhone/iPad/iPod), Mac OSX with XCode installed is required. To cross-compile for iOS (iPhone/iPad/iPod), Mac OSX with XCode installed is required.
- To cross-compile for ArmV7 (iPod 4, iPad 1/2/3, iPhone4, iPhone4S), run: - To cross-compile for ArmV7 (iPod 4, iPad 1/2/3, iPhone4, iPhone4S), run:
$ ./make.sh ios_armv7 $ ./make.sh ios_armv7
@ -268,5 +268,5 @@ Unicorn requires few dependent packages as follows.
Automated unit tests use the cmocka unit testing framework (https://cmocka.org/). Automated unit tests use the cmocka unit testing framework (https://cmocka.org/).
It can be installed in most Linux distros using the package manager, e.g. It can be installed in most Linux distros using the package manager, e.g.
`sudo yum install libcmocka libcmocka-devel`, or you can easily build and install it from source. `sudo yum install libcmocka libcmocka-devel`, or you can easily build and install it from source.
You can run the tests by running `make test` in the project directory. You can run the tests by running `make test` in the project directory.

View File

@ -1,7 +1,7 @@
# Package version of Unicorn for Makefile. # Package version of Unicorn for Makefile.
# To be used to generate unicorn.pc for pkg-config # To be used to generate unicorn.pc for pkg-config
# version major & minor # version major & minor
PKG_MAJOR = 0 PKG_MAJOR = 0
PKG_MINOR = 9 PKG_MINOR = 9

View File

@ -43,7 +43,7 @@ static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_da
if (uc_emu_stop(uc) != UC_ERR_OK) { if (uc_emu_stop(uc) != UC_ERR_OK) {
printf("not ok - uc_emu_stop fail during hook_code callback, addr: 0x%" PRIx64 "\n", addr); printf("not ok - uc_emu_stop fail during hook_code callback, addr: 0x%" PRIx64 "\n", addr);
_exit(-1); _exit(-1);
} }
} }
opcode = buf[0]; opcode = buf[0];
@ -137,7 +137,7 @@ static void do_nx_demo(bool cause_fault)
if (cause_fault) { if (cause_fault) {
// insert instruction to trigger U_PROT_EXEC change (see hook_code function) // insert instruction to trigger U_PROT_EXEC change (see hook_code function)
code_buf[0x1000] = 0x41; // inc ecx at page1 code_buf[0x1000] = 0x41; // inc ecx at page1
} }
// write machine code to be emulated to memory // write machine code to be emulated to memory
if (uc_mem_write(uc, 0x100000, code_buf, sizeof(code_buf))) { if (uc_mem_write(uc, 0x100000, code_buf, sizeof(code_buf))) {

View File

@ -13,7 +13,7 @@
// code to be emulated // code to be emulated
#define X86_CODE32 "\x41\x4a" // INC ecx; DEC edx #define X86_CODE32 "\x41\x4a" // INC ecx; DEC edx
#define X86_CODE32_JUMP "\xeb\x02\x90\x90\x90\x90\x90\x90" // jmp 4; nop; nop; nop; nop; nop; nop #define X86_CODE32_JUMP "\xeb\x02\x90\x90\x90\x90\x90\x90" // jmp 4; nop; nop; nop; nop; nop; nop
// #define X86_CODE32_SELF "\xeb\x1c\x5a\x89\xd6\x8b\x02\x66\x3d\xca\x7d\x75\x06\x66\x05\x03\x03\x89\x02\xfe\xc2\x3d\x41\x41\x41\x41\x75\xe9\xff\xe6\xe8\xdf\xff\xff\xff\x31\xd2\x6a\x0b\x58\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\xca\x7d\x41\x41\x41\x41" // #define X86_CODE32_SELF "\xeb\x1c\x5a\x89\xd6\x8b\x02\x66\x3d\xca\x7d\x75\x06\x66\x05\x03\x03\x89\x02\xfe\xc2\x3d\x41\x41\x41\x41\x75\xe9\xff\xe6\xe8\xdf\xff\xff\xff\x31\xd2\x6a\x0b\x58\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\xca\x7d\x41\x41\x41\x41"
//#define X86_CODE32 "\x51\x51\x51\x51" // PUSH ecx; //#define X86_CODE32 "\x51\x51\x51\x51" // PUSH ecx;
#define X86_CODE32_LOOP "\x41\x4a\xeb\xfe" // INC ecx; DEC edx; JMP self-loop #define X86_CODE32_LOOP "\x41\x4a\xeb\xfe" // INC ecx; DEC edx; JMP self-loop
#define X86_CODE32_MEM_WRITE "\x89\x0D\xAA\xAA\xAA\xAA\x41\x4a" // mov [0xaaaaaaaa], ecx; INC ecx; DEC edx #define X86_CODE32_MEM_WRITE "\x89\x0D\xAA\xAA\xAA\xAA\x41\x4a" // mov [0xaaaaaaaa], ecx; INC ecx; DEC edx
@ -23,7 +23,7 @@
#define X86_CODE32_INOUT "\x41\xE4\x3F\x4a\xE6\x46\x43" // INC ecx; IN AL, 0x3f; DEC edx; OUT 0x46, AL; INC ebx #define X86_CODE32_INOUT "\x41\xE4\x3F\x4a\xE6\x46\x43" // INC ecx; IN AL, 0x3f; DEC edx; OUT 0x46, AL; INC ebx
//#define X86_CODE64 "\x41\xBC\x3B\xB0\x28\x2A \x49\x0F\xC9 \x90 \x4D\x0F\xAD\xCF\x49\x87\xFD\x90\x48\x81\xD2\x8A\xCE\x77\x35\x48\xF7\xD9" // <== still crash //#define X86_CODE64 "\x41\xBC\x3B\xB0\x28\x2A \x49\x0F\xC9 \x90 \x4D\x0F\xAD\xCF\x49\x87\xFD\x90\x48\x81\xD2\x8A\xCE\x77\x35\x48\xF7\xD9" // <== still crash
//#define X86_CODE64 "\x41\xBC\x3B\xB0\x28\x2A\x49\x0F\xC9\x90\x4D\x0F\xAD\xCF\x49\x87\xFD\x90\x48\x81\xD2\x8A\xCE\x77\x35\x48\xF7\xD9" //#define X86_CODE64 "\x41\xBC\x3B\xB0\x28\x2A\x49\x0F\xC9\x90\x4D\x0F\xAD\xCF\x49\x87\xFD\x90\x48\x81\xD2\x8A\xCE\x77\x35\x48\xF7\xD9"
#define X86_CODE64 "\x41\xBC\x3B\xB0\x28\x2A\x49\x0F\xC9\x90\x4D\x0F\xAD\xCF\x49\x87\xFD\x90\x48\x81\xD2\x8A\xCE\x77\x35\x48\xF7\xD9\x4D\x29\xF4\x49\x81\xC9\xF6\x8A\xC6\x53\x4D\x87\xED\x48\x0F\xAD\xD2\x49\xF7\xD4\x48\xF7\xE1\x4D\x19\xC5\x4D\x89\xC5\x48\xF7\xD6\x41\xB8\x4F\x8D\x6B\x59\x4D\x87\xD0\x68\x6A\x1E\x09\x3C\x59" #define X86_CODE64 "\x41\xBC\x3B\xB0\x28\x2A\x49\x0F\xC9\x90\x4D\x0F\xAD\xCF\x49\x87\xFD\x90\x48\x81\xD2\x8A\xCE\x77\x35\x48\xF7\xD9\x4D\x29\xF4\x49\x81\xC9\xF6\x8A\xC6\x53\x4D\x87\xED\x48\x0F\xAD\xD2\x49\xF7\xD4\x48\xF7\xE1\x4D\x19\xC5\x4D\x89\xC5\x48\xF7\xD6\x41\xB8\x4F\x8D\x6B\x59\x4D\x87\xD0\x68\x6A\x1E\x09\x3C\x59"
#define X86_CODE16 "\x00\x00" // add byte ptr [bx + si], al #define X86_CODE16 "\x00\x00" // add byte ptr [bx + si], al
#define X86_CODE64_SYSCALL "\x0f\x05" // SYSCALL #define X86_CODE64_SYSCALL "\x0f\x05" // SYSCALL

10
uc.c
View File

@ -62,7 +62,7 @@ const char *uc_strerror(uc_err code)
case UC_ERR_NOMEM: case UC_ERR_NOMEM:
return "No memory available or memory not present (UC_ERR_NOMEM)"; return "No memory available or memory not present (UC_ERR_NOMEM)";
case UC_ERR_ARCH: case UC_ERR_ARCH:
return "Invalid/unsupported architecture(UC_ERR_ARCH)"; return "Invalid/unsupported architecture (UC_ERR_ARCH)";
case UC_ERR_HANDLE: case UC_ERR_HANDLE:
return "Invalid handle (UC_ERR_HANDLE)"; return "Invalid handle (UC_ERR_HANDLE)";
case UC_ERR_MODE: case UC_ERR_MODE:
@ -96,7 +96,7 @@ const char *uc_strerror(uc_err code)
case UC_ERR_FETCH_UNALIGNED: case UC_ERR_FETCH_UNALIGNED:
return "Fetch from unaligned memory (UC_ERR_FETCH_UNALIGNED)"; return "Fetch from unaligned memory (UC_ERR_FETCH_UNALIGNED)";
case UC_ERR_HOOK_EXIST: case UC_ERR_HOOK_EXIST:
return "Hook for this type event already existed (UC_ERR_HOOK_EXIST)"; return "Hook for this type event already exists (UC_ERR_HOOK_EXIST)";
} }
} }
@ -281,7 +281,7 @@ uc_err uc_close(uc_engine *uc)
uc->root->free(uc->root); uc->root->free(uc->root);
free(uc->hook_callbacks); free(uc->hook_callbacks);
free(uc->mapped_blocks); free(uc->mapped_blocks);
// finally, free uc itself. // finally, free uc itself.
@ -619,9 +619,9 @@ static uint8_t *copy_region(struct uc_struct *uc, MemoryRegion *mr)
parameter is true, the no new section will be created to replace the indicate parameter is true, the no new section will be created to replace the indicate
range. This functions exists to support uc_mem_protect and uc_mem_unmap. range. This functions exists to support uc_mem_protect and uc_mem_unmap.
This is a static function and callers have already done some preliminary This is a static function and callers have already done some preliminary
parameter validation. parameter validation.
The do_delete argument indicates that we are being called to support The do_delete argument indicates that we are being called to support
uc_mem_unmap. In this case we save some time by choosing NOT to remap uc_mem_unmap. In this case we save some time by choosing NOT to remap
the areas that are intended to get unmapped the areas that are intended to get unmapped