From 0f8583dc6c95d792a0b2f26fc0ffda3673424279 Mon Sep 17 00:00:00 2001 From: dmex Date: Sun, 23 Jun 2013 12:13:04 +0000 Subject: [PATCH] OnlineChecks: Added debug define git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5327 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/plugins/OnlineChecks/upload.c | 20 ++++++++++------- 2.x/trunk/plugins/Updater/updater.c | 29 ++++++++++--------------- 2.x/trunk/plugins/Updater/updater.h | 2 ++ 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/2.x/trunk/plugins/OnlineChecks/upload.c b/2.x/trunk/plugins/OnlineChecks/upload.c index ee8fca451..fa6a632ad 100644 --- a/2.x/trunk/plugins/OnlineChecks/upload.c +++ b/2.x/trunk/plugins/OnlineChecks/upload.c @@ -23,6 +23,9 @@ #include "onlnchk.h" +// Disable all hash-checking and always upload the file for analysis. +//#define DEBUG_UPLOAD + static SERVICE_INFO UploadServiceInfo[] = { { UPLOAD_SERVICE_VIRUSTOTAL, L"www.virustotal.com", INTERNET_DEFAULT_HTTPS_PORT, WINHTTP_FLAG_SECURE, L"???", L"file" }, @@ -520,6 +523,7 @@ static NTSTATUS UploadWorkerThreadStart( __leave; } +#ifndef DEBUG_UPLOAD if (strstr(subRequestBuffer, "\"file_exists\": true")) { // No upload needed; show the results immediately. @@ -539,7 +543,7 @@ static NTSTATUS UploadWorkerThreadStart( __leave; } } - +#endif PhDereferenceObject(hashString); PhDereferenceObject(subObjectName); @@ -589,7 +593,7 @@ static NTSTATUS UploadWorkerThreadStart( PhDereferenceObject(hashString); PhDereferenceObject(subObjectName); - +#ifndef DEBUG_UPLOAD if (uploadId = strstr(subRequestBuffer, "\"id\":")) { uploadId += 6; @@ -612,7 +616,7 @@ static NTSTATUS UploadWorkerThreadStart( } } } - +#endif objectName = PhCreateString(serviceInfo->UploadObjectName); } break; @@ -839,7 +843,7 @@ static NTSTATUS UploadWorkerThreadStart( NULL ); - if (status == HTTP_STATUS_OK || status == HTTP_STATUS_REDIRECT) + if (status == HTTP_STATUS_OK || status == HTTP_STATUS_REDIRECT_METHOD || status == HTTP_STATUS_REDIRECT) { switch (context->Service) { @@ -859,8 +863,8 @@ static NTSTATUS UploadWorkerThreadStart( if (buffer)// && ((PWSTR)buffer)[0]) { // Display the retrieved URL... - //context->LaunchCommand = PhFormatString(L"%s", (PWSTR)buffer); - //PhFree(buffer); + context->LaunchCommand = PhFormatString(L"%s", (PWSTR)buffer); + PhFree(buffer); if (context->DialogHandle && context->LaunchCommand) { @@ -1089,8 +1093,8 @@ INT_PTR CALLBACK UploadDlgProc( if (!PhIsNullOrEmptyString(context->ErrorMessage)) { - PhDereferenceObject(context->LaunchCommand); - context->LaunchCommand = NULL; + PhDereferenceObject(context->ErrorMessage); + context->ErrorMessage = NULL; } RemoveProp(hwndDlg, L"Context"); diff --git a/2.x/trunk/plugins/Updater/updater.c b/2.x/trunk/plugins/Updater/updater.c index c155c05ab..df786ea60 100644 --- a/2.x/trunk/plugins/Updater/updater.c +++ b/2.x/trunk/plugins/Updater/updater.c @@ -185,7 +185,7 @@ static BOOL ReadRequestString( dataLength = 0; // Zero the buffer - RtlZeroMemory(buffer, PAGE_SIZE); + memset(buffer, 0, PAGE_SIZE); while (WinHttpReadData(Handle, buffer, PAGE_SIZE, &returnLength)) { @@ -199,9 +199,9 @@ static BOOL ReadRequestString( } // Copy the returned buffer into our pointer - RtlCopyMemory(data + dataLength, buffer, returnLength); + memcpy(data + dataLength, buffer, returnLength); // Zero the returned buffer for the next loop - //RtlZeroMemory(buffer, PAGE_SIZE); + //memset(buffer, 0, returnLength); dataLength += returnLength; } @@ -774,8 +774,8 @@ static NTSTATUS UpdateDownloadThread( ); // Update the progress bar position - PostMessage(GetDlgItem(UpdateDialogHandle, IDC_PROGRESS), PBM_SETPOS, percent, 0); - SetWindowText(GetDlgItem(UpdateDialogHandle, IDC_STATUS), dlLengthString->Buffer); + SendMessage(context->ProgressHandle, PBM_SETPOS, percent, 0); + SetWindowText(context->StatusHandle, dlLengthString->Buffer); PhDereferenceObject(dlLengthString); PhDereferenceObject(totalDownloaded); @@ -864,13 +864,15 @@ static INT_PTR CALLBACK UpdaterWndProc( case WM_INITDIALOG: { LOGFONT headerFont; - HWND parentWindow = GetParent(hwndDlg); memset(&headerFont, 0, sizeof(LOGFONT)); headerFont.lfHeight = -15; headerFont.lfWeight = FW_MEDIUM; headerFont.lfQuality = CLEARTYPE_QUALITY | ANTIALIASED_QUALITY; + + context->StatusHandle = GetDlgItem(hwndDlg, IDC_STATUS); + context->ProgressHandle = GetDlgItem(hwndDlg, IDC_PROGRESS); // Create the font handle context->FontHandle = CreateFontIndirect(&headerFont); @@ -884,7 +886,7 @@ static INT_PTR CALLBACK UpdaterWndProc( GetSystemMetrics(SM_CYICON), LR_SHARED ); - + context->SourceforgeBitmap = LoadImageFromResources( MAKEINTRESOURCE(IDB_SF_PNG), L"PNG" @@ -892,21 +894,12 @@ static INT_PTR CALLBACK UpdaterWndProc( // Set the window icons if (context->IconHandle) - SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)context->IconHandle); - + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)context->IconHandle); // Set the text font if (context->FontHandle) SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), WM_SETFONT, (WPARAM)context->FontHandle, FALSE); - if (context->SourceforgeBitmap) - { - SendMessage( - GetDlgItem(hwndDlg, IDC_UPDATEICON), - STM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)context->SourceforgeBitmap - ); - } + SendMessage(GetDlgItem(hwndDlg, IDC_UPDATEICON), STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)context->SourceforgeBitmap); // Center the update window on PH if it's visible else we center on the desktop. PhCenterWindow(hwndDlg, (IsWindowVisible(parentWindow) && !IsIconic(parentWindow)) ? parentWindow : NULL); diff --git a/2.x/trunk/plugins/Updater/updater.h b/2.x/trunk/plugins/Updater/updater.h index 649f2340f..bdcc8bbfa 100644 --- a/2.x/trunk/plugins/Updater/updater.h +++ b/2.x/trunk/plugins/Updater/updater.h @@ -60,6 +60,8 @@ typedef struct _PH_UPDATER_CONTEXT HBITMAP SourceforgeBitmap; HICON IconHandle; HFONT FontHandle; + HWND StatusHandle; + HWND ProgressHandle; } PH_UPDATER_CONTEXT, *PPH_UPDATER_CONTEXT; VOID ShowUpdateDialog(