Declarando una Libreria en VB6

Iniciado por ZoNike, 22 Octubre 2008, 22:57 PM

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

ZoNike

Buenas a todos, abro este post para exponer mi problema.
He conseguido un codigo en C/C++ que lo que hace es cargar una libreria utilizando la funcion LoadLibrary, GetProcAddress y FreeLibrary.
Lo que yo quiero es hacer lo mismo que hace ese codigo en C/C++ pero en VB6, he intentado hacerlo declarando la libreria utilizando (Declare Function "taltal" lib "libreria.dll"), y tambien declarando la funcion LoadLibrary y demas he intentando usarla para cargar la otra libreria.. pero de ningun modo he podido conseguir que funcionase.
El problema esque en mi codigo vb6 me devuelve el string "salida" y el integer "ret" vacios. Me han dicho algo de que debo reservar un espacio de memoria para que la funcion pueda guardar los datos de salida, pero no se como hacerlo..

Aqui os dejo los 2 codigos, el MIO creado en VB6:

Código (vb) [Seleccionar]
Private Declare Function descifrar Lib "Steam.dll" Alias "SteamDecryptDataForThisMachine" _
(ByRef encpwd As String, ByVal encpwdlen As Long, ByRef pwd As String, ByVal pwdlen As Long, ByRef ret As Integer) As Long

Private Sub Form_Load()
Dim clave As String
Dim salida As String
Dim ret As Integer

clave = "FB438E0EE7653893D139C47160AC11A6E6E5EE661F1AE5D7A83337D0F6CB8972254FB1165DB4F0711F8FFBC07377"

descifrar clave, Len(clave), salida, Len(salida), ret

MsgBox "Phrase: " & clave & vbCrLf & _
        "Len(Phrase): " & Len(clave) & vbCrLf & vbCrLf & _
        "Password: " & salida & vbCrLf & _
        "Len(Password): " & ret
End
End Sub





y el codigo que encontré en C/C++:

Código (cpp) [Seleccionar]
/*
by Luigi Auriemma
*/

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <windows.h>

typedef int (__stdcall *SteamDecryptDataForThisMachine_t)(char *a, int b, char *c, int d, int *e);


int main(int argc, char *argv[]) {
    SteamDecryptDataForThisMachine_t    SteamDecryptDataForThisMachine;
HANDLE  dll;
    int     len;
    char    pwd[100],
            *encpwd;

    if(argc < 2) {
        printf("\n"
            "Usage: %s <encrypted_password>\n"
            "\n", argv[0]);
        exit(1);
    }
    encpwd = argv[1];

dll = LoadLibrary("STEAM.DLL");
if(!dll) {
        printf("\nError: the file STEAM.DLL has not been found\n");
        exit(1);
    }
    SteamDecryptDataForThisMachine = (void *)GetProcAddress(dll, "SteamDecryptDataForThisMachine");
    if(!SteamDecryptDataForThisMachine) {
        printf("\nError: the function SteamDecryptDataForThisMachine has not been found\n");
        exit(1);
    }

    if(!SteamDecryptDataForThisMachine(encpwd, strlen(encpwd), pwd, sizeof(pwd), &len)) {
        printf("\n  password: %.*s\n", len, pwd);
    } else {
        printf("\nError: you can't decrypt this encrypted password\n");
    }
    FreeLibrary(dll);
    return(0);
}