Ventana en ASM

Iniciado por EAX_, 19 Diciembre 2009, 19:32 PM

0 Miembros y 1 Visitante están viendo este tema.

EAX_

Sisi, recien lo saque y con un msgbox confirme que funcionó, iba a responder pero ganaste.. gracias..

EAX_
"Everyone is a genius. But if you judge a fish on its ability to climb a tree, it will live its whole life believing it is stupid." - Albert Einstein

YST

Citar%HomeDrive% o %SystemRoot%.

Puedes tambien obtener las variables de entorno con GetEnvironmentVariable

Código (asm) [Seleccionar]

include "win32ax.inc"
.code
start:
  invoke GetEnvironmentVariable,"HomeDrive",Buffer,MAX_PATH
invoke MessageBox,0,Buffer,0,0
invoke ExitProcess,0
.data
Buffer db MAX_PATH dup (0)
.end start


Yo le enseñe a Kayser a usar objetos en ASM

EAX_

#12
Uff, despues de unos intentos me sirvio lo que me pasaste, gracias.. pero no logré usar invoke asi que lo hice asi:
Código (asm) [Seleccionar]

.codee:
       push    MAX_PATH
       push    buff2
       push    _home
       call    [GetEnvironmentVariable]
.data
buff2   db MAX_PATH dup (0)
end data


Gracias..

Edito

Me quede sin memoria (out of memory) y le di más con FASM, ahora nose porque pero me cierra el programa y sale la ventanita de enviar informe de errores

Que tengo mal?
Código (asm) [Seleccionar]
hInstance equ 0x00400000
format PE GUI 4.0 at hInstance as 'exe'
entry codee
include 'WIN32A.INC'

section '.bss' readable writeable
msg             MSG
bools           db ? ; [1]Exit


section '.text' code readable executable

codee:
        push    _classname
        push    0
        push    0
        call    [CreateMutex]
        call    [GetLastError]
        TEST    EAX,EAX
        jnz     .fiiin
        push    MAX_PATH
        push    buff2
        push    _home
        call    [GetEnvironmentVariable]
        push    DKGRAY_BRUSH
        call    [GetStockObject]
        mov     [wc.hbrBackground],EAX
        push    IDC_ARROW
        push    0
        call    [LoadCursor]
        mov     [wc.hCursor],EAX
        push    IDI_APPLICATION
        push    0
        call    [LoadIcon]
        mov     [wc.hIcon],EAX
        push    wc
        call    [RegisterClass]
        push    0
        push    [wc.hInstance]
        push    0
        push    0
        push    300
        push    500
        push    CW_USEDEFAULT
        push    CW_USEDEFAULT
        push    WS_VISIBLE+WS_CAPTION+WS_SYSMENU+WS_MAXIMIZEBOX+WS_THICKFRAME
        push    _title
        push    _classname
        push    0
        call    [CreateWindowEx]
        jmp     .jump0
        .jump:
        push    msg
        call    [TranslateMessage]
        push    msg
        call    [DispatchMessage]
        test    [bools],1
        jnz     .fiiin

        .jump0:
        push    0
        push    0
        push    0
        push    msg
        call    [GetMessage]
        cmp     EAX,1
        je      .jump
.fiiin:
        ret

WindowProc:
        mov     EAX,DWORD PTR SS: ESP+8
        cmp     EAX,WM_LBUTTONDOWN
        je      .lbdwn
        cmp     EAX,WM_DESTROY
        je      .wm_destroy
        jmp     [DefWindowProc]
        .lbdwn:
        push    SW_SHOWNORMAL
        push    0
        push    _c
        push    _cmdp
        push    _cmd
        push    _open
        push    0
        call    [ShellExecute]
        retn    16
        .wm_destroy:
        or      [bools],1
        retn    16


section '.data' writable readable

buff2           db MAX_PATH dup(0)
_home           TCHAR 'HomeDrive'
_open           TCHAR 'open',0
_c              TCHAR 'C:\',0
_cmd            TCHAR 'cmd',0
_cmdp           TCHAR '/c msg * asd',0
_title          TCHAR 'Program fucking',0
_classname      TCHAR 'MyFuckingProgram'
wc              WNDCLASS 0,WindowProc,0,0,hInstance,0,0,0,0,_classname

data import

U_KERNEL32     equ 1
U_NTDLL        equ 0
U_USER32       equ 1
U_GDI32        equ 1
U_DWM          equ 0
U_SHELL32      equ 1
U_ADVAPI32     equ 0
U_WS2_32       equ 0
U_COMCTL32     equ 0
U_MSIMG32      equ 0
U_MSVCRT       equ 0
U_OLE32        equ 1
include        'LIBS.INC'

end data



EAX_
"Everyone is a genius. But if you judge a fish on its ability to climb a tree, it will live its whole life believing it is stupid." - Albert Einstein

YST

Le metes un parametro de mas al ShellExecute :P 

Lo adapte un poquito a mi gusto pero esta funcional toma

Código (asm) [Seleccionar]

hInstance equ 0x00400000
format PE GUI 4.0 at hInstance as 'exe'

include 'WIN32AX.INC'

section '.bss' readable writeable
msg             MSG
bools           db ? ; [1]Exit


section '.text' code readable executable

codee:
        push    _classname
        push    0
        push    0
        call    [CreateMutex]
        call    [GetLastError]
        TEST    EAX,EAX
        jnz     .fiiin
        push    MAX_PATH
        push    buff2
        push    _home
        call    [GetEnvironmentVariable]
        push    DKGRAY_BRUSH
        call    [GetStockObject]
        mov     [wc.hbrBackground],EAX
        push    IDC_ARROW
        push    0
        call    [LoadCursor]
        mov     [wc.hCursor],EAX
        push    IDI_APPLICATION
        push    0
        call    [LoadIcon]
        mov     [wc.hIcon],EAX
        push    wc
        call    [RegisterClass]
        push    0
        push    [wc.hInstance]
        push    0
        push    0
        push    300
        push    500
        push    CW_USEDEFAULT
        push    CW_USEDEFAULT
        push    WS_VISIBLE+WS_CAPTION+WS_SYSMENU+WS_MAXIMIZEBOX+WS_THICKFRAME
        push    _title
        push    _classname
        push    0
        call    [CreateWindowEx]
        jmp     .jump0
        .jump:
        push    msg
        call    [TranslateMessage]
        push    msg
        call    [DispatchMessage]
        test    [bools],1
        jnz     .fiiin

        .jump0:
        push    0
        push    0
        push    0
        push    msg
        call    [GetMessage]
        cmp     EAX,1
        je      .jump
.fiiin:
        ret

WindowProc:
        mov     EAX,DWORD[ESP+8]
        ;pop edx
        cmp     EAX,WM_LBUTTONDOWN
        je      .lbdwn
        cmp     EAX,WM_DESTROY
        je      .wm_destroy
        jmp     [DefWindowProc]
        .lbdwn:

       invoke ShellExecute,0,_open,_cmd,_cmdp,_c, SW_SHOWNORMAL
        ret
        .wm_destroy:
invoke ExitProcess,0

section '.data' writable readable

buff2           db MAX_PATH dup(0)
_home           TCHAR 'HomeDrive'
_open           TCHAR 'open',0
_c              TCHAR 'C:\',0
_cmd            TCHAR 'cmd',0
_cmdp           TCHAR '/c msg * asd',0
_title          TCHAR 'Program fucking',0
_classname      TCHAR 'MyFuckingProgram'
wc              WNDCLASS 0,WindowProc,0,0,hInstance,0,0,0,0,_classname

.end codee
               


Yo le enseñe a Kayser a usar objetos en ASM