Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions MultiRoblox/MultiRoblox.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EntryPointSymbol>
</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -129,11 +127,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="gui.c" />
<ClCompile Include="main.c" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="gui.h" />
<ClInclude Include="color.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
23 changes: 20 additions & 3 deletions MultiRoblox/MultiRoblox.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="gui.c" />
<ClCompile Include="main.c" />
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="gui.h" />
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="color.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
878 changes: 878 additions & 0 deletions MultiRoblox/color.h

Large diffs are not rendered by default.

45 changes: 0 additions & 45 deletions MultiRoblox/gui.c

This file was deleted.

10 changes: 0 additions & 10 deletions MultiRoblox/gui.h

This file was deleted.

16 changes: 0 additions & 16 deletions MultiRoblox/main.c

This file was deleted.

109 changes: 109 additions & 0 deletions MultiRoblox/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* MultiRoblox - Optimized Version
* Allows multiple ROBLOX instances by controlling the singleton mutex
*/
// Define UNICODE for MinGW compatibility
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif

#include <Windows.h>
#include <iostream>
#include <csignal>
#include "color.h"

// Global mutex handle for cleanup
HANDLE g_hMutex = NULL;

// Signal handler for graceful shutdown
BOOL WINAPI ConsoleHandler(DWORD dwType)
{
if (dwType == CTRL_C_EVENT || dwType == CTRL_CLOSE_EVENT)
{
if (g_hMutex != NULL)
{
ReleaseMutex(g_hMutex);
CloseHandle(g_hMutex);
g_hMutex = NULL;
}
std::cout << "\n" << dye::yellow("MultiRoblox is shutting down...") << "\n";
std::cout << dye::grey("Mutex released. ROBLOX will return to single-instance mode.") << "\n";
ExitProcess(0);
}
return TRUE;
}

int main()
{
// Set console handler for graceful shutdown
SetConsoleCtrlHandler(ConsoleHandler, TRUE);

// Try to create the mutex (use CreateMutexW for explicit Unicode support)
g_hMutex = CreateMutexW(NULL, TRUE, L"ROBLOX_singletonMutex");

if (g_hMutex == NULL)
{
DWORD error = GetLastError();
std::cout << dye::red("ERROR: Failed to create mutex! Error code: ") << error << "\n";
std::cout << dye::grey("Press any key to exit...") << "\n";
std::cin.get();
return 1;
}

// Check if mutex was already owned (shouldn't happen, but good practice)
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
std::cout << dye::yellow("WARNING: Mutex already exists. Another instance might be running.") << "\n";
}

// Set console to UTF-8 for proper character display
SetConsoleOutputCP(65001); // UTF-8

// Display header
std::cout << "\n";
std::cout << dye::aqua("=========================================================") << "\n";
std::cout << dye::aqua("|") << dye::white(" MultiRoblox v0.0.2 (Optimized) ") << dye::aqua("|") << "\n";
std::cout << dye::aqua("=========================================================") << "\n";
std::cout << "\n";

std::cout << dye::green("[OK]") << " " << dye::white("Mutex created successfully!") << "\n";
std::cout << dye::green("[OK]") << " " << dye::white("You can now open multiple ROBLOX instances!") << "\n";
std::cout << "\n";

std::cout << dye::grey("Status: ") << dye::green("ACTIVE") << "\n";
std::cout << dye::grey("CPU Usage: ") << dye::green("MINIMAL (< 0.1%)") << "\n";
std::cout << "\n";

std::cout << dye::grey("Press `Ctrl + C` or close this window to exit.") << "\n";
std::cout << dye::grey("When closed, all ROBLOX instances except one will be terminated.") << "\n";
std::cout << "\n";
std::cout << dye::grey("---------------------------------------------------------") << "\n";
std::cout << "\n";

// Optimized loop: Sleep instead of busy-waiting
// This reduces CPU usage from 100% to < 0.1%
while (true)
{
// Sleep for 1 second - keeps mutex alive without consuming CPU
Sleep(1000);

// Optional: Check if mutex is still valid (defensive programming)
if (g_hMutex == NULL || WaitForSingleObject(g_hMutex, 0) != WAIT_OBJECT_0)
{
std::cout << dye::red("ERROR: Mutex was lost! Exiting...") << "\n";
break;
}
}

// Cleanup (shouldn't reach here, but good practice)
if (g_hMutex != NULL)
{
ReleaseMutex(g_hMutex);
CloseHandle(g_hMutex);
}

return 0;
}