flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > fasm with IUP toolkit

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
hi there,
i just tried the following, but i still need you guys help.

to set up your environment, try the below suggestions.

1. make sure your fasm in PATH
2. download the mingw32 IUP dll file, http://sourceforge.net/projects/iup/files/3.5/Windows%20Libraries/iup-3.5_Win32_dllw4_lib.zip/download
3. unpack those dll and place them where we want to code our first application.
4. we need to generate INC file from the IUP.DLL, i attach here, you can do it yourself if you want.
5. you can fasm my sample code that come with bug

Code:
format PE GUI 4.0
include 'win32ax.inc'

IUP_CENTER      = 0xFFFF
IUP_CONTINUE = -4
IUP_CLOSE      = -3
IUP_DEFAULT     = -2

.code
start:
     invoke  IupOpen,NULL,NULL
   
    ; controls
  ; --------
  invoke  IupButton,"Sort A-Z","btnAZ"
                    mov     [btnA],eax
  invoke  IupSetCallback,eax,"ACTION",btnA_cb
       invoke  IupButton,"Sort Z-A","btnZA"
                    mov [btnZ],eax
      
    invoke  IupItem,"Open",NULL
                       mov [miOpen],eax
    invoke  IupSetAttribute,eax,"KEY","O"
   invoke  IupSetCallback,[miOpen],"ACTION",miOpen_cb
        
    invoke  IupItem,"Close",NULL
                      mov [miClose],eax
                   
    invoke  IupSetAttribute,eax,"KEY","C"
   invoke  IupMenu,[miOpen],[miClose],NULL
                     mov [menuTopFile],eax
       invoke  IupSubmenu,"File",eax
                     mov [menuTop],eax
   invoke  IupMenu,eax,NULL
                    mov [menuMaster],eax
        invoke  IupSetHandle,"appmenu",eax

    ; layout
    ; ------
    invoke  IupHbox,[btnA],[btnZ],NULL
                  mov     [hboxh],eax

     ; dialog
    ; ------
    invoke  IupDialog,eax
                       mov     [dlgh],eax
  invoke  IupFileDlg
                  mov [fdlgh],eax
                     
    invoke  IupSetAttribute,[dlgh],"SIZE","300X200"
 invoke  IupSetAttribute,[dlgh],"TITLE","IUP toolkit - FASM"
     invoke  IupSetAttribute,[dlgh],"MENU","appmenu"
 invoke  IupShowXY,[dlgh],IUP_CENTER,IUP_CENTER
      invoke  IupMainLoop

     invoke  IupClose
    invoke  ExitProcess,0

; callback procedure
; ------------------
proc btnA_cb uses ebp esi edi, h
       mov eax,IUP_CLOSE
   ret
endp

proc miOpen_cb uses ebp esi edi
  invoke  IupSetAttribute,[fdlgh],"DIALOGTYPE=OPEN"
 invoke  IupPopup,[fdlgh],IUP_CENTER,IUP_CENTER
      invoke  IupMessage,"ok","message"
                       mov eax,IUP_DEFAULT
                 ret
endp


.data
        dlgh            dd 0
        fdlgh           dd 0
        hboxh           dd 0
        btnA            dd 0
        btnZ            dd 0
        
    ; menu variables
    ; --------------
    menuMaster      dd 0
                menuTop         dd 0
                        menuTopFile     dd 0
                                miOpen          dd 0
                                miClose         dd 0
        

section '.idata' import data readable writeable
library    kernel32,       'kernel32.dll',\
         user32,         'user32.dll',\
           msvcrt,         'msvcrt.dll',\
           iup,            'iup.dll'

include 'API\KERNEL32.INC'
include 'API\USER32.INC'
include 'API\MSVCRT.INC'
include 'API\IUP.INC'
    


if everything is fine, you would get a window
i am not really sure the way i code it is correct, calling convention, stack, function parameters count, am not really sure yet.

if you click File > Open, it would open file dialog, but when you exit it, everything will close [bug1]


Description: this is what you would probably get.
Filesize: 5.5 KB
Viewed: 17004 Time(s)

iup.PNG


Description: IUP.INC
Download
Filename: IUP.INC
Filesize: 15.51 KB
Downloaded: 494 Time(s)

Post 17 May 2012, 20:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
There is a good chance that the external DLL uses the C calling convention. I suggest you try using cinvoke to call the functions.
Post 17 May 2012, 22:11
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
thanks revolution,
the bug gone after i change everything to cinvoke Smile
Post 18 May 2012, 04:20
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
download cd-5.5_Win32_dllw4_lib.zip file from sourceforge

http://sourceforge.net/projects/canvasdraw/files/5.5/Windows%20Libraries/Dynamic/

IUP provides the most insane easy method to control your cell sheet like matrix control,

please call
cinvoke IupControlsOpen
after IupOpen


Code:
             cinvoke IupSetAttributes,[mat1],<'NUMCOL="20",NUMLIN="30",NUMCOL_VISIBLE="2",NUMLIN_VISIBLE="3"'>
           cinvoke IupSetAttributes,[mat1],<'1:0="Row 1",2:0="Row 2"'>
             cinvoke IupSetAttributes,[mat1],<'0:1="Column 1",0:2="Column 2"'>
               cinvoke IupSetAttributes,[mat1],<'RESIZEMATRIX="YES",MARKMODE="LINCOL",MULTIPLE="YES",AREA="NOT_CONTINUOUS"'>

    


Description: easy
Filesize: 8.79 KB
Viewed: 16948 Time(s)

matrix.PNG


Post 18 May 2012, 12:53
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 824
Location: Jakarta, Indonesia
TmX
Looks nice. BTW, how did you make the include file?
I remember someone posted a dll to inc (of course in FASM) in this board long ago, but couldn't find it.
Post 18 May 2012, 13:12
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
i use this ETL.EXE

http://board.flatassembler.net/topic.php?t=7647

DLL to INC tools, somebody should stick this tools in win32 section.
Post 18 May 2012, 13:23
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 824
Location: Jakarta, Indonesia
TmX
Ah, yes, that's the one.

Anyway, I tried "etl.exe C:\Windows\System32\msvcrt.dll > msvcrt.inc", the resulting output is empty.

Strange.
Post 18 May 2012, 13:32
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
strange, because i got list of functions using the same etl.exe


* i think the user is required to do a little bit polish job to the output INC file

i updated with the polished one, i think i got it somewhere.


Description: msvcrt.dll functions
Download
Filename: MSVCRT.INC
Filesize: 43.5 KB
Downloaded: 516 Time(s)



Last edited by sleepsleep on 18 May 2012, 14:06; edited 1 time in total
Post 18 May 2012, 13:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
sleepsleep wrote:
i use this ETL.EXE

http://board.flatassembler.net/topic.php?t=7647

DLL to INC tools, somebody should stick this tools in win32 section.
I added it to here: Windows Frequently Asked Questions (FAQ)
Post 18 May 2012, 13:42
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
sometime i think, the search engine in this board is borked, even a search on ETL.exe wouldn't direct to the 7647 thread, doh!

thanks revolution.
Post 18 May 2012, 13:46
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 824
Location: Jakarta, Indonesia
TmX
Anyway, I assembled your code, and got this error:
Quote:

flat assembler version 1.70.01 (1642505 kilobytes memory)
C:\FASM\INCLUDE/API/MSVCRT.INC [2]:
import msvcrt.dll,\
C:\FASM\INCLUDE/macro/import32.inc [31] import [5]:
if used label
error: invalid name.
Post 18 May 2012, 13:49
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Quote:
I remember someone posted a dll to inc (of course in FASM) in this board long ago, but couldn't find it.

Another excellent tool (written by me Very Happy ) for extracting DLL functions and creating import include files is ImportDB.

It supports different import macroses with or without arguments, etc.
It is GUI application and supports SQLite database with the collected information about the DLL's and the exported functions, arguments and more.
Post 18 May 2012, 13:53
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
TmX wrote:
Anyway, I assembled your code, and got this error:
Quote:

flat assembler version 1.70.01 (1642505 kilobytes memory)
C:\FASM\INCLUDE/API/MSVCRT.INC [2]:
import msvcrt.dll,\
C:\FASM\INCLUDE/macro/import32.inc [31] import [5]:
if used label
error: invalid name.


i think you better get madmatt include files pack, come with examples and almost everything that useful.

https://secure.bluehost.com/~flatasse/subdomains/board/topic.php?t=13931
Post 18 May 2012, 14:09
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
i did a csv file data browser using IUP, not complete yet, but able to load CSV file now,

i still have issue when loading file that come with quote (') or double quote (")

i attach my vbscript that generate dummy data,
Quote:

Randomize
For i = 1 to 999999
f1.Write( i )


http://www.sinimari.com/csvdb.zip
(i zipped together with iup required dll file) ( around 1mb )


Description: so far i tested loading 999,999 lines
Filesize: 24.81 KB
Viewed: 16834 Time(s)

CSV.PNG


Description: the magic dummy csv creator
rename to .vbs to start the magic

Download
Filename: createcsv.txt
Filesize: 1.4 KB
Downloaded: 494 Time(s)

Description: the source
Download
Filename: source.zip
Filesize: 4.19 KB
Downloaded: 379 Time(s)

Post 23 May 2012, 13:58
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
anyone could help me with this "double quote" problem?

the data file is like below
Code:
1     Goo'sgle       4.30    8394883
2    Mic\"rosoft       3.5     3838888
3    Dell    2.35    1233455
4    Ac"er      8.7     9983877
5    Hp      1.35    3342245
6    C\\"ompaq        2.3     4445899
    


but the output on my csv viewer is Crying or Very sad


Description: my bug, with double quote
Filesize: 8.61 KB
Viewed: 16806 Time(s)

mybug.PNG


Post 23 May 2012, 19:40
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
A simple comparison will do.

Code:
.if index + 1 < str_len
  .if string[index] == '\' && string[index+1] == '"'
     ;double quote escapement found
  .endif
.endif
    
Post 23 May 2012, 21:15
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
By chance does using the same character twice solves the problem? (e.g. <"> -> <"">)
Post 24 May 2012, 00:02
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
OK, after a bit of testing I couldn't get quotes to work with the function you have used, however the following code shown Micro"soft in the first cell without a problem:
Code:
cinvoke IupSetAttribute,[math], "1:1", "Micro""soft"    
Perhaps it would be better if you use this function instead (which might be even faster since you don't need to be constructing long strings that in turn the UIP engine will have to interpret)
Post 24 May 2012, 04:45
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
ya,, the Iup mailing list also suggest me to use IupSetAttribute,

but i just find it weird why the double quote break in the IupSetAttributes.
Post 24 May 2012, 13:55
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9133
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
ok, i updated my code using the IupSetAttribute, and the double quote problem gone Smile

next is doing sorting,
sort A-Z
sort Z-A
sort by 1-9
sort by 9-1

i think i better do export to csv file from iup matrix control first Cool

Code:
iupmatrixinsingle1         db '%i:%i',0
iupmatrixinsingle2                db '%i:%i = %s',CR,LF,0
; required :
;  [matheapattrib] : buffer for attrib name
proc iupmatrix_insingle math, lns, col, straddr
; ------------------------------------------------------------------------------------------------------------------------
       cinvoke wsprintf,[matheapattrib],iupmatrixinsingle1,[lns],[col]
     cinvoke IupSetAttribute,[math],[matheapattrib],[straddr]
    ;cinvoke        wsprintf,buff,iupmatrixinsingle2,[lns],[col],[straddr]
      ;stdcall        FileWriteLog,buff
   ret
endp
    


Code:
; ------------------------------------------------------------------------------------------------------------------------
proc iupmatrix_csv math,straddr
; ------------------------------------------------------------------------------------------------------------------------
locals
     lns                     dd 1
        col                     dd 1
        strstart        dd 0
endl
        ; loop 1 time to count lns & col
        ; ------------------------------
            mov     esi,[straddr]
                       mov edx,1               ; count lns
                 mov     eax,1           ; count col, select biggest value

                               .while byte [esi] <> 0
                                        .if byte [esi] = 9              ; found tab, increase col
                                           inc     eax
                                 .endif
                                      
                                    .if byte [esi] = CR             ; found CR, change it to TAB, check for biggest col value
                                           mov     byte [esi],9
                                                .if eax > [col]
                                                  mov     [col],eax
                                           .endif

                                          inc     edx                             ; add next line
                                             mov     eax,1                   ; reset col back to 1
                                       .endif
                                      
                                    inc     esi
                         .endw
                       
                            mov     [lns],edx
                           mov     byte [esi],9
                                        inc     esi
                                         mov byte [esi],LF
                                                   inc     esi
                                                         mov byte [esi],0
                            
                            stdcall iupmatrix_autolc,[math],[lns],[col]
                         stdcall iupmatrix_clearall,[math]
                           

                mov     esi,[straddr]
               mov     [strstart],esi
              mov     [lns],1
             mov     [col],1
             .while byte [esi] <> 0
                        .if byte [esi] = 9
                          mov     byte [esi],0            ; put terminator
                            stdcall iupmatrix_insingle,[math],[lns],[col],[strstart]
                                    inc     [col]
                                       mov     [strstart],esi
                                      inc     [strstart]
                  .endif
                      .if byte [esi] = LF
                         inc     [lns]
                               mov     [col],1
                             mov     [strstart],esi
                              inc     [strstart]
                  .endif
                      inc     esi
         .endw
               cinvoke IupSetAttribute,[math],'REDRAW','ALL'
   ret
endp
    


don't laugh my unoptimize code Laughing
Post 25 May 2012, 02:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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.