883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
52 lines
4.1 KiB
C++
52 lines
4.1 KiB
C++
#include <cstdint>
|
|
#include <cstddef>
|
|
#include <cstring>
|
|
#include <iostream>
|
|
#include <stdexcept>
|
|
#include <sys/mman.h>
|
|
#include "club_service.hpp"
|
|
using LONG64=int64_t;using DWORD=uint32_t;
|
|
struct MEMORY_BASIC_INFORMATION {void* BaseAddress=nullptr;size_t RegionSize=0;DWORD State=0,Protect=0;};
|
|
constexpr DWORD MEM_COMMIT=0x1000,PAGE_GUARD=0x100,PAGE_NOACCESS=1,PAGE_READWRITE=4,PAGE_WRITECOPY=8,PAGE_EXECUTE_READWRITE=64,PAGE_EXECUTE_WRITECOPY=128;
|
|
static DWORD protection=PAGE_READWRITE;
|
|
static void* GetModuleHandleA(const char*){return reinterpret_cast<void*>(0x140000000ULL);}
|
|
static size_t VirtualQuery(void*,MEMORY_BASIC_INFORMATION* p,size_t n){*p={reinterpret_cast<void*>(0x14574b000ULL),4096,MEM_COMMIT,protection};return n;}
|
|
static unsigned char InterlockedCompareExchange128(volatile LONG64* p,LONG64 high,LONG64 low,LONG64* expected){
|
|
if(p[0]!=expected[0]||p[1]!=expected[1]){expected[0]=p[0];expected[1]=p[1];return 0;}
|
|
p[0]=low;p[1]=high;return 1;
|
|
}
|
|
static uint32_t credentials_generation=7;
|
|
static struct {uint32_t consumed_generation;} gw_wire_auth_credentials_data{7};
|
|
#ifndef GW_SOURCE_ONLY_PROFILE
|
|
#define GW_SOURCE_ONLY_PROFILE 5
|
|
#endif
|
|
#include "wine_club_source_context.inc"
|
|
static void require(bool b,const char* why){if(!b)throw std::runtime_error(why);}
|
|
int main(){try{
|
|
void* memory=mmap(reinterpret_cast<void*>(0x14574b000ULL),4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED_NOREPLACE,-1,0);
|
|
require(memory!=MAP_FAILED,"isolated test slot allocation");auto* slot=reinterpret_cast<volatile LONG64*>(0x14574b3c0ULL);
|
|
auto key=gw_source_account_key("fixture_a",9);
|
|
require(key && key==gw_source_account_key("FIXTURE_A",9) && key!=gw_source_account_key("fixture_b",9),"Source normalization/stable distinct identities");
|
|
require(!gw_source_account_key("",0)&&!gw_source_account_key("bad\x01",4),"invalid names must not create identity");
|
|
club_source_prepare("fixture_a",9,6);require(club_source_publish()==-1 && !slot[0]&&!slot[1],"stale epoch may not publish");
|
|
club_source_prepare("fixture_a",9,7);gw_wire_auth_credentials_data.consumed_generation=6;require(club_source_publish()==-1,"consumed account generation guard");gw_wire_auth_credentials_data.consumed_generation=7;
|
|
protection=PAGE_NOACCESS;require(club_source_publish()==-2,"must not deprotect original storage");protection=PAGE_READWRITE;
|
|
slot[0]=123;slot[1]=LONG64(GW_SOURCE_INTERNAL_ACCOUNT_HIGH);require(club_source_publish()==-3&&slot[0]==123,"foreign identity refusal");slot[0]=0;slot[1]=0;
|
|
require(club_source_publish()==0&&slot[0]==key&&uint64_t(slot[1])==GW_SOURCE_INTERNAL_ACCOUNT_HIGH,"typed private Source context");
|
|
require(club_source_publish()==0,"same authenticated generation is idempotent");
|
|
club_source_clear();require(!slot[0]&&!slot[1]&&!club_source_key&&!club_source_generation,"retirement removes only owned context");
|
|
club_source_prepare("fixture_a",9,7);require(club_source_publish()==0,"next publish");slot[0]=456;club_source_clear();require(slot[0]==456&&uint64_t(slot[1])==GW_SOURCE_INTERNAL_ACCOUNT_HIGH,"retirement preserves changed foreign context");
|
|
gateway::GuildInfo info;info.id=21;info.name="OwnedGuild";
|
|
gateway::GuildRoster roster;roster.source_rank_rights={0xffffffff,0xc,0,0,0};
|
|
gateway::GuildRosterMember me;me.guid=4509;me.name="FixtureOne";me.rank=0;me.online=1;
|
|
auto peer=me;peer.guid=4514;peer.name="FixtureTwo";peer.rank=4;roster.members={me,peer};
|
|
NativeClubService clubs;gateway::Bytes date;gateway::cstring(date,info.name);
|
|
for(auto n:{1u,1u,2026u,2u,2u})gateway::le(date,n,4);
|
|
clubs.creation=date;
|
|
clubs.refresh(21,4509,70,info,roster,key);
|
|
require(clubs.snapshot && clubs.snapshot->account(4509)==key && clubs.snapshot->account(4514)==0,"only authenticated self receives private identity");
|
|
auto self_fields=gateway::club_wire::fields(clubs.snapshot->id(4509));
|
|
require(gateway::club_wire::number(self_fields,3)==key,"membership self identity matches typed native context");
|
|
munmap(memory,4096);std::cout<<"PASS Source normalization, generation binding, natural-page hold, foreign identity refusal and owned retirement\n";
|
|
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}
|