flat assembler
Message board for the users of flat assembler.

Index > Windows > Conversion of Masm to Fasm

Author
Thread Post new topic Reply to topic
shism2



Joined: 14 Sep 2005
Posts: 248
shism2 20 Sep 2005, 01:05
Code:
            ;======================================================================= 
 format PE GUI 4.0 
;format PE CONSOLE 
;======================================================================= 
 include '%fasminc%\win32a.inc'
 include '%fasminc%\macro\if.inc'                                          
;======================================================================= 
IDC_CLOSE      equ 1002
IDC_BACKUP     equ 2001
IDC_CHOOSEFILE equ 1001
IDC_TARGETFILE equ 1000
IDD_MAINDLG    equ 100
IDI_ICON        equ 9000
;----------------------------------------------------------------------- 
section '.flat' code readable writeable executable 

entry $ 



    invoke GetModuleHandle,0
        mov [gIst],eax
        invoke DialogBoxParam,eax,IDD_MAINDLG,0, DlgProc,0
    
THEEND:
        invoke ExitProcess,0

proc DlgProc, hDlg, uMsg, wParam, lParam
        
       
push edi esi ebx
    
           
        je      jCOMMAND 
        .if [uMsg],e,WM_INITDIALOG 
        je      jINITDIALOG 
        .endif
        
        .if [uMsg],e,WM_CLOSE
        je      jCLOSE 
        .endif
        
      mov       eax, [wParam]

        .if ax,e,IDC_CLOSE
        invoke ExitProcess,0
        
        .elseif ax,e,IDC_CHOOSEFILE <-------- This is what I dont know how 
          mov ofn.lStructSize,SIZEOF ofn 
              mov ofn.lpstrFilter, szFilter
              push hDlg
              pop ofn.hwndOwner
              mov ofn.lpstrFile, cFname 
              mov ofn.nMaxFile,SIZEOF cFname
              mov ofn.lpstrInitialDir, szCurDir
              mov ofn.Flags, OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST or OFN_LONGNAMES or OFN_HIDEREADONLY
              push  ofn
              call GetOpenFileName
              test eax,eax
              jz @@ExitDlgProc
              invoke SetDlgItemText,hDlg,IDC_TARGETFILE,offset cFname  
        .endif
         ; ---- build the protection flag -----
          xor edi,edi
              invoke IsDlgButtonChecked,[hDlg],IDC_BACKUP
              .if eax,e,BST_CHECKED
                 invoke CopyFile,cFname,backup1,0 
                 
                 
              .endif
        
        
        
        xor eax,eax
        
        jmp finish 
       
       
       
       
       
jINITDIALOG: 

       invoke LoadIcon,[gIst],IDI_ICON
           invoke SendMessage,[hDlg],WM_SETICON,TRUE,eax

        mov eax,[hDlg] 
        mov [gWnd],eax 
        mov eax,1 
        jmp finish 
         
jCOMMAND: 
        mov eax,[wParam] 
       .if eax,e,1000 
        je      a1000
        .endif 
        xor eax,eax 
        jmp finish 
         
a1000: 
        invoke SendMessage,[hDlg],WM_CLOSE,0,0 
        mov eax,1 
        jmp finish 
         
jCLOSE:  
     invoke EndDialog,[hDlg],NULL
    
         
finish: 
        pop ebx esi edi 
        ret
endp 

; .DATA
cFname                  db MAX_PATH dup (0)
backup1 db 'Backup.exe',0
ofn                     OPENFILENAME <>


gIst dd 0 
gWnd dd 0 
szFilter                db "ExE files",0,"*.exe",0,"All files",0,"*.*",0,0  

data import 




library kernel, 'KERNEL32.DLL',\ 
          user,   'USER32.DLL' 

  import  kernel,\ 
          GetModuleHandle,'GetModuleHandleA',\
          CopyFile,'CopyFileA',\ 
          ExitProcess,    'ExitProcess' 
          
  import  user,\ 
          DialogBoxParam, 'DialogBoxParamA',\ 
          EndDialog,      'EndDialog',\
          LoadIcon,       'LoadIconA',\
          MessageBox,     'MessageBoxA',\
          IsDlgButtonChecked, 'IsDlgButtonChecked',\
          SendMessage,    'SendMessageA' 

end data 


section '.rsrc' resource from 'rsrc1.res' data readable     



Help would be appreciated Smile
Post 20 Sep 2005, 01:05
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 20 Sep 2005, 05:32
try this:

mov ofn.lStructSize,SIZEOF ofn >
mov [ofn.lStructSize],sizeof.OPENFILENAME

mov ofn.lpstrFilter, szFilter > mov [ofn.lpstrFilter], szFilter
...

if size of ofn is unknown to compiler (you create it with other way) it is possible do this:
mov [ofn + OPENFILENAME.lpstrFilter], szFilter
Post 20 Sep 2005, 05:32
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2 20 Sep 2005, 20:53
Sigh none of them worked Sad
Post 20 Sep 2005, 20:53
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2 20 Sep 2005, 23:02
C:\Documents and Settings\Owner\Desktop\crap\fasmexp\flatpe.asm [21]:
mov [ofn.lStructSize], sizeof.OPENFILENAME
error: undefined symbol.

Maybe im missing an include file or something?
Post 20 Sep 2005, 23:02
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 21 Sep 2005, 03:47
some parts of code are stripped, because i can't understand what you do

Code:
format pe gui 4.0 
entry start

;======================================================================= 
include '%fasminc%\win32a.inc'
;======================================================================= 

IDC_CLOSE               = 1002
IDC_BACKUP              = 2001
IDC_CHOOSEFILE          = 1001
IDC_TARGETFILE          = 1000
IDD_MAINDLG             = 100
IDI_ICON                = 9000

;----------------------------------------------------------------------- 

section '.idata' data readable writeable

  backup1       db "Backup.exe",0
  szFilter      db "ExE files",0,"*.exe",0,"All files",0,"*.*",0,0  

section '.udata' readable writeable

  gIst          dd ?
  gWnd          dd ?
  cFname        rb MAX_PATH
  ofn           OPENFILENAME

section '.flat' code readable writeable executable 

  start:
        invoke  GetModuleHandle,0
        mov     [gIst],eax
        invoke  DialogBoxParam,eax,IDD_MAINDLG,0,DlgProc,0
    
  THEEND:
        invoke ExitProcess,0

  proc DlgProc uses ebx esi edi, hDlg, uMsg, wParam, lParam
        
        movzx   eax,word [wMsg]
        cmp     ax,WM_COMMAND
        jz      .wmcommand
        cmp     ax,WM_CLOSE
        jz      .wmclose
        cmp     ax,WM_INITDIALOG
        jnz     .not_processed
        
  ;.wminitdlg:
        invoke  LoadIcon,[gIst],IDI_ICON
        invoke  SendMessage,[hDlg],WM_SETICON,TRUE,eax
        mov     eax,[hDlg] 
        mov     [gWnd],eax 
        jmp     .processed
        

  .wmcommand:
        cmp     [wParam],BN_CLICKED shl 16 + IDC_CLOSE ; <- resource id (control)
        jz      .wmclose
        cmp     [wParam],BN_CLICKED shl 16 + IDC_CHOOSEFILE ; <- resource id (control)
        jnz     .processed

        mov     [ofn.lStructSize],sizeof.OPENFILENAME
        mov     [ofn.lpstrFilter],szFilter
        push    [hDlg]
        pop     [ofn.hwndOwner]
        mov     [ofn.lpstrFile],cFname 
        mov     [ofn.nMaxFile],MAX_PATH
        ;mov    [ofn.lpstrInitialDir],szCurDir ; <- not defined
        mov     [ofn.Flags],OFN_FILEMUSTEXIST+OFN_PATHMUSTEXIST+OFN_LONGNAMES+OFN_HIDEREADONLY
        invoke  GetOpenFileName,ofn
        test    eax,eax
        jz      @F
        invoke  SetDlgItemText,[hDlg],IDC_TARGETFILE,cFname  
  @@:
        jmp     .processed
       
  .wmclose:  
        invoke  EndDialog,[hDlg],NULL

  .processed:
        xor     eax,eax
        inc     eax
        jmp     .finish

  .not_processed:
        xor     eax,eax
         
  .finish: 
        ret
  endp 

section '.idata' import data readable writeable

  library       kernel32,'kernel32.dll',\
                user32,'user32.dll'

  include       '%fasminc%\apia\kernel32.inc'
  include       '%fasminc%\apia\user32.inc'

section '.rsrc' resource from 'rsrc1.res' data readable 

; eof
    

_________________
[not enough memory]
Post 21 Sep 2005, 03:47
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2 21 Sep 2005, 05:17
I got i reinstalled fasm include files and now i get this

C:\Documents and Settings\Owner\Desktop\crap\fasmexp\flatpe.asm [20]:
cFname db MAX_PATH dup (0)
error: undefined symbol.


Last edited by shism2 on 21 Sep 2005, 05:22; edited 1 time in total
Post 21 Sep 2005, 05:17
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 21 Sep 2005, 05:21
example


Description:
Download
Filename: shism.zip
Filesize: 3.22 KB
Downloaded: 356 Time(s)


_________________
UNICODE forever!
Post 21 Sep 2005, 05:21
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2 21 Sep 2005, 05:31
Where can I get shlwapi.inc?
Post 21 Sep 2005, 05:31
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 21 Sep 2005, 05:40
oh, sorry Smile it's my template Smile through it off - it is not needed here Wink there are a lot of dll->inc around a forum to make such things Wink
Post 21 Sep 2005, 05:40
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 21 Sep 2005, 05:45
Quote:

MAX_PATH

- is not defined in fasm includes - define it by yourself (=260)
Post 21 Sep 2005, 05:45
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 21 Sep 2005, 05:56
here same but in pure fasm and without shlwapi.inc


Description:
Download
Filename: shism2.zip
Filesize: 1.99 KB
Downloaded: 357 Time(s)


_________________
UNICODE forever!
Post 21 Sep 2005, 05:56
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2 21 Sep 2005, 06:12
wow thanks alot..Your very helpful and my new TEACHER Laughing Wink
Post 21 Sep 2005, 06:12
View user's profile Send private message Reply with quote
mrpink



Joined: 03 Jun 2005
Posts: 27
Location: Germany
mrpink 30 Sep 2005, 06:50
Wouldn' t if be good to have a masm --> fasm source translator?

Or more generally a source to source translator that takes as input
source code from one assembler and outputs the source code
for another assembler?
Post 30 Sep 2005, 06:50
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 30 Sep 2005, 07:06
there is a masm.inc to support masm syntaxis. it is not too easy in real to make a good converter, and i prefer to use matching compiler to the ready source.
Post 30 Sep 2005, 07:06
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.