flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > [c] call eax

Author
Thread Post new topic Reply to topic
asmrox



Joined: 19 Jan 2008
Posts: 160
asmrox
how do i call eax in c?
Code:
#include <windows.h>
int main(){
GetProcAddress(LoadLibrary("x.dll"),1);
asm("call %eax");
}    


i belive thers a better way.
Post 19 Feb 2008, 08:39
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3043
Location: vpcmipstrm
bitRAKE
Might want to put that return value into something the complier will recognize. Currently, it just assumes to throw it away. Kind of silly to want to (ab)use a HLL at this granularity.

_________________
¯\(°_o)/¯ unlicense.org
Post 19 Feb 2008, 15:01
View user's profile Send private message Visit poster's website Reply with quote
dap



Joined: 01 Dec 2007
Posts: 61
Location: Belgium
dap
Simply use pointers to functions :

Code:
int main (void)
{
   /* defines a pointer to function */
   void (*func)(const char*) = NULL;
   
   /* retrieves the address of the function and assigns it to the pointer */
   func = (void(*)(const char*))GetProcAddress (LoadLibrary ("msvcrt.dll"), "puts");
   
   /* calls the function through the pointer */
   func ("pouet");
   
   return 0;
}    


You may skip the list of parameters in the cast I guess.

_________________
(French only) http://dap.developpez.com
Post 19 Feb 2008, 17:17
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.