Cromon

CBaseRelocation.cpp

Oct 19th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1.     void CBaseRelocation::bindToModule(LPVOID dllBase, CMemory& memory, DWORD dwOriginalBase) {
  2.         DWORD baseAddress = mReloc.VirtualAddress + (DWORD)dllBase;
  3.         for(auto entry : mRelocations) {
  4.             WORD relocationType = (entry & 0xF000) >> 12;
  5.             if(relocationType == IMAGE_REL_BASED_ABSOLUTE)
  6.                 continue;
  7.  
  8.             if(relocationType == IMAGE_REL_BASED_HIGHLOW) {
  9.                 DWORD offset = baseAddress + (entry & 0xFFF);
  10.                 DWORD dwOldAddress = 0;
  11.                 memory.read(offset, dwOldAddress);
  12.                 dwOldAddress -= dwOriginalBase;
  13.                 dwOldAddress += (DWORD)dllBase;
  14.                 memory.write(offset, dwOldAddress);
  15.             }
  16.         }
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment