Initializes a stack guard cookie.
Unit
Syntax
procedure __initialize_security_cookie(
out ASecurityCookie: Pointer
);
Parameters
ASecurityCookie [out]
Returns transparent "magic" value. This must be a local variable in the function. The local variable must be listed first.
Remarks
This function initializes ASecurityCookie argument with some "magic" value, which is supposed to stay unchanged during execution of current routine. If stack corruption occurs (e.g. buffer overflow damages the stack) - then this value will be changed. This change can be detected later by the __security_check_cookie function.
This function also protects against overwrites of return address. In other words, if function's return address will be changed/corrupted/overwritten between calls to the __security_check_cookie/__security_check_cookie functions - an error will be triggered.
Examples
procedure DoSomething;
var
Cookie: Pointer; // MUST be the first local variable
// ... other local variables
begin
__initialize_security_cookie(Cookie);
// ... you normal code for DoSomething goes here
__security_check_cookie(Cookie); // will throw an error if stack corruption is detected
// or:
// __security_check_cookie(Cookie, 'Unit1.DoSomething');
// or:
// __security_check_cookie(Cookie, PChar(__LOCATION__)); // uses EDebugInfo, not recommended
end;
See also
| Send feedback... |
Build date: 2026-10-21 Last edited: 2026-10-21 |
|
PRIVACY STATEMENT The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed. Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_function_ELowLevel___initialize_security_cookie |
|