PMode call-opcode problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
FlashBurn

PMode call-opcode problem

Post 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.
FlashBurn

Re:PMode call-opcode problem

Post 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.
drizzt

Re:PMode call-opcode problem

Post 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.
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:PMode call-opcode problem

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 8:35 pm, edited 1 time in total.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:PMode call-opcode problem

Post 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)
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:PMode call-opcode problem

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 8:35 pm, edited 1 time in total.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:PMode call-opcode problem

Post 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.
Post Reply