Re: Hooking to stop file move(ment)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



by default in C and CPP calling conversions are "cdecl" that means that the
caller will clean stack.
when stdcall is used the calling function (callee) will clean the stack.
This conversion is used by win api functions.

here is an machine code generated when you call cdecl function:

push param1
call Foo
add esp, 4 ; caller is cleaning stack
.....

and when your function is declared as stdcall :
push param1
call Foo ; stack is cleaned in Foo
....

Seems like your hook function was cdecl.

--
[Scherbina Vladimir]


"Civel" <Civel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:36CFE464-C678-489F-9FAF-918C5CAC1AC3@xxxxxxxxxxxxxxxx
> Way to go Marc! You nailed it. Specified __stdcall as the calling
> convention and it worked.
>
> I'm not overly familiar with using different calling conventions and why
> you'd use them. What calling convention is used in the event that you
> don't
> specify one? Why is __stdcall different and why did I need to use it?
>
> Sorry to bombard you further, just interested in finally understanding
> this
> a little better.
>
> Civel
>
> "Marc Sherman" wrote:
>
>> > I've also tried to not call the real MoveFileW function, just
>> > return true from my hook function; unfortunately, that didn't work
>> > either.
>>
>> This sounds like the calling convention of your hook function doesn't
>> match
>> that of MoveFileW which is probably __stdcall.
>>
>> Marc
>>
>>
>>


.



Relevant Pages

  • Re: keyboard/mouse programming
    ... procedure local auto variables (created in a new stackframe each time) ... parameters returned to the calling procedure via pointer (copied into ... "cdecl" calling convention is what's normally used for C on x86. ... "stdcall" is what is normally used for Windows, ...
    (alt.lang.asm)
  • Re: keyboard/mouse programming
    ... procedure local auto variables (created in a new stackframe each time) ... parameters returned to the calling procedure via pointer (copied into ... "And the cdecl calling convention is possibly the worst of the x86 calling ... the caller has to clean up the stack. ...
    (alt.lang.asm)
  • Re: Mixed stdcall and cdecl code
    ... >> convention. ... I link to a 3rd party static library that apparently uses the ... >> errors from the linker until I changed my project settings from stdcall ... The 3rd party did not explicitly declare a calling convention in ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: How to export afunction in class?
    ... but I rarely find that I need stdcall when calling the exported functions of a DLL. ... I'll trade off performance vs. convenience at this level any time, ...
    (microsoft.public.vc.mfc)
  • Re: using the CWegPage.dll
    ... It is using the WINAPI (_stdcall) calling ... > The source code for the DLL is on that page and is in this link to the zip ... >> change the calling convention to that which VB can handle. ... >>> The goal is to put an internet explorer web browswer on my form. ...
    (microsoft.public.vc.language)