|
| 1 | +#pragma once |
| 2 | + |
| 3 | +// lvt plugin interface — C ABI for runtime-loaded framework provider plugins. |
| 4 | +// Plugins are DLLs placed in %USERPROFILE%/.lvt/plugins/ and discovered at startup. |
| 5 | +// This header is the ONLY dependency between lvt core and any plugin. |
| 6 | + |
| 7 | +#include <stdint.h> |
| 8 | +#include <Windows.h> |
| 9 | + |
| 10 | +#ifdef __cplusplus |
| 11 | +extern "C" { |
| 12 | +#endif |
| 13 | + |
| 14 | +#define LVT_PLUGIN_API_VERSION 1 |
| 15 | + |
| 16 | +// ---------- Plugin metadata ---------- |
| 17 | + |
| 18 | +struct LvtPluginInfo { |
| 19 | + uint32_t struct_size; // sizeof(LvtPluginInfo), for versioning |
| 20 | + uint32_t api_version; // must be LVT_PLUGIN_API_VERSION |
| 21 | + const char* name; // short identifier, e.g. "myframework" |
| 22 | + const char* description; // human-readable, e.g. "Custom framework support" |
| 23 | +}; |
| 24 | + |
| 25 | +// ---------- Framework detection ---------- |
| 26 | + |
| 27 | +struct LvtFrameworkDetection { |
| 28 | + uint32_t struct_size; |
| 29 | + const char* name; // framework name reported by plugin |
| 30 | + const char* version; // version string or NULL |
| 31 | +}; |
| 32 | + |
| 33 | +// ---------- Element data (C ABI mirror of lvt::Element) ---------- |
| 34 | + |
| 35 | +struct LvtBounds { |
| 36 | + int32_t x, y, width, height; |
| 37 | +}; |
| 38 | + |
| 39 | +struct LvtProperty { |
| 40 | + const char* key; |
| 41 | + const char* value; |
| 42 | +}; |
| 43 | + |
| 44 | +struct LvtElementData { |
| 45 | + uint32_t struct_size; |
| 46 | + const char* type; |
| 47 | + const char* framework; |
| 48 | + const char* class_name; |
| 49 | + const char* text; |
| 50 | + LvtBounds bounds; |
| 51 | + const LvtProperty* properties; |
| 52 | + uint32_t property_count; |
| 53 | + struct LvtElementData* children; |
| 54 | + uint32_t child_count; |
| 55 | + uintptr_t native_handle; // e.g. HWND |
| 56 | +}; |
| 57 | + |
| 58 | +// ---------- Plugin entry points ---------- |
| 59 | +// Plugins must export these functions by name. |
| 60 | + |
| 61 | +// Returns static plugin metadata. Called once at load time. |
| 62 | +typedef LvtPluginInfo* (*LvtPluginInfoFn)(void); |
| 63 | + |
| 64 | +// Detect if this plugin's framework is present in the target process. |
| 65 | +// Returns nonzero if detected, fills `out` with framework info. |
| 66 | +// `out` is caller-allocated. Plugin should set name and version fields. |
| 67 | +typedef int (*LvtDetectFrameworkFn)(DWORD pid, HWND hwnd, LvtFrameworkDetection* out); |
| 68 | + |
| 69 | +// Enrich the element tree with this plugin's framework data. |
| 70 | +// `json_out` receives a malloc'd JSON string (caller frees with lvt_plugin_free). |
| 71 | +// The JSON follows the same schema as the XAML TAP DLL output: |
| 72 | +// [{"type":"...", "name":"...", "children":[...], "width":..., "height":..., "offsetX":..., "offsetY":...}] |
| 73 | +// `hwnd_filter` is the HWND of a specific host window to scope enrichment to, |
| 74 | +// or NULL for all. |
| 75 | +// Returns nonzero on success. |
| 76 | +typedef int (*LvtEnrichTreeFn)(HWND hwnd, DWORD pid, const char* element_class_filter, char** json_out); |
| 77 | + |
| 78 | +// Free memory allocated by the plugin (e.g. json_out from LvtEnrichTreeFn). |
| 79 | +typedef void (*LvtPluginFreeFn)(void* ptr); |
| 80 | + |
| 81 | +// Exported function names (for GetProcAddress) |
| 82 | +#define LVT_PLUGIN_INFO_FUNC "lvt_plugin_info" |
| 83 | +#define LVT_PLUGIN_DETECT_FUNC "lvt_detect_framework" |
| 84 | +#define LVT_PLUGIN_ENRICH_FUNC "lvt_enrich_tree" |
| 85 | +#define LVT_PLUGIN_FREE_FUNC "lvt_plugin_free" |
| 86 | + |
| 87 | +#ifdef __cplusplus |
| 88 | +} |
| 89 | +#endif |
0 commit comments