Sign in to follow this  

ASM to = DLL

This topic is 4411 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
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
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

This topic is 4411 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this