26 #define MakePtr( cast, ptr, addValue ) ( cast )( (DWORD)( ptr ) + (DWORD)( addValue ) )
48 if ( lpszLibPathName == NULL || pFile.
bad() ) {
49 assert( lpszLibPathName != NULL );
50 assert( pFile.
good() );
51 m_strErrorMsg.assign(
"NULL <lpszLibPathName> or Invalid file handle." );
55 if ( !
Dump( lpszLibPathName, pFile ) )
return FALSE;
76 m_strErrorMsg =
"Unable to access file ";
77 m_strErrorMsg += lpszLibPathName;
83 PSTR pArchiveStartString = (PSTR)libFile.
GetBase();
85 if ( 0 !=
strncmp( pArchiveStartString, IMAGE_ARCHIVE_START, IMAGE_ARCHIVE_START_SIZE ) ) {
86 m_strErrorMsg.assign(
"Not a valid COFF LIB file." );
92 PIMAGE_ARCHIVE_MEMBER_HEADER pMbrHdr;
93 pMbrHdr =
MakePtr( PIMAGE_ARCHIVE_MEMBER_HEADER, pArchiveStartString, IMAGE_ARCHIVE_START_SIZE );
96 PDWORD pcbSymbols = (PDWORD)( pMbrHdr + 1 );
100 DWORD cSymbols = ConvertBigEndian( *pcbSymbols );
104 PDWORD pMemberOffsets = pcbSymbols + 1;
108 PSTR pszSymbolName =
MakePtr( PSTR, pMemberOffsets, 4 * cSymbols );
113 for (
unsigned i = 0; i < cSymbols; i++ ) {
118 offset = ConvertBigEndian( *pMemberOffsets );
123 if ( IsRegularLibSymbol( pszSymbolName ) ) {
124 string symbol( pszSymbolName );
125 if ( IsFiltedSymbol( symbol ) ) { pFile << symbol <<
endl; }
131 pszSymbolName +=
strlen( pszSymbolName ) + 1;
141 if ( 0 ==
strncmp( pszSymbolName,
"__IMPORT_DESCRIPTOR_", 20 ) )
return FALSE;
143 if ( 0 ==
strncmp( pszSymbolName,
"__NULL_IMPORT_DESCRIPTOR", 24 ) )
return FALSE;
145 if (
strstr( pszSymbolName,
"_NULL_THUNK_DATA" ) )
return FALSE;
153 if ( symbolName.
compare( 0, 2,
"__" ) == 0 )
return FALSE;
154 if ( symbolName.
compare( 0, 3,
"??_" ) == 0 && symbolName[3] !=
'0' )
156 if ( symbolName[0] ==
'_' ) {
157 symbolName.
erase( 0, 1 );
160 if ( symbolName.
find(
"detail@boost" ) != string::npos )
return FALSE;
161 if ( symbolName.
find(
"details@boost" ) != string::npos )
return FALSE;
171 temp |= bigEndian >> 24;
172 temp |= ( ( bigEndian & 0x00FF0000 ) >> 8 );
173 temp |= ( ( bigEndian & 0x0000FF00 ) << 8 );
174 temp |= ( ( bigEndian & 0x000000FF ) << 24 );
187 m_hFile = INVALID_HANDLE_VALUE;
189 m_pMemoryMappedFileBase = 0;
194 CreateFile( pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)0 );
196 if ( m_hFile == INVALID_HANDLE_VALUE ) {
200 m_cbFile = ::GetFileSize( m_hFile, 0 );
202 m_hFileMapping = CreateFileMapping( m_hFile, NULL, PAGE_READONLY, 0, 0, NULL );
203 if ( m_hFileMapping == 0 ) {
205 CloseHandle( m_hFile );
206 m_hFile = INVALID_HANDLE_VALUE;
210 m_pMemoryMappedFileBase = (PCHAR)MapViewOfFile( m_hFileMapping, FILE_MAP_READ, 0, 0, 0 );
211 if ( m_pMemoryMappedFileBase == 0 ) {
213 CloseHandle( m_hFileMapping );
215 CloseHandle( m_hFile );
216 m_hFile = INVALID_HANDLE_VALUE;
225 if ( m_pMemoryMappedFileBase ) UnmapViewOfFile( m_pMemoryMappedFileBase );
227 if ( m_hFileMapping ) CloseHandle( m_hFileMapping );
229 if ( m_hFile != INVALID_HANDLE_VALUE ) CloseHandle( m_hFile );