flat assembler
Message board for the users of flat assembler.

Index > Main > how create and modify code into Button and Edit

Author
Thread Post new topic Reply to topic
clemens73



Joined: 21 May 2012
Posts: 3
clemens73 21 May 2012, 07:24
Iam learning flat assembly on win32.
Sad
how assign one proc that use Event OnClick on the Button and Entry EDIT?
Embarassed
Post 21 May 2012, 07:24
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 21 May 2012, 08:15
Take a look at this example. I'm not the author, but you can ask questions:

Code:
format PE GUI 4.0
entry start

include 'win32a.inc'

section '.data' data readable writeable

class     db 'FASMWIN32',0
title     db 'WINDOW',0
classb       db 'BUTTON',0
classe       db 'EDIT',0
classs db 'STATIC',0
textb1       db 'Copy',0
textb2 db 'Clear',0
textg db 'Frame',0
texts db 'Text',0
textc  db 'Clear all',0
errtxt    db 'Error',0
hwnd  dd ?
hwnde   dd ?                    ;Edit box 1
hwnds    dd ?                    ;Edit box 2 (read only)
hwndc        dd ?                    ;Checkbox
text       rb 100
form  db '>;CG5=> D09;>2: %d',0

wc  WNDCLASS 0,WindowProc,0,0,0,0,0,COLOR_BTNFACE+1,0,class
msg  MSG

section '.code' code readable executable

start:

 invoke  GetModuleHandle,0
   mov     [wc.hInstance],eax
  invoke  LoadIcon,0,IDI_APPLICATION
  mov     [wc.hIcon],eax
      invoke  LoadCursor,0,IDC_ARROW
      mov     [wc.hCursor],eax
    invoke  RegisterClass,wc
    cmp     eax,0
       je      error

   ;WS_EX_ACCEPTFILES @07@5H05B >:=C ?>;CG0BL D09;K Drag&Drop
  invoke CreateWindowEx,WS_EX_ACCEPTFILES,class,title,WS_VISIBLE+ WS_SYSMENU,128,128,256,192,0,0,[wc.hInstance],0
     cmp     eax,0
       je      error
       mov     [hwnd],eax
msg_loop:
 invoke  GetMessage,msg,0,0,0
        cmp     eax,0
       je      end_loop
    invoke  IsDialogMessage,[hwnd],msg      ; C6=> 4;O >1@01>B:8 A>>1I5=89 >:=C 480;>30
  cmp     eax,0                           ; A;8 C1@0BL, B> ?5@5E>4 <564C >:=0<8
  jne     msg_loop                        ; ?> TAB =5 1C45B >ACI5AB2;OBLAO
  invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
 jmp     msg_loop

error:
  invoke  MessageBox,0,errtxt,0,MB_ICONERROR+MB_OK

end_loop:
       invoke  ExitProcess,[msg.wParam]

proc WindowProc hwnd,wmsg,wparam,lparam
     push    ebx esi edi
 cmp     [wmsg],WM_CREATE
    je      .wmcreate
   cmp     [wmsg],WM_COMMAND
   je      .wmcommand
  cmp     [wmsg],WM_DESTROY
   je      .wmdestroy
  cmp     [wmsg],WM_DROPFILES     ;A;8 :B>-B> GB>-B> Drag&Drop=C;
  je      .drop
  .defwndproc:
 invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
       jmp     .finish
  .wmcreate:
 invoke  CreateWindowEx,0,classb,textg,WS_VISIBLE+ WS_CHILD+ BS_GROUPBOX,5,5,240,150,[hwnd],1000,[wc.hInstance],0
    invoke  CreateWindowEx,0,classb,textb1,WS_VISIBLE+WS_CHILD+ BS_PUSHBUTTON+WS_TABSTOP,20,100,100,40,[hwnd],1001,[wc.hInstance],0
     invoke  CreateWindowEx,0,classb,textb2,WS_VISIBLE+WS_CHILD+ BS_PUSHBUTTON+WS_TABSTOP,130,100,100,40,[hwnd],1002,[wc.hInstance],0
    invoke  CreateWindowEx,0,classe,texts,WS_VISIBLE+WS_CHILD+WS_BORDER+ WS_TABSTOP+ES_AUTOHSCROLL,10,25,230,20,[hwnd],1003,[wc.hInstance],0
    mov     [hwnde],eax
 invoke  CreateWindowEx,0,classe,0,WS_VISIBLE+WS_CHILD+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL+ES_READONLY,10,50,230,20,[hwnd],1004,[wc.hInstance],0
     mov     [hwnds],eax
 invoke  CreateWindowEx,0,classb,textc,WS_VISIBLE+WS_CHILD+ BS_AUTOCHECKBOX+WS_TABSTOP,130,75,110,20,[hwnd],1005,[wc.hInstance],0
    mov     [hwndc],eax
 invoke  CreateWindowEx,0,classs,textg,WS_VISIBLE+ WS_CHILD,190,145,43,15,[hwnd],1006,[wc.hInstance],0
       invoke  SetFocus,[hwnde]
    jmp     .finish
  .wmcommand:
        cmp     [wparam],1001
       je      .but1
       cmp     [wparam],1002
       je      .but2
       jmp     .finish
    .but1:
   invoke  SendMessage,[hwnde],WM_GETTEXT,100,text
     invoke  SendMessage,[hwnds],WM_SETTEXT,0,text
       jmp     .finish
    .but2:
   invoke  SendMessage,[hwnds],WM_SETTEXT,0,0
  invoke  SendMessage,[hwndc],BM_GETCHECK,0,0
 cmp     eax,BST_CHECKED
     jne     .finish
     invoke  SendMessage,[hwnde],WM_SETTEXT,0,0
  invoke  SendMessage,[hwndc],BM_SETCHECK,BST_UNCHECKED,0
     jmp     .finish
  .drop:
     invoke  DragQueryFile,[wparam],-1,text,100      ; >;CG8< 2 EAX :>;-2> D09;>2 (?0@0<5B@ -1)
       invoke  wsprintf,text,form,eax                  ;0?8H5< 2 [text] AB@>:C form
   invoke  SendMessage,[hwnds],WM_SETTEXT,0,text
       invoke  DragQueryFile,[wparam],0,text,100       ; >;CG8< 2 text 8<O D09;0
          invoke  SendMessage,[hwnde],WM_SETTEXT,0,text
       jmp     .finish
  .wmdestroy:
        invoke  PostQuitMessage,0
   mov     eax,0
  .finish:
     pop     edi esi ebx
 ret
endp

section '.idata' import data readable writeable

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

include  'api\kernel32.inc'
include        'api\user32.inc'
include 'api\shell32.inc'
    
Post 21 May 2012, 08:15
View user's profile Send private message Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 206
Location: Brazil
ctl3d32 21 May 2012, 08:54
bzdashek,

Use cinvoke wsprintf,text,form,eax
Post 21 May 2012, 08:54
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 21 May 2012, 12:27
ctl3d32 wrote:
bzdashek,

Use cinvoke wsprintf,text,form,eax

And I was wondering which switched witch spoils my stack

Thank you.
Post 21 May 2012, 12:27
View user's profile Send private message Reply with quote
clemens73



Joined: 21 May 2012
Posts: 3
clemens73 21 May 2012, 14:38
I'll start to study it.
As I can do the online debug on win32?
Post 21 May 2012, 14:38
View user's profile Send private message Reply with quote
clemens73



Joined: 21 May 2012
Posts: 3
clemens73 21 May 2012, 14:40
How to debug online on Flat Asm win32?
Post 21 May 2012, 14:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20409
Location: In your JS exploiting you and your system
revolution 21 May 2012, 14:57
Use OllyDbg
Post 21 May 2012, 14:57
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 22 May 2012, 10:54
What's "debug online"?
Post 22 May 2012, 10:54
View user's profile Send private message Send e-mail Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 22 May 2012, 18:40
AsmGuru62 wrote:
What's "debug online"?

I think it means runtime debug.
Post 22 May 2012, 18:40
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 22 May 2012, 18:46
@clemens73:
You need to use INT3 instruction for that.
Any debugger will stop at the line with INT3.
Post 22 May 2012, 18:46
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 cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.