Advertisement
Imperious123

dfsd

Jun 24th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. bool CompareData(const char* Data, const char* Pattern, const char* Mask) {
  2. while (*Mask) {
  3. if (*Mask != '?') {
  4. if (*Data != *Pattern) {
  5. return false;
  6. };
  7. };
  8. ++Mask;
  9. ++Data;
  10. ++Pattern;
  11. };
  12. return true;
  13. };
  14.  
  15. struct AOBType {
  16.  
  17. string name;
  18.  
  19. const char* first;
  20.  
  21. const char* second;
  22.  
  23. };
  24.  
  25.  
  26.  
  27. /*
  28.  
  29. AOB Scanning
  30.  
  31. */
  32.  
  33. namespace AOB {
  34.  
  35. bool Check(const BYTE* pd, const BYTE* aob, const char* mask)
  36. {
  37. for (; *mask; ++mask, ++pd, ++aob)
  38. if (*mask != '?' && *pd != *aob)
  39. return false;
  40. return (*mask) == NULL;
  41. }
  42.  
  43.  
  44.  
  45. DWORD FindPattern(const char* aob, const char* mask)
  46. {
  47. for (DWORD ind = (DWORD)GetModuleHandle(0); ind <= 0xFFFFFFF; ++ind) {
  48. if (Check((BYTE*)ind, (BYTE*)aob, mask))
  49. return ind;
  50. }
  51. return 0x00000000;
  52. }
  53. }
  54.  
  55.  
  56. namespace Memory {
  57.  
  58. void write(void* address, void* instructions, size_t size) {
  59. DWORD tbuf;
  60. VirtualProtect(address, 1, PAGE_EXECUTE_READWRITE, &tbuf);
  61. memcpy(address, instructions, size);
  62. VirtualProtect(address, 1, tbuf, &tbuf);
  63. }
  64.  
  65. bool compare(BYTE* address, BYTE* pattern, BYTE* mask) {
  66. for (; *mask; address++, pattern++, mask++) {
  67. if (*mask == 'x' && *address != *pattern) {
  68. return false;
  69. }
  70. }
  71. return true;
  72. }
  73.  
  74. DWORD scan(BYTE* aob, BYTE* mask, BYTE prot = (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)) {
  75. MEMORY_BASIC_INFORMATION mbi;
  76. DWORD j = (DWORD)GetModuleHandle(NULL);
  77. while (j < 0x7FFFFFFF && VirtualQuery((void*)j, &mbi, sizeof(mbi))) {
  78. if (!(mbi.Protect & PAGE_GUARD) && (mbi.State & MEM_COMMIT) && (mbi.Protect & prot)) {
  79. for (DWORD k = (DWORD)mbi.BaseAddress; k < ((DWORD)mbi.BaseAddress + mbi.RegionSize); ++k) {
  80. if (compare((BYTE*)k, (BYTE*)aob, (BYTE*)mask)) {
  81. return k;
  82. }
  83. }
  84. }
  85. j += mbi.RegionSize;
  86. }
  87. return 0;
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement