Page 1 of 1
PMode call-opcode problem
Posted: Sun Jan 26, 2003 6:01 am
by FlashBurn
When I call something in PMode bochs gives me the error "running in bogus memory", which should mean that the eip pointer is in the never-never land. Maybe someone of you have an idea what can produce such a failure.
Re:PMode call-opcode problem
Posted: Sun Jan 26, 2003 8:49 am
by FlashBurn
Ok, I found the problem it was the stack! But how have I to setup the stack right? I?ve written 0fffffh in esp and now 1000h. But how can I now control the stack, because now when there is a failure in my code it could overwrite my kernel.
Re:PMode call-opcode problem
Posted: Sun Jan 26, 2003 12:54 pm
by drizzt
you can control stack overflows/underflows by the paging mechanism. In fact you can put an unmapped page at the extremes of the stack, so when the stack go out of its boundaries a stack-fault exception occurs... and you can manage it in the opportune way.
Re:PMode call-opcode problem
Posted: Sun Jan 26, 2003 8:12 pm
by Perica
..
Re:PMode call-opcode problem
Posted: Mon Jan 27, 2003 3:01 am
by Pype.Clicker
Perica Senjak wrote:
Or: You could make a Stack DataSelector in your GDT that maps the Area where you want your Stack to be! (In my Opinion, this is an easier solution -- And the one i am About to use: I just got to get around to implementing it ;D);
just keep in mind that C and most HLL will *require* that a stack offset can be used as data offset aswell (i.e. no special instruction should be involved to get &on_stack)
Re:PMode call-opcode problem
Posted: Mon Jan 27, 2003 5:26 pm
by Perica
..
Re:PMode call-opcode problem
Posted: Tue Jan 28, 2003 1:17 am
by Pype.Clicker
what i mean is that *bases* will have to be aligned. limits, however, can differ. I use a no-limit (0xffff.ffff) data segment and a expand-down stack segment that guarantees a protection for stack overflows only (limit = max top-of-stack).
Any other scheme (and believe me, i've been trying a lot of them) will require a modification of the code generated by the C compiler. Only a few languages like Java and assembly will let you play with ss.base != ds.base.