mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:25:53 +01:00
[PR #2341] dnsapi_offline: answer DNS client calls without the network (DNS-OFFLINE) #2345
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2345
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2341
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:feat/dnsapi-offline📝 Commits (1)
e203d57dnsapi_offline: answer DNS client calls without the network (DNS-OFFLINE)📊 Changes
5 files changed (+705 additions, -2 deletions)
View changed files
📝
docs/runtime_imports.md(+41 -2)📝
runtime/CMakeLists.txt(+16 -0)➕
runtime/shims/dnsapi_offline.cpp(+294 -0)📝
runtime/shims/registry.cpp(+1 -0)➕
runtime/test/dnsapi_offline_test.cpp(+353 -0)📄 Description
Claimed in the coordination issue as: DNS-OFFLINE
What and why
docs/runtime_imports.mdlisteddnsapi.dllas the known gap next to the WinHTTP and Winsock2 offline shims: "a title that calls it reaches the host's resolver". The host's DNS client sends a query for any name. It also sends dynamic updates (DnsModifyRecordsInSet_*,DnsReplaceRecordSet*), server checks (DnsValidateServerStatus) and DNS-SD / multicast DNS on the local link (DnsService*,DnsStartMulticastQuery). TheDnsService*functions are the ones the games partition ofwindns.hoffers a GDK title, besides the free functions.runtime/shims/dnsapi_offline.cppvets the documented functions that can send.dnsapi.dllstays host-owned (owns_dll), likews2_32.dll, soLoadLibraryreturns the real module, andDnsRecordListFree,DnsFree,DnsQueryConfig,DnsCancelQueryand the name helpers stay the host's.DnsQuery_A/W/UTF8,DnsQueryExforlocalhost(any case, trailing dot) or a loopback literal (127.0.0.0/8in plain decimal,::1,::ffff:127.x)DNS_ERROR_RECORD_DOES_NOT_EXIST, no recordsDnsQueryRaw,DnsModifyRecordsInSet_A/W/UTF8,DnsReplaceRecordSetA/W/UTF8,DnsServiceBrowse/Resolve/Register/DeRegister,DnsStartMulticastQueryERROR_NETWORK_UNREACHABLEbefore anything is sent; no callbackDnsValidateServerStatusDNS_VALSVR_ERROR_UNREACHABLE; the server is never askedThe loopback names go to the host with
DNS_QUERY_NO_WIRE_QUERY,NO_NETBT,NO_MULTICASTandNO_HOSTS_FILEadded.WIRE_ONLY,MULTICAST_ONLY,BYPASS_CACHEandRETURN_MESSAGEare removed, because the host refuses them next toNO_WIRE_QUERYwithERROR_INVALID_PARAMETER. Server lists (pExtra,pDnsServerList, version 3's custom servers) are dropped. The records are the host's own, so the title frees them as usual.The rest follows measurements on Windows 11 with a small probe (cache-only queries, no names sent):
localhostwithDNS_QUERY_NO_WIRE_QUERY(also withNO_HOSTS_FILE) gives127.0.0.1and::1, and a literal gives its own record.DNS_ERROR_RECORD_DOES_NOT_EXIST, so the shim uses the same code. An empty name gives the machine's own addresses, and any other literal gives itself; the shim refuses both. It also does not read the resolver cache or the hosts file, as the Winsock2 lookups don't, so a title can't read what other programs resolved.DnsQueryExwith a completion callback returnslocalhostat once, without calling back. The shim therefore completes every query before it returns (no shim query is ever pending), andDnsCancelQuerystays the host's.DnsQueryExrejects a null request, result or name, a resultVersionother than 1 and a requestVersion7 withERROR_INVALID_PARAMETER. The shim keeps those checks for refused names too.0127.0.0.1is refused, as in the Winsock2 lookups: the host itself answers it withERROR_INVALID_NAME.Refused names and functions are logged once (
[rt] dnsapi: offline, refused <function> <name>). Not covered: undocumented exports (DnsQueryExA/W/UTF8,DnsValidateServer_A/W, the internalDns_*andSocket_*helpers).Tested
Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:
New
runtime/test/dnsapi_offline_test.cpp(ctestdnsapi_offline), 46 checks, all pass. It covers:localhost,LocalHost.,127.45.6.7,::1and::ffff:127.0.0.1throughDnsQuery_W,_A,_UTF8andDnsQueryEx, also withWIRE_ONLY,MULTICAST_ONLY,BYPASS_CACHE,RETURN_MESSAGE, a server list, version 3 custom servers or a completion callback;NO_LOCAL_NAMErefuseslocalhoston both);.invalidname, an SRV lookup, an empty name, RFC 5737 / RFC 3849 literals,0127.0.0.1,foo.localhost,localhost.example,::1%1, non-ASCII names in W and UTF-8, a reverse lookup;DnsQueryEx's argument checks;DnsService*are given real callbacks that count);DnsValidateServerStatus.Only loopback names reach the host's DNS client.
Full
ctest -j 8(169 CPU tests, no Vulkan SDK here): all pass.gta6rtbuilds with the shim and needs nodnsapi.lib(host calls are resolved at run time from System32).Merges without new conflicts against every pull request that touches
runtime/CMakeLists.txt,runtime/shims/registry.cppordocs/runtime_imports.md, including #400 (which also edits theowns_dllhost list).scripts/check_no_game_data.pyon the five files.Not tested under Wine.
GPUs tested: n/a (CPU tests)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.