Skip to content

Curve/lime

Repository files navigation

👋 Introduction

Lime is a cross-platform library that is focused on game modding and tries to provide you with useful features for your journey.

🗒️ Features

  • Detours
    • x86/x86-64
    • Lambda support
    • (Cross-Platform) Calling Convention support (for lambdas!)
  • Instruction
    • Get next / prev instruction
    • Get immediates, displacement, size, mnemonic
    • Calculate absolute target (follow relative instructions...)
  • Memory Pages
    • Allocate pages
      • Anywhere
      • Exactly at specified address
      • In ±2GB range of specified address
    • Read / Write / Restore protection
  • Module
    • Iterate Loaded Modules
    • Iterate Symbols
    • Load Modules
  • Address
    • Read / Write Data
  • Signature Scanner
    • Supports Traditional & IDA Signatures
  • Cross-Platform Entrypoint
  • [MinGW] Proxy-DLL Generation

Note

Lime follows RAII so you won't have to care about manually cleaning anything up (i.e. when allocating a page).

⚙️ Configuration

Static Entrypoint

set(lime_static_entrypoint ON)

Default is: OFF

Use a platform-independent method for the entrypoint implementation.
You do not need to enable this to make use of the cross-platform entrypoint!

VirtualAlloc2

set(lime_no_alloc2 ON)

Default is: OFF

Can be used to disable the usage of VirtualAlloc2.

This should be used for compatibility with wine as it currently does not support the LowestStartingAddress requirement.
Should work since wine 8.11 🎉

📦 Installation

  • Using CPM

    CPMFindPackage(
      NAME           lime
      VERSION        5.0
      GIT_REPOSITORY "https://github.com/Curve/lime"
    )
  • Using FetchContent

    include(FetchContent)
    
    FetchContent_Declare(lime GIT_REPOSITORY "https://github.com/Curve/lime" GIT_TAG v5.0)
    FetchContent_MakeAvailable(lime)
    
    target_link_libraries(<target> cr::lime)

📖 Examples

lime/tests/hook.test.cpp

Lines 46 to 52 in 7de073b

lime::make_hook(test_fn,
[](auto *hook, int param) -> int
{
auto rtn = hook->original()(param + 10);
delete hook;
return rtn;
});

lime/tests/hook.test.cpp

Lines 44 to 52 in 9ee66d3

using hook_t = lime::hook<int(void *, int), lime::convention::c_fastcall>;
hook_t::create(0xDEADBEEF,
[&](auto *hook, void *thiz, int param) -> int
{
auto ret = hook->original()(thiz, param);
delete hook;
return ret;
});

For more examples see tests

🌐 Who's using Lime

Extend the list!