1. How to get the adress machine of any c_proc()
- Posted by javier07b9 Nov 14, 2013
- 1559 views
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)
2. Re: How to get the adress machine of any c_proc()
- Posted by jimcbrown (admin) Nov 14, 2013
- 1518 views
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.
-- 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)
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.
3. Re: How to get the adress machine of any c_proc()
- Posted by javier07b9 Nov 14, 2013
- 1489 views
Yes, this is a complicated way for call any c_proc(), only i try this for understanding how works Euphoria
4. Re: How to get the adress machine of any c_proc()
- Posted by petelomax Nov 14, 2013
- 1545 views
- Last edited Nov 15, 2013
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
5. Re: How to get the adress machine of any c_proc()
- Posted by mattlewis (admin) Nov 15, 2013
- 1480 views
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