#pragma once
#include <Windows.h>

namespace my
{
// hook通用函数，置空目标函数逻辑
void detour_func_null();


class EZDetour
{
public:
    EZDetour() : addr_(0) {}
    ~EZDetour()
    {
        this->detach(addr_, pDetourFunc_);
    }

public:
    //DWORD     GetAddr() { return addr_; }
    LONG WINAPI Attach(_Inout_ PVOID &ppPointer, _In_ PVOID pDetour);
    LONG WINAPI Attach(const char* dll_name, const char* fun_name, _In_ PVOID pDetour);
    LONG WINAPI Detach()
    {
        return this->detach(addr_, pDetourFunc_);
    }

private:
    // 不需要主动调用，析构函数自动处理
    LONG WINAPI detach(_Inout_ PVOID &ppPointer, _In_ PVOID pDetour);

public:
    PVOID                       addr_;
private:
    PVOID                       pDetourFunc_;
};
}
