i have the following two C++ methods:
inline void ApplyValue(ulong** IntPtr)
{
// Now this 'some_value' variable is declared only in the containing method's
// stack scope, thus its value "0xDEADBEAF" should only be avaialble in stack
// within the containing method "ApplyValue".
ulong some_value = 0xDEADBEAF;
*IntPtr = &some_value; // Now we have a pointer to our local in stack pointer value.
}
int TestMethod1()
{
ulong* SamplePtr = NULL;
ApplyValue(&SamplePtr);
// Somehow though the source value Pointer, is local to the ApplyValue method,
// Thus, should not be avaialble here, the C++ outputs the correct value
// Loaded within the Child method.
cout << *SamplePtr << endl;
return 0;
}
I believe my problem is self-explanatory from the two methods above, So isn’t it supposed that the Output be invalid or some other value other than “0xDeadBeaf
” as that value is only local to the ApplyValue()
method?