How do you convert C++ _tcscpy, _tcscat to Delphi? -


i'm converting this code c++ delphi don't following part of code. can explain me following code means; what's happening szbuff buffer ?

i'm pretty sure it's such kind of formatting (replacement), don't know expected result , can't find sensible documentation of used functions (maybe i'm lame :)

can me translation of code delphi (or direct me proper documentation) ?

i don't how convert kind of questions myself, mentioned @ least function names in question title might searchable else in future.

function tsecinfo.buildsecurityattributes(var secattrs: tsecurityattributes): boolean; var   pszsiduser: pchar;   szbuff: array [0..1024] of char; begin  // pszsiduser @ time contains user sid // s-1-5-21-1454471165-1004336348-1606980848-5555  // tchar szbuff[1024]; // i'm not sure array [0..1024] of char;    _tcscpy(szbuff, _t("d:"));   _tcscat(szbuff, _t("(a;;ga;;;"));   _tcscat(szbuff, pszsiduser);   _tcscat(szbuff, _t(")"));   _tcscat(szbuff, _t("(a;;gwgr;;;an)"));   _tcscat(szbuff, _t("(a;;gwgr;;;wd)"));  ...    _tcscat(szbuff, _t("s:(ml;;nw;;;s-1-16-0)"));  end; 

for interested in what's whole code link can tell should trick how access network pipes writing anonymous user on windows vista above. whole article follow this link.

thanks time
regards

_tcscpy , _tcscat tchar macro versions of c standard library functions strcpy , strcat copying , concatenating c strings. evaluate ansi or unicode versions depending on whether or type of project targeting. it's c code rather c++ code in view.

in delphi use string variables this:

function tsecinfo.buildsecurityattributes(var secattrs: tsecurityattributes): boolean; var   pszsiduser: pchar;   buff: string; begin   // pszsiduser @ time contains user sid   // s-1-5-21-1454471165-1004336348-1606980848-5555    buff := 'd:(a;;ga;;;'+pszsiduser+')(a;;gwgr;;;an)(a;;gwgr;;;wd)s:(ml;;nw;;;s-1-16-0)';   someotherwindowsapicall(pchar(buff));     end; 

presumably in c code there call windows api function receives lpctstr. c code pass szbuff can pass pchar(buff) have shown above.

the c code using fixed length buffer because doesn't have available dynamically allocated string class delphi's string or std::string in c++. fixed length buffers lead buffer overruns. in delphi don't use fixed length buffer if can avoid it.

this classic example of why languages built in string handling easier work c.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -