Skip to content

kirchesz/kiero2

Repository files navigation

kiero v2

A lightweight C++ library that hooks locates graphics API methods at runtime.


Important

Breaking Changes (compared to v1)

You bring your own hooking library. kiero just finds the addresses.

Check MIGRATION_GUIDE.md for more details.

Official Supported APIs

  • DirectX 9 (kiero_d3d9.hpp)
  • DirectX 10 (kiero_d3d10.hpp)
  • DirectX 11 (kiero_d3d11.hpp)
  • DirectX 12 (kiero_d3d12.hpp)
  • OpenGL (kiero_opengl.hpp)
    • Windows
    • Linux
    • MacOS
  • Vulkan (kiero_vulkan.hpp)
    • Windows
    • Linux
    • MacOS

Requirements

  • C++17
  • Windows SDK (for DirectX backends)
  • DirectX SDK (for DirectX backends)
  • Vulkan SDK (for Vulkan backends)

Quick start

#include "kiero.hpp"
#include "kiero_d3d9.hpp" // order is important!
                          // kiero.hpp must be included before any backend header
                          // also order changes implementation indices
                          // for example if you include kiero_d3d11.hpp before
                          // kiero_d3d9.hpp, then kiero::Implementation_D3D9
                          // will be 2 instead of 1

kiero::D3D9Output d3d9;
auto err = kiero::locate<kiero::Implementation_D3D9>(
  nullptr, &d3d9
);
if (err != kiero::Error_Nil) {
  // handle error
}

// d3d9.device_methods[42] is the address of
// IDirect3DDevice9::EndScene — hook it however you like

How it works

Each backend do some magic inside (check each backend cpp file for details), and results stores in a typed output structs. The temporary resources are released before locate returns.

The single entry point is a function template:

template<int Impl>
kiero::Error kiero::locate(void* in, void* out);

Each backend provides a full specialization. Include only the headers you need — unused backends add zero overhead.

Error handling

locate returns kiero::Error. Shared codes:

Code Meaning
Error_Nil Success
Error_ModuleNotFound Required DLL not loaded
Error_MethodNotFound Export not found in DLL

Each backend defines additional codes. Check the corresponding header for the full list.

Adding a new backend

  1. Create kiero_myapi.hpp:

    • Define Implementation_MyAPI = KIERO_IMPL_FREE_SLOT
    • Define backend-specific errors from Error_BaseIndex
    • Define your MyAPIOutput struct
    • #undef and #define KIERO_IMPL_CURR_SLOT
  2. Create kiero_myapi.cpp:

    • Include kiero.hpp, your header, kiero_intern.hpp
    • Provide template<> kiero::locate<...>(...)

License

kiero v2 is licensed under the MIT License. See LICENSE for details.

About

A lightweight C++ library that locates graphics API methods at runtime.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages