Skip to content

Commit

Permalink
[SLIMDETOURS] Improve initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
RatinCN committed Mar 24, 2024
1 parent bfd5da9 commit d7fb083
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 30 deletions.
5 changes: 5 additions & 0 deletions Source/SlimDetours/Instruction.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,8 @@ ULONG detour_is_code_filler(_In_ PBYTE pbCode)
}

#endif // defined(_M_ARM64)

PVOID NTAPI SlimDetoursCodeFromPointer(_In_ PVOID pPointer)
{
return detour_skip_jmp((PBYTE)pPointer);
}
23 changes: 0 additions & 23 deletions Source/SlimDetours/SlimDetours.c

This file was deleted.

16 changes: 16 additions & 0 deletions Source/SlimDetours/SlimDetours.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* KNSoft SlimDetours (https://github.com/KNSoft/SlimDetours) Core Functionality
* Copyright (c) KNSoft.org (https://github.com/KNSoft). All rights reserved.
* Licensed under the MPL-2.0 license.
*/

#include "SlimDetours.inl"

static BOOL g_Initialized = detour_init();

BOOL detour_init()
{
detour_memory_init();

return TRUE;
}
2 changes: 1 addition & 1 deletion Source/SlimDetours/SlimDetours.inl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

EXTERN_C_START

VOID detour_init();
BOOL detour_init();

/* Basic structures */

Expand Down
2 changes: 1 addition & 1 deletion Source/SlimDetours/SlimDetours.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ItemGroup>
<ClCompile Include="Instruction.c" />
<ClCompile Include="Memory.c" />
<ClCompile Include="SlimDetours.c" />
<ClCompile Include="SlimDetours.cpp" />
<ClCompile Include="Disasm.c" />
<ClCompile Include="Thread.c" />
<ClCompile Include="Trampoline.c" />
Expand Down
2 changes: 1 addition & 1 deletion Source/SlimDetours/SlimDetours.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Disasm.c" />
<ClCompile Include="SlimDetours.c" />
<ClCompile Include="SlimDetours.cpp" />
<ClCompile Include="Memory.c" />
<ClCompile Include="Instruction.c" />
<ClCompile Include="Trampoline.c" />
Expand Down
4 changes: 0 additions & 4 deletions Source/SlimDetours/Transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ NTSTATUS NTAPI SlimDetoursTransactionBegin()
return STATUS_TRANSACTIONAL_CONFLICT;
}

detour_init();

// Make sure the trampoline pages are writable.
Status = detour_writable_trampoline_regions();
if (!NT_SUCCESS(Status))
Expand Down Expand Up @@ -638,8 +636,6 @@ NTSTATUS NTAPI SlimDetoursDelayAttach(
PVOID DllBase;
PDETOUR_DELAY_ATTACH NewNode;

detour_init();

/* Check if Dll is already loaded */
RtlInitUnicodeStringEx(&DllNameString, DllName);
Status = LdrGetDllHandle(NULL, NULL, &DllNameString, &DllBase);
Expand Down

0 comments on commit d7fb083

Please sign in to comment.