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,11 +3,31 @@
/* Sample code to demonstrate how to emulate X86 code */
#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
@ -792,7 +812,19 @@ static void test_x86_16(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();
test_i386_inout();
@ -823,5 +855,10 @@ int main(int argc, char **argv, char **envp)
printf("Syntax: %s <-16|-32|-64>\n", argv[0]);
}
// dynamically free shared library
#ifdef DYNLOAD
uc_dyn_free();
#endif
return 0;
}