Restrict content of GrooveMaster
This commit is contained in:
parent
07f2c9d020
commit
3565da0040
@ -348,7 +348,10 @@ BOOL WINAPI FakeReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRe
|
||||
}
|
||||
|
||||
BOOL WINAPI FakeCloseHandle(HANDLE hObject) {
|
||||
RemoveDataForHandle(hObject);
|
||||
if ((DWORD_PTR)hObject & MICE_HANDLE_MASK) {
|
||||
RemoveDataForHandle(hObject);
|
||||
return TRUE;
|
||||
}
|
||||
return TrueCloseHandle(hObject);
|
||||
}
|
||||
|
||||
@ -417,6 +420,14 @@ DWORD WINAPI FakeGetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) {
|
||||
return length;
|
||||
}
|
||||
|
||||
DWORD WINAPI FakeGetFileType(HANDLE hFile) {
|
||||
if ((DWORD_PTR)hFile & MICE_HANDLE_MASK) {
|
||||
// TODO: This is a lie
|
||||
return FILE_TYPE_CHAR;
|
||||
}
|
||||
return TrueGetFileType(hFile);
|
||||
}
|
||||
|
||||
void hook_io() {
|
||||
hook("Kernel32.dll", "DeviceIoControl", FakeDeviceIoControl, (void**)&TrueDeviceIoControl);
|
||||
|
||||
@ -429,6 +440,7 @@ void hook_io() {
|
||||
hook("Kernel32.dll", "WriteFile", FakeWriteFile, (void**)&TrueWriteFile);
|
||||
hook("Kernel32.dll", "ReadFile", FakeReadFile, (void**)&TrueReadFile);
|
||||
hook("Kernel32.dll", "GetFileSizeEx", FakeGetFileSizeEx, (void**)&TrueGetFileSizeEx);
|
||||
hook("Kernel32.dll", "GetFileType", FakeGetFileType, (void**)&TrueGetFileType);
|
||||
|
||||
// PathIsDirectory, PathFileExists, etc just call GetFileAttributes under the hood
|
||||
hook("Kernel32.dll", "DeleteFileA", FakeDeleteFileA, (void**)&TrueDeleteFileA);
|
||||
|
@ -46,6 +46,7 @@ BOOL(WINAPI* TrueWriteFile)
|
||||
_MICE_FILES BOOL(WINAPI* TrueReadFile)(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
|
||||
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
|
||||
_MICE_FILES BOOL(WINAPI* TrueGetFileSizeEx)(HANDLE hFile, PLARGE_INTEGER lpFileSize);
|
||||
_MICE_FILES DWORD(WINAPI* TrueGetFileType)(HANDLE hFile);
|
||||
_MICE_FILES BOOL(WINAPI* TrueCloseHandle)(HANDLE hObject);
|
||||
_MICE_FILES BOOL(WINAPI* TrueDeleteFileA)(LPCSTR lpFileName);
|
||||
_MICE_FILES BOOL(WINAPI* TrueDeleteFileW)(LPCWSTR lpFileName);
|
||||
|
@ -108,6 +108,57 @@ void hook_system() {
|
||||
const char* SystemVersion = "00691001\r\n";
|
||||
const char* UpdateVersion = "0000\r\n";
|
||||
|
||||
HANDLE hGM = CreateFileA("GrooveMaster.ini", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
BOOL bGmIs1P = FALSE;
|
||||
if (hGM != INVALID_HANDLE_VALUE) {
|
||||
CHAR line[256];
|
||||
DWORD_PTR lidx = 0;
|
||||
DWORD nRead = 0;
|
||||
while (1) {
|
||||
// Literally not worth recovering; we're working with something stupid.
|
||||
// Play stupid games, win stupid prizes.
|
||||
if (lidx == _countof(line)) break;
|
||||
|
||||
ReadFile(hGM, &(line[lidx]), 1, &nRead, NULL);
|
||||
if (nRead != 1) break;
|
||||
if (line[lidx] == '\n') {
|
||||
if (strncmp(line, "1P_ONLY 1\r\n", lidx) == 0) {
|
||||
bGmIs1P = TRUE;
|
||||
break;
|
||||
}
|
||||
lidx = 0;
|
||||
} else
|
||||
lidx++;
|
||||
}
|
||||
CloseHandle(hGM);
|
||||
}
|
||||
|
||||
// You can have any configuration you want as long as it's black
|
||||
if (bGmIs1P) {
|
||||
const char* GrooveMaster1P =
|
||||
("# TODO: Get maimai_deliver not rebooting the cab\r\n"
|
||||
"NO_DELIVER 1\r\n"
|
||||
"# TODO: figure out how to do this without also needing a USB\r\n"
|
||||
"USB_DL_DISABLE 1\r\n"
|
||||
"# These are just easier to do via GM than a patch\r\n"
|
||||
"1P_ONLY 1\r\n"
|
||||
"NO_REBOOT 1\r\n"
|
||||
"ROTATE 1\r\n");
|
||||
hook_file_with_buffer(L"GrooveMaster.ini", (LPBYTE)GrooveMaster1P,
|
||||
strlen(GrooveMaster1P) + 1, GENERIC_READ);
|
||||
} else {
|
||||
const char* GrooveMaster =
|
||||
("# TODO: Get maimai_deliver not rebooting the cab\r\n"
|
||||
"NO_DELIVER 1\r\n"
|
||||
"# TODO: figure out how to do this without also needing a USB\r\n"
|
||||
"USB_DL_DISABLE 1\r\n"
|
||||
"# These are just easier to do via GM than a patch\r\n"
|
||||
"NO_REBOOT 1\r\n"
|
||||
"ROTATE 1\r\n");
|
||||
hook_file_with_buffer(L"GrooveMaster.ini", (LPBYTE)GrooveMaster,
|
||||
strlen(GrooveMaster) + 1, GENERIC_READ);
|
||||
}
|
||||
|
||||
const char* RingmasterPub =
|
||||
("-----BEGIN PUBLIC KEY-----\r\n"
|
||||
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDH/y0LFuiVonnU+7fKLEOhfQoi\r\n"
|
||||
|
@ -25,3 +25,6 @@ void* open_mapped_file(LPCSTR path, DWORD size, HANDLE* file, HANDLE* file_mappi
|
||||
|
||||
#define char_lower(value) (('A' <= (value) && (value) <= 'Z') ? ((value) - 'A' + 'a') : (value))
|
||||
#define char_upper(value) (('a' <= (value) && (value) <= 'z') ? ((value) - 'a' + 'A') : (value))
|
||||
|
||||
// Use the second tag bit to indicate a mice handle
|
||||
#define MICE_HANDLE_MASK 0x00000002
|
||||
|
@ -7,9 +7,6 @@
|
||||
|
||||
#include "../hooks/files.h"
|
||||
|
||||
// Use the second tag bit to indicate a mice handle
|
||||
#define MICE_HANDLE_MASK 0x00000002
|
||||
|
||||
void PrintStack(void) {
|
||||
unsigned int i;
|
||||
void* stack[100];
|
||||
@ -59,6 +56,7 @@ PVOID GetDataForHandle(HANDLE hObject) {
|
||||
DWORD_PTR dwIndex = (DWORD_PTR)hObject >> 2;
|
||||
PHANDLE_DATA found = MiceDAGet(g_handleData, dwIndex);
|
||||
if (found == NULL) return NULL;
|
||||
|
||||
return found->m_pData;
|
||||
}
|
||||
void SetDataForHandle(HANDLE hObject, PVOID pData, BOOL isHeap) {
|
||||
@ -95,6 +93,7 @@ BOOL RemoveDataForHandle(HANDLE hObject) {
|
||||
found->m_pData = NULL;
|
||||
found->m_bOccupied = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HANDLE GetDummyHandle() {
|
||||
|
@ -6,11 +6,7 @@
|
||||
static inline void _MiceDAGrow(PMICE_DA lpDa) {
|
||||
DWORD_PTR newSize = lpDa->m_Capacity * 2 + 1;
|
||||
if (lpDa->m_Array) {
|
||||
LPVOID newArray = realloc(lpDa->m_Array, lpDa->m_Size * newSize);
|
||||
if (newArray != lpDa->m_Array) {
|
||||
memcpy(newArray, lpDa->m_Array, lpDa->m_Size * lpDa->m_Capacity);
|
||||
}
|
||||
lpDa->m_Array = newArray;
|
||||
lpDa->m_Array = realloc(lpDa->m_Array, lpDa->m_Size * newSize);
|
||||
} else {
|
||||
lpDa->m_Array = malloc(lpDa->m_Size * newSize);
|
||||
}
|
||||
@ -59,6 +55,9 @@ BOOL MiceDAGrowAndSet(PMICE_DA lpDa, DWORD_PTR dwIndex, LPVOID lpValue) {
|
||||
if (!lpDa || !lpValue) return FALSE;
|
||||
if (dwIndex >= lpDa->m_Length) {
|
||||
while (dwIndex >= lpDa->m_Capacity) _MiceDAGrow(lpDa);
|
||||
if (lpDa->m_Length != dwIndex)
|
||||
ZeroMemory(_MICE_DA_INDEX_P(lpDa, lpDa->m_Length),
|
||||
lpDa->m_Size * (lpDa->m_Length - dwIndex));
|
||||
lpDa->m_Length = dwIndex + 1;
|
||||
}
|
||||
_MICE_DA_COPY_INTO_DA(lpDa, dwIndex, lpValue);
|
||||
|
Loading…
x
Reference in New Issue
Block a user