Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "scan.h"
  3.  
  4. #define SerializerFunc 0xA1B010
  5. #define WorkspaceVTable 0x1165EBC
  6. #define InstanceSetParent 0x5249C0
  7.  
  8. std::string RBXMX_FileName;
  9. std::ofstream RBXMX_Out;
  10.  
  11. struct instance_shared_ptr {
  12. void* instance;
  13. void* unk;
  14. };
  15.  
  16. //typedef int(__thiscall* _ffc)(void* instance, std::string childname, char recursive);
  17. typedef void (__cdecl* _serialize)(std::ostream&, std::vector<instance_shared_ptr>, ULONG);
  18. typedef char (__thiscall* _SetParentInstance)(void* self, int wot, int whatever);
  19. _SetParentInstance SetParentInstance;
  20. //_ffc findfirstchild;
  21. _serialize serialize;
  22. DWORD WorkspaceVT;
  23. DWORD Workspace;
  24. DWORD Terrain;
  25.  
  26. BOOL Dump_Instance_Vector(std::ostream& export_stream, std::vector<instance_shared_ptr>* instance_vector)
  27. {
  28. serialize(export_stream, *instance_vector, NULL);
  29. return TRUE;
  30. }
  31.  
  32. std::string* GetName(int Instance) {
  33. return (std::string*)(*(int*)(Instance + 0x28));
  34. }
  35.  
  36. int GetChildByName(int Instance, std::string Name) {
  37. // iterate over the children vector
  38. DWORD StartOfChildren = *(DWORD*)(Instance + 0x2C);
  39. DWORD EndOfChildren = *(DWORD*)(StartOfChildren + 4);
  40. for (int i = *(int*)StartOfChildren; i != EndOfChildren; i += 8)
  41. if (strcmp(GetName(*(int*)i)->c_str(), Name.c_str()) == 0)
  42. return *(int*)i;
  43. return 0;
  44. }
  45.  
  46. /*
  47. void RemoveTerrainFromWorkspace(int Workspace)
  48. {
  49. DWORD StartOfChildren = *(DWORD*)(Workspace + 0x2C);
  50. DWORD EndOfChildren = *(DWORD*)(StartOfChildren + 4);
  51. for (int i = *(int*)StartOfChildren; i != EndOfChildren; i += 8)
  52. if (strcmp(GetName(*(int*)i)->c_str(), "Terrain") == 0)
  53. *(int*)i = NULL;
  54. }
  55. */
  56.  
  57. int __stdcall MessageBoxHook(HWND WindowParent, LPCSTR Body, LPCSTR Caption, UINT Type)
  58. {
  59. MessageBoxW(WindowParent, L"The place has successfully been dumped! Roblox will now close.", L"Magus Night", MB_ICONINFORMATION);
  60. PostMessage(GetConsoleWindow(), WM_CLOSE, NULL, NULL);
  61. std::exit(NULL);
  62. return 0;
  63. }
  64.  
  65. // crash rate: ~40%
  66. // please excuse the terrible code (this was made in 5 minutes)
  67. VOID Init()
  68. {
  69. std::stringstream RBXMX_Log;
  70. DWORD OldPerm, OldPermMsg, Base;
  71.  
  72. // open console
  73. VirtualProtect(&FreeConsole, 1, PAGE_EXECUTE_READWRITE, &OldPerm);
  74. VirtualProtect(&MessageBoxA, 5, PAGE_EXECUTE_READWRITE, &OldPerm);
  75. *(BYTE*)(&FreeConsole) = 0xC3;
  76. AllocConsole();
  77. freopen("CONOUT$", "w", stdout);
  78. freopen("CONIN$", "r", stdin);
  79. SetConsoleTitleA("Magus Night v2.2 - by Louka @ V3rmillion");
  80.  
  81. // header/filestream stuff
  82. std::cout << "Magus Night v2.2 - by Louka @ V3rmillion\nIf the game crashes during the dumping process, just try again.\n\nPlease enter filename: ";
  83. getline(std::cin, RBXMX_FileName);
  84. RBXMX_Out = std::ofstream(RBXMX_FileName, std::ios_base::out|std::ios_base::binary);
  85. if (RBXMX_Out.fail())
  86. {
  87. std::cout << "\nSomething went wrong while opening the file. Close Roblox and try again.";
  88. return;
  89. }
  90.  
  91. // get functions from their offset
  92. std::cout << "[1/3] Getting funcs... ";
  93. Base = (DWORD)GetModuleHandleA("RobloxPlayerBeta.exe");
  94. serialize = (_serialize)(SerializerFunc - 0x400000 + Base);
  95. //SerializerJumpTo = (SerializerBckt - 0x400000 + Base);
  96. SetParentInstance = (_SetParentInstance)(InstanceSetParent - 0x400000 + Base);
  97. std::cout << "OK!\n[2/3] Obtaining workspace children vector... ";
  98.  
  99. // obtain the workspace service by scanning its vftable
  100. WorkspaceVT = (WorkspaceVTable - 0x400000 + Base);
  101. Workspace = Memory::Scan(PAGE_READWRITE, (char*)&WorkspaceVT, "xxxx");
  102. if (strcmp(GetName(Workspace)->c_str(), "Workspace"))
  103. {
  104. std::cout << "Wrong Workspace instance! Quit Roblox and try again.";
  105. return;
  106. }
  107.  
  108. // save the thing
  109. std::cout << "OK!\n[3/3] Dumping place to file... ";
  110. Terrain = GetChildByName(Workspace, "Terrain");
  111. //*(DWORD*)(Terrain + 0x22) = 0;
  112. //*(DWORD*)(Terrain + 0x34) = NULL;
  113. //RemoveTerrainFromWorkspace(Workspace);
  114. try
  115. {
  116. SetParentInstance((void*)Terrain, NULL, TRUE);
  117. Dump_Instance_Vector(RBXMX_Out, (std::vector<instance_shared_ptr>*)(Workspace + 0x2C));
  118. }
  119. catch (std::exception e)
  120. {
  121. std::cout << "An error occured while dumping: " << e.what() << "\n";
  122. return;
  123. }
  124. //Serialize_Instances(RBXMX_Out, *(std::vector<instance_shared_ptr>*)(Workspace + 0x2C), NULL);
  125. *(BYTE*)(&MessageBoxA) = 0xE9;
  126. *(DWORD*)((DWORD)&MessageBoxA + 1) = ((DWORD)&MessageBoxHook - (DWORD)&MessageBoxA) - 5;
  127. std::cout << "OK!\nDump successful!";
  128. RBXMX_Out.close();
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement