1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:55:06 +00:00

UserspaceEmulator: Put the executable name in argv[0] :^)

The emulated program can now find its own name in argv[0]. Very cool!
This commit is contained in:
Andreas Kling 2020-07-12 20:24:10 +02:00
parent ddf7b817df
commit 079021a607
5 changed files with 23 additions and 6 deletions

View file

@ -139,6 +139,14 @@ void SoftCPU::write_memory32(X86::LogicalAddress address, u32 value)
m_emulator.mmu().write32(address, value);
}
void SoftCPU::push_string(const StringView& string)
{
size_t space_to_allocate = round_up_to_power_of_two(string.length() + 1, 16);
set_esp(esp() - space_to_allocate);
m_emulator.mmu().copy_to_vm(esp(), string.characters_without_null_termination(), string.length());
m_emulator.mmu().write8({ 0x20, esp() + string.length() }, '\0');
}
void SoftCPU::push32(u32 value)
{
set_esp(esp() - sizeof(value));