1. RE:

> -----Original Message-----
> From: George Papadopoulos [mailto:georgp at otenet.gr]
 
> Does anybody knows how to call a dll routine from asm?
> Dll has been opened from Euphoria, so i have an address.
> I know the offset of the routine from PE header of the file.
> I think Address + Offset falls on start of the routine but the only
> thing i'm sure is that i'm full of invalid page faults.

You can do this, but you'll need to link to LoadLibrary and GetProcAddress
(in kernel32.dll) yourself, and use these functions, rather than open_dll
and define_c_func/proc.  Use LoadLibrary to get the handle of the dll, and
then GetProcAddress to get the pointer to the function:

HINSTANCE LoadLibrary(
    LPCTSTR  lpLibFileName 	// address of filename of executable module 
   );

FARPROC GetProcAddress(
    HMODULE  hModule,	// handle to DLL module  
    LPCSTR  lpProcName 	// name of function 
   );

Once you've done this, you can use the code below (from fptr.e in EuCOM) to
call a function by pointer (actually, any function, including Eu
call_backs).  Then you use call_fptr, passing the pointer to the function as
the first parameter, and the arguments in a sequence.  Note that this only
works with routines declared as stdcall.

-- start code
include machine.e
include misc.e
constant
fptr_asm = {
    #60,                    --    0: pusha
    #BB,#00,#00,#00,#00,    --    1: mov ebx, paramcount (2)
    #B9,#00,#00,#00,#00,    --    6: mov ecx, params (7)
                            --    B: start:
    #8B,#01,                --    B: mov eax, [ecx]
    #50,                    --    D: push eax
    #83,#C1,#04,            --    E: add ecx, 4
    #4B,                    --   11: dec ebx
    #75,#F7,                --   12: jnz start
    #FF,#15,#00,#00,#00,#00,--   14: call dword ptr [comfunc] (22)
    #A3,#00,#00,#00,#00,    --   1A: mov [retpointer], eax (27)
    #61,                    --   1F: popa
    #C3},                   --   20: ret


fptr_paramcount = 2,
fptr_params = 7,
fptr_funcptr = 22+0,
fptr_retptr = 27+0,
retval = allocate(4),

fptr_asm_addr = allocate( length( fptr_asm ) + 20 * 4 )

constant
fptr_func = fptr_asm_addr + 33,
fptr_retval = fptr_asm_addr + 37,
fptr_param_ptr = fptr_asm_addr + 41

poke( fptr_asm_addr, fptr_asm )
poke4( fptr_asm_addr + fptr_funcptr, fptr_func )
poke4( fptr_asm_addr + fptr_params, fptr_param_ptr )
poke4( fptr_asm_addr + fptr_retptr, fptr_retval )

global function call_fptr( atom fptr, sequence params )
    atom ret

    -- store the pointer to the function
    poke4( fptr_func, fptr )

    -- reverse the params for stdcall calling convention
    params = reverse(params)

    -- store the params
    poke4( fptr_param_ptr, params )

    -- tell the asm how many params to push
    poke4( fptr_asm_addr + fptr_paramcount, length(params) )

    -- run the asm
    call( fptr_asm_addr )

    -- get the value returned from the function
    ret = peek4u( fptr_retval )

    return ret
end procedure
-- end code

Matt Lewis

new topic     » topic index » view message » categorize

2. RE:

Igor Kachan wrote:
> Imagine file.exe which you get with DJGPP,
> and DJGPP's **some** functions which are 
> slower than same **some** functions of WATCOM,
> then file.exe you get with WATCOM will be
> faster, and ever ex.exe file.ex may be
> faster than that DJGPP's file.exe above.
> 
> All these things about slower/faster 
> require the very careful testing on 
> monotask OS, for example in plain Dos-32
> mode.
> 
> Binded .exe, not compiled, may be 'more'
> fast than just ex.exe file.ex.
> 
> Also these things are depending from the 
> amount of free memory on your machine in 
> the concrete session, and are random in 
> the most cases.
> 
> Try carefully another programs, not EU's,
> and you'll get same random results.
> 
 
I don't understand, if is fastest when uses EX.EXE
why someone uses an EXE file?

thanks



sergio

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

3. RE:

I believe that Win32Lib used clib.e at one time but it no longer does.  
Just download the latest version of Win32Lib from 
http://www.users.bigpond.com/ddparnell/euphoria/euphoria.htm and 
overwrite the existing files in the truegl directory.

-- Brian


Chris wrote:
> 
> 
> Hi
> 
> I need the clib.e in order to run the openGL demo by Daniel Kluss
> 
> Anyone know where to get it, or can you email me a copy please.
> 
> Ta
> 
> Chris
> 
> 
> ---- Message sent via Totalise Webmail - http://www.totalise.co.uk/
>

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

4. RE:

Kat wrote:
> My suggestion is to get a real isp, not AOL or MSN or .NET. Both spend a 
> great deal 
> of time trying to lock in proprietary closed "standards".
> 

.NET is an OS and doesn't exist as an ISP. :) in fact, it doesn't even 
exist as an OS yet :>

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

5. RE:

mistertrik at hotmail.com wrote:
> Hey everyone.
> 
> I am currently creating a game graphics library, glib.e, which
> has heavily optimised sprite drawing capabilities. It's almost

Why don't you just cut and paste all the bitmaps into one
large 256 bitmap in a paint program and then you can create
them all with the same palette.

Bernie

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

6. RE:

Tony Bucholtz wrote:
> I like the idea of library namespacing using the syntax
> "include <library> as <namespace>". I won't bore you by
> repeating all the good reasons already discussed. I'd
> also like the ability to define my own namespace, using
> syntax like "namespace <namespace>" or similar. What I'd
> *really* like to be able to do is something like the
> following:

sounds good, but OOP would fix the problem too ;) it'd be nice, wouldn't 
it? we could have code like:

class aclass
  integer i
end class

aclass a = new aclass()
integer j
j=1
a.i=j

the good thing is we can mix non-OOP code and OOP code. in java, there 
are the simple integer types(though we could widen the category to 
"simple types" so it would include sequences) and object types(like 
their wrapper classes).

another thing would be to add a built-in euphoria_version() function 
that returns a floating-point number. the next version of euphoria could 
have a euphoria_version that returns 2.3.

and one more thing. you used gcc to compile Euphoria for x86 linux 
right? maybe if you got hold of a mac(or a mac emulator and an illegal 
mac ROM ;) and a mac linux distro, you could compile it for 68k and PPC 
macintoshes. i mean, surely a company no matter how small can afford 20 
to 50 $US...unless it's one of those little garage things :)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu