This just looks like an inefficient string copy routine, it copies string onto stack then calls some other function, i'm guessing it is stdcall, not sure what Adr is or doing in the called function. Note that is aligns memory on 4 bytes for speed copy of dword's but i don't see it writing any left over bytes. Also what is _EAX, _EDX, _ECX ? you need to post all variables used so i can convert it.
Is RegCall a param? can you post the function declaration?
Code:
procedure YourProc(StkAdr: PAnsiChar; StkUsage: LongWord);
var
stkDest: array of AnsiChar;
nLen: LongWord;
begin
SetLength(stkDest, stkUsage);
StrLCopy(@stkDest[0], stkAdr, StkUsage);
if RegCall = True then begin
//_EAX, _EDX etc ???
Adr( _EAX, _EDX, _ECX);
end else
Adr( .... // this does not make sense what your function is doing, no params? if so this needs to be cdecl and this function needs to correct the stack.
end;
Also if RegCall is false, then your stack is going to become corrupt. Since stdcall requires you pass the params that it expects, you could get away with this with cdecl but not stdcall.
Bookmarks