Added samples projects for MSVC binding.
Added MSVC support to unicorn samples.
This commit is contained in:
@ -3,11 +3,31 @@
|
||||
|
||||
/* Sample code to trace code with Linux code with syscall */
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// windows specific
|
||||
#ifdef _MSC_VER
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#define PRIx64 "llX"
|
||||
#ifdef DYNLOAD
|
||||
#include <unicorn/unicorn_dynload.h>
|
||||
#else // DYNLOAD
|
||||
#include <unicorn/unicorn.h>
|
||||
#ifdef _WIN64
|
||||
#pragma comment(lib, "unicorn_staload64.lib")
|
||||
#else // _WIN64
|
||||
#pragma comment(lib, "unicorn_staload.lib")
|
||||
#endif // _WIN64
|
||||
#endif // DYNLOAD
|
||||
|
||||
// posix specific
|
||||
#else // _MSC_VER
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <unicorn/unicorn.h>
|
||||
#endif // _MSC_VER
|
||||
|
||||
// common includes
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// code to be emulated
|
||||
@ -32,7 +52,7 @@ static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user
|
||||
|
||||
size = MIN(sizeof(tmp), size);
|
||||
if (!uc_mem_read(uc, address, tmp, size)) {
|
||||
int i;
|
||||
uint32_t i;
|
||||
for (i=0; i<size; i++) {
|
||||
printf("%x ", tmp[i]);
|
||||
}
|
||||
@ -137,7 +157,19 @@ static void test_i386(void)
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
if (argc == 2) {
|
||||
// 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc == 2) {
|
||||
if (!strcmp(argv[1], "-32")) {
|
||||
test_i386();
|
||||
}
|
||||
@ -145,5 +177,10 @@ int main(int argc, char **argv, char **envp)
|
||||
printf("Syntax: %s <-32|-64>\n", argv[0]);
|
||||
}
|
||||
|
||||
// dynamically free shared library
|
||||
#ifdef DYNLOAD
|
||||
uc_dyn_free();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user