Thread: __local_size [msvc 7.1]

  1. #1
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005

    __local_size [msvc 7.1]

    I need someone to explain this to me. As I understand it, __LOCAL_SIZE is the total size of all local variables in a naked function, like the one I've got here:

    _declspec(naked) int StringLen(char* stri)
        int l;
            push    ebp
            mov     ebp, esp
            sub     esp, __LOCAL_SIZE
            mov     esp, ebp
            pop     ebp
            xor     eax, eax
    I'm not sure how many bytes in size an int is on my machine, but I'm certain it's not 204 - my disassembler says otherwise. Is it taking into account stri as well? Or am I misunderstanding it.

    (Yes, I know the function hasn't been written yet.)
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  2. #2
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    I don't actually know, but reading about it you are correct, it's just the size of all local crap.
    I think it should be only the local int.
    Assuming your on x86 an int is a double word, which is 32 bits, 32 < 204. Next time I boot into windows if you still haven't figured it out I'll take a look with a debugger, since this post is only speculation. I hope it's of at least a bit of help.

    A call goes like this:
    Each argument is pushed onto the stack from right to left then call pushes the current ip on the stack and jumps to the location specified. So esp = return address, esp+4 = last arg, so all you should need to subtract from the stack should be your local vars.
    Last edited by valis; 05-06-2006 at 01:28 PM.

Popular pages Recent additions subscribe to a feed