Click here to Skip to main content
15,887,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: char* problem Pin
ddmcr21-Sep-05 3:26
ddmcr21-Sep-05 3:26 
GeneralRe: char* problem Pin
David Crow21-Sep-05 3:54
David Crow21-Sep-05 3:54 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 4:20
Blake Miller21-Sep-05 4:20 
GeneralRe: char* problem Pin
David Crow21-Sep-05 4:33
David Crow21-Sep-05 4:33 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 5:00
Blake Miller21-Sep-05 5:00 
GeneralRe: char* problem Pin
David Crow21-Sep-05 6:37
David Crow21-Sep-05 6:37 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 6:45
Blake Miller21-Sep-05 6:45 
GeneralRe: char* problem Pin
Blake Miller21-Sep-05 6:49
Blake Miller21-Sep-05 6:49 
You might find this code snippet I developed interesting:
You can call this to find out if the address is a member of the local stack memory pool or not.
If not, it might be a local function of another thread’s stack, or from the memory allocation pool.

<br />
<br />
BOOL WINAPI IsOnStackOrNot(LPCVOID pObject)<br />
{<br />
    BOOL bRetVal = FALSE;<br />
<br />
    if( pObject ){<br />
<br />
        LPVOID  pStack;<br />
        MEMORY_BASIC_INFORMATION TheMemoryInfo;<br />
<br />
        // get stack address into local value<br />
        _asm mov eax, esp;<br />
        _asm mov pStack, eax;<br />
<br />
        // get memory base of lcoal stack value<br />
        if( sizeof(TheMemoryInfo) <= VirtualQuery(pStack, &TheMemoryInfo, sizeof(TheMemoryInfo)) ){<br />
            // see if our address is within stack allocation range<br />
            // then it is on the stack, otherwise, it is on the heap somewhere<br />
            if( ((DWORD)pObject >= (DWORD)TheMemoryInfo.BaseAddress) &&<br />
                ((DWORD)pObject <= ((DWORD)TheMemoryInfo.BaseAddress + (DWORD)TheMemoryInfo.RegionSize) ) ){<br />
                bRetVal = TRUE;<br />
            }<br />
        }<br />
    }<br />
<br />
    return bRetVal;          <br />
}<br />
<br />


If you also compared address to CURRENT value of ESP and EBP, you could probably deduce if it is a local variable, a parameter, or something from a PREVIOUS function call's stack.
AnswerRe: char* problem Pin
Nish Nishant21-Sep-05 3:11
sitebuilderNish Nishant21-Sep-05 3:11 
AnswerRe: char* problem Pin
mikeorama1234522-Sep-05 6:41
mikeorama1234522-Sep-05 6:41 
QuestionMoving controls on a dialog Pin
bugDanny21-Sep-05 2:56
bugDanny21-Sep-05 2:56 
AnswerRe: Moving controls on a dialog Pin
David Crow21-Sep-05 3:12
David Crow21-Sep-05 3:12 
AnswerRe: Moving controls on a dialog Pin
prasad_som21-Sep-05 3:15
prasad_som21-Sep-05 3:15 
GeneralRe: Moving controls on a dialog Pin
andrewtruckle21-Sep-05 3:23
andrewtruckle21-Sep-05 3:23 
AnswerRe: Moving controls on a dialog Pin
Rage21-Sep-05 3:18
professionalRage21-Sep-05 3:18 
GeneralRe: Moving controls on a dialog Pin
bugDanny21-Sep-05 4:56
bugDanny21-Sep-05 4:56 
QuestionInserting values into tree recursively Pin
rajeevktripathi21-Sep-05 1:54
rajeevktripathi21-Sep-05 1:54 
AnswerRe: Inserting values into tree recursively Pin
David Crow21-Sep-05 3:18
David Crow21-Sep-05 3:18 
QuestionRe: Inserting values into tree recursively Pin
rajeevktripathi21-Sep-05 3:49
rajeevktripathi21-Sep-05 3:49 
AnswerRe: Inserting values into tree recursively Pin
David Crow21-Sep-05 4:05
David Crow21-Sep-05 4:05 
QuestionRe: Inserting values into tree recursively Pin
rajeevktripathi21-Sep-05 18:15
rajeevktripathi21-Sep-05 18:15 
AnswerRe: Inserting values into tree recursively Pin
David Crow22-Sep-05 2:27
David Crow22-Sep-05 2:27 
QuestionUsing Reliable UDP Pin
V.G21-Sep-05 1:41
V.G21-Sep-05 1:41 
AnswerRe: Using Reliable UDP Pin
Mohammad A Gdeisat21-Sep-05 5:34
Mohammad A Gdeisat21-Sep-05 5:34 
QuestionUsing ActiveX wrapper class in MFC console Pin
yccheok21-Sep-05 0:12
yccheok21-Sep-05 0:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.