Skip to content

Commit

Permalink
Fixes for tests in release-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HoShiMin committed Feb 25, 2023
1 parent e232c02 commit d2400ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions HookLib/HookLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<TargetVersion>Windows7</TargetVersion>
<TargetVersion>Windows10</TargetVersion>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging>
<DriverType>WDM</DriverType>
Expand All @@ -72,7 +72,7 @@
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<TargetVersion>Windows7</TargetVersion>
<TargetVersion>Windows10</TargetVersion>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging>
<DriverType>WDM</DriverType>
Expand Down Expand Up @@ -108,7 +108,7 @@
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<TargetVersion>Windows7</TargetVersion>
<TargetVersion>Windows10</TargetVersion>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
<SupportsPackaging>false</SupportsPackaging>
<DriverType>WDM</DriverType>
Expand Down
7 changes: 7 additions & 0 deletions HookLibDrvTests/HookLibDrvTests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Configuration>Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
<RootNamespace>HookLibDrvTests</RootNamespace>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -118,6 +119,9 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalOptions>/Ob3 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DriverSign>
Expand Down Expand Up @@ -157,6 +161,9 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalOptions>/Ob3 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />
Expand Down
13 changes: 8 additions & 5 deletions HookLibDrvTests/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@

#define hk_assert(cond) if (!(cond)) { __int2c(); } __assume((cond))

extern "C" NTSTATUS NTAPI ZwYieldExecution();

namespace
{
template <unsigned int index>
constexpr unsigned int validFunc(int a, int b)
constexpr inline unsigned int validFunc(int a, int b)
{
return 0x1ee7c0de * (a + b + index);
}

template <unsigned int index>
constexpr unsigned int validHandler(int a, int b)
constexpr inline unsigned int validHandler(int a, int b)
{
return 0xc0ffee * (a + b + index);
}

template <unsigned int index>
__declspec(noinline) unsigned int func(int a, int b)
__declspec(noinline) __declspec(dllexport) unsigned int func(int a, int b)
{
ZwYieldExecution();
return validFunc<index>(a, b);
}

template <unsigned int index>
__declspec(noinline) unsigned int handler(int a, int b)
__declspec(noinline) __declspec(dllexport) unsigned int handler(int a, int b)
{
ZwYieldExecution();
return validHandler<index>(a, b);
}

Expand Down Expand Up @@ -87,7 +91,6 @@ namespace
testHookOnce();
testMultihook();
}

} // namespace


Expand Down

0 comments on commit d2400ce

Please sign in to comment.