memscan.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef _INCLUDE_MEMSCAN_UTIL_H_
  2. #define _INCLUDE_MEMSCAN_UTIL_H_
  3. #include <stdio.h>
  4. #include <cstdint>
  5. #if _WINDOWS
  6. #define WIN32_LEAN_AND_MEAN
  7. #include <windows.h>
  8. #elif _LINUX
  9. #include "mmsplugin.h"
  10. #include <fcntl.h>
  11. #include <gelf.h>
  12. #endif
  13. class ILibInfo {
  14. public:
  15. virtual ~ILibInfo() {};
  16. virtual bool LocatePattern(const char* bytes, size_t length, void** result) = 0;
  17. virtual bool LocateSymbol(const char* name, void** result) = 0;
  18. protected:
  19. bool m_bValid;
  20. };
  21. #if _WINDOWS
  22. class CWinLibInfo : public ILibInfo {
  23. public:
  24. CWinLibInfo(void* pInBase);
  25. virtual bool LocatePattern(const char* bytes, size_t length, void** result);
  26. virtual bool LocateSymbol(const char* name, void** result);
  27. private:
  28. uintptr_t m_StartRange, m_EndRange;
  29. };
  30. #elif _LINUX
  31. class CLinuxLibInfo : public ILibInfo {
  32. public:
  33. CLinuxLibInfo(void* pInBase);
  34. ~CLinuxLibInfo();
  35. virtual bool LocatePattern(const char* bytes, size_t length, void** result);
  36. virtual bool LocateSymbol(const char* name, void** result);
  37. private:
  38. int m_fd;
  39. Elf *m_Elf;
  40. Dl_info m_info;
  41. };
  42. #endif
  43. #endif