go my file uploader
This commit is contained in:
146
plugins/SbieSupport/SbieSupport.rc
Normal file
146
plugins/SbieSupport/SbieSupport.rc
Normal file
@@ -0,0 +1,146 @@
|
||||
// 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
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,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", "Sandboxie Support for Process Hacker"
|
||||
VALUE "FileVersion", "1.0"
|
||||
VALUE "InternalName", "SbieSupport"
|
||||
VALUE "LegalCopyright", "Licensed under the GNU GPL, v3."
|
||||
VALUE "OriginalFilename", "SbieSupport.dll"
|
||||
VALUE "ProductName", "Sandboxie Support for Process Hacker"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0xc09, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_OPTIONS DIALOGEX 0, 0, 268, 50
|
||||
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 "SbieDll.dll path:",IDC_STATIC,7,9,50,8
|
||||
EDITTEXT IDC_SBIEDLLPATH,63,8,143,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Browse...",IDC_BROWSE,211,7,50,14
|
||||
DEFPUSHBUTTON "OK",IDOK,158,29,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,211,29,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_OPTIONS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 261
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 43
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
77
plugins/SbieSupport/SbieSupport.vcxproj
Normal file
77
plugins/SbieSupport/SbieSupport.vcxproj
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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>{EEF1E81D-D286-422A-89E6-C6C8F3BE648A}</ProjectGuid>
|
||||
<RootNamespace>SbieSupport</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectName>SbieSupport</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|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>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="sbiedll.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="SbieSupport.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
35
plugins/SbieSupport/SbieSupport.vcxproj.filters
Normal file
35
plugins/SbieSupport/SbieSupport.vcxproj.filters
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sbiedll.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="SbieSupport.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
551
plugins/SbieSupport/main.c
Normal file
551
plugins/SbieSupport/main.c
Normal file
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
* Process Hacker Sandboxie Support -
|
||||
* main program
|
||||
*
|
||||
* Copyright (C) 2010-2011 wj32
|
||||
*
|
||||
* 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 <phdk.h>
|
||||
#include "resource.h"
|
||||
#include "sbiedll.h"
|
||||
|
||||
typedef struct _BOX_INFO
|
||||
{
|
||||
WCHAR BoxName[34];
|
||||
PH_STRINGREF IpcRoot;
|
||||
WCHAR IpcRootBuffer[256];
|
||||
} BOX_INFO, *PBOX_INFO;
|
||||
|
||||
typedef struct _BOXED_PROCESS
|
||||
{
|
||||
HANDLE ProcessId;
|
||||
WCHAR BoxName[34];
|
||||
} BOXED_PROCESS, *PBOXED_PROCESS;
|
||||
|
||||
VOID NTAPI LoadCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI ShowOptionsCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI MenuItemCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI MainMenuInitializingCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI ProcessesUpdatedCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI GetProcessHighlightingColorCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI GetProcessTooltipTextCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI GetIsDotNetDirectoryNamesCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
);
|
||||
|
||||
VOID NTAPI RefreshSandboxieInfo(
|
||||
_In_opt_ PVOID Context,
|
||||
_In_ BOOLEAN TimerOrWaitFired
|
||||
);
|
||||
|
||||
INT_PTR CALLBACK OptionsDlgProc(
|
||||
_In_ HWND hwndDlg,
|
||||
_In_ UINT uMsg,
|
||||
_In_ WPARAM wParam,
|
||||
_In_ LPARAM lParam
|
||||
);
|
||||
|
||||
PPH_PLUGIN PluginInstance;
|
||||
PH_CALLBACK_REGISTRATION PluginLoadCallbackRegistration;
|
||||
PH_CALLBACK_REGISTRATION PluginShowOptionsCallbackRegistration;
|
||||
PH_CALLBACK_REGISTRATION PluginMenuItemCallbackRegistration;
|
||||
PH_CALLBACK_REGISTRATION MainMenuInitializingCallbackRegistration;
|
||||
PH_CALLBACK_REGISTRATION ProcessesUpdatedCallbackRegistration;
|
||||
PH_CALLBACK_REGISTRATION GetProcessHighlightingColorCallbackRegistration;
|
||||
PH_CALLBACK_REGISTRATION GetProcessTooltipTextCallbackRegistration;
|
||||
|
||||
P_SbieApi_QueryBoxPath SbieApi_QueryBoxPath;
|
||||
P_SbieApi_EnumBoxes SbieApi_EnumBoxes;
|
||||
P_SbieApi_EnumProcessEx SbieApi_EnumProcessEx;
|
||||
P_SbieDll_KillAll SbieDll_KillAll;
|
||||
|
||||
PPH_HASHTABLE BoxedProcessesHashtable;
|
||||
PH_QUEUED_LOCK BoxedProcessesLock = PH_QUEUED_LOCK_INIT;
|
||||
BOOLEAN BoxedProcessesUpdated = FALSE;
|
||||
|
||||
BOX_INFO BoxInfo[16];
|
||||
ULONG BoxInfoCount;
|
||||
|
||||
LOGICAL DllMain(
|
||||
_In_ HINSTANCE Instance,
|
||||
_In_ ULONG Reason,
|
||||
_Reserved_ PVOID Reserved
|
||||
)
|
||||
{
|
||||
switch (Reason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{
|
||||
PPH_PLUGIN_INFORMATION info;
|
||||
|
||||
PluginInstance = PhRegisterPlugin(PLUGIN_NAME, Instance, &info);
|
||||
|
||||
if (!PluginInstance)
|
||||
return FALSE;
|
||||
|
||||
info->DisplayName = L"Sandboxie Support";
|
||||
info->Author = L"wj32";
|
||||
info->Description = L"Provides functionality for sandboxed processes.";
|
||||
info->Url = L"https://wj32.org/processhacker/forums/viewtopic.php?t=1115";
|
||||
info->HasOptions = TRUE;
|
||||
|
||||
PhRegisterCallback(
|
||||
PhGetPluginCallback(PluginInstance, PluginCallbackLoad),
|
||||
LoadCallback,
|
||||
NULL,
|
||||
&PluginLoadCallbackRegistration
|
||||
);
|
||||
PhRegisterCallback(
|
||||
PhGetPluginCallback(PluginInstance, PluginCallbackShowOptions),
|
||||
ShowOptionsCallback,
|
||||
NULL,
|
||||
&PluginShowOptionsCallbackRegistration
|
||||
);
|
||||
PhRegisterCallback(
|
||||
PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem),
|
||||
MenuItemCallback,
|
||||
NULL,
|
||||
&PluginMenuItemCallbackRegistration
|
||||
);
|
||||
|
||||
PhRegisterCallback(
|
||||
PhGetGeneralCallback(GeneralCallbackMainMenuInitializing),
|
||||
MainMenuInitializingCallback,
|
||||
NULL,
|
||||
&MainMenuInitializingCallbackRegistration
|
||||
);
|
||||
PhRegisterCallback(
|
||||
PhGetGeneralCallback(GeneralCallbackProcessesUpdated),
|
||||
ProcessesUpdatedCallback,
|
||||
NULL,
|
||||
&ProcessesUpdatedCallbackRegistration
|
||||
);
|
||||
PhRegisterCallback(
|
||||
PhGetGeneralCallback(GeneralCallbackGetProcessHighlightingColor),
|
||||
GetProcessHighlightingColorCallback,
|
||||
NULL,
|
||||
&GetProcessHighlightingColorCallbackRegistration
|
||||
);
|
||||
PhRegisterCallback(
|
||||
PhGetGeneralCallback(GeneralCallbackGetProcessTooltipText),
|
||||
GetProcessTooltipTextCallback,
|
||||
NULL,
|
||||
&GetProcessTooltipTextCallbackRegistration
|
||||
);
|
||||
|
||||
{
|
||||
static PH_SETTING_CREATE settings[] =
|
||||
{
|
||||
{ StringSettingType, SETTING_NAME_SBIE_DLL_PATH, L"C:\\Program Files\\Sandboxie\\SbieDll.dll" }
|
||||
};
|
||||
|
||||
PhAddSettings(settings, sizeof(settings) / sizeof(PH_SETTING_CREATE));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN NTAPI BoxedProcessesEqualFunction(
|
||||
_In_ PVOID Entry1,
|
||||
_In_ PVOID Entry2
|
||||
)
|
||||
{
|
||||
return ((PBOXED_PROCESS)Entry1)->ProcessId == ((PBOXED_PROCESS)Entry2)->ProcessId;
|
||||
}
|
||||
|
||||
ULONG NTAPI BoxedProcessesHashFunction(
|
||||
_In_ PVOID Entry
|
||||
)
|
||||
{
|
||||
return HandleToUlong(((PBOXED_PROCESS)Entry)->ProcessId) / 4;
|
||||
}
|
||||
|
||||
VOID NTAPI LoadCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PPH_STRING sbieDllPath;
|
||||
HMODULE module;
|
||||
HANDLE timerQueueHandle;
|
||||
HANDLE timerHandle;
|
||||
|
||||
BoxedProcessesHashtable = PhCreateHashtable(
|
||||
sizeof(BOXED_PROCESS),
|
||||
BoxedProcessesEqualFunction,
|
||||
BoxedProcessesHashFunction,
|
||||
32
|
||||
);
|
||||
|
||||
sbieDllPath = PhaGetStringSetting(SETTING_NAME_SBIE_DLL_PATH);
|
||||
module = LoadLibrary(sbieDllPath->Buffer);
|
||||
|
||||
SbieApi_QueryBoxPath = PhGetProcedureAddress(module, SbieApi_QueryBoxPath_Name, 0);
|
||||
SbieApi_EnumBoxes = PhGetProcedureAddress(module, SbieApi_EnumBoxes_Name, 0);
|
||||
SbieApi_EnumProcessEx = PhGetProcedureAddress(module, SbieApi_EnumProcessEx_Name, 0);
|
||||
SbieDll_KillAll = PhGetProcedureAddress(module, SbieDll_KillAll_Name, 0);
|
||||
|
||||
if (NT_SUCCESS(RtlCreateTimerQueue(&timerQueueHandle)))
|
||||
{
|
||||
RtlCreateTimer(timerQueueHandle, &timerHandle, RefreshSandboxieInfo, NULL, 0, 4000, 0);
|
||||
}
|
||||
}
|
||||
|
||||
VOID NTAPI ShowOptionsCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
DialogBox(
|
||||
PluginInstance->DllBase,
|
||||
MAKEINTRESOURCE(IDD_OPTIONS),
|
||||
(HWND)Parameter,
|
||||
OptionsDlgProc
|
||||
);
|
||||
}
|
||||
|
||||
VOID NTAPI MenuItemCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PPH_PLUGIN_MENU_ITEM menuItem = Parameter;
|
||||
|
||||
switch (menuItem->Id)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (PhShowConfirmMessage(
|
||||
PhMainWndHandle,
|
||||
L"terminate",
|
||||
L"all sandboxed processes",
|
||||
NULL,
|
||||
FALSE
|
||||
))
|
||||
{
|
||||
PBOXED_PROCESS boxedProcess;
|
||||
ULONG enumerationKey = 0;
|
||||
|
||||
// Make sure we have an update-to-date list.
|
||||
RefreshSandboxieInfo(NULL, FALSE);
|
||||
|
||||
PhAcquireQueuedLockShared(&BoxedProcessesLock);
|
||||
|
||||
while (PhEnumHashtable(BoxedProcessesHashtable, &boxedProcess, &enumerationKey))
|
||||
{
|
||||
HANDLE processHandle;
|
||||
|
||||
if (NT_SUCCESS(PhOpenProcess(&processHandle, PROCESS_TERMINATE, boxedProcess->ProcessId)))
|
||||
{
|
||||
PhTerminateProcess(processHandle, STATUS_SUCCESS);
|
||||
NtClose(processHandle);
|
||||
}
|
||||
}
|
||||
|
||||
PhReleaseQueuedLockShared(&BoxedProcessesLock);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
VOID NTAPI MainMenuInitializingCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter;
|
||||
|
||||
if (!SbieDll_KillAll)
|
||||
return;
|
||||
if (menuInfo->u.MainMenu.SubMenuIndex != PH_MENU_ITEM_LOCATION_TOOLS)
|
||||
return;
|
||||
|
||||
PhInsertEMenuItem(menuInfo->Menu, PhPluginCreateEMenuItem(PluginInstance, PH_EMENU_SEPARATOR, 0, NULL, NULL), -1);
|
||||
PhInsertEMenuItem(menuInfo->Menu, PhPluginCreateEMenuItem(PluginInstance, 0, 1, L"Terminate sandboxed processes", NULL), -1);
|
||||
}
|
||||
|
||||
VOID NTAPI ProcessesUpdatedCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PBOXED_PROCESS boxedProcess;
|
||||
ULONG enumerationKey = 0;
|
||||
|
||||
if (BoxedProcessesUpdated)
|
||||
{
|
||||
// Invalidate the nodes of boxed processes (so they use the correct highlighting color).
|
||||
|
||||
PhAcquireQueuedLockShared(&BoxedProcessesLock);
|
||||
|
||||
if (BoxedProcessesUpdated)
|
||||
{
|
||||
while (PhEnumHashtable(BoxedProcessesHashtable, &boxedProcess, &enumerationKey))
|
||||
{
|
||||
PPH_PROCESS_NODE processNode;
|
||||
|
||||
if (processNode = PhFindProcessNode(boxedProcess->ProcessId))
|
||||
PhUpdateProcessNode(processNode);
|
||||
}
|
||||
|
||||
BoxedProcessesUpdated = FALSE;
|
||||
}
|
||||
|
||||
PhReleaseQueuedLockShared(&BoxedProcessesLock);
|
||||
}
|
||||
}
|
||||
|
||||
VOID NTAPI GetProcessHighlightingColorCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PPH_PLUGIN_GET_HIGHLIGHTING_COLOR getHighlightingColor = Parameter;
|
||||
BOXED_PROCESS lookupBoxedProcess;
|
||||
PBOXED_PROCESS boxedProcess;
|
||||
|
||||
PhAcquireQueuedLockShared(&BoxedProcessesLock);
|
||||
|
||||
lookupBoxedProcess.ProcessId = ((PPH_PROCESS_ITEM)getHighlightingColor->Parameter)->ProcessId;
|
||||
|
||||
if (boxedProcess = PhFindEntryHashtable(BoxedProcessesHashtable, &lookupBoxedProcess))
|
||||
{
|
||||
getHighlightingColor->BackColor = RGB(0x33, 0x33, 0x00);
|
||||
getHighlightingColor->Cache = TRUE;
|
||||
getHighlightingColor->Handled = TRUE;
|
||||
}
|
||||
|
||||
PhReleaseQueuedLockShared(&BoxedProcessesLock);
|
||||
}
|
||||
|
||||
VOID NTAPI GetProcessTooltipTextCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PPH_PLUGIN_GET_TOOLTIP_TEXT getTooltipText = Parameter;
|
||||
BOXED_PROCESS lookupBoxedProcess;
|
||||
PBOXED_PROCESS boxedProcess;
|
||||
|
||||
PhAcquireQueuedLockShared(&BoxedProcessesLock);
|
||||
|
||||
lookupBoxedProcess.ProcessId = ((PPH_PROCESS_ITEM)getTooltipText->Parameter)->ProcessId;
|
||||
|
||||
if (boxedProcess = PhFindEntryHashtable(BoxedProcessesHashtable, &lookupBoxedProcess))
|
||||
{
|
||||
PhAppendFormatStringBuilder(getTooltipText->StringBuilder, L"Sandboxie:\n Box name: %s\n", boxedProcess->BoxName);
|
||||
}
|
||||
|
||||
PhReleaseQueuedLockShared(&BoxedProcessesLock);
|
||||
}
|
||||
|
||||
VOID NTAPI RefreshSandboxieInfo(
|
||||
_In_opt_ PVOID Context,
|
||||
_In_ BOOLEAN TimerOrWaitFired
|
||||
)
|
||||
{
|
||||
LONG index;
|
||||
WCHAR boxName[34];
|
||||
ULONG pids[512];
|
||||
PBOX_INFO boxInfo;
|
||||
|
||||
if (!SbieApi_QueryBoxPath || !SbieApi_EnumBoxes || !SbieApi_EnumProcessEx)
|
||||
return;
|
||||
|
||||
PhAcquireQueuedLockExclusive(&BoxedProcessesLock);
|
||||
|
||||
PhClearHashtable(BoxedProcessesHashtable);
|
||||
|
||||
BoxInfoCount = 0;
|
||||
|
||||
index = -1;
|
||||
|
||||
while ((index = SbieApi_EnumBoxes(index, boxName)) != -1)
|
||||
{
|
||||
if (SbieApi_EnumProcessEx(boxName, TRUE, 0, pids) == 0)
|
||||
{
|
||||
ULONG count;
|
||||
PULONG pid;
|
||||
|
||||
count = pids[0];
|
||||
pid = &pids[1];
|
||||
|
||||
while (count != 0)
|
||||
{
|
||||
BOXED_PROCESS boxedProcess;
|
||||
|
||||
boxedProcess.ProcessId = UlongToHandle(*pid);
|
||||
memcpy(boxedProcess.BoxName, boxName, sizeof(boxName));
|
||||
|
||||
PhAddEntryHashtable(BoxedProcessesHashtable, &boxedProcess);
|
||||
|
||||
count--;
|
||||
pid++;
|
||||
}
|
||||
}
|
||||
|
||||
if (BoxInfoCount < 16)
|
||||
{
|
||||
ULONG filePathLength = 0;
|
||||
ULONG keyPathLength = 0;
|
||||
ULONG ipcPathLength = 0;
|
||||
|
||||
boxInfo = &BoxInfo[BoxInfoCount++];
|
||||
memcpy(boxInfo->BoxName, boxName, sizeof(boxName));
|
||||
|
||||
SbieApi_QueryBoxPath(
|
||||
boxName,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&filePathLength,
|
||||
&keyPathLength,
|
||||
&ipcPathLength
|
||||
);
|
||||
|
||||
if (ipcPathLength < sizeof(boxInfo->IpcRootBuffer))
|
||||
{
|
||||
boxInfo->IpcRootBuffer[0] = 0;
|
||||
SbieApi_QueryBoxPath(
|
||||
boxName,
|
||||
NULL,
|
||||
NULL,
|
||||
boxInfo->IpcRootBuffer,
|
||||
NULL,
|
||||
NULL,
|
||||
&ipcPathLength
|
||||
);
|
||||
|
||||
if (boxInfo->IpcRootBuffer[0] != 0)
|
||||
{
|
||||
PhInitializeStringRef(&boxInfo->IpcRoot, boxInfo->IpcRootBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
BoxInfoCount--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BoxInfoCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BoxedProcessesUpdated = TRUE;
|
||||
|
||||
PhReleaseQueuedLockExclusive(&BoxedProcessesLock);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK OptionsDlgProc(
|
||||
_In_ HWND hwndDlg,
|
||||
_In_ UINT uMsg,
|
||||
_In_ WPARAM wParam,
|
||||
_In_ LPARAM lParam
|
||||
)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
PPH_STRING sbieDllPath;
|
||||
|
||||
sbieDllPath = PhaGetStringSetting(SETTING_NAME_SBIE_DLL_PATH);
|
||||
SetDlgItemText(hwndDlg, IDC_SBIEDLLPATH, sbieDllPath->Buffer);
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(hwndDlg, IDCANCEL);
|
||||
break;
|
||||
case IDOK:
|
||||
{
|
||||
PhSetStringSetting2(SETTING_NAME_SBIE_DLL_PATH,
|
||||
&PhaGetDlgItemText(hwndDlg, IDC_SBIEDLLPATH)->sr);
|
||||
|
||||
EndDialog(hwndDlg, IDOK);
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSE:
|
||||
{
|
||||
static PH_FILETYPE_FILTER filters[] =
|
||||
{
|
||||
{ L"SbieDll.dll", L"SbieDll.dll" },
|
||||
{ L"All files (*.*)", L"*.*" }
|
||||
};
|
||||
PVOID fileDialog;
|
||||
PPH_STRING fileName;
|
||||
|
||||
fileDialog = PhCreateOpenFileDialog();
|
||||
PhSetFileDialogFilter(fileDialog, filters, sizeof(filters) / sizeof(PH_FILETYPE_FILTER));
|
||||
|
||||
fileName = PH_AUTO(PhGetFileName(PhaGetDlgItemText(hwndDlg, IDC_SBIEDLLPATH)));
|
||||
PhSetFileDialogFileName(fileDialog, fileName->Buffer);
|
||||
|
||||
if (PhShowFileDialog(hwndDlg, fileDialog))
|
||||
{
|
||||
fileName = PH_AUTO(PhGetFileDialogFileName(fileDialog));
|
||||
SetDlgItemText(hwndDlg, IDC_SBIEDLLPATH, fileName->Buffer);
|
||||
}
|
||||
|
||||
PhFreeFileDialog(fileDialog);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
18
plugins/SbieSupport/resource.h
Normal file
18
plugins/SbieSupport/resource.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by SbieSupport.rc
|
||||
//
|
||||
#define IDD_OPTIONS 101
|
||||
#define IDC_SBIEDLLPATH 1001
|
||||
#define IDC_BROWSE 1002
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1003
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
42
plugins/SbieSupport/sbiedll.h
Normal file
42
plugins/SbieSupport/sbiedll.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef SBIEDLL_H
|
||||
#define SBIEDLL_H
|
||||
|
||||
#define PLUGIN_NAME L"ProcessHacker.SbieSupport"
|
||||
#define SETTING_NAME_SBIE_DLL_PATH (PLUGIN_NAME L".SbieDllPath")
|
||||
|
||||
typedef LONG (__stdcall *P_SbieApi_QueryBoxPath)(
|
||||
const WCHAR *box_name, // pointer to WCHAR [34]
|
||||
WCHAR *file_path,
|
||||
WCHAR *key_path,
|
||||
WCHAR *ipc_path,
|
||||
ULONG *file_path_len,
|
||||
ULONG *key_path_len,
|
||||
ULONG *ipc_path_len);
|
||||
|
||||
typedef LONG (__stdcall *P_SbieApi_EnumBoxes)(
|
||||
LONG index, // initialize to -1
|
||||
WCHAR *box_name); // pointer to WCHAR [34]
|
||||
|
||||
typedef LONG (__stdcall *P_SbieApi_EnumProcessEx)(
|
||||
const WCHAR *box_name, // pointer to WCHAR [34]
|
||||
BOOLEAN all_sessions,
|
||||
ULONG which_session,
|
||||
ULONG *boxed_pids); // pointer to ULONG [512]
|
||||
|
||||
typedef BOOLEAN (__stdcall *P_SbieDll_KillAll)(
|
||||
ULONG session_id,
|
||||
const WCHAR *box_name);
|
||||
|
||||
#ifdef _WIN64
|
||||
#define SbieApi_QueryBoxPath_Name "SbieApi_QueryBoxPath"
|
||||
#define SbieApi_EnumBoxes_Name "SbieApi_EnumBoxes"
|
||||
#define SbieApi_EnumProcessEx_Name "SbieApi_EnumProcessEx"
|
||||
#define SbieDll_KillAll_Name "SbieDll_KillAll"
|
||||
#else
|
||||
#define SbieApi_QueryBoxPath_Name "_SbieApi_QueryBoxPath@28"
|
||||
#define SbieApi_EnumBoxes_Name "_SbieApi_EnumBoxes@8"
|
||||
#define SbieApi_EnumProcessEx_Name "_SbieApi_EnumProcessEx@16"
|
||||
#define SbieDll_KillAll_Name "_SbieDll_KillAll@8"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user