1

リモート デスクトップの IP アドレスを取得しようとしています。そのため、API WTSQuerysessionInformation をフックしています。しかし、この関数はフックしていません。どなたか助けてください。私のコードは次のとおりです。パラメータの不一致を確認し、私が持っているものを提案してください行う。

#include "stdafx.h"
#include "MinHook.h"
#include <Wtsapi32.h>

#if defined _M_X64
#pragma comment(lib, "libMinHook.x64.lib")
#elif defined _M_IX86
#pragma comment(lib, "libMinHook.x86.lib")
#endif

typedef BOOL(WINAPI *WTSQuerySessionInformationWNext)(IN HANDLE hServer,
             IN DWORD SessionId, IN WTS_INFO_CLASS WTSInfoClass, __deref_out_bcount(*pBytesReturned) LPWSTR * ppBuffer, __out DWORD * pBytesReturned);

WTSQuerySessionInformationWNext Real_WTSQuerySessionInformationW = NULL;

BOOL WINAPI WTSQuerySessionInformationWCallback(IN HANDLE hServer,IN DWORD SessionId,  IN WTS_INFO_CLASS WTSInfoClass, __deref_out_bcount(*pBytesReturned) LPWSTR * ppBuffer, __out DWORD * pBytesReturned)
{

BOOL ret =  Real_WTSQuerySessionInformationW(hServer, SessionId, WTSInfoClass,  ppBuffer, pBytesReturned);
if(ret != NULL)
{
    MessageBoxA(NULL, "WTSQuerySessionInformationW Called", "Info", MB_OK);
    return ret;
}
else
{
    MessageBoxA(NULL, "WTSQuerySessionInformationW fails", "Info", MB_OK);
    return ret;
}
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
                        if (MH_Initialize() != MH_OK)
                        {
                            MessageBoxW(NULL, L"Failed Initialize", L"Info!", MB_ICONWARNING|MB_OK);    
                        }   
                        if (MH_CreateHook(&WTSQuerySessionInformationW, &WTSQuerySessionInformationWCallback, reinterpret_cast<void**>(&Real_WTSQuerySessionInformationW)) != MH_OK)
                        {
                            MessageBoxW(NULL, L"Failed CreateHook WTSQuerySessionInformationW", L"Info!",MB_ICONWARNING|MB_OK);
                        }
                        if (MH_EnableHook(&WTSQuerySessionInformationW) != MH_OK)
                        {
                            MessageBoxW(NULL, L"Failed EnableHook WTSQuerySessionInformationW", L"Info!",MB_ICONWARNING|MB_OK);
                        }

                        break;
case DLL_PROCESS_DETACH:
                        if (MH_Uninitialize() != MH_OK)
                        {               
                        }
                        if(MH_DisableHook(&ProcessIdToSessionId) != MH_OK)
                        {
                        }
                        break;
                    }
                    return TRUE;
}
4

0 に答える 0