Return strucure from function
<p>hi have this 2 pieces of code in my program:</p>

<pre><code>PIMAGE_IMPORT_DESCRIPTOR PE::GetImportedLibInfo(LPSTR libName )
{
    PIMAGE_DOS_HEADER doshdr = (PIMAGE_DOS_HEADER)EntryPoint;
    PIMAGE_NT_HEADERS nthdr = (PIMAGE_NT_HEADERS)((DWORD)doshdr + doshdr-&gt;e_lfanew);
    DWORD tmp =nthdr-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
    DWORD Rva = RvaToOffset((DWORD)tmp);
    if(Rva != -1)
    {
        Rva += EntryPoint; 
        PIMAGE_IMPORT_DESCRIPTOR iid =(PIMAGE_IMPORT_DESCRIPTOR)(DWORD)Rva;

        while(iid-&gt;Characteristics)
        {
            char* dll = (char*)((DWORD_PTR)RvaToOffset(iid-&gt;Name)+ EntryPoint);
            DWORD res=lstrcmp((LPCSTR)dll,(LPCSTR)libName);
            if(res == 0)
            {
                return iid;
            }
            iid ++;
        }
    }
    return NULL;
}


VOID FillLibInfo(PIMAGE_IMPORT_DESCRIPTOR iiD)
{
    if(iiD != NULL)
    {
        char* buff[20];
        wsprintf((LPSTR)&amp;buff,"%08lX",(DWORD)iiD-&gt;OriginalFirstThunk);
        SetDlgItemText(hImpDlg,IDC_EDIT1,(LPCSTR)&amp;buff);
        wsprintf((LPSTR)&amp;buff,"%08lX",(DWORD)iiD-&gt;TimeDateStamp);
        SetDlgItemText(hImpDlg,IDC_EDIT2,(LPCSTR)&amp;buff);
        wsprintf((LPSTR)&amp;buff,"%08lX",(DWORD)iiD-&gt;ForwarderChain);
        SetDlgItemText(hImpDlg,IDC_EDIT3,(LPCSTR)&amp;buff);
        wsprintf((LPSTR)&amp;buff,"%08lX",(DWORD)iiD-&gt;FirstThunk);
        SetDlgItemText(hImpDlg,IDC_EDIT4,(LPCSTR)&amp;buff);
    }
}
</code></pre>

<p>And then i use it so:</p>

<pre><code>FillLibInfo(GetImportedLibInfo("MyLibName"));
</code></pre>

<p>what append is that my textboxes don't actualize text until i pass mouse hover them</p>

<p>and after a couple of calls to <code>GetImportedLibInfo()</code> the program crash.
i think that is something with stack corrupted...</p>

<p>can someone give me a hint?</p>

<p>@Edit:</p>

<p>Class PE defenition:</p>

<pre><code>class PE
{
private:
DWORD ptrImgDosHeader;
DWORD RvaToOffset(DWORD Rva);
DWORD RvaToMemory(DWORD Rva);

public:
DWORD EntryPoint;
PE(DWORD ptrMemory);
~PE();
VOID EnumSections(BOOL (*ptrCallBack)(PIMAGE_SECTION_HEADER));
VOID EnumImports(BOOL (*ptrCallBack)(LPSTR,DWORD),DWORD);
VOID EnumImportedFunctionsFromLib(LPSTR,BOOL (*ptrCallBack)(LPSTR,LPSTR));
VOID EnumExportedFunctions(BOOL (*ptrCallBack)(LPSTR,LPSTR,LPSTR));
WORD GetPeType();
DWORD ValidatePE();
DWORD ValidateNtHeader();
PIMAGE_IMPORT_DESCRIPTOR GetImportedLibInfo(LPSTR lib);
};
</code></pre>
