Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
DvvCz committed Sep 5, 2023
1 parent d90204a commit 227d916
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[*.yml]
indent_style = space
indent_size = 2
20 changes: 20 additions & 0 deletions .github/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: check

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check
run: cargo check --verbose
28 changes: 28 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

permissions:
contents: write

on:
push:
tags:
- v[0-9]+.*

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}

upload-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: multiblox
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 0.1.0

Initial version.

Creates a mutex with CreateMutexA with name `ROBLOX_singletonMutex`, stays in system tray.

Windows only.
42 changes: 42 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "multiblox"
version = "0.1.0"
edition = "2021"

[profile.release]
panic = "abort"
strip = true
opt-level = "z"
lto = true
codegen-units = 1

[dependencies]
trayicon = "0.1.3"
winapi = { version = "0.3.9", features = ["winuser"] }
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Multiblox

Simple program to allow running multiple Roblox client instances at once.

## Downloading

Download a build from the [Releases](https://github.com/DvvCz/Multiblox/releases/latest)

## Usage

Open Multiblox **before** opening Roblox, and it should move to your system tray / "hidden icons".

You should be able to open multiple clients while it is there.

## ⚠️ Note

This is not associated with the Roblox corporation in any way.

I doubt you would get banned for using this, but keep in mind there could always be a chance.
Binary file added assets/icon.ico
Binary file not shown.
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hard_tabs = true
52 changes: 52 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
mod singleton;

#[derive(PartialEq, Clone)]
enum Events {
Close,
}

fn main() {
// If you're overwhelmed by the amount of code here, don't worry
// This single variable declaration is all that matters with regards to patching Roblox.
// The rest of it just makes this use a system tray icon.
let singleton = singleton::Singleton::new().expect("Failed to acquire mutex");

let (stop_send, stop_recv) = std::sync::mpsc::channel::<bool>();
let (event_send, event_recv) = std::sync::mpsc::channel::<Events>();

let icon = trayicon::TrayIconBuilder::new()
.sender(event_send)
.icon_from_buffer(include_bytes!("../assets/icon.ico"))
.tooltip("Multiblox")
.menu(trayicon::MenuBuilder::new().item("Close", Events::Close))
.build()
.expect("Failed to create trayicon");

let join = std::thread::spawn(move || {
event_recv.iter().next();
let _ = stop_send.send(true); // Couldn't have hung up
});

loop {
use winapi::um::winuser;

let _ = icon;
let _ = singleton;

if let Ok(true) = stop_recv.try_recv() {
let _ = join.join(); // Can't possibly panic
break;
}

let mut msg = core::mem::MaybeUninit::uninit();
let bret = unsafe { winuser::GetMessageA(msg.as_mut_ptr(), 0 as _, 0, 0) };
if bret > 0 {
unsafe {
winuser::TranslateMessage(msg.as_ptr());
winuser::DispatchMessageA(msg.as_ptr());
}
} else {
break;
}
}
}
41 changes: 41 additions & 0 deletions src/singleton.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extern "system" {
fn CreateMutexA(
opts: *const core::ffi::c_void,
takeover: u32,
name: *const i8,
) -> *const core::ffi::c_void;
fn ReleaseMutex(m: *const core::ffi::c_void);
fn CloseHandle(m: *const core::ffi::c_void);
}

pub struct Singleton {
mutex: *const core::ffi::c_void,
}

impl Singleton {
#[inline]
pub fn new() -> core::option::Option<Self> {
let mutex = unsafe {
CreateMutexA(
core::ptr::null(),
1,
"ROBLOX_singletonMutex\0".as_ptr() as _,
)
};
if mutex.is_null() {
None
} else {
Some(Self { mutex })
}
}
}

impl Drop for Singleton {
#[inline]
fn drop(&mut self) {
unsafe {
ReleaseMutex(self.mutex);
CloseHandle(self.mutex);
}
}
}

0 comments on commit 227d916

Please sign in to comment.