175 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
42 lines
1.8 KiB
C
42 lines
1.8 KiB
C
#ifndef GW_WIRE_REALM_OWNER_BIND_PRIVATE_H
|
|
#define GW_WIRE_REALM_OWNER_BIND_PRIVATE_H
|
|
|
|
#include <windows.h>
|
|
#include <stdint.h>
|
|
#include "wine_engine_realm.h"
|
|
#include "wine_preopen_hook.private.h"
|
|
/* Direct constructor-seam mode reuses the Wire-owned realm control and its
|
|
* original owner CAS at the authenticated preopen owner/thread generation. */
|
|
static inline int gw_wire_realm_bind_direct_owner(
|
|
struct gw_engine_realm_control *realm,
|
|
const struct GwWirePreOpenHook *pre,
|
|
void *owner, DWORD current_thread,
|
|
uint32_t credential_generation, uint32_t pipe_generation) {
|
|
LONG64 previous;
|
|
if (!realm || !pre || !owner || !current_thread ||
|
|
!credential_generation || credential_generation > 64 ||
|
|
credential_generation != pipe_generation ||
|
|
pre->abi != 1 || pre->size != sizeof(*pre) ||
|
|
InterlockedCompareExchange((volatile LONG *)&pre->ready,1,1) != 1 ||
|
|
pre->reserved || pre->owner != owner ||
|
|
pre->primary_thread != current_thread ||
|
|
realm->abi != 1 || realm->size != sizeof(*realm) ||
|
|
InterlockedCompareExchange((volatile LONG *)&realm->stage,0,0) != 0 ||
|
|
InterlockedCompareExchange((volatile LONG *)&realm->error,0,0) != 0)
|
|
return -1;
|
|
previous = InterlockedCompareExchange64((volatile LONG64 *)&realm->owner,
|
|
(LONG64)(uintptr_t)owner, 0);
|
|
return previous == 0 ? 1 : -2;
|
|
}
|
|
static inline int gw_wire_realm_unbind_direct_owner(
|
|
struct gw_engine_realm_control *realm, void *owner) {
|
|
if (!realm || !owner ||
|
|
InterlockedCompareExchange((volatile LONG *)&realm->stage,0,0) != 0)
|
|
return -1;
|
|
return InterlockedCompareExchange64((volatile LONG64 *)&realm->owner,
|
|
0, (LONG64)(uintptr_t)owner) ==
|
|
(LONG64)(uintptr_t)owner ? 1 : -2;
|
|
}
|
|
|
|
#endif
|