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

Implement some FS opcodes used in windows dlls #86

Merged
merged 1 commit into from
Jan 13, 2020

Conversation

mittorn
Copy link
Contributor

@mittorn mittorn commented Jan 13, 2020

Used by exception handlers and TLS in win32

@ptitSeb
Copy link
Owner

ptitSeb commented Jan 13, 2020

Sounds good, but are you sure it works by just adding the segment content?
My understanding is the FS: on windows is similar to GS: on linux: so accessing TLS (Thread Local Storage) data? Maybe it would be needed to check the content of FS value, and if similar to GS, use the same mecanism?

@mittorn
Copy link
Contributor Author

mittorn commented Jan 13, 2020

It only needed if you need to interact with native libraries, but native linux libraries does not use FS. So it should be enough until box86 ported to arm windows (but arm windows has own x86 translator). And different threads using different x86emu_t structs, i am right?

@ptitSeb
Copy link
Owner

ptitSeb commented Jan 13, 2020

Ok for FS: I'll add some code later, but I understand it will probably be not used on linux.

Different thread should be using different x86emu_t struct yes.
Note that now, you can create small x86emu_t from the stack. look at RunFunction(...) for example, that can be usefull in your case (you don't even need to create an x86emu_t sruct in that case, you just need a global box86context_t for it).

@mittorn
Copy link
Contributor Author

mittorn commented Jan 13, 2020

I think, RunFunction is slow and eats many stack memory. and it still needs box86context. Single global should be enough for hl.dll as it single-threaded, but if some other games need dll in multi-threaded mode, it is possible to keep current context storage in TLS, which should make FS usage correct.

@ptitSeb
Copy link
Owner

ptitSeb commented Jan 13, 2020

RunFunction(...) eats some stack memory yes, but it's not slow. "Allocation" of memory on the stack is super fast (just a substraction from a register), much much faster than malloc (that is a functon call, doing many things).

@ptitSeb ptitSeb merged commit 290adf2 into ptitSeb:master Jan 13, 2020
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.

None yet

2 participants