Commit Graph

49 Commits

Author SHA1 Message Date
Igor Pissolati
90b38b3bff Fix user_handle_table initialization 2026-01-05 09:01:05 -03:00
Igor Pissolati
5d59700ec7 Remove parse_number 2026-01-05 09:00:45 -03:00
Igor Pissolati
7112d619b4 Fix clang tidy 2026-01-04 16:28:30 -03:00
Igor Pissolati
5302900a9d Fix for older Windows builds 2026-01-04 16:01:13 -03:00
Igor Pissolati
de491ade0e Add support for user_object/user_handle_table 2026-01-02 19:46:04 -03:00
ssvine
7724b0d416 Refactor emulator_object 2026-01-02 19:03:54 +03: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
57ad277158 Fix creating suspended thread and parse create_flags 2025-12-30 15:18:55 +03:00
ssvine
fea27338bb Support SameTebFlags.InitialThread
This flag is needed to suport emulation of .net executables
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.
2025-12-30 13:44:21 +03:00
66hh
ecc00216d6 Support ProcessInstrumentationCallback 2025-12-27 17:17:23 +08:00
ssvine
3686625fb1 Fix PEB32 2025-12-25 13:42:20 +03:00
brian
5171ef63dc Fix deserialization of optional WOW64 emulator_object members (PEB32/params32) 2025-12-05 20:21:25 +08:00
brian
65eecf1cfd Comprehensive WOW64 subsystem implementation 2025-10-13 19:55:50 +08:00
momo5502
5a3d05c64c Fix compilation 2025-08-18 19:16:43 +02:00
momo5502
8e984b8b29 Keep GDTR readable for now 2025-08-18 19:07:12 +02:00
momo5502
2cef0a5511 Make sure GDTR is page aligned 2025-08-18 19:01:09 +02:00
momo5502
584b770def Store previous IP per thread 2025-08-17 07:32:26 +02:00
momo5502
b2eef2bf46 Align processor counts 2025-08-17 07:31:37 +02:00
momo5502
7d6648ade0 Extend clang-format column limit to 140 2025-08-16 14:55:07 +02:00
3fault
e5e5d05d05 Add temp environment variables to fix GetTempPath(2)W 2025-06-10 09:59:34 -04:00
momo5502
da4a4f90c9 Cleanup exception callbacks 2025-06-07 07:54:11 +02:00
momo5502
802e295bcc Adapt more printing 2025-06-07 07:29:30 +02:00
momo5502
da658e5178 Prepare timer support 2025-06-01 13:56:45 +02:00
momo5502
67031b40ea More UI syscalls 2025-05-18 10:35:22 +02:00
momo5502
0fbd563e8c Support window creation 2025-05-18 09:51:28 +02:00
momo5502
bd4e27469f Add more ui syscall stubs 2025-05-17 18:28:53 +02:00
Igor Pissolati
bab8c55ed3 Disable Trap Test on icicle 2025-04-28 19:27:56 -03:00
Igor Pissolati
b67a512ea6 Properly expand REG_EXPAND_SZ keys 2025-04-28 15:24:49 -03:00
Igor Pissolati
9d5338b168 Load environment variables from registry 2025-04-28 12:46:36 -03:00
robert-yates
b2296930d3 prepare 32bit support with name and class inheritance modifications 2025-04-22 12:01:40 +02:00
Igor Pissolati
657bf6121a Apply suggested changes 2025-04-22 03:44:45 -03:00
Igor Pissolati
6deefb932f Add NtUserGetAtomName syscall 2025-04-22 01:19:05 -03:00
Igor Pissolati
3dfad0f789 Add more atom-related syscalls 2025-04-19 13:52:13 -03:00
Maurice Heumann
0e9cffa5cb More 32 bit fixes 2025-04-14 14:34:06 +02:00
momo5502
a8926592bc Prepare APC dispatching 2025-04-13 13:39:09 +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
Maurice Heumann
67d34b3988 Small fix 2025-04-08 10:17:05 +02:00
momo5502
3c58c1af98 Log debug strings 2025-04-07 21:03:57 +02:00
momo5502
637ed75b8c GDT fixes 2025-03-29 10:44:41 +01:00
Maurice Heumann
dec66f051d Test 2025-03-29 10:44:41 +01:00
momo5502
53fb2f9116 Support more syscalls 2025-03-22 19:53:53 +01:00
momo5502
bf01b125ac Fix clang-tidy warnings 2025-03-18 20:40:14 +01:00
momo5502
db1ef0dd16 Include PCH everywhere 2025-03-18 20:19:26 +01:00
Maurice Heumann
95c7ffbf91 Move executed instructions into windows emulator 2025-03-18 12:35:38 +01:00
Maurice Heumann
450e3c2a9c Use clock interfaces to precisely control time 2025-03-18 11:48:44 +01:00
momo5502
3218e26306 Small callback optimization and unification 2025-02-14 09:05:55 +01:00
Elias Bachaalany
1d7f841ee4 added more callbacks 2025-02-10 11:25:04 -08:00
momo5502
934374c4bb Extract main module cache into module manager 2025-02-10 17:43:09 +01:00
momo5502
c1aa260f8f Cleanup process context 2025-02-10 17:28:00 +01:00