...
This noncompliant code example assigns the address of the printf()
function to the log_fn
function pointer, which can be allocated in the stack or data segment.:
Code Block | ||||
---|---|---|---|---|
| ||||
int (*log_fn)(const char *, ...) = printf; /* ... */ log_fn("foo"); |
...
Microsoft Windows provides the EncodePointer()
and DecodePointer()
functions that encrypt and decrypt pointers using a secret that is unique to the given process.:
Code Block | ||||
---|---|---|---|---|
| ||||
int (*log_fn)(const char *, ...) = EncodePointer(printf); /* ... */ DecodePointer(log_fn)("foo"); |
...