32 lines
1.6 KiB
C
32 lines
1.6 KiB
C
#pragma once
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
/* 70334 LOCAL live proof: global owner RVA 05e7a098; VirtualRealms count
|
|
* +828; current virtual address +898; API realm ID +89c and name +8a0.
|
|
* Only the supplied name's bytes plus NUL are written (no tail clearing).
|
|
* Caller qualifies the registered 70334 Main and writable owner allocation.
|
|
*/
|
|
#define GW_CURRENT_REALM_OWNER_RVA 0x5e7a098u
|
|
#define GW_CURRENT_REALM_NAME_LIMIT 127u
|
|
static inline int gw_current_realm_record(void* image,size_t image_bytes,void* owner,size_t owner_bytes,
|
|
uint32_t build,int auth_queued,uint32_t address,
|
|
const char* name,size_t name_bytes){
|
|
uint64_t current_owner;uint32_t current_address,count,id;size_t length=0;
|
|
unsigned char* p=(unsigned char*)owner;
|
|
if(build!=70334u||!auth_queued||!image||!owner||!address||!(address&0xffffu)||
|
|
image_bytes<GW_CURRENT_REALM_OWNER_RVA+8u||owner_bytes<0x8a1u||!name||!name_bytes)return -1;
|
|
while(length<name_bytes&&length<=GW_CURRENT_REALM_NAME_LIMIT&&name[length]){
|
|
if((unsigned char)name[length]<32u)return -1;
|
|
++length;
|
|
}
|
|
if(!length||length==name_bytes||length>GW_CURRENT_REALM_NAME_LIMIT||owner_bytes<0x8a0u+length+1u)return -1;
|
|
memcpy(¤t_owner,(unsigned char*)image+GW_CURRENT_REALM_OWNER_RVA,8);
|
|
memcpy(¤t_address,p+0x898,4);memcpy(&count,p+0x828,4);
|
|
if(current_owner!=(uint64_t)(uintptr_t)owner||current_address!=address||!count)return -1;
|
|
id=address&0xffffu;
|
|
memcpy(p+0x8a0,name,length+1u);memcpy(p+0x89c,&id,4);
|
|
return 0;
|
|
}
|