Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS not implemented #70

Closed
evmar opened this issue Sep 23, 2024 · 1 comment
Closed

TLS not implemented #70

evmar opened this issue Sep 23, 2024 · 1 comment

Comments

@evmar
Copy link
Owner

evmar commented Sep 23, 2024

Pocoman (#43) appears to depend on thread local storage, which is currently stubbed.

I pushed a new thread.exe demonstrating the tls problem in 769053b

Right now it prints

thread=0 name="main" tls=1 i=0
thread=1 name="i_am_thread" tls=2 i=0
thread=0 name="main" tls=2 i=1
thread=1 name="i_am_thread" tls=2 i=1
thread=0 name="main" tls=2 i=2
thread=0 name="main" tls=2 i=3
thread=1 name="i_am_thread" tls=2 i=2

But if you look at the code, the tls values it prints should flip between 1/2 depending on which thread is running.

@evmar evmar mentioned this issue Sep 23, 2024
27 tasks
@evmar
Copy link
Owner Author

evmar commented Sep 23, 2024

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:

/// The FS register points at the TEB (thread info), which points at the PEB (process info).

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.)

@evmar evmar closed this as completed in 15d8cf2 Oct 16, 2024
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

No branches or pull requests

1 participant