Added samples projects for MSVC binding.

Added MSVC support to unicorn samples.
This commit is contained in:
xorstream
2015-12-08 18:21:32 +11:00
parent c08fa22550
commit c5c13e110a
20 changed files with 1199 additions and 34 deletions

View File

@ -3,9 +3,28 @@
/* Sample code to demonstrate how to emulate Mips code (big endian) */
#include <inttypes.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
// code to be emulated
@ -126,8 +145,25 @@ static void test_mips_el(void)
int main(int argc, char **argv, char **envp)
{
test_mips_eb();
// 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
test_mips_eb();
test_mips_el();
// dynamically free shared library
#ifdef DYNLOAD
uc_dyn_free();
#endif
return 0;
}