Apply clang-format across the whole tree

Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs,
Allman functions) over every source file so the tree is formatter-clean.
Whitespace only -- no behavior change; full x64 + x86 suites pass.

Also set SortIncludes: false in .clang-format. Windows include order is
load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h /
dinput.h; winsock2.h must precede windows.h), and the default
alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build
break. Leaving order alone keeps the manual, correct grouping.
This commit is contained in:
2026-07-12 11:52:53 +02:00
parent c684a15fb9
commit 30eccf749d
155 changed files with 3333 additions and 6171 deletions

View File

@@ -26,28 +26,19 @@
#include <windows.h>
namespace coop::hook
{
namespace coop::hook {
class DetourGate
{
public:
class DetourGate {
public:
// RAII: marks a detour body as in-flight for as long as it's on the stack.
class Guard
{
public:
explicit Guard(DetourGate& gate) : m_gate(gate)
{
m_gate.m_active.fetch_add(1, std::memory_order_acq_rel);
}
~Guard()
{
m_gate.m_active.fetch_sub(1, std::memory_order_acq_rel);
}
class Guard {
public:
explicit Guard(DetourGate& gate) : m_gate(gate) { m_gate.m_active.fetch_add(1, std::memory_order_acq_rel); }
~Guard() { m_gate.m_active.fetch_sub(1, std::memory_order_acq_rel); }
Guard(const Guard&) = delete;
Guard& operator=(const Guard&) = delete;
private:
private:
DetourGate& m_gate;
};
@@ -64,22 +55,17 @@ public:
// reliably, so checking before the first sleep is not safe.
void drain()
{
for (int spins = 0; spins < 400; ++spins)
{
for (int spins = 0; spins < 400; ++spins) {
Sleep(1);
if (m_active.load(std::memory_order_acquire) == 0)
{
if (m_active.load(std::memory_order_acquire) == 0) {
return;
}
}
}
int active() const
{
return m_active.load(std::memory_order_acquire);
}
int active() const { return m_active.load(std::memory_order_acquire); }
private:
private:
std::atomic<int> m_active{0};
};
@@ -92,8 +78,7 @@ private:
template <class InlineHook>
void disable_for_removal(InlineHook& hook)
{
if (!hook.disable())
{
if (!hook.disable()) {
OutputDebugStringA("coop: SafetyHook InlineHook::disable() failed during removal -- unhook may be unsafe\n");
}
}