Skip to content

Commit 42d3808

Browse files
committed
[SYNC] Update KNSoft.NDK and minor code improvements, no functional changes
1 parent ea95b89 commit 42d3808

File tree

14 files changed

+32
-37
lines changed

14 files changed

+32
-37
lines changed

Source/Demo/COMHook.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* This demo may crash on ARM64 host, see opening issues:
88
* https://github.com/microsoft/Detours/issues/292
99
* https://github.com/microsoft/Detours/issues/355
10+
* it may be related to ARM64 emulators, there’s nothing we can do.
1011
*/
1112

1213
#include "Demo.h"
@@ -15,17 +16,8 @@
1516

1617
#pragma comment(lib, "shlwapi.lib")
1718

18-
typedef
19-
HRESULT
20-
STDMETHODCALLTYPE
21-
FN_IStream_Read(
22-
IStream* This,
23-
_Out_writes_bytes_to_(cb, *pcbRead) void* pv,
24-
_In_ ULONG cb,
25-
_Out_opt_ ULONG* pcbRead);
26-
2719
static IStream* g_pStream = NULL;
28-
static FN_IStream_Read* g_pfnIStream_Read = NULL;
20+
static FIELD_TYPE(IStream, lpVtbl->Read) g_pfnIStream_Read = NULL;
2921
static LONG volatile g_lCount = 0;
3022
static ULONG g_ulValue = 123, g_ulRead = 0;
3123

@@ -50,12 +42,13 @@ Hooked_IStream_Read(
5042

5143
TEST_FUNC(COMHook)
5244
{
53-
/* FIXME: Skip in incompatible cases, see issues mentioned in the head */
54-
if (SharedUserData->NativeProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64)
45+
/* FIXME: Skip incompatible cases, see issues mentioned in the head */
46+
if (GET_NT_VERSION() >= NT_VERSION_WIN10 &&
47+
SharedUserData->NativeProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64 &&
48+
NtReadTeb(WowTebOffset) != 0)
5549
{
56-
#if defined(_M_IX86) || defined(_M_X64)
5750
TEST_SKIP("FIXME: COM Hook has issues in non-native environments on ARM64\n");
58-
#endif
51+
return;
5952
}
6053

6154
HRESULT hr;

Source/Demo/DelayHook.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#pragma comment(lib, "KNSoft.NDK.WinAPI.lib") // For Ldr(Register/Unregister)DllNotification imports
1515

1616
static HRESULT g_hrDelayAttach = E_FAIL;
17-
static FN_EqualRect* g_pfnOrgEqualRect = NULL;
17+
static typeof(&EqualRect) g_pfnOrgEqualRect = NULL;
1818

1919
static
2020
_Function_class_(LDR_DLL_NOTIFICATION_FUNCTION)

Source/Demo/Demo.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,14 @@
99

1010
EXTERN_C_START
1111

12-
typedef
13-
BOOL
14-
WINAPI
15-
FN_EqualRect(
16-
_In_ CONST RECT *lprc1,
17-
_In_ CONST RECT *lprc2);
18-
1912
typedef enum _DEMO_ENGINE_TYPE
2013
{
2114
EngineInvalid,
2215
EngineSlimDetours,
2316
EngineMicrosoftDetours
2417
} DEMO_ENGINE_TYPE, *PDEMO_ENGINE_TYPE;
2518

26-
EXTERN_C FN_EqualRect* g_pfnEqualRect;
19+
EXTERN_C typeof(&EqualRect) g_pfnEqualRect;
2720
EXTERN_C UNICODE_STRING g_usUser32;
2821
EXTERN_C ANSI_STRING g_asEqualRect;
2922
EXTERN_C LONG volatile g_lEqualRectCount;

Source/Demo/Demo.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@
229229
<ImportGroup Label="ExtensionTargets">
230230
<Import Project="$(VCTargetsPath)\BuildCustomizations\marmasm.targets" />
231231
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
232-
<Import Project="..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets" Condition="Exists('..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets')" />
232+
<Import Project="..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets" Condition="Exists('..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets')" />
233233
</ImportGroup>
234234
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
235235
<PropertyGroup>
236236
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
237237
</PropertyGroup>
238-
<Error Condition="!Exists('..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets'))" />
238+
<Error Condition="!Exists('..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets'))" />
239239
</Target>
240240
</Project>

Source/Demo/Instruction.x86.asm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.MODEL FLAT, C
2+
13
INCLUDE Instruction.inc
24

35
.CODE

Source/Demo/Main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CONST UNITTEST_ENTRY UnitTestList[] = {
2323

2424
#define DEMO_SWITCH_ENGINE L"-Engine="
2525

26-
FN_EqualRect* g_pfnEqualRect = NULL;
26+
typeof(&EqualRect) g_pfnEqualRect = NULL;
2727
UNICODE_STRING g_usUser32 = RTL_CONSTANT_STRING(L"user32.dll");
2828
ANSI_STRING g_asEqualRect = RTL_CONSTANT_STRING("EqualRect");
2929
LONG volatile g_lEqualRectCount = 0;

Source/Demo/TwiceSimpleHook.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "Demo.h"
88

99
static LONG volatile g_lEqualRect = 0;
10-
static FN_EqualRect* g_pfnEqualRect1 = NULL;
11-
static FN_EqualRect* g_pfnEqualRect2 = NULL;
10+
static typeof(&EqualRect) g_pfnEqualRect1 = NULL;
11+
static typeof(&EqualRect) g_pfnEqualRect2 = NULL;
1212

1313
static
1414
BOOL

Source/Demo/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="KNSoft.NDK" version="1.2.38-beta" targetFramework="native" />
3+
<package id="KNSoft.NDK" version="1.2.47-beta" targetFramework="native" />
44
</packages>

Source/KNSoft.SlimDetours/KNSoft.SlimDetours.vcxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<ClInclude Include="SlimDetours.h" />
4848
</ItemGroup>
4949
<ItemGroup>
50+
<None Include="packages.config" />
5051
<None Include="SlimDetours.inl" />
5152
<None Include="SlimDetours.NDK.inl" />
5253
</ItemGroup>
@@ -200,12 +201,12 @@
200201
</ItemDefinitionGroup>
201202
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
202203
<ImportGroup Label="ExtensionTargets">
203-
<Import Project="..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets" Condition="Exists('..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets')" />
204+
<Import Project="..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets" Condition="Exists('..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets')" />
204205
</ImportGroup>
205206
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
206207
<PropertyGroup>
207208
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
208209
</PropertyGroup>
209-
<Error Condition="!Exists('..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\KNSoft.NDK.1.2.38-beta\build\KNSoft.NDK.targets'))" />
210+
<Error Condition="!Exists('..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\KNSoft.NDK.1.2.47-beta\build\KNSoft.NDK.targets'))" />
210211
</Target>
211212
</Project>

Source/KNSoft.SlimDetours/KNSoft.SlimDetours.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
<ItemGroup>
1616
<None Include="SlimDetours.inl" />
1717
<None Include="SlimDetours.NDK.inl" />
18+
<None Include="packages.config" />
1819
</ItemGroup>
1920
</Project>

0 commit comments

Comments
 (0)