Commit Graph

20 Commits

Author SHA1 Message Date
thejanit0r
497a4e98cb Fixed formatting 2026-01-04 13:35:54 +01:00
thejanit0r
29b8ec4072 Added additional vmp compatibility 2026-01-04 09:33:54 +01:00
Maurice Heumann
1f936c024d Fix thread support (#640)
This PR fixes several things related to threads emulation:

1. Support `SameTebFlags.InitialThread`
This flag is needed to support emulation of .net executables (not yet
fully supported) that don't have an entry point set in `PE` header. This
applies to both `PE32` and `PE64` executables. If `InitialThread` is set
the loader substitutes an entry point of the .net executable with
`mscoree.dll!_CorExeMain`.

2. Fix static thread local storage for `WOW64`
This fix resolves `shell32.dll` initialization on `WOW64`. This fix also
uses correct structure and field names that are obtained from the
corresponding `.pdb` files.

3. Fix dynamic thread local storage for `WOW64`

4. Fix setting argument of a `WOW64` thread start proc

5. Fix creating suspended thread and parse create_flags
Currently creating suspended thread doesn't work because
`NtCreateThreadEx` handler uses invalid flag `CREATE_SUSPENDED`. This PR
fixes that, and moreover it carefully parses create_flags of the
`NtCreateThreadEx` call.

6. Fix `FS` and `GS` handling
This PR fixes several problems with `GS` and `FS` segments:

    * Wrong GDT descriptor for selector 0x53
* Update GDT descriptor for selector 0x53 for a `WOW64` process every
context switch like Windows does
* Set `GS` base when `GS` segment register is updated in 64-bit code
(code selector is `0x33`). When `GS` segment register is loaded with
correct selector (`0x2b`) `GS` base is set to 0. So, when the code
accesses something like `gs:[0]`, a page fault occurs. `KiPageFault`
handles this situation and sets correct `GS` base.

Also, take into account that `teb64.ExceptionList` initially contains
`teb32` address for `WOW64` process. This is used to setup `FS` base
when `wrfsbase` instruction is available. We can enable this instruction
using `kusd.ProcessorFeatures.arr[PF_RDWRFSGSBASE_AVAILABLE] = 1;` and
this work perfectly with `unicorn` backend. Unfortunately `icicle`
backend does not support `wrfsbase`, so I don't enable this instruction
by default.
2025-12-30 17:56:30 +01:00
ssvine
04ff582fa9 Fix static TLS for WOW64
This fix resolves shell32.dll TLS problems.
Also it uses correct structure and field names
2025-12-30 15:18:18 +03:00
66hh
d830bea3c5 Try to fix the build 2025-12-30 17:40:16 +08:00
66hh
d83c602f19 Change data type to fix 32-bit build 2025-12-28 12:40:51 +08:00
66hh
ecc00216d6 Support ProcessInstrumentationCallback 2025-12-27 17:17:23 +08:00
ssvine
8438a1f456 Support extended variant of ProcessBasicInformation 2025-12-24 18:33:49 +03:00
momo5502
568ca68481 Ignore ProcessPriorityClass 2025-12-06 11:12:19 +01:00
momo5502
8c75475f0d Stub more syscalls 2025-11-20 18:43:20 +01:00
momo5502
2be5f73755 Support ProcessPriorityClass in NtQueryInformationProcess 2025-11-20 18:25:33 +01:00
brian
65eecf1cfd Comprehensive WOW64 subsystem implementation 2025-10-13 19:55:50 +08:00
momo5502
7d6648ade0 Extend clang-format column limit to 140 2025-08-16 14:55:07 +02:00
momo5502
1421550764 Cleanup and fix NtQueryInformationProcess 2025-06-15 09:31:57 +02:00
Red
f14b16d080 Fix anti-debug detections for NtQueryInformationProcess with ProcessDebugObjectHandle 2025-06-14 15:00:53 +02:00
momo5502
c605131a80 Small changes 2025-06-01 12:48:59 +02:00
Igor Pissolati
a629f77e31 Miscellaneous fixes 2025-04-28 12:48:28 -03:00
Igor Pissolati
134b45d1e8 Fix vm crash when teb.ThreadLocalStoragePointer is null 2025-04-23 01:16:31 -03:00
Maurice Heumann
0e9cffa5cb More 32 bit fixes 2025-04-14 14:34:06 +02:00
RektInator
8bc49bdd03 refactor(windows-emulator/syscalls): partial refactor of syscalls.cpp, splits syscall implementations over multiple files 2025-04-11 16:42:00 +02:00