Argument passing

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
WinExperements
Member
Member
Posts: 97
Joined: Thu Jul 14, 2022 9:45 am
Contact:

Argument passing

Post by WinExperements »

Hello, guys!

I have problem with passing arguments to user mode process. If i do this:

Code: Select all

int *stack = (int *)fr->usersp+4;
All works fine, but if i try to add something to the allocated stack, the stack are brokes:

Code: Select all

frame->usersp = (isUser ? ((int)pmml_alloc(true)+4096) : 0);
The first poping from stack are zero, i use this code for checking valid of stack:

Code: Select all

pop eax
    ; Check if argument exists
    cmp eax,0
    je .exit
And program always jumps to exit label, this means that after the poping from stack done, the register eax are zero.
What i am doing wrong?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Argument passing

Post by Octocontrabass »

Where is your code to add something to the allocated stack?
WinExperements
Member
Member
Posts: 97
Joined: Thu Jul 14, 2022 9:45 am
Contact:

Re: Argument passing

Post by WinExperements »

Octocontrabass wrote:Where is your code to add something to the allocated stack?
Here is:

Code: Select all

*(--stack) = (int)argv;
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Argument passing

Post by Octocontrabass »

That looks fine.

After you add that value to the user stack, do you put the user stack pointer back into the stack frame?
WinExperements
Member
Member
Posts: 97
Joined: Thu Jul 14, 2022 9:45 am
Contact:

Re: Argument passing

Post by WinExperements »

Octocontrabass wrote:That looks fine.

After you add that value to the user stack, do you put the user stack pointer back into the stack frame?
Ah, yeah i don't update the pointer of stack. Thank now all works fine!
Post Reply