diff --git a/src/micetools/dll/devices/ser_led_bd.c b/src/micetools/dll/devices/ser_led_bd.c index 31a6c71..6a0d21e 100644 --- a/src/micetools/dll/devices/ser_led_bd.c +++ b/src/micetools/dll/devices/ser_led_bd.c @@ -192,7 +192,6 @@ void __stdcall led_overlay(unsigned int hookType, IDirect3DDevice9* dev) { // maimai is DX9, so no point handling anything else anyway if (hookType != UI_HOOK_DX9) return; - ShowCursor(true); D3DDEVICE_CREATION_PARAMETERS cparams; RECT rect; diff --git a/src/micetools/dll/games.c b/src/micetools/dll/games.c index c0d024b..4a5b274 100644 --- a/src/micetools/dll/games.c +++ b/src/micetools/dll/games.c @@ -73,7 +73,8 @@ void mice_got_game_id(char game_id[4]) { memset(&jvsKeybindings[0].buttons[3 * 2], 0, 12 * 2); memset(&jvsKeybindings[0].invert[3 * 2], 0, 12 * 2); - jvsKeybindings[0].buttons[1 * 2] = VK_TAB; + jvsKeybindings[0].buttons[0 * 2] = VK_BACK; + jvsKeybindings[0].buttons[1 * 2] = VK_RETURN; jvsKeybindings[0].buttons[3 * 2] = VK_UP; jvsKeybindings[0].buttons[4 * 2] = VK_DOWN; diff --git a/src/micetools/dll/gui/gui.c b/src/micetools/dll/gui/gui.c index f0fdfb9..6d9ee82 100644 --- a/src/micetools/dll/gui/gui.c +++ b/src/micetools/dll/gui/gui.c @@ -71,6 +71,12 @@ extern void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); // TODO: Implement log viewing extern CRITICAL_SECTION logger_lock; +// Open flags +static bool showFps = false; +static bool showEeprom = false; +static bool showSram = false; +static bool showControl = false; + void InitImGui(unsigned int hookType, IDirect3DDevice9* pDevice) { if (hookType == UI_HOOK_DX9) { D3DDEVICE_CREATION_PARAMETERS CP; @@ -135,15 +141,16 @@ void hud_eeprom(ImGuiKey open_key) { static bool has_init = false; if (!has_init) { MemoryEditor_Init(&editor); - editor.Open = false; + showEeprom = false; has_init = true; } - if (igIsKeyPressed_Bool(open_key, false)) editor.Open = !editor.Open; + if (igIsKeyPressed_Bool(open_key, false)) showEeprom = !showEeprom; // TODO: Less hacky :) extern BYTE EEPROM_DATA[0x2000]; - if (editor.Open) + editor.Open = showEeprom; + if (showEeprom) MemoryEditor_DrawWindow(&editor, "EEPROM Editor", EEPROM_DATA, sizeof EEPROM_DATA, 0x000); } void hud_sram(ImGuiKey open_key) { @@ -151,15 +158,15 @@ void hud_sram(ImGuiKey open_key) { static bool has_init = false; if (!has_init) { MemoryEditor_Init(&editor); - editor.Open = false; + showSram = false; has_init = true; } - if (igIsKeyPressed_Bool(open_key, false)) editor.Open = !editor.Open; + if (igIsKeyPressed_Bool(open_key, false)) showSram = !showSram; // TODO: Less hacky :) extern LPBYTE SRAM_DATA; - if (editor.Open) - MemoryEditor_DrawWindow(&editor, "SRAM Editor", SRAM_DATA, 1024 * 1024, 0x0000); + editor.Open = showSram; + if (showSram) MemoryEditor_DrawWindow(&editor, "SRAM Editor", SRAM_DATA, 1024 * 1024, 0x0000); } void igHelpMarker(const char* text) { @@ -892,21 +899,8 @@ void tab_main_keybinds() { } void hud_control(ImGuiKey open_key) { - static bool isOpen = false; - static bool oldCursor; - if (igIsKeyPressed_Bool(open_key, false)) { - isOpen = !isOpen; - if (isOpen) { - CURSORINFO ci; - GetCursorInfo(&ci); - oldCursor = !!(ci.flags & CURSOR_SHOWING); - ShowCursor(TRUE); - } else { - ShowCursor(oldCursor); - } - } - - if (!isOpen) return; + if (igIsKeyPressed_Bool(open_key, false)) showControl = !showControl; + if (!showControl) return; igBegin("Micetools", NULL, 0); static bool haveFirstFrame = false; @@ -940,12 +934,18 @@ void hud_control(ImGuiKey open_key) { } void __stdcall hud_gui(unsigned int hookType, IDirect3DDevice9* dev) { - ShowCursor(1); + static bool lastAnyOpen = false; + bool anyOpen = showControl || showEeprom || showSram; + if (anyOpen != lastAnyOpen) { + changeCursorState = anyOpen ? 1 : 0; + lastAnyOpen = anyOpen; + } static bool initialized = false; if (!initialized) { InitImGui(hookType, dev); initialized = true; + changeCursorState = 0; // Hide cursor by default } if (hookType == UI_HOOK_DX9) { @@ -958,7 +958,6 @@ void __stdcall hud_gui(unsigned int hookType, IDirect3DDevice9* dev) { ImGui_ImplGLUT_NewFrame(); } - static bool showFps = false; if (igIsKeyPressed_Bool(ImGuiKey_F12, false)) showFps = !showFps; if (showFps) hud_fps(); diff --git a/src/micetools/dll/hooks/_hooks.c b/src/micetools/dll/hooks/_hooks.c index f31f17b..7e60c4a 100644 --- a/src/micetools/dll/hooks/_hooks.c +++ b/src/micetools/dll/hooks/_hooks.c @@ -14,5 +14,5 @@ void hook_all() { if (MiceConfig.hooks.time) hook_time(); if (MiceConfig.hooks.registry) hook_registry(); if (MiceConfig.hooks.drives) hook_drives(); - hook_system(); + if (MiceConfig.hooks.system) hook_system(); } diff --git a/src/micetools/dll/hooks/drive/drive.c b/src/micetools/dll/hooks/drive/drive.c index 769b0d2..4abd950 100644 --- a/src/micetools/dll/hooks/drive/drive.c +++ b/src/micetools/dll/hooks/drive/drive.c @@ -4,6 +4,7 @@ #include "../../../lib/ami/amiMd5.h" #include "../../../micemaster/mxmEventLog.h" #include "../../../sysconf.h" +#include "../../util/_util.h" #include "../files.h" /* @@ -87,7 +88,7 @@ BOOL WriteFunc_Original0(DWORD nOffset, LPCVOID lpBuffer, DWORD nNumberOfBytesTo } BOOL ReadFunc_Patch0(DWORD nOffset, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, - LPDWORD lpNumberOfBytesRead) { + LPDWORD lpNumberOfBytesRead) { *lpNumberOfBytesRead = 0; if (!_PathFileExistsA(PATCH0_PATH)) { log_error(plfDrive, "Failed to open %s (does not exist)", PATCH0_PATH); @@ -109,7 +110,7 @@ BOOL ReadFunc_Patch0(DWORD nOffset, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, return ret; } BOOL WriteFunc_Patch0(DWORD nOffset, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, - LPDWORD lpNumberOfBytesWritten) { + LPDWORD lpNumberOfBytesWritten) { *lpNumberOfBytesWritten = 0; HANDLE hFile = @@ -128,7 +129,7 @@ BOOL WriteFunc_Patch0(DWORD nOffset, LPCVOID lpBuffer, DWORD nNumberOfBytesToWri } BOOL WriteFunc_OS(DWORD nOffset, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, - LPDWORD lpNumberOfBytesWritten) { + LPDWORD lpNumberOfBytesWritten) { *lpNumberOfBytesWritten = nNumberOfBytesToWrite; log_warning(plfDrive, "%d bytes write in OS at %08x", nNumberOfBytesToWrite, nOffset); return TRUE; @@ -346,14 +347,6 @@ sbr_slot_t* get_sbr_slot(spd_slot_t slot) { } } -inline char char_lower(char value) { - if ('A' <= value && value <= 'Z') return value - 'A' + 'a'; - return value; -} -inline char char_upper(char value) { - if ('a' <= value && value <= 'z') return value - 'a' + 'A'; - return value; -} char matchWorkFilename[MAX_PATH + 1]; inline static BOOL matchVolume(disk_volume_t* volume, LPCSTR lpRootPathName, DWORD match) { if (match & VOL_MATCH_GUID) { @@ -675,9 +668,11 @@ BOOL q_drive_ReadFile(file_context_t* ctx, LPVOID lpBuffer, DWORD nNumberOfBytes * +512: Boot ID (128 sectors) [keychip.decrypt] */ - // HANDLE hFile = _CreateFileA("\\\\.\\E:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + // HANDLE hFile = _CreateFileA("\\\\.\\E:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, + // NULL, // OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - HANDLE hFile = _CreateFileA("H:\\Arcades\\Images\\ALLNet_Pras_Multi_Ver2\\DVR-0069A.iso", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + HANDLE hFile = _CreateFileA("H:\\Arcades\\Images\\ALLNet_Pras_Multi_Ver2\\DVR-0069A.iso", + GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { log_error(plfDrive, "Q:READ FAILED. FILE FALLBACK FAILED. %d", GetLastError()); @@ -731,8 +726,9 @@ void hook_drives() { NULL); hook("Kernel32.dll", "DeleteVolumeMountPointA", &FakeDeleteVolumeMountPointA, NULL); hook("Kernel32.dll", "SetVolumeMountPointA", &FakeSetVolumeMountPointA, NULL); - hook("Kernel32.dll", "GetDriveTypeA", &FakeGetDriveTypeA, NULL); - hook("Kernel32.dll", "GetDiskFreeSpaceExA", &FakeGetDiskFreeSpaceExA, (void**)&TrueGetDiskFreeSpaceExA); + hook("Kernel32.dll", "GetDriveTypeA", &FakeGetDriveTypeA, (void**)&TrueGetDriveTypeA); + hook("Kernel32.dll", "GetDiskFreeSpaceExA", &FakeGetDiskFreeSpaceExA, + (void**)&TrueGetDiskFreeSpaceExA); hook("Winmm.dll", "mciSendStringA", &Fake_mciSendStringA, NULL); diff --git a/src/micetools/dll/hooks/drive/drive.h b/src/micetools/dll/hooks/drive/drive.h index f98ac82..d94fc8c 100644 --- a/src/micetools/dll/hooks/drive/drive.h +++ b/src/micetools/dll/hooks/drive/drive.h @@ -87,6 +87,7 @@ BOOL WINAPI FakeSetVolumeMountPointW(LPCWSTR lpszVolumeMountPoint, LPCWSTR lpszV MCIERROR WINAPI Fake_mciSendStringA(LPCTSTR lpszCommand, LPTSTR lpszReturnString, UINT cchReturn, HANDLE hwndCallback); UINT WINAPI FakeGetDriveTypeA(LPCSTR lpRootPathName); +UINT(WINAPI* TrueGetDriveTypeA)(LPCSTR lpRootPathName); BOOL WINAPI FakeGetDiskFreeSpaceExA(LPCSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailableToCaller, PULARGE_INTEGER lpTotalNumberOfBytes, diff --git a/src/micetools/dll/hooks/drive/hooks.c b/src/micetools/dll/hooks/drive/hooks.c index ee00045..2d5f2e4 100644 --- a/src/micetools/dll/hooks/drive/hooks.c +++ b/src/micetools/dll/hooks/drive/hooks.c @@ -219,7 +219,8 @@ DWORD WINAPI FakeQueryDosDeviceA(LPCSTR lpDeviceName, LPSTR lpTargetPath, DWORD return 0; } -const wchar_t* DUMMY_USB_RM = L"STORAGE#RemovableMedia#0&75ad516&0&rm#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}"; +const wchar_t* DUMMY_USB_RM = + L"STORAGE#RemovableMedia#0&75ad516&0&rm#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}"; DWORD WINAPI FakeQueryDosDeviceW(LPCWSTR lpDeviceName, LPWSTR lpTargetPath, DWORD ucchMax) { log_warning(plfDrive, "QueryDosDeviceW(%ls, -, %d)", lpDeviceName, ucchMax); if (lpDeviceName != NULL) { @@ -286,10 +287,21 @@ MCIERROR WINAPI Fake_mciSendStringA(LPCTSTR lpszCommand, LPTSTR lpszReturnString } UINT WINAPI FakeGetDriveTypeA(LPCSTR lpRootPathName) { + log_trace(plfDrive, "GetDriveTypeA(%s)", lpRootPathName); + disk_volume_t* volume = getVolumeByPath(lpRootPathName, VOL_MATCH_PATH | VOL_MATCH_DOS_DEVICE); if (volume == NULL) { - SetLastError(ERROR_FILE_NOT_FOUND); - return DRIVE_NO_ROOT_DIR; + // If we aren't faking this drive, check if we're allowing fall-through + // char gameDrive = char_lower(GetGamedataDrive()); + // if (strlen(lpRootPathName) >= 2 && char_lower(lpRootPathName[0]) == gameDrive && + // lpRootPathName[1] == ':') { + // return DRIVE_FIXED; + // } + // SetLastError(ERROR_FILE_NOT_FOUND); + // return DRIVE_NO_ROOT_DIR; + + // We could do the above, but for now, we're just going to pass through to the real API. + return TrueGetDriveTypeA(lpRootPathName); } switch (volume->m_pDrive->m_DiskType) { diff --git a/src/micetools/dll/hooks/files.c b/src/micetools/dll/hooks/files.c index 13d1ef8..5e877b1 100644 --- a/src/micetools/dll/hooks/files.c +++ b/src/micetools/dll/hooks/files.c @@ -1,5 +1,6 @@ #define _MICE_FILES #include "files.h" +#include "../util/_util.h" HANDLE open_hook(file_hook_t* file_hook) { open_hook_t* opened = (open_hook_t*)malloc(sizeof(open_hook_t)); @@ -116,19 +117,6 @@ file_hook_t* find_hook(LPCWSTR lpFileName) { return NULL; }; -char WORKING_DIR[MAX_PATH + 1] = { 0 }; -char get_gamedata_drive() { - if (WORKING_DIR[0] == 0x00) { - GetCurrentDirectoryA(sizeof WORKING_DIR, WORKING_DIR); - } - return WORKING_DIR[0]; -} - -inline char char_lower(char value) { - if ('A' <= value && value <= 'Z') return value - 'A' + 'a'; - return value; -} - BOOL redirect_path(LPCSTR path, LPCSTR* redirected) { for (int i = 0; i < sizeof DRIVE_REDIRECT_TABLE / sizeof DRIVE_REDIRECT_TABLE[0]; i++) { drive_redirect_t row = DRIVE_REDIRECT_TABLE[i]; @@ -153,8 +141,7 @@ BOOL redirect_path(LPCSTR path, LPCSTR* redirected) { } // Don't redirect local paths - GetCurrentDirectoryA(sizeof WORKING_DIR, WORKING_DIR); - if (PathPrefix(path, WORKING_DIR)) return FALSE; + if (IsGamedataLocalPath(path)) return FALSE; if ((('a' <= path[0] && path[0] <= 'z') || ('A' <= path[0] && path[0] <= 'Z')) && path[1] == ':' && (path[2] == '/' || path[2] == '\\')) { @@ -425,10 +412,8 @@ DWORD WINAPI FakeGetFileAttributesW(LPCWSTR lpFileName) { return TrueGetFileAttributesW(lpFileName); } HANDLE WINAPI FakeFindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData) { - printf("FakeFindFirstFileA(%s)\n", lpFileName); LPCSTR redirected; if (redirect_path(lpFileName, &redirected)) { - printf("->FakeFindFirstFileA(%s)\n", redirected); return TrueFindFirstFileA(redirected, lpFindFileData); } return TrueFindFirstFileA(lpFileName, lpFindFileData); diff --git a/src/micetools/dll/hooks/gui.c b/src/micetools/dll/hooks/gui.c index 4f47097..9bc17bb 100644 --- a/src/micetools/dll/hooks/gui.c +++ b/src/micetools/dll/hooks/gui.c @@ -128,10 +128,21 @@ void register_gui_hook(FnEndScene* end_scene) { *head = hook; } +DWORD changeCursorState = (DWORD)-1; LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); + if (changeCursorState == 1) { + while (ShowCursor(TRUE) < 0) + ; + changeCursorState = (DWORD)-1; + } else if (changeCursorState == 0) { + while (ShowCursor(FALSE) >= 0) + ; + changeCursorState = (DWORD)-1; + } + return DefSubclassProc(hWnd, uMsg, wParam, lParam); } @@ -192,15 +203,15 @@ void SetupWindowPosition(LPRECT lpRect, DWORD dwStyle) { lpRect->top = y; lpRect->bottom = y + h; - // AdjustWindowRect(lpRect, dwStyle, FALSE); + AdjustWindowRect(lpRect, dwStyle, FALSE); } HWND WINAPI FakeCreateWindowExA(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam) { // Pass-through for system stuff - if (lpWindowName == NULL || strcmp(lpWindowName, "OleMainThreadWndName") == 0 || - strcmp(lpWindowName, "CicMarshalWnd") == 0) { + if (lpWindowName != NULL && (strcmp(lpWindowName, "OleMainThreadWndName") == 0 || + strcmp(lpWindowName, "CicMarshalWnd") == 0)) { return TrueCreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); } @@ -259,10 +270,10 @@ HRESULT STDMETHODCALLTYPE FakeCreateDevice(IDirect3D9* this, UINT Adapter, D3DDE } else if (pPresentationParameters->Windowed) { D3DDISPLAYMODE d3ddm; this->lpVtbl->GetAdapterDisplayMode(this, Adapter, &d3ddm); - pPresentationParameters->Windowed = FALSE; pPresentationParameters->FullScreen_RefreshRateInHz = d3ddm.RefreshRate; } + if (MiceConfig.window.borderless) UnFrameWindow(hFocusWindow); else @@ -365,14 +376,29 @@ void __stdcall Fake_glutReshapeWindow(int width, int height) { // True_glutReshapeWindow(winRect.right - winRect.left, winRect.bottom - winRect.top); } +LONG WINAPI FakeChangeDisplaySettingsA(DEVMODEA* lpDevMode, DWORD dwFlags) { + return DISP_CHANGE_SUCCESSFUL; +} +LONG WINAPI FakeChangeDisplaySettingsExA(LPCSTR lpszDeviceName, DEVMODEA* lpDevMode, HWND hwnd, + DWORD dwflags, LPVOID lParam) { + return DISP_CHANGE_SUCCESSFUL; +} + +HCURSOR WINAPI FakeSetCursor(HCURSOR hCursor) { return NULL; } + void hook_gui() { hook("User32.dll", "CreateWindowExA", FakeCreateWindowExA, (void**)&TrueCreateWindowExA); hook("User32.dll", "CreateWindowExW", FakeCreateWindowExW, (void**)&TrueCreateWindowExW); + hook("User32.dll", "GetSystemMetrics", FakeGetSystemMetrics, (void**)&TrueGetSystemMetrics); hook("User32.dll", "ChangeDisplaySettingsExW", FakeChangeDisplaySettingsExW, (void**)&TrueChangeDisplaySettingsExW); hook("D3d9.dll", "Direct3DCreate9", FakeDirect3DCreate9, (void**)&TrueDirect3DCreate9); + hook("User32.dll", "ChangeDisplaySettingsA", FakeChangeDisplaySettingsA, NULL); + hook("User32.dll", "ChangeDisplaySettingsExA", FakeChangeDisplaySettingsExA, NULL); + hook("User32.dll", "SetCursor", FakeSetCursor, (void**)&TrueSetCursor); + if (PathFileExistsA("FREEGLUT.DLL")) { // Hooked as a way to identify use of GLUT hook("FREEGLUT.DLL", "glutInitDisplayMode", Fake_glutInitDisplayMode, diff --git a/src/micetools/dll/hooks/gui.h b/src/micetools/dll/hooks/gui.h index b674e85..aa7c7b2 100644 --- a/src/micetools/dll/hooks/gui.h +++ b/src/micetools/dll/hooks/gui.h @@ -12,6 +12,8 @@ static HWND(WINAPI* TrueCreateWindowExW)(DWORD dwExStyle, LPCWSTR lpClassName, L static BOOL(WINAPI* TrueSetSystemCursor)(HCURSOR hcur, DWORD id); static IDirect3D9*(WINAPI* TrueDirect3DCreate9)(UINT SDKVersion); static int(WINAPI* TrueGetSystemMetrics)(int nIndex); +HCURSOR(WINAPI* TrueSetCursor)(HCURSOR hCursor); +#define _SetCursor (TrueSetCursor ? TrueSetCursor : SetCursor) static void (__stdcall* True_glutFullScreen)(void); static void (__stdcall* True_glutSwapBuffers)(void); @@ -42,3 +44,4 @@ void hook_gui(); void setup_hud_gui(); extern HWND mainWindow; +extern DWORD changeCursorState; diff --git a/src/micetools/dll/hooks/system.c b/src/micetools/dll/hooks/system.c index 431ac49..dfd9394 100644 --- a/src/micetools/dll/hooks/system.c +++ b/src/micetools/dll/hooks/system.c @@ -39,12 +39,6 @@ HCURSOR WINAPI FakeLoadCursorFromFileA(LPCSTR lpFileName) { return (HANDLE)1; } BOOL FakeSetSystemCursor(HCURSOR hcur, DWORD id) { return TRUE; } BOOL FakeDeleteObject(HGDIOBJ ho) { return TRUE; } -LONG WINAPI FakeChangeDisplaySettingsA(DEVMODEA* lpDevMode, DWORD dwFlags) { return 0; } -LONG WINAPI FakeChangeDisplaySettingsExA(LPCSTR lpszDeviceName, DEVMODEA* lpDevMode, HWND hwnd, - DWORD dwflags, LPVOID lParam) { - return 0; -} - FARPROC FakeGetProcAddress(HMODULE hModule, LPCSTR lpProcName) { log_trace(plfSystem, "GetProcAddress(%s)", lpProcName); return TrueGetProcAddress(hModule, lpProcName); @@ -57,12 +51,12 @@ HMODULE FakeGetModuleHandleA(LPCSTR lpModuleName) { LONG WINAPI FakeRtlGetVersion(PRTL_OSVERSIONINFOW lpVersionInformation) { log_trace(plfSystem, "RtlGetVersion(%p)", lpVersionInformation); - if (lpVersionInformation->dwOSVersionInfoSize >= sizeof (OSVERSIONINFOW)) { + if (lpVersionInformation->dwOSVersionInfoSize >= sizeof(OSVERSIONINFOW)) { lpVersionInformation->dwMajorVersion = OS_VERSION.dwMajorVersion; lpVersionInformation->dwMinorVersion = OS_VERSION.dwMinorVersion; lpVersionInformation->dwBuildNumber = OS_VERSION.dwBuildNumber; } - if (lpVersionInformation->dwOSVersionInfoSize >= sizeof (OSVERSIONINFOEXW)) { + if (lpVersionInformation->dwOSVersionInfoSize >= sizeof(OSVERSIONINFOEXW)) { PRTL_OSVERSIONINFOEXW lpVersionInformationEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation; lpVersionInformationEx->wServicePackMajor = 3; lpVersionInformationEx->wServicePackMinor = 0; @@ -78,9 +72,6 @@ void hook_system() { // hook("Kernel32.dll", "GetProcAddress", FakeGetProcAddress, (void*)&TrueGetProcAddress); // hook("Kernel32.dll", "GetModuleHandleA", FakeGetModuleHandleA, (void*)&TrueGetModuleHandleA); - hook("User32.dll", "ChangeDisplaySettingsA", FakeChangeDisplaySettingsA, NULL); - hook("User32.dll", "ChangeDisplaySettingsExA", FakeChangeDisplaySettingsExA, NULL); - // hook("ntdll.dll", "RtlGetVersion", FakeRtlGetVersion, NULL); // hook("User32.dll", "LoadCursorFromFileA", FakeLoadCursorFromFileA, NULL); diff --git a/src/micetools/dll/util/_util.h b/src/micetools/dll/util/_util.h index 2a0c991..6ece4b4 100644 --- a/src/micetools/dll/util/_util.h +++ b/src/micetools/dll/util/_util.h @@ -1,7 +1,7 @@ #pragma once -#include "log.h" #include "hook.h" +#include "log.h" #define HDATA_FILE 0 #define HDATA_FIND_VOLUME 1 @@ -17,6 +17,11 @@ void PrintStack(void); BOOL PathEqual(LPCSTR path1, LPCSTR path2); BOOL PathPrefix(LPCSTR path, LPCSTR prefix); +char GetGamedataDrive(void); +BOOL IsGamedataLocalPath(LPCSTR path); void make_dirs(const char* path); void* open_mapped_file(LPCWSTR path, DWORD size, HANDLE* file, HANDLE* file_mapping); + +#define char_lower(value) (('A' <= (value) && (value) <= 'Z') ? ((value) - 'A' + 'a') : (value)) +#define char_upper(value) (('a' <= (value) && (value) <= 'z') ? ((value) - 'a' + 'A') : (value)) diff --git a/src/micetools/dll/util/log.c b/src/micetools/dll/util/log.c index a6fc95a..f1f0e51 100644 --- a/src/micetools/dll/util/log.c +++ b/src/micetools/dll/util/log.c @@ -222,7 +222,7 @@ void log_stack(PLOG_FACILITY facility) { SymGetSymFromAddr64(process, (ULONG64)stack.AddrPC.Offset, &displacement, symbol); UnDecorateSymbolName(symbol->Name, (PSTR)name, sizeof(name), UNDNAME_COMPLETE); - log_error(facility, "%02u called from 0x%08X STACK=0x%08X FRAME=0x%08X %s\n", frame, + log_error(facility, "%02u called from 0x%08X STACK=0x%08X FRAME=0x%08X %s", frame, (ULONG64)stack.AddrPC.Offset, (ULONG64)stack.AddrStack.Offset, (ULONG64)stack.AddrFrame.Offset, symbol->Name); diff --git a/src/micetools/dll/util/misc.c b/src/micetools/dll/util/misc.c index 8230996..f97e198 100644 --- a/src/micetools/dll/util/misc.c +++ b/src/micetools/dll/util/misc.c @@ -179,11 +179,10 @@ void* open_mapped_file(LPCWSTR path, DWORD size, HANDLE* file, HANDLE* file_mapp if (mapping == NULL || GetLastError()) { log_error(plfMisc, "Failed to MapViewOfFileEx: %d", GetLastError()); CloseHandle(*file); - CloseHandle(*file_mapping); + CloseHandle(*file_mapping); *file = INVALID_HANDLE_VALUE; *file_mapping = INVALID_HANDLE_VALUE; return NULL; } return mapping; } - diff --git a/src/micetools/dll/util/path.c b/src/micetools/dll/util/path.c index fffcf3a..01b1a40 100644 --- a/src/micetools/dll/util/path.c +++ b/src/micetools/dll/util/path.c @@ -1,7 +1,7 @@ #include -#include -#include #include +#include +#include BOOL PathEqual(LPCSTR path1, LPCSTR path2) { char buffer1[MAX_PATH]; @@ -21,3 +21,13 @@ BOOL PathPrefix(LPCSTR path, LPCSTR prefix) { return strstr(buffer1, buffer2) == buffer1; } + +static char WORKING_DIR[MAX_PATH + 1] = { 0 }; +char GetGamedataDrive(void) { + if (WORKING_DIR[0] == 0x00) GetCurrentDirectoryA(sizeof WORKING_DIR, WORKING_DIR); + return WORKING_DIR[0]; +} +BOOL IsGamedataLocalPath(LPCSTR path) { + if (WORKING_DIR[0] == 0x00) GetCurrentDirectoryA(sizeof WORKING_DIR, WORKING_DIR); + return PathPrefix(path, WORKING_DIR); +} diff --git a/src/micetools/launcher/locate.c b/src/micetools/launcher/locate.c index b02b5e6..6efacef 100644 --- a/src/micetools/launcher/locate.c +++ b/src/micetools/launcher/locate.c @@ -6,6 +6,9 @@ const char* KNOWN_GAMES[] = { // Preferentially use a decrypted dump if present "maimai_dump_.exe", + // Specific games + "DOA5A.exe", + // Generic "RingGame.exe", diff --git a/src/micetools/lib/mice/config.def b/src/micetools/lib/mice/config.def index 9aeae76..a49955c 100644 --- a/src/micetools/lib/mice/config.def +++ b/src/micetools/lib/mice/config.def @@ -31,7 +31,7 @@ SECTION(sysconf, "System configuration settings") CFG_int(sysconf, region, 1, "Board region. 1 = Jpn, 2 = USA, 4 = Exp, 8 = Chn") CFG_bool(sysconf, rental, false, "") CFG_str(sysconf, serial, "AASE-01A65646203", "") -CFG_hex(sysconf, dipsw, 2, 70, "DIP Switch values") +CFG_hex(sysconf, dipsw, 2, 40, "DIP Switch values") // Default 40 = 1280x720 ENDSECTION(sysconf) SECTION(window, "Game window positioning settings") @@ -41,7 +41,7 @@ CFG_int(window, adaptor, 0, "Display adaptor to use") CFG_bool(window, centre, true, "Centre the window. X and Y are used otherwise") CFG_int(window, x, 0, "Window position X") CFG_int(window, y, 0, "Window position Y") -CFG_bool(window, nosize, true, "Don't change window resolution") +CFG_bool(window, nosize, false, "Don't change window resolution") CFG_bool(window, dipsw, true, "Use DIPSW for resolution") CFG_int(window, w, 0, "Window width (0 to unset)") CFG_int(window, h, 0, "Window height (0 to unset)") @@ -87,6 +87,7 @@ CFG_bool(hooks, network, true, "Provides a virtual network environment for the g CFG_bool(hooks, time, true, "Some binaries try to change the system time; this handles that") CFG_bool(hooks, registry, true, "") CFG_bool(hooks, drives, true, "Provides an emulation layer for the physical game SSD") +CFG_bool(hooks, system, true, "") ENDSECTION(hooks) SECTION(keys, "Raw keybinding data. Edit this using the built in binding tool!")