home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / pehack.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  1.7 KB  |  44 lines

  1. #pragma 
  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   : pehack.h                                                             //
  12. //  Description: API hooking through import/export table                             //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KPEFile
  17. {
  18.     PIMAGE_DOS_HEADER pDOSHeader;
  19.     PIMAGE_NT_HEADERS pNTHeader;
  20.  
  21. public:
  22.     const char        * pModule;
  23.  
  24.     const char * RVA2Ptr(unsigned rva)
  25.     {
  26.         if ( (pModule!=NULL) && rva )
  27.             return pModule + rva;
  28.         else
  29.             return NULL;
  30.     }
  31.  
  32.     KPEFile(HMODULE hModule);
  33.     const void * GetDirectory(int id);
  34.     PIMAGE_IMPORT_DESCRIPTOR GetImportDescriptor(LPCSTR pDllName);
  35.     const unsigned * GetFunctionPtr(PIMAGE_IMPORT_DESCRIPTOR 
  36.         pImport, LPCSTR pProcName);
  37.     
  38.     FARPROC SetImportAddress(LPCSTR pDllName, LPCSTR pProcName, 
  39.         FARPROC pNewProc);
  40.  
  41.     FARPROC SetExportAddress(LPCSTR pProcName, FARPROC pNewProc);
  42. };
  43.  
  44.