I mit der externen Methode einen DLLс ++ Anruf von anderem dll DLL mit std :: vector
extern "C" HAL_HASH_API basic_hash* getAlgorithmInstance(int algorithm);
und basic_hash hat nächste Methode
// resets to the initial condition of the algorithm,
// reset the counter and the current values
virtual void reset() = 0;
// performs all encryption cycle.
virtual void hash(const byte*, uint64, vector_byte&) = 0;
Der erste Parameter ist ein Zeiger <data>
Am Anfang der Daten gibt der zweite Parameter <size>
die Größe der Hash-Daten an, der dritte Parameter <hash>
ist ein Puffer zum Speichern des Hash-Wertes. Vektorgröße ändert sich automatisch.
und ich habe nächste Typen
typedef unsigned char byte;
typedef unsigned long long uint64;
typedef std::vector<byte> vector_byte;
wenn ich Variablen init und hash
RUNSCRIPT_FUNCTION runScript;
basic_hash* pointerBasicHash;
// Load the DLL
HINSTANCE dll = LoadLibrary(L"HAL.dll");
if (dll == NULL)
{
printf("Unable to load library\n");
}
// Get the function pointer
runScript = (RUNSCRIPT_FUNCTION)GetProcAddress(dll, "getAlgorithmInstance");
if (runScript == NULL)
{
FreeLibrary(dll);
printf("Unable to load function\n");
}
// Call the function
pointerBasicHash= (runScript)(0);
vector_byte hashresult;
hashresult.reserve(1024);
uint64 size = 8;
byte myString[] = "1234567";
const byte* buff = &myString[0];
pointerBasicHash->reset();
pointerBasicHash->hash(buff, size, hashresult);
Variable hashresult
falsch nennen, ist es eine Systemvariable PATH und Müll enthält.
EDIT basic_hash es ist Klasse
extern "C" class basic_hash
{
public:
virtual ~basic_hash() {}
virtual void reset() = 0;
virtual void hash(const byte*, uint64, vector_byte&) = 0;
};
posten Sie bitte die Signatur von pointerBasicHash :: hash() –
Sorry, ich bearbeite Code pointerBasicHash es ist 'basic_hash * pointerBasicHash;' – 6azbljlb
Haben Sie 'hash' Funktion der Klasse von' pointerBasicHash' getestet bekommen Sie? – grisumbras