Files
WoW-Hybrid-gateway/native/nohelper/wire_public_addon_v1.private.h
praxisandClaude Fable 5.2 8e02dccb86 In-client stack: transport, session lifecycle and engine bridge
175 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

52 lines
2.0 KiB
C

#ifndef GW_WIRE_PUBLIC_ADDON_V1_PRIVATE_H
#define GW_WIRE_PUBLIC_ADDON_V1_PRIVATE_H
#include <windows.h>
#include <stdint.h>
#include <string.h>
/* Source file(addons,10000) admits 0..9999 public bytes. This row is owned by
* the Windows Wire module and consumed once by its genuine account worker. */
struct GwWirePublicAddonV1 {
uint32_t abi, size;
volatile LONG state; /* 0 empty, -1 publishing, 1 published, -2 consuming, 2 consumed */
uint32_t generation;
uint32_t byte_count;
uint8_t bytes[10000];
};
_Static_assert(sizeof(struct GwWirePublicAddonV1) == 10020,
"Public addon row ABI changed");
static inline int gw_wire_public_addon_publish(struct GwWirePublicAddonV1 *row,
uint32_t generation,
const uint8_t *bytes,
uint32_t count) {
if (!row || !generation || count >= 10000 || (count && !bytes) ||
row->abi != 1 || row->size != sizeof(*row) || row->generation ||
row->byte_count || InterlockedCompareExchange(&row->state, -1, 0) != 0)
return 0;
if (count) memcpy(row->bytes, bytes, count);
row->byte_count = count;
row->generation = generation;
MemoryBarrier();
InterlockedExchange(&row->state, 1);
return 1;
}
static inline int gw_wire_public_addon_take(struct GwWirePublicAddonV1 *row,
uint32_t generation,
uint8_t bytes[10000],
uint32_t *count) {
if (!row || !bytes || !count || !generation || row->abi != 1 ||
row->size != sizeof(*row) || row->generation != generation ||
row->byte_count >= 10000 ||
InterlockedCompareExchange(&row->state, -2, 1) != 1)
return 0;
*count = row->byte_count;
if (*count) memcpy(bytes, row->bytes, *count);
InterlockedExchange(&row->state, 2);
return 1;
}
#endif