• Sábado 20 de Abril de 2024, 01:02

Autor Tema:  ¿no Ensambla Este Codigo? :(  (Leído 2251 veces)

Rozor

  • Nuevo Miembro
  • *
  • Mensajes: 14
    • Ver Perfil
¿no Ensambla Este Codigo? :(
« en: Miércoles 19 de Septiembre de 2007, 12:19 »
0
Hola, he estado codeando con masm32 y siendo correcta la sintaxis segun numentor y otros codes que he echo y me da error :S , me da error en las estructuras WSADATA y SOCKADDR_IN. Aver que se puede hacer gracias.

He lido varias veces post de asm en este foro, y desarrollado como por ejemplo cuando lo del bootstrap. Y hoy me decidi a postear :P


Error:

Código: Text
  1.  
  2. Microsoft (R) Macro Assembler Version 6.14.8444
  3. Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.
  4.  
  5.  Assembling: C:\masm32\conexion.asm
  6. C:\masm32\conexion.asm(30) : error A2008: syntax error : wsa
  7. C:\masm32\conexion.asm(31) : error A2008: syntax error : sin
  8. _
  9. Assembly Error
  10. Presione una tecla para continuar . . .
  11.  
  12.  





El codigo fuente:

Código: Text
  1.  
  2. .586P
  3. .MODEL FLAT, STDCALL
  4.  
  5.  
  6.  
  7. include \masm32\include\wsock32.inc
  8. include \masm32\include\kernel32.inc
  9. include \masm32\include\user32.inc
  10.  
  11. includelib \masm32\lib\wsock32.lib
  12. includelib \masm32\lib\kernel32.lib
  13. includelib \masm32\lib\user32.lib
  14.  
  15.  
  16.  
  17.  
  18. CrearConexion proto
  19. EnviarMensage proto
  20. Error proto
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. .DATA
  29.  
  30.    wsa WSADATA <>  &#59; <--- ERROR  Linea 30
  31.    sin SOCKADDR_IN <> &#59; <--- ERROR Linea 31
  32.  
  33.    ip dq 0100007Fh
  34.    port dd 9a02h
  35.    buffsend db "#### barata", 0
  36.    cap db "Error", 0
  37.    txt db "Error no enviado", 0
  38.    cap2 db "Adios", 0
  39.    txt2 db "A funcado bien xDDD", 0
  40.  
  41.  
  42.  
  43.  
  44. .DATA?
  45.  
  46.    sock dd ?
  47.  
  48.  
  49.  
  50.  
  51.  
  52. .CONST
  53.  
  54.    protocolo dd 06h&#59; IPPROTO_TCP
  55.    familia dd 02h &#59; AF_INET
  56.    stream dd 01h  &#59; SOCK_STREAM
  57.    sizesin dd 10h &#59; sizeof sockaddr_in
  58.    make dd 101h   &#59; MAKEWORD(1,1)
  59.    wm_sock dd 464h&#59; WM_SOCKET = WM_USER+100
  60.    f_connect dd 10h &#59; FD_CONNECT
  61.    f_read dd 01h    &#59; FD_READ
  62.    f_close dd 20h   &#59; FD_CLOSE
  63.    f_all dd 31h     &#59; Suma de los 3
  64.  
  65.  
  66. .CODE
  67.  
  68.  
  69.  
  70.   Inicio:
  71.  
  72.                 xor eax, eax
  73.                 call CrearConexion
  74.  
  75.                 push 00h
  76.                 push offset cap
  77.                 push offset txt
  78.                 push 00h
  79.                 call MessageBoxA
  80.  
  81.                 push sock
  82.                 call closesocket
  83.  
  84.                 call WSACleanup
  85.  
  86.                 push 00h
  87.                 call ExitProcess        
  88.  
  89.  end Inicio
  90.  
  91.  
  92.  
  93.  
  94.   CrearConexion proto
  95.  
  96.                 push offset wsa
  97.                 push offset make
  98.                 call WSAStartup
  99.  
  100.                 push offset protocolo
  101.                 push offset stream
  102.                 push offset familia
  103.                 call socket
  104.                 mov sock, eax
  105.  
  106.  
  107.                 push offset f_all
  108.                 push offset wm_sock
  109.                 push 00h
  110.                 push sock
  111.                 call WSAAsyncSelect
  112.  
  113.  
  114.                          
  115.                 mov sin.sin_family, offset familia
  116.                 mov sin.sin_port, offset puerto
  117.                 mov sin.sin_addr, offset ip
  118.  
  119.  
  120.                 push offset sizesin
  121.                 push offset sin
  122.                 push offset sock
  123.                 call connect
  124.                 je EnviarMensage
  125.                 jnz Error
  126.                 ret&#59; w0w
  127.  
  128.   CrearConexion endp
  129.  
  130.  
  131.  
  132.  
  133.   EnviarMensage proto
  134.  
  135.                 push 00h
  136.                 push 15
  137.                 push offset sendbuff
  138.                 push offset sock
  139.                 call send
  140.                 ret
  141.  
  142.   EnviarMensage endp
  143.  
  144.  
  145.  
  146.  
  147.   Error proto
  148.  
  149.                 push 00h
  150.                 push offset cap
  151.                 push offset txt
  152.                 push 00h
  153.                 call MessageBoxA
  154.  
  155.                 push 00h
  156.                 call ExitProcess
  157.  
  158.                 leave
  159.                 ret&#59; w0w
  160.                
  161.   Error endp
  162.  
  163.  


Gracias.

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: ¿no Ensambla Este Codigo? :(
« Respuesta #1 en: Miércoles 19 de Septiembre de 2007, 16:58 »
0
Esas estructuras no estan definidas en ninguno de los includes que usas. Estan en windows.inc y la segunda es con minusculas (sockaddr_in).

Averigua en la ayuda como incluir ese archivo.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

Rozor

  • Nuevo Miembro
  • *
  • Mensajes: 14
    • Ver Perfil
Re: ¿no Ensambla Este Codigo? :(
« Respuesta #2 en: Miércoles 19 de Septiembre de 2007, 22:21 »
0
Si perdonen por el post, tenia windows.inc y lo quite por que tenia fallo luego no me acorde y no me di cuenta jejejej, reinstale y compilo sin problemas.

Por cierto, el codigo arreglado, ya no me funciona pero a nivel ejecucion, he debugeado y todo va bien hasta "connect", hay falla no pillo el por que :S . ( no es culpa del servidor ).


Código: Text
  1.  
  2. 586p
  3. .model flat, stdcall
  4. option casemap:none
  5.  
  6.  
  7. include \masm32\include\wsock32.inc
  8. include \masm32\include\kernel32.inc
  9. include \masm32\include\user32.inc
  10. include \masm32\include\windows.inc
  11.  
  12. includelib \masm32\lib\wsock32.lib
  13. includelib \masm32\lib\kernel32.lib
  14. includelib \masm32\lib\user32.lib
  15.  
  16.  
  17.  
  18.  
  19. CrearConexion proto
  20. EnviarMensage proto
  21. Error proto
  22.  
  23.  
  24.  
  25. .data
  26.  
  27.    wsa WSADATA <>
  28.    sin sockaddr_in <>
  29.  
  30.    ip db "127.0.0.1", 0  
  31.    port dd 666
  32.    buffsend db "#### barata", 0
  33.    cap db "Error", 0
  34.    txt db "Error no enviado", 0
  35.    cap2 db "Adios", 0
  36.    txt2 db "A funcado bien xDDD", 0
  37.  
  38.  
  39.  
  40.  
  41. .data?
  42.  
  43.   sock dd ?
  44.   hand dd ?
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. .const
  52.  
  53.    protocolo dd 06h&#59; IPPROTO_TCP
  54.    familia dd 02h &#59; AF_INET
  55.    stream dd 01h  &#59; SOCK_STREAM
  56.    sizesin dd 10h &#59; sizeof sockaddr_in
  57.    make dw 101h   &#59; MAKEWORD(1,1)
  58.    wm_sock dd WM_USER+100&#59; WM_SOCKET = WM_USER+100
  59.    f_connect dd 10h &#59; FD_CONNECT
  60.    f_read dd 01h    &#59; FD_READ
  61.    f_close dd 20h   &#59; FD_CLOSE
  62.    f_all dd 31h     &#59; Suma de los 3
  63.  
  64.  
  65. .code
  66.  
  67.  
  68.  
  69.   Inicio:
  70.  
  71.                 xor eax, eax
  72.                 call CrearConexion
  73.  
  74.                 push 00h
  75.                 push offset cap
  76.                 push offset txt
  77.                 push 00h
  78.                 call MessageBoxA
  79.  
  80.                 push sock
  81.                 call closesocket
  82.  
  83.                 call WSACleanup
  84.  
  85.                 push 00h
  86.                 call ExitProcess        
  87.  
  88.  
  89.  
  90.  
  91.  
  92.   CrearConexion proc
  93.  
  94.                 push offset wsa
  95.                 push 101h
  96.                 call WSAStartup
  97.  
  98.                 push 0
  99.                 push SOCK_STREAM
  100.                 push AF_INET
  101.                 call socket
  102.                 mov sock, eax
  103.                 .if eax==INVALID_SOCKET
  104.                    call Error
  105.                 .endif
  106.  
  107.  
  108.                 push FD_READ+FD_WRITE+FD_CONNECT
  109.                 push offset wm_sock
  110.                 push offset hand
  111.                 push sock
  112.                 call WSAAsyncSelect
  113.  
  114.  
  115.                          
  116.                 mov sin.sin_family, 02h
  117.                 push 29ah
  118.                 call htons
  119.                 mov sin.sin_port, ax
  120.                 push offset ip
  121.                 call inet_addr
  122.                 mov sin.sin_addr, eax
  123.  
  124.  
  125.                 push sizeof sin
  126.                 mov eax, offset sin
  127.                 push eax
  128.                 push offset sock
  129.                 call connect
  130.                 .if eax==SOCKET_ERROR
  131.                     call Error
  132.                 .endif
  133.                 call EnviarMensage
  134.                 ret&#59; w0w
  135.  
  136.   CrearConexion endp
  137.  
  138.  
  139.  
  140.  
  141.   EnviarMensage proc
  142.  
  143.                 push 00h
  144.                 push 15
  145.                 push offset buffsend
  146.                 push offset sock
  147.                 call send
  148.                 ret
  149.  
  150.   EnviarMensage endp
  151.  
  152.  
  153.  
  154.  
  155.   Error proc
  156.  
  157.                 push 00h
  158.                 push offset cap
  159.                 push offset txt
  160.                 push 00h
  161.                 call MessageBoxA
  162.  
  163.                 push 00h
  164.                 call ExitProcess
  165.  
  166.                 leave
  167.                 ret&#59; w0w
  168.                
  169.   Error endp
  170.  
  171.  
  172.  
  173. end Inicio
  174.  
  175.  

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: ¿no Ensambla Este Codigo? :(
« Respuesta #3 en: Miércoles 19 de Septiembre de 2007, 22:32 »
0
hand ... ¿Para que arrancas con sockets asincronos? Mejor hacelo funcionar con sincronos primero.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.