Skip to content

feat: add dbghelp shim for Antigravity CLI#100

Open
lesserafim4ever0502 wants to merge 2 commits into
yuaotian:mainfrom
lesserafim4ever0502:feat/cli-dbghelp-shim
Open

feat: add dbghelp shim for Antigravity CLI#100
lesserafim4ever0502 wants to merge 2 commits into
yuaotian:mainfrom
lesserafim4ever0502:feat/cli-dbghelp-shim

Conversation

@lesserafim4ever0502
Copy link
Copy Markdown

@lesserafim4ever0502 lesserafim4ever0502 commented May 31, 2026

Summary

This PR adds a minimal dbghelp.dll shim for Antigravity CLI (agy.exe) so the CLI can load the existing version.dll proxy without a separate launcher.

Changes

  • Add a small dbghelp.dll shim that exports SymFromAddr.
  • Load colocated version.dll from the shim when agy.exe loads dbghelp.dll.
  • Forward SymFromAddr calls to the system dbghelp.dll.
  • Copy dbghelp.dll to output during build.
  • Add agy.exe to the default target process list and config-web defaults.
  • Document the CLI deployment flow in README / README_EN.

Validation

Tested locally on Windows:

  • ./build.ps1 -Config Release -Arch x64 -SkipTests
  • Confirmed output contains version.dll, dbghelp.dll, and config.json
  • Confirmed output does not contain agyp.exe or agy-proxy-launcher.exe
  • Confirmed current agy.exe imports dbghelp.dll!SymFromAddr
  • Ran agy.exe --version
  • Ran agy.exe --print "Reply with OK only." --print-timeout 90s
  • Verified proxy logs show version.dll loaded, hooks installed, and SOCKS5 tunnels established to Google endpoints

Notes

Thanks @CrazyBoyFeng for the review feedback about splitting concerns and keeping maintenance cost low.

Thanks @median-dxz for pointing out that agy.exe imports dbghelp.dll and suggesting the shim-based approach.

@CoreyZhang
Copy link
Copy Markdown

你好,感谢这个 dbghelp shim PR。在实际测试中发现一个竞态条件问题,导致 agy.exe 主进程无法走代理:

问题现象

Eligibility check failed: Post "https://daily-cloudcode-pa.googleapis.com/v1internal:loadCodeAssist": dial tcp 216.239.36.223:443: connectex: No connection could be made
because the target machine actively refused it.

agy.exe 主进程在 version.dll hook 安装完成前就发出了 Eligibility Check 的网络请求。proxy 日志显示子进程(如 node.exe)的 ConnectEx 重定向是正常的,但主进程直连真实 IP
被系统拒绝。

根因分析

dbghelp.dllDllMain 中用 CreateThread 异步加载 version.dll

const HANDLE thread = CreateThread(nullptr, 0, LoadVersionDll, nullptr, 0, nullptr);
if (thread) {
    CloseHandle(thread);
}

DllMain 返回后主线程继续执行,但新线程还在后台加载 version.dll、安装 hook。agy.exe 启动时立即发起 Eligibility Check 请求,网络调用比 hook 安装跑得快,导致第一个请求直连真实
IP 被拒。

建议修复

将异步加载改为同步加载,确保 hook 安装完成后再返回:

BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID) {
    if (reason == DLL_PROCESS_ATTACH) {
        DisableThreadLibraryCalls(module);
        LoadVersionDll(nullptr);  // 同步加载,不创建新线程
    }
    return TRUE;
}

这样 DllMain 会阻塞直到 version.dll 及其 hook 全部安装完成,agy.exe 主线程恢复执行时 hook 已就位。

感谢!

---

@lesserafim4ever0502
Copy link
Copy Markdown
Author

感谢反馈,判断是对的。

这里确实存在竞态:之前 dbghelp.dllDllMain 里用后台线程加载 version.dllagy.exe 主线程可能会先继续执行并发出 Eligibility Check,导致首个请求绕过 hook。

我已经在 1e055f4 修复:改为在 DLL_PROCESS_ATTACH 中同步加载 version.dll,确保 DllMain 返回前 hook 已安装完成。

本地已重新验证:

  • ./build.ps1 -Config Release -Arch x64 -SkipTests
  • agy.exe --version
  • agy.exe --print "Reply with OK only." --print-timeout 90s

日志确认 version.dll 加载、hook 安装成功,并且 Google 相关请求已通过 SOCKS5 隧道。感谢指出这个问题。

@CoreyZhang
Copy link
Copy Markdown

请问能基于 1e055f4 发一个新 Release 吗?现有 Release 里的 dbghelp.dll 还是修复前的版本。

@CoreyZhang
Copy link
Copy Markdown

CoreyZhang commented Jun 3, 2026 via email

@lesserafim4ever0502
Copy link
Copy Markdown
Author

好的,已经推送了 @CoreyZhang

@CoreyZhang
Copy link
Copy Markdown

CoreyZhang commented Jun 3, 2026 via email

@ganluo960214
Copy link
Copy Markdown

@lesserafim4ever0502 更新到1.0.5好像就不用了。env 里面有 https_proxy 和 http_proxy就行了 。

@lesserafim4ever0502
Copy link
Copy Markdown
Author

@lesserafim4ever0502 更新到1.0.5好像就不用了。env 里面有 https_proxy 和 http_proxy就行了 。

测试过了,确实;看看后续版本能不能持续吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants