Updater: fixed release crash, fixed invalid state

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4718 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
dmex
2011-09-25 17:21:19 +00:00
parent 23427e7224
commit 9bfddea2b0
3 changed files with 50 additions and 47 deletions
+3 -3
View File
@@ -100,9 +100,9 @@ BEGIN
CONTROL 105,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,176,2,83,24
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,6,61,253,14
CONTROL "Ready",IDC_STATUSTEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,7,50,136,9,WS_EX_TRANSPARENT
CONTROL "Checking...",IDC_MESSAGE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,7,7,110,9
CONTROL "Released:",IDC_RELDATE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | NOT WS_VISIBLE | WS_GROUP,7,19,114,9
CONTROL "Size:",IDC_DLSIZE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | NOT WS_VISIBLE | WS_GROUP,7,28,54,9
CONTROL "Checking...",IDC_MESSAGE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,6,6,150,9
CONTROL "Released:",IDC_RELDATE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | NOT WS_VISIBLE | WS_GROUP,6,18,114,9
CONTROL "Size:",IDC_DLSIZE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | NOT WS_VISIBLE | WS_GROUP,6,29,54,9
CONTROL "Speed:",IDC_SPEEDTEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | NOT WS_VISIBLE | WS_GROUP,151,50,108,9,WS_EX_TRANSPARENT
CONTROL "Remaining:",IDC_RTIMETEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | NOT WS_VISIBLE | WS_GROUP,6,79,133,9,WS_EX_TRANSPARENT
END
+41 -44
View File
@@ -22,12 +22,6 @@
*/
#include "updater.h"
#include <process.h>
// Always consider the remote version newer
#ifdef _DEBUG
#define TEST_MODE
#endif
static PPH_STRING RemoteHashString = NULL, LocalFilePathString = NULL, LocalFileNameString = NULL;
static HINTERNET NetInitialize = NULL, NetConnection = NULL, NetRequest = NULL;
@@ -168,17 +162,40 @@ static void __cdecl WorkerThreadStart(
Edit_SetText(GetDlgItem(hwndDlg, IDC_RELDATE), summaryText->Buffer);
PhDereferenceObject(summaryText);
summaryText = PhFormatString(L"Size: %s", xmlData.Size->Buffer);
Edit_SetText(GetDlgItem(hwndDlg, IDC_DLSIZE), summaryText->Buffer);
PhDereferenceObject(summaryText);
summaryText = PhFormatString(L"Size: %s", xmlData.Size->Buffer);
Edit_SetText(GetDlgItem(hwndDlg, IDC_DLSIZE), summaryText->Buffer);
PhDereferenceObject(summaryText);
LocalFileNameString = PhFormatString(L"processhacker-%u.%u-setup.exe", xmlData.MajorVersion, xmlData.MinorVersion);
LocalFileNameString = PhFormatString(L"processhacker-%u.%u-setup.exe", xmlData.MajorVersion, xmlData.MinorVersion);
Edit_Visible(GetDlgItem(hwndDlg, IDC_RELDATE), TRUE);
Edit_Visible(GetDlgItem(hwndDlg, IDC_DLSIZE), TRUE);
Edit_Visible(GetDlgItem(hwndDlg, IDC_RELDATE), TRUE);
Edit_Visible(GetDlgItem(hwndDlg, IDC_DLSIZE), TRUE);
Button_Enable(GetDlgItem(hwndDlg, IDC_DOWNLOAD), TRUE);
}
Button_Enable(GetDlgItem(hwndDlg, IDC_DOWNLOAD), TRUE);
{
PPH_STRING sText = PhFormatString(L"\\%s", LocalFileNameString->Buffer);
LocalFilePathString = PhGetKnownLocation(CSIDL_DESKTOP, sText->Buffer);
PhDereferenceObject(sText);
// Create output file
if ((TempFileHandle = CreateFile(
LocalFilePathString->Buffer,
GENERIC_WRITE,
FILE_SHARE_WRITE,
0, // handle cannot be inherited
CREATE_ALWAYS, // if file exists, delete it
FILE_ATTRIBUTE_NORMAL,
0)) == INVALID_HANDLE_VALUE)
{
LogEvent(hwndDlg, PhFormatString(L"CreateFile failed (%d)", GetLastError()));
}
}
PhUpdaterState = Downloading;
}
else if (result == 0)
{
PPH_STRING summaryText = PhFormatString(L"You're running the latest version: %u.%u", xmlData.MajorVersion, xmlData.MinorVersion);
@@ -190,37 +207,18 @@ static void __cdecl WorkerThreadStart(
else if (result < 0)
{
PPH_STRING summaryText = PhFormatString(L"You're running a newer version: %u.%u", localMajorVersion, localMinorVersion);
PPH_STRING stableText = PhFormatString(L"Latest stable version: %u.%u", xmlData.MajorVersion, xmlData.MinorVersion);
Edit_SetText(GetDlgItem(hwndDlg, IDC_MESSAGE), summaryText->Buffer);
PhDereferenceObject(summaryText);
Edit_Visible(GetDlgItem(hwndDlg, IDC_RELDATE), TRUE);
Edit_SetText(GetDlgItem(hwndDlg, IDC_MESSAGE), summaryText->Buffer);
Edit_SetText(GetDlgItem(hwndDlg, IDC_RELDATE), stableText->Buffer);
PhDereferenceObject(summaryText);
PhDereferenceObject(stableText);
}
FreeXmlData(&xmlData);
DisposeConnection();
{
PPH_STRING sText = PhFormatString(L"\\%s", LocalFileNameString->Buffer);
LocalFilePathString = PhGetKnownLocation(CSIDL_DESKTOP, sText->Buffer);
PhDereferenceObject(sText);
// Create output file
if ((TempFileHandle = CreateFile(
LocalFilePathString->Buffer,
GENERIC_WRITE,
FILE_SHARE_WRITE,
0, // handle cannot be inherited
CREATE_ALWAYS, // if file exists, delete it
FILE_ATTRIBUTE_NORMAL,
0)) == INVALID_HANDLE_VALUE)
{
LogEvent(hwndDlg, PhFormatString(L"CreateFile failed (%d)", GetLastError()));
}
}
PhUpdaterState = Downloading;
}
static void __cdecl DownloadWorkerThreadStart(
@@ -439,7 +437,6 @@ static void __cdecl DownloadWorkerThreadStart(
// Enable the Install button
Button_Enable(GetDlgItem(hwndDlg, IDC_DOWNLOAD), TRUE);
// If PH is not elevated show the UAC sheild since it'll be shown by the PH setup.
if (!PhElevated)
SendMessage(GetDlgItem(hwndDlg, IDC_DOWNLOAD), BCM_SETSHIELD, 0, TRUE);
@@ -895,9 +892,9 @@ VOID RunAction(
{
Edit_SetText(GetDlgItem(hwndDlg, IDC_STATUSTEXT), L"Initializing");
// Show the status text
Edit_Visible(GetDlgItem(hwndDlg, IDC_STATUSTEXT), TRUE);
Edit_Visible(GetDlgItem(hwndDlg, IDC_SPEEDTEXT), TRUE);
Edit_Visible(GetDlgItem(hwndDlg, IDC_RTIMETEXT), TRUE);
Edit_Enable(GetDlgItem(hwndDlg, IDC_STATUSTEXT), TRUE);
Edit_Enable(GetDlgItem(hwndDlg, IDC_SPEEDTEXT), TRUE);
Edit_Enable(GetDlgItem(hwndDlg, IDC_RTIMETEXT), TRUE);
// Star our Downloader thread
_beginthread(DownloadWorkerThreadStart, 0, hwndDlg);
+6
View File
@@ -12,6 +12,12 @@
#include <ShlObj.h>
#include <stdint.h>
#include <CommCtrl.h>
#include <process.h>
// Always consider the remote version newer
#ifdef _DEBUG
//#define TEST_MODE
#endif
#define BUFFER_LEN 512
#define UPDATE_MENUITEM 1