Skip to content

Commit

Permalink
Added usage
Browse files Browse the repository at this point in the history
  • Loading branch information
HerXayah committed Jul 8, 2023
1 parent 6d3c73a commit d5b9b48
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 30 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Discord-Fixer
Disabled the Global Hotkey Process to save Deltas (get you nyoooooming)

## Usage

1. Download the latest release from [here](
2. Open the .exe
3. Proft

If you are a developer or interested, pass -debug as an argument to the exe to see the debug console.

## Todo?

- [ ] Autolaunch on Discord startup
- [X] Make it work on Canary and PTB
- [ ] create Debug mode

## Credits

- [Amit](https://twitter.com/amitxv) * for the scientific analysis of the problem and the idea
- [Aetopia](https://github.com/Aetopia) *thnx for fixing my shizz and rewriting it better <3
- [Me(Sarah)](https://github.com/PrincessAkira) * fixing code from aetopia and making it work :3
92 changes: 62 additions & 30 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,92 @@
#include <tlhelp32.h>
#include <wtsapi32.h>
#include <winternl.h>
#include <stdio.h>

#define printf __builtin_printf

#define NtQueryInformationThread ((NTSTATUS (NTAPI*)(HANDLE, THREADINFOCLASS, PVOID, ULONG, PULONG))GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "NtQueryInformationThread"))

INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nShowCmd)
{
HANDLE hThreadSnapshot,
hModuleSnapshot,
hThread,
hProcess = 0;
BOOL debugMode = wcsstr(GetCommandLineW(), L"-debug") != NULL;

if(debugMode) {
AllocConsole();
AttachConsole(GetCurrentProcessId());
freopen("CON", "w", stdout);
freopen ("CON", "r", stdin);
}

HANDLE hThreadSnapshot, hModuleSnapshot, hThread, hProcess = 0;
THREADENTRY32 te = {.dwSize = sizeof(THREADENTRY32)};
MODULEENTRY32W me = {.dwSize = sizeof(MODULEENTRY32W)};
PWTS_PROCESS_INFOW pProcessInfo = 0;
DWORD dwCount = 0;
DWORD64 dw64StartAddress = 0;

// Array of the executables names
LPCWSTR exes[] = { L"discord.exe", L"discordcanary.exe", L"discordptb.exe" };
int exesCount = sizeof(exes) / sizeof(LPCWSTR);

if (!WTSEnumerateProcessesW(WTS_CURRENT_SERVER, 0, 1, &pProcessInfo, &dwCount))
return 1;

for (DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++)
{
if (wcscmp(L"discord.exe", _wcslwr(pProcessInfo[dwIndex].pProcessName)) != 0)
continue;
printf("Process Name: %ls | Process ID: %ld\n", pProcessInfo[dwIndex].pProcessName, pProcessInfo[dwIndex].ProcessId);
if (Thread32First((hThreadSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0)), &te))
for(int i = 0; i < exesCount; i++)
{
OpenThread(THREAD_ALL_ACCESS, FALSE, te.th32ThreadID);
do
if (wcscmp(exes[i], _wcslwr(pProcessInfo[dwIndex].pProcessName)) != 0)
continue;
if(debugMode) {
printf("Process Name: %ls | Process ID: %ld\n", pProcessInfo[dwIndex].pProcessName, pProcessInfo[dwIndex].ProcessId);
}
if (Thread32First((hThreadSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0)), &te))
{
if (te.th32OwnerProcessID != pProcessInfo[dwIndex].ProcessId)
continue;
hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, te.th32ThreadID);
NtQueryInformationThread(hThread, ThreadQuerySetWin32StartAddress, &dw64StartAddress, sizeof(DWORD64), NULL);
if (Module32FirstW((hModuleSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE32 | TH32CS_SNAPMODULE, pProcessInfo[dwIndex].ProcessId)), &me))
OpenThread(THREAD_ALL_ACCESS, FALSE, te.th32ThreadID);
do
{
do
if (te.th32OwnerProcessID != pProcessInfo[dwIndex].ProcessId)
continue;
hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, te.th32ThreadID);
NtQueryInformationThread(hThread, ThreadQuerySetWin32StartAddress, &dw64StartAddress, sizeof(DWORD64), NULL);
if (Module32FirstW((hModuleSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE32 | TH32CS_SNAPMODULE, pProcessInfo[dwIndex].ProcessId)), &me))
{
if (dw64StartAddress >= (DWORD64)me.modBaseAddr &&
dw64StartAddress <= ((DWORD64)me.modBaseAddr + me.modBaseSize))
do
{
printf("Thread ID: %ld | Module: %ls | Module Match: %ls\n", te.th32ThreadID, me.szModule, !wcscmp(me.szModule, L"discord_utils.node") ? L"True" : L"False");
if (!wcscmp(me.szModule, L"discord_utils.node"))
SuspendThread(hThread);
break;
}
} while (Module32NextW(hModuleSnapshot, &me));
}
CloseHandle(hModuleSnapshot);
CloseHandle(hThread);
} while (Thread32Next(hThreadSnapshot, &te));
if (dw64StartAddress >= (DWORD64)me.modBaseAddr &&
dw64StartAddress <= ((DWORD64)me.modBaseAddr + me.modBaseSize))
{
if(debugMode) {
printf("Thread ID: %ld | Module: %ls | Module Match: %ls\n", te.th32ThreadID, me.szModule, !wcscmp(me.szModule, L"discord_utils.node") ? L"True" : L"False");
}
if (!wcscmp(me.szModule, L"discord_utils.node"))
SuspendThread(hThread);
break;
}
} while (Module32NextW(hModuleSnapshot, &me));
}
CloseHandle(hModuleSnapshot);
CloseHandle(hThread);
} while (Thread32Next(hThreadSnapshot, &te));
}
if(debugMode) {
printf("Done!\n");
}
CloseHandle(hThreadSnapshot);
}
printf("Done!\n");
CloseHandle(hThreadSnapshot);
CloseHandle(hProcess);
}
if(debugMode) {
AllocConsole();
AttachConsole(GetCurrentProcessId());
freopen("CON", "w", stdout);
freopen ("CON", "r", stdin);
}
if(debugMode) {
printf("Press any key to close the console...");
getchar();
}

return 0;
}

0 comments on commit d5b9b48

Please sign in to comment.