home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / Chapt_04 / Pogy / Post.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  2.9 KB  |  96 lines

  1. //-----------------------------------------------------------------------------------//
  2. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  3. //                             ISBN  0-13-086985-6                                   //
  4. //                                                                                   //
  5. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  6. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  7. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  8. //                                                                                   //
  9. //  FileName   : post.cpp                                                             //
  10. //  Description: Send information to spying DLL                                      //
  11. //  Version    : 1.00.000, May 31, 2000                                              //
  12. //-----------------------------------------------------------------------------------//
  13.  
  14. #define NOCRYPT
  15.  
  16. #include <windows.h>
  17. #include <assert.h>
  18.  
  19. #include "..\Diver\Diver.h"
  20.  
  21. #define nCopy(dest, src) { dest[sizeof(dest)-1] = 0; strncpy(dest, src, sizeof(dest)-1); }
  22.  
  23.  
  24. int KPost::LoadModule(const char *caller, const char *callee,
  25.                       const char *intrfc, unsigned vtable, unsigned queryinterface,
  26.                       int methodno, GUID & iid)
  27. {
  28.     KLoadModule    lm;
  29.     memset(&lm, 0, sizeof(KLoadModule));
  30.  
  31.     nCopy(lm.m_caller, caller);
  32.     nCopy(lm.m_callee, callee);
  33.     nCopy(lm.m_intrfc, intrfc);
  34.  
  35.     lm.vtable          = vtable;
  36.     lm.queryinterface = queryinterface;
  37.     lm.methodno       = methodno;
  38.     lm.iid            = iid;
  39.  
  40.     COPYDATASTRUCT cds;
  41.  
  42.     cds.dwData     = C_LOADMODULE;
  43.     cds.cbData     = sizeof(KLoadModule);
  44.     cds.lpData     = & lm;
  45.  
  46.     seq = 0;
  47.     return SendMessage(hReceiver, WM_COPYDATA, (WPARAM) hSender, (LPARAM) & cds);
  48. }
  49.  
  50.  
  51. int KPost::AddFunc(const char *name, unsigned cls, int parano, const char * paratype, int kind, const void * pOldAddr)
  52. {
  53.     KAddFunc       af;
  54.     COPYDATASTRUCT cds;
  55.  
  56.     memset(&af, 0, sizeof(af));
  57.  
  58.     af.m_ord        = seq ++;
  59.     af.m_cls        = cls;
  60.     af.m_parano     = parano;
  61.     af.m_kind       = kind;
  62.     af.m_oldaddress = pOldAddr;
  63.  
  64.     if ( strlen(paratype) < sizeof(af.m_paratype) )
  65.         strcpy(af.m_paratype, paratype);
  66.     else
  67.         assert(false);
  68.  
  69. //  assert(parano <= MAXPARANO);
  70.  
  71.     nCopy(af.m_name, name);
  72.  
  73.     cds.dwData   = C_ADDFUNC;
  74.     cds.cbData   = sizeof(KAddFunc);
  75.     cds.lpData   = & af;
  76.  
  77.     return SendMessage(hReceiver, WM_COPYDATA, (WPARAM) hSender, (LPARAM) & cds);
  78. }
  79.  
  80.  
  81. int KPost::Intercept(BOOL logcall, BOOL dispcall)
  82. {
  83.     COPYDATASTRUCT cds;
  84.     KOptions       opt;
  85.  
  86.     opt.bLogCall  = logcall;
  87.     opt.bDispCall = dispcall;
  88.  
  89.     cds.dwData    = C_INTERCEPT;
  90.     cds.cbData    = sizeof(opt);
  91.     cds.lpData    = & opt;
  92.  
  93.     return SendMessage(hReceiver, WM_COPYDATA, (WPARAM) hSender, (LPARAM) & cds);
  94. }
  95.  
  96.