home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / pefile.h < prev    next >
C/C++ Source or Header  |  2000-05-12  |  2KB  |  58 lines

  1. #pragma once
  2.  
  3. //-----------------------------------------------------------------------------------//
  4. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  5. //                             ISBN  0-13-086985-6                                   //
  6. //                                                                                   //
  7. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  8. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  9. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  10. //                                                                                   //
  11. //  FileName   : pefile.h                                                             //
  12. //  Description: PE file access                                                      //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. // PE File Access
  17. class KPEFile
  18. {
  19.     char             * m_pBaseAddress;
  20.     IMAGE_DOS_HEADER * m_pDOSHeader;
  21.     IMAGE_NT_HEADERS * m_pNTHeader;
  22.  
  23.     void * RealAddress(unsigned rta)
  24.     {
  25.         if ( rta == 0)
  26.             return NULL;
  27.         else
  28.             return m_pBaseAddress + rta;
  29.     }
  30.  
  31. public:
  32.     KPEFile(void)
  33.     {
  34.         m_pBaseAddress = NULL;
  35.         m_pDOSHeader   = NULL;
  36.         m_pNTHeader    = NULL;
  37.     }
  38.  
  39.     bool Load(const TCHAR * filename);
  40.     void Unload(void);
  41.  
  42.     virtual bool FuncEnumCallBack(const char * funcname)
  43.     {
  44.         return true;
  45.     }
  46.  
  47.     virtual bool SectionEnumCallBack(IMAGE_SECTION_HEADER * pSection)
  48.     {
  49.         return true;
  50.     }
  51.  
  52.     int  EnumExported(void);
  53.     int  EnumSection(void);
  54.  
  55.     const char * GetSectionName(unsigned offset);
  56. };
  57.  
  58.