//--------------------------------------------------------------- // cMemory Static Link Library // Copyright (c) 2007 - Wiccaan (wiccaan@comcast.net) //--------------------------------------------------------------- // This file is part of the cMemory Static Link Library. //--------------------------------------------------------------- // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // publiced by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILIY or FITNESS FOR A PARTICULAR PRUPOSE. See the // GNU General Public License for more details. //--------------------------------------------------------------- // // File: cMemory.h // Date: Nov. 26, 2007 // //--------------------------------------------------------------- namespace ProcessAccess { class cProcess { public: ///////////////////////////////////////////////////////////////////////////////// // Process Information Functions ///////////////////////////////////////////////////////////////////////////////// static DWORD ProcIdByProcName (TCHAR* tszProcName); static DWORD ProcIdByWinTitle (TCHAR* tszWinTitle); static HANDLE ProcHandleByProcName (TCHAR* tszProcName); static BOOL ProcNameFromWinTitle (TCHAR* tszWinTitle, TCHAR* tszNameStorage); static BOOL ProcNameFromProcId (DWORD dwProcId, TCHAR* tszNameStorage); ///////////////////////////////////////////////////////////////////////////////// // Process Module Information Functions ///////////////////////////////////////////////////////////////////////////////// static BYTE* ModBaseFromProcName (TCHAR* tszProcName, TCHAR* tszModName); static DWORD ModSizeFromProcName (TCHAR* tszProcName, TCHAR* tszModName); }; } namespace MemoryAccess { class cMemory { public: ///////////////////////////////////////////////////////////////////////////////// // Write Memory Functions ///////////////////////////////////////////////////////////////////////////////// static HRESULT WriteMemory (DWORD dwProcId, BYTE* pAddress, LPVOID lpBuffer, DWORD dwSizeToWrite); static HRESULT WriteNops (DWORD dwProcId, BYTE* pAddress, int iNopsToWrite); ///////////////////////////////////////////////////////////////////////////////// // Read Memory Functions ///////////////////////////////////////////////////////////////////////////////// static HRESULT ReadMemory (DWORD dwProcId, BYTE* pAddress, LPVOID lpStorage, DWORD dwSizeToRead); static HRESULT ReadPointer (DWORD dwProcId, BYTE* pBaseAddr, DWORD iPtrOffset, DWORD* pStorage); ///////////////////////////////////////////////////////////////////////////////// // Code Cave Functions ///////////////////////////////////////////////////////////////////////////////// static DWORD MakeCave (DWORD dwProcId, LPVOID lpCaveBytes, DWORD dwCaveSize); static HRESULT DeleteCave (DWORD dwProcId, BYTE* pCaveAddr, DWORD dwCaveSize); static DWORD MakeJump (DWORD dwProcId, BYTE* pOrigAddr, int iNopsNeeded, LPVOID lpCaveBytes, DWORD dwCaveSize); }; } namespace SignatureScan { class cSigScan { public: ///////////////////////////////////////////////////////////////////////////////// // Signature Scanning Functions ///////////////////////////////////////////////////////////////////////////////// static DWORD FindPattern (DWORD dwProcId, BYTE* bBaseAddr, DWORD dwModuleSize, BYTE* bPattern, int iPatternSize, int iOffset); static DWORD FindPatternMasked (DWORD dwProcId, BYTE* bBaseAddr, DWORD dwModuleSize, BYTE* bPattern, int iPatternSize, int iOffset, TCHAR* tszMask); private: static BOOL MaskCheck (const BYTE* pData, const BYTE* bMask, const TCHAR* tszMask); }; }