1. How to get the adress machine of any c_proc()

Example :

atom libr 
 
libr = open_dll("mylibrary.dll") 
 
constant proc_00 = define_c_proc(libr,"ini",{}) 
 
c_proc(proc_00,{}) 
-- Now would get the adress machine 32 bits of this c_proc  
-- and then call the proc 
call(proc_00) 
 
new topic     » topic index » view message » categorize

2. Re: How to get the adress machine of any c_proc()

javier07b9 said...

Example :

atom libr 
 
libr = open_dll("mylibrary.dll") 
 
constant proc_00 = define_c_proc(libr,"ini",{}) 
 
c_proc(proc_00,{}) 

This is the correct way to call the proc. This is the only way that you should be doing this.

javier07b9 said...
-- Now would get the adress machine 32 bits of this c_proc  
-- and then call the proc 

You can do so like this:

atom libr 
 
libr = open_dll("mylibrary.dll") 
 
constant proc_00 = define_c_proc(libr,"ini",{}) 
 
c_proc(proc_00,{}) 
-- Now would get the adress machine 32 bits of this c_proc  
-- and then call the proc 
constant proc_00_addr define_c_var(libr,"ini") 
call(proc_00_addr) 
javier07b9 said...
call(proc_00) 
 

But why would you ever want to do this? There are a lot of gotchas and pitfalls to be aware of when doing this.

new topic     » goto parent     » topic index » view message » categorize

3. Re: How to get the adress machine of any c_proc()

Yes, this is a complicated way for call any c_proc(), only i try this for understanding how works Euphoria

new topic     » goto parent     » topic index » view message » categorize

4. Re: How to get the adress machine of any c_proc()

javier07b9 said...

Yes, this is a complicated way for call any c_proc(), only i try this for understanding how works Euphoria

On windows, open_dll and define_c_func are just wrappers for LoadLibrary and GetProcAddress respectively. You can (if you really really really must) do something like

    kernel32 = open_dll("kernel32.dll") 
    xLoadLibrary = define_c_func(kernel32,"LoadLibraryA",{C_PTR},C_PTR) 
    xGetProcAddress = define_c_func(kernel32, "GetProcAddress",{C_PTR,C_PTR},C_PTR) 

and invoke those via c_func to get the raw addresses and play with those directly (strictly for learning purposes only, and may require some assembly code)

Pete

new topic     » goto parent     » topic index » view message » categorize

5. Re: How to get the adress machine of any c_proc()

petelomax said...
javier07b9 said...

Yes, this is a complicated way for call any c_proc(), only i try this for understanding how works Euphoria

You can do something like

    kernel32 = open_dll("kernel32.dll") 
    xLoadLibrary = define_c_func(kernel32,"LoadLibraryA",{C_PTR},C_PTR) 
    xGetProcAddress = define_c_func(kernel32, "GetProcAddress",{C_PTR,C_PTR},C_PTR) 

and invoke those via c_func to get the raw addresses and play with those directly (for learning purposes, and may require some assembly code)

Those aren't necessary in euphoria code (as Jim already mentioned). Just use define_c_var(), which gives you the address of a function or variable in the DLL. The backend uses LoadLibrary and GetProcAddress behind the scenes.

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu