1. exw.exe bugs ?

i have written a program in Euphoria using win32api functions,
but the program stall on the function getmessage used by the while loop
for managing window meassaging. But the problem doesnt' depend on my
error, in fact i have alleged the program (something will appear to you
not clear but it's in construction), the program doesn't work and if you
put trace function immediately before while getmessage loop you will see
program stalling on it, but if you cut the "include file.e" the program
will work, if you will reput the program will return to his strange
behaviour (the program starts and after 2 seconds it leave but exw is
still alive, press ctrl+alt+canc to see). It seems that the line include
file.e create problems. In another program i have a such bug but
euphoria compiler tell me that it's all ok, so i can't imagine what to
do... ( i have tried 2.0 and 2.1 versions of the file exw.exe to run my
prog)
        and now it's time to show you the program, can you help me ?
who i can contact for getting a sure answer, euphoria development staff
? What is their e-mail ?

        stop my long talking that is the program ( cut include file.e
and it will work, i tell you that i run it on my 486 dx2 66 )


include machine.e
include dll.e
include get.e
include file.e
atom user,gdi,winmm,advapi,kernel
user = open_dll("user32.dll")
gdi = open_dll("gdi32.dll")
winmm = open_dll("winmm.dll")
advapi = open_dll("advapi32.dll")
kernel = open_dll("kernel32.dll")
atom RegisterClass, LoadIcon, LoadCursor, GetStockObject, CreateWindow,
PostQuitMessage
atom ShowWindow, UpdateWindow, GetMessage, TranslateMessage,
DispatchMessage
atom DefWindowProc, GetSystemMetrics, CreateMenu, AppendMenu
atom bmp,x,y
RegisterClass = define_c_proc(user, "RegisterClassExA", {C_POINTER})
LoadIcon = define_c_func(user, "LoadIconA", {C_INT, C_INT}, C_INT)
LoadCursor = define_c_func(user, "LoadCursorA", {C_INT, C_INT}, C_INT)
GetStockObject = define_c_func(gdi, "GetStockObject", {C_INT}, C_INT)
CreateWindow = define_c_func(user, "CreateWindowExA", {C_INT, C_INT,
C_INT, C_INT,
                                                       C_INT, C_INT,
C_INT, C_INT,
                                                       C_INT, C_INT,
C_INT, C_INT}, C_INT)
ShowWindow = define_c_proc(user, "ShowWindow", {C_INT, C_INT})
UpdateWindow = define_c_proc(user, "UpdateWindow", {C_INT})
GetMessage = define_c_func(user, "GetMessageA", {C_INT, C_INT, C_INT,
C_INT}, C_INT)
TranslateMessage = define_c_proc(user, "TranslateMessage", {C_INT})
DispatchMessage = define_c_proc(user, "DispatchMessageA", {C_INT})
PostQuitMessage = define_c_proc(user, "PostQuitMessage", {C_INT})
DefWindowProc = define_c_func(user, "DefWindowProcA", {C_INT, C_INT,
C_INT, C_INT}, C_INT)
GetSystemMetrics = define_c_func(user, "GetSystemMetrics", {C_INT},
C_INT)
CreateMenu = define_c_func(user, "CreateMenu", {}, C_LONG)
AppendMenu = define_c_proc(user, "AppendMenuA", {C_INT, C_INT, C_INT,
C_INT})
global function WndProc(atom hwnd, atom imsg, atom wparam, atom lparam)
        if imsg=2 then c_proc(PostQuitMessage, {0})
                       return(0)
        end if
        return c_func(DefWindowProc, {hwnd, imsg, wparam, lparam})
end function
procedure WinMain()
        atom
        ind = allocate(48)
        msg = allocate(40)
        st1 = allocate_string("MemoDay")
        st2 = allocate_string("MemoDay")
        pbmp = allocate_string("MemoDay.bmp")
        x = c_func(GetSystemMetrics, {13})*25
        y = c_func(GetSystemMetrics, {14})*18.75
        indwndproc = call_back(routine_id("WndProc"))
        poke4(ind, 48)
        poke4(ind+4, 3)
        poke4(ind+8, indwndproc)
        poke4(ind+12, 0)
        poke4(ind+16, 0)
        poke4(ind+20, 0)
        poke4(ind+24, c_func(LoadIcon, {0, 32515}))
        poke4(ind+28, c_func(LoadCursor, {0, 32512}))
        poke4(ind+32, c_func(GetStockObject, {0}))
        poke4(ind+36, 0)
        poke4(ind+40, st1)
        poke4(ind+48, c_func(LoadIcon, {0, 32512}))
        c_proc(RegisterClass, {ind})
        hmenu = c_func(CreateMenu, {})
        hmenuitem = c_func(CreateMenu, {})
        c_proc(AppendMenu,
{hmenuitem,1024,2,allocate_string("&Aggiorna")})
        c_proc(AppendMenu,
{hmenuitem,1024,3,allocate_string("&Rimuovi")})
        c_proc(AppendMenu,
{hmenuitem,1024,4,allocate_string("&Conferma")})
        c_proc(AppendMenu, {hmenuitem,1024,5,allocate_string("&Esci")})
        c_proc(AppendMenu,
{hmenu,1040,hmenuitem,allocate_string("&Edit")})
        hmenuite2 = c_func(CreateMenu, {})
        c_proc(AppendMenu,
        c_proc(AppendMenu, {hmenuite2,1024,7,allocate_string("A&bout")})
        c_proc(AppendMenu,
{hmenu,1040,hmenuite2,allocate_string("&Help")})
        hwd = c_func(CreateWindow, {0,st1,st2,#00CF0000,
                                        (c_func(GetSystemMetrics,
{0})-(x/3*2))/2,
                                        (c_func(GetSystemMetrics,
{1})-(y/3*2))/2,
                                        x/3*2,
                                        y/3*2,
                                        0,hmenu,0,0})
        c_proc(ShowWindow, {hwd, 1})
        c_proc(UpdateWindow, {hwd})
        while c_func(GetMessage, {msg,0,0,0}) do
               c_proc(TranslateMessage, {msg})
               c_proc(DispatchMessage, {msg})
        end while
end procedure
WinMain()

new topic     » topic index » view message » categorize

2. Re: exw.exe bugs ?

Flaminio writes:
[.exw program only works when "include file.e" is taken out]

I put your program in a temporary directory.
Then I typed:
       copy \euphoria\include\safe.e machine.e
       exw flaminio.exw

poke4() in safe.e terminated your program at the following line:

  poke4(ind+48, c_func(LoadIcon, {0, 32512}))

earlier you have:
       ind = allocate(48)
That's obviously not enough to allow for 4 bytes to be poked
starting at ind+48. i.e 48,49,50,51
You should allocate at least 52 bytes (or eliminate
the poke into ind+48). When I allocated 52 bytes the program
ran ok. safe.e didn't complain anymore.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://www.RapidEuphoria.com

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

3. Re: exw.exe bugs ?

Rob Craig writes regarding Flaminio's program:
> When I allocated 52 bytes the program
> ran ok. safe.e didn't complain anymore.

There's another "flaky" bug in there somewhere.
I tried a few more combinations and I got it
to hang on GetMessage() in one case.
It has nothing to do with file.e. It's just that by
including file.e or not, you are changing the
memory addresses around. My guess is that
you are not setting up all your C calls exactly right.
Maybe you are not allocating enough space for some
data structure, or you are not initializing all required fields.
safe.e is no longer catching anything, but it can't
catch all such bugs.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://www.RapidEuphoria.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu