Files
WoW-Hybrid-gateway/ops/windows_ui_metadata.c
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

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

31 lines
2.4 KiB
C

/* Ordinary read-only Win32 window metadata. Never reads titles, field values,
* WM_GETTEXT, passwords, process memory, Lua state or networking information. */
#include <windows.h>
static char output[768];static unsigned used;
static void text(const char *s){while(*s && used+1<sizeof(output))output[used++]=*s++;}
static void number(unsigned long long n){char digits[24];unsigned count=0;do{digits[count++]=(char)('0'+n%10);n/=10;}while(n);while(count)output[used++]=digits[--count];}
static int equal(const char *a,const char *b){while(*a && *b){char x=*a++,y=*b++;if(x>='A' && x<='Z')x=(char)(x-'A'+'a');if(y>='A' && y<='Z')y=(char)(y-'A'+'a');if(x!=y)return 0;}return !*a && !*b;}
static int is_client(DWORD pid){
HANDLE process=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,FALSE,pid);char path[1024];DWORD size=sizeof(path);char *name=path,*p;int result=0;
if(!process)return 0;
if(QueryFullProcessImageNameA(process,0,path,&size)){
for(p=path;*p;++p)if(*p=='\\' || *p=='/')name=p+1;
result=equal(name,"WowB.exe");
}
CloseHandle(process);return result;
}
static void emit(HWND window,int child){
char cls[128];RECT rect;DWORD pid=0,written;int edit;
if(!GetClassNameA(window,cls,sizeof(cls)) || !GetWindowRect(window,&rect))return;
GetWindowThreadProcessId(window,&pid);edit=equal(cls,"Edit") || equal(cls,"RichEdit20A") || equal(cls,"RichEdit20W");
used=0;text("{\"child\":");text(child?"true":"false");text(",\"class\":\"");
for(unsigned i=0;cls[i];++i){unsigned char c=(unsigned char)cls[i];if(c>=32 && c<127 && c!='"' && c!='\\')output[used++]=(char)c;}
text("\",\"id\":");number((ULONG_PTR)window);text(",\"native_pid\":");number(pid);
text(",\"width\":");number((unsigned)(rect.right-rect.left));text(",\"height\":");number((unsigned)(rect.bottom-rect.top));
text(",\"standard_edit\":");text(edit?"true":"false");text(",\"password_style\":");text(edit && (GetWindowLongPtrA(window,GWL_STYLE)&ES_PASSWORD)?"true":"false");text("}\n");
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),output,used,&written,0);
}
static BOOL CALLBACK child(HWND window,LPARAM unused){(void)unused;emit(window,1);return TRUE;}
static BOOL CALLBACK top(HWND window,LPARAM unused){DWORD pid=0;(void)unused;GetWindowThreadProcessId(window,&pid);if(is_client(pid)){emit(window,0);EnumChildWindows(window,child,0);}return TRUE;}
void WINAPI ui_metadata_start(void){EnumWindows(top,0);ExitProcess(0);}