indirect call with MASM? 
Author Message
 indirect call with MASM?

I have been trying to figure out how to get MASM to assemble an
indirect call.

There is an opcode a 32-bit indirect call.  Some C++ code I've looked
at has used the opcode.

I have gotten close, but always need a register. ie.

mov eax, [foo]
call eax[4]

or something

Is there a way to call without the register? ie.

call [foo+4]

What the above does is just make a call to the address of foo, not the
value contained in foo.

Been working hours on this, any help, thanks.....



Wed, 01 Dec 2004 02:22:13 GMT  
 indirect call with MASM?

Quote:

> I have been trying to figure out how to get MASM to assemble an
> indirect call.

> There is an opcode a 32-bit indirect call.  Some C++ code I've looked
> at has used the opcode.

> I have gotten close, but always need a register. ie.

> mov eax, [foo]
> call eax[4]

> or something

> Is there a way to call without the register? ie.

> call [foo+4]

maybe you need the word ptr:

call word ptr [foo+4]

(in a 32 bit segment you would use dword ptr).

This opcode does exist but I don't remember offhand how to get the
assembler to put it in.

David

- Show quoted text -

Quote:

> What the above does is just make a call to the address of foo, not the
> value contained in foo.

> Been working hours on this, any help, thanks.....



Wed, 01 Dec 2004 04:56:12 GMT  
 indirect call with MASM?

Quote:

> I have been trying to figure out how to get MASM to assemble an
> indirect call.

> There is an opcode a 32-bit indirect call.  Some C++ code I've looked
> at has used the opcode.

> I have gotten close, but always need a register. ie.

> mov eax, [foo]
> call eax[4]

> or something

> Is there a way to call without the register? ie.

> call [foo+4]

> What the above does is just make a call to the address of foo, not the
> value contained in foo.

> Been working hours on this, any help, thanks.....

Try:

  call dword ptr [foor+4]



Wed, 01 Dec 2004 08:56:02 GMT  
 indirect call with MASM?

Quote:


> > I have been trying to figure out how to get MASM to assemble an
> > indirect call.

> > There is an opcode a 32-bit indirect call.  Some C++ code I've looked
> > at has used the opcode.

> > I have gotten close, but always need a register. ie.

> > mov eax, [foo]
> > call eax[4]

> > or something

> > Is there a way to call without the register? ie.

> > call [foo+4]

> > What the above does is just make a call to the address of foo, not the
> > value contained in foo.

> > Been working hours on this, any help, thanks.....

> Try:

>   call dword ptr [foor+4]

Did some more research.  What I'm look for is near indirect call with
address in memory.

P4      TYPEDEF proto :DWORD, :DWORD, :DWORD, :DWORD
PP4     TYPEDEF PTR P4

.data?
        myString SSTRING<>
.code
        lea eax, dword ptr sstring;
        mov myString.handle, eax;  jump dd OFFSET jumphere

        invoke PP4 ptr [myString], ADDR myString, 1,4096, 8192
;now for the dissassembly of the invoke:
00401123 FF 15 A4 43 40 00 call dword ptr [myString (4043A4h)]

The call above will not call 4043A4h but the address contained in
4043A4h

call dword ptr[foo+4] will call the address of foo+4

This will probably have to be done with typedef.  I'm just no good
with typedefs, however.  Thanks.



Wed, 01 Dec 2004 18:55:56 GMT  
 indirect call with MASM?
I solved a similar problem a few years back, but I cannot find it
right now.  If I correctly remember, it depends on your definition of
your FOO, i.e., if FOO is defined as NEAR or FAR, then MASM assembles
the call as a direct call, but if FOO is defined as WORD or DWORD then
MASM assembles an indirect call.

Maybe I am wrong, but it is worth trying. Use the LABEL statement as
follows:

     FOO  LABEL  WORD
          DD     whatever
          DW     OFFSET callee

for a NEAR call, or

     FOO  LABEL  DWORD
          DD     whatever
          DD     callee

for FAR call.

Quote:

> I have been trying to figure out how to get MASM to assemble an
> indirect call.

> There is an opcode a 32-bit indirect call.  Some C++ code I've looked
> at has used the opcode.

> I have gotten close, but always need a register. ie.

> mov eax, [foo]
> call eax[4]

> or something

> Is there a way to call without the register? ie.

> call [foo+4]

> What the above does is just make a call to the address of foo, not the
> value contained in foo.

> Been working hours on this, any help, thanks.....



Thu, 02 Dec 2004 21:56:09 GMT  
 indirect call with MASM?

Quote:


> > Try:

> >   call dword ptr [foor+4]

> Did some more research.  What I'm look for is near indirect call with
> address in memory.

> P4 TYPEDEF proto :DWORD, :DWORD, :DWORD, :DWORD
> PP4        TYPEDEF PTR P4

> .data?
>    myString SSTRING<>
> .code
>    lea eax, dword ptr sstring;
>    mov myString.handle, eax;  jump dd OFFSET jumphere

>    invoke PP4 ptr [myString], ADDR myString, 1,4096, 8192
> ;now for the dissassembly of the invoke:
> 00401123 FF 15 A4 43 40 00 call dword ptr [myString (4043A4h)]

> The call above will not call 4043A4h but the address contained in
> 4043A4h

> call dword ptr[foo+4] will call the address of foo+4

> This will probably have to be done with typedef.  I'm just no good
> with typedefs, however.  Thanks.

No really, try call dword ptr [foo+4].  Or I'm not really
understanding the question.  "foo" dows have to be a pointer (eg  "foo
dd xxx"), and not the name of a routine.


Sat, 04 Dec 2004 06:56:03 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Indirect calls using MASM 6.1 (how?)

2. Q: Interfacing C/ADA: Indirect Calls

3. Help - indirect call

4. indirect function calls and variable variables

5. Indirect function member calls

6. Indirect calls

7. Indirect calls

8. indirect function calls and variable variables

9. Question regarding indirect function calls

10. indirect **keyword calls

11. Calling Microsoft C Function from MASM

12. What's the debugger call in MASM?

 

 
Powered by phpBB® Forum Software