Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Program se rusi... ne vidim gresku

[es] :: Asembler :: Program se rusi... ne vidim gresku

[ Pregleda: 3564 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

de_c0der

Član broj: 127698
Poruke: 107
*.adsl.net.t-com.hr.



Profil

icon Program se rusi... ne vidim gresku30.12.2006. u 17:45 - pre 209 meseci
Evo koda:

Pravio sam ga u MASM32-u, namjerno nisam koristio windows.inc, user32.inc i invoke-like pozive:
Code:

.386
.model flat, stdcall
option casemap:none




includelib ..\lib\kernel32.lib
includelib ..\lib\user32.lib


MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
ExitProcess PROTO uExitCode:DWORD
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
GetModuleHandleA PROTO :DWORD
LoadIconA PROTO :DWORD,:DWORD
LoadCursorA PROTO :DWORD,:DWORD
RegisterClassA PROTO :DWORD
CreateWindowExA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ShowWindow PROTO :DWORD,:DWORD
UpdateWindow PROTO :DWORD
GetMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORD
TranslateMessage PROTO :DWORD
DispatchMessageA PROTO :DWORD
DefWindowProcA PROTO :DWORD,:DWORD,:DWORD,:DWORD
PostQuitMessage PROTO :DWORD




;tipovi varijabli
;novo ime---------vec postojece
HINSTANCE typedef DWORD
LPSTR     typedef DWORD
HWND      typedef DWORD
LPARAM    typedef DWORD
WPARAM    typedef DWORD
UINT      typedef DWORD


;konstante
SW_SHOWNORMAL     equ 1
IDI_APPLICATION   equ 32512
IDC_ARROW         equ 32512
CS_HREDRAW        equ 2h
CS_VREDRAW        equ 1h
COLOR_WINDOW      equ 5
WS_OVERLAPPEDWINDOW  equ 0CF0000h
TRUE              equ 1
FALSE             equ 0
NULL              equ 0
WM_DESTROY        equ 2h

;strukture
WNDCLASSEX STRUCT
  cbSize            DWORD      ?
  style             DWORD      ?
  lpfnWndProc       DWORD      ?
  cbClsExtra        DWORD      ?
  cbWndExtra        DWORD      ?
  hInstance         DWORD      ?
  hIcon             DWORD      ?
  hCursor           DWORD      ?
  hbrBackground     DWORD      ?
  lpszMenuName      DWORD      ?
  lpszClassName     DWORD      ?
  hIconSm           DWORD      ?
WNDCLASSEX ENDS

POINT STRUCT
  x  DWORD ?
  y  DWORD ?
POINT ENDS

MSG STRUCT
  hwnd      DWORD      ?
  message   DWORD      ?
  wParam    DWORD      ?
  lParam    DWORD      ?
  time      DWORD      ?
  pt        POINT      <>
MSG ENDS





.data
Naslov db "File listing",0
Text db "This program is made by Passwd!",0


;ime nase klase
ClassName db "ClassName",0
AppName db "FileListing",0


.data?
hInstance HINSTANCE ?
wc        WNDCLASSEX <>
hwnd      HWND ?
msg       MSG <>



.code


start:

push 0
push offset Naslov
push offset Text
push 0
call MessageBoxA

push 0
call GetModuleHandleA
mov hInstance, eax

push SW_SHOWNORMAL
push 0
push 0
push hInstance
call WinMain
push 0
call ExitProcess



WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
;LOCAL wc:WNDCLASSEX
;LOCAL hwnd:HWND
;LOCAL msg:MSG
    mov   wc.cbSize,SIZEOF WNDCLASSEX       
    mov   wc.style, CS_HREDRAW or CS_VREDRAW 
    mov   wc.lpfnWndProc, OFFSET WndProc 
    mov   wc.cbClsExtra,0
    mov   wc.cbWndExtra,0 
    push  hInstance 
    pop   wc.hInstance 
    mov   wc.hbrBackground,COLOR_WINDOW+1 
    mov   wc.lpszMenuName,0 
    mov   wc.lpszClassName,OFFSET ClassName 
    push IDI_APPLICATION
    push 0
    call LoadIconA
    mov   wc.hIcon,eax 
    mov   wc.hIconSm,eax 
    push IDC_ARROW
    push 0
    call LoadCursorA 
    mov   wc.hCursor,eax 
    push offset wc  
    call RegisterClassA
    push 0
    push hInst
    push 0
    push 0
    push 300 ;sirina 
    push 300 ;visina
    push 300 ;y-kor
    push 300 ;x kor
    push WS_OVERLAPPEDWINDOW
    push offset AppName
    push offset ClassName
    call CreateWindowExA
    push CmdShow
    push hwnd
    call ShowWindow
    push hwnd
    call UpdateWindow 

    .WHILE TRUE 
                push 0
                push 0
                push 0
                push offset msg
                call GetMessageA              
                .BREAK .IF (!eax) 
                push offset msg
                call TranslateMessage
                push offset msg
                call DispatchMessageA
    .ENDW 
    mov eax, msg.wParam
    ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM 
    .IF uMsg==WM_DESTROY     
        push 0 
        call PostQuitMessage             
    .ELSE 
        push lParam
        push wParam
        push uMsg
        push hWnd
        call DefWindowProcA
        ret 
    .ENDIF 
    xor eax,eax 
    ret 
WndProc endp 


end start
 
Odgovor na temu

Eurora3D Team
Nebojsa - Programer & Vodja tima
Beograd

Član broj: 120376
Poruke: 900
*.beobug.com.



+7 Profil

icon Re: Program se rusi... ne vidim gresku04.01.2007. u 21:13 - pre 209 meseci
Nisam probao kod u asembleru ali na prvi pogled vidim da si ispred CreateWindowEx zaboravio prvi parametar (ExStyle). Zbog toga se rusi. Stavi Push 0 ispred Call CreateWindowEx
I jos jedna stvar kopiraj eax u hwnd posle CreateWindowEx mov hwnd,eax
Pozdrav
 
Odgovor na temu

Eurora3D Team
Nebojsa - Programer & Vodja tima
Beograd

Član broj: 120376
Poruke: 900
*.beobug.com.



+7 Profil

icon Re: Program se rusi... ne vidim gresku05.01.2007. u 14:10 - pre 209 meseci
Ovaj kod sam probao u MASM32 , imas komentare u kodu (sta je menjano)
Promeni samo includelib directive za svoj assembler u
includelib ..\lib\kernel32.lib
includelib ..\lib\user32.lib
Napravio si samo dve greske (ali kljucne)
Pozdrav
;===================================================
.386
.model flat, stdcall
option casemap:none

MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
ExitProcess PROTO uExitCode:DWORD
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
GetModuleHandleA PROTO :DWORD
LoadIconA PROTO :DWORD,:DWORD
LoadCursorA PROTO :DWORD,:DWORD
RegisterClassExA PROTO :DWORD;dodato WNDCLASSEX ide sa RegisterClassEx
CreateWindowExA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ShowWindow PROTO :DWORD,:DWORD
UpdateWindow PROTO :DWORD
GetMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORD
TranslateMessage PROTO :DWORD
DispatchMessageA PROTO :DWORD
DefWindowProcA PROTO :DWORD,:DWORD,:DWORD,:DWORD
PostQuitMessage PROTO :DWORD

WndProc PROTO:DWORD,:DWORD,:DWORD,:DWORD;dodato
includelib kernel32.lib
includelib user32.lib



;tipovi varijabli
;novo ime---------vec postojece
HINSTANCE typedef DWORD
LPSTR typedef DWORD
HWND typedef DWORD
LPARAM typedef DWORD
WPARAM typedef DWORD
UINT typedef DWORD


;konstante
SW_SHOWNORMAL equ 1
IDI_APPLICATION equ 32512
IDC_ARROW equ 32512
CS_HREDRAW equ 2h
CS_VREDRAW equ 1h
COLOR_WINDOW equ 5
WS_OVERLAPPEDWINDOW equ 0CF0000h
TRUE equ 1
FALSE equ 0
NULL equ 0
WM_DESTROY equ 2h

;strukture
WNDCLASSEX STRUCT
cbSize DWORD ?
style DWORD ?
lpfnWndProc DWORD ?
cbClsExtra DWORD ?
cbWndExtra DWORD ?
hInstance DWORD ?
hIcon DWORD ?
hCursor DWORD ?
hbrBackground DWORD ?
lpszMenuName DWORD ?
lpszClassName DWORD ?
hIconSm DWORD ?
WNDCLASSEX ENDS

POINT STRUCT
x DWORD ?
y DWORD ?
POINT ENDS

MSG STRUCT
hwnd DWORD ?
message DWORD ?
wParam DWORD ?
lParam DWORD ?
time DWORD ?
pt POINT <>
MSG ENDS

.data
Naslov db "File listing",0
Text db "This program is made by Passwd!",0

;ime nase klase
ClassName db "ClassName",0
AppName db "FileListing",0

.data?
hInstance dd ?
hwnd dd ?
hIcon dd ?
hCursor dd ?
wc WNDCLASSEX <>
msg MSG <>

.code
start:
push 0
call GetModuleHandleA
mov hInstance, eax
;push 0h
;push offset Text
;push offset Text
;call MessageBoxA

push SW_SHOWNORMAL
push 0
push 0
push hInstance
call WinMain
push 0
call ExitProcess

WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD

push IDI_APPLICATION
push 0
call LoadIconA
mov hIcon,eax
push IDC_ARROW
push 0
call LoadCursorA
mov hCursor,eax
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,0
mov wc.cbWndExtra,0
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,0
mov wc.lpszClassName,OFFSET ClassName
mov eax,hIcon
mov wc.hIcon,eax
mov wc.hIconSm,eax
mov eax,hCursor
mov wc.hCursor,eax
push offset wc
call RegisterClassExA
.if eax==0;dodato
ret
.endif
push 0
push hInst
push 0
push 0
push 300 ;sirina
push 300 ;visina
push 300 ;y-kor
push 300 ;x kor
push WS_OVERLAPPEDWINDOW
push offset AppName
push offset ClassName
push 0;DODATO
call CreateWindowExA
.if eax==0;DODATO
ret
.endif
mov hwnd,eax
push CmdShow
push hwnd
call ShowWindow
push hwnd
call UpdateWindow

.WHILE TRUE
push 0
push 0
push 0
push offset msg
call GetMessageA
.BREAK .IF (!eax)
push offset msg
call TranslateMessage
push offset msg
call DispatchMessageA
.ENDW
mov eax, msg.wParam
ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg==WM_DESTROY
push 0
call PostQuitMessage
ret
.ELSE
push lParam
push wParam
push uMsg
push hWnd
call DefWindowProcA
ret
.ENDIF
xor eax,eax
ret
WndProc endp
end start
;=========================================
 
Odgovor na temu

de_c0der

Član broj: 127698
Poruke: 107
*.adsl.net.t-com.hr.



Profil

icon Re: Program se rusi... ne vidim gresku05.01.2007. u 17:25 - pre 209 meseci
Radi... fala puno, samo jos ovo da te pitam:
kako usporediti dva DWORDA

znaci ovo
cmp d1,d2
je nesto


a d1 je DWORD i d2 je DWORD i stalno mi javlja:
error A2070: invalid instruction operands
 
Odgovor na temu

Eurora3D Team
Nebojsa - Programer & Vodja tima
Beograd

Član broj: 120376
Poruke: 900
*.com
Via: [es] mailing liste



+7 Profil

icon Re: Program se rusi... ne vidim gresku05.01.2007. u 19:46 - pre 209 meseci
Ne moze da poredi dve memoriske adrese
Uradi ovako:
;=======
mov eax,d2 ; kopiraj prvo sadrzaj u eax ili neki drugi registar
cmp d1,eax ; i onda ih uporedi
je nesto
;=======
Evo ti tabela uslovnih skokova iz Asemblerskog helpa
Jxx - Jump Instructions Table
Mnemonic Meaning Jump Condition
JA Jump if Above CF=0 and ZF=0
JAE Jump if Above or Equal CF=0
JB Jump if Below CF=1
JBE Jump if Below or Equal CF=1 or ZF=1
JC Jump if Carry CF=1

JCXZ Jump if CX Zero CX=0
JE Jump if Equal ZF=1
JG Jump if Greater (signed) ZF=0 and SF=OF
JGE Jump if Greater or Equal (signed) SF=OF
JL Jump if Less (signed) SF != OF
JLE Jump if Less or Equal (signed) ZF=1 or SF != OF
JMP Unconditional Jump unconditional

JNA Jump if Not Above CF=1 or ZF=1
JNAE Jump if Not Above or Equal CF=1
JNB Jump if Not Below CF=0
JNBE Jump if Not Below or Equal CF=0 and ZF=0
JNC Jump if Not Carry CF=0
JNE Jump if Not Equal ZF=0
JNG Jump if Not Greater (signed) ZF=1 or SF != OF

JNGE Jump if Not Greater or Equal (signed) SF != OF
JNL Jump if Not Less (signed) SF=OF
JNLE Jump if Not Less or Equal (signed) ZF=0 and SF=OF
JNO Jump if Not Overflow (signed) OF=0
JNP Jump if No Parity PF=0
JNS Jump if Not Signed (signed) SF=0
JNZ Jump if Not Zero ZF=0

JO Jump if Overflow (signed) OF=1
JP Jump if Parity PF=1
JPE Jump if Parity Even PF=1
JPO Jump if Parity Odd PF=0
JS Jump if Signed (signed) SF=1
JZ Jump if Zero ZF=1
Clocks Size
Operands 808x 286 386 486 Bytes

Jx: jump 16 7+m 7+m 3 2
no jump 4 3 3 1
Jx near-label - - 7+m 3 4
no jump - - 3 1
- It's a good programming practice to organize code so the
expected case is executed without a jump since the actual
jump takes longer to execute than falling through the test.

- see JCXZ and JMP for their respective timings

77 cb JA rel8 Jump short if above (CF=0 and ZF=0)
73 cb JAE rel8 Jump short if above or equal (CF=0)
72 cb JB rel8 Jump short if below (CF=1)
76 cb JBE rel8 Jump short if below or equal (CF=1 or ZF=1)
72 cb JC rel8 Jump short if carry (CF=1)

E3 cb JCXZ rel8 Jump short if CX register is 0
E3 cb JECXZ rel8 Jump short if ECX register is 0
74 cb JE rel8 Jump short if equal (ZF=1)
7F cb JG rel8 Jump short if greater (ZF=0 and SF=OF)
7D cb JGE rel8 Jump short if greater or equal (SF=OF)
7C cb JL rel8 Jump short if less (SF<>OF)
7E cb JLE rel8 Jump short if less or equal (ZF=1 or SF<>OF)

76 cb JNA rel8 Jump short if not above (CF=1 or ZF=1)
72 cb JNAE rel8 Jump short if not above or equal (CF=1)
73 cb JNB rel8 Jump short if not below (CF=0)
77 cb JNBE rel8 Jump short if not below or equal (CF=0 and ZF=0)
73 cb JNC rel8 Jump short if not carry (CF=0)
75 cb JNE rel8 Jump short if not equal (ZF=0)

7E cb JNG rel8 Jump short if not greater (ZF=1 or SF<>OF)
7C cb JNGE rel8 Jump short if not greater or equal (SF<>OF)
7D cb JNL rel8 Jump short if not less (SF=OF)
7F cb JNLE rel8 Jump short if not less or equal (ZF=0 and SF=OF)
71 cb JNO rel8 Jump short if not overflow (OF=0)
7B cb JNP rel8 Jump short if not parity (PF=0)

79 cb JNS rel8 Jump short if not sign (SF=0)
75 cb JNZ rel8 Jump short if not zero (ZF=0)
70 cb JO rel8 Jump short if overflow (OF=1)
7A cb JP rel8 Jump short if parity (PF=1)
7A cb JPE rel8 Jump short if parity even (PF=1)
7B cb JPO rel8 Jump short if parity odd (PF=0)
78 cb JS rel8 Jump short if sign (SF=1)

74 cb JZ rel8 Jump short if zero (ZF = 1)
0F 87 cw/cd JA rel16/32 Jump near if above (CF=0 and ZF=0)
0F 83 cw/cd JAE rel16/32 Jump near if above or equal (CF=0)
0F 82 cw/cd JB rel16/32 Jump near if below (CF=1)
0F 86 cw/cd JBE rel16/32 Jump near if below or equal (CF=1 or ZF=1)

0F 82 cw/cd JC rel16/32 Jump near if carry (CF=1)
0F 84 cw/cd JE rel16/32 Jump near if equal (ZF=1)
0F 84 cw/cd JZ rel16/32 Jump near if 0 (ZF=1)
0F 8F cw/cd JG rel16/32 Jump near if greater (ZF=0 and SF=OF)
0F 8D cw/cd JGE rel16/32 Jump near if greater or equal (SF=OF)
0F 8C cw/cd JL rel16/32 Jump near if less (SF<>OF)

0F 8E cw/cd JLE rel16/32 Jump near if less or equal (ZF=1 or SF<>OF)
0F 86 cw/cd JNA rel16/32 Jump near if not above (CF=1 or ZF=1
)
0F 82 cw/cd JNAE rel16/32 Jump near if not above or equal (CF=1)
0F 83 cw/cd JNB rel16/32 Jump near if not below (CF=0)
0F 87 cw/cd JNBE rel16/32 Jump near if not below or equal (CF=0 and
ZF=0)

0F 83 cw/cd JNC rel16/32 Jump near if not carry (CF=0)
0F 85 cw/cd JNE rel16/32 Jump near if not equal (ZF=0)
0F 8E cw/cd JNG rel16/32 Jump near if not greater (ZF=1 or SF<>OF)
0F 8C cw/cd JNGE rel16/32 Jump near if not greater or equal (SF<>OF)
0F 8D cw/cd JNL rel16/32 Jump near if not less (SF=OF)

0F 8F cw/cd JNLE rel16/32 Jump near if not less or equal (ZF0 and SF=OF)
0F 81 cw/cd JNO rel16/32 Jump near if not overflow (OF=0)
0F 8B cw/cd JNP rel16/32 Jump near if not parity (PF=0)
0F 89 cw/cd JNS rel16/32 Jump near if not sign (SF=0)
0F 85 cw/cd JNZ rel16/32 Jump near if not zero (ZF=0)

0F 80 cw/cd JO rel16/32 Jump near if overflow (OF=1)
0F 8A cw/cd JP rel16/32 Jump near if parity (PF=1)
0F 8A cw/cd JPE rel16/32 Jump near if parity even (PF=1)
0F 8B cw/cd JPO rel16/32 Jump near if parity odd (PF=0)
0F 88 cw/cd JS rel16/32 Jump near if sign (SF=1)
0F 84 cw/cd JZ rel16/32 Jump near if 0 (ZF=1)
 
Odgovor na temu

de_c0der

Član broj: 127698
Poruke: 107
*.adsl.net.t-com.hr.



Profil

icon Re: Program se rusi... ne vidim gresku05.01.2007. u 21:04 - pre 209 meseci
E hvala ti puno, car si!!!

Aj mi daj mail il nesto gdje te mogu cimnit ako zapnem negdje opet :))))

pozz i thx jos jednom!!!!!
 
Odgovor na temu

Eurora3D Team
Nebojsa - Programer & Vodja tima
Beograd

Član broj: 120376
Poruke: 900
*.com
Via: [es] mailing liste



+7 Profil

icon Re: Program se rusi... ne vidim gresku05.01.2007. u 23:35 - pre 209 meseci
Imas ovde na forumu pisanje privatnih poruka a mozes i na [email protected]
Pozdrav i polako sa asemblerom
 
Odgovor na temu

Eurora3D Team
Nebojsa - Programer & Vodja tima
Beograd

Član broj: 120376
Poruke: 900
*.beobug.com.



+7 Profil

icon Re: Program se rusi... ne vidim gresku07.01.2007. u 09:29 - pre 209 meseci
de_c0der postavio sam jedan primer za MASM na http://www.elitesecurity.org/t...rimer-unistavanja-procesa-MASM
Pogledaj kod. Imas neke osnovne manipulacije sa bajt nizovima (stringovima) i sl.
Pozdrav
 
Odgovor na temu

[es] :: Asembler :: Program se rusi... ne vidim gresku

[ Pregleda: 3564 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.