Skip to content

Commit

Permalink
[SLIMDETOURS] Code improvements, no functional changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RatinCN committed Aug 9, 2024
1 parent 0939099 commit b68c239
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Source/Demo/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Hooked_EqualRect(
BOOL Ret;

InterlockedIncrement(&g_lEqualRectCount);
UnitTest_FormatMessage("Hooked EqualRect enter: lprc1 = (%d, %d, %d, %d), lprc2 = (%d, %d, %d, %d)\n",
UnitTest_FormatMessage("Hooked EqualRect enter: lprc1 = (%ld, %ld, %ld, %ld), lprc2 = (%ld, %ld, %ld, %ld)\n",
lprc1->top,
lprc1->right,
lprc1->bottom,
Expand Down
4 changes: 2 additions & 2 deletions Source/SlimDetours/SlimDetours.inl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

/* Use ReactOS NDK with addendum on ReactOS */

#include "SlimDetours.NDK.Addendum.inl"

#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
Expand All @@ -25,6 +23,8 @@

#include <suppress.h>

#include "SlimDetours.NDK.Addendum.inl"

#endif

#include "SlimDetours.h"
Expand Down
18 changes: 9 additions & 9 deletions Source/SlimDetours/Transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ struct _DETOUR_DELAY_ATTACH
PVOID Context;
};

#endif /* (NTDDI_VERSION >= NTDDI_WIN6) */

static HANDLE s_nPendingThreadId = 0; // Thread owning pending transaction.
static PHANDLE s_phSuspendedThreads = NULL;
static ULONG s_ulSuspendedThreadCount = 0;
static PDETOUR_OPERATION s_pPendingOperations = NULL;

#if (NTDDI_VERSION >= NTDDI_WIN6)

static const ANSI_STRING g_asLdrRegisterDllNotification = RTL_CONSTANT_STRING("LdrRegisterDllNotification");
static FN_LdrRegisterDllNotification* g_pfnLdrRegisterDllNotification = NULL;
static NTSTATUS g_lDelayAttachStatus = STATUS_UNSUCCESSFUL;
Expand All @@ -55,6 +46,11 @@ static PDETOUR_DELAY_ATTACH g_DelayedAttaches = NULL;

#endif /* (NTDDI_VERSION >= NTDDI_WIN6) */

static HANDLE s_nPendingThreadId = 0; // Thread owning pending transaction.
static PHANDLE s_phSuspendedThreads = NULL;
static ULONG s_ulSuspendedThreadCount = 0;
static PDETOUR_OPERATION s_pPendingOperations = NULL;

HRESULT
NTAPI
SlimDetoursTransactionBegin(VOID)
Expand Down Expand Up @@ -696,9 +692,13 @@ SlimDetoursDelayAttach(
PDETOUR_DELAY_ATTACH NewNode;

/* Don't need try/except */
#ifdef _MSC_VER
#pragma warning(disable: __WARNING_PROBE_NO_TRY)
#endif
Status = RtlRunOnceExecuteOnce(&g_stInitDelayAttach, detour_init_delay_attach, NULL, NULL);
#ifdef _MSC_VER
#pragma warning(default: __WARNING_PROBE_NO_TRY)
#endif
if (!NT_SUCCESS(Status))
{
return HRESULT_FROM_NT(Status);
Expand Down

0 comments on commit b68c239

Please sign in to comment.