Problem with example for __asm calls  
Author Message
RouL





PostPosted: Visual C++ General, Problem with example for __asm calls Top

I tried the following example from msdn sites:

http://www.hide-link.com/

I've made a new project >> Win32-Consoleapplication
selected empty project
added a blanc file called main.cpp into it and copied the examplecode into it
saved
build project
and started debug for testing it

and i got the following response:

Unhandled Exception at 0x004020a2 in asm_1.exe: 0xC0000005: Access Violation while writing at Position 0x00003010.
(*translated from german to english)

I searched msdn and google for it but found nothing.
Is there Something wrong with the example, or did i forgot something

Environment:
AMD AthlonXP
WinXP Home Edition SP2
MS VC++ 2005 .NET




Visual C++2  
 
 
Mike Danes





PostPosted: Visual C++ General, Problem with example for __asm calls Top

That code only works if you link statically to the C runtime library. By default (and recomended) VC++ 2005 links dynamically to the runtime library so to make it work change the call line to this:

call dword ptr [printf]

Basically with dynamic linking the function name is the address of a variable that contains a pointer to the function and that's why you need an indirect call.


 
 
RouL





PostPosted: Visual C++ General, Problem with example for __asm calls Top

Thanks for fast answer, now it works great and i can continue with coding the real code.
(wanted to test the example before starting with real code)