Commit Graph

138 Commits

Author SHA1 Message Date
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
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
momo5502
cb4fe6c30f Merge remote-tracking branch 'origin/main' into wow64 2025-10-25 11:06:03 +02:00
Maurice Heumann
eb0ba686cd Bugfixes - minidump load, memory tail boundary (#568)
Minor change to allow minidump load to work with pages with copy
permission set.

File was probing memory via VirtualQuery incrementally, previously this
ran forever as Sogen doesn't replicate Windows behaviour.

Added exclusive allocation end boundary so that allocation / info check
on last page of user space VA works. Modified
memory_manager::find_free_allocation_base and
memory_manager::get_region_info to use exclusive boundary.
Added check to NtQueryVirtualMemory - now correctly returns
STATUS_INVALID_PARAMETER when run against memory outside of user space
VA. Kernel modules should use ZwQueryVirtualMemory not the user land
API.
2025-10-25 10:55:18 +02:00
CarlTSpeak
22df3e7889 Fix format issue 2025-10-24 11:13:55 +01:00
CarlTSpeak
064df5b6ef Revert earlier rdtsc changes, implement fixes 2025-10-24 10:59:28 +01:00
Igor Pissolati
3c6c2e2dde Apply review suggestion 2025-10-23 11:19:35 -03:00
Igor Pissolati
2c82277b5e Add FileIdInformation file info class 2025-10-23 11:19:17 -03:00
Igor Pissolati
46b97fd91c Don't request 'file_size' for directories 2025-10-22 17:21:04 -03:00
Igor Pissolati
c07f541528 Stub NtSetSecurityObject 2025-10-22 17:20:38 -03:00
Igor Pissolati
c8a18cf61c Add FileIsRemoteDeviceInformation file info class 2025-10-22 17:14:51 -03:00
Igor Pissolati
c0fd8ebf51 Add FileFsAttributeInformation fs info class 2025-10-22 17:14:19 -03:00
momo5502
effd2f7a02 Merge remote-tracking branch 'origin/main' into wow64 2025-10-21 20:45:29 +02:00
Maurice Heumann
b84ae7475f Implement ALPC port abstraction and implement DNS resolver port (#558)
This PR introduces an abstraction for ALPC ports to make them easier to
manage in the future, and implements the DNS resolver port, at least
enough to get host address queries working.
There's a lot of code in this PR that I'm not very confident about, so
don't hesitate on the feedback 😄

<img width="1377" height="624" alt="image"
src="https://github.com/user-attachments/assets/4d56b84d-4b87-42ed-9bfa-be04dbbf3735"
/>
2025-10-21 20:42:26 +02:00
momo5502
652f8d7f17 Fix formatting 2025-10-21 20:15:20 +02:00
Maurice Heumann
304dbcc661 Comprehensive WOW64 subsystem implementation (#555)
# Major Features Implemented
**Core WOW64 Architecture**
1. Full TEB, PEB, and Windows structure implementations for 32-bit
processes
2. Proper thread context switching with 32-bit stack allocation
3. Configurable memory allocation with 32-bit/64-bit address space
handling
4. Automatic WOW64 process identification and handling
5. Heaven's Gate Implementation for handling exceptions

**Enhanced Emulation Features**
1. Fixed GDT setup and segment management for WOW64
2. Multi-architecture PE loading with proper import resolution
3. Segment-aware disassembly with WOW64 debugging capabilities

**Testing & Validation**
**32-bit Test Sample**: Minimal "hello" executable with full ASM source

# TODO
Needs more testing, currently in very early stages.
2025-10-21 20:13:01 +02:00
Igor Pissolati
dc3a0e6fd4 Small improvements 2025-10-21 11:23:57 -03:00
Igor Pissolati
248c09d554 Implement ALPC port abstraction and implement DNS resolver port 2025-10-19 23:23:29 -03:00
Igor Pissolati
887b02c240 Support file renaming and support relative path in NtQueryAttributesFile 2025-10-19 17:51:44 -03:00
brian
65eecf1cfd Comprehensive WOW64 subsystem implementation 2025-10-13 19:55:50 +08:00
momo5502
9453123db0 Force new line at EOF 2025-10-12 17:21:51 +02:00
momo5502
c9c6b46ec2 Support object types information query 2025-09-12 20:36:45 +02:00
momo5502
b2eef2bf46 Align processor counts 2025-08-17 07:31:37 +02:00
momo5502
9c29f26647 Small fixes 2025-08-17 07:26:11 +02:00
momo5502
7d6648ade0 Extend clang-format column limit to 140 2025-08-16 14:55:07 +02:00
momo5502
5fbf065937 Handle debug strings via callback 2025-08-10 10:03:12 +02:00
CarlTSpeak
051cef2212 fix: handle VirtualAlloc invalid size and flags 2025-08-08 14:52:03 +01:00
CarlTSpeak
0aea1f5385 I just learned how clang-format works. Fail. 2025-08-08 11:22:56 +01:00
CarlTSpeak
210ab2930c Fixed platform portability issues 2025-08-06 11:12:44 +01:00
CarlTSpeak
8b2c170236 Fixed clang exception. Again. 2025-08-06 11:01:42 +01:00
CarlTSpeak
ffea72d48a Added basic pipe support to NtRead/WriteFile 2025-08-06 10:30:40 +01:00
CarlTSpeak
100638d8ea Fixed clang-tidy issue 2025-08-05 16:26:13 +01:00
CarlTSpeak
85843ff5c9 Fixed cross-platform: removed MS-specific macro 2025-08-05 15:55:36 +01:00
CarlTSpeak
5f9bfd4694 Added stubs for NtCreateNamedPipeFile NtReleaseWorkerFactoryWorker 2025-08-05 15:44:19 +01:00
CarlTSpeak
cae1cf5c1f Added stubs for NtCreateNamedPipeFile NtReleaseWorkerFactoryWorker 2025-08-05 15:35:31 +01:00