Skip to content

Commit

Permalink
Merge pull request #9 from processhacker/master
Browse files Browse the repository at this point in the history
[pull] master from processhacker:master
  • Loading branch information
pull[bot] authored Sep 22, 2020
2 parents 0244b0a + 1862ce0 commit 45139a0
Show file tree
Hide file tree
Showing 22 changed files with 2,335 additions and 767 deletions.
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ plugins/OnlineChecks/virustotal.h
!tools/CustomBuildTool/bin/
tools/CustomBuildTool/bin/Debug*/
tools/CustomBuildTool/bin/Release*/*
!tools/CustomBuildTool/bin/Release/CustomBuildTool.exe
!tools/CustomBuildTool/bin/Release/clrcompression.dll
!tools/CustomBuildTool/bin/Release/clrjit.dll
!tools/CustomBuildTool/bin/Release/coreclr.dll
!tools/CustomBuildTool/bin/Release/mscordaccore.dll
!tools/CustomBuildTool/bin/Release/*.exe
!tools/CustomBuildTool/bin/Release/*.dll
!tools/CustomBuildTool/bin/Release/*.pdb

!tools/CustomSignTool/bin/
tools/CustomSignTool/bin/Debug*/
Expand Down
3 changes: 2 additions & 1 deletion phlib/include/wslsup.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
_In_ PPH_STRING FileName
);

ULONG PhCreateProcessLxss(
_Success_(return)
BOOLEAN PhCreateProcessLxss(
_In_ PWSTR LxssDistribution,
_In_ PWSTR LxssCommandLine,
_In_opt_ PWSTR LxssCurrentDirectory,
Expand Down
61 changes: 29 additions & 32 deletions phlib/wslsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
_In_ PPH_STRING FileName
)
{
ULONG status;
PPH_STRING lxssCommandLine = NULL;
PPH_STRING lxssPackageName = NULL;
PPH_STRING lxssDistroName;
Expand All @@ -165,32 +164,29 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
return FALSE;
}

if (PhIsNullOrEmptyString(lxssDistroName) || PhIsNullOrEmptyString(lxssDistroPath) || PhIsNullOrEmptyString(lxssFileName))
if (
PhIsNullOrEmptyString(lxssDistroName) ||
PhIsNullOrEmptyString(lxssDistroPath) ||
PhIsNullOrEmptyString(lxssFileName)
)
{
if (lxssDistroName) PhDereferenceObject(lxssDistroName);
if (lxssDistroPath) PhDereferenceObject(lxssDistroPath);
if (lxssFileName) PhDereferenceObject(lxssFileName);
return FALSE;
}

if (PhEqualString2(lxssFileName, L"/init", FALSE))
{
PhMoveReference(&lxssFileName, PhCreateString(L"init"));
}

PhMoveReference(&lxssCommandLine, PhFormatString(
L"rpm -qf %s --queryformat \"%%{VERSION}|%%{VENDOR}|%%{SUMMARY}\"",
lxssFileName->Buffer
));

status = PhCreateProcessLxss(
if (PhCreateProcessLxss(
lxssDistroName->Buffer,
lxssCommandLine->Buffer,
NULL,
&result
);

if (status == 0)
))
{
goto ParseResult;
}
Expand All @@ -200,14 +196,12 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
lxssFileName->Buffer
));

status = PhCreateProcessLxss(
if (!PhCreateProcessLxss(
lxssDistroName->Buffer,
lxssCommandLine->Buffer,
NULL,
&result
);

if (status != 0)
))
{
PhDereferenceObject(lxssCommandLine);
PhDereferenceObject(lxssDistroName);
Expand Down Expand Up @@ -242,14 +236,12 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
lxssPackageName->Buffer
));

status = PhCreateProcessLxss(
if (!PhCreateProcessLxss(
lxssDistroName->Buffer,
lxssCommandLine->Buffer,
NULL,
&result
);

if (status != 0)
))
{
PhDereferenceObject(lxssCommandLine);
PhDereferenceObject(lxssDistroName);
Expand Down Expand Up @@ -293,7 +285,8 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
return TRUE;
}

ULONG PhCreateProcessLxss(
_Success_(return)
BOOLEAN PhCreateProcessLxss(
_In_ PWSTR LxssDistribution,
_In_ PWSTR LxssCommandLine,
_In_opt_ PWSTR LxssCurrentDirectory,
Expand Down Expand Up @@ -335,7 +328,7 @@ ULONG PhCreateProcessLxss(
);

if (!NT_SUCCESS(status))
return status;
return FALSE;

status = PhCreatePipeEx(
&inputReadHandle,
Expand All @@ -348,7 +341,7 @@ ULONG PhCreateProcessLxss(
{
NtClose(outputWriteHandle);
NtClose(outputReadHandle);
return status;
return FALSE;
}

memset(&startupInfo, 0, sizeof(STARTUPINFO));
Expand Down Expand Up @@ -378,7 +371,7 @@ ULONG PhCreateProcessLxss(
NtClose(outputReadHandle);
NtClose(inputReadHandle);
NtClose(inputWriteHandle);
return status;
return FALSE;
}

// Note: Close the write handles or the child process
Expand All @@ -396,18 +389,22 @@ ULONG PhCreateProcessLxss(
}

// Note: Don't use NTSTATUS now that we have the lxss exit code. (dmex)
if (Result && status == 0)
if (status == 0)
{
*Result = lxssOutputString;
if (Result) *Result = lxssOutputString;
if (processHandle) NtClose(processHandle);
if (outputReadHandle) NtClose(outputReadHandle);
if (inputWriteHandle) NtClose(inputWriteHandle);

return TRUE;
}
else
{
PhSetReference(&lxssOutputString, NULL);
}
if (lxssOutputString) PhDereferenceObject(lxssOutputString);
if (processHandle) NtClose(processHandle);
if (outputReadHandle) NtClose(outputReadHandle);
if (inputWriteHandle) NtClose(inputWriteHandle);

NtClose(processHandle);
NtClose(outputReadHandle);
NtClose(inputWriteHandle);

return status;
return FALSE;
}
}
5 changes: 3 additions & 2 deletions plugins/ToolStatus/toolbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ TBBUTTON ToolbarButtons[MAX_TOOLBAR_ITEMS] =
{ I_IMAGECALLBACK, TIDC_FINDWINDOW, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, { 0 }, 0, 0 },
{ I_IMAGECALLBACK, TIDC_FINDWINDOWTHREAD, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, { 0 }, 0, 0 },
{ I_IMAGECALLBACK, TIDC_FINDWINDOWKILL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, { 0 }, 0, 0 },
{ 0, 0, 0, BTNS_SEP, { 0 }, 0, 0 },
{ I_IMAGECALLBACK, PHAPP_ID_HACKER_SHOWDETAILSFORALLPROCESSES, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, { 0 }, 0, 0 },
// Available toolbar buttons (hidden)
{ I_IMAGECALLBACK, PHAPP_ID_VIEW_ALWAYSONTOP, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, { 0 }, 0, 0 },
{ I_IMAGECALLBACK, TIDC_POWERMENUDROPDOWN, TBSTATE_ENABLED, BTNS_WHOLEDROPDOWN | BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT,{ 0 }, 0, 0 },
{ I_IMAGECALLBACK, PHAPP_ID_HACKER_SHOWDETAILSFORALLPROCESSES, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT,{ 0 }, 0, 0 },
{ I_IMAGECALLBACK, TIDC_POWERMENUDROPDOWN, TBSTATE_ENABLED, BTNS_WHOLEDROPDOWN | BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, { 0 }, 0, 0 },
};

VOID RebarBandInsert(
Expand Down
4 changes: 2 additions & 2 deletions plugins/ToolStatus/toolstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
#define SETTING_NAME_TOOLBARDISPLAYSTYLE (PLUGIN_NAME L".ToolbarDisplayStyle")
#define SETTING_NAME_SEARCHBOXDISPLAYMODE (PLUGIN_NAME L".SearchBoxDisplayMode")

#define MAX_DEFAULT_TOOLBAR_ITEMS 9
#define MAX_DEFAULT_TOOLBAR_ITEMS 11
#define MAX_DEFAULT_STATUSBAR_ITEMS 3
#define MAX_TOOLBAR_ITEMS 12
#define MAX_TOOLBAR_ITEMS 13
#define MAX_STATUSBAR_ITEMS 14

#define TIDC_FINDWINDOW (WM_APP + 1)
Expand Down
29 changes: 3 additions & 26 deletions plugins/Updater/updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ VOID UpdateContextDeleteProcedure(
PhDereferenceObject(context->Version);
if (context->RelDate)
PhDereferenceObject(context->RelDate);
if (context->CommitHash)
PhDereferenceObject(context->CommitHash);
if (context->SetupFileDownloadUrl)
PhDereferenceObject(context->SetupFileDownloadUrl);
if (context->SetupFileLength)
Expand All @@ -49,10 +51,6 @@ VOID UpdateContextDeleteProcedure(
PhDereferenceObject(context->SetupFileHash);
if (context->SetupFileSignature)
PhDereferenceObject(context->SetupFileSignature);
if (context->BuildMessage)
PhDereferenceObject(context->BuildMessage);
if (context->CommitHash)
PhDereferenceObject(context->CommitHash);
}

PPH_UPDATER_CONTEXT CreateUpdateContext(
Expand Down Expand Up @@ -414,12 +412,11 @@ BOOLEAN QueryUpdateData(

Context->Version = PhGetJsonValueAsString(jsonObject, "version");
Context->RelDate = PhGetJsonValueAsString(jsonObject, "updated");
Context->CommitHash = PhGetJsonValueAsString(jsonObject, "commit");
Context->SetupFileDownloadUrl = PhGetJsonValueAsString(jsonObject, "setup_url");
Context->SetupFileLength = PhFormatSize(PhGetJsonValueAsLong64(jsonObject, "setup_length"), 2);
Context->SetupFileHash = PhGetJsonValueAsString(jsonObject, "setup_hash");
Context->SetupFileSignature = PhGetJsonValueAsString(jsonObject, "setup_sig");
Context->BuildMessage = PhGetJsonValueAsString(jsonObject, "changelog");
Context->CommitHash = PhGetJsonValueAsString(jsonObject, "commit");

Context->CurrentVersion = ParseVersionString(Context->CurrentVersionString);
#ifdef FORCE_LATEST_VERSION
Expand All @@ -442,8 +439,6 @@ BOOLEAN QueryUpdateData(
goto CleanupExit;
if (PhIsNullOrEmptyString(Context->SetupFileSignature))
goto CleanupExit;
if (PhIsNullOrEmptyString(Context->BuildMessage))
goto CleanupExit;
if (PhIsNullOrEmptyString(Context->CommitHash))
goto CleanupExit;

Expand All @@ -453,27 +448,9 @@ BOOLEAN QueryUpdateData(

if (httpContext)
PhHttpSocketDestroy(httpContext);

if (jsonString)
PhDereferenceObject(jsonString);

if (success && !PhIsNullOrEmptyString(Context->BuildMessage))
{
PH_STRING_BUILDER sb;

PhInitializeStringBuilder(&sb, 0x100);

for (SIZE_T i = 0; i < Context->BuildMessage->Length / sizeof(WCHAR); i++)
{
if (Context->BuildMessage->Data[i] == L'\n')
PhAppendStringBuilder2(&sb, L"\r\n");
else
PhAppendCharStringBuilder(&sb, Context->BuildMessage->Data[i]);
}

PhMoveReference(&Context->BuildMessage, PhFinalStringBuilderString(&sb));
}

return success;
}

Expand Down
3 changes: 0 additions & 3 deletions plugins/Updater/updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ typedef struct _PH_UPDATER_CONTEXT
PPH_STRING CurrentVersionString;
PPH_STRING Version;
PPH_STRING RelDate;

PPH_STRING SetupFileLength;
PPH_STRING SetupFileDownloadUrl;
PPH_STRING SetupFileHash;
PPH_STRING SetupFileSignature;

// Nightly builds only
PPH_STRING BuildMessage;
PPH_STRING CommitHash;
} PH_UPDATER_CONTEXT, *PPH_UPDATER_CONTEXT;

Expand Down
Loading

0 comments on commit 45139a0

Please sign in to comment.