Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I found a strange problem! #69

Open
zhaokaixs opened this issue Jun 17, 2020 · 0 comments
Open

I found a strange problem! #69

zhaokaixs opened this issue Jun 17, 2020 · 0 comments

Comments

@zhaokaixs
Copy link

zhaokaixs commented Jun 17, 2020

Xenos_2.3.2.7z =>Xenos64.exe size (1367KB)
i build source => Xenos64.exe size (1309KB)
image

I use xenos64.exe compiled by myself to inject DLL, and hook VTable does not work,
But using Release xenos64.exe its's works well.
this is my hook dll code
image
//-----------------------------------------------------------------------------
#include <windows.h>
#include <Audioclient.h>
#include <mmdeviceapi.h>
#include "detours.h"
#pragma comment(lib,"detours.lib")
typedef HRESULT(STDMETHODCALLTYPE *GetDefaultAudioEndpoint_t)( IMMDeviceEnumerator * This,In EDataFlow dataFlow,In ERole role,Out IMMDevice **ppEndpoint);
HRESULT STDMETHODCALLTYPE Hook_GetDefaultAudioEndpoint(IMMDeviceEnumerator * This,In EDataFlow dataFlow, In ERole role,Out IMMDevice **ppEndpoint)
{
HRESULT hr = S_OK;
MessageBox(0, L"Hook_GetDefaultAudioEndpoint", 0, 0);
return hr;
}

void hook_audio()
{
MessageBox(0, L"hook_audio", 0, 0);
CoInitialize(NULL);
IMMDeviceCollection* devs = NULL;
IMMDeviceEnumerator deviceEnumerator = NULL;
IMMDevice device = NULL;
HRESULT hr;
uintptr_t vtable;
void
old_GetDefaultAudioEndpoint = NULL;
bool ret = false;
hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void
)&deviceEnumerator);
hr = deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
vtable = (uintptr_t*)deviceEnumerator;
old_GetDefaultAudioEndpoint = (void*)vtable[4];
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&old_GetDefaultAudioEndpoint, &Hook_GetDefaultAudioEndpoint);
auto error =DetourTransactionCommit();
}

BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
if(DLL_PROCESS_ATTACH == ul_reason_for_call)
hook_audio();
return TRUE;
}
//------------------------------------------------------------------------

Use Release Xenos64.exe
image
Use My Xenos64.exe
image
it's not jump my hook function

Who can tell me the difference
OS: win10 19041.324/17134.1488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant