delphi VMProtectDecryptStringA memory clean?

procedure TForm1.Button1Click(Sender: TObject);
var
nthookscript: Tstringlist;
begin
nthookscript:=nil;
nthookscript:=tstringlist.create;
nthookscript.add(VMProtectDecryptStringA((‘teststring0000’)));
nthookscript.add(VMProtectDecryptStringA((‘teststring0001’)));
nthookscript.add(VMProtectDecryptStringA((‘teststring0002’)));

nthookscript.clear;
nthookscript.free;
end;

teststring0000,teststring0001,teststring0002 → memory data string delete!!

VMProtectFreeString?

Does using VMProtectFreeString in Delphi initialize memory?

How do I use it in my TStringList example?

I want to delete string data from memory

str1 = VMProtectDecryptStringA('teststring0000');
str2 = VMProtectDecryptStringA('teststring0001');
str3 = VMProtectDecryptStringA('teststring0002');
...
nthookscript:=tstringlist.create;
nthookscript.add(str1);
nthookscript.add(str2);
nthookscript.add(str3);

nthookscript.clear;
nthookscript.free;
...
VMProtectFreeString(str1);
VMProtectFreeString(str2);
VMProtectFreeString(str3);

procedure TForm1.Button1Click(Sender: TObject);
var
nthookscript: Tstringlist;
str1 : string;
str2 : string;
str3 : string;
begin

showmessage(‘1’);

str1 := VMProtectDecryptStringA(‘teststring0000’);
str2 := VMProtectDecryptStringA(‘teststring0001’);
str3 := VMProtectDecryptStringA(‘teststring0002’);
nthookscript:=nil;
nthookscript:=tstringlist.create;

nthookscript.add(str1);
nthookscript.add(str2);
nthookscript.add(str3);

nthookscript.clear;
nthookscript.free;

showmessage(‘2’);

VMProtectFreeString(@str1);
VMProtectFreeString(@str2);
VMProtectFreeString(@str3);

end;

Lazarus test.

Declare a variable and search the memory string after packing

Memory uninitialized after showmessge(2)

Look at the declaration of VMProtectDecryptStringA more curefully:

function VMProtectDecryptStringA(Value: PAnsiChar): PAnsiChar; {$IFDEF MSWINDOWS} stdcall {$ELSE} cdecl {$ENDIF};

It seems you don’t know what differences between String and PAnsiChar. Here is the correct code:

str1 : PAnsiChar;
str2 : PAnsiChar;
str3 : PAnsiChar;
...
VMProtectFreeString(str1);
VMProtectFreeString(str2);
VMProtectFreeString(str3);

PAnsiChar → memory clean success

thank you