I have written my own DBX 4 in Delphi 2010 for Firebird database. The driver is a dynalink driver and it works fine with TSQLConnection.
Recently, I try to use the DataExplorer.exe released with Delphi 2010 and encounter error:
"Attempted to read or write protected memory.
This is often an indication that other memory is corrupt".
After trace the source code, I found the following export method may be the cause of the problem:
function DBXLoader_GetDriver(Count: TInt32; Names, Values: TWideStringArray;
ErrorMessage: TDBXWideStringBuilder; out pDriver: TDBXDriverHandle):
TDBXErrorCode; stdcall;
When debugging this method, the Names and Values parameter contain corrupted value. I don't know what cause the problem. Perhaps there is some memory manager problem with DataExplorer.exe (.net issue?)
After some trial and error, I attempt to change the method to as follow:
type
TWideStringArray2 = array of PChar;
function DBXLoader_GetDriver(Count: TInt32; Names, Values: TWideStringArray2;
ErrorMessage: TDBXWideStringBuilder; out pDriver: TDBXDriverHandle):
TDBXErrorCode; stdcall;
This time, the error is gone and soon after it exit this method, the same error raise again
"Attempted to read or write protected memory.
This is often an indication that other memory is corrupt".
Do you have any ideas what could the the cause of the problem?
Looks like you have some memory allocation problems. Are you using SimpleShareMem eventualy?
http://docwiki.embarcadero.com/CodeExamples/en/SimpleShareMem_Sample - describes how to use it.
http://www.codexterity.com/memmgr.htm - also contains some insights on memory allocation but with older approachi using FastSharemem module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With