int Test(HWND hwnd, LPCTSTR str1, LPCTSTR str2, UINT nType);
   2: PROC* pfnNew = (PROC*)Test;
   3: PROC* ppfn = NULL;
   4:  
   5:  
int Test(HWND hwnd, LPCTSTR str1, LPCTSTR str2, UINT nType)
   7: {
, MB_OK);
);
return 0;
  11: }
  12:  
  13:  
int argc, _TCHAR* argv[])
  15: {
  16:  HMODULE hMd = GetModuleHandleA(NULL);
  18:  
if (!hMd)
  20:  {
return 0;
  22:  }
  23:  
  24:  PROC pfnOrig = GetProcAddress( 
),
  27:   );
  28:  
  29:  ULONG ulSize;
  30:  
  31:  PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)
  32:   ImageDirectoryEntryToData(
  33:   hMd,
TRUE,
  35:   IMAGE_DIRECTORY_ENTRY_IMPORT,
  36:   &ulSize
  37:   );
  38:  
if (pImportDesc == NULL)
  40:  {
return 0;
  42:  }
  43:  
for (; pImportDesc->Name; pImportDesc++)
  45:  {
  46:   PSTR  pszName = (PSTR) ((PBYTE)hMd + pImportDesc->Name);
) == 0)
  48:   {
break;
  50:   }
  51:  }
  52:  
if (pImportDesc->Name == NULL)
  54:  {
return 0;
  56:  }
  57:  
  58:  PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)
  59:   ((PBYTE)hMd + pImportDesc->FirstThunk); 
  60:  
for (; pThunk->u1.Function; pThunk++)
  62:  {
  63:   ppfn = (PROC*) &pThunk->u1.Function;
  64:   BOOL bFound = (*ppfn == pfnOrig);
  65:  
if (bFound)
  67:   {   
if (WriteProcessMemory(
  69:        GetCurrentProcess(),
  70:        ppfn,
  71:        &pfnNew,
sizeof(pfnNew),
  73:        NULL
  74:        ))
  75:    {
break;
  77:    }
else
  79:    {
  80:     DWORD dwoldProtect;
sizeof(pfnNew), PAGE_WRITECOPY, &dwoldProtect);
sizeof(pfnNew), NULL);
sizeof(pfnNew), dwoldProtect, &dwoldProtect);
  84:    }   
  85:   }
  86:  }
  87:  
, MB_OK);
  89:  
, MB_OK);
  91:  
  93:  
return 0; 
  95: }

相关文章:

  • 2021-12-26
  • 2021-12-26
  • 2021-09-29
  • 2021-12-26
  • 2021-07-06
  • 2022-02-05
  • 2022-12-23
猜你喜欢
  • 2021-12-26
  • 2021-12-26
  • 2022-02-21
  • 2021-09-12
  • 2021-06-17
  • 2021-08-02
相关资源
相似解决方案