we have a delphi pointer (can be string or zero-string or whatever) and the proc or function in the assembled .obj module to use this pointer to modify the data. I have the proc but can not call it from delphi without Accesviolation when the pointer is used by the function or proc.
(This migth be question of a Delphi platform but my low level brain could'nt handle more on high level platforms. And really tried all possible ways ).
Thanks in advance
procedure modify(ptr:PChar);register;external;
modify proc public
push esi
mov esi,eax
...
;code to modify the string or data
...
pop esi
ret
modify endp
(This migth be question of a Delphi platform but my low level brain could'nt handle more on high level platforms. And really tried all possible ways ).
Thanks in advance
procedure modify(ptr:PChar);register;external;
modify proc public
push esi
mov esi,eax
...
;code to modify the string or data
...
pop esi
ret
modify endp
Not really a Delphi buff, but check out this link for some ideas on what could be wrong.
To quote an important line from that link, "The bottom line is that Delphi seems to work okay with the OBJ files that TASM produces, but fails miserably with OBJ files that other assemblers (including MASM) produce."
I guess the first question would be... which assembler are you using???
To quote an important line from that link, "The bottom line is that Delphi seems to work okay with the OBJ files that TASM produces, but fails miserably with OBJ files that other assemblers (including MASM) produce."
I guess the first question would be... which assembler are you using???
Sorry, there is no problem with the assembler. I've found out that i can actually pass the pointer but i can only read with it. I can not modify the string or data trough the pointer. Its a delphi thing. I guess i have to hit my head to some more help files and properties and commas, semicolons etc.
thanks for your attention
thanks for your attention
Hi Confusius,
you cant treat pchar as pointer to modifiable buffer
and think if you assign a string to it , that you can
modify that string, all strings go to readonly section.
lets me test my Delphi skills, its been a while :)
you cant treat pchar as pointer to modifiable buffer
and think if you assign a string to it , that you can
modify that string, all strings go to readonly section.
lets me test my Delphi skills, its been a while :)
type TypeSTOSD = array [0..3]of char;
PTypeSTOSD = ^TypeSTOSD;
procedure modify(myptr:PChar);
begin
ShowMessage(myptr);
PTypeSTOSD(myptr)^:='driz';
(myptr+4)^:='z';
(myptr+5)^:=' ';
PTypeSTOSD(myptr+6)^:='rule';
(myptr+10)^:='s';
(myptr+11)^:=#0;
ShowMessage(myptr);
end;
procedure modify_in_asm(myptr:PChar); stdcall;
asm
push edi
xor ecx,ecx
mov edi,myptr
push ecx
push ecx
push edi
push ecx
call MessageBoxA
mov edx,edi
mov eax,'zird'
stosd
mov eax,'ur z'
stosd
mov eax,'sel'
stosd
xor ecx,ecx
push ecx
push ecx
push edx
push ecx
call MessageBoxA
pop edi
end;
var g_sz:array[0..MAX_PATH] of char;// global buff
procedure TForm1.Button1Click(Sender: TObject);
var l_sz:array[0..MAX_PATH] of char;// local buff
begin
StrCopy(@l_sz,PCHAR(ExtractFilePath(ParamStr(0))));
StrCopy(@g_sz,PCHAR(ExtractFileName(ParamStr(0))));
modify(@l_sz);
modify_in_asm(@g_sz);
end;