DecodeStudios

Untitled

Aug 31st, 2019
1,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.42 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <stdio.h>
  3. #include <Psapi.h>
  4.  
  5. #include <cstring>
  6.  
  7. DWORD64   GObjObjects_offset = NULL;
  8. DWORD64   Names_offset = NULL;
  9. DWORD   Offset_Name = 0x18;
  10.  
  11. MODULEINFO GetModuleInfo(LPCTSTR lpModuleName)
  12. {
  13.     MODULEINFO miInfos = { NULL };
  14.  
  15.     HMODULE hmModule = GetModuleHandle(lpModuleName);
  16.  
  17.     if (hmModule)
  18.     {
  19.         GetModuleInformation(GetCurrentProcess(), hmModule, &miInfos, sizeof(MODULEINFO));
  20.     }
  21.  
  22.     return miInfos;
  23. }
  24.  
  25. template < class T > struct TArray
  26. {
  27.     T* Data;
  28.     DWORD   Num;
  29.     DWORD   Max;
  30. };
  31.  
  32. struct UObject
  33. {
  34.     UCHAR   Unknown[0x18];       // unknowed data
  35.     DWORD   NameIndex;                              // struct FName
  36. };
  37.  
  38. class FUObjectItem
  39. {
  40. public:
  41.     UObject* Object;
  42.     __int32 Flags;
  43.     __int32 ClusterIndex;
  44.     //__int32 SerialNumber;
  45.     char unknowndata_00[0x4]; //New
  46. };
  47.  
  48. class PreFUObjectItem
  49. {
  50. public:
  51.     FUObjectItem* Object_1;
  52.     FUObjectItem* Object_2;
  53. };
  54.  
  55. class TUObjectArray
  56. {
  57. public:
  58.     PreFUObjectItem* Objects;
  59.     char unknowndata_00[0x8]; //New
  60.     __int32 MaxElements;
  61.     __int32 NumElements;
  62. };
  63.  
  64. class FUObjectArray
  65. {
  66. public:
  67.     __int32 ObjFirstGCIndex; //0x0000
  68.     __int32 ObjLastNonGCIndex; //0x0004
  69.     __int32 MaxObjectsNotConsideredByGC; //0x0008
  70.     __int32 OpenForDisregardForGC; //0x000C
  71.  
  72.     TUObjectArray ObjObjects;
  73. };
  74.  
  75. struct FNameEntry
  76. {
  77.     int Index;
  78.     char pad_0x0004[0x4];
  79.     FNameEntry* HashNext;
  80.     char AnsiName[1024];
  81. };
  82.  
  83. class TNameEntryArray
  84. {
  85. private:
  86.     DWORD64* chunks;
  87.  
  88. public:
  89.     FNameEntry const* const& GetById(int Index) const
  90.     {
  91.         if (!chunks ||
  92.             !*(DWORD64*)chunks ||
  93.             !(DWORD64*)(*(DWORD64*)chunks) ||
  94.             !(DWORD64*)(*(DWORD64*)(chunks + 1)) ||
  95.             !(DWORD64*)(*(DWORD64*)(chunks + 2)) ||
  96.             !(DWORD64*)(*(DWORD64*)(chunks + 3))) return NULL;
  97.  
  98.         if (Index * 0x8 < 0x20000)
  99.             return *(FNameEntry * *)(*(DWORD64*)chunks + (Index * 0x8));
  100.         else if (Index * 0x8 >= 0x20000
  101.             && Index * 0x8 < (0x20000 * 2))
  102.             return *(FNameEntry * *)(*(DWORD64*)(chunks + 1) + (Index * 0x8 - 0x20000));
  103.         else if (Index * 0x8 >= (0x20000 * 2)
  104.             && Index * 0x8 < (0x20000 * 3))
  105.             return *(FNameEntry * *)(*(DWORD64*)(chunks + 2) + (Index * 0x8 - (0x20000 * 2)));
  106.         else if (Index * 0x8 >= (0x20000 * 3)
  107.             && Index * 0x8 < (0x20000 * 4))
  108.         {
  109.             if (!*(DWORD64*)(chunks + 3)
  110.                 || !*(DWORD64*)(*(DWORD64*)(chunks + 3) + (Index * 0x8 - (0x20000 * 3)))
  111.                 || !*(DWORD64 * *)(*(DWORD64*)(chunks + 3) + (Index * 0x8 - (0x20000 * 3))))
  112.                 return NULL;
  113.  
  114.             return *(FNameEntry * *)(*(DWORD64*)(chunks + 3) + (Index * 0x8 - (0x20000 * 3)));
  115.         }
  116.         else
  117.             return NULL;
  118.     }
  119.  
  120.     bool IsValidIndex(int index) const
  121.     {
  122.         return index >= 0 && index < (0x20000 * 4) && GetById(index) != nullptr;
  123.     }
  124. };
  125.  
  126. FUObjectArray* GObjObjects = NULL;
  127. TNameEntryArray* Names = NULL;
  128.  
  129. char* GetName(UObject* Object)
  130. {
  131.     DWORD NameIndex = *(PDWORD)((DWORD64)Object + Offset_Name);
  132.  
  133.     if (NameIndex < 0 || NameIndex >(0x20000 * 4))
  134.     {
  135.         static char ret[256];
  136.         sprintf_s(ret, "INVALID NAME INDEX : %i > %i", NameIndex, (0x20000 * 4));
  137.         printf("INVALID NAME INDEX : %i > %i", NameIndex, (0x20000 * 4));
  138.         return ret;
  139.     }
  140.     else
  141.     {
  142.         return (char*)Names->GetById(NameIndex)->AnsiName;
  143.     }
  144. }
  145.  
  146. void ObjectDump()
  147. {
  148.     FILE* Log = NULL;
  149.     fopen_s(&Log, "ObjectDump.txt", "w+");
  150.  
  151.     //for (DWORD64 i = 0x0; i < (GObjObjects->ObjObjects.NumElements - 2); i++)
  152.     for (DWORD64 i = 0x0; i < 700000; i++)
  153.     {
  154.         if (i <= 0xFFFF)
  155.         {
  156.             if (!GObjObjects->ObjObjects.Objects->Object_1[i].Object) { continue; }
  157.  
  158.             fprintf(Log, "UObject[%06i] %-50s 0x%llX\n", i, GetName(GObjObjects->ObjObjects.Objects->Object_1[i].Object), GObjObjects->ObjObjects.Objects->Object_1[i].Object);
  159.             printf("UObject[%06i] %-50s 0x%llX\n", i, GetName(GObjObjects->ObjObjects.Objects->Object_1[i].Object), GObjObjects->ObjObjects.Objects->Object_1[i].Object);
  160.         }
  161.         else if (i > 0xFFFF && i <= 0x1FFFE)
  162.         {
  163.             if (!GObjObjects->ObjObjects.Objects->Object_2[(i - 0xFFFF)].Object) { continue; }
  164.  
  165.             fprintf(Log, "UObject[%06i] %-50s 0x%llX\n", i, GetName(GObjObjects->ObjObjects.Objects->Object_2[(i - 0xFFFF)].Object), GObjObjects->ObjObjects.Objects->Object_2[(i - 0xFFFF)].Object);
  166.             printf("UObject[%06i] %-50s 0x%llX\n", i, GetName(GObjObjects->ObjObjects.Objects->Object_2[(i - 0xFFFF)].Object), GObjObjects->ObjObjects.Objects->Object_2[(i - 0xFFFF)].Object);
  167.         }
  168.         else
  169.         {
  170.             fclose(Log);
  171.             return;
  172.         }
  173.     }
  174.  
  175.     fclose(Log);
  176. }
  177.  
  178. void NameDump()
  179. {
  180.     FILE* Log = NULL;
  181.     fopen_s(&Log, "NameDump.txt", "w+");
  182.  
  183.     for (DWORD64 i = 0x0; i < (0x20000 * 4); i++)
  184.     {
  185.         if (!Names->GetById(i)) { continue; }
  186.  
  187.         fprintf(Log, "Name[%06i] %s\n", i, Names->GetById(i)->AnsiName);
  188.         printf("Name[%06i] %s\n", i, Names->GetById(i)->AnsiName);
  189.     }
  190.  
  191.     fclose(Log);
  192. }
  193.  
  194. void onAttach()
  195. {
  196.     AllocConsole();
  197.     FILE* ff;
  198.     freopen_s(&ff, "CONOUT$", "w", stdout);
  199.  
  200.     printf("Injected!\n");
  201.  
  202.     MODULEINFO miGame = GetModuleInfo(NULL);
  203.  
  204.     GObjObjects_offset = (DWORD64)((DWORD64)miGame.lpBaseOfDll + 0x32A4668);
  205.     Names_offset = ((DWORD64)miGame.lpBaseOfDll + 0x32A0368);
  206.  
  207.     GObjObjects = (FUObjectArray*)GObjObjects_offset;
  208.     Names = (TNameEntryArray*)Names_offset;
  209.  
  210.     NameDump();
  211.     ObjectDump();
  212. }
  213.  
  214. BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
  215. {
  216.     switch (dwReason)
  217.     {
  218.     case DLL_PROCESS_ATTACH:
  219.         DisableThreadLibraryCalls(hModule);
  220.         CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)onAttach, NULL, 0, NULL);
  221.         return true;
  222.         break;
  223.  
  224.     case DLL_PROCESS_DETACH:
  225.         return true;
  226.         break;
  227.     }
  228. }
Add Comment
Please, Sign In to add comment