|
I think you have to set the last parameter to true to load the symbols directly SymInitialize(GetCurrentProcess(),NULL,TRUE); or use SymLoadModule64 to get an base module address that you can use with your SymEnumSymbols call.
Here I found some cpp on the net maybe that helps.
Greetings
Covean
|
|
|
|
|
|
The problem with your code is, that you don't load any symbols that SymEnumSymbols can enumerate.
The number 64 at the end just says that it is an 64 bit-compatible function.
SysLoadModule64 supersedes the old function SysLoadModule, that just worked on an 32 bit
os. The new function works on an 32 as well as 64 bit os.
From MSDN:
"Where necessary, the DbgHelp library has been widened to support both 32- and 64-bit Windows. The original function and structure definitions are still in DbgHelp.h, but there are also updated versions of these definitions that are compatible with 64-bit Windows. If you use the updated functions in your code, it can be compiled for both 32- and 64-bit Windows. Your code will also be more efficient, since the original functions simply call the updated functions to perform the work.
For example, DbgHelp.h contains definitions for SymUnloadModule (original function) and SymUnloadModule64 (updated function). These definitions are nearly identical, but use different types for the BaseOfDll parameter. (SymUnloadModule uses the DWORD type, while SymUnloadModule64 uses the DWORD64 type.) If you write your code to use SymUnloadModule64, it can be compiled for both 32- and 64-bit Windows. The code is also more efficient than if it were to call SymUnloadModule."
Greetings
Covean
|
|
|
|
|
I just compiled every thing with 64 bit compatibility functions , means SymLoadModule64(..,..,..) and others.
now it returns error code which I checked from GetLastError() is 87(desc : ERROR_INVALID_PARAMETER i.e Parameter is incorrect)
??
|
|
|
|
|
How I hate this f...ing error code ERROR_INVALID_PARAMETER, often this can mean anything...
Can you please post your code? (from init to the call)
Have you tried the code I found on the net?
Greetings
Covean
|
|
|
|
|
exactly that code I am just trying upto large extent..
Here it's
string strPDBPath = "..//..//MathDLL//Release//MathDLL.pdb"
HANDLE hProcess = GetCurrentProcess();
DWORD symOptions = SymGetOptions();
DWORD oldOptions = symOptions;
symOptions|=SYMOPT_PUBLICS_ONLY;
SymSetOptions(symOptions);
bRet = ::SymInitialize(GetCurrentProcess(),NULL,FALSE);
if(bRet==FALSE)
{
_tprintf(_T("Error: SymInitialize() failed. Error code: %u \n"), ::GetLastError());
return 0;
}//end of if
do
{
DWORD BaseAddr = 0;
DWORD FileSize = 0;
// Determine the base address and the file size
const TCHAR* pFileName = (char*)strPDBPath.c_str();// = argv[1];
_tprintf(pFileName,"%s",(char*)strPDBPath.c_str());
if( !GetFileParams( pFileName, BaseAddr, FileSize ) )
{
_tprintf( _T("Error: Cannot obtain file parameters (internal error).\n") );
break;
}
DWORD ModBase = ::SymLoadModule (
GetCurrentProcess(), // Process handle of the current process
NULL, // Handle to the module's image file (not needed)
pFileName, // Path/name of the file
NULL, // User-defined short name of the module (it can be NULL)
BaseAddr, // Base address of the module (cannot be NULL if .PDB file is used, otherwise it can be NULL)
FileSize // Size of the file (cannot be NULL if .PDB file is used, otherwise it can be NULL)
);
if( ModBase == 0 )
{
_tprintf(_T("Error: SymLoadModule() failed. Error code: %u \n"), ::GetLastError());
break;
}
_tprintf( _T("\nLoad address: %u \n"), ModBase );
// Obtain and display information about loaded symbols
ShowSymbolInfo( ModBase );
// Enumerate symbols and display information about them
//if( pSearchMask != NULL )
if((char*)pSearchMask.c_str()!=NULL)
_tprintf( _T("Search mask: %s \n"), (char*)pSearchMask.c_str() );
_tprintf( _T("\nSymbols: \n") );
int NumLocals = 0;
bRet = ::SymEnumSymbols(GetCurrentProcess(),0,0,MyEnumSymbolsCallback,&NumLocals);
Here its code
|
|
|
|
|
You are loading the symbols now, but you don't set the module base (BaseDLL) parameter in your SymEnumSymbols call.
Try:
bRet = ::SymEnumSymbols(GetCurrentProcess(),ModBase,0,MyEnumSymbolsCallback,&NumLocals);
Hope that works, if not please repost your question, because I don't have any time left for today to answer.
Greetings
Covean
|
|
|
|
|
Sir its failing here at first..
void ShowSymbolInfo( DWORD64 ModBase )
{
// Get module information
IMAGEHLP_MODULE64 ModuleInfo;
memset(&ModuleInfo, 0, sizeof(ModuleInfo) );
ModuleInfo.SizeOfStruct = sizeof(ModuleInfo);
<b>BOOL bRet = ::SymGetModuleInfo64( GetCurrentProcess(), ModBase, &ModuleInfo ); //failing here and says 'incorrect parameter'</b>
.......
.......
}
and i also checked by giving ModeBase still it's giving same error code (incorrect parameter)
|
|
|
|
|
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 .
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
|
|
|
|
|
Code for GetFileParams() ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
bool GetFileParams( const TCHAR* pFileName, DWORD64& BaseAddr, DWORD& FileSize )
{
// Check parameters
if( pFileName == 0 )
{
return false;
}
// Determine the extension of the file
TCHAR szFileExt[_MAX_EXT] = {0};
_tsplitpath( pFileName, NULL, NULL, NULL, szFileExt );
// Is it .PDB file ?
if( _tcsicmp( szFileExt, _T(".PDB") ) == 0 )
{
// Yes, it is a .PDB file
// Determine its size, and use a dummy base address
BaseAddr = 0x10000000; // it can be any non-zero value, but if we load symbols
// from more than one file, memory regions specified
// for different files should not overlap
// (region is "base address + file size")
if( !GetFileSize( pFileName, FileSize ) )
{
return false;
}
}
else
{
// It is not a .PDB file
// Base address and file size can be 0
BaseAddr = 0;
FileSize = 0;
}
// Complete
return true;
}
bool GetFileSize( const TCHAR* pFileName, DWORD& FileSize )
{
// Check parameters
if( pFileName == 0 )
{
return false;
}
// Open the file
HANDLE hFile = ::CreateFile( pFileName, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL );
if( hFile == INVALID_HANDLE_VALUE )
{
_tprintf( _T("CreateFile() failed. Error: %u \n"), ::GetLastError() );
return false;
}
// Obtain the size of the file
FileSize = ::GetFileSize( hFile, NULL );
if( FileSize == INVALID_FILE_SIZE )
{
_tprintf( _T("GetFileSize() failed. Error: %u \n"), ::GetLastError() );
// and continue ...
}
// Close the file
if( !::CloseHandle( hFile ) )
{
_tprintf( _T("CloseHandle() failed. Error: %u \n"), ::GetLastError() );
// and continue ...
}
// Complete
return ( FileSize != INVALID_FILE_SIZE );
}
|
|
|
|
|
I want to make an application consisting of text boxes, radio buttons and check buttons. I did it in visual basic.
But i want to know that is there is any difference between what we program in Code Blocks and in Visual C ?
|
|
|
|
|
Razanust wrote: I want to make an application consisting of text boxes, radio buttons and check buttons. I did it in visual basic.
Either you did or didn't.
Razanust wrote: But i want to know that is there is any difference between what we program in Code Blocks and in Visual C ?
Have you read what either one is? Code::Blocks is a C++ IDE whereas Visual C++ is a language. Do you want to compare Code::Blocks with Visual Studio instead?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Razanust wrote: is any difference between what we program in Code Blocks and in Visual C ?
yes, huge differences.
|
|
|
|
|
Hi ,
I am working on Windows 7 operating system. I have created a window application . When I minimize that window it get minimize properly but when I try to Maximize it its not able to Maximize . It is not showing any error , it just keep itself in the taskbar. Please tell me how can I proceed in this.
The window is getting maximize succesfuly in other Operating system like Vista and XP.
Thanks in Advance
|
|
|
|
|
what code is running when maximized?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Please,
would it be possible
to enumerate all MB-advantages shortly ?
Thank you !
virtual void BeHappy() = 0;
modified on Wednesday, March 24, 2010 7:38 AM
|
|
|
|
|
Fixed-length vs variable-length UNICODE, the first that comes in my mind:
UTF-8 is pretty much everywhere and the most used variable-length UNICODE encoding ("multibyte"). Alone for compatibility in network applications or together with XML it could be a very good idea to choose it, probably because it is a "fits-all" format. It is able to represent any UNICODE character, yet backwards compatible with ASCII (7 bit). Also see UTF-8 advantages and disadvantages[^].
/M
|
|
|
|
|
Thank you, Moak !
(I did not know, that "multibyte" does mean "UTF-8"... )
virtual void BeHappy() = 0;
|
|
|
|
|
That is incorrect MBCS and Unicode are different things. See http://msdn.microsoft.com/en-us/library/5z097dxa.aspx. VC++ implements MSCS as DBCS (Double Byte Character Sets).
-Saurabh
P.S. Some how auto links are not working.
|
|
|
|
|
MBCS is not same as Unicode as reported by other poster. See http://msdn.microsoft.com/en-us/library/5z097dxa.aspx for details.
-Saurabh
P.S. Some how auto links are not working.
|
|
|
|
|
Thank you, Saurabh !
(I would prefer to use UNICODE
since there is no a "size-fixed character type" (like TCHAR )
to use with MBCS sequences, and it (MBCS) is not fully supported in MFC... )
virtual void BeHappy() = 0;
|
|
|
|
|
You are welcome. If you are interested then you can read more about it in excellent articles from Michael Dunn.
http://www.codeproject.com/KB/string/cppstringguide1.aspx
http://www.codeproject.com/KB/string/cppstringguide2.aspx
-Saurabh
|
|
|
|
|
|
Hi,
Im writting mpeg files into ASF container.Its written successfully and run on VLC fine.But its not getting played in WMP.First,it shows the error message as "DX50 codec is not installed on ur system"..so,i have installed.still its npt getting played in WMP even its showing the corrct time.video is missing.how to solve this?
|
|
|
|
|