sequence of byte -> komischer Datentyp
Moin moin,
ich versuche die MD5 Proceduren aus der Microsoft Cryptdll.dll zu benutzen, leider tritt dabei beim Ausführen folgendes Codes eine AccessViolation bzw. Priviligierte Instruktion auf. Ich nehme an das mit den Aufrufen der Funktionen etwas schief läuft ... die Aufrufkonventionen müsste aber stimmen, ist ja aus der Windows API
Delphi-Quellcode:
Problematisch bei der Übersetzung/Einbindung ist folgendes:
// ...
uses classes; // Windows Cript API imports type MD5_CTX = packed record i: packed array[0..1] of longint; // ULONG[2] buf: packed array[0..3] of longint; // ULONG[4] _in: packed array[0..63] of byte; // unsigned char[64] digest: packed array[0..15] of byte; // unsigned char[16] end; procedure MD5Init(var MD5_CTX); stdcall; external 'Cryptdll.dll' name 'MD5Init'; procedure MD5Update(var MD5_CTX; const input; inputLength: longint); stdcall; external 'Cryptdll.dll' name 'MD5Init'; procedure MD5Final(var MD5_CTX); stdcall; external 'Cryptdll.dll' name 'MD5Init'; function StreamToMD5String(x: TStream): string; // suboptimaler Funktionsname implementation function StreamToMD5String(x: TStream): string; var context: MD5_CTX; buffer: packed array[0..511] of byte; length: integer; begin MD5Init(context); x.Position := 0; repeat length := x.Read(buffer, 512); MD5Update(context, buffer, length); until length <= 0; MD5Final(context); end; // ...
Code:
[Quelle]
procedure MD5Update(
var context: MD5_CTX, input: sequence of BYTE, inputLen: integer) Was ist "sequence of BYTE"? Pointer hab ich schon probiert (s.o.)... Ich freue mich über sachdienliche Hinweise :) MfG, Bug |
Re: sequence of byte -> komischer Datentyp
Zitat:
Ich denke, daß es in der Protokollbeschreibung nur "symbolisch" so steht. Es ist kein eigentlicher Typ. Im Notfall kann ich mal mit IDA in die DLL gucken. |
Re: sequence of byte -> komischer Datentyp
Zitat:
Delphi-Quellcode:
type TInput = packed array[0..511] of byte;
procedure MD5Update(var MD5_CTX; input: TInput; inputLength: longint); stdcall; external 'Cryptdll.dll' name 'MD5Init'; // ... var buffer: TInput; // ... MD5Init(context); // ... MD5Update(context, buffer, 512); // ... MD5Final(context); // ... Zitat:
MfG, Bug |
Re: sequence of byte -> komischer Datentyp
Zitat:
Ich schau mal schnell rein. |
Re: sequence of byte -> komischer Datentyp
Da schau ich so rein und da fällt mir auf, daß ich das doch schon kenne. Ist doch dokumentiert ;)
http://msdn.microsoft.com/en-us/library/bb432359(VS.85).aspx Ich würde dir aber mal empfehlen nochmal hier nachzulesen. |
Re: sequence of byte -> komischer Datentyp
Aber dann müßte das:
Delphi-Quellcode:
doch funktionieren, oder? Macht es leider nicht ... irgendwas mach ich falsch :wall:
procedure MD5Update(var context: MD5_CTX; const input; inputLength: word); stdcall; external 'Cryptdll.dll' name 'MD5Init';
Zitat:
EDIT: :wall: hat geholfen, natürlich muss da
Delphi-Quellcode:
stehen ... Problem gelöst!
procedure MD5Update(var context: MD5_CTX; const input; inputLength: word); stdcall; external 'Cryptdll.dll' name 'MD5Update';
Trotzdem vielen Dank! MfG, Bug |
Re: sequence of byte -> komischer Datentyp
Könntest du mir einfach mal das kompilierte Programm anhängen? Ich würde es einfach mal im IDA Debgger durchlaufen lassen und mir die C-Variante vergleichend anschauen.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:02 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz