Added samples projects for MSVC binding.
Added MSVC support to unicorn samples.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
This directory contains bindings & test code for Python, Java, Go and .NET.
|
||||
This directory contains bindings & test code for Python, Java, Go, .NET and MSVC.
|
||||
See <language>/README or <language>/README.TXT for how to install each binding.
|
||||
|
||||
The following bindings are contributed by community.
|
||||
@ -6,6 +6,7 @@ The following bindings are contributed by community.
|
||||
- Java binding: by Chris Eagle.
|
||||
- Go binding: by Ryan Hileman.
|
||||
- .NET binding: by Antonio Parata.
|
||||
- MSVC binding: by Zak Escano
|
||||
|
||||
More bindings created & maintained externally by community are available as follows.
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
|
||||
|
||||
:: Overview
|
||||
|
||||
This documentation explains how to use Unicorn with Microsoft Visual C++ (MSVC).
|
||||
This will not build the Unicorn Engine itself, it just allows you to use the
|
||||
prebuilt Windows binaries when writing projects in Microsoft Visual C++.
|
||||
@ -8,17 +12,19 @@ heading on the following page. Be sure to use the 32bit package when making
|
||||
build 64bit applications.
|
||||
http://www.unicorn-engine.org/download/
|
||||
|
||||
|
||||
|
||||
It is not possible to use the prebuilt static Unicorn library, unicorn.lib,
|
||||
It is not possible to use the prebuilt static Unicorn library "unicorn.lib"
|
||||
with Microsoft Visual C++ because it will complain about a bunch of missing
|
||||
functions, variables etc.
|
||||
|
||||
We therefore use the prebuilt dynamic Unicorn library, unicorn.dll.
|
||||
We therefore use the prebuilt dynamic Unicorn library "unicorn.dll".
|
||||
There are two ways to use this with your Microsoft Visual C++ project:
|
||||
1) By dynamically linking the dll into your project.
|
||||
2) By statically linking the dll into your project.
|
||||
|
||||
There are pre-prepared sample projects that use each method, but in the event
|
||||
you wish to set up your own projects there are details to do so below.
|
||||
|
||||
|
||||
|
||||
|
||||
:: 1) Dynamic Linking
|
||||
@ -49,6 +55,7 @@ Now build your application as normal.
|
||||
|
||||
|
||||
|
||||
|
||||
:: 2) Static Linking
|
||||
|
||||
To perform static linking of unicorn.dll, you need to first generate some
|
||||
@ -75,3 +82,106 @@ Or by adding "unicorn_staload.lib" to your project in:
|
||||
Configuration Properties -> C/C++ -> Linker -> Input -> Additional Dependencies
|
||||
|
||||
|
||||
|
||||
|
||||
:: Notes about Visual Studio versions.
|
||||
|
||||
These solution and project files were created using Visual Studio 2012.
|
||||
They should be able to be opened in newer versions of Visual Studio.
|
||||
For older versions of Visual Studio you could try a little hack of changing
|
||||
the line in the solution file "samples.sln" from:
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
to
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
|
||||
Or whatever version number your Visual Studio version uses.
|
||||
(Hint: Check an existing solution file you have created with your version
|
||||
of Visual Studio to know what this value is expected to be.)
|
||||
|
||||
Also note that all instructions below are for Visual Studio 2012. So if you
|
||||
are using a different version then the settings may be located in different
|
||||
areas or have different names.
|
||||
|
||||
|
||||
|
||||
|
||||
:: Building the pre-prepared sample projects
|
||||
|
||||
Some sample projects have been included in the bindings\msvc\samples directory.
|
||||
The solution file in this directory is "samples.sln".
|
||||
This was created with Visual Studio 2012 and once opened contains 2 projects
|
||||
"dynload" and "staload".
|
||||
|
||||
The "dynload" project is an example of a project that uses dynamic linking.
|
||||
The "satload" project is an example of a project that uses static linking.
|
||||
|
||||
Both projects have 32bit (win32) and 64bit (x64) target platforms.
|
||||
The 32bit platform (win32) will create a 32bit app that can run on either
|
||||
32bit or 64bit Windows. The 64bit platform (x64) can only run on 64bit Windows.
|
||||
|
||||
All variants can be built at once by using the batch build function:
|
||||
Go to "Build -> Batch Build" and tick all checkboxes, or at least the ones
|
||||
that you wish to build. Then click on the Build or Rebuild button.
|
||||
Note that when building the "staload" projects you must first have built
|
||||
the static import libraries as mentioned above.
|
||||
|
||||
|
||||
|
||||
|
||||
:: Running the pre-prepared sample projects
|
||||
|
||||
When running the samples they will need to be able to load the unicorn dlls.
|
||||
|
||||
The unicorn dlls required for 32bit apps are:
|
||||
libgcc_s_dw2-1.dll
|
||||
libglib-2.0-0.dll
|
||||
libiconv-2.dll
|
||||
libintl-8.dll
|
||||
libwinpthread-1.dll
|
||||
unicorn.dll
|
||||
|
||||
The unicorn dlls required for 64bit apps are:
|
||||
libgcc_s_seh-1.dll
|
||||
libglib-2.0-0.dll
|
||||
libiconv-2.dll
|
||||
libintl-8.dll
|
||||
libwinpthread-1.dll
|
||||
unicorn.dll
|
||||
|
||||
Note that while some of the 32bit and 64bit dlls have the same filename,
|
||||
they are internally different in that they are either 32bit or 64bit files
|
||||
themselves. So you will have to have separate directories to store them in.
|
||||
I suggest using directory names such as "unicorn32" and "unicorn64" when
|
||||
installing the prebuilt windows binaries. This will make it easy to
|
||||
differentiate between them.
|
||||
|
||||
If running the sample exe files from the command line or from Windows Explorer
|
||||
then you need ensure that the exe file is in the same directory as either the
|
||||
32bit or 64bit set of dlls.
|
||||
|
||||
To run the samples from inside Visual Studio so that you can debug them or just
|
||||
easily test various changes you should set the working directory to point to a
|
||||
directory that contains all of the dlls. Assuming you are running a 32bit app
|
||||
and have the 32bit unicorn dlls in the directory "C:\unicorn32" then do:
|
||||
|
||||
1) Go to the Solution Explorer window in Visual Studio.
|
||||
You can use "View -> Solution Explorer" to get to it.
|
||||
|
||||
2) Highlight one or more projects that you want to run/debu from in
|
||||
Visual Studio. Use hold control when selecting to select multiples,
|
||||
or hold Shift to select ranges of projects.
|
||||
|
||||
3) Right click on the selected projects and go to Properties.
|
||||
|
||||
4) Now go to "Configuration Properties -> Debugging -> Working Directory".
|
||||
Change the value for this to "C:\unicorn32".
|
||||
You will need to change this for both Debug and Release configurations.
|
||||
You can change between configurations on the top left of the Property Pages
|
||||
dialog box that you are currently on.
|
||||
|
||||
6) Click OK when done and then you are ready to run or debug the projects.
|
||||
Do "Debug -> Start Debugging" or press F5 to debug the current project.
|
||||
Do "Debug -> Start Without Debugging" or press Ctrl+F5 to run the current project.
|
||||
You can change the current project by right clicking on a project in
|
||||
Solution Explorer and selecting "Set as StartUp Project"
|
||||
|
||||
|
167
bindings/msvc/samples/dynload/dynload.vcxproj
Normal file
167
bindings/msvc/samples/dynload/dynload.vcxproj
Normal file
@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>dynload</RootNamespace>
|
||||
<ProjectName>dynload</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);DYNLOAD</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);DYNLOAD</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);DYNLOAD</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);DYNLOAD</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\unicorn_dynload.c" />
|
||||
<ClCompile Include="..\main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
7
bindings/msvc/samples/dynload/dynload.vcxproj.filters
Normal file
7
bindings/msvc/samples/dynload/dynload.vcxproj.filters
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\main.c" />
|
||||
<ClCompile Include="..\..\unicorn_dynload.c" />
|
||||
</ItemGroup>
|
||||
</Project>
|
134
bindings/msvc/samples/main.c
Normal file
134
bindings/msvc/samples/main.c
Normal file
@ -0,0 +1,134 @@
|
||||
//
|
||||
// Simple code as an example for building apps with MSVC++ using the Unicorn Engine.
|
||||
//
|
||||
// Zak Escano - December 2015
|
||||
//
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
// Test MIPS little endian code.
|
||||
// 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
|
||||
};
|
||||
bool test_passed_ok = false;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
uc_engine *uc;
|
||||
uc_err err;
|
||||
uc_hook hhc;
|
||||
uint32_t val;
|
||||
|
||||
// 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
|
||||
|
||||
// Initialize emulator in MIPS 32bit little endian mode
|
||||
err = uc_open(UC_ARCH_MIPS, UC_MODE_MIPS32, &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);
|
||||
if (err)
|
||||
{
|
||||
printf("Failed on uc_mem_map() with error returned: %u\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
// write machine code to be emulated to memory
|
||||
err = uc_mem_write(uc, addr, loop_test_code, sizeof(loop_test_code));
|
||||
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 )
|
||||
{
|
||||
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);
|
||||
if (err)
|
||||
{
|
||||
printf("Failed on uc_emu_start() with error returned %u: %s\n",
|
||||
err, uc_strerror(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
|
||||
#ifdef DYNLOAD
|
||||
uc_dyn_free();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
36
bindings/msvc/samples/samples.sln
Normal file
36
bindings/msvc/samples/samples.sln
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynload", "dynload\dynload.vcxproj", "{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "staload", "staload\staload.vcxproj", "{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Debug|x64.Build.0 = Debug|x64
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Release|Win32.Build.0 = Release|Win32
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Release|x64.ActiveCfg = Release|x64
|
||||
{EBBC5CEA-1237-4E20-9E38-E610D3C529EB}.Release|x64.Build.0 = Release|x64
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Debug|x64.Build.0 = Debug|x64
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Release|Win32.Build.0 = Release|Win32
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Release|x64.ActiveCfg = Release|x64
|
||||
{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
165
bindings/msvc/samples/staload/staload.vcxproj
Normal file
165
bindings/msvc/samples/staload/staload.vcxproj
Normal file
@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{85FFC5E9-CC3D-41F6-8970-092FAC8E5E39}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>staload</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..;..\..\..\..\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>..\..</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
6
bindings/msvc/samples/staload/staload.vcxproj.filters
Normal file
6
bindings/msvc/samples/staload/staload.vcxproj.filters
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\main.c" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -26,6 +26,9 @@
|
||||
// Zak Escano - November 2015
|
||||
//
|
||||
|
||||
// Only use this if DYNLOAD is set in preprocessor definitions
|
||||
#ifdef DYNLOAD
|
||||
|
||||
// This is to detect whether we are loading a dll in windows or a so in linux.
|
||||
#ifdef _MSC_VER
|
||||
#define WINDOWS_DLL 1
|
||||
@ -276,3 +279,4 @@ uc_err uc_mem_protect(uc_engine *uc, uint64_t address, size_t size, uint32_t per
|
||||
return gp_uc_mem_protect(uc, address, size, perms);
|
||||
}
|
||||
|
||||
#endif // DYNLOAD
|
||||
|
Reference in New Issue
Block a user