Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Differentiating between fuction parameter and function variable #18

Open
8thMage opened this issue Jul 20, 2016 · 6 comments
Open

Differentiating between fuction parameter and function variable #18

8thMage opened this issue Jul 20, 2016 · 6 comments

Comments

@8thMage
Copy link

8thMage commented Jul 20, 2016

hello,
i'm trying to parse a pdb in order to write a debugger. i've got the following sample function:
`static void clear(PictureBuffer buffer,unsigned int Color)
{
PictureBuffer a = buffer;
for(int i=0;i<a.height;i++)
{
for(int j=0;j<buffer.width;j++)
{
buffer.picture[i*buffer.pitch+j]=Color;

    }
}

}
`
and you can see in this function 2 instances of PictureBuffer, one of them is passed as a parameter and one is in the function. the function parameter as speced in x64 call convention is passed as a pointer, and the instance in the scope sits as values on the stack
well i've got the hex for the places in the pdb here, and i don't see any difference between the two instances, can you point me to how i can know whether it's a pointer or not?

hex

also, is there a place to ask question about the pdb file format that is not in the github issues section? please point me to it if there is one.
thanks,
the_8th_mage.

@8thMage 8thMage changed the title Hello, Differentiating between fuction parameter and function variable Jul 20, 2016
@AndrewPardoe
Copy link
Contributor

Hey 8thMage, send me mail--it's my firstname.lastname@microsoft.com--and I'll loop you in with the linker dev who can explain these things for you. We've never really documented this area as there are so few people who are interested :-/

@8thMage
Copy link
Author

8thMage commented Jul 21, 2016

I sent it, but you have not responded, please tell if you didn't get it.

@avakar
Copy link

avakar commented Jul 21, 2016

Wouldn't it be better to keep the discussion here? So that other people can benefit from it in the future?

@AndrewPardoe
Copy link
Contributor

@8thMage, I was sleeping :) I sent mail a couple hours ago.

@avakar, email and Skype can be more expedient than GitHub issues. We will roll back anything we've learned or discovered from this conversation to a public forum.

@Dazler
Copy link

Dazler commented Jan 21, 2017

What i think is both the variables are acting as a pointer ..because in memory, u have created only one instance of your image, and first you have stored address of that instance into function parameter and then again into variable used in function, that's why you are not getting any difference in hex places for both variables, since both are pointing to the address of the picture simultaneously.

@skochinsky
Copy link

Yes, the compiler probably reused the incoming argument slot for the local variable (it can do that because you don't use the argument anywhere else) so both point to the same stack location. You can verify by checking the generated assembly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants