//------------------------------------------------------------------------------------------------- // Entry point //------------------------------------------------------------------------------------------------- int main(void) { HWND Handle; unsigned int Game_Index, Error_Code; LONG_PTR Window_Style; // Display the banner wprintf(L"+------------------------------------------+\n"); wprintf(L"| Play It Fullscreen, (C) Adrien RICCIARDI |\n"); wprintf(L"| Build date : " CONVERT_ASCII_STRING_TO_WIDECHAR_STRING(__DATE__) L", " CONVERT_ASCII_STRING_TO_WIDECHAR_STRING(__TIME__) L" |\n"); wprintf(L"+------------------------------------------+\n"); // Wait for a game to be launched wprintf(L"Waiting for a game to be launched...\n"); WaitForGame(&Handle, &Game_Index); wprintf(L"Game found : %s.\n", Games[Game_Index].String_Window_Title); // TODO : use a new field in the struct for the game real name in case of some game not having a presentable window title // Remove the window border if required to if (Games[Game_Index].Is_Window_Border_Removed) { wprintf(L"Removing the window border...\n"); // Get the current window style Window_Style = GetWindowLongPtr(Handle, GWL_STYLE); if (Window_Style == 0) { wprintf(L"Error : failed to get the window style (error %u).\n", GetLastError()); goto Exit_Error; } // Remove the border and the title bar Window_Style &= ~(WS_BORDER | WS_CAPTION); // Set the new window style if (SetWindowLongPtr(Handle, GWL_STYLE, Window_Style) == 0) { Error_Code = GetLastError(); wprintf(L"Error : failed to set the window style (error %u).\n", Error_Code); if (Error_Code == ERROR_ACCESS_DENIED) wprintf(L"Try to run the program as administrator.\n"); goto Exit_Error; } wprintf(L"The window border was successfully removed.\n"); } // Maximize the game window if required to if (Games[Game_Index].Is_Window_Maximized) { ShowWindow(Handle, SW_MAXIMIZE); wprintf(L"The window was successfully maximized.\n"); } return EXIT_SUCCESS; Exit_Error: getchar(); return EXIT_FAILURE; }
void main() { is64bit = IsWow64(); printf("-=[w7ddpatcher by mudlord]=-\n"); printf("-=[for Win7/Vista %s]=-\n", is64bit ? "x64" : "x86"); OPENFILENAME ofn = {.lStructSize = sizeof(ofn)}; STARTUPINFO si = {.cb = sizeof(si)}; PROCESS_INFORMATION pi = {0}; char szFileName[MAX_PATH] = ""; ofn.hwndOwner = NULL; ofn.lpstrFilter = "Executables (*.exe)\0*.exe\0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = "exe"; printf("Waiting for executable file name...\n"); if (GetOpenFileName(&ofn)) { if (!CreateProcess(NULL, // No module name (use command line) szFileName, // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi) // Pointer to PROCESS_INFORMATION structure ) { printf("Can't load process!\n"); return; } WaitForGame(PathFindFileName(szFileName), &pi); } else { printf("Cancelled\n"); } int ch; printf("\nPress any key to exit...\n"); ch = _getch(); }