mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 19:23:56 +00:00
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.
This commit is contained in:
@@ -116,7 +116,8 @@ namespace
|
||||
}
|
||||
|
||||
emulator_thread::emulator_thread(memory_manager& memory, const process_context& context, const uint64_t start_address,
|
||||
const uint64_t argument, const uint64_t stack_size, const bool suspended, const uint32_t id)
|
||||
const uint64_t argument, const uint64_t stack_size, const bool suspended, const uint32_t id,
|
||||
const bool initial_thread)
|
||||
: memory_ptr(&memory),
|
||||
// stack_size(page_align_up(std::max(stack_size, static_cast<uint64_t>(STACK_SIZE)))),
|
||||
start_address(start_address),
|
||||
@@ -152,6 +153,7 @@ emulator_thread::emulator_thread(memory_manager& memory, const process_context&
|
||||
teb_obj.NtTib.Self = this->teb64->value();
|
||||
teb_obj.CurrentLocale = 0x409;
|
||||
teb_obj.ProcessEnvironmentBlock = context.peb64.value();
|
||||
teb_obj.SameTebFlags.InitialThread = initial_thread;
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -209,6 +211,7 @@ emulator_thread::emulator_thread(memory_manager& memory, const process_context&
|
||||
teb_obj.CurrentLocale = 0x409;
|
||||
|
||||
teb_obj.ProcessEnvironmentBlock = context.peb64.value();
|
||||
teb_obj.SameTebFlags.InitialThread = initial_thread;
|
||||
teb_obj.StaticUnicodeString.MaximumLength = sizeof(teb_obj.StaticUnicodeBuffer);
|
||||
teb_obj.StaticUnicodeString.Buffer = this->teb64->value() + offsetof(TEB64, StaticUnicodeBuffer);
|
||||
|
||||
@@ -264,6 +267,7 @@ emulator_thread::emulator_thread(memory_manager& memory, const process_context&
|
||||
}
|
||||
|
||||
teb32_obj.WowTebOffset = -0x2000;
|
||||
teb32_obj.InitialThread = initial_thread;
|
||||
|
||||
// Note: CurrentLocale and other fields will be initialized by WOW64 runtime
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user