Skip to content

Commit d7c4eb8

Browse files
committed
Minor code improvements, no functional change
1 parent 1920131 commit d7c4eb8

5 files changed

Lines changed: 13 additions & 21 deletions

File tree

Source/Demo/Instruction.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ static FN_INSTRUCTION** g_apfnInstructionFunctions[] = {
4343

4444
TEST_FUNC(Instruction)
4545
{
46-
ULONG i;
4746
HRESULT hr;
4847
FN_INSTRUCTION *pfn1, *pfn2;
4948

50-
for (i = 0; i < ARRAYSIZE(g_apfnInstructionFunctions) && g_apfnInstructionFunctions[i] != NULL; i++)
49+
for (ULONG i = 0; i < ARRAYSIZE(g_apfnInstructionFunctions) && g_apfnInstructionFunctions[i] != NULL; i++)
5150
{
5251
pfn2 = pfn1 = *g_apfnInstructionFunctions[i];
5352
if (pfn1() != (ULONG_PTR)PRESET_RETURN_VALUE)

Source/Demo/TwiceSimpleHook.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ TEST_FUNC(TwiceSimpleHook)
4848
}
4949

5050
g_pfnEqualRect1 = g_pfnEqualRect2 = g_pfnEqualRect;
51-
hr = SlimDetoursInlineHook(TRUE, (PVOID)&g_pfnEqualRect1, Hooked_EqualRect1);
51+
hr = SlimDetoursInlineHook(TRUE, (PVOID*)&g_pfnEqualRect1, Hooked_EqualRect1);
5252
if (FAILED(hr))
5353
{
5454
TEST_SKIP("1st SlimDetoursInlineHook failed with 0x%08lX\n", hr);
5555
return;
5656
}
57-
hr = SlimDetoursInlineHook(TRUE, (PVOID)&g_pfnEqualRect2, Hooked_EqualRect2);
57+
hr = SlimDetoursInlineHook(TRUE, (PVOID*)&g_pfnEqualRect2, Hooked_EqualRect2);
5858
if (FAILED(hr))
5959
{
6060
TEST_SKIP("2nd SlimDetoursInlineHook failed with 0x%08lX\n", hr);
6161
return;
6262
}
6363

64-
g_pfnEqualRect(&rc, &rc);
64+
TEST_OK(g_pfnEqualRect(&rc, &rc) != FALSE);
6565
TEST_OK(g_lEqualRect == 2);
6666

67-
TEST_OK(SUCCEEDED(SlimDetoursInlineHook(FALSE, (PVOID)&g_pfnEqualRect2, Hooked_EqualRect2)));
68-
TEST_OK(SUCCEEDED(SlimDetoursInlineHook(FALSE, (PVOID)&g_pfnEqualRect1, Hooked_EqualRect1)));
67+
TEST_OK(SUCCEEDED(SlimDetoursInlineHook(FALSE, (PVOID*)&g_pfnEqualRect2, Hooked_EqualRect2)));
68+
TEST_OK(SUCCEEDED(SlimDetoursInlineHook(FALSE, (PVOID*)&g_pfnEqualRect1, Hooked_EqualRect1)));
6969
}

Source/SlimDetours/InlineHook.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SlimDetoursInitInlineHooks(
4242

4343
for (i = 0; i < ulCount; i++)
4444
{
45-
if ((UINT_PTR)pHooks[i].pszFuncName > MAXWORD)
45+
if ((ULONG_PTR)pHooks[i].pszFuncName > MAXWORD)
4646
{
4747
Status = RtlInitAnsiStringEx(&FuncName, pHooks[i].pszFuncName);
4848
if (!NT_SUCCESS(Status))
@@ -54,7 +54,7 @@ SlimDetoursInitInlineHooks(
5454
} else
5555
{
5656
pFuncName = NULL;
57-
uOridinal = (ULONG)(UINT_PTR)pHooks[i].pszFuncName;
57+
uOridinal = (ULONG)(ULONG_PTR)pHooks[i].pszFuncName;
5858
}
5959
Status = LdrGetProcedureAddress(hModule, pFuncName, uOridinal, pHooks[i].ppPointer);
6060
if (!NT_SUCCESS(Status))

Source/SlimDetours/Thread.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ detour_thread_suspend(
248248
goto _Suspend_next_thread;
249249

250250
_Fail:
251-
for (UINT i = 0; i < SuspendedCount; ++i)
251+
for (ULONG i = 0; i < SuspendedCount; ++i)
252252
{
253253
NtResumeThread(Buffer[i], NULL);
254254
NtClose(Buffer[i]);
@@ -273,9 +273,7 @@ detour_thread_resume(
273273
_In_reads_(SuspendedHandleCount) _Frees_ptr_ PHANDLE SuspendedHandles,
274274
_In_ ULONG SuspendedHandleCount)
275275
{
276-
ULONG i;
277-
278-
for (i = 0; i < SuspendedHandleCount; i++)
276+
for (ULONG i = 0; i < SuspendedHandleCount; i++)
279277
{
280278
NtResumeThread(SuspendedHandles[i], NULL);
281279
NtClose(SuspendedHandles[i]);
@@ -293,7 +291,6 @@ detour_thread_update(
293291
_In_ PDETOUR_OPERATION PendingOperations)
294292
{
295293
NTSTATUS Status;
296-
PDETOUR_OPERATION o;
297294
CONTEXT cxt;
298295
BOOL bUpdateContext;
299296

@@ -316,7 +313,7 @@ detour_thread_update(
316313
}
317314

318315
bUpdateContext = FALSE;
319-
for (o = PendingOperations; o != NULL && !bUpdateContext; o = o->pNext)
316+
for (PDETOUR_OPERATION o = PendingOperations; o != NULL && !bUpdateContext; o = o->pNext)
320317
{
321318
if (o->fIsRemove)
322319
{

Source/SlimDetours/Trampoline.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,7 @@ detour_align_from_trampoline(
432432
_In_ PDETOUR_TRAMPOLINE pTrampoline,
433433
BYTE obTrampoline)
434434
{
435-
ULONG n;
436-
437-
for (n = 0; n < ARRAYSIZE(pTrampoline->rAlign); n++)
435+
for (ULONG n = 0; n < ARRAYSIZE(pTrampoline->rAlign); n++)
438436
{
439437
if (pTrampoline->rAlign[n].obTrampoline == obTrampoline)
440438
{
@@ -449,9 +447,7 @@ detour_align_from_target(
449447
_In_ PDETOUR_TRAMPOLINE pTrampoline,
450448
BYTE obTarget)
451449
{
452-
ULONG n;
453-
454-
for (n = 0; n < ARRAYSIZE(pTrampoline->rAlign); n++)
450+
for (ULONG n = 0; n < ARRAYSIZE(pTrampoline->rAlign); n++)
455451
{
456452
if (pTrampoline->rAlign[n].obTarget == obTarget)
457453
{

0 commit comments

Comments
 (0)