Click here to Skip to main content
15,905,915 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
glitteringsound24-Mar-10 5:30
glitteringsound24-Mar-10 5:30 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
Covean24-Mar-10 5:38
Covean24-Mar-10 5:38 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
glitteringsound24-Mar-10 5:50
glitteringsound24-Mar-10 5:50 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
Covean24-Mar-10 6:00
Covean24-Mar-10 6:00 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
glitteringsound24-Mar-10 6:07
glitteringsound24-Mar-10 6:07 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
Covean24-Mar-10 6:18
Covean24-Mar-10 6:18 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
glitteringsound24-Mar-10 6:42
glitteringsound24-Mar-10 6:42 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
Covean25-Mar-10 3:25
Covean25-Mar-10 3:25 
This code works on my machine and I hope also on yours. You only have to add some checks.
I hope my C++ is not that cruel Laugh | :laugh: .

char szPDBFile[] = "<path to pdb file>\\Symbols.pdb";
HANDLE hProcess = GetCurrentProcess();
BOOL bRet = FALSE;

bRet = SymInitialize(hProcess, NULL, FALSE);
HANDLE hFile = CreateFileA((LPCSTR)&szPDBFile, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dwFileSize = GetFileSize(hFile, NULL);
CloseHandle(hFile);

DWORD64 dwModBase = SymLoadModule64(hProcess, NULL, (LPCSTR)&szPDBFile, NULL, 0x10000000, dwFileSize);
bRet = SymEnumSymbols(hProcess, dwModBase, NULL, MyEnumSymbolsCallback, NULL);
bRet = SymUnloadModule64(hProcess, dwModBase);
bRet = SymCleanup(hProcess);


BOOL CALLBACK MyEnumSymbolsCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
    return TRUE;
}


In this example I used the fixed base 0x10000000. If you need to load more than one pdb you have calculate this address and make sure the pdbs do not overlap in memory.


Examble:

1. PDB = 0x10000000
2. PDB = 0x10000000 + file size of 1. PDB
3. PDB = 0x10000000 + file size of 1. PDB + file size of 2. PDB
...


In addition make sure not to cause an exception in your callback, because SymEnumSymbols will return false (and GetLastError returns 0xC0000005 if you cause an access violation).
Greetings
Covean

GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
cmk24-Mar-10 12:28
cmk24-Mar-10 12:28 
GeneralRe: SymEnumSymbols is getting failed even GetLastError returns 0 Pin
glitteringsound24-Mar-10 20:27
glitteringsound24-Mar-10 20:27 
QuestionDifference between C and Visual C. Pin
Razanust24-Mar-10 4:17
Razanust24-Mar-10 4:17 
QuestionRe: Difference between C and Visual C. Pin
David Crow24-Mar-10 4:32
David Crow24-Mar-10 4:32 
AnswerRe: Difference between C and Visual C. Pin
Chris Losinger24-Mar-10 7:10
professionalChris Losinger24-Mar-10 7:10 
QuestionWindow is not getting Maximize on WINDOWS 7 operating system Pin
pandit8424-Mar-10 2:30
pandit8424-Mar-10 2:30 
AnswerRe: Window is not getting Maximize on WINDOWS 7 operating system Pin
KarstenK24-Mar-10 3:16
mveKarstenK24-Mar-10 3:16 
Question[solved] What benefit has a MULTIBYTE application compared to a UNICODE version ? [modified] Pin
Eugen Podsypalnikov24-Mar-10 0:45
Eugen Podsypalnikov24-Mar-10 0:45 
AnswerRe: What benefit has a MULTIBYTE application compared to a UNICODE version ? Pin
Moak24-Mar-10 1:02
Moak24-Mar-10 1:02 
GeneralRe: What benefit has a MULTIBYTE application compared to a UNICODE version ? Pin
Eugen Podsypalnikov24-Mar-10 1:38
Eugen Podsypalnikov24-Mar-10 1:38 
GeneralRe: What benefit has a MULTIBYTE application compared to a UNICODE version ? Pin
Saurabh.Garg24-Mar-10 17:41
Saurabh.Garg24-Mar-10 17:41 
AnswerRe: [solved] What benefit has a MULTIBYTE application compared to a UNICODE version ? Pin
Saurabh.Garg24-Mar-10 17:43
Saurabh.Garg24-Mar-10 17:43 
GeneralRe: [solved] What benefit has a MULTIBYTE application compared to a UNICODE version ? Pin
Eugen Podsypalnikov24-Mar-10 21:19
Eugen Podsypalnikov24-Mar-10 21:19 
GeneralRe: [solved] What benefit has a MULTIBYTE application compared to a UNICODE version ? Pin
Saurabh.Garg24-Mar-10 21:35
Saurabh.Garg24-Mar-10 21:35 
GeneralRe: [solved] What benefit has a MULTIBYTE application compared to a UNICODE version ? Pin
Moak24-Mar-10 22:27
Moak24-Mar-10 22:27 
QuestionWindows Media Player Pin
gmallax24-Mar-10 0:39
gmallax24-Mar-10 0:39 
AnswerRe: Windows Media Player Pin
KarstenK24-Mar-10 3:18
mveKarstenK24-Mar-10 3:18 

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.