Forráskód Böngészése

Remove custom memory scanning implementation

No point in keeping the custom sigscanning setup since we're all-in
on SourceMod now.
nosoop 1 éve
szülő
commit
2b0db1a9dd
4 módosított fájl, 0 hozzáadás és 165 törlés
  1. 0 1
      AMBuilder
  2. 0 109
      memscan.cpp
  3. 0 53
      memscan.h
  4. 0 2
      mmsplugin.cpp

+ 0 - 1
AMBuilder

@@ -5,7 +5,6 @@ proj_name = 'tf2dynschema'
 
 proj_srcs = [
   'mmsplugin.cpp',
-  'memscan.cpp',
   'smsdk_config.cpp',
 ]
 

+ 0 - 109
memscan.cpp

@@ -1,109 +0,0 @@
-#include "memscan.h"
-
-uintptr_t FindPattern(uintptr_t start, uintptr_t end, const char* pattern, size_t length) {
-	uintptr_t ptr = start;
-	while (ptr < end - length) {
-		bool f = true;
-		const char* cur = reinterpret_cast<char*>(ptr);
-		for (register size_t i = 0; i < length; i++) {
-			if (pattern[i] != '\x2A' && pattern[i] != cur[i]) {
-				f = false;
-				break;
-			}
-		}
-		if (f) {
-			return ptr;
-		}
-		ptr++;
-	}
-	return 0;
-}
-
-#if _WINDOWS
-CWinLibInfo::CWinLibInfo(void* pInBase) {
-	MEMORY_BASIC_INFORMATION info;
-	if (!VirtualQuery(pInBase, &info, sizeof(MEMORY_BASIC_INFORMATION))) {
-		this->m_bValid = false;
-		return;
-	}
-	uintptr_t base = reinterpret_cast<uintptr_t>(info.AllocationBase);
-	IMAGE_DOS_HEADER *dos = reinterpret_cast<IMAGE_DOS_HEADER *>(base);
-	IMAGE_NT_HEADERS *pe = reinterpret_cast<IMAGE_NT_HEADERS *>(base + dos->e_lfanew);
-	IMAGE_OPTIONAL_HEADER *opt = &pe->OptionalHeader;
-	size_t size = opt->SizeOfImage;
-	
-	this->m_StartRange = reinterpret_cast<uintptr_t>(info.AllocationBase);
-	this->m_EndRange = this->m_StartRange + size;
-	this->m_bValid = true;
-}
-
-bool CWinLibInfo::LocateSymbol(const char* name, void** result) {
-	return false;
-}
-
-bool CWinLibInfo::LocatePattern(const char* bytes, size_t length, void** result) {
-	if (!this->m_bValid) {
-		return false;
-	}
-	
-	uintptr_t pResult = FindPattern(this->m_StartRange, this->m_EndRange, bytes, length);
-	if (pResult) {
-		*result = reinterpret_cast<void*>(pResult);
-		return true;
-	}
-	return false;
-}
-#elif _LINUX
-CLinuxLibInfo::CLinuxLibInfo(void* pInBase) {
-	if (!dladdr(pInBase, &this->m_info)) {
-		this->m_bValid = false;
-		return;
-	}
-	
-	elf_version(EV_CURRENT);
-	
-	this->m_fd = open(m_info.dli_fname, O_RDONLY);
-	this->m_Elf = elf_begin(this->m_fd, ELF_C_READ, NULL);
-	this->m_bValid = true;
-}
-
-bool CLinuxLibInfo::LocatePattern(const char* bytes, size_t length, void** result) {
-	return false;
-}
-
-bool CLinuxLibInfo::LocateSymbol(const char* name, void** result) {
-	if (!this->m_bValid) {
-		return false;
-	}
-	
-	Elf_Scn *scn = NULL;
-	GElf_Shdr shdr;
-	while ((scn = elf_nextscn(this->m_Elf, scn)) != NULL) {
-		gelf_getshdr(scn, &shdr);
-		if (shdr.sh_type == SHT_SYMTAB) {
-			break;
-		}
-	}
-
-	Elf_Data *data = elf_getdata(scn, NULL);
-	size_t count = shdr.sh_size / shdr.sh_entsize;
-
-	// iterate symbols
-	for (size_t i = 0; i < count; ++i) {
-		GElf_Sym sym;
-		gelf_getsym(data, i, &sym);
-		
-		const char *symname = elf_strptr(this->m_Elf, shdr.sh_link, sym.st_name);
-		if (symname && !strcmp(symname, name)) {
-			*result = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(m_info.dli_fbase) + sym.st_value);
-			return true;
-		}
-	}
-	return false;
-}
-
-CLinuxLibInfo::~CLinuxLibInfo() {
-	elf_end(this->m_Elf);
-	close(this->m_fd);
-}
-#endif

+ 0 - 53
memscan.h

@@ -1,53 +0,0 @@
-#ifndef _INCLUDE_MEMSCAN_UTIL_H_
-#define _INCLUDE_MEMSCAN_UTIL_H_
-
-#include <stdio.h>
-#include <cstdint>
-
-#if _WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#elif _LINUX
-#include "mmsplugin.h"
-#include <fcntl.h>
-#include <gelf.h>
-#endif
-
-class ILibInfo {
-public:
-	virtual ~ILibInfo() {};
-	virtual bool LocatePattern(const char* bytes, size_t length, void** result) = 0;
-	virtual bool LocateSymbol(const char* name, void** result) = 0;
-	
-protected:
-	bool m_bValid;
-};
-
-#if _WINDOWS
-class CWinLibInfo : public ILibInfo {
-public:
-	CWinLibInfo(void* pInBase);
-	
-	virtual bool LocatePattern(const char* bytes, size_t length, void** result);
-	virtual bool LocateSymbol(const char* name, void** result);
-	
-private:
-	uintptr_t m_StartRange, m_EndRange;
-};
-#elif _LINUX
-class CLinuxLibInfo : public ILibInfo {
-public:
-	CLinuxLibInfo(void* pInBase);
-	~CLinuxLibInfo();
-	
-	virtual bool LocatePattern(const char* bytes, size_t length, void** result);
-	virtual bool LocateSymbol(const char* name, void** result);
-	
-private:
-	int m_fd;
-	Elf *m_Elf;
-	Dl_info m_info;
-};
-#endif
-
-#endif

+ 0 - 2
mmsplugin.cpp

@@ -14,8 +14,6 @@
 #include <KeyValues.h>
 #include <filesystem.h>
 
-#include "memscan.h"
-
 #include <map>
 
 void BindToSourceMod();