Closed evmar closed 1 month ago
The way this works in general in Windows is the fs register is supposed to point at the current thread's TEB, which then holds things like thread-local vars. You can see where retrowin32's TEB is set up here, and in particular how it doesn't set anything up per thread: https://github.com/evmar/retrowin32/blob/da79608b9d7b2e9c9ec1a9c518ffc145fe8c48cc/win32/src/winapi/kernel32/init.rs#L143
I think the way it should work is that instead whenever we create a thread we allocate a new TEB and set the fs_addr field in the new CPU appropriately. (And probably the place where the initial TEB is set up should use the same thing.)
Pocoman (#43) appears to depend on thread local storage, which is currently stubbed.
I pushed a new thread.exe demonstrating the tls problem in https://github.com/evmar/retrowin32/commit/769053b190b10c9a486c6b597291657177e3a3ee
Right now it prints
But if you look at the code, the tls values it prints should flip between 1/2 depending on which thread is running.