OnlineChecks: Added debug define

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5327 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
dmex
2013-06-23 12:13:04 +00:00
parent 8f8c4467bd
commit 0f8583dc6c
3 changed files with 25 additions and 26 deletions
+12 -8
View File
@@ -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");
+11 -18
View File
@@ -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);
+2
View File
@@ -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(