MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / readFromContext

Function readFromContext

source/kernel/kthread.cpp:1005–1045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1003
1004void common_fxrstor(CPU* cpu, U32 address);
1005void readFromContext(CPU* cpu, U32 context) {
1006 KMemory* memory = (KMemory*)cpu->memory;
1007
1008 cpu->setSegment(GS, memory->readd(context+0x14));
1009 cpu->setSegment(FS, memory->readd(context+0x18));
1010 cpu->setSegment(ES, memory->readd(context+0x1C));
1011 cpu->setSegment(DS, memory->readd(context+0x20));
1012
1013 cpu->reg[7].u32 = memory->readd(context+0x24); // EDI
1014 cpu->reg[6].u32 = memory->readd(context+0x28); // ESI
1015 cpu->reg[5].u32 = memory->readd(context+0x2C); // EBP
1016 cpu->reg[4].u32 = memory->readd(context+0x30); // ESP
1017
1018 cpu->reg[3].u32 = memory->readd(context+0x34); // EBX
1019 cpu->reg[2].u32 = memory->readd(context+0x38); // EDX
1020 cpu->reg[1].u32 = memory->readd(context+0x3C); // ECX
1021 cpu->reg[0].u32 = memory->readd(context+0x40); // EAX
1022
1023 cpu->eip.u32 = memory->readd(context+0x4C);
1024 cpu->setSegment(CS, memory->readd(context+0x50));
1025 cpu->flags = memory->readd(context+0x54);
1026 cpu->setSegment(SS, memory->readd(context+0x5C));
1027
1028 /* common_fxrstor will handle this
1029 cpu->fpu.SetCW(memory->readd(context + 0x70));
1030 cpu->fpu.SetSW(memory->readd(context + 0x74));
1031 cpu->fpu.SetTag(memory->readd(context + 0x78));
1032 cpu->fpu.isMMXInUse = (memory->readw(context + 0xDE) & 0x8000) != 0;
1033 for (U32 i = 0; i < 8; i++) {
1034 U32 address = context + 0x8C + i * 10;
1035
1036 if (cpu->fpu.isMMXInUse) {
1037 cpu->reg_mmx[i].q = cpu->memory->readq(address);
1038 } else {
1039 U32 index = (i - cpu->fpu.GetTop()) & 7;
1040 cpu->fpu.regs[i].d = cpu->fpu.FLD80(cpu->memory->readq(address), (S16)cpu->memory->readw(address+8));
1041 }
1042 }
1043 */
1044 common_fxrstor(cpu, context + 0xE0);
1045}
1046
1047U32 KThread::sigreturn() {
1048 kpanic("KThread::sigreturn This code seems wrong, we never did a memcpy to memory of CPU, should this be readContext. Debug this after finding a program that triggers it");

Callers 1

onExitSignalFunction · 0.85

Calls 3

common_fxrstorFunction · 0.85
setSegmentMethod · 0.80
readdMethod · 0.45

Tested by

no test coverage detected