commit 3b32150f15cdda28f1827ef84cac1da98afbfa6f
parent b67393f796dfbbd8998dc7d77d7e1be6118f1057
Author: anon <anon@example.com>
Date: Tue, 13 Oct 2026 13:09:58 +0000
Implement database byte-range file locks in the browser runtime
Diffstat:
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/docs/browser-porting.md b/docs/browser-porting.md
@@ -999,3 +999,23 @@ eight WORDs containing year, month, weekday, day, hour, minute, second and
milliseconds. The browser runtime uses UTC for both, consistent with its
zero timezone offset and CRT clock policy; it does not inherit the host's
local timezone.
+
+### Database record file locks
+
+In pinned `client-target/ctreestd.dll` (SHA-256
+`727ef5cc050ee5fc519e5f9a0cc2bb819a54f5eed0aac990d97a678b427b3fd5`),
+the routine at RVA `0x10d0..0x1219` seeks to a record offset, calls
+`LockFile(handle, offset, 0, length, 0)`, performs `ReadFile` or `WriteFile`,
+then calls `UnlockFile` with the same range if locking succeeded. Failed
+locks invoke a helper with argument `0x32` and retry up to 3000 times.
+This is native client database I/O, rather than a game-server protocol lock
+(REA evidence `ev_f10c97c317890eef166a553ec4e457cf04da185a2e3d0af05b390d38fa0ff41f`).
+
+The Win32 contract combines low/high DWORDs into 64-bit offsets and lengths.
+Exclusive ranges cannot overlap, including locks requested by their existing
+owner. I/O through the owning handle is permitted; other handles cannot
+access a locked range. Unlocking requires the original range, and closing
+the handle releases its locks. See [LockFile](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfile)
+and [UnlockFile](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-unlockfile).
+The browser runtime coordinates file handles within one client worker;
+these locks do not coordinate separate browser workers or native clients.