flat assembler
Message board for the users of flat assembler.

Index > Windows > small PE for 4k intro

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
Daemon



Joined: 08 Jul 2003
Posts: 15
Daemon
Code:
include '%include%\win32axp.inc'
entry start
section '.flat' data import readable executable

library kernel32,'KERNEL32.DLL',\
         user32,'USER32.DLL'

 import kernel32,\
        ExitProcess,'ExitProcess'
 import user32,\
        MessageBox,'MessageBoxA'

_message db 'Message',0
_caption db 'Caption',0

start:

        invoke  MessageBox,0,_message,_caption,MB_YESNO
        invoke  ExitProcess, eax

    


it's simple - the 1st section is import+code, prev. import.
(don't know if it will work on WinXP...)
Post 08 Sep 2003, 16:46
View user's profile Send private message Reply with quote
keenin



Joined: 25 Aug 2003
Posts: 33
keenin
Hi,

Daemon, you forgot to add 'code' in that section, didn't you?

Presently I optimized my code not to use large op codes and large memory addresses (data and calls : ) and I saved a lot of bytes.
The main problem is the Windows programming itself: To initialize the window and OpenGL many data has to be moved and many procedures have to be called (sort of calling overhead).
I got the initialization to 2k including some features like configuration data, which is ok.

But I am really glad of Privalov, because he really helped.
Post 08 Sep 2003, 20:48
View user's profile Send private message Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
i see in assembler files

format PE GUI 4.0 DLL

I can complier assembler files to Obj files or Lib files none?

Please help me...

When use invoke GetModuleHandle,0
Post 14 Sep 2003, 07:58
View user's profile Send private message Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
hey do you know about XBM format in assembler .......?


Description:
Filesize: 785 Bytes
Viewed: 4117 Time(s)

ilu.xbm.gif


Post 05 Oct 2003, 07:54
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
XBM in asm? Something like this?
(compile with the line below to produce the xbm file)
fasm x.asm x.xbm


Description: remove .gif
Filesize: 303 Bytes
Viewed: 4105 Time(s)

x.xbm.gif


Description:
Download
Filename: x.asm
Filesize: 1.92 KB
Downloaded: 176 Time(s)


_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 05 Oct 2003, 09:56
View user's profile Send private message Visit poster's website Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
If i want add color in it then how do i do?


Description:
Filesize: 1007 Bytes
Viewed: 3650 Time(s)

i_&_u.gif


Post 06 Oct 2003, 04:00
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
xbm (x bitmap) is black and white (correction, monocrome, you can use any two colors if you write your own reader).
I'd try xpm (x pixmap) for colors, don't remember how to hand code them (they have the same C/C++ format as xbm just iwht some more info), try google for xpm.

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 06 Oct 2003, 04:25
View user's profile Send private message Visit poster's website Reply with quote
hamoz



Joined: 14 Dec 2006
Posts: 29
hamoz
Hello ,

How to handle the xbm file after compiling with fasm

thanks a lot
newbie
Post 13 Feb 2007, 22:39
View user's profile Send private message Reply with quote
hamoz



Joined: 14 Dec 2006
Posts: 29
hamoz
hello,

why does the compiler give an error at that line

( proc WindowProc, hwnd,wmsg,wparam,lparam )

Code:
  format PE GUI 4.0
  entry start

 include '%include%\win32a.inc'

  start:

        mov     esi,user
        mov     edi,wc
        macro   invoke proc,[arg] {common invoke esi+proc-user,arg}
        virtual at edi
        ediwc   WNDCLASS
        end     virtual

        invoke  GetModuleHandle,ebx
        mov     [ediwc.hInstance],eax
        invoke  LoadIcon,0,IDI_EXCLAMATION
        mov     [ediwc.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [ediwc.hCursor],eax
        xor     eax,eax
        mov     [ediwc.style],eax
        mov     [ediwc.lpfnWndProc],WindowProc
        mov     [ediwc.cbClsExtra],eax
        mov     [ediwc.cbWndExtra],eax
        mov     [ediwc.lpszMenuName],eax
        mov     [ediwc.hbrBackground],COLOR_BTNFACE+1
        mov     ebx,_title
        mov     [ediwc.lpszClassName],ebx
        invoke  RegisterClass,edi
        invoke  CreateWindowEx,0,ebx,ebx,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,64,64,127,127,NULL,NULL,[ediwc.hInstance],NULL

        mov     ebx,msg
  msg_loop:
        invoke  GetMessage,ebx,NULL,0,0
        or      eax,eax
        jz      end_loop
        invoke  TranslateMessage,ebx
        invoke  DispatchMessage,ebx
        jmp     msg_loop

  end_loop:
        invoke  ExitProcess,0

proc WindowProc, hwnd,wmsg,wparam,lparam
        enter
        push    esi
        mov     esi,user
        cmp     [wmsg],WM_DESTROY
        je      wmdestroy
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     finish
  wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  finish:
        pop     esi
        return

data import

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

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

  import user,\
         RegisterClass,'RegisterClassA',\
         LoadIcon,'LoadIconA',\
         LoadCursor,'LoadCursorA',\
         CreateWindowEx,'CreateWindowExA',\
         DefWindowProc,'DefWindowProcA',\
         GetMessage,'GetMessageA',\
         TranslateMessage,'TranslateMessage',\
         DispatchMessage,'DispatchMessageA',\
         PostQuitMessage,'PostQuitMessage'

end data

  _title db '1024',0

  msg MSG
  wc WNDCLASS
    
[/quote]
Post 18 Feb 2007, 01:43
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
because you forgot to put "endp" below return.

BTW, if you are not using a really old fasm release then replace "return" with "ret" and remove "enter" otherwise you will get error for those too.
Post 18 Feb 2007, 02:13
View user's profile Send private message Reply with quote
hamoz



Joined: 14 Dec 2006
Posts: 29
hamoz
locodelassembly , I have tried it with different possibilities but I still get error

please help me Crying or Very sad
Post 18 Feb 2007, 03:06
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
Code:
  format PE GUI 4.0
  entry start 

 include '%include%\win32a.inc' 

  start: 
user equ DefWindowProc ; Since the imports related macros doesn't define such label I randomly pick a function of USER32.DLL instead
; Note that choosing the function that produces proc-user = -128..127 most of the time is preferable since it produces shorter encodings
        mov     esi,user
        mov     edi,wc 
        macro   invoke proc,[arg] {common invoke esi+proc-user,arg} 
        virtual at edi 
        ediwc   WNDCLASS 
        end     virtual 

        invoke  GetModuleHandle,ebx 
        mov     [ediwc.hInstance],eax 
        invoke  LoadIcon,0,IDI_EXCLAMATION 
        mov     [ediwc.hIcon],eax 
        invoke  LoadCursor,0,IDC_ARROW 
        mov     [ediwc.hCursor],eax 
        xor     eax,eax 
        mov     [ediwc.style],eax 
        mov     [ediwc.lpfnWndProc],WindowProc 
        mov     [ediwc.cbClsExtra],eax 
        mov     [ediwc.cbWndExtra],eax 
        mov     [ediwc.lpszMenuName],eax 
        mov     [ediwc.hbrBackground],COLOR_BTNFACE+1 
        mov     ebx,_title 
        mov     [ediwc.lpszClassName],ebx 
        invoke  RegisterClass,edi 
        invoke  CreateWindowEx,0,ebx,ebx,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,64,64,127,127,NULL,NULL,[ediwc.hInstance],NULL 

        mov     ebx,msg 
  msg_loop: 
        invoke  GetMessage,ebx,NULL,0,0 
        or      eax,eax 
        jz      end_loop 
        invoke  TranslateMessage,ebx 
        invoke  DispatchMessage,ebx 
        jmp     msg_loop 

  end_loop: 
        invoke  ExitProcess,0 

proc WindowProc, hwnd,wmsg,wparam,lparam 
        push    esi
        mov     esi,user 
        cmp     [wmsg],WM_DESTROY 
        je      wmdestroy 
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] 
        jmp     finish 
  wmdestroy: 
        invoke  PostQuitMessage,0 
        xor     eax,eax 
  finish: 
        pop     esi 
        ret

endp

data import 

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

  import kernel,\ 
         GetModuleHandle,'GetModuleHandleA',\ 
         ExitProcess,'ExitProcess' 

  import user,\ 
         RegisterClass,'RegisterClassA',\ 
         LoadIcon,'LoadIconA',\ 
         LoadCursor,'LoadCursorA',\ 
         CreateWindowEx,'CreateWindowExA',\ 
         DefWindowProc,'DefWindowProcA',\ 
         GetMessage,'GetMessageA',\ 
         TranslateMessage,'TranslateMessage',\ 
         DispatchMessage,'DispatchMessageA',\ 
         PostQuitMessage,'PostQuitMessage' 

end data 

  _title db '1024',0 

  msg MSG 
  wc WNDCLASS    


That works with FASM 1.67.20
Post 18 Feb 2007, 03:51
View user's profile Send private message Reply with quote
hamoz



Joined: 14 Dec 2006
Posts: 29
hamoz
LocoDelAssembly, thanks alot alot Smile

newbie
Post 18 Feb 2007, 14:25
View user's profile Send private message Reply with quote
ACP



Joined: 23 Sep 2006
Posts: 204
ACP
keenin wrote:
Yeah, I already did everything into one section.
Can the dos stuff in PE files be overwritten with data and be used?


You can use the header to store data. Process Image starts with MZ header in memory - use OllyDBG for inspection - however keep in mind that overwriting header in memory or supplying it with wrong data can break something. Fortunately Windows process loader is quite flexible and does not care about most of settings. You can even have parts of PE/COFF header invalid and process will be loaded anyway.
Post 18 Feb 2007, 22:49
View user's profile Send private message Reply with quote
yumka



Joined: 09 Feb 2007
Posts: 38
Location: Tenochtitlan
yumka
But 1024 is really 1,536 bytes, that is 50% bigger!

"Fixed" with FSG to 1005 bytes Very Happy
Post 19 Feb 2007, 17:45
View user's profile Send private message Visit poster's website Reply with quote
yumka



Joined: 09 Feb 2007
Posts: 38
Location: Tenochtitlan
yumka
Also i have seen that Pelles Linker is able to reduce de size of the executable by making some optimisations at linking.
If your demo is size critical, try that option, and compare the size of both files.
Post 19 Feb 2007, 19:33
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
1) Be aware of the fact that FSG puts some code in the header. It is a neat solution, but recent processors have DEP (Data Execution Protection or sth similar) that won't run FSG-packed files.

2) Pelles Linker just merges sections, which in fasm is a trivial task, so Pelles won't help much here Smile
Post 19 Feb 2007, 21:30
View user's profile Send private message Visit poster's website Reply with quote
pierre



Joined: 07 Nov 2004
Posts: 10
pierre
You should try this : http://crinkler.net/
Post 20 Feb 2007, 13:06
View user's profile Send private message Reply with quote
yumka



Joined: 09 Feb 2007
Posts: 38
Location: Tenochtitlan
yumka
upack in my tests is the king of eXe packers

http://wex.cn/dwing/mycomp.htm
Post 20 Feb 2007, 21:06
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Crinkler is a pretty interesting piece of code, by some pretty interesting people. You should look at some of the loonies productions - iirc Aske (Blueberry) made a VM for one of the amiga intros to get it small enough.
Post 21 Feb 2007, 11:30
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:  
Goto page Previous  1, 2, 3  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.