initial commit

This commit is contained in:
nexusverypro
2026-07-03 02:00:27 +01:00
parent 85fa958433
commit 3192afe07d
18 changed files with 1592 additions and 0 deletions

56
tests/test_stability.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include <cassert>
#include <vector>
#include "radhook/radhook.h"
static int fn() { return 42; }
static int detour() { return 1337; }
int main() {
RadHookHandle handles[200];
size_t count = 0;
// create many hooks
for (int i = 0; i < 200; i++) {
RadHookHandle h = nullptr;
auto r = RadHookCreate(
(void*)fn,
(void*)detour,
&h
);
assert(r == RadHookResult::Success);
assert(h != nullptr);
handles[count++] = h;
}
// enumerate
RadHookHandle listed[200];
size_t listedCount = RadHookEnumerate(listed, 200);
assert(listedCount == 200);
// every created handle must still be valid
for (size_t i = 0; i < count; i++) {
assert(RadHookIsValid(handles[i]));
}
// destroy half of them
for (size_t i = 0; i < count; i += 2) {
RadHookDestroy(handles[i]);
}
// validate
for (size_t i = 0; i < count; i++) {
if (i % 2 == 0) {
assert(!RadHookIsValid(handles[i]));
} else {
assert(RadHookIsValid(handles[i]));
}
}
// final enumeration must not return destroyed hooks
size_t finalCount = RadHookEnumerate(listed, 200);
assert(finalCount == 100);
return 0;
}