flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > contest: Find 10 differences (solved by Walter)

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 157
Location: Russian Federation, Sochi
In attachment masm32 and fasm generated exes.
Fasm exe work no so like it should. Question - Why?
All sources, Exes, IDA listing, & IDA generated asm for both version.

And besides I find bug in my previous dialogitemex macro: item ID not aligned after by 4 byte border, it is trully dword value, (in simple dialogitem ID is word value).


Description:
Download
Filename: SYSIMAGES.zip
Filesize: 43.59 KB
Downloaded: 61 Time(s)


_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 11 Aug 2017, 10:15; edited 1 time in total
Post 10 Aug 2017, 15:16
View user's profile Send private message Send e-mail Reply with quote
YONG



Joined: 16 Mar 2005
Posts: 8000
Location: 22° 15' N | 114° 10' E
Do you offer a monetary prize, for example, 1 Bitcoin, for the contest? Rolling Eyes

If yes, I am interested; otherwise, I will pass.

Wink
Post 11 Aug 2017, 01:55
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 157
Location: Russian Federation, Sochi
Well, I`ll continue to look for mistake my own. Binary almost identical. I will share with result when it will be solved.
Post 11 Aug 2017, 05:34
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 157
Location: Russian Federation, Sochi
I make patcher based on fasmg: for simplify patching (to avoid fixies in headers and for reasons not creating from patcher disassembler) there is only 1 condition: original source take same or more place then patched.
Code:
include 'CPU_SPEC\x86\OPCODESET\p6.inc' include 'CPU_SPEC\x86\opcodeextender.inc' include 'ABI\x86\PROC.INC' use32 macro align boundary,value:? db (boundary-1)-($+boundary-1) mod boundary dup value end macro file 'MASM32sysimgs.exe' ;rename binary as 'testFG.exe' load __PE:dword from $3C ;procedure portable noneeded in solving virtual addres of it load __ImageBase:dword from __PE+$34 ; -z- ;include 'FUNDAMENTALS\MACROS\LISTING.INC' virtual at __ImageBase+$11C4 ; -z- proc udw2str uses ecx edx edi,usrc,destbuffer xor edx,edx mov eax,[usrc] mov edi,[destbuffer] add edi,5 mov ecx,10 cicle0: mov [edi],dl dec edi xor edx,edx div ecx add dl,'0' cmp edi,[destbuffer] jae cicle0 ret endp align $10,$90 patchsz = $-$$ load patch:patchsz from $$ dd udw2str ; force use of symbol end virtual store patch:patchsz at $5C4


So, I patched peace of code udw2str common variant in original file with my one.
Program not became unworked. Degree of binary identity is increased. However fasm variant still work no so like it should.
Post 11 Aug 2017, 09:47
View user's profile Send private message Send e-mail Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 128
If what you are not seeing are the bitmaps, icons and cursors from the fasm version, try using the compiled masm res file.


Code:
section '.rsrc' data readable resource from 'SystImages_rc.RES'
Post 11 Aug 2017, 09:55
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 157
Location: Russian Federation, Sochi
You win Walter. Code is clear. Bug in resources.
Code:
section '.rsrc' resource data readable file 'SystImages.exe':$C00,$400 ; all now work as in original.


I initialy afraid that bug in macros, but actualy I missed to define flag bit LBS_NOTIFY.

so, correct workable fullsource (I moved back to simple dialog version because even it is enough):
Code:
format PE GUI 4.0 ; from WASM.RU, author TheSvin© entry start include 'win32ax.inc' IDD_DLG1 = 1 IDC_LST1 = 10 IDC_LST2 = 11 IDC_LST3 = 12 IDC_IMG1 = 20 IDC_IMG2 = 21 IDC_IMG3 = 22 IDC_EDT1 = 13 section '.text' code readable executable start: invoke GetModuleHandle,0 invoke DialogBoxParam,eax,IDD_DLG1,HWND_DESKTOP,DlgProc,0 invoke ExitProcess,eax proc DlgProc uses ebx esi edi, hwnd,umsg,wparam,lparam mov eax, [umsg] cmp eax, WM_CLOSE je .wmclose cmp eax, WM_INITDIALOG je .wminitdialog cmp eax, WM_COMMAND je .wmcommand cmp eax, WM_VKEYTOITEM je .wmvkeytoitem xor eax,eax jmp .ret .wmclose: invoke EndDialog, [hwnd], eax jmp .ret .wminitdialog: mov ebx,IDC_LST1 @@: invoke GetDlgItem, [hwnd], ebx mov [hListBoxes+ebx*4-IDC_LST1*4], eax inc ebx cmp ebx,IDC_LST3 jbe @B xor edi,edi @@: mov ebx,32000 mov esi,[Procs+edi*4] .nextcall: stdcall dword [esi], 0, ebx test eax,eax je .nextid push eax stdcall udw2str,ebx,number invoke SendMessage,[hListBoxes+edi*4],LB_ADDSTRING,0,number pop ecx invoke SendMessage,[hListBoxes+edi*4],LB_SETITEMDATA,eax,ecx .nextid: cmp ebx,32999 inc ebx jc .nextcall inc edi jnp @B xor eax,eax inc eax jmp .ret .wmcommand: mov eax,[wparam] cmp eax,2 mov ebx,eax je .wmclose and ebx,0FFFFh ; ebx = loWORD(wparam) _ctrl_ID shr eax,16 ; eax = hiWORD(wparam) - notify_msg sub ebx,IDC_LST1 cmp ebx,3 jnb .ret cmp eax,LBN_DBLCLK .vk: mov esi,[SendMessage] mov edi,[lparam] je .dblclk cmp eax,LBN_SELCHANGE jne .ret stdcall esi,edi,LB_GETCURSEL,0,0 cmp eax, [bmSelected+ebx*4] je .ret mov [bmSelected+ebx*4],eax stdcall esi,edi,LB_GETITEMDATA,eax,0 lea ecx,[ebx+IDC_IMG1] invoke SendDlgItemMessage,[hwnd],ecx,STM_SETIMAGE,ebx,eax jmp .ret .dblclk: stdcall esi,edi,LB_GETCURSEL,0,0 stdcall esi,edi,LB_GETTEXT,eax,[ApiNum+ebx*4] invoke SetDlgItemText,[hwnd],IDC_EDT1,[ApiTxt+ebx*4] or eax,-2 jmp .ret .wmvkeytoitem: or eax,-1 cmp word [wparam],VK_SPACE jne .ret xor ebx,ebx mov eax,[lparam] @@: cmp eax,[hListBoxes+ebx*4] lea ebx,[ebx+1] jne @B dec ebx cmp eax,eax jmp .vk .ret: ret endp proc udw2str usrc,destbuffer push ecx edx edi xor edx,edx mov eax,[usrc] mov edi,[destbuffer] add edi,5 mov ecx,10 @@: mov [edi],dl dec edi xor edx,edx div ecx add dl,'0' cmp edi,[destbuffer] jae @B pop edi edx ecx ret endp section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include 'API/KERNEL32.INC' include 'API/USER32.INC' section '.data' data readable writeable bmpApi db 'invoke LoadBitmap,0,' bmpNum db 6 dup (0) icoApi db 'invoke LoadIcon,0,' icoNum db 6 dup (0) curApi db 'invoke LoadCursor,0,' curNum db 6 dup (0) bmSelected dd -1 icoSelected dd -1 curSelected dd -1 Procs dd LoadBitmap,LoadIcon,LoadCursor ApiTxt dd bmpApi,icoApi,curApi ApiNum dd bmpNum,icoNum,curNum align 16 hListBoxes dd 3 dup (?) number db 6 dup (?) section '.rsrc' resource data readable directory RT_DIALOG,dialogs resource dialogs,\ IDD_DLG1,LANG_ENGLISH+SUBLANG_DEFAULT,predefimgids dialog predefimgids,,'System resources by TheSvin©',6,6,170,179,WS_VISIBLE or WS_SYSMENU or WS_MINIMIZEBOX or WS_DLGFRAME or WS_BORDER or DS_CENTER or DS_SETFONT dialogitem 'LISTBOX',,IDC_LST1,6,60,52,92,WS_VISIBLE or WS_VSCROLL or WS_BORDER or WS_TABSTOP or WS_CHILD or LBS_WANTKEYBOARDINPUT or LBS_NOINTEGRALHEIGHT or LBS_HASSTRINGS or LBS_NOTIFY,WS_EX_DLGMODALFRAME or WS_EX_CLIENTEDGE dialogitem 'LISTBOX',,IDC_LST2,58,60,52,92,WS_VISIBLE or WS_VSCROLL or WS_BORDER or WS_TABSTOP or WS_CHILD or LBS_WANTKEYBOARDINPUT or LBS_NOINTEGRALHEIGHT or LBS_HASSTRINGS or LBS_NOTIFY,WS_EX_DLGMODALFRAME or WS_EX_CLIENTEDGE dialogitem 'LISTBOX',,IDC_LST3,110,60,52,92,WS_VISIBLE or WS_VSCROLL or WS_BORDER or WS_TABSTOP or WS_CHILD or LBS_WANTKEYBOARDINPUT or LBS_NOINTEGRALHEIGHT or LBS_HASSTRINGS or LBS_NOTIFY,WS_EX_DLGMODALFRAME or WS_EX_CLIENTEDGE dialogitem 'STATIC','Bitmaps',-1,10,48,44,9,WS_VISIBLE or WS_CHILD or SS_CENTER dialogitem 'STATIC','Icons',-1,62,48,46,10,WS_VISIBLE or WS_CHILD or SS_CENTER dialogitem 'STATIC','Cursors',-1,116,48,40,9,WS_VISIBLE or WS_CHILD or SS_CENTER dialogitem 'STATIC','',IDC_IMG1,8,5,49,36,WS_VISIBLE or WS_CHILD or SS_CENTERIMAGE or SS_BITMAP dialogitem 'STATIC','',IDC_IMG2,72,14,21,19,WS_VISIBLE or WS_CHILD or SS_CENTERIMAGE or SS_ICON dialogitem 'STATIC','',IDC_IMG3,124,14,21,19,WS_VISIBLE or WS_CHILD or SS_CENTERIMAGE or SS_ICON dialogitem 'EDIT','select item and press spacebar',IDC_EDT1,6,158,156,14,WS_VISIBLE or WS_CHILD or SS_REALSIZEIMAGE,WS_EX_CLIENTEDGE enddialog
Post 11 Aug 2017, 10:15
View user's profile Send private message Send e-mail Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 128
ProMiNick,

Can you post your dialogex and dialogitemex macros?
Post 11 Aug 2017, 20:24
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 157
Location: Russian Federation, Sochi
Code:
ANSl_CHARSET = 0 DEFAULT_CHARSET = 1 SYMBOL_CHARSET = 2 MAC_CHARSET = 77 SHIFTJIS_CHARSET = 128 HANGEUL_CHARSET = 129 HANGUL_CHARSET = 129 JOHAB_CHARSET = 130 GB2312_CHARSET = 134 CHINESEBIG5_CHARSET = 136 GREEK_CHARSEO = 161 TURKISH_CHARSET = 162 VIETNAMESE_CHARSET = 163 HEBREW_CHARSET = 177 ARABIC_CHARSET = 178 BALTIC_CHARSET = 186 THAI_CHARSET = 222 EASTEUROPE_CHARSET = 238 RUSSIAN_CHARSET = 204 OEM_CHARSET = 255 macro dialogex label,class,title,x,y,cx,cy,style,exstyle,menu,helpID,fontname,fontsize,fontweight,italic,charset { local data,size,items label dd RVA data,size,0,0 align 16 ; align should be here - I found it with help of exloring example described in that post data dw 1,0FFFFh dd helpID+0 dd exstyle+0,style+0 dw items,x,y,cx,cy menudone = 0 match ,menu \{ dw 0 menudone = 1\} match any =, more,menu \{ du menu,0 menudone = 1\} if menudone else if menu eqtype '' if menu eq '' dw 0 else du menu,0 end if else if ~menu dw 0 else dw 0FFFFh,menu end if end if classdone = 0 match ,class \{ dw 0 classdone = 1\} match any =, more,class \{ du class,0 classdone = 1\} if classdone else if class eqtype '' if class eq '' dw 0 else du class,0 end if else if ~class dw 0 else dw 0FFFFh,class end if end if titledone = 0 match ,title \{ titledone = 1\} match any =, more,title \{ du title titledone = 1\} if ~titledone & title eqtype '' if ~title eq '' du title ;,0 from common case below end if end if dw 0 ;fontweight=0..1000; 0=default=400; bold = 700 if style and DS_SETFONT ;or DS_SHELLFONT=DS_SETFONT or DS_FIXEDSYS if fontname eq dw 8,400 db italic+0 if charset eq db 1 else db charset end if du 'MS Sans Serif',0 else dw fontsize+0,fontweight+0 db italic+0 if charset eq db 1 else db charset end if du fontname,0 end if end if align 4 dialog_size equ size = $ - data dialog_items equ items = dialog_items_counter dialog_items_counter = 0 }


Code:
macro dialogitemex class,title,id,x,y,cx,cy,style,exstyle,helpID { align 4 dd helpID+0,exstyle +0,style or WS_CHILD dw x,y,cx,cy dd id ; against dialogitem here ID has dword size if class eq dw 0 else if class eqtype '' if class eq 'BUTTON' dw 0FFFFh,80h else if class eq 'EDIT' dw 0FFFFh,81h else if class eq 'STATIC' dw 0FFFFh,82h else if class eq 'LISTBOX' dw 0FFFFh,83h else if class eq 'SCROLLBAR' dw 0FFFFh,84h else if class eq 'COMBOBOX' dw 0FFFFh,85h else if class eq '' dw 0 else du class,0 end if else if (class and 1Fh) =10 | (class and 1Fh) =16 | (class-(class and 80h))>18h | class<0 .err unsupported classID = class end if dw 0FFFFh,class end if titledone = 0 match ,title \{ dw 0 titledone = 1\} match any =, more,title \{ du title,0 titledone = 1\} if titledone else if title eqtype '' if title eq '' dw 0 else du title,0 end if else if ~title dw 0 else dw 0FFFFh,title end if end if dw 0 ; actualy here isn`t 0 but length of extradata seted by another macro dialog_items_counter = dialog_items_counter + 1 }


xtradata can be added to dialogitem or dialogitemex
enddialog stayed the same for dialog & dialogex
Code:
macro dlgitmxtrdata { local fin store word (fin-$) at $-2 macro enddlgitmxtrdata \{ fin = $ \} } macro enddialog { dialog_items dialog_size }


all macros for fasm1 & for fasmg are in my collaborate package:
https://board.flatassembler.net/topic.php?t=19966

In fasmg ver of macros they even more correct: dialogitem,dlgitmxtrdata,enddialog incapsulated in dialog, ex versions in dialogex.
Post 12 Aug 2017, 00:00
View user's profile Send private message Send e-mail 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 can attach files in this forum
You can download files in this forum


Copyright © 2004-2018, Tomasz Grysztar.

Powered by rwasa.