Automated leading tab to spaces conversion.

This commit is contained in:
xorstream
2017-01-21 12:28:22 +11:00
parent df41c49e2d
commit 770c5616e2
69 changed files with 3839 additions and 3839 deletions

View File

@ -334,7 +334,7 @@ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_open
*/
JNIEXPORT jint JNICALL Java_unicorn_Unicorn_version
(JNIEnv *env, jclass clz) {
return (jint)uc_version(NULL, NULL);
return (jint)uc_version(NULL, NULL);
}
/*
@ -344,7 +344,7 @@ JNIEXPORT jint JNICALL Java_unicorn_Unicorn_version
*/
JNIEXPORT jboolean JNICALL Java_unicorn_Unicorn_arch_1supported
(JNIEnv *env, jclass clz, jint arch) {
return (jboolean)(uc_arch_supported((uc_arch)arch) != 0);
return (jboolean)(uc_arch_supported((uc_arch)arch) != 0);
}
/*

View File

@ -31,11 +31,11 @@
// It should loop 3 times before ending.
const uint64_t addr = 0x100000;
const unsigned char loop_test_code[] = {
0x02,0x00,0x04,0x24, // 100000: li $a0, 2
// loop1
0x00,0x00,0x00,0x00, // 100004: nop
0xFE,0xFF,0x80,0x14, // 100008: bnez $a0, loop1
0xFF,0xFF,0x84,0x24, // 10000C: addiu $a0, -1
0x02,0x00,0x04,0x24, // 100000: li $a0, 2
// loop1
0x00,0x00,0x00,0x00, // 100004: nop
0xFE,0xFF,0x80,0x14, // 100008: bnez $a0, loop1
0xFF,0xFF,0x84,0x24, // 10000C: addiu $a0, -1
};
bool test_passed_ok = false;
int loop_count = 0;
@ -43,14 +43,14 @@ int loop_count = 0;
static void mips_codehook(uc_engine *uc, uint64_t address, uint32_t size, void *user_data)
{
if( address == 0x10000C )
test_passed_ok = true;
if( address == 0x100004 )
{
printf("\nloop %d:\n", loop_count);
loop_count++;
}
printf("Code: %llX\n", address);
if( address == 0x10000C )
test_passed_ok = true;
if( address == 0x100004 )
{
printf("\nloop %d:\n", loop_count);
loop_count++;
}
printf("Code: %llX\n", address);
}
@ -58,76 +58,76 @@ int main(int argc, char **argv, char **envp)
{
uc_engine *uc;
uc_err err;
uc_hook hhc;
uint32_t val;
uc_hook hhc;
uint32_t val;
// dynamically load shared library
// dynamically load shared library
#ifdef DYNLOAD
if( !uc_dyn_load(NULL, 0) )
{
printf("Error dynamically loading shared library.\n");
printf("Please check that unicorn.dll/unicorn.so is available as well as\n");
printf("any other dependent dll/so files.\n");
printf("The easiest way is to place them in the same directory as this app.\n");
return 1;
}
if( !uc_dyn_load(NULL, 0) )
{
printf("Error dynamically loading shared library.\n");
printf("Please check that unicorn.dll/unicorn.so is available as well as\n");
printf("any other dependent dll/so files.\n");
printf("The easiest way is to place them in the same directory as this app.\n");
return 1;
}
#endif
// Initialize emulator in MIPS 32bit little endian mode
// Initialize emulator in MIPS 32bit little endian mode
err = uc_open(UC_ARCH_MIPS, UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN, &uc);
if (err)
{
{
printf("Failed on uc_open() with error returned: %u\n", err);
return err;
}
// map in a page of mem
err = uc_mem_map(uc, addr, 0x1000, UC_PROT_ALL);
// map in a page of mem
err = uc_mem_map(uc, addr, 0x1000, UC_PROT_ALL);
if (err)
{
{
printf("Failed on uc_mem_map() with error returned: %u\n", err);
return err;
}
// write machine code to be emulated to memory
// write machine code to be emulated to memory
err = uc_mem_write(uc, addr, loop_test_code, sizeof(loop_test_code));
if( err )
{
if( err )
{
printf("Failed on uc_mem_write() with error returned: %u\n", err);
return err;
}
// hook all instructions by having @begin > @end
uc_hook_add(uc, &hhc, UC_HOOK_CODE, mips_codehook, NULL, (uint64_t)1, (uint64_t)0);
if( err )
{
if( err )
{
printf("Failed on uc_hook_add(code) with error returned: %u\n", err);
return err;
}
// execute code
printf("---- Executing Code ----\n");
err = uc_emu_start(uc, addr, addr + sizeof(loop_test_code), 0, 0);
printf("---- Executing Code ----\n");
err = uc_emu_start(uc, addr, addr + sizeof(loop_test_code), 0, 0);
if (err)
{
{
printf("Failed on uc_emu_start() with error returned %u: %s\n",
err, uc_strerror(err));
return err;
return err;
}
// done executing, print some reg values as a test
printf("---- Execution Complete ----\n\n");
uc_reg_read(uc, UC_MIPS_REG_PC, &val); printf("pc is %X\n", val);
uc_reg_read(uc, UC_MIPS_REG_A0, &val); printf("a0 is %X\n", val);
// free resources
uc_close(uc);
// dynamically free shared library
// done executing, print some reg values as a test
printf("---- Execution Complete ----\n\n");
uc_reg_read(uc, UC_MIPS_REG_PC, &val); printf("pc is %X\n", val);
uc_reg_read(uc, UC_MIPS_REG_A0, &val); printf("a0 is %X\n", val);
// free resources
uc_close(uc);
// dynamically free shared library
#ifdef DYNLOAD
uc_dyn_free();
#endif
return 0;
return 0;
}

View File

@ -154,12 +154,12 @@ bool uc_dyn_load(const char* path, int flags)
gp_uc_mem_protect = (uc_mem_protect_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_mem_protect");
gp_uc_mem_regions = (uc_mem_regions_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_mem_regions");
gp_uc_context_alloc = (uc_context_alloc_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_context_alloc");
gp_uc_context_save = (uc_context_save_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_context_save");
gp_uc_context_restore = (uc_context_restore_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_context_restore");
gp_uc_free = (uc_free_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_free");
gp_uc_context_save = (uc_context_save_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_context_save");
gp_uc_context_restore = (uc_context_restore_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_context_restore");
gp_uc_free = (uc_free_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_free");
//support old compiled dlls
if(gp_uc_free==0) gp_uc_free = (uc_free_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_context_free");
//support old compiled dlls
if(gp_uc_free==0) gp_uc_free = (uc_free_t)DYNLOAD_GETFUNC(g_dyn_handle, "uc_context_free");
return true;
}
@ -194,10 +194,10 @@ bool uc_dyn_free(void)
gp_uc_mem_unmap = NULL;
gp_uc_mem_protect = NULL;
gp_uc_mem_regions = NULL;
gp_uc_context_alloc = NULL;
gp_uc_context_save = NULL;
gp_uc_context_restore = NULL;
gp_uc_free = NULL;
gp_uc_context_alloc = NULL;
gp_uc_context_save = NULL;
gp_uc_context_restore = NULL;
gp_uc_free = NULL;
return true;
}
@ -350,20 +350,20 @@ uc_err uc_mem_regions(uc_engine *uc, uc_mem_region **regions, uint32_t *count)
}
uc_err uc_context_alloc(uc_engine *uc, uc_context **context){
return gp_uc_context_alloc(uc,context);
return gp_uc_context_alloc(uc,context);
}
uc_err uc_context_save(uc_engine *uc, uc_context *context)
{
return gp_uc_context_save(uc,context);
return gp_uc_context_save(uc,context);
}
uc_err uc_context_restore(uc_engine *uc, uc_context *context){
return gp_uc_context_restore(uc,context);
return gp_uc_context_restore(uc,context);
}
uc_err uc_free(void *mem){
return gp_uc_free(mem);
return gp_uc_free(mem);
}