Discussion:
Indys TIdHashMessageDigest4 and Cpp problems
(too old to reply)
test
2008-03-22 17:33:38 UTC
Permalink
Hi,

Trying to use the TIdHashMessageDigest4 component, but came access the
delphi/cpp convert error, (cpp can't return arrays)
The generated cpp code is as such


typedef unsigned T16x4LongWordRecord[16];

typedef unsigned T4x4x4LongWordRecord[4][4];

......
class DELPHICLASS TIdHashMessageDigest4;
class PASCALIMPLEMENTATION TIdHashMessageDigest4 : public
TIdHashMessageDigest
{
typedef TIdHashMessageDigest inherited;

protected:
unsigned FBuffer[4];
unsigned FCBuffer[16];
virtual void __fastcall MDCoder(void);
virtual unsigned __fastcall func_f(unsigned x, unsigned y, unsigned z);
virtual unsigned __fastcall func_g(unsigned x, unsigned y, unsigned z);
virtual unsigned __fastcall func_h(unsigned x, unsigned y, unsigned z);

public:
virtual Idhash::T4x4LongWordRecord __fastcall HashValue(Classes::TStream*
AStream)/* overload */;
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TIdHashMessageDigest4(void) :
TIdHashMessageDigest() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual
~TIdHashMessageDigest4(void) { }
#pragma option pop

/* Hoisted overloads: */

public:
inline Idhash::T4x4LongWordRecord __fastcall HashValue(const AnsiString
ASrc){ return TIdHash128::HashValue(ASrc); }
};

the lines

virtual Idhash::T4x4LongWordRecord __fastcall HashValue(Classes::TStream*
AStream)/* overload */;
inline Idhash::T4x4LongWordRecord __fastcall HashValue(const AnsiString
ASrc){ return TIdHash128::HashValue(ASrc); }

were the ones giving errors, so after some googling (very limited results
;( ) I changed them to

virtual unsigned __fastcall HashValue(Classes::TStream* AStream)/* overload
*/;
inline unsigned __fastcall HashValue(const AnsiString ASrc){ return
TIdHash128::HashValue(ASrc); }

My App compiles but I get an access voilation error as soon as I try to use
it, any ideas how to fix this?

Project Project1.exe raised exception class EAccessViolation with message
'Access violation at address 20621acc in module 'indy100.bpl'. write of
address 20620ff8'.

I'm using Indy 9.0.50. I downgraded form 10 to 9 as I need 9 for older
projects. Also I'm using Code Gear 2007.

Thanks,
ar
test
2008-04-04 18:26:12 UTC
Permalink
Nobody have any input/ideas?
Remy Lebeau (TeamB)
2008-04-04 18:57:19 UTC
Permalink
Post by test
Trying to use the TIdHashMessageDigest4 component, but
came access the delphi/cpp convert error, (cpp can't return arrays)
<snip>

Indy 9 does not have a ready solution for this. Indy 10's hash classes had
to be re-written to address this problem (arrays are not passed in the
return value anymore).
Post by test
My App compiles but I get an access voilation error as
soon as I try to use it, any ideas how to fix this?
How are you trying to access it exactly? You are likely casting the
'unsigned' value incorrectly.


Gambit
Test
2008-04-07 17:29:00 UTC
Permalink
Post by Remy Lebeau (TeamB)
How are you trying to access it exactly? You are likely casting the
'unsigned' value incorrectly.
Hi,

I was using the code below

TFileStream* FS = new TFileStream(Edit1->Text, fmOpenRead);
TMemoryStream* MS = new TMemoryStream();
TIdHashMessageDigest4* md4 = new TIdHashMessageDigest4();
...
MS->SetSize(1000000);
MS->LoadFromStream(FS);
Label1->Caption = md4->HashValue(MS);
...

delete md4;
delete MS;
delete FS;


I ended up installing indy 10 on a different computer and was able to use the component with no problems.

Thanks

Loading...