go my file uploader

This commit is contained in:
AirDog46
2025-05-13 19:45:22 +03:00
commit c5fab8aa94
708 changed files with 343216 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
1.6
* Added "Collapse by Default" option for processes
1.5
* Added individual process highlighting support
1.4
* Added tray icon mini info window support
1.3
* Added ability to save I/O priority
1.2
* Fixed bug where process priorities were not actually saved
1.1
* Added ability to save process priority
* Added "Only for processes with the same command line" option for process comments
1.0
* Initial release

View File

@@ -0,0 +1,182 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (Australia) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_OPTIONS DIALOGEX 0, 0, 316, 71
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Options"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Database location:",IDC_STATIC,7,9,61,8
EDITTEXT IDC_DATABASE,72,8,183,12,ES_AUTOHSCROLL
PUSHBUTTON "Browse...",IDC_BROWSE,259,7,50,14
LTEXT "If a relative path is specified, it is relative to Process Hacker's directory. Environment variables can be used. Changes will take place after Process Hacker is restarted.",IDC_STATIC,7,26,302,19
DEFPUSHBUTTON "OK",IDOK,205,50,50,14
PUSHBUTTON "Cancel",IDCANCEL,259,50,50,14
END
IDD_PROCCOMMENT DIALOGEX 0, 0, 260, 260
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Comment"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_COMMENT,7,7,246,229,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
PUSHBUTTON "Revert",IDC_REVERT,7,239,50,14,WS_DISABLED
CONTROL "Only for processes with the same command line",IDC_MATCHCOMMANDLINE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,86,241,167,10
END
IDD_SRVCOMMENT DIALOGEX 0, 0, 252, 179
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Comment"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_COMMENT,7,7,238,165,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_OPTIONS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 309
TOPMARGIN, 7
BOTTOMMARGIN, 64
END
IDD_PROCCOMMENT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 253
TOPMARGIN, 7
BOTTOMMARGIN, 253
END
IDD_SRVCOMMENT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 245
TOPMARGIN, 7
BOTTOMMARGIN, 172
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,6,0,0
PRODUCTVERSION 1,6,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "0c0904b0"
BEGIN
VALUE "CompanyName", "wj32"
VALUE "FileDescription", "User Notes plugin for Process Hacker"
VALUE "FileVersion", "1.6"
VALUE "InternalName", "UserNotes"
VALUE "LegalCopyright", "Licensed under the GNU GPL, v3."
VALUE "OriginalFilename", "UserNotes.dll"
VALUE "ProductName", "User Notes plugin for Process Hacker"
VALUE "ProductVersion", "1.6"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0xc09, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// AFX_DIALOG_LAYOUT
//
IDD_OPTIONS AFX_DIALOG_LAYOUT
BEGIN
0
END
#endif // English (Australia) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7C38D0AA-572C-4D75-8E4E-D68AF3C051AF}</ProjectGuid>
<RootNamespace>UserNotes</RootNamespace>
<Keyword>Win32Proj</Keyword>
<ProjectName>UserNotes</ProjectName>
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Plugins.props" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Debug32</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Release64</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Release32</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Debug64</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Link>
<AdditionalDependencies>uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<AdditionalDependencies>uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<AdditionalDependencies>uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<AdditionalDependencies>uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="db.c" />
<ClCompile Include="main.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="db.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="usernotes.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UserNotes.rc" />
</ItemGroup>
<ItemGroup>
<Text Include="CHANGELOG.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="db.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="db.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="usernotes.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UserNotes.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Text Include="CHANGELOG.txt" />
</ItemGroup>
</Project>

457
plugins/UserNotes/db.c Normal file
View File

@@ -0,0 +1,457 @@
/*
* Process Hacker User Notes -
* database functions
*
* Copyright (C) 2011-2015 wj32
* Copyright (C) 2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#include "usernotes.h"
BOOLEAN NTAPI ObjectDbEqualFunction(
_In_ PVOID Entry1,
_In_ PVOID Entry2
);
ULONG NTAPI ObjectDbHashFunction(
_In_ PVOID Entry
);
PPH_HASHTABLE ObjectDb;
PH_QUEUED_LOCK ObjectDbLock = PH_QUEUED_LOCK_INIT;
PPH_STRING ObjectDbPath;
VOID InitializeDb(
VOID
)
{
ObjectDb = PhCreateHashtable(
sizeof(PDB_OBJECT),
ObjectDbEqualFunction,
ObjectDbHashFunction,
64
);
}
BOOLEAN NTAPI ObjectDbEqualFunction(
_In_ PVOID Entry1,
_In_ PVOID Entry2
)
{
PDB_OBJECT object1 = *(PDB_OBJECT *)Entry1;
PDB_OBJECT object2 = *(PDB_OBJECT *)Entry2;
return object1->Tag == object2->Tag && PhEqualStringRef(&object1->Key, &object2->Key, TRUE);
}
ULONG NTAPI ObjectDbHashFunction(
_In_ PVOID Entry
)
{
PDB_OBJECT object = *(PDB_OBJECT *)Entry;
return object->Tag + PhHashStringRef(&object->Key, TRUE);
}
ULONG GetNumberOfDbObjects(
VOID
)
{
return ObjectDb->Count;
}
VOID LockDb(
VOID
)
{
PhAcquireQueuedLockExclusive(&ObjectDbLock);
}
VOID UnlockDb(
VOID
)
{
PhReleaseQueuedLockExclusive(&ObjectDbLock);
}
PDB_OBJECT FindDbObject(
_In_ ULONG Tag,
_In_ PPH_STRINGREF Name
)
{
DB_OBJECT lookupObject;
PDB_OBJECT lookupObjectPtr;
PDB_OBJECT *objectPtr;
lookupObject.Tag = Tag;
lookupObject.Key = *Name;
lookupObjectPtr = &lookupObject;
objectPtr = PhFindEntryHashtable(ObjectDb, &lookupObjectPtr);
if (objectPtr)
return *objectPtr;
else
return NULL;
}
PDB_OBJECT CreateDbObject(
_In_ ULONG Tag,
_In_ PPH_STRINGREF Name,
_In_opt_ PPH_STRING Comment
)
{
PDB_OBJECT object;
BOOLEAN added;
PDB_OBJECT *realObject;
object = PhAllocate(sizeof(DB_OBJECT));
memset(object, 0, sizeof(DB_OBJECT));
object->Tag = Tag;
object->Key = *Name;
object->BackColor = ULONG_MAX;
realObject = PhAddEntryHashtableEx(ObjectDb, &object, &added);
if (added)
{
object->Name = PhCreateStringEx(Name->Buffer, Name->Length);
object->Key = object->Name->sr;
if (Comment)
PhSetReference(&object->Comment, Comment);
else
object->Comment = PhReferenceEmptyString();
}
else
{
PhFree(object);
object = *realObject;
if (Comment)
PhSwapReference(&object->Comment, Comment);
}
return object;
}
VOID DeleteDbObject(
_In_ PDB_OBJECT Object
)
{
PhRemoveEntryHashtable(ObjectDb, &Object);
PhDereferenceObject(Object->Name);
PhDereferenceObject(Object->Comment);
PhFree(Object);
}
VOID SetDbPath(
_In_ PPH_STRING Path
)
{
PhSwapReference(&ObjectDbPath, Path);
}
mxml_type_t MxmlLoadCallback(
_In_ mxml_node_t *node
)
{
return MXML_OPAQUE;
}
PPH_STRING GetOpaqueXmlNodeText(
_In_ mxml_node_t *node
)
{
if (node->child && node->child->type == MXML_OPAQUE && node->child->value.opaque)
{
return PhConvertUtf8ToUtf16(node->child->value.opaque);
}
else
{
return PhReferenceEmptyString();
}
}
NTSTATUS LoadDb(
VOID
)
{
NTSTATUS status;
HANDLE fileHandle;
LARGE_INTEGER fileSize;
mxml_node_t *topNode;
mxml_node_t *currentNode;
status = PhCreateFileWin32(
&fileHandle,
ObjectDbPath->Buffer,
FILE_GENERIC_READ,
0,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
);
if (!NT_SUCCESS(status))
return status;
if (NT_SUCCESS(PhGetFileSize(fileHandle, &fileSize)) && fileSize.QuadPart == 0)
{
// A blank file is OK. There are no objects to load.
NtClose(fileHandle);
return status;
}
topNode = mxmlLoadFd(NULL, fileHandle, MxmlLoadCallback);
NtClose(fileHandle);
if (!topNode)
return STATUS_FILE_CORRUPT_ERROR;
if (topNode->type != MXML_ELEMENT)
{
mxmlDelete(topNode);
return STATUS_FILE_CORRUPT_ERROR;
}
LockDb();
for (currentNode = topNode->child; currentNode; currentNode = currentNode->next)
{
PDB_OBJECT object = NULL;
PPH_STRING tag = NULL;
PPH_STRING name = NULL;
PPH_STRING priorityClass = NULL;
PPH_STRING ioPriorityPlusOne = NULL;
PPH_STRING comment = NULL;
PPH_STRING backColor = NULL;
PPH_STRING collapse = NULL;
if (currentNode->type == MXML_ELEMENT &&
currentNode->value.element.num_attrs >= 2)
{
for (INT i = 0; i < currentNode->value.element.num_attrs; i++)
{
if (_stricmp(currentNode->value.element.attrs[i].name, "tag") == 0)
PhMoveReference(&tag, PhConvertUtf8ToUtf16(currentNode->value.element.attrs[i].value));
else if (_stricmp(currentNode->value.element.attrs[i].name, "name") == 0)
PhMoveReference(&name, PhConvertUtf8ToUtf16(currentNode->value.element.attrs[i].value));
else if (_stricmp(currentNode->value.element.attrs[i].name, "priorityclass") == 0)
PhMoveReference(&priorityClass, PhConvertUtf8ToUtf16(currentNode->value.element.attrs[i].value));
else if (_stricmp(currentNode->value.element.attrs[i].name, "iopriorityplusone") == 0)
PhMoveReference(&ioPriorityPlusOne, PhConvertUtf8ToUtf16(currentNode->value.element.attrs[i].value));
else if (_stricmp(currentNode->value.element.attrs[i].name, "backcolor") == 0)
PhMoveReference(&backColor, PhConvertUtf8ToUtf16(currentNode->value.element.attrs[i].value));
else if (_stricmp(currentNode->value.element.attrs[i].name, "collapse") == 0)
PhMoveReference(&collapse, PhConvertUtf8ToUtf16(currentNode->value.element.attrs[i].value));
}
}
comment = GetOpaqueXmlNodeText(currentNode);
if (tag && name && comment)
{
ULONG64 tagInteger;
ULONG64 priorityClassInteger = 0;
ULONG64 ioPriorityPlusOneInteger = 0;
PhStringToInteger64(&tag->sr, 10, &tagInteger);
if (priorityClass)
PhStringToInteger64(&priorityClass->sr, 10, &priorityClassInteger);
if (ioPriorityPlusOne)
PhStringToInteger64(&ioPriorityPlusOne->sr, 10, &ioPriorityPlusOneInteger);
object = CreateDbObject((ULONG)tagInteger, &name->sr, comment);
object->PriorityClass = (ULONG)priorityClassInteger;
object->IoPriorityPlusOne = (ULONG)ioPriorityPlusOneInteger;
}
// NOTE: These items are handled separately to maintain compatibility with previous versions of the database.
if (object && backColor)
{
ULONG64 backColorInteger = ULONG_MAX;
PhStringToInteger64(&backColor->sr, 10, &backColorInteger);
object->BackColor = (COLORREF)backColorInteger;
}
if (object && collapse)
{
ULONG64 collapseInteger = 0;
PhStringToInteger64(&collapse->sr, 10, &collapseInteger);
object->Collapse = !!collapseInteger;
}
PhClearReference(&tag);
PhClearReference(&name);
PhClearReference(&priorityClass);
PhClearReference(&ioPriorityPlusOne);
PhClearReference(&comment);
PhClearReference(&backColor);
PhClearReference(&collapse);
}
UnlockDb();
mxmlDelete(topNode);
return STATUS_SUCCESS;
}
char *MxmlSaveCallback(
_In_ mxml_node_t *node,
_In_ int position
)
{
if (PhEqualBytesZ(node->value.element.name, "object", TRUE))
{
if (position == MXML_WS_BEFORE_OPEN)
return " ";
else if (position == MXML_WS_AFTER_CLOSE)
return "\r\n";
}
else if (PhEqualBytesZ(node->value.element.name, "objects", TRUE))
{
if (position == MXML_WS_AFTER_OPEN)
return "\r\n";
}
return NULL;
}
PPH_BYTES StringRefToUtf8(
_In_ PPH_STRINGREF String
)
{
return PH_AUTO(PhConvertUtf16ToUtf8Ex(String->Buffer, String->Length));
}
mxml_node_t *CreateObjectElement(
_Inout_ mxml_node_t *ParentNode,
_In_ PPH_STRINGREF Tag,
_In_ PPH_STRINGREF Name,
_In_ PPH_STRINGREF PriorityClass,
_In_ PPH_STRINGREF IoPriorityPlusOne,
_In_ PPH_STRINGREF Comment,
_In_ PPH_STRINGREF BackColor,
_In_ PPH_STRINGREF Collapse
)
{
mxml_node_t *objectNode;
mxml_node_t *textNode;
// Create the setting element.
objectNode = mxmlNewElement(ParentNode, "object");
// Set the attributes.
mxmlElementSetAttr(objectNode, "tag", StringRefToUtf8(Tag)->Buffer);
mxmlElementSetAttr(objectNode, "name", StringRefToUtf8(Name)->Buffer);
mxmlElementSetAttr(objectNode, "priorityclass", StringRefToUtf8(PriorityClass)->Buffer);
mxmlElementSetAttr(objectNode, "iopriorityplusone", StringRefToUtf8(IoPriorityPlusOne)->Buffer);
mxmlElementSetAttr(objectNode, "backcolor", StringRefToUtf8(BackColor)->Buffer);
mxmlElementSetAttr(objectNode, "collapse", StringRefToUtf8(Collapse)->Buffer);
// Set the value.
textNode = mxmlNewOpaque(objectNode, StringRefToUtf8(Comment)->Buffer);
return objectNode;
}
PPH_STRING UInt64ToBase10String(
_In_ ULONG64 Integer
)
{
return PH_AUTO(PhIntegerToString64(Integer, 10, FALSE));
}
NTSTATUS SaveDb(
VOID
)
{
PH_AUTO_POOL autoPool;
NTSTATUS status;
HANDLE fileHandle;
mxml_node_t *topNode;
ULONG enumerationKey = 0;
PDB_OBJECT *object;
PhInitializeAutoPool(&autoPool);
topNode = mxmlNewElement(MXML_NO_PARENT, "objects");
LockDb();
while (PhEnumHashtable(ObjectDb, (PVOID*)&object, &enumerationKey))
{
CreateObjectElement(
topNode,
&UInt64ToBase10String((*object)->Tag)->sr,
&(*object)->Name->sr,
&UInt64ToBase10String((*object)->PriorityClass)->sr,
&UInt64ToBase10String((*object)->IoPriorityPlusOne)->sr,
&(*object)->Comment->sr,
&UInt64ToBase10String((*object)->BackColor)->sr,
&UInt64ToBase10String((*object)->Collapse)->sr
);
PhDrainAutoPool(&autoPool);
}
UnlockDb();
// Create the directory if it does not exist.
{
PPH_STRING fullPath;
ULONG indexOfFileName;
if (fullPath = PH_AUTO(PhGetFullPath(ObjectDbPath->Buffer, &indexOfFileName)))
{
if (indexOfFileName != -1)
SHCreateDirectoryEx(NULL, PhaSubstring(fullPath, 0, indexOfFileName)->Buffer, NULL);
}
}
PhDeleteAutoPool(&autoPool);
status = PhCreateFileWin32(
&fileHandle,
ObjectDbPath->Buffer,
FILE_GENERIC_WRITE,
0,
FILE_SHARE_READ,
FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
);
if (!NT_SUCCESS(status))
{
mxmlDelete(topNode);
return status;
}
mxmlSaveFd(topNode, fileHandle, MxmlSaveCallback);
mxmlDelete(topNode);
NtClose(fileHandle);
return STATUS_SUCCESS;
}

91
plugins/UserNotes/db.h Normal file
View File

@@ -0,0 +1,91 @@
/*
* Process Hacker User Notes -
* database functions
*
* Copyright (C) 2011-2015 wj32
* Copyright (C) 2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DB_H
#define DB_H
#define PLUGIN_NAME L"ProcessHacker.UserNotes"
#define SETTING_NAME_DATABASE_PATH (PLUGIN_NAME L".DatabasePath")
#define SETTING_NAME_CUSTOM_COLOR_LIST (PLUGIN_NAME L".ColorCustomList")
#define FILE_TAG 1
#define SERVICE_TAG 2
#define COMMAND_LINE_TAG 3
typedef struct _DB_OBJECT
{
ULONG Tag;
PH_STRINGREF Key;
PPH_STRING Name;
PPH_STRING Comment;
ULONG PriorityClass;
ULONG IoPriorityPlusOne;
COLORREF BackColor;
BOOLEAN Collapse;
} DB_OBJECT, *PDB_OBJECT;
VOID InitializeDb(
VOID
);
ULONG GetNumberOfDbObjects(
VOID
);
VOID LockDb(
VOID
);
VOID UnlockDb(
VOID
);
PDB_OBJECT FindDbObject(
_In_ ULONG Tag,
_In_ PPH_STRINGREF Name
);
PDB_OBJECT CreateDbObject(
_In_ ULONG Tag,
_In_ PPH_STRINGREF Name,
_In_opt_ PPH_STRING Comment
);
VOID DeleteDbObject(
_In_ PDB_OBJECT Object
);
VOID SetDbPath(
_In_ PPH_STRING Path
);
NTSTATUS LoadDb(
VOID
);
NTSTATUS SaveDb(
VOID
);
#endif

1717
plugins/UserNotes/main.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by UserNotes.rc
//
#define IDD_OPTIONS 101
#define IDD_COMMENT 102
#define IDD_PROCCOMMENT 102
#define IDD_SRVCOMMENT 103
#define IDC_DATABASE 1001
#define IDC_BROWSE 1002
#define IDC_COMMENT 1003
#define IDC_REVERT 1004
#define IDC_CHECK1 1005
#define IDC_MATCHCOMMANDLINE 1005
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,113 @@
/*
* Process Hacker User Notes -
* UserNotes Header
*
* Copyright (C) 2011-2015 wj32
* Copyright (C) 2016 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _USERNOTES_H_
#define _USERNOTES_H_
#include <phdk.h>
#include <phappresource.h>
#include <mxml.h>
#include <windowsx.h>
#include <shlobj.h>
#include <uxtheme.h>
#include "db.h"
#include "resource.h"
#define INTENT_PROCESS_COMMENT 0x1
#define INTENT_PROCESS_PRIORITY_CLASS 0x2
#define INTENT_PROCESS_IO_PRIORITY 0x4
#define INTENT_PROCESS_HIGHLIGHT 0x8
#define INTENT_PROCESS_COLLAPSE 0x10
typedef enum _USERNOTES_COMMAND_ID
{
PROCESS_PRIORITY_SAVE_ID = 1,
PROCESS_PRIORITY_SAVE_FOR_THIS_COMMAND_LINE_ID,
PROCESS_IO_PRIORITY_SAVE_ID,
PROCESS_IO_PRIORITY_SAVE_FOR_THIS_COMMAND_LINE_ID,
PROCESS_HIGHLIGHT_ID,
PROCESS_COLLAPSE_ID,
} USERNOTES_COMMAND_ID;
#define COMMENT_COLUMN_ID 1
typedef struct _PROCESS_EXTENSION
{
LIST_ENTRY ListEntry;
PPH_PROCESS_ITEM ProcessItem;
BOOLEAN Valid;
PPH_STRING Comment;
} PROCESS_EXTENSION, *PPROCESS_EXTENSION;
typedef struct _PROCESS_COMMENT_PAGE_CONTEXT
{
HWND CommentHandle;
HWND RevertHandle;
HWND MatchCommandlineHandle;
PPH_STRING OriginalComment;
} PROCESS_COMMENT_PAGE_CONTEXT, *PPROCESS_COMMENT_PAGE_CONTEXT;
typedef struct _SERVICE_EXTENSION
{
LIST_ENTRY ListEntry;
BOOLEAN Valid;
PPH_STRING Comment;
} SERVICE_EXTENSION, *PSERVICE_EXTENSION;
typedef struct _SERVICE_COMMENT_PAGE_CONTEXT
{
PPH_SERVICE_ITEM ServiceItem;
PH_LAYOUT_MANAGER LayoutManager;
} SERVICE_COMMENT_PAGE_CONTEXT, *PSERVICE_COMMENT_PAGE_CONTEXT;
INT_PTR CALLBACK OptionsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
INT_PTR CALLBACK ProcessCommentPageDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
INT_PTR CALLBACK ServiceCommentPageDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
UINT_PTR CALLBACK ColorDlgHookProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
#endif