Skip to content

Hooking works for Windows 10 users, but not for Windows 7 #85

@shavitush

Description

@shavitush

Code:

bool redirect(bool enable, void **function, void *redirection)
{
	if(DetourTransactionBegin() != NO_ERROR)
	{
		return false;
	}

	if(DetourUpdateThread(GetCurrentThread()) != NO_ERROR)
	{
		return false;
	}

	if((enable? DetourAttach:DetourDetach)(function, redirection) != NO_ERROR)
	{
		return false;
	}

	if(DetourTransactionCommit() == NO_ERROR)
	{
		return true;
	}

	DetourTransactionAbort();

	return false;
}

typedef int(__stdcall *IsCorrectItem_t)(int);
IsCorrectItem_t g_real_IsCorrectItem = reinterpret_cast<IsCorrectItem_t>(0x005D4A2B);

int __stdcall hooked_IsCorrectItem(int nItemID)
{
	return 0;
}

// inside my function
detours::redirect(true, reinterpret_cast<void **>(&g_real_IsCashItem), hooked_IsCorrectItem);

This seems to be perfectly fine on Windows 10, but on Windows 7 it simply doesn't work. I installed the static Detours library through vcpkg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions