コード例 #1
0
ファイル: module.cpp プロジェクト: whb224117/hadesmem
void DetourNtdllForModule(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetNtdllModule();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"ntdll", base, module))
  {
    DetourFunc(process,
               base,
               "NtMapViewOfSection",
               GetNtMapViewOfSectionDetour(),
               NtMapViewOfSectionDetour);
    DetourFunc(process,
               base,
               "NtUnmapViewOfSection",
               GetNtUnmapViewOfSectionDetour(),
               NtUnmapViewOfSectionDetour);
    DetourFunc(
      process, base, "LdrLoadDll", GetLdrLoadDllDetour(), LdrLoadDllDetour);
    DetourFunc(process,
               base,
               "LdrUnloadDll",
               GetLdrUnloadDllDetour(),
               LdrUnloadDllDetour);
  }
}
コード例 #2
0
ファイル: d3d10.cpp プロジェクト: geota/hadesmem
void DetourD3D101(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetD3D101Module();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"D3D10_1", base, module))
  {
    DetourFunc(process,
               base,
               "D3D10CreateDevice1",
               GetD3D10CreateDevice1Detour(),
               D3D10CreateDevice1Detour);
    DetourFunc(process,
               base,
               "D3D10CreateDeviceAndSwapChain1",
               GetD3D10CreateDeviceAndSwapChain1Detour(),
               D3D10CreateDeviceAndSwapChain1Detour);
  }
}
コード例 #3
0
ファイル: dxgi.cpp プロジェクト: GliderPro/hadesmem
void DetourDXGI(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetDXGIModule();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"DXGI", base, module))
  {
    auto& render_helper = GetRenderHelperInterface();
    auto const render_offsets = render_helper.GetRenderOffsets();
    auto const dxgi_offsets = &render_offsets->dxgi_offsets_;
    auto const offset_base = reinterpret_cast<std::uint8_t*>(base);

    if (!dxgi_offsets->present_)
    {
      HADESMEM_DETAIL_TRACE_FORMAT_A(
        "WARNING! No DXGI offsets. Skipping hooks.");
      return;
    }

    auto const present_fn = offset_base + dxgi_offsets->present_;
    DetourFunc(process,
               "IDXGISwapChain::Present",
               GetIDXGISwapChainPresentDetour(),
               reinterpret_cast<IDXGISwapChain_Present_Fn>(present_fn),
               IDXGISwapChain_Present_Detour);

    auto const resize_buffers_fn = offset_base + dxgi_offsets->resize_buffers_;
    DetourFunc(
      process,
      "IDXGISwapChain::ResizeBuffers",
      GetIDXGISwapChainResizeBuffersDetour(),
      reinterpret_cast<IDXGISwapChain_ResizeBuffers_Fn>(resize_buffers_fn),
      IDXGISwapChain_ResizeBuffers_Detour);

    auto const present_1_fn = offset_base + dxgi_offsets->present_1_;
    DetourFunc(process,
               "IDXGISwapChain1::Present1",
               GetIDXGISwapChain1Present1Detour(),
               reinterpret_cast<IDXGISwapChain1_Present1_Fn>(present_1_fn),
               IDXGISwapChain1_Present1_Detour);
  }
}
コード例 #4
0
ファイル: window.cpp プロジェクト: GliderPro/hadesmem
void DetourUser32ForWindow(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetUser32Module();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"user32", base, module))
  {
    DetourFunc(process,
               base,
               "GetForegroundWindow",
               GetGetForegroundWindowDetour(),
               GetForegroundWindowDetour);
  }
}
コード例 #5
0
ファイル: exception.cpp プロジェクト: GliderPro/hadesmem
void DetourKernelBaseForException(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetKernelBaseModule();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"kernelbase", base, module))
  {
    DetourFunc(process,
               base,
               "SetUnhandledExceptionFilter",
               GetSetUnhandledExceptionFilterDetour(),
               SetUnhandledExceptionFilterDetour);
  }
}
コード例 #6
0
ファイル: exception.cpp プロジェクト: GliderPro/hadesmem
void DetourNtdllForException(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetNtdllModule();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"ntdll", base, module))
  {
    DetourFunc(process,
               base,
               "RtlAddVectoredExceptionHandler",
               GetRtlAddVectoredExceptionHandlerDetour(),
               RtlAddVectoredExceptionHandlerDetour);
  }
}
コード例 #7
0
ファイル: opengl.cpp プロジェクト: GliderPro/hadesmem
void DetourOpenGL32(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetOpenGL32Module();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"OpenGL32", base, module))
  {
    DetourFunc(process,
               base,
               "wglSwapBuffers",
               GetWglSwapBuffersDetour(),
               WglSwapBuffersDetour);
  }
}
コード例 #8
0
ファイル: raw_input.cpp プロジェクト: GliderPro/hadesmem
void DetourUser32ForRawInput(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetUser32Module();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"user32", base, module))
  {
    DetourFunc(process,
               base,
               "GetRawInputBuffer",
               GetGetRawInputBufferDetour(),
               GetRawInputBufferDetour);
    DetourFunc(process,
               base,
               "GetRawInputData",
               GetGetRawInputDataDetour(),
               GetRawInputDataDetour);
    DetourFunc(process,
               base,
               "RegisterRawInputDevices",
               GetRegisterRawInputDevicesDetour(),
               RegisterRawInputDevicesDetour);
  }
}
コード例 #9
0
ファイル: d3d9.cpp プロジェクト: capturePointer/hadesmem
void DetourD3D9(HMODULE base)
{
  auto const& process = GetThisProcess();
  auto& module = GetD3D9Module();
  auto& helper = GetHelperInterface();
  if (helper.CommonDetourModule(process, L"D3D9", base, module))
  {
    auto& render_helper = GetRenderHelperInterface();
    auto const render_offsets = render_helper.GetRenderOffsets();
    auto const d3d9_offsets = &render_offsets->d3d9_offsets_;
    auto const offset_base = reinterpret_cast<std::uint8_t*>(base);

    if (!d3d9_offsets->add_ref_)
    {
      HADESMEM_DETAIL_TRACE_FORMAT_A(
        "WARNING! No D3D9 offsets. Skipping hooks.");
      return;
    }

    auto const add_ref_fn = offset_base + d3d9_offsets->add_ref_;
    DetourFunc(process,
               "IDirect3DDevice9::AddRef",
               GetIDirect3DDevice9AddRefDetour(),
               reinterpret_cast<IDirect3DDevice9_AddRef_Fn>(add_ref_fn),
               IDirect3DDevice9_AddRef_Detour);

    auto const release_fn = offset_base + d3d9_offsets->release_;
    DetourFunc(process,
               "IDirect3DDevice9::Release",
               GetIDirect3DDevice9ReleaseDetour(),
               reinterpret_cast<IDirect3DDevice9_Release_Fn>(release_fn),
               IDirect3DDevice9_Release_Detour);

    auto const present_fn = offset_base + d3d9_offsets->present_;
    DetourFunc(process,
               "IDirect3DDevice9::Present",
               GetIDirect3DDevice9PresentDetour(),
               reinterpret_cast<IDirect3DDevice9_Present_Fn>(present_fn),
               IDirect3DDevice9_Present_Detour);

    auto const reset_fn = offset_base + d3d9_offsets->reset_;
    DetourFunc(process,
               "IDirect3DDevice9::Reset",
               GetIDirect3DDevice9ResetDetour(),
               reinterpret_cast<IDirect3DDevice9_Reset_Fn>(reset_fn),
               IDirect3DDevice9_Reset_Detour);

    auto const end_scene_fn = offset_base + d3d9_offsets->end_scene_;
    DetourFunc(process,
               "IDirect3DDevice9::EndScene",
               GetIDirect3DDevice9EndSceneDetour(),
               reinterpret_cast<IDirect3DDevice9_EndScene_Fn>(end_scene_fn),
               IDirect3DDevice9_EndScene_Detour);

    auto const present_ex_fn = offset_base + d3d9_offsets->present_ex_;
    DetourFunc(process,
               "IDirect3DDevice9Ex::PresentEx",
               GetIDirect3DDevice9ExPresentExDetour(),
               reinterpret_cast<IDirect3DDevice9Ex_PresentEx_Fn>(present_ex_fn),
               IDirect3DDevice9Ex_PresentEx_Detour);

    auto const reset_ex_fn = offset_base + d3d9_offsets->reset_ex_;
    DetourFunc(process,
               "IDirect3DDevice9Ex::ResetEx",
               GetIDirect3DDevice9ExResetExDetour(),
               reinterpret_cast<IDirect3DDevice9Ex_ResetEx_Fn>(reset_ex_fn),
               IDirect3DDevice9Ex_ResetEx_Detour);

    auto const swap_chain_present_fn =
      offset_base + d3d9_offsets->swap_chain_present_;
    DetourFunc(
      process,
      "IDirect3DSwapChain9::Present",
      GetIDirect3DSwapChain9PresentDetour(),
      reinterpret_cast<IDirect3DSwapChain9_Present_Fn>(swap_chain_present_fn),
      IDirect3DSwapChain9_Present_Detour);
  }
}
コード例 #10
0
ファイル: dllmain.cpp プロジェクト: niuxianghui/addressHook
BOOL Hook(DWORD Address, DWORD* RE_Addr) {
	reCall = (DWORD)DetourFunc((BYTE*)Address, (BYTE*)_Skin, 5, DETOUR_TYPE_JMP, &memoryinfo);
	return TRUE;
}