mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
Merge pull request #385 from Hoikas/patch-phailure
Fix some plUruLauncher Probz
This commit is contained in:
@ -497,22 +497,18 @@ bool InitPhysX()
|
||||
return false;
|
||||
|
||||
// launch the PhysX installer
|
||||
STARTUPINFOW startupInfo;
|
||||
PROCESS_INFORMATION processInfo;
|
||||
memset(&startupInfo, 0, sizeof(startupInfo));
|
||||
memset(&processInfo, 0, sizeof(processInfo));
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
if(!CreateProcessW(NULL, s_physXSetupExeName, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
|
||||
{
|
||||
hsMessageBox("Failed to launch PhysX installer.\nPlease re-run URU to ensure you have the latest version.", "Error", hsMessageBoxNormal);
|
||||
return false;
|
||||
}
|
||||
SHELLEXECUTEINFOW info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.cbSize = sizeof(info);
|
||||
info.lpFile = s_physXSetupExeName;
|
||||
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC;
|
||||
ShellExecuteExW(&info);
|
||||
|
||||
// let the user know what's going on
|
||||
HWND waitingDialog = ::CreateDialog(gHInst, MAKEINTRESOURCE(IDD_LOADING), NULL, WaitingForPhysXDialogProc);
|
||||
|
||||
// run a loop to wait for it to quit, pumping the windows message queue intermittently
|
||||
DWORD waitRet = WaitForSingleObject(processInfo.hProcess, 100);
|
||||
DWORD waitRet = WaitForSingleObject(info.hProcess, 100);
|
||||
MSG msg;
|
||||
while (waitRet == WAIT_TIMEOUT)
|
||||
{
|
||||
@ -521,12 +517,11 @@ bool InitPhysX()
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
waitRet = WaitForSingleObject(processInfo.hProcess, 100);
|
||||
waitRet = WaitForSingleObject(info.hProcess, 100);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
CloseHandle(processInfo.hThread);
|
||||
CloseHandle(processInfo.hProcess);
|
||||
CloseHandle(info.hProcess);
|
||||
::DestroyWindow(waitingDialog);
|
||||
}
|
||||
else
|
||||
|
@ -234,6 +234,8 @@ plString plClientLauncher::GetAppArgs() const
|
||||
ss << " -Image";
|
||||
if (hsCheckBits(fFlags, kPatchOnly))
|
||||
ss << " -PatchOnly";
|
||||
if (hsCheckBits(fFlags, kSkipLoginDialog))
|
||||
ss << " -SkipLoginDialog";
|
||||
|
||||
return ss.GetString();
|
||||
}
|
||||
@ -429,13 +431,15 @@ void plClientLauncher::ParseArguments()
|
||||
if (cmdParser.GetBool(arg)) \
|
||||
fFlags |= flag;
|
||||
|
||||
enum { kArgServerIni, kArgNoSelfPatch, kArgImage, kArgRepairGame, kArgPatchOnly };
|
||||
enum { kArgServerIni, kArgNoSelfPatch, kArgImage, kArgRepairGame, kArgPatchOnly,
|
||||
kArgSkipLoginDialog };
|
||||
const CmdArgDef cmdLineArgs[] = {
|
||||
{ kCmdArgFlagged | kCmdTypeString, L"ServerIni", kArgServerIni },
|
||||
{ kCmdArgFlagged | kCmdTypeBool, L"NoSelfPatch", kArgNoSelfPatch },
|
||||
{ kCmdArgFlagged | kCmdTypeBool, L"Image", kArgImage },
|
||||
{ kCmdArgFlagged | kCmdTypeBool, L"Repair", kArgRepairGame },
|
||||
{ kCmdArgFlagged | kCmdTypeBool, L"PatchOnly", kArgPatchOnly }
|
||||
{ kCmdArgFlagged | kCmdTypeBool, L"PatchOnly", kArgPatchOnly },
|
||||
{ kCmdArgFlagged | kCmdTypeBool, L"SkipLoginDialog", kArgSkipLoginDialog }
|
||||
};
|
||||
|
||||
CCmdParser cmdParser(cmdLineArgs, arrsize(cmdLineArgs));
|
||||
@ -448,6 +452,7 @@ void plClientLauncher::ParseArguments()
|
||||
APPLY_FLAG(kArgImage, kClientImage);
|
||||
APPLY_FLAG(kArgRepairGame, kRepairGame);
|
||||
APPLY_FLAG(kArgPatchOnly, kPatchOnly);
|
||||
APPLY_FLAG(kArgSkipLoginDialog, kSkipLoginDialog);
|
||||
|
||||
// last chance setup
|
||||
if (hsCheckBits(fFlags, kPatchOnly))
|
||||
|
@ -63,8 +63,9 @@ private:
|
||||
{
|
||||
kHaveSelfPatched = 1<<0,
|
||||
kClientImage = 1<<1,
|
||||
kGameDataOnly = (1<<2),
|
||||
kGameDataOnly = 1<<2,
|
||||
kPatchOnly = 1<<3,
|
||||
kSkipLoginDialog = 1<<4,
|
||||
|
||||
kRepairGame = kHaveSelfPatched | kClientImage | kGameDataOnly,
|
||||
};
|
||||
|
@ -66,26 +66,29 @@ static plClientLauncher s_launcher;
|
||||
static UINT s_taskbarCreated = RegisterWindowMessageW(L"TaskbarButtonCreated");
|
||||
static ITaskbarList3* s_taskbar = nullptr;
|
||||
|
||||
typedef std::unique_ptr<void, std::function<BOOL(HANDLE)>> handleptr_t;
|
||||
|
||||
// ===================================================
|
||||
|
||||
/** Create a global patcher mutex that is backwards compatible with eap's */
|
||||
static HANDLE CreatePatcherMutex()
|
||||
static handleptr_t CreatePatcherMutex()
|
||||
{
|
||||
return CreateMutexW(nullptr, FALSE, plManifest::PatcherExecutable().AsString().ToWchar());
|
||||
return handleptr_t(CreateMutexW(nullptr, TRUE, plManifest::PatcherExecutable().AsString().ToWchar()),
|
||||
CloseHandle);
|
||||
}
|
||||
|
||||
static bool IsPatcherRunning()
|
||||
{
|
||||
HANDLE mut = CreatePatcherMutex();
|
||||
return WaitForSingleObject(mut, 0) != WAIT_OBJECT_0;
|
||||
handleptr_t mut = CreatePatcherMutex();
|
||||
return WaitForSingleObject(mut.get(), 0) != WAIT_OBJECT_0;
|
||||
}
|
||||
|
||||
static void WaitForOldPatcher()
|
||||
{
|
||||
HANDLE mut = CreatePatcherMutex();
|
||||
DWORD wait = WaitForSingleObject(mut, 0);
|
||||
handleptr_t mut = CreatePatcherMutex();
|
||||
DWORD wait = WaitForSingleObject(mut.get(), 0);
|
||||
while (wait != WAIT_OBJECT_0) // :( :( :(
|
||||
wait = WaitForSingleObject(mut, 100);
|
||||
wait = WaitForSingleObject(mut.get(), 100);
|
||||
Sleep(1000); // :(
|
||||
}
|
||||
|
||||
@ -231,7 +234,7 @@ static void ISetDownloadStatus(const plString& status)
|
||||
}
|
||||
|
||||
|
||||
static HANDLE ICreateProcess(const plFileName& exe, const plString& args)
|
||||
static handleptr_t ICreateProcess(const plFileName& exe, const plString& args)
|
||||
{
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
@ -262,7 +265,7 @@ static HANDLE ICreateProcess(const plFileName& exe, const plString& args)
|
||||
// So maybe it needs elevation... Or maybe everything arseploded.
|
||||
if (result != FALSE) {
|
||||
CloseHandle(pi.hThread);
|
||||
return pi.hProcess;
|
||||
return handleptr_t(pi.hProcess, CloseHandle);
|
||||
} else if (GetLastError() == ERROR_ELEVATION_REQUIRED) {
|
||||
SHELLEXECUTEINFOW info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
@ -270,9 +273,9 @@ static HANDLE ICreateProcess(const plFileName& exe, const plString& args)
|
||||
info.lpFile = file.GetData();
|
||||
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC;
|
||||
info.lpParameters = args.ToWchar();
|
||||
hsAssert(ShellExecuteExW(&info), "ShellExecuteExW phailed");
|
||||
ShellExecuteExW(&info);
|
||||
|
||||
return info.hProcess;
|
||||
return handleptr_t(info.hProcess, CloseHandle);
|
||||
} else {
|
||||
wchar_t* msg = nullptr;
|
||||
FormatMessageW(
|
||||
@ -306,14 +309,13 @@ static bool IInstallRedist(const plFileName& exe)
|
||||
ss << " /norestart"; // I don't want to image the accusations of viruses and hacking if this happened...
|
||||
|
||||
// Now fire up the process...
|
||||
HANDLE process = ICreateProcess(exe, ss.GetString());
|
||||
handleptr_t process = ICreateProcess(exe, ss.GetString());
|
||||
if (process) {
|
||||
WaitForSingleObject(process, INFINITE);
|
||||
WaitForSingleObject(process.get(), INFINITE);
|
||||
|
||||
// Get the exit code so we can indicate success/failure to the redist thread
|
||||
DWORD code = PLASMA_OK;
|
||||
hsAssert(GetExitCodeProcess(process, &code), "failed to get redist exit code");
|
||||
CloseHandle(process);
|
||||
GetExitCodeProcess(process.get(), &code);
|
||||
|
||||
return code != PLASMA_PHAILURE;
|
||||
}
|
||||
@ -329,17 +331,14 @@ static void ILaunchClientExecutable(const plFileName& exe, const plString& args)
|
||||
// Only launch a client executable if we're given one. If not, that's probably a cue that we're
|
||||
// done with some service operation and need to go away.
|
||||
if (!exe.AsString().IsEmpty()) {
|
||||
HANDLE hEvent = CreateEventW(nullptr, TRUE, FALSE, L"UruPatcherEvent");
|
||||
HANDLE process = ICreateProcess(exe, args);
|
||||
handleptr_t hEvent = handleptr_t(CreateEventW(nullptr, TRUE, FALSE, L"UruPatcherEvent"), CloseHandle);
|
||||
handleptr_t process = ICreateProcess(exe, args);
|
||||
|
||||
// if this is the real game client, then we need to make sure it gets this event...
|
||||
if (plManifest::ClientExecutable().AsString().CompareI(exe.AsString()) == 0) {
|
||||
WaitForInputIdle(process, 1000);
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
WaitForInputIdle(process.get(), 1000);
|
||||
WaitForSingleObject(hEvent.get(), INFINITE);
|
||||
}
|
||||
|
||||
CloseHandle(process);
|
||||
CloseHandle(hEvent);
|
||||
}
|
||||
|
||||
// time to hara-kiri...
|
||||
@ -399,7 +398,7 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
|
||||
IShowErrorDialog(text.ToWchar());
|
||||
return PLASMA_OK;
|
||||
}
|
||||
HANDLE _onePatcherMut = CreatePatcherMutex();
|
||||
HANDLE _onePatcherMut = CreatePatcherMutex().release();
|
||||
|
||||
// Initialize the network core
|
||||
s_launcher.InitializeNetCore();
|
||||
|
Reference in New Issue
Block a user