LibVolcano
LibVolcano (or simply, Volcano) is a C library for macOS-related shenanigans. Performing low-level tasks such as reading and writing process memory can get complex quickly and require lots of boilerplate code. The goal of LibVolcano is simple: to provide a clean, consistent, and powerful API on top of numerous macOS system APIs.
#include <Volcano/Log.h>
#include <Volcano/ObjectiveC.h>
// ...
@implementation VCExample
+ (BOOL)alwaysNo {
return NO;
}
@end
void __attribute__((constructor)) init() {
struct VcLogContext *lc = VcLogCreateContext();
VcLog(lc, "Module loaded successfully");
VcObjcReplaceMethod("NSString", "hasPrefix", "VCExample", "alwaysNo");
VcLog(lc, "Replaced NSString/hasPrefix; will always return NO");
}
A simple example showing Objective-C method replacement at runtime.
Disclaimer: This is not a production-ready library. It is the result of my attempts to cut down on repeated code in various projects of mine. There will issues, and I probably don't have time to fix all of them. That being said...
I hope you find this library useful, and if you do, please let me know!
Building
Given that this is a library for macOS-specific mischief, it obviously only compiles on macOS. However, since LibVolcano uses CMake, obtaining a macOS machine should be the hardest part of the build process. To build, simply configure CMake and build:
$ cmake -S . -B build
$ cmake --build build -j8
Conventions
This project follows a handful of conventions, some typical and some unusual:
-
Type aliases via
typedef
are used rather frequently to alias primitive and system types. This may be upsetting to some, but I prefer to see consistently named types in my code, and I wrote this library for myself after all. -
All functions are prefixed with
Vc
and an additional group prefix, for exampleVcObjc
andVcKern
for Objective-C and kernel related functions, respectively. -
Source code is formatted using the LLVM
clang-format
style.
Documentation
Documentation can be built by running doxygen
in the project root.
License
Copyright 2021 Jon Palmisciano. Licensed under the 3-clause BSD license. For more information, see LICENSE.txt.