Switched to internally defined types.

WRUSSD and WRUSSQ cannot be executed when CPL != 0.
pull/54/head
BITDEFENDER\vlutas 2 years ago
parent 08103713b2
commit fe6a937f51

File diff suppressed because it is too large Load Diff

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugKernel|ARM64">
<Configuration>DebugKernel</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="DebugKernel|Win32"> <ProjectConfiguration Include="DebugKernel|Win32">
<Configuration>DebugKernel</Configuration> <Configuration>DebugKernel</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -9,6 +13,10 @@
<Configuration>DebugKernel</Configuration> <Configuration>DebugKernel</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -17,6 +25,10 @@
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="ReleaseKernel|ARM64">
<Configuration>ReleaseKernel</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseKernel|Win32"> <ProjectConfiguration Include="ReleaseKernel|Win32">
<Configuration>ReleaseKernel</Configuration> <Configuration>ReleaseKernel</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -25,6 +37,10 @@
<Configuration>ReleaseKernel</Configuration> <Configuration>ReleaseKernel</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -78,6 +94,12 @@
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
@ -88,11 +110,26 @@
<SupportsPackaging>false</SupportsPackaging> <SupportsPackaging>false</SupportsPackaging>
<ALLOW_DATE_TIME>1</ALLOW_DATE_TIME> <ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<TargetVersion></TargetVersion>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging>
<ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
@ -102,6 +139,15 @@
<SupportsPackaging>false</SupportsPackaging> <SupportsPackaging>false</SupportsPackaging>
<ALLOW_DATE_TIME>1</ALLOW_DATE_TIME> <ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<TargetVersion></TargetVersion>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging>
<ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
@ -120,15 +166,27 @@
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <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" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="PropertySheets"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'" Label="PropertySheets">
<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"> <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" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="PropertySheets"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'" 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 Label="UserMacros" />
<PropertyGroup> <PropertyGroup>
<_ProjectFileVersion>14.0.23107.0</_ProjectFileVersion> <_ProjectFileVersion>14.0.23107.0</_ProjectFileVersion>
@ -145,10 +203,18 @@
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
@ -161,10 +227,18 @@
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent> <PreBuildEvent>
<Command> <Command>
@ -250,6 +324,39 @@
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib> </Lib>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<Midl />
<ClCompile>
<AdditionalOptions>/D "AMD64" %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>include;..\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Lib>
<AdditionalLibraryDirectories>x:\Projects-devel\dacia-hg\bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'">
<PreBuildEvent> <PreBuildEvent>
<Command> <Command>
@ -287,6 +394,42 @@
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib> </Lib>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'">
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<Midl />
<ClCompile>
<AdditionalOptions>/kernel /D "AMD64" %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>include;..\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Lib>
<AdditionalLibraryDirectories>x:\Projects-devel\dacia-hg\bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Native</SubSystem>
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent> <PreBuildEvent>
<Command> <Command>
@ -367,6 +510,48 @@
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<Midl />
<ClCompile>
<AdditionalOptions>/D "AMD64" %(AdditionalOptions)</AdditionalOptions>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>include;..\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<StringPooling>true</StringPooling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile> </ClCompile>
<ProjectReference> <ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies> <LinkLibraryDependencies>false</LinkLibraryDependencies>
@ -419,6 +604,44 @@
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib> </Lib>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'">
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<Midl />
<ClCompile>
<AdditionalOptions>/kernel /D "AMD64" %(AdditionalOptions)</AdditionalOptions>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>include;..\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<StringPooling>true</StringPooling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<SubSystem>Native</SubSystem>
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="bdformat.c" /> <ClCompile Include="bdformat.c" />
<ClCompile Include="bdhelpers.c" /> <ClCompile Include="bdhelpers.c" />
@ -426,14 +649,19 @@
<ClCompile Include="bddisasm.c"> <ClCompile Include="bddisasm.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|Win32'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'">NotUsing</PrecompiledHeader>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='DebugKernel|Win32'"> <ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='DebugKernel|Win32'">
</ForcedIncludeFiles> </ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'"> <ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'">
</ForcedIncludeFiles> </ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'">
</ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|Win32'"> <ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|Win32'">
</ForcedIncludeFiles> </ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'"> <ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'">
</ForcedIncludeFiles> </ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'">
</ForcedIncludeFiles>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -113,7 +113,7 @@ static const char *gRegTile[] =
static const char *gConditionCodes[] = static const char *gConditionCodes[] =
{ {
"EQ", "LT", "LE", "UNORD", "NEQ", "NLT", "NLE", "ORD", "EQ", "LT", "LE", "UNORD", "NEQ", "NLT", "NLE", "ORD",
"EQ_UQ", "NGE", "NGT", "false", "NEQ_OQ", "GE", "GT", "TRUE", "EQ_UQ", "NGE", "NGT", "ND_FALSE", "NEQ_OQ", "GE", "GT", "TRUE",
"EQ_OS", "LT_OQ", "LE_OQ", "UNORD_S", "NEQ_US", "NLT_UQ", "NLE_UQ", "ORD_S", "EQ_OS", "LT_OQ", "LE_OQ", "UNORD_S", "NEQ_US", "NLT_UQ", "NLE_UQ", "ORD_S",
"EQ_US", "NGE_UQ", "NGT_UQ", "FALSE_OS", "NEQ_OS", "GE_OQ", "GT_OQ", "TRUE_US", "EQ_US", "NGE_UQ", "NGT_UQ", "FALSE_OS", "NEQ_OS", "GE_OQ", "GT_OQ", "TRUE_US",
}; };
@ -131,7 +131,7 @@ static const char *gEmbeddedRounding[] =
static NDSTATUS static NDSTATUS
NdSprintf( NdSprintf(
char *Destination, char *Destination,
size_t DestinationSize, ND_SIZET DestinationSize,
const char *Formatstring, const char *Formatstring,
... ...
) )
@ -142,12 +142,12 @@ NdSprintf(
int res; int res;
va_list args; va_list args;
if (NULL == Destination) if (ND_NULL == Destination)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
if (NULL == Formatstring) if (ND_NULL == Formatstring)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
@ -162,7 +162,7 @@ NdSprintf(
va_end(args); va_end(args);
if ((res < 0) || ((size_t)res >= DestinationSize - 1)) if ((res < 0) || ((ND_SIZET)res >= DestinationSize - 1))
{ {
return ND_STATUS_BUFFER_OVERFLOW; return ND_STATUS_BUFFER_OVERFLOW;
} }
@ -177,32 +177,32 @@ NdSprintf(
NDSTATUS NDSTATUS
NdToText( NdToText(
const INSTRUX *Instrux, const INSTRUX *Instrux,
uint64_t Rip, ND_UINT64 Rip,
uint32_t BufferSize, ND_UINT32 BufferSize,
char *Buffer char *Buffer
) )
{ {
NDSTATUS status; NDSTATUS status;
char *res, temp[64]; char *res, temp[64];
uint32_t opIndex, opsStored; ND_UINT32 opIndex, opsStored;
const ND_OPERAND *pOp; const ND_OPERAND *pOp;
bool alignmentStored; ND_BOOL alignmentStored;
// pre-init // pre-init
status = ND_STATUS_SUCCESS; status = ND_STATUS_SUCCESS;
res = NULL; res = (char *)ND_NULL;
opIndex = 0; opIndex = 0;
opsStored = 0; opsStored = 0;
pOp = NULL; pOp = (const ND_OPERAND *)ND_NULL;
alignmentStored = false; alignmentStored = ND_FALSE;
// Validate args. // Validate args.
if (NULL == Instrux) if (ND_NULL == Instrux)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
if (NULL == Buffer) if (ND_NULL == Buffer)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
@ -225,12 +225,12 @@ NdToText(
if (Instrux->Rep == ND_PREFIX_G1_REPE_REPZ) if (Instrux->Rep == ND_PREFIX_G1_REPE_REPZ)
{ {
res = nd_strcat_s(Buffer, BufferSize, "REPZ "); res = nd_strcat_s(Buffer, BufferSize, "REPZ ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
else if (Instrux->Rep == ND_PREFIX_G1_REPNE_REPNZ) else if (Instrux->Rep == ND_PREFIX_G1_REPNE_REPNZ)
{ {
res = nd_strcat_s(Buffer, BufferSize, "REPNZ "); res = nd_strcat_s(Buffer, BufferSize, "REPNZ ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
@ -240,24 +240,24 @@ NdToText(
if (Instrux->Rep == ND_PREFIX_G1_REPE_REPZ) if (Instrux->Rep == ND_PREFIX_G1_REPE_REPZ)
{ {
res = nd_strcat_s(Buffer, BufferSize, "REP "); res = nd_strcat_s(Buffer, BufferSize, "REP ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
else if (Instrux->Rep == ND_PREFIX_G1_REPNE_REPNZ) else if (Instrux->Rep == ND_PREFIX_G1_REPNE_REPNZ)
{ {
res = nd_strcat_s(Buffer, BufferSize, "REPNZ "); res = nd_strcat_s(Buffer, BufferSize, "REPNZ ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
if (Instrux->IsXreleaseEnabled) if (Instrux->IsXreleaseEnabled)
{ {
res = nd_strcat_s(Buffer, BufferSize, "XRELEASE "); res = nd_strcat_s(Buffer, BufferSize, "XRELEASE ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
else if (Instrux->IsXacquireEnabled) else if (Instrux->IsXacquireEnabled)
{ {
res = nd_strcat_s(Buffer, BufferSize, "XACQUIRE "); res = nd_strcat_s(Buffer, BufferSize, "XACQUIRE ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
@ -266,7 +266,7 @@ NdToText(
if (ND_LOCK_SUPPORT(Instrux)) if (ND_LOCK_SUPPORT(Instrux))
{ {
res = nd_strcat_s(Buffer, BufferSize, "LOCK "); res = nd_strcat_s(Buffer, BufferSize, "LOCK ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
@ -275,7 +275,7 @@ NdToText(
if (ND_BND_SUPPORT(Instrux)) if (ND_BND_SUPPORT(Instrux))
{ {
res = nd_strcat_s(Buffer, BufferSize, "BND "); res = nd_strcat_s(Buffer, BufferSize, "BND ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
@ -285,17 +285,17 @@ NdToText(
{ {
case ND_PREFIX_G2_BR_TAKEN: case ND_PREFIX_G2_BR_TAKEN:
res = nd_strcat_s(Buffer, BufferSize, "BHT "); res = nd_strcat_s(Buffer, BufferSize, "BHT ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_PREFIX_G2_BR_NOT_TAKEN: case ND_PREFIX_G2_BR_NOT_TAKEN:
res = nd_strcat_s(Buffer, BufferSize, "BHNT "); res = nd_strcat_s(Buffer, BufferSize, "BHNT ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_PREFIX_G2_BR_ALT: case ND_PREFIX_G2_BR_ALT:
res = nd_strcat_s(Buffer, BufferSize, "BHALT "); res = nd_strcat_s(Buffer, BufferSize, "BHALT ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
default: default:
@ -308,19 +308,19 @@ NdToText(
if (!Instrux->IsCetTracked) if (!Instrux->IsCetTracked)
{ {
res = nd_strcat_s(Buffer, BufferSize, "DNT "); res = nd_strcat_s(Buffer, BufferSize, "DNT ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
// Store the mnemonic. // Store the mnemonic.
res = nd_strcat_s(Buffer, BufferSize, Instrux->Mnemonic); res = nd_strcat_s(Buffer, BufferSize, Instrux->Mnemonic);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
// Store condition code, if any. // Store condition code, if any.
if (ND_HAS_SSE_CONDITION(Instrux)) if (ND_HAS_SSE_CONDITION(Instrux))
{ {
res = nd_strcat_s(Buffer, BufferSize, gConditionCodes[Instrux->SseCondition]); res = nd_strcat_s(Buffer, BufferSize, gConditionCodes[Instrux->SseCondition]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
// If there are no explicit operands, we can leave. // If there are no explicit operands, we can leave.
@ -358,7 +358,7 @@ NdToText(
// Store alignment. // Store alignment.
if (!alignmentStored) if (!alignmentStored)
{ {
size_t idx = 0; ND_SIZET idx = 0;
while ((idx < BufferSize) && (Buffer[idx])) while ((idx < BufferSize) && (Buffer[idx]))
{ {
@ -377,14 +377,14 @@ NdToText(
Buffer[idx] = 0; Buffer[idx] = 0;
alignmentStored = true; alignmentStored = ND_TRUE;
} }
// Store the comma, if this isn't the first operand. // Store the comma, if this isn't the first operand.
if (opsStored > 0) if (opsStored > 0)
{ {
res = nd_strcat_s(Buffer, BufferSize, ", "); res = nd_strcat_s(Buffer, BufferSize, ", ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
opsStored++; opsStored++;
@ -409,31 +409,31 @@ NdToText(
if ((Instrux->EncMode != ND_ENCM_LEGACY) || Instrux->HasRex) if ((Instrux->EncMode != ND_ENCM_LEGACY) || Instrux->HasRex)
{ {
res = nd_strcat_s(Buffer, BufferSize, gReg8Bit64[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gReg8Bit64[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
else else
{ {
res = nd_strcat_s(Buffer, BufferSize, gReg8Bit[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gReg8Bit[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
case ND_SIZE_16BIT: case ND_SIZE_16BIT:
// 16 bit register. // 16 bit register.
res = nd_strcat_s(Buffer, BufferSize, gReg16Bit[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gReg16Bit[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_32BIT: case ND_SIZE_32BIT:
// 32 bit register. // 32 bit register.
res = nd_strcat_s(Buffer, BufferSize, gReg32Bit[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gReg32Bit[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_64BIT: case ND_SIZE_64BIT:
// 64 bit register. // 64 bit register.
res = nd_strcat_s(Buffer, BufferSize, gReg64Bit[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gReg64Bit[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
default: default:
@ -450,7 +450,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegSeg[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegSeg[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -462,7 +462,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegFpu[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegFpu[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -474,7 +474,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegMmx[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegMmx[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -489,15 +489,15 @@ NdToText(
{ {
case ND_SIZE_128BIT: case ND_SIZE_128BIT:
res = nd_strcat_s(Buffer, BufferSize, gRegXmm[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegXmm[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_256BIT: case ND_SIZE_256BIT:
res = nd_strcat_s(Buffer, BufferSize, gRegYmm[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegYmm[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_512BIT: case ND_SIZE_512BIT:
res = nd_strcat_s(Buffer, BufferSize, gRegZmm[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegZmm[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
default: default:
return ND_STATUS_INVALID_INSTRUX; return ND_STATUS_INVALID_INSTRUX;
@ -513,7 +513,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegControl[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegControl[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -525,7 +525,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegDebug[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegDebug[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -537,7 +537,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegTest[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegTest[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -550,7 +550,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegBound[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegBound[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -563,7 +563,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegMask[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegMask[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -576,7 +576,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, gRegTile[pOp->Info.Register.Reg]); res = nd_strcat_s(Buffer, BufferSize, gRegTile[pOp->Info.Register.Reg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -593,7 +593,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -612,7 +612,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -621,16 +621,16 @@ NdToText(
switch (pOp->Size) switch (pOp->Size)
{ {
case 1: case 1:
status = NdSprintf(temp, sizeof(temp), "0x%02x", (uint8_t)pOp->Info.Immediate.Imm); status = NdSprintf(temp, sizeof(temp), "0x%02x", (ND_UINT8)pOp->Info.Immediate.Imm);
break; break;
case 2: case 2:
status = NdSprintf(temp, sizeof(temp), "0x%04x", (uint16_t)pOp->Info.Immediate.Imm); status = NdSprintf(temp, sizeof(temp), "0x%04x", (ND_UINT16)pOp->Info.Immediate.Imm);
break; break;
case 4: case 4:
status = NdSprintf(temp, sizeof(temp), "0x%08x", (uint32_t)pOp->Info.Immediate.Imm); status = NdSprintf(temp, sizeof(temp), "0x%08x", (ND_UINT32)pOp->Info.Immediate.Imm);
break; break;
case 8: case 8:
status = NdSprintf(temp, sizeof(temp), "0x%016llx", (uint64_t)pOp->Info.Immediate.Imm); status = NdSprintf(temp, sizeof(temp), "0x%016llx", (ND_UINT64)pOp->Info.Immediate.Imm);
break; break;
} }
if (!ND_SUCCESS(status)) if (!ND_SUCCESS(status))
@ -639,13 +639,13 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
case ND_OP_OFFS: case ND_OP_OFFS:
{ {
uint64_t dest = Rip + Instrux->Length + pOp->Info.RelativeOffset.Rel; ND_UINT64 dest = Rip + Instrux->Length + pOp->Info.RelativeOffset.Rel;
// Truncate to the actual word length. // Truncate to the actual word length.
switch (Instrux->WordLength) switch (Instrux->WordLength)
@ -667,7 +667,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -677,15 +677,15 @@ NdToText(
{ {
case 4: case 4:
status = NdSprintf(temp, sizeof(temp), "0x%04x:0x%04x", status = NdSprintf(temp, sizeof(temp), "0x%04x:0x%04x",
pOp->Info.Address.BaseSeg, (uint16_t)pOp->Info.Address.Offset); pOp->Info.Address.BaseSeg, (ND_UINT16)pOp->Info.Address.Offset);
break; break;
case 6: case 6:
status = NdSprintf(temp, sizeof(temp), "0x%04x:0x%08x", status = NdSprintf(temp, sizeof(temp), "0x%04x:0x%08x",
pOp->Info.Address.BaseSeg, (uint32_t)pOp->Info.Address.Offset); pOp->Info.Address.BaseSeg, (ND_UINT32)pOp->Info.Address.Offset);
break; break;
case 10: case 10:
status = NdSprintf(temp, sizeof(temp), "0x%04x:0x%016llx", status = NdSprintf(temp, sizeof(temp), "0x%04x:0x%016llx",
pOp->Info.Address.BaseSeg, (uint64_t)pOp->Info.Address.Offset); pOp->Info.Address.BaseSeg, (ND_UINT64)pOp->Info.Address.Offset);
break; break;
default: default:
return ND_STATUS_INVALID_INSTRUX; return ND_STATUS_INVALID_INSTRUX;
@ -697,7 +697,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -710,43 +710,43 @@ NdToText(
{ {
case 1: case 1:
res = nd_strcat_s(Buffer, BufferSize, "byte ptr "); res = nd_strcat_s(Buffer, BufferSize, "byte ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 2: case 2:
res = nd_strcat_s(Buffer, BufferSize, "word ptr "); res = nd_strcat_s(Buffer, BufferSize, "word ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 4: case 4:
res = nd_strcat_s(Buffer, BufferSize, "dword ptr "); res = nd_strcat_s(Buffer, BufferSize, "dword ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 6: case 6:
res = nd_strcat_s(Buffer, BufferSize, "fword ptr "); res = nd_strcat_s(Buffer, BufferSize, "fword ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 8: case 8:
res = nd_strcat_s(Buffer, BufferSize, "qword ptr "); res = nd_strcat_s(Buffer, BufferSize, "qword ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 10: case 10:
res = nd_strcat_s(Buffer, BufferSize, "tbyte ptr "); res = nd_strcat_s(Buffer, BufferSize, "tbyte ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 16: case 16:
res = nd_strcat_s(Buffer, BufferSize, "xmmword ptr "); res = nd_strcat_s(Buffer, BufferSize, "xmmword ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 32: case 32:
res = nd_strcat_s(Buffer, BufferSize, "ymmword ptr "); res = nd_strcat_s(Buffer, BufferSize, "ymmword ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 48: case 48:
res = nd_strcat_s(Buffer, BufferSize, "m384 ptr "); res = nd_strcat_s(Buffer, BufferSize, "m384 ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case 64: case 64:
res = nd_strcat_s(Buffer, BufferSize, "zmmword ptr "); res = nd_strcat_s(Buffer, BufferSize, "zmmword ptr ");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
default: default:
break; break;
@ -764,16 +764,16 @@ NdToText(
(NDR_GS == pOp->Info.Memory.Seg)) (NDR_GS == pOp->Info.Memory.Seg))
{ {
res = nd_strcat_s(Buffer, BufferSize, gRegSeg[pOp->Info.Memory.Seg]); res = nd_strcat_s(Buffer, BufferSize, gRegSeg[pOp->Info.Memory.Seg]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
res = nd_strcat_s(Buffer, BufferSize, ":"); res = nd_strcat_s(Buffer, BufferSize, ":");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
// Prepend the "[" // Prepend the "["
res = nd_strcat_s(Buffer, BufferSize, "["); res = nd_strcat_s(Buffer, BufferSize, "[");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
// Base, if any. // Base, if any.
if (pOp->Info.Memory.HasBase) if (pOp->Info.Memory.HasBase)
@ -787,19 +787,19 @@ NdToText(
{ {
case ND_SIZE_8BIT: case ND_SIZE_8BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg8Bit[pOp->Info.Memory.Base]); res = nd_strcat_s(Buffer, BufferSize, gReg8Bit[pOp->Info.Memory.Base]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_16BIT: case ND_SIZE_16BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg16Bit[pOp->Info.Memory.Base]); res = nd_strcat_s(Buffer, BufferSize, gReg16Bit[pOp->Info.Memory.Base]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_32BIT: case ND_SIZE_32BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg32Bit[pOp->Info.Memory.Base]); res = nd_strcat_s(Buffer, BufferSize, gReg32Bit[pOp->Info.Memory.Base]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_64BIT: case ND_SIZE_64BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg64Bit[pOp->Info.Memory.Base]); res = nd_strcat_s(Buffer, BufferSize, gReg64Bit[pOp->Info.Memory.Base]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
default: default:
return ND_STATUS_INVALID_INSTRUX; return ND_STATUS_INVALID_INSTRUX;
@ -817,38 +817,38 @@ NdToText(
if (pOp->Info.Memory.HasBase) if (pOp->Info.Memory.HasBase)
{ {
res = nd_strcat_s(Buffer, BufferSize, "+"); res = nd_strcat_s(Buffer, BufferSize, "+");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
switch (pOp->Info.Memory.IndexSize) switch (pOp->Info.Memory.IndexSize)
{ {
case ND_SIZE_8BIT: case ND_SIZE_8BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg8Bit[pOp->Info.Memory.Index]); res = nd_strcat_s(Buffer, BufferSize, gReg8Bit[pOp->Info.Memory.Index]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_16BIT: case ND_SIZE_16BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg16Bit[pOp->Info.Memory.Index]); res = nd_strcat_s(Buffer, BufferSize, gReg16Bit[pOp->Info.Memory.Index]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_32BIT: case ND_SIZE_32BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg32Bit[pOp->Info.Memory.Index]); res = nd_strcat_s(Buffer, BufferSize, gReg32Bit[pOp->Info.Memory.Index]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_64BIT: case ND_SIZE_64BIT:
res = nd_strcat_s(Buffer, BufferSize, gReg64Bit[pOp->Info.Memory.Index]); res = nd_strcat_s(Buffer, BufferSize, gReg64Bit[pOp->Info.Memory.Index]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_128BIT: case ND_SIZE_128BIT:
res = nd_strcat_s(Buffer, BufferSize, gRegXmm[pOp->Info.Memory.Index]); res = nd_strcat_s(Buffer, BufferSize, gRegXmm[pOp->Info.Memory.Index]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_256BIT: case ND_SIZE_256BIT:
res = nd_strcat_s(Buffer, BufferSize, gRegYmm[pOp->Info.Memory.Index]); res = nd_strcat_s(Buffer, BufferSize, gRegYmm[pOp->Info.Memory.Index]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
case ND_SIZE_512BIT: case ND_SIZE_512BIT:
res = nd_strcat_s(Buffer, BufferSize, gRegZmm[pOp->Info.Memory.Index]); res = nd_strcat_s(Buffer, BufferSize, gRegZmm[pOp->Info.Memory.Index]);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
break; break;
default: default:
return ND_STATUS_INVALID_INSTRUX; return ND_STATUS_INVALID_INSTRUX;
@ -864,14 +864,14 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
// Handle displacement. // Handle displacement.
if (pOp->Info.Memory.HasDisp) if (pOp->Info.Memory.HasDisp)
{ {
uint64_t normDisp, disp; ND_UINT64 normDisp, disp;
disp = pOp->Info.Memory.Disp; disp = pOp->Info.Memory.Disp;
@ -900,12 +900,12 @@ NdToText(
break; break;
} }
// Handle compressed displacement. It is fine to cast the normDisp to uint32_t, as the // Handle compressed displacement. It is fine to cast the normDisp to ND_UINT32, as the
// compressed displacement only works with uint8_t displacements. Also, in this phase, // compressed displacement only works with ND_UINT8 displacements. Also, in this phase,
// the normDisp is converted to a positive quantity, so no sign-extension is needed. // the normDisp is converted to a positive quantity, so no sign-extension is needed.
if (pOp->Info.Memory.HasCompDisp) if (pOp->Info.Memory.HasCompDisp)
{ {
normDisp = (uint64_t)(uint32_t)normDisp * pOp->Info.Memory.CompDispSize; normDisp = (ND_UINT64)(ND_UINT32)normDisp * pOp->Info.Memory.CompDispSize;
} }
} }
@ -914,12 +914,12 @@ NdToText(
if (pOp->Info.Memory.HasBase || pOp->Info.Memory.HasIndex) if (pOp->Info.Memory.HasBase || pOp->Info.Memory.HasIndex)
{ {
res = nd_strcat_s(Buffer, BufferSize, Instrux->SignDisp ? "-" : "+"); res = nd_strcat_s(Buffer, BufferSize, Instrux->SignDisp ? "-" : "+");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
if (pOp->Info.Memory.IsRipRel) if (pOp->Info.Memory.IsRipRel)
{ {
uint64_t target = disp + Rip + Instrux->Length; ND_UINT64 target = disp + Rip + Instrux->Length;
if (Instrux->AddrMode == ND_ADDR_32) if (Instrux->AddrMode == ND_ADDR_32)
{ {
@ -930,7 +930,7 @@ NdToText(
} }
else else
{ {
uint8_t trimSize; ND_UINT8 trimSize;
trimSize = (Instrux->AddrMode == ND_ADDR_16) ? 2 : ((Instrux->AddrMode == ND_ADDR_32) ? 4 : 8); trimSize = (Instrux->AddrMode == ND_ADDR_16) ? 2 : ((Instrux->AddrMode == ND_ADDR_32) ? 4 : 8);
@ -945,12 +945,12 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
// And the ending "]" // And the ending "]"
res = nd_strcat_s(Buffer, BufferSize, "]"); res = nd_strcat_s(Buffer, BufferSize, "]");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
break; break;
@ -968,7 +968,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
// Handle masking. // Handle masking.
@ -986,14 +986,14 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
// Handle zeroing. Note that zeroing without masking is ignored. // Handle zeroing. Note that zeroing without masking is ignored.
if (pOp->Decorator.HasZero && pOp->Decorator.HasMask) if (pOp->Decorator.HasZero && pOp->Decorator.HasMask)
{ {
res = nd_strcat_s(Buffer, BufferSize, "{z}"); res = nd_strcat_s(Buffer, BufferSize, "{z}");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
// Append Suppress All Exceptions decorator. // Append Suppress All Exceptions decorator.
@ -1001,7 +1001,7 @@ NdToText(
{ {
// ER implies SAE, so if we have ER, we will list that. // ER implies SAE, so if we have ER, we will list that.
res = nd_strcat_s(Buffer, BufferSize, ", {sae}"); res = nd_strcat_s(Buffer, BufferSize, ", {sae}");
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
// Append Embedded Rounding decorator. // Append Embedded Rounding decorator.
@ -1019,7 +1019,7 @@ NdToText(
} }
res = nd_strcat_s(Buffer, BufferSize, temp); res = nd_strcat_s(Buffer, BufferSize, temp);
RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
} }
} }
@ -1029,18 +1029,18 @@ NdToText(
NDSTATUS NDSTATUS
NdToText( NdToText(
const INSTRUX *Instrux, const INSTRUX *Instrux,
uint64_t Rip, ND_UINT64 Rip,
uint32_t BufferSize, ND_UINT32 BufferSize,
char *Buffer char *Buffer
) )
{ {
UNREFERENCED_PARAMETER(Instrux); UNREFERENCED_PARAMETER(Instrux);
UNREFERENCED_PARAMETER(Rip); UNREFERENCED_PARAMETER(Rip);
// At least make sure the buffer is NULL-terminated so integrators can use NdToText without checking if the // At least make sure the buffer is ND_NULL-terminated so integrators can use NdToText without checking if the
// BDDISASM_NO_FORMAT macro is defined. This makes switching between versions with formatting and versions without // BDDISASM_NO_FORMAT macro is defined. This makes switching between versions with formatting and versions without
// formatting easier. // formatting easier.
if (Buffer != NULL && BufferSize >= 1) if (Buffer != ND_NULL && BufferSize >= 1)
{ {
*Buffer = '\0'; *Buffer = '\0';
} }

@ -5,7 +5,7 @@
// //
// NdIsInstruxRipRelative // NdIsInstruxRipRelative
// //
bool ND_BOOL
NdIsInstruxRipRelative( NdIsInstruxRipRelative(
const INSTRUX *Instrux const INSTRUX *Instrux
) )
@ -13,9 +13,9 @@ NdIsInstruxRipRelative(
// Provided for backwards compatibility with existing code that uses disasm 1.0 // Provided for backwards compatibility with existing code that uses disasm 1.0
// //
{ {
if (NULL == Instrux) if (ND_NULL == Instrux)
{ {
return false; return ND_FALSE;
} }
else else
{ {
@ -33,20 +33,20 @@ NdGetFullAccessMap(
ND_ACCESS_MAP *AccessMap ND_ACCESS_MAP *AccessMap
) )
{ {
uint32_t i; ND_UINT32 i;
const ND_OPERAND *pOp; const ND_OPERAND *pOp;
// pre-init // pre-init
i = 0; i = 0;
pOp = NULL; pOp = (const ND_OPERAND *)ND_NULL;
// validate // validate
if (NULL == Instrux) if (ND_NULL == Instrux)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
if (NULL == AccessMap) if (ND_NULL == AccessMap)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
@ -96,7 +96,7 @@ NdGetFullAccessMap(
{ {
case ND_REG_GPR: case ND_REG_GPR:
{ {
uint32_t k; ND_UINT32 k;
for (k = 0; k < pOp->Info.Register.Count; k++) for (k = 0; k < pOp->Info.Register.Count; k++)
{ {
@ -122,7 +122,7 @@ NdGetFullAccessMap(
break; break;
case ND_REG_SSE: case ND_REG_SSE:
{ {
uint32_t k; ND_UINT32 k;
for (k = 0; k < pOp->Info.Register.Count; k++) for (k = 0; k < pOp->Info.Register.Count; k++)
{ {
@ -175,7 +175,7 @@ NdGetFullAccessMap(
} }
else if (ND_OP_BANK == Instrux->Operands[i].Type) else if (ND_OP_BANK == Instrux->Operands[i].Type)
{ {
uint8_t j; ND_UINT8 j;
// Bank registers access. This needs special handling. Note that LOADALL/LOADALLD is not supported, as // Bank registers access. This needs special handling. Note that LOADALL/LOADALLD is not supported, as
// it is too old and it's not valid since the good old 486. // it is too old and it's not valid since the good old 486.
@ -225,12 +225,12 @@ NdGetOperandRlut(
ND_OPERAND_RLUT *Rlut ND_OPERAND_RLUT *Rlut
) )
{ {
if (NULL == Instrux) if (ND_NULL == Instrux)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
if (NULL == Rlut) if (ND_NULL == Rlut)
{ {
return ND_STATUS_INVALID_PARAMETER; return ND_STATUS_INVALID_PARAMETER;
} }
@ -238,16 +238,16 @@ NdGetOperandRlut(
// Initialize the RLUT. // Initialize the RLUT.
nd_memset(Rlut, 0, sizeof(*Rlut)); nd_memset(Rlut, 0, sizeof(*Rlut));
for (uint8_t i = 0; i < Instrux->OperandsCount; i++) for (ND_UINT8 i = 0; i < Instrux->OperandsCount; i++)
{ {
if (!!(Instrux->Operands[i].Access.Access & ND_ACCESS_ANY_WRITE)) if (!!(Instrux->Operands[i].Access.Access & ND_ACCESS_ANY_WRITE))
{ {
// We only care about the first 2 destination operands. // We only care about the first 2 destination operands.
if (Rlut->Dst1 == NULL) if (Rlut->Dst1 == ND_NULL)
{ {
Rlut->Dst1 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Dst1 = (PND_OPERAND)&Instrux->Operands[i];
} }
else if (Rlut->Dst2 == NULL) else if (Rlut->Dst2 == ND_NULL)
{ {
Rlut->Dst2 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Dst2 = (PND_OPERAND)&Instrux->Operands[i];
} }
@ -256,19 +256,19 @@ NdGetOperandRlut(
if (!!(Instrux->Operands[i].Access.Access & ND_ACCESS_ANY_READ)) if (!!(Instrux->Operands[i].Access.Access & ND_ACCESS_ANY_READ))
{ {
// We only care about the first 4 source operands. // We only care about the first 4 source operands.
if (Rlut->Src1 == NULL) if (Rlut->Src1 == ND_NULL)
{ {
Rlut->Src1 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Src1 = (PND_OPERAND)&Instrux->Operands[i];
} }
else if (Rlut->Src2 == NULL) else if (Rlut->Src2 == ND_NULL)
{ {
Rlut->Src2 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Src2 = (PND_OPERAND)&Instrux->Operands[i];
} }
else if (Rlut->Src3 == NULL) else if (Rlut->Src3 == ND_NULL)
{ {
Rlut->Src3 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Src3 = (PND_OPERAND)&Instrux->Operands[i];
} }
else if (Rlut->Src4 == NULL) else if (Rlut->Src4 == ND_NULL)
{ {
Rlut->Src4 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Src4 = (PND_OPERAND)&Instrux->Operands[i];
} }
@ -277,11 +277,11 @@ NdGetOperandRlut(
if (Instrux->Operands[i].Type == ND_OP_MEM) if (Instrux->Operands[i].Type == ND_OP_MEM)
{ {
// We only care about the first 2 memory operands. // We only care about the first 2 memory operands.
if (Rlut->Mem1 == NULL) if (Rlut->Mem1 == ND_NULL)
{ {
Rlut->Mem1 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Mem1 = (PND_OPERAND)&Instrux->Operands[i];
} }
else if (Rlut->Mem2 == NULL) else if (Rlut->Mem2 == ND_NULL)
{ {
Rlut->Mem2 = (PND_OPERAND)&Instrux->Operands[i]; Rlut->Mem2 = (PND_OPERAND)&Instrux->Operands[i];
} }

@ -10,12 +10,12 @@
char * char *
nd_strcat_s( nd_strcat_s(
char *dst, char *dst,
size_t dst_size, ND_SIZET dst_size,
const char *src const char *src
) )
{ {
char *p; char *p;
size_t available; ND_SIZET available;
p = dst; p = dst;
available = dst_size; available = dst_size;
@ -28,7 +28,7 @@ nd_strcat_s(
if (available == 0) if (available == 0)
{ {
nd_memzero(dst, dst_size); nd_memzero(dst, dst_size);
return NULL; return (char *)ND_NULL;
} }
while ((*p++ = *src++) != 0 && --available > 0); while ((*p++ = *src++) != 0 && --available > 0);
@ -36,7 +36,7 @@ nd_strcat_s(
if (available == 0) if (available == 0)
{ {
nd_memzero(dst, dst_size); nd_memzero(dst, dst_size);
return NULL; return (char *)ND_NULL;
} }
return dst; return dst;
@ -45,18 +45,18 @@ nd_strcat_s(
#if !defined(BDDISASM_NO_FORMAT) && defined(BDDISASM_HAS_VSNPRINTF) #if !defined(BDDISASM_NO_FORMAT) && defined(BDDISASM_HAS_VSNPRINTF)
#include <stdio.h> #include <stdio.h>
int nd_vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, const char *format, va_list argptr) int nd_vsnprintf_s(char *buffer, ND_SIZET sizeOfBuffer, ND_SIZET count, const char *format, va_list argptr)
{ {
UNREFERENCED_PARAMETER(count); UNREFERENCED_PARAMETER(count);
return vsnprintf(buffer, sizeOfBuffer, format, argptr); return vsnprintf(buffer, sizeOfBuffer, format, argptr);
} }
#endif // !defined(BDDISASM_NO_FORMAT) && defined(BDDISASM_HAS_VSNPRINTF) #endif // !defined(BDDISASM_NO_FORMAT) && defined(BDDISASM_HAS_VSNPRINTF)
#if !defined(BDDISASM_NO_FORMAT) && defined(BDDISASM_HAS_MEMSET) #if defined(BDDISASM_HAS_MEMSET)
#include <string.h> #include <string.h>
void *nd_memset(void *s, int c, size_t n) void *nd_memset(void *s, int c, ND_SIZET n)
{ {
return memset(s, c, n); return memset(s, c, n);
} }
#endif // !defined(BDDISASM_NO_FORMAT) && defined(BDDISASM_HAS_MEMSET) #endif // defined(BDDISASM_HAS_MEMSET)

@ -44711,7 +44711,7 @@ const ND_INSTRUCTION gInstructions[2701] =
{ {
ND_INS_WRUSS, ND_CAT_CET, ND_SET_CET_SS, 1659, ND_INS_WRUSS, ND_CAT_CET, ND_SET_CET_SS, 1659,
0, 0,
ND_MOD_ANY, ND_MOD_R0|ND_MOD_REAL|ND_MOD_V8086|ND_MOD_PROT|ND_MOD_COMPAT|ND_MOD_LONG|ND_MOD_VMXR|ND_MOD_VMXN|ND_MOD_VMXR_SEAM|ND_MOD_VMXN_SEAM|ND_MOD_VMX_OFF|ND_MOD_SMM|ND_MOD_SMM_OFF|ND_MOD_SGX_OFF|ND_MOD_TSX|ND_MOD_TSX_OFF,
0, ND_OPS_CNT(2, 0), 0, 0, 0, 0, 0, 0, ND_FLAG_SHS|ND_FLAG_MODRM, ND_CFF_CET_SS, 0, ND_OPS_CNT(2, 0), 0, 0, 0, 0, 0, 0, ND_FLAG_SHS|ND_FLAG_MODRM, ND_CFF_CET_SS,
0, 0,
0, 0,
@ -44727,7 +44727,7 @@ const ND_INSTRUCTION gInstructions[2701] =
{ {
ND_INS_WRUSS, ND_CAT_CET, ND_SET_CET_SS, 1660, ND_INS_WRUSS, ND_CAT_CET, ND_SET_CET_SS, 1660,
0, 0,
ND_MOD_ANY, ND_MOD_R0|ND_MOD_REAL|ND_MOD_V8086|ND_MOD_PROT|ND_MOD_COMPAT|ND_MOD_LONG|ND_MOD_VMXR|ND_MOD_VMXN|ND_MOD_VMXR_SEAM|ND_MOD_VMXN_SEAM|ND_MOD_VMX_OFF|ND_MOD_SMM|ND_MOD_SMM_OFF|ND_MOD_SGX_OFF|ND_MOD_TSX|ND_MOD_TSX_OFF,
0, ND_OPS_CNT(2, 0), 0, 0, 0, 0, 0, 0, ND_FLAG_SHS|ND_FLAG_MODRM, ND_CFF_CET_SS, 0, ND_OPS_CNT(2, 0), 0, 0, 0, 0, 0, 0, ND_FLAG_SHS|ND_FLAG_MODRM, ND_CFF_CET_SS,
0, 0,
0, 0,
@ -44743,7 +44743,7 @@ const ND_INSTRUCTION gInstructions[2701] =
{ {
ND_INS_XABORT, ND_CAT_UNCOND_BR, ND_SET_TSX, 1661, ND_INS_XABORT, ND_CAT_UNCOND_BR, ND_SET_TSX, 1661,
0, 0,
ND_MOD_R0|ND_MOD_R1|ND_MOD_R2|ND_MOD_R3|ND_MOD_REAL|ND_MOD_V8086|ND_MOD_PROT|ND_MOD_COMPAT|ND_MOD_LONG|ND_MOD_VMXR|ND_MOD_VMXN|ND_MOD_VMXR_SEAM|ND_MOD_VMXN_SEAM|ND_MOD_VMX_OFF|ND_MOD_SMM|ND_MOD_SMM_OFF|ND_MOD_SGX|ND_MOD_SGX_OFF|ND_MOD_TSX_OFF, ND_MOD_ANY,
0, ND_OPS_CNT(1, 2), 0, 0, 0, 0, 0, 0, ND_FLAG_MODRM, ND_CFF_RTM, 0, ND_OPS_CNT(1, 2), 0, 0, 0, 0, 0, 0, ND_FLAG_MODRM, ND_CFF_RTM,
0, 0,
0, 0,

@ -11,54 +11,8 @@
#define UNREFERENCED_PARAMETER(P) ((void)(P)) #define UNREFERENCED_PARAMETER(P) ((void)(P))
#endif #endif
#if defined(_MSC_VER) #if !defined(_MSC_VER)
#include <vadefs.h>
# ifndef _ADDRESSOF
# ifdef __cplusplus
# define _ADDRESSOF(v) ( &reinterpret_cast<const char &>(v) )
# else
# define _ADDRESSOF(v) ( &(v) )
# endif // __cplusplus
# endif // !_ADDRESSOF
# ifndef _KERNEL_MODE
# if defined(AMD64) || defined(WIN64)
# define _crt_va_start(ap, x) ( __va_start(&ap, x) )
# define _crt_va_arg(ap, t) ( ( sizeof(t) > sizeof(QWORD) || ( sizeof(t) & (sizeof(t) - 1) ) != 0 ) \
? **(t **)( ( ap += sizeof(QWORD) ) - sizeof(QWORD) ) \
: *(t *)( ( ap += sizeof(QWORD) ) - sizeof(QWORD) ) )
# define _crt_va_end(ap) ( ap = (va_list)0 )
# else
// a guess at the proper definitions for other platforms
# ifndef _INTSIZEOF
# define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
# endif // !_INTSIZEOF
# define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
# define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
# define _crt_va_end(ap) ( ap = (va_list)0 )
# endif // AMD64 || WIN64
# define va_start _crt_va_start
# define va_arg _crt_va_arg
# define va_end _crt_va_end
#endif // _KERNEL_MODE
#else
# include <stdarg.h>
# define __forceinline inline __attribute__((always_inline)) # define __forceinline inline __attribute__((always_inline))
#endif // _MSC_VER #endif // _MSC_VER
// By default, an integrator is expected to provide nd_vsnprintf_s and nd_strcat_s. // By default, an integrator is expected to provide nd_vsnprintf_s and nd_strcat_s.
@ -66,10 +20,12 @@
// If BDDISASM_NO_FORMAT is defined at compile time these requirements are removed. Instruction formatting will no // If BDDISASM_NO_FORMAT is defined at compile time these requirements are removed. Instruction formatting will no
// longer be available in bddisasm and emulation tracing will no longer be available in bdshemu. // longer be available in bddisasm and emulation tracing will no longer be available in bdshemu.
#ifndef BDDISASM_NO_FORMAT #ifndef BDDISASM_NO_FORMAT
#include <stdarg.h>
extern int nd_vsnprintf_s( extern int nd_vsnprintf_s(
char *buffer, char *buffer,
size_t sizeOfBuffer, ND_SIZET sizeOfBuffer,
size_t count, ND_SIZET count,
const char *format, const char *format,
va_list argptr va_list argptr
); );
@ -77,13 +33,13 @@ extern int nd_vsnprintf_s(
char * char *
nd_strcat_s( nd_strcat_s(
char *dst, char *dst,
size_t dst_size, ND_SIZET dst_size,
const char *src const char *src
); );
#endif // !BDDISASM_NO_FORMAT #endif // !BDDISASM_NO_FORMAT
// Declared here only. Expecting it to be defined in the integrator. // Declared here only. Expecting it to be defined in the integrator.
extern void *nd_memset(void *s, int c, size_t n); extern void *nd_memset(void *s, int c, ND_SIZET n);
#define nd_memzero(Dest, Size) nd_memset((Dest), 0, (Size)) #define nd_memzero(Dest, Size) nd_memset((Dest), 0, (Size))

@ -10,7 +10,7 @@
#define ND_PREF_CODE_EX 2 #define ND_PREF_CODE_EX 2
#define ND_PREF_CODE_REX 3 #define ND_PREF_CODE_REX 3
static const uint8_t gPrefixesMap[256] = static const ND_UINT8 gPrefixesMap[256] =
{ {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F // 0 1 2 3 4 5 6 7 8 9 A B C D E F
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -5,6 +5,8 @@
#ifndef TABLEDEFS_H #ifndef TABLEDEFS_H
#define TABLEDEFS_H #define TABLEDEFS_H
#include "../inc/disasmtypes.h"
// //
// Types of tables. // Types of tables.
// //
@ -80,104 +82,104 @@ typedef enum _ND_ILUT_TYPE
typedef struct _ND_TABLE typedef struct _ND_TABLE
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[1]; const void *Table[1];
} ND_TABLE, *PND_TABLE; } ND_TABLE, *PND_TABLE;
typedef struct _ND_TABLE_INSTRUCTION typedef struct _ND_TABLE_INSTRUCTION
{ {
uint32_t Type; ND_UINT32 Type;
const void *Instruction; const void *Instruction;
} ND_TABLE_INSTRUCTION, *PND_TABLE_INSTRUCTION; } ND_TABLE_INSTRUCTION, *PND_TABLE_INSTRUCTION;
typedef struct _ND_TABLE_OPCODE typedef struct _ND_TABLE_OPCODE
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[256]; const void *Table[256];
} ND_TABLE_OPCODE, *PND_TABLE_OPCODE; } ND_TABLE_OPCODE, *PND_TABLE_OPCODE;
typedef struct _ND_TABLE_MODRM_MOD typedef struct _ND_TABLE_MODRM_MOD
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[2]; const void *Table[2];
} ND_TABLE_MODRM_MOD, *PND_TABLE_MODRM_MOD; } ND_TABLE_MODRM_MOD, *PND_TABLE_MODRM_MOD;
typedef struct _ND_TABLE_MODRM_REG typedef struct _ND_TABLE_MODRM_REG
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[8]; const void *Table[8];
} ND_TABLE_MODRM_REG, *PND_TABLE_MODRM_REG; } ND_TABLE_MODRM_REG, *PND_TABLE_MODRM_REG;
typedef struct _ND_TABLE_MODRM_RM typedef struct _ND_TABLE_MODRM_RM
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[8]; const void *Table[8];
} ND_TABLE_MODRM_RM, *PND_TABLE_MODRM_RM; } ND_TABLE_MODRM_RM, *PND_TABLE_MODRM_RM;
typedef struct _ND_TABLE_MPREFIX typedef struct _ND_TABLE_MPREFIX
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[4]; const void *Table[4];
} ND_TABLE_MPREFIX, *PND_TABLE_MPREFIX; } ND_TABLE_MPREFIX, *PND_TABLE_MPREFIX;
typedef struct _ND_TABLE_AUXILIARY typedef struct _ND_TABLE_AUXILIARY
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[6]; const void *Table[6];
} ND_TABLE_AUXILIARY, *PND_TABLE_AUXILIARY; } ND_TABLE_AUXILIARY, *PND_TABLE_AUXILIARY;
typedef struct _ND_TABLE_VENDOR typedef struct _ND_TABLE_VENDOR
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[6]; const void *Table[6];
} ND_TABLE_VENDOR; } ND_TABLE_VENDOR;
typedef struct _ND_TABLE_FEATURE typedef struct _ND_TABLE_FEATURE
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[4]; const void *Table[4];
} ND_TABLE_FEATURE; } ND_TABLE_FEATURE;
typedef struct _ND_TABLE_DSIZE typedef struct _ND_TABLE_DSIZE
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[6]; const void *Table[6];
} ND_TABLE_DSIZE, *PND_TABLE_DSIZE; } ND_TABLE_DSIZE, *PND_TABLE_DSIZE;
typedef struct _ND_TABLE_ASIZE typedef struct _ND_TABLE_ASIZE
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[4]; const void *Table[4];
} ND_TABLE_ASIZE, *PND_TABLE_ASIZE; } ND_TABLE_ASIZE, *PND_TABLE_ASIZE;
typedef struct _ND_TABLE_MODE typedef struct _ND_TABLE_MODE
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[4]; const void *Table[4];
} ND_TABLE_MODE, *PND_TABLE_MODE; } ND_TABLE_MODE, *PND_TABLE_MODE;
typedef struct _ND_TABLE_VEX_MMMMM typedef struct _ND_TABLE_VEX_MMMMM
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[32]; const void *Table[32];
} ND_TABLE_VEX_MMMMM, *PND_TABLE_VEX_MMMMM; } ND_TABLE_VEX_MMMMM, *PND_TABLE_VEX_MMMMM;
typedef struct _ND_TABLE_VEX_PP typedef struct _ND_TABLE_VEX_PP
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[4]; const void *Table[4];
} ND_TABLE_VEX_PP, *PND_TABLE_VEX_PP; } ND_TABLE_VEX_PP, *PND_TABLE_VEX_PP;
typedef struct _ND_TABLE_VEX_L typedef struct _ND_TABLE_VEX_L
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[4]; const void *Table[4];
} ND_TABLE_VEX_L, *PND_TABLE_VEX_L; } ND_TABLE_VEX_L, *PND_TABLE_VEX_L;
typedef struct _ND_TABLE_VEX_W typedef struct _ND_TABLE_VEX_W
{ {
uint32_t Type; ND_UINT32 Type;
const void *Table[8]; const void *Table[8];
} ND_TABLE_VEX_W, *PND_TABLE_VEX_W; } ND_TABLE_VEX_W, *PND_TABLE_VEX_W;
@ -194,37 +196,37 @@ __attribute__((aligned(128)))
#endif #endif
typedef struct _ND_INSTRUCTION typedef struct _ND_INSTRUCTION
{ {
uint16_t Instruction; // Instruction identifier. Check ND_INS_CLASS definitions. ND_UINT16 Instruction; // Instruction identifier. Check ND_INS_CLASS definitions.
uint8_t Category; // Instruction category. Check ND_INS_TYPE. ND_UINT8 Category; // Instruction category. Check ND_INS_TYPE.
uint8_t IsaSet; // Instruction set. Check ND_INS_SET. ND_UINT8 IsaSet; // Instruction set. Check ND_INS_SET.
uint16_t Mnemonic; // Mnemonic (index inside the global mnemonic table). ND_UINT16 Mnemonic; // Mnemonic (index inside the global mnemonic table).
uint16_t ValidPrefixes; // Accepted prefixes. ND_UINT16 ValidPrefixes; // Accepted prefixes.
uint32_t ValidModes; // Valid operating modes for the instruction. ND_UINT32 ValidModes; // Valid operating modes for the instruction.
uint8_t ValidDecorators;// Accepted decorators (valid for EVEX instructions). ND_UINT8 ValidDecorators;// Accepted decorators (valid for EVEX instructions).
uint8_t OpsCount; // Low 4 bits: explicit operands count; high 4 bits: implicit ops count. ND_UINT8 OpsCount; // Low 4 bits: explicit operands count; high 4 bits: implicit ops count.
uint8_t TupleType; // EVEX tuple type. ND_UINT8 TupleType; // EVEX tuple type.
uint8_t ExcType : 5; // SSE/VEX/EVEX/OPMASK/AMX exception type. ND_UINT8 ExcType : 5; // SSE/VEX/EVEX/OPMASK/AMX exception type.
uint8_t ExcClass : 3; // Indicates the exception class (SSE/AVX, EVEX, OPMASK or AMX). ND_UINT8 ExcClass : 3; // Indicates the exception class (SSE/AVX, EVEX, OPMASK or AMX).
uint8_t FpuFlags; // FPU status word C0, C1, C2 & C3 access type. ND_UINT8 FpuFlags; // FPU status word C0, C1, C2 & C3 access type.
uint8_t Reserved2; ND_UINT8 Reserved2;
uint16_t Reserved3; ND_UINT16 Reserved3;
uint32_t Attributes; // Instruction attributes. ND_UINT32 Attributes; // Instruction attributes.
uint64_t CpuidFlag; // Required CPUID feature flag. ND_UINT64 CpuidFlag; // Required CPUID feature flag.
// Per-flag access. Undefined flags will have their bit set in both the "Set" and "Cleared" mask, since a flag // Per-flag access. Undefined flags will have their bit set in both the "Set" and "Cleared" mask, since a flag
// cannot be both cleared and set. // cannot be both cleared and set.
uint32_t TestedFlags; // Tested flags. ND_UINT32 TestedFlags; // Tested flags.
uint32_t ModifiedFlags; // Modified flags. ND_UINT32 ModifiedFlags; // Modified flags.
uint32_t SetFlags; // Flags that are always set to 1. ND_UINT32 SetFlags; // Flags that are always set to 1.
uint32_t ClearedFlags; // Flags that are always cleared. ND_UINT32 ClearedFlags; // Flags that are always cleared.
uint64_t Operands[10]; ND_UINT64 Operands[10];
} ND_INSTRUCTION, *PND_INSTRUCTION; } ND_INSTRUCTION, *PND_INSTRUCTION;
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
@ -241,12 +243,12 @@ typedef struct _ND_INSTRUCTION
// Byte 4: operand decorators // Byte 4: operand decorators
// Byte 5: operand block addressing mode - 0 if not block addressing // Byte 5: operand block addressing mode - 0 if not block addressing
// //
#define ND_OP(type, size, flags, acc, dec, block) (((uint64_t)((type) & 0xFF) << 0) | \ #define ND_OP(type, size, flags, acc, dec, block) (((ND_UINT64)((type) & 0xFF) << 0) | \
((uint64_t)((size) & 0xFF) << 8) | \ ((ND_UINT64)((size) & 0xFF) << 8) | \
((uint64_t)((flags) & 0xFF) << 16) | \ ((ND_UINT64)((flags) & 0xFF) << 16) | \
((uint64_t)((acc) & 0xFF) << 24) | \ ((ND_UINT64)((acc) & 0xFF) << 24) | \
((uint64_t)((dec) & 0xFF) << 32) | \ ((ND_UINT64)((dec) & 0xFF) << 32) | \
((uint64_t)((block) & 0xFF) << 40)) ((ND_UINT64)((block) & 0xFF) << 40))
#define OP ND_OP #define OP ND_OP

@ -114,9 +114,9 @@
ISA Set: CET_SS, Ins cat: CET, CET tracked: no ISA Set: CET_SS, Ins cat: CET, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7 CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7
Valid modes Valid modes
R0: yes, R1: yes, R2: yes, R3: yes R0: yes, R1: no, R2: no, R3: no
Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes SMM on: yes, SMM off: yes, SGX on: no, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes Valid prefixes
REP: no, REPcc: no, LOCK: no REP: no, REPcc: no, LOCK: no
@ -131,9 +131,9 @@
ISA Set: CET_SS, Ins cat: CET, CET tracked: no ISA Set: CET_SS, Ins cat: CET, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7 CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7
Valid modes Valid modes
R0: yes, R1: yes, R2: yes, R3: yes R0: yes, R1: no, R2: no, R3: no
Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes SMM on: yes, SMM off: yes, SGX on: no, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes Valid prefixes
REP: no, REPcc: no, LOCK: no REP: no, REPcc: no, LOCK: no

@ -39,7 +39,7 @@
Valid modes Valid modes
R0: yes, R1: yes, R2: yes, R3: yes R0: yes, R1: yes, R2: yes, R3: yes
Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: no, TSX off: yes SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes Valid prefixes
REP: no, REPcc: no, LOCK: no REP: no, REPcc: no, LOCK: no

@ -133,9 +133,9 @@
ISA Set: CET_SS, Ins cat: CET, CET tracked: no ISA Set: CET_SS, Ins cat: CET, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7 CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7
Valid modes Valid modes
R0: yes, R1: yes, R2: yes, R3: yes R0: yes, R1: no, R2: no, R3: no
Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes SMM on: yes, SMM off: yes, SGX on: no, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes Valid prefixes
REP: no, REPcc: no, LOCK: no REP: no, REPcc: no, LOCK: no

@ -167,9 +167,9 @@
ISA Set: CET_SS, Ins cat: CET, CET tracked: no ISA Set: CET_SS, Ins cat: CET, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7 CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7
Valid modes Valid modes
R0: yes, R1: yes, R2: yes, R3: yes R0: yes, R1: no, R2: no, R3: no
Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes SMM on: yes, SMM off: yes, SGX on: no, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes Valid prefixes
REP: no, REPcc: no, LOCK: no REP: no, REPcc: no, LOCK: no
@ -184,9 +184,9 @@
ISA Set: CET_SS, Ins cat: CET, CET tracked: no ISA Set: CET_SS, Ins cat: CET, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7 CPUID leaf: 0x00000007, sub-leaf: 0x00000000, reg: ecx, bit: 7
Valid modes Valid modes
R0: yes, R1: yes, R2: yes, R3: yes R0: yes, R1: no, R2: no, R3: no
Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes Real: yes, V8086: yes, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes SMM on: yes, SMM off: yes, SGX on: no, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes Valid prefixes
REP: no, REPcc: no, LOCK: no REP: no, REPcc: no, LOCK: no

File diff suppressed because it is too large Load Diff

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugKernel|ARM64">
<Configuration>DebugKernel</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="DebugKernel|Win32"> <ProjectConfiguration Include="DebugKernel|Win32">
<Configuration>DebugKernel</Configuration> <Configuration>DebugKernel</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -9,10 +13,18 @@
<Configuration>DebugKernel</Configuration> <Configuration>DebugKernel</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="ReleaseKernel|ARM64">
<Configuration>ReleaseKernel</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseKernel|Win32"> <ProjectConfiguration Include="ReleaseKernel|Win32">
<Configuration>ReleaseKernel</Configuration> <Configuration>ReleaseKernel</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -21,6 +33,10 @@
<Configuration>ReleaseKernel</Configuration> <Configuration>ReleaseKernel</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -79,6 +95,12 @@
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
@ -88,6 +110,15 @@
<DriverTargetPlatform>Desktop</DriverTargetPlatform> <DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging> <SupportsPackaging>false</SupportsPackaging>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<TargetVersion></TargetVersion>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
@ -95,6 +126,13 @@
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
@ -105,6 +143,16 @@
<DriverTargetPlatform>Desktop</DriverTargetPlatform> <DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging> <SupportsPackaging>false</SupportsPackaging>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<TargetVersion></TargetVersion>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
@ -125,15 +173,27 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="PropertySheets"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'" 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|x64'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="PropertySheets"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'" 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 Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
@ -153,12 +213,24 @@
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.lib</TargetExt>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<TargetExt>.lib</TargetExt> <TargetExt>.lib</TargetExt>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.lib</TargetExt>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
@ -177,12 +249,24 @@
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.lib</TargetExt> <TargetExt>.lib</TargetExt>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.lib</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.lib</TargetExt> <TargetExt>.lib</TargetExt>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.lib</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
@ -253,6 +337,37 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies> <LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference> </ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>..\inc;..\bddisasm\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<StringPooling>true</StringPooling>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/D "AMD64" %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>bddisasm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|x64'">
<ClCompile> <ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
@ -284,6 +399,37 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies> <LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference> </ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugKernel|ARM64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>..\inc;..\bddisasm\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<StringPooling>true</StringPooling>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/kernel /D "AMD64" %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>bddisasm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
@ -363,6 +509,46 @@
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<AdditionalOptions>/D "AMD64" %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/D "AMD64" %(AdditionalOptions)</AdditionalOptions>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>bddisasm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<Lib />
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>
</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>..\inc;..\bddisasm\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
<ShowIncludes>false</ShowIncludes>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<StringPooling>true</StringPooling>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<ExceptionHandling>Sync</ExceptionHandling>
<MinimalRebuild>true</MinimalRebuild>
<AdditionalOptions>/D "AMD64" %(AdditionalOptions)</AdditionalOptions>
<CompileAs>Default</CompileAs>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -415,6 +601,44 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies> <LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference> </ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKernel|ARM64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>
</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>..\inc;..\bddisasm\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
<ShowIncludes>false</ShowIncludes>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<StringPooling>true</StringPooling>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<ProgramDataBaseFileName>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName).pdb</ProgramDataBaseFileName>
<ExceptionHandling>Sync</ExceptionHandling>
<MinimalRebuild>true</MinimalRebuild>
<AdditionalOptions>/kernel /D "AMD64" %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>bddisasm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<Lib />
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="bdshemu.c" /> <ClCompile Include="bdshemu.c" />
</ItemGroup> </ItemGroup>

@ -12,7 +12,7 @@ from setuptools import find_packages, setup, Command, Extension, Distribution
from codecs import open from codecs import open
VERSION = (0, 1, 3) VERSION = (0, 1, 3)
LIBRARY_VERSION = (1, 34, 9) LIBRARY_VERSION = (1, 34, 10)
LIBRARY_INSTRUX_SIZE = 856 LIBRARY_INSTRUX_SIZE = 856
packages = ['pybddisasm'] packages = ['pybddisasm']

File diff suppressed because it is too large Load Diff

@ -27,13 +27,13 @@ typedef void
// Note that by using the ShemuContext, the integrator knows whether the access is user or supervisor (the Ring field // Note that by using the ShemuContext, the integrator knows whether the access is user or supervisor (the Ring field
// inside ShemuContext), and he knows whether it is 16/32/64 bit mode (Mode field inside ShemuContext). // inside ShemuContext), and he knows whether it is 16/32/64 bit mode (Mode field inside ShemuContext).
// //
typedef bool typedef ND_BOOL
(*ShemuMemAccess)( (*ShemuMemAccess)(
void *ShemuContext, // Shemu emulation context. void *ShemuContext, // Shemu emulation context.
uint64_t Gla, // Linear address to be accessed. ND_UINT64 Gla, // Linear address to be accessed.
size_t Size, // Number of bytes to access. ND_SIZET Size, // Number of bytes to access.
uint8_t *Buffer, // Contains the read content (if Store is false), or the value to be stored at Gla. ND_UINT8 *Buffer, // Contains the read content (if Store is false), or the value to be stored at Gla.
bool Store // If false, read content at Gla. Otherwise, write content at Gla. ND_BOOL Store // If false, read content at Gla. Otherwise, write content at Gla.
); );
@ -51,36 +51,35 @@ typedef bool
// //
typedef struct _SHEMU_GPR_REGS typedef struct _SHEMU_GPR_REGS
{ {
uint64_t RegRax; ND_UINT64 RegRax;
uint64_t RegRcx; ND_UINT64 RegRcx;
uint64_t RegRdx; ND_UINT64 RegRdx;
uint64_t RegRbx; ND_UINT64 RegRbx;
uint64_t RegRsp; ND_UINT64 RegRsp;
uint64_t RegRbp; ND_UINT64 RegRbp;
uint64_t RegRsi; ND_UINT64 RegRsi;
uint64_t RegRdi; ND_UINT64 RegRdi;
uint64_t RegR8; ND_UINT64 RegR8;
uint64_t RegR9; ND_UINT64 RegR9;
uint64_t RegR10; ND_UINT64 RegR10;
uint64_t RegR11; ND_UINT64 RegR11;
uint64_t RegR12; ND_UINT64 RegR12;
uint64_t RegR13; ND_UINT64 RegR13;
uint64_t RegR14; ND_UINT64 RegR14;
uint64_t RegR15; ND_UINT64 RegR15;
uint64_t RegCr2; ND_UINT64 RegCr2;
uint64_t RegFlags; ND_UINT64 RegFlags;
uint64_t RegDr7; ND_UINT64 RegDr7;
uint64_t RegRip; ND_UINT64 RegRip;
uint64_t RegCr0; ND_UINT64 RegCr0;
uint64_t RegCr4; ND_UINT64 RegCr4;
uint64_t RegCr3; ND_UINT64 RegCr3;
uint64_t RegCr8; ND_UINT64 RegCr8;
uint64_t RegIdtBase; ND_UINT64 RegIdtBase;
uint64_t RegIdtLimit; ND_UINT64 RegIdtLimit;
uint64_t RegGdtBase; ND_UINT64 RegGdtBase;
uint64_t RegGdtLimit; ND_UINT64 RegGdtLimit;
ND_UINT64 FpuRip;
uint64_t FpuRip;
} SHEMU_GPR_REGS, *PSHEMU_GPR_REGS; } SHEMU_GPR_REGS, *PSHEMU_GPR_REGS;
@ -89,10 +88,10 @@ typedef struct _SHEMU_GPR_REGS
// //
typedef struct _SHEMU_SEG typedef struct _SHEMU_SEG
{ {
uint64_t Base; ND_UINT64 Base;
uint64_t Limit; ND_UINT64 Limit;
uint64_t Selector; ND_UINT64 Selector;
uint64_t AccessRights; ND_UINT64 AccessRights;
} SHEMU_SEG, *PSHEMU_SEG; } SHEMU_SEG, *PSHEMU_SEG;
@ -127,85 +126,85 @@ typedef struct _SHEMU_CONTEXT
SHEMU_SEG_REGS Segments; SHEMU_SEG_REGS Segments;
// MMX register state. 8 x 8 bytes = 64 bytes for the MMX registers. Can be provided on input, if needed. // MMX register state. 8 x 8 bytes = 64 bytes for the MMX registers. Can be provided on input, if needed.
uint64_t MmxRegisters[ND_MAX_MMX_REGS]; ND_UINT64 MmxRegisters[ND_MAX_MMX_REGS];
// SSE registers state. 32 x 64 bytes = 2048 bytes for the SSE registers. Can be provided on input, if needed. // SSE registers state. 32 x 64 bytes = 2048 bytes for the SSE registers. Can be provided on input, if needed.
uint8_t SseRegisters[ND_MAX_SSE_REGS * ND_MAX_REGISTER_SIZE]; ND_UINT8 SseRegisters[ND_MAX_SSE_REGS * ND_MAX_REGISTER_SIZE];
// General purpose registers write bitmap. After the first write, a register will be marked dirty in here. // General purpose registers write bitmap. After the first write, a register will be marked dirty in here.
// Should be 0 on input. // Should be 0 on input.
uint16_t DirtyGprBitmap; ND_UINT16 DirtyGprBitmap;
// Operating mode (ND_CODE_16, ND_CODE_32 or ND_CODE_64). Must be provided as input. // Operating mode (ND_CODE_16, ND_CODE_32 or ND_CODE_64). Must be provided as input.
uint8_t Mode; ND_UINT8 Mode;
// Operating ring (0, 1, 2, 3). Must be provided as input. // Operating ring (0, 1, 2, 3). Must be provided as input.
uint8_t Ring; ND_UINT8 Ring;
// The suspicious code to be emulated. Must be provided as input. // The suspicious code to be emulated. Must be provided as input.
uint8_t *Shellcode; ND_UINT8 *Shellcode;
// Virtual stack. RSP will point somewhere inside. Must be allocated as input, and it can be initialized with // Virtual stack. RSP will point somewhere inside. Must be allocated as input, and it can be initialized with
// actual stack contents. Can also be 0-filled. // actual stack contents. Can also be 0-filled.
uint8_t *Stack; ND_UINT8 *Stack;
// Internal use. Must be at least the size of the shell + stack. Needs not be initialized, but must be allocated // Internal use. Must be at least the size of the shell + stack. Needs not be initialized, but must be allocated
// and accessible on input. // and accessible on input.
uint8_t *Intbuf; ND_UINT8 *Intbuf;
// Shellcode base address (the address the shellcode would see). Must be provided as input. // Shellcode base address (the address the shellcode would see). Must be provided as input.
uint64_t ShellcodeBase; ND_UINT64 ShellcodeBase;
// Stack base address (the RSP the shellcode would see). Must be provided as input. // Stack base address (the RSP the shellcode would see). Must be provided as input.
uint64_t StackBase; ND_UINT64 StackBase;
// Shellcode size. Must be provided as input. Usually just a page in size, but can be larger. // Shellcode size. Must be provided as input. Usually just a page in size, but can be larger.
uint32_t ShellcodeSize; ND_UINT32 ShellcodeSize;
// Stack size. Must be provided as input. Minimum two pages. // Stack size. Must be provided as input. Minimum two pages.
uint32_t StackSize; ND_UINT32 StackSize;
// Internal buffer size. Must be provided as input. Must be at least the size of the shell + stack. // Internal buffer size. Must be provided as input. Must be at least the size of the shell + stack.
uint32_t IntbufSize; ND_UINT32 IntbufSize;
// Number of NOPs encountered. Should be 0 on input. // Number of NOPs encountered. Should be 0 on input.
uint32_t NopCount; ND_UINT32 NopCount;
// The length of the string constructed on the stack, if any. Should be 0 on input. // The length of the string constructed on the stack, if any. Should be 0 on input.
uint32_t StrLength; ND_UINT32 StrLength;
// Number of external memory access (outside stack/shellcode). Should be 0 on input. // Number of external memory access (outside stack/shellcode). Should be 0 on input.
uint32_t ExtMemAccess; ND_UINT32 ExtMemAccess;
// Number of emulated instructions. Should be 0 on input. Once InstructionsCount reaches MaxInstructionsCount, // Number of emulated instructions. Should be 0 on input. Once InstructionsCount reaches MaxInstructionsCount,
// emulation will stop. // emulation will stop.
uint32_t InstructionsCount; ND_UINT32 InstructionsCount;
// Max number of instructions that should be emulated. Once this limit has been reached, emulation will stop. // Max number of instructions that should be emulated. Once this limit has been reached, emulation will stop.
// Lower values will mean faster processing, but less chances of detection. Higher values mean low performance, // Lower values will mean faster processing, but less chances of detection. Higher values mean low performance,
// but very high chances of yielding useful results. Must be provided as input. // but very high chances of yielding useful results. Must be provided as input.
uint32_t MaxInstructionsCount; ND_UINT32 MaxInstructionsCount;
// Base address of the Thread Information Block (the TIB the shellcode would normally see). Must be provided as // Base address of the Thread Information Block (the TIB the shellcode would normally see). Must be provided as
// input. // input.
uint64_t TibBase; ND_UINT64 TibBase;
// Shellcode Flags (see SHEMU_FLAG_*). Must be provided as input. // Shellcode Flags (see SHEMU_FLAG_*). Must be provided as input.
uint64_t Flags; ND_UINT64 Flags;
// Emulation options. See SHEMU_OPT_* for possible options. Must be provided as input. // Emulation options. See SHEMU_OPT_* for possible options. Must be provided as input.
uint32_t Options; ND_UINT32 Options;
// Percent of NOPs (out of total instructions emulated) that trigger NOP sled detection. Must be provided as input. // Percent of NOPs (out of total instructions emulated) that trigger NOP sled detection. Must be provided as input.
uint32_t NopThreshold; ND_UINT32 NopThreshold;
// Stack string length threshold. Stack-constructed strings must be at least this long to trigger stack string // Stack string length threshold. Stack-constructed strings must be at least this long to trigger stack string
// detection. Must be provided as input. // detection. Must be provided as input.
uint32_t StrThreshold; ND_UINT32 StrThreshold;
// Number of external mem accesses threshold. No more than this number of external accesses will be issued. Must // Number of external mem accesses threshold. No more than this number of external accesses will be issued. Must
// be provided as input. // be provided as input.
uint32_t MemThreshold; ND_UINT32 MemThreshold;
// Optional auxiliary data, provided by the integrator. Can be NULL, or can point to integrator specific data. // Optional auxiliary data, provided by the integrator. Can be NULL, or can point to integrator specific data.
// Shemu will not use this data in any way, but callbacks that receive a SHEMU_CONTEXT pointer (such as // Shemu will not use this data in any way, but callbacks that receive a SHEMU_CONTEXT pointer (such as

@ -5,7 +5,7 @@
#define ND_CFF_NO_SUBLEAF 0x00FFFFFF #define ND_CFF_NO_SUBLEAF 0x00FFFFFF
#define ND_CFF(leaf, subleaf, reg, bit) ((uint64_t)(leaf) | ((uint64_t)((subleaf) & 0xFFFFFF) << 32) | ((uint64_t)(reg) << 56) | ((uint64_t)(bit) << 59)) #define ND_CFF(leaf, subleaf, reg, bit) ((ND_UINT64)(leaf) | ((ND_UINT64)((subleaf) & 0xFFFFFF) << 32) | ((ND_UINT64)(reg) << 56) | ((ND_UINT64)(bit) << 59))
#define ND_CFF_FPU ND_CFF(0x00000001, 0xFFFFFFFF, NDR_EDX, 0) #define ND_CFF_FPU ND_CFF(0x00000001, 0xFFFFFFFF, NDR_EDX, 0)
#define ND_CFF_MSR ND_CFF(0x00000001, 0xFFFFFFFF, NDR_EDX, 5) #define ND_CFF_MSR ND_CFF(0x00000001, 0xFFFFFFFF, NDR_EDX, 5)

@ -8,7 +8,7 @@
// //
// Return statuses. // Return statuses.
// //
typedef unsigned int NDSTATUS; typedef ND_UINT32 NDSTATUS;
// Success codes are all < 0x80000000. // Success codes are all < 0x80000000.
#define ND_STATUS_SUCCESS 0x00000000 // All good. #define ND_STATUS_SUCCESS 0x00000000 // All good.

@ -5,35 +5,96 @@
#ifndef DISASM_TYPES_H #ifndef DISASM_TYPES_H
#define DISASM_TYPES_H #define DISASM_TYPES_H
#if defined(_KERNEL_MODE) && defined(_MSC_VER)
# include <ntddk.h>
# include <Ntstrsafe.h>
# include <basetsd.h>
typedef UINT8 uint8_t; #if defined(_MSC_VER) || defined(__ICC) || defined(__INTEL_COMPILER)
typedef UINT16 uint16_t;
typedef UINT32 uint32_t;
typedef UINT64 uint64_t;
typedef INT8 int8_t; // Microsoft VC compiler.
typedef INT16 int16_t;
typedef INT32 int32_t;
typedef INT64 int64_t;
typedef _Bool bool; typedef unsigned __int8 ND_UINT8;
#define false 0 typedef unsigned __int16 ND_UINT16;
#define true 1 typedef unsigned __int32 ND_UINT32;
typedef unsigned __int64 ND_UINT64;
typedef signed __int8 ND_SINT8;
typedef signed __int16 ND_SINT16;
typedef signed __int32 ND_SINT32;
typedef signed __int64 ND_SINT64;
#elif defined(__KERNEL__) && defined(__GNUC__) #elif defined(__GNUC__) || defined(__GNUG__) || defined(__clang__)
# include <linux/types.h> // clang/GCC compiler.
typedef __UINT8_TYPE__ ND_UINT8;
typedef __UINT16_TYPE__ ND_UINT16;
typedef __UINT32_TYPE__ ND_UINT32;
typedef __UINT64_TYPE__ ND_UINT64;
typedef __INT8_TYPE__ ND_SINT8;
typedef __INT16_TYPE__ ND_SINT16;
typedef __INT32_TYPE__ ND_SINT32;
typedef __INT64_TYPE__ ND_SINT64;
#else #else
# include <stddef.h> // other compilers, assume stdint is present.
# include <stdint.h>
# include <stdbool.h> #include <stdint.h>
typedef uint8_t ND_UINT8;
typedef uint16_t ND_UINT16;
typedef uint32_t ND_UINT32;
typedef uint64_t ND_UINT64;
typedef int8_t ND_SINT8;
typedef int16_t ND_SINT16;
typedef int32_t ND_SINT32;
typedef int64_t ND_SINT64;
#endif #endif
#if defined(_M_AMD64) || defined(__x86_64__)
#define ND_ARCH_X64
#elif defined(_M_IX86) || defined(__i386__)
#define ND_ARCH_X86
#elif defined(_M_ARM64) || defined(__aarch64__)
#define ND_ARCH_AARCH64
#elif defined(_M_ARM) || defined(__arm__)
#define ND_ARCH_ARM
#else
#error "Unknown architecture!"
#endif
// Handle architecture definitions.
#if defined(ND_ARCH_X64) || defined(ND_ARCH_AARCH64)
typedef ND_UINT64 ND_SIZET;
#elif defined(ND_ARCH_X86) || defined(ND_ARCH_ARM)
typedef ND_UINT32 ND_SIZET;
#else
#error "Unknown architecture!"
#endif
// Common definitions.
typedef ND_UINT8 ND_BOOL;
#define ND_NULL ((void *)(0))
#define ND_TRUE (1)
#define ND_FALSE (0)
#endif #endif

@ -7,6 +7,6 @@
#define DISASM_VERSION_MAJOR 1 #define DISASM_VERSION_MAJOR 1
#define DISASM_VERSION_MINOR 34 #define DISASM_VERSION_MINOR 34
#define DISASM_VERSION_REVISION 9 #define DISASM_VERSION_REVISION 10
#endif // DISASM_VER_H #endif // DISASM_VER_H

@ -1215,7 +1215,7 @@ def dump_translation_tree_c(t, hname, f):
i = 0 i = 0
for p in pointers: for p in pointers:
if not p: if not p:
res += ' /* %02x */ NULL,\n' % i res += ' /* %02x */ ND_NULL,\n' % i
else: else:
res += ' /* %02x */ (const void *)&%s,\n' % (i, p) res += ' /* %02x */ (const void *)&%s,\n' % (i, p)
i += 1 i += 1
@ -1250,7 +1250,7 @@ def generate_features(features, fname):
f.write('#define ND_CFF_NO_SUBLEAF 0x00FFFFFF\n') f.write('#define ND_CFF_NO_SUBLEAF 0x00FFFFFF\n')
f.write('\n') f.write('\n')
f.write('\n') f.write('\n')
f.write('#define ND_CFF(leaf, subleaf, reg, bit) ((uint64_t)(leaf) | ((uint64_t)((subleaf) & 0xFFFFFF) << 32) | ((uint64_t)(reg) << 56) | ((uint64_t)(bit) << 59))\n') f.write('#define ND_CFF(leaf, subleaf, reg, bit) ((ND_UINT64)(leaf) | ((ND_UINT64)((subleaf) & 0xFFFFFF) << 32) | ((ND_UINT64)(reg) << 56) | ((ND_UINT64)(bit) << 59))\n')
f.write('\n') f.write('\n')
for c in features: for c in features:

@ -125,8 +125,8 @@ MOVBE Mv,Gv nil [ 0x0F 0x
MOVBE Mv,Gv nil [ 0x66 0x0F 0x38 0xF1 /r:mem] s:MOVBE, t:DATAXFER, w:W|R, a:S66 MOVBE Mv,Gv nil [ 0x66 0x0F 0x38 0xF1 /r:mem] s:MOVBE, t:DATAXFER, w:W|R, a:S66
CRC32 Gy,Ev nil [ 0xF2 0x0F 0x38 0xF1 /r] s:SSE42, t:SSE, w:RW|R CRC32 Gy,Ev nil [ 0xF2 0x0F 0x38 0xF1 /r] s:SSE42, t:SSE, w:RW|R
CRC32 Gy,Ev nil [ 0x66 0xF2 0x0F 0x38 0xF1 /r] s:SSE42, t:SSE, w:RW|R, a:S66 CRC32 Gy,Ev nil [ 0x66 0xF2 0x0F 0x38 0xF1 /r] s:SSE42, t:SSE, w:RW|R, a:S66
WRUSSD My,Gy nil [ 0x66 0x0F 0x38 0xF5 /r:mem] s:CET_SS, t:CET, c:WRUSS, a:SHS, w:W|R WRUSSD My,Gy nil [ 0x66 0x0F 0x38 0xF5 /r:mem] s:CET_SS, t:CET, c:WRUSS, a:SHS, w:W|R, m:KERNEL
WRUSSQ My,Gy nil [ rexw 0x66 0x0F 0x38 0xF5 /r:mem] s:CET_SS, t:CET, c:WRUSS, a:SHS, w:W|R WRUSSQ My,Gy nil [ rexw 0x66 0x0F 0x38 0xF5 /r:mem] s:CET_SS, t:CET, c:WRUSS, a:SHS, w:W|R, m:KERNEL
WRSSD My,Gy nil [ NP 0x0F 0x38 0xF6 /r:mem] s:CET_SS, t:CET, c:WRSS, a:SHS, w:W|R WRSSD My,Gy nil [ NP 0x0F 0x38 0xF6 /r:mem] s:CET_SS, t:CET, c:WRSS, a:SHS, w:W|R
WRSSQ My,Gy nil [ rexw NP 0x0F 0x38 0xF6 /r:mem] s:CET_SS, t:CET, c:WRSS, a:SHS, w:W|R WRSSQ My,Gy nil [ rexw NP 0x0F 0x38 0xF6 /r:mem] s:CET_SS, t:CET, c:WRSS, a:SHS, w:W|R
ADCX Gy,Ey Fv [ 0x66 0x0F 0x38 0xF6 /r] s:ADX, t:ARITH, w:RW|R|RW, f:CF=m ADCX Gy,Ey Fv [ 0x66 0x0F 0x38 0xF6 /r] s:ADX, t:ARITH, w:RW|R|RW, f:CF=m

@ -1,10 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -43,6 +51,12 @@
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
@ -50,6 +64,13 @@
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
@ -64,9 +85,15 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" 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|x64'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" 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 Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
@ -80,10 +107,18 @@
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_intdir\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
@ -104,6 +139,16 @@
<Command>generate_tables.py instructions</Command> <Command>generate_tables.py instructions</Command>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<PreBuildEvent>
<Command>generate_tables.py instructions</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
@ -136,6 +181,22 @@
<Command>generate_tables.py instructions</Command> <Command>generate_tables.py instructions</Command>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent>
<Command>generate_tables.py instructions</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<None Include="disasmlib.py" /> <None Include="disasmlib.py" />
<None Include="generate_tables.py" /> <None Include="generate_tables.py" />

Loading…
Cancel
Save