3GL   4GL   5GL  

,

(. . , ). , . (symbol tables), (debugging symbols) , , . , , , . "" , . , PDB (Program DataBase ), , . , .

, . , , .

SYM , MS-DOS 16- Windows. SYM- Windows 98. SYM- , 16- . , , WDEB386.

COFF (Common Object File Format ) : , Windows NT 3.1 ( Windows NT). Windows NT Windows NT . COFF , UNIX-, . WINNT.H COFF-, Microsoft e public- . Microsoft , COFF .

7 CodeView MS-DOS Microsoft C/C++ 7. , "CodeView". Microsoft. 7 , Win32, , CL.EXE /Z7 7 Compatible1 Debug Info C/C++ Project Settings.

IDE Microsoft Visul C++.

  /PDB:NONE,   Link Project Settings Customize  Use Program Database. WinDBG Visual C++ , 7. , , 7 . . , 7, , , . "NB11", 7.

7 MSDN "VC5.0 Symbolic Debug Information". . , , Dr. Watson - MSDN. \Include 7. , , .

, , 7, . 7 . -, , - . -, . REBASE.EXE, (, PDB), .

PDB , Visual C++, Visual Basic. 7, PDB- , , . , Visual C++ 6 /PDBTYPE:SEPT, VC60.PDB, <-->.. . , , j , , PDB-, /PDBTYPE:CON. , Visual Basic .

, PDB- , . . >: "NB10" PDB-, , PDB-. PDB 7. Microsoft . , PDB- Microsoft .

DBG , , , . COFF 7. DBG- , (Portable Executable), Win32. DBG- REBASE.EXE, COFF 7 DBG-. REBASE.EXE , PDB-, . DBG- MSDN-- REBASE.EXE. Microsoft DBG-, Windows 2000 PDB-. , , , , . , DBG- . Disassembly.

, . Microsoft. DUMPBIN.EXE, /SYMBOLS. (DUMPBIN.EXE Visual C++.) . , Microsoft , , . - - , .

Working Set Tuner (WST), Platform SDK. WST , , Microsoft . :

if ( TRUE = blsError)

{ <- .

// . 

} <- .

Microsoft , . - (fixup1) , Microsoft , .

DBGHELP.DLL Microsoft. DBGHELP.DLL PDB, COFF 7. IMAGEHLP.DLL, Microsoft DLL, . , , IMAGEHLP.DLL, (symbol engine exports). IMAGEHLP.DLL DBGHELP.DLL. MSDN- IMAGEHLP.DLL.

DBGHELP.DLL . , . , . DBGHELP.DLL , . , , , .

WDBG - ( C++), ( SYMBOLENGINE.H) 4-7. BUGSLAYERUTIL.DLL. API DBGHELP.DLL, , IMAGEHLP.DLL. SYMBOLENGINE.H , IMAGEHLP.DLL.

 Fixup (, , ). .

 4-7. SYMBOLENGINE.H

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - -

"Debugging Applications" (Microsoft Press)

Copyright (c) 1997-2000 John Robbins All rights reserved.

- - - - - - - -- - - - - - - - - - - - - - - - - - - - - - 

- DBGHELP.DLL. , HANDLE-. DBGHELP.DLL , .

 - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - 

:

DO_NOT_WORK_AROUND_SRCLINE_BUG  

SymGetLineFromAddr, PDB fMile .

USE_BUGSLAYERUTIL  

BSUSymlnitialize BUGSLAYERUTIL.DLL. , 32- Windows- . SYMBOLENGINE. BUGSLAYERUTIL.H.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#ifndef _SYMBOLENGINE_H

#define _SYMBOLENGINE_H

// IMAGEHLP.DLL, DBGHELP.DLL.

# include "imagehlp.h"

#include <tchar.h>

// ,

//

#pragma comment (lib, "dbghelp. lib")

#pragma comment (lib, "version, lib")

// - ,

// , - MSJ

// (Paul DiLascia). , !;

// IMAGEHLP_SYMBOL,

// .

// - IMAGEHLP_MODULE

struct CImageHlp_Module : public IMAGEHLP_MODULE

{

CImageHlp_Module ()

{

memset ( this, NULL, sizeof ( IMAGEHLP_MODULE));

SizeOfStruct = sizeof ( IMAGEHLP_MODULE); 

}

};

// - IMAGEHLP_LINE 

struct CImageHlp_Line : public IMAGEHLP_LINE 

{

CImageHlp_Line () 

{

memset ( this, NULL, sizeof ( IMAGEHLP_LINE)); 

SizeOfStruct = sizeof ( IMAGEHLP_LINE); 

}

};

// class CSymbolEngine

{

/*- - - - - - - - - - - - - - - - - - - - - - - - - -

Public-  

- - - -- - - - - - - - - - - - - - - - - - - - - - - - - - */

public :

// , Symlnitialize

//

// DBGHELP.DLL

CSymbolEngine ( void)

{

}

virtual -CSymbolEngine ( void)

{

}

/ *- - - - - - - - - - - - - - - - - - - - - - - - - - - -

public-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

public :

// DBGHELP.DLL.

// ,

// :

// wsprintf ( szVer ,

// _ ( "%d.%02d.%d.%d"),

// HIWORD ( dwMS)

// LOWORD ( dwMS)

// HIWORD ( dwLS)

// LOWORD ( dwLS) );

// szVer : 5.00.1878.1

BOOL GetlmageHlpVersion ( DWORD & dwMS, DWORD & dwLS)

{

return( GetlnMemoryFileVersion ( _T ( "DBGHELP.DLL"),

dwMS , 

dwLS ) ) ; 

}

BOOL GetDbgHelpVersion ( DWORD & dwMS, DWORD & dwLS)

 {

return( GetlnMemoryFileVersion ( __T ( "DBGHELP.DLL"),

dwMS , 

dwLS ) ) ; 

}

// DLL-, PDB.

 BOOL GetPDBReaderVersion ( DWORD & dwMS, DWORD & dwLS)

 {

// MSDBI.DLL.

if ( TRUE == GetlnMemoryFileVersion ( _T ( "MSDBI.DLL"),

dwMS ,

 dwLS ) )

 {

return ( TRUE); 

}

else if.( TRUE == GetlnMemoryFileVersion ( _T ( "MSPDB60.DLL"),

dwMS

dwLS ) ) 

{

return ( TRUE); 

}

// MSPDB50.DLL. 

return ( GetlnMemoryFileVersion ( _T ( "MSPDB50.DLL"),

dwMS

dwLS ) ) ;

 }

// , .

 BOOL GetlnMemoryFileVersion ( LPCTSTR szFile,

DWORD & dwMS , 

DWORD & dwLS ) 

{

HMODULE hlnstlH = GetModuleHandle ( szFile);

//

TCHAR sz!mageHlp[ MAX_PATH ];

GetModuleFileName ( hlnst-IH, szImageHlp, MAX_PATH);

dwMS = 0;

dwLS = 0;

// .

DWORD dwVerlnfoHandle;

DWORD dwVerSize;

dwVerSize = GetFileVersionlnfoSize ( szImageHlp ,

SdwVerlnfoHandle ); 

if ( 0 == dwVerSize) 

{

return ( FALSE); 

}

// ,

 // .

LPVOID IpData = (LPVOID)new TCHAR [ dwVerSize ]; 

if ( FALSE == GetFileVersionlnfo ( szImageHlp ,

dwVerlnfoHandle , dwVerSize , IpData )) 

{

delete [] IpData; return ( FALSE);

 }

VS_FIXEDFILEINFO * IpVerlnfo; 

UINT uiLen;

BOOL bRet = VerQueryValue ( IpData ,

_T ( "\\")

  (LPVOID*)SlpVerlnfo, &uiLen ) ;

 if ( TRUE == bRet)

 {

dwMS = lpVerInfo->dwFileVersionMS;

 dwLS = lpVer!nfo->dwFileVersionLS;

 }

delete [] IpData; return ( bRet);

}

 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

public :

BOOL Symlnitialize ( IN HANDLE hProcess ,

 IN LPSTR UserSearchPath, 

IN BOOL flnvadeProcess )

 {

m_hProcess = hProcess;

return ( ::Symlnitialize ( hProcess ,

UserSearchPath, fInvadeProcess ));

 }

#ifdef USE_BUGSLAYERUTIL

BOOL BSUSymlnitialize ( DWORD dwPID ,

HANDLE hProcess ,

 PSTR UserSearchPath,

 BOOL flnvadeProcess ) 

{

m_hProcess = hProcess;

return ( ::BSUSymlnitialize ( dwPID ,

hProcess , UserSearchPath, flnvadeProcess ));

 }

#endif // USE_BUGSLAYERUTIL 

BOOL SymCleanup ( void) 

{

return ( ::SymCleanup ( m_hProcess)) ;

}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Public-

- - - - - - - - - - - - - - - - - - - - - - - - - - * /

public :

BOOL SymEnumerateModules ( IN PSYM_ENUMMODULES_CALLBACK

EnumModulesCallback, 

IN PVOID UserContext) 

{

return ( ::SymEnumerateModules ( m_hProcess ,

EnumModulesCallback , 

UserContext )) ; 

}

BOOL SymLoadModule { IN HANDLE hFile , 

IN PSTR ImageName , 

IN PSTR ModuleName , 

IN DWORD BaseOfDll ,

 IN DWORD SizeOfDll ) 

{

return ( ::SymLoadModule ( m_hProcess ,

hFile

ImageName ,

 ModuleName , 

BaseOfDll SizeOfDll )); 

BOOL EnumerateLoadedModules ( IN PENUMLOADED_MODULES_CALLBACK

EnumLoadedModulesCallback,

 IN PVOID UserContext )

{

return ( ::EnumerateLoadedModules ( m_hProcess ,

EnumLoadedModulesCallback, 

UserContext )); 

}

BOOL SymUnloadModule ( IN DWORD BaseOfDll) 

{

return ( ::SymUnloadModule ( m_hProcess, BaseOfDll)); 

BOOL SymGetModulelnfo ( IN DWORD dwAddr

OUT PIMAGEHLP__MODULE Modulelnfo ) 

{

return ( ::SymGetModulelnfo ( m_hProcess ,

dwAddr ,

 Modulelnfo )); 

}

DWORD SymGetModuleBase ( IN DWORD dwAddr) 

{

return ( ::SymGetModuleBase ( m_hProcess, dwAddr));

 }

 /*- - - - - - - - - - - - - - - - - - - - - - - - - - 

Public-

- - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

public :

BOOL SymEnumerateSymbols ( IN DWORD BaseOfDll,

IN PSYM_ENUMSYMBOLS_CALLBACK

EnumSymbolsCallback,

IN PVOID UserContext) 

{

return ( ::SymEnumerateSymbols ( m_hProcess ,

BaseOfDll

EnumSymbolsCallback, 

UserContext )); 

}

BOOL SymGetSymFromAddr ( IN DWORD dwAddr ,

OUT PDWORD pdwDisplacement, 

OUT PIMAGEHLP_SYMBOL Symbol ) 

{

return ( ::SymGetSymFromAddr ( m_hProcess ,

dwAddr , 

pdwDisplacement , 

Symbol )); 

}

BOOL SymGetSymFromName ( IN LPSTR Name ,

OUT PIMAGEHLP_SYMBOL Symbol )

{

return ( ::SymGetSymFromName ( m_hProcess,

Name ,

 Symbol }}; 

}

BOOL SymGetSymNext ( IN OUT PIMAGEHLP_SYMBOL Symbol)

 {

return ( ::SymGetSymNext ( m_hProcess, Symbol)); 

}

BOOL SymGetSymPrev ( IN OUT PIMAGEHLP_SYMBOL Symbol)

 {

return ( ::SymGetSymPrev ( m_hProcess, Symbol));

}

 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Public-

- - - -- - - - - - - - - - - - - - - - - - - - - - - - - */

public :

BOOL SymGetLineFromAddr ( IN DWORD dwAddr ,

OUT PDWORD pdwDisplacement, OUT PIMAGEHLP_LINE Line ) 

{

# ifde f DO_NOT_WORK_AROUND_SRCLINE_BUG

// , main-

 return ( ::SymGetLineFromAddr ( m_hProcess ,

dwAddr 

, pdwDisplacement, 

Line ) ) ;

#else

// ,

 // ( ),

 // .

 // , 100 .

 DWORD dwTempDis = 0;

while ( FALSE == ::SymGetLineFromAddr ( m_hProcess ,

dwAddr dwTempDis ,

 pdwDisplacement , 

Line ) ) 

}

dwTempDis += 1;

if ( 100 == dwTempDis)

{

return ( FALSE); 

}

}

if (0 != dwTempDis)

 {

*pdwDisplacement = dwTempDis; 

}

return { TRUE);

#endif // DO_NOT_WORK_AROUND_SRCLINE_BUG 

}

BOOL SymGetLineFromName ( IN LPSTR ModuleName ,

IN LPSTR FileName ,

 IN DWORD dwLineNumber ,

 OUT PLONG plDisplacement , 

IN OUT PIMAGEHLP_LINE Line ) 

{

return ( ::SymGetLineFromName ( m_hProcess ,

ModuleName , 

FileName , 

dwLineNumber ,

plDisplacement , 

Line ) ) ; 

}

BOOL SymGetLineNext ( IN OUT PIMAGEHLP_LINE Line) 

{

return ( ::SymGetLineNext ( m_hProcess, Line)); 

}

BOOL SymGetLinePrev ( IN OUT PIMAGEHLP_LINE Line) 

{

return ( ::SymGetLinePrev ( m_hProcess, Line));

 }

BOOL SymMatchFileName ( IN LPSTR FileName ,

IN LPSTR Match , 

OUT LPSTR * FileNameStop ,

 OUT LPSTR * MatchStop ) 

{

return ( ::SymMatchFileName ( FileName ,

Match , 

FileNameStop , 

MatchStop ));

 } 

/*- - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - -

public-

- - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - -*/

public :

LPVOID SymFunctionTableAccess ( DWORD AddrBase)

 {

return ( ::SymFunctionTableAccess ( m_hProcess, AddrBase)); 

}

BOOL SymGetSearchPath ( OUT LPSTR SearchPath ,

IN DWORD SearchPathLength ) 

{

return ( ::SymGetSearchPath ( m_hProcess ,

SearchPath , 

SearchPathLength )); 

}

BOOL SymSetSearchPath ( IN LPSTR SearchPath) 

{

return ( ::SymSetSearchPath ( m_hProcess, SearchPath)); 

BOOL SymRegisterCallback ( IN PSYMBOL_REGISTERED_CALLBACK

CallbackFunction,

IN PVOID UserContext ) 

{

return ( ::SymRegisterCallback ( m_hProcess ,

CallbackFunction , 

UserContext ));

}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

protected :

// ,  

// .

 // , . 

HANDLE m_hProcess ;

};

ttendif // _SYMBOLENGINE_H

Windows 2000 , Microsoft, . , IMAGEHLP.DLL, . , . , DBGHELP.DLL , . , Platform SDK. www.microsoft.com MSDN. DBGHELP.DLL, , DBGHELP.DLL PATH.

DBGHELP.DLL , , . DBG- DBGHELP.DLL :

, , . , - DLL, C:\MyFiles, :

DBG- .

PDB- , DBGHELP.DLL PDB- PDB . DBGHELP.DLL PDB- , , DBG- (. . , ).

  DBG-. .

  , PDB-, . .

, . DBGHELP.DLL API- stackwalk, . WDBG , Visual C++. STACKFRAME. 4-8 , . stackwalk , , . , , . . , . Visual C++ Visual Basic , , , . , , FPO (Frame Pointer Omission). FPO- , stackwalk , , . FPO- , MSDN . FPO- WINNT.H.

  4-8. InitializeStackFrameWithGontext i386CPUHELP.C

BOOL CPUHELP_DLLINTERFACE _stdcall

InitializeStackFrameWithContext ( STACKFRAME * pStack,

CONTEXT * pCtx)

{

ASSERT ( FALSE == IsBadReadPtr ( pCtx, sizeof ( CONTEXT))); 

ASSERT ( FALSE == IsBadWritePtr ( pStack, sizeof ( STACKFRAME)) 

} ;

if ( ( TRUE == IsBadReadPtr ( pCtx, sizeof ( CONTEXT))) ||

( TRUE == IsBadWritePtr ( pStack, sizeof ( STACKFRAME)))) 

{

return ( FALSE);

 }

pStack->AddrPC.Offset = pCtx->Eip; 

pStack->AddrPC.Mode = AddrModeFlat ;

 pStack->AddrStack.Offset = pCtx->Esp;

 pStack->AddrStack.Mode = AddrModeFlat ;

 pStack->AddrFrame.Offset = pCtx->Ebp;

 pStack->AddrFrame.Mode = AddrModeFlat ;

 return ( TRUE); 

}

        3GL   4GL   5GL  

, - , . , , , .. , . . , " ".




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution