Jump to content
  • Advertisement
Sign in to follow this  
alex32

ASM to = DLL

This topic is 4627 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, i'm using VC++2003 and , from ASM, i need to pass to the DLL a memory address so that i can read data from there. here is the code but both the options fails to compile since VC says that label IP or EIP do not exist. However i've seen most of the debuggers to refer to the Instruction Pointer as EIP (extended IP) 32bit...so that register should exist in the CPU... Any idea what's wrong ? __asm { // OPTION #1 error: label IP not defined PUSH EDX MOV DX, CS // COPY CODE SEGMENT => DX SHL EDX,16 // shift 16bits => MOVE CS TO MSB MOV EDX, IP // COPY IP TO LSB // CALL TO DLL POP EDX // OPTION #2 error: label EIP not defined PUSH EDX MOV EDX, EIP // CALL TO DLL POP EDX } thanks !

Share this post


Link to post
Share on other sites
Advertisement
Actually, you're not supposed to be able to reference eip directly. The typical approach to directing excution to where you want it to go is through a jmp or call instruction or through a return address.

For example, inside a function but before the stack frame is set up, the return address can be found at [esp], after the stack frame is set up it can be found at [ebp+4].

Share this post


Link to post
Share on other sites
Why would you need to pass eip to the DLL?

Also, note that even if your 2 examples had worked, they wouldn't be equivalent - eip is not the same as (cs << 16) | ip.

Share this post


Link to post
Share on other sites
A rather neat trick is (written in a wierd mesh of Intel and AT&T assembly):


call 1f
1:
pop eax



or something of the ilk. Just like the only way to get the eflags register is to push it on the stack and pop it off again.

Share this post


Link to post
Share on other sites
Thanks all,

My need is to pass to the DLL the actual value of the IP since that is the area where DLL-data will be saved. I thought to do it saving IP into some registers or in the Stack...
The calling stub is in ASM , after few bytes start the DLL-data segment whose address i need to pass to the DLL. I believe that is the easiest way to pass data to the DLL..

thanks !

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!