Commit Graph

174 Commits

Author SHA1 Message Date
ahm3dgg
49ae9ef68a Add dummy stub for NtFlushInstructionCache 2026-01-07 20:21:19 +02:00
ahm3dgg
1ec9816d9a Return STATUS_IMAGE_MACHINE_TYPE_MISMATCH in case a 64-bit process tries to map a 32-bit executable 2026-01-07 19:50:26 +02:00
ahm3dgg
fdcc7455a1 Separated KnownDLLs and KnownDLLs32 2026-01-07 19:37:36 +02:00
ahm3dgg
c3a760dace Fixed Formatting 2026-01-07 08:23:00 +02:00
ahm3dgg
4f8745ce1b Support for KnownDLLs and Some Refactoring 2026-01-07 08:06:19 +02:00
ahm3dgg
f54bc3467f Support for KnownDLLs and Some Refactoring 2026-01-07 07:34:34 +02:00
Maurice Heumann
5d81d8bda9 Implement NtQueryMultipleValueKey (#684)
This PR implements `NtQueryMultipleValueKey` that is used in calls like
`RegQueryMultipleValues`.
2026-01-06 10:38:10 +01:00
ahm3dgg
67e130a3b8 Check if the known dll path exists first 2026-01-06 09:57:33 +02:00
redthing1
a2a119aec2 object syscalls: implement NtCompareObjects 2026-01-05 23:08:18 -08:00
redthing1
6f8dca6614 object syscalls: implement NtWaitForMultipleObjects32 2026-01-05 23:08:14 -08:00
ahm3dgg
b642486bc4 Add Support for KnownDLLs 2026-01-06 08:34:41 +02:00
ssvine
37c2184bfc Implement NtQueryMultipleValueKey 2026-01-05 13:11:35 +03:00
Maurice Heumann
f218ec5d1d Fix virtual memory semantics and refactor region policy (#681) 2026-01-04 19:46:14 +01:00
Brian Wynn
2b0277cf6b Update src/windows-emulator/syscalls/section.cpp
Co-authored-by: Maurice Heumann <MauriceHeumann@gmail.com>
2026-01-04 23:14:35 +08:00
Maurice Heumann
ec0d626a96 Added additional vmp compatibility (#679) 2026-01-04 15:01:35 +01:00
thejanit0r
497a4e98cb Fixed formatting 2026-01-04 13:35:54 +01:00
thejanit0r
0688a2cb98 Fixed formatting 2026-01-04 13:37:23 +01:00
brian
6943b4369a Fix virtual memory semantics and refactor region policy 2026-01-04 18:01:24 +08:00
thejanit0r
29b8ec4072 Added additional vmp compatibility 2026-01-04 09:33:54 +01:00
thejanit0r
b00f40aba7 Added support for NtCreateDirectoryObject 2026-01-04 04:31:49 +01:00
Maurice Heumann
0de53515ed Fix waiting (#675)
This PR fixes `INFINITE` waiting (`SleepEx`, `WaitForSingleObject`,
etc). Currently `INFINITE` is not infinite but "at this moment" (waiting
point in time == `clock.steady_now()`).
2026-01-02 22:14:02 +01:00
ssvine
b9df0682ad Support SystemEmulationProcessorInformation 2026-01-02 18:28:38 +03:00
ssvine
254475e308 Don't read null ptr in NtDelayExecution 2026-01-02 17:36:05 +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
1ebe5356c9 Fix dynamic TLS for WOW64 2025-12-30 15:18:33 +03: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
0521fdef7d Fix code formatting issues 2025-12-30 18:50:59 +08:00
66hh
d830bea3c5 Try to fix the build 2025-12-30 17:40:16 +08:00
66hh
c144f2f438 Adjust memory allocation method 2025-12-30 17:05:08 +08:00
66hh
536f2ce883 Adjust variable order 2025-12-29 00:54:31 +08:00
66hh
3cd461e2ab Add the debugger_hide attribute to emulator_thread 2025-12-29 00:52:59 +08:00
66hh
12e96c8921 Adjust memory allocation method 2025-12-29 00:31:49 +08:00
66hh
83d4cadf76 Modify memory API implementation 2025-12-28 20:48:26 +08:00
66hh
020e7ca3f6 Fix the base address alignment issue 2025-12-28 19:14:42 +08:00
66hh
d83c602f19 Change data type to fix 32-bit build 2025-12-28 12:40:51 +08:00
66hh
2d24b4189d Fix VMP NtClose detection 2025-12-27 19:51:29 +08:00
66hh
95b17566a0 Add NtRaiseHardError error message logging 2025-12-27 17:17:24 +08:00
66hh
55310c57ac Add additional path checks for NtOpenSection 2025-12-27 17:17:24 +08:00
66hh
98393c03d2 Add a check before the conversion path 2025-12-27 17:17:24 +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
f0f223faaa Remove error 2025-12-24 08:58:15 +01:00
momo5502
5d84f86eaf Fix warnings 2025-12-23 11:31:51 +01:00
momo5502
35b7839ec8 Support section offsets 2025-12-23 10:50:07 +01:00
momo5502
db3a89a0da Support KeyCachedInformation 2025-12-23 09:31:10 +01:00
momo5502
66cfe980d7 Ignore ThreadPriorityBoost 2025-12-22 14:39:44 +01:00
Maurice Heumann
1708212af9 Translate file paths before usage in section.cpp (#634)
Emulated applications are currently able to access files from the host
system, rather than being restricted to the virtualized file system, by
using `Section` related Syscalls. This behavior appears to have been
introduced in:

- 2024-12-13: [Prepare better section support
(syscalls.cpp:582)](719a50444e (diff-96c7de348bdc06e650bdc371a600a91f80594d4201afd7a28ffa160fa755be9dR582))
- 2025-10-13: [Comprehensive WOW64 subsystem implementation
(section.cpp:141)](65eecf1cfd (diff-415eed3b4b314dc10cc9f7926687770be53799766bc9a4edca2a7f4a45477169R141)))

Because the emulator is [advertised for malware
analysis](https://github.com/momo5502/sogen/blob/main/README.md), this
unintended access path could be considered a security concern.

This PR only fixes two current misuses of an API that interacts with the
host system. As a long term solution, APIs that interact with host
resources should consistently use C++ types that enforce translation of
resource identifiers (e.g., file and registry paths) into their emulated
equivalents. This would help prevent future misuse and ensure that
emulated applications remain isolated from the host environment.
2025-12-22 07:51:10 +01:00
momo5502
69ddd7a93b Small fixes 2025-12-22 07:42:34 +01:00
Maurice Kayser
db7548d130 Translate paths before usage in section.cpp 2025-12-21 00:00:00 +00:00