Sign in to follow this  
alex32

ASM to = DLL

Recommended Posts

alex32    122
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
LessBread    1415
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
bakery2k1    712
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
CloudNine    224
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
alex32    122
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

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