I have a delphi application that uses BTMemoryModule and imports/calls functions from a DLL. The DLL is written in C/C++.
The delphi application sends an original pwidechar (array of 4 bytes or array of widechars) to a function.
I have no C/C++ pseudo code but it looks like this:
type
TMyFunc = function ( p : pointer ): pointer; stdcall;
procedure anynamehere();
var
Addr : TMyFunc;
MyString : WideString;
begin
[...]
Addr := BTMemoryGetProcAddress('mydll.dll', 'ExportedFunc');
MyString := 'TEST';
[...]
ExportedFunc (pwidechar(MyString));
MessageBoxW (0, pwidechar(MyString), '', 0);
end;
The DLL should now have the original pointer to the MyString var. The procedure in the delphiapp stays active (until the dll ExportedFunc is finished). So the MyString var gets NOT disposed after the procedure ends. My question now is: Is it possible to CHANGE the value of MyString within the DLL? (technically possible...) But How? The string is null terminated so the user knows how long the pointer length is. But if the C++ DLL changes the value , doesn't have the user also alloc new space or something? Or does this happen automatically?
Thanks for your help.