Implement export forwarders and refactor hooks

Introduce a PAHO_FORWARDER_EXPORTS macro and generate Original_* FARPROC forwarder targets, replace the many hand-written fake exports with assembly forwarding stubs, and simplify exports.cpp to declare and initialize those forwarder pointers. Refactor paho-mqtt3as-proxy hook logic: improve logging, robustly load/save JSON config using std::filesystem and safe parsing, consolidate URL/host patching logic for HTTP/WS/MQTT, and add safer MQTT URI patching and resolution helpers. Update main to populate forwarder addresses at startup and make hook installation more defensive when symbols aren't found. Add docs images, update README (bump tested version and enable images), remove STATE.md, and adjust .gitignore to keep docs included.
This commit is contained in:
√(noham)²
2026-05-09 23:14:02 +02:00
parent 5153c4cad0
commit b9c992e3d7
11 changed files with 581 additions and 421 deletions

View File

@@ -21,8 +21,11 @@ $OrigName = "paho-mqtt3as_orig.dll"
$TargetPath = Join-Path $InstallDir $TargetName
$OrigPath = Join-Path $InstallDir $OrigName
$DefaultDebug = "C:\Users\noham\Documents\paho-mqtt3as-proxy\x64\Debug\paho-mqtt3as.dll"
$DefaultRelease = "C:\Users\noham\Documents\paho-mqtt3as-proxy\x64\Release\paho-mqtt3as.dll"
$RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
$DefaultDebug = Join-Path $RepoRoot "paho-mqtt3as-proxy\x64\Debug\paho-mqtt3as.dll"
$DefaultRelease = Join-Path $RepoRoot "paho-mqtt3as-proxy\x64\Release\paho-mqtt3as.dll"
$LegacyDebug = Join-Path $RepoRoot "x64\Debug\paho-mqtt3as.dll"
$LegacyRelease = Join-Path $RepoRoot "x64\Release\paho-mqtt3as.dll"
function Show-Help {
"Actions:"
@@ -31,7 +34,7 @@ function Show-Help {
""
"Examples:"
" .\install-hook.ps1 -Action install"
" .\install-hook.ps1 -Action install -SourcePath `"$DefaultDebug`""
" .\install-hook.ps1 -Action install -SourcePath `"$DefaultRelease`""
" .\install-hook.ps1 -Action restore"
}
@@ -63,11 +66,17 @@ function Install-Proxy {
$resolvedSource = $SourcePath
if (-not $resolvedSource) {
if (Test-Path $DefaultDebug) {
if (Test-Path $DefaultRelease) {
$resolvedSource = $DefaultRelease
}
elseif (Test-Path $DefaultDebug) {
$resolvedSource = $DefaultDebug
}
elseif (Test-Path $DefaultRelease) {
$resolvedSource = $DefaultRelease
elseif (Test-Path $LegacyRelease) {
$resolvedSource = $LegacyRelease
}
elseif (Test-Path $LegacyDebug) {
$resolvedSource = $LegacyDebug
}
else {
Write-Error "No source DLL supplied and none found in default Debug/Release paths."
@@ -119,4 +128,4 @@ switch ($Action) {
"restore" { Restore-Original; break }
"help" { Show-Help; break }
default { Show-Help; break }
}
}