Skip to content

Commit

Permalink
Merge pull request #24 from unknownv2/dev-tests
Browse files Browse the repository at this point in the history
refactor: Rename trampoline variables
  • Loading branch information
unknownv2 authored Oct 28, 2018
2 parents 3e27ec4 + 7493101 commit 466a38d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/barrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ LONG detour_set_acl(_In_ HOOK_ACL *pAcl,
{
ASSERT(IsValidPointer(pAcl, sizeof(HOOK_ACL)));

if (dwThreadCount > MAX_ACL_COUNT) {
if (dwThreadCount > MAX_THREAD_COUNT) {
return ERROR_INVALID_PARAMETER;
}

Expand Down
7 changes: 5 additions & 2 deletions src/barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ void detour_sleep(_In_ DWORD milliSeconds);
/////////////////////////////////////////// Trampoline thread barrier definitions
//

// Maximum number of detours that can be created
#define MAX_HOOK_COUNT 1024
#define MAX_ACL_COUNT 128
// Maximum number of entries in the hook ACL
#define MAX_ACE_COUNT 128
// Maximum number of threads supported by a hook ACL
#define MAX_THREAD_COUNT 128

typedef struct _HOOK_ACL_
{
ULONG Count;
BOOL IsExclusive;
ULONG Entries[MAX_ACL_COUNT];
ULONG Entries[MAX_ACE_COUNT];
} HOOK_ACL;

typedef struct _RUNTIME_INFO_
Expand Down
20 changes: 10 additions & 10 deletions src/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,17 +2012,17 @@ LONG WINAPI DetourIsThreadIntercepted(_In_ TRACED_HOOK_HANDLE pHook,
_In_ DWORD dwThreadId,
_Out_ BOOL *pResult)
{
PDETOUR_TRAMPOLINE Handle;
PDETOUR_TRAMPOLINE pTrampoline;

if (!detour_is_valid_handle(pHook, &Handle)) {
if (!detour_is_valid_handle(pHook, &pTrampoline)) {
return ERROR_INVALID_PARAMETER;
}

if (!IsValidPointer(pResult, sizeof(BOOL))) {
return ERROR_INVALID_PARAMETER;
}

*pResult = detour_is_thread_intercepted(&Handle->LocalACL, dwThreadId);
*pResult = detour_is_thread_intercepted(&pTrampoline->LocalACL, dwThreadId);

return NO_ERROR;
}
Expand All @@ -2049,30 +2049,30 @@ LONG WINAPI DetourSetInclusiveACL(_In_ DWORD *pThreadIdList,
LONG WINAPI DetourGetHookBypassAddress(_In_ TRACED_HOOK_HANDLE pHook,
_Outptr_ PVOID **pppOutAddress)
{
PDETOUR_TRAMPOLINE Handle;
PDETOUR_TRAMPOLINE pTrampoline;

if (!detour_is_valid_handle(pHook, &Handle)) {
if (!detour_is_valid_handle(pHook, &pTrampoline)) {
return ERROR_INVALID_HANDLE;
}
if (!IsValidPointer(pppOutAddress, sizeof(PVOID*))) {
return ERROR_INVALID_PARAMETER;
}

*pppOutAddress = reinterpret_cast<PVOID*>(Handle->OldProc);
*pppOutAddress = reinterpret_cast<PVOID*>(pTrampoline->OldProc);

return NO_ERROR;
}

LONG WINAPI DetourSetExclusiveACL(_In_ DWORD *pThreadIdList,
_In_ DWORD dwThreadCount,
_In_ TRACED_HOOK_HANDLE pHandle)
_In_ TRACED_HOOK_HANDLE pHookHandle)
{
PDETOUR_TRAMPOLINE Handle;
PDETOUR_TRAMPOLINE pTrampoline;

if (!detour_is_valid_handle(pHandle, &Handle)) {
if (!detour_is_valid_handle(pHookHandle, &pTrampoline)) {
return ERROR_INVALID_HANDLE;
}
return detour_set_acl(&Handle->LocalACL, TRUE, pThreadIdList, dwThreadCount);
return detour_set_acl(&pTrampoline->LocalACL, TRUE, pThreadIdList, dwThreadCount);
}

LONG WINAPI DetourTransactionCommitEx(_Out_opt_ PVOID **pppFailedPointer)
Expand Down

0 comments on commit 466a38d

Please sign in to comment.