flat assembler
Message board for the users of flat assembler.
Index
> Projects and Ideas > [IDEA] fdasm - FASM decompiler Goto page Previous 1, 2 |
Author |
|
sylwek32 10 Dec 2006, 20:58
has somebody already made a disassembler for fasm which makes compilable code ?
|
|||
10 Dec 2006, 20:58 |
|
vid 10 Dec 2006, 23:30
sylwek: i bet no
|
|||
10 Dec 2006, 23:30 |
|
coconut 11 Dec 2006, 03:56
anyone make a disassembler in fasm itself?
|
|||
11 Dec 2006, 03:56 |
|
kohlrak 11 Dec 2006, 04:08
I havn't read all of this, but the fix to disassembling "mov ax, label-label2" can't be perfect, but instead of placing an address there, it could declare a variable with that address, then comment behind it saying it has no clue how that address was picked. Then some one could use a little intellegence to figure out what it was, but you don't want to make a perfect dissassembler, anyway. It could help some one steal your own code that you worked on for money. Just change a little and claim that you copied their code rather than them copying yours.
|
|||
11 Dec 2006, 04:08 |
|
DOS386 12 Dec 2006, 22:19
..
Last edited by DOS386 on 12 Dec 2007, 06:28; edited 2 times in total |
|||
12 Dec 2006, 22:19 |
|
kohlrak 12 Dec 2006, 22:22
Only the program can be sure what their code is supposed to do, even then, sometimes they do not... No machine can think like a human, in turn, there is no perfect decompiler. All you can do is your best.
|
|||
12 Dec 2006, 22:22 |
|
ATV 14 Dec 2006, 12:08
One source tells more than 1000 word. This tetris example is not for beginners, it has lots of optimize triks inside.
This source can be compile under FASM but it has 28 different bytes compared with original TASM produced tetris.com (example "xor cl,al" = 32 C8 = 30 C1) There are many "mov reg,[ofs2-ofs1]" that are very difficult to suppurt even with interactive disassembler. I was disassembling this side by side with original source. DASM can also disassembly 32bit code (F10 and change code size), but there isn't any windows related information header/calls/macros just pure asm. EDIT: L0167h missed call fixed (i fall into my own trick) Code: ; title Disassembly of file: TETRIS.COM - produced by DASM.EXE v1.02 empty_line equ 9fa0h field equ 0a0a0h Lff00h equ 0ff00h org 0100h L0100h: mov di,empty_line ;Use keys J,K,L,SPACE mov bp,field ;also screen segment mov ah,5fh ;'_' ;mov ah,(fHeight*4-1) L0108h: mov cl,0ah xor cl,al rep stosb xor al,7ch ;'|' dec ah jne L0108h mov ch,01h rep stosb mov al,13h int 10h L011ch: cwd mov di,seed imul ax,[di],24cdh inc ax stosw idiv word [di-2fh] ;idiv word [di+seven-pieceC] xchg dx,ax stosb xchg bx,ax mov ah,[bx+di-0ah] ;mov ah,[bx+di+tblXY-pieceXY] mov al,50h ;'P' L0131h: shr ax,03h je L0158h mov si,ax and al,07h aam 04h add al,03h stosw xchg si,ax mov cl,[bp+si] jcxz L0131h L0144h: sub al,20h ;' ' ;sub al,startCh jcxz L019dh je L0100h ; L014ah: mov ah,00h ;Keyboard - Get keystroke int 16h dec ah jne L0144h mov al,03h int 10h int 20h ;Terminate program L0158h: call L01d9h xchg dx,ax sub dl,[bp-77h] ;sub dl,[bp+score-field+1] L015fh: test dh,dh jns L0165h inc word [bp-78h] ;inc word [bp-78] L0165h = $-01h db 0d6h ;mov dh,dl +hidden dummy setalc L0167h: call L01efh dec dh jg L0167h mov bx,0100h ;move piece down call L01aah jcxz L015fh L0176h: mov di,bx mov cl,0ah L017ah: cmp [bp+di],ch ;is field[di] empty je L0194h inc di loop L017ah L0181h: mov cl,[bp+di+Lff00h] ;mov cl,[bp+di-fieldWidth] mov [bp+di],cl dec di jne L0181h shl ax,1 add [bp-78h],ax ;add [bp+score-field],ax mov cl,dl call L01fah L0194h: inc bh cmp bh,17h jnc L011ch jmp L0176h L019dh: jne L01a1h mov dh,0ffh L01a1h: sub al,4ah ;'J' ;sub al,leftCh-startCh cmp al,03h jnc L01eeh cbw dec ax xchg bx,ax ; L01aah: call L01d9h mov di,si mov cl,04h L01b1h: lodsw test bx,bx jne L01c8h cmp [di-01h],ch ;cmp [di+pieceC-pieceXY],ch je L01d9h xchg al,ah neg ah add ax,[di] sub al,[di+01h] add ah,[di] js L01d9h L01c8h: add ax,bx mov [si+06h],ax ;save newXY(N) xchg di,ax cmp [bp+di],ch ;is field[di] free xchg di,ax jne L01d9h loop L01b1h movsw ;piecxXY(N)=newXY(N) movsw movsw movsw ; L01d9h: mov si,L0267h ;mov si,pieceC-1 lodsw mov al,68h ;'h' aad 02h pusha mov cl,04h L01e4h: xchg di,ax lodsw xchg di,ax xor [bp+di],al ;field[di] xor al loop L01e4h popa mov al,0ah L01eeh: ret ; L01efh: mov ah,01h ;Keyboard - Check for keystroke int 16h je L01f8h call L014ah L01f8h: mov cl,01h ; L01fah: pusha mov ax,[bp-78h] ;mov ax,[bp+score-field] mov bx,000ah mov cl,04h L0203h: cwd div bx pusha xchg cx,ax add al,11h ;add al,(fieldX+12/2)-3 xchg dx,ax add ax,0230h int 10h int 29h ;Dos - Fast console output popa loop L0203h mov si,0b8abh ;field+(fHeight-1)*fWidth+10Bh mov di,0e670h ;((fHeight-1)*320+fieldX)*8 L021bh: mov dx,010ch sub si,dx L0220h: lodsb mov cl,08h pusha mov dl,40h ;'@' mov ah,74h ;'t' L0228h: mov bx,cx mov es,bp push di L022dh: pusha rep stosb popa add di,dx dec bx jne L022dh pop di dec cx push cs seven: pop es ;note: dw 7 db 00h,0e4h ;add ah,ah jnc L0240h adc di,dx L0240h: add al,ah jc L0228h popa add di,cx dec dl jne L0220h sub di,0a60h ;sub di,(320+10+2)*8 jnc L021bh int 1ah mov bl,dl L0255h: int 1ah cmp bl,dl je L0255h popa loop L01fah ret tblXY db 1dh,3dh,3eh,6eh,30h,17h,3ch seed dw 3039h L0267h = $-01h pieceC:
Last edited by ATV on 18 Dec 2006, 08:10; edited 1 time in total |
|||||||||||
14 Dec 2006, 12:08 |
|
rugxulo 15 Dec 2006, 21:05
Not bad, not bad at all. BUT, the .ZIP only contains the .COM, a .BAT to run DASM, plus the tiny .DSM data file, so anybody wanting to download this should copy/paste the source into Notepad, TDE(W), or whatever and SAVE!
P.S. Here's a screenshot, if anyone's curious:
Last edited by rugxulo on 15 Dec 2006, 21:11; edited 1 time in total |
||||||||||
15 Dec 2006, 21:05 |
|
kohlrak 15 Dec 2006, 21:10
I wish i didn't loose my floppy long ago... I don't see any special formatting, so i'm assuming that it would run off of a floppy. (and i might be wrong, the whole ms-dos thing was never explained to me very well...)
EDIT: Heck, the screenshot is bigger than the actual program itself... |
|||
15 Dec 2006, 21:10 |
|
ATV 18 Dec 2006, 08:11
Sorry I have write too little information. Writing is not my best part.
That dsm file is data file for DASM that can be found in first page of this thread. It has code/data tables and labels and comments. Unpack it same dir as DASM and run bat then press F5 to save asm file, so asm file is not needed inside zip. rugxulo, it's almost like steganography, asm file hidden inside data file. Few important keys to use DASM: F1 - Help F4 - Set instruction type code/ascii/data F5 - Save to asm file F6 - Scan file to build label table F9 - Set label Shift+F9 - Set comment F10 - change parameters |
|||
18 Dec 2006, 08:11 |
|
kohlrak 19 Dec 2006, 06:15
Quote: C:\Documents and Settings\Kohlrak\Local Settings\Temporary Internet Files\Conten I woudln't mind having it disassemble to another assembler and then moving it to fasm format, but that's kinda difficult for me. Maybe it's my computer, cause i don't have alot of software installed that others usually use. I'm usually just missing a program or have a setting different or something than everyone else. |
|||
19 Dec 2006, 06:15 |
|
ATV 19 Dec 2006, 13:08
kohlrak, that error tells that windows can't find dasm.exe you should have dasm.exe + dtetris.bat + tetris.com + tetris.dsm all in same directory.
If you don't want to use 7zip or winzip or any other zip handling programs you should create new directory by yourself and copy those 4 files there. Windows own zip handling is not good. PS. You can also copy dasm.exe into your windows directory, so it always availabe. |
|||
19 Dec 2006, 13:08 |
|
kohlrak 19 Dec 2006, 21:36
i did, maybe i did something wrong and didn't notice it, but oh well... I do specifically recal placing them in the same directory.
|
|||
19 Dec 2006, 21:36 |
|
ds316 01 Jan 2007, 09:44
kohlrak wrote: Only the program can be sure what their code is supposed to do, even then, sometimes they do not... No machine can think like a human, in turn, there is no perfect decompiler. All you can do is your best. OllyDbg's analyzing engine is damn good at distinguishing between code/data. And I'm pretty sure that OllyDbg plugins can make use of this engine, so it might be best to do it this way. |
|||
01 Jan 2007, 09:44 |
|
edfed 22 Oct 2007, 20:47
i think a decompiler is an emulator
an emulator translates instructions |
|||
22 Oct 2007, 20:47 |
|
DOS386 22 Oct 2007, 21:54
> i think a decompiler is an emulator
NO. A decompiler translates binary (back) into a higher language, including ASM at worst case. Disassembler is just a decompiler producing ASM output. > an emulator translates instructions NO. An emulator executes them. _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
22 Oct 2007, 21:54 |
|
DOS386 22 Oct 2007, 22:01
> has somebody already made a disassembler for fasm which makes compilable code ?
NOT exactly, but: FAQ Nevertheless, the challenge is not to make compilable code, but understandable and modifiable code ... Here NDISASM, DISTORM and BIEW are not ideal, the famous "IDA" might be marginally better, but it produces horrible MA$M syntax, is not free (?), and dropped DOS support 10 years ago |
|||
22 Oct 2007, 22:01 |
|
edfed 22 Oct 2007, 22:33
to make compilable code i can :
db x,x,x,x,x,x,x db x,x,x,x,x,x,x etc etc... to make modifiable code i need to analyse: where are instructions where are pointers where are datas what are equates what is the memory model what is the size of the datas and creating labels for branchs and calls __________________________________________________________________ to make a good program, you need to know axactlly what you want a long time before editing the first code line _________________________________________________________________ |
|||
22 Oct 2007, 22:33 |
|
penang 04 May 2008, 15:14
Is this project dead?
|
|||
04 May 2008, 15:14 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.