Skip to content

Commit 524af8f

Browse files
committed
v0.2
Removed Process Hacker source code fragments, plugin now requires PH 2.36 Fixed bug when process wouldn't launch because of "Allow only one instance" option
1 parent df098e2 commit 524af8f

13 files changed

Lines changed: 38 additions & 3387 deletions

Emergency.vcxproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8080
<GenerateManifest>false</GenerateManifest>
8181
</PropertyGroup>
82+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
83+
<GenerateManifest>false</GenerateManifest>
84+
</PropertyGroup>
8285
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8386
<ClCompile>
8487
<Optimization>Disabled</Optimization>
@@ -117,7 +120,7 @@
117120
<GenerateDebugInformation>true</GenerateDebugInformation>
118121
<SubSystem>Windows</SubSystem>
119122
<TargetMachine>MachineX64</TargetMachine>
120-
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
123+
<OutputFile>D:\VGDB\PH\processhacker-code\2.x\trunk\bin\Release64\plugins\MalHide.dll</OutputFile>
121124
</Link>
122125
</ItemDefinitionGroup>
123126
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -129,13 +132,13 @@
129132
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
130133
<FunctionLevelLinking>true</FunctionLevelLinking>
131134
<WarningLevel>Level3</WarningLevel>
132-
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
135+
<DebugInformationFormat>None</DebugInformationFormat>
133136
<CallingConvention>StdCall</CallingConvention>
134137
</ClCompile>
135138
<Link>
136139
<AdditionalDependencies>ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
137140
<AdditionalLibraryDirectories>..\..\lib\i386;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
138-
<GenerateDebugInformation>true</GenerateDebugInformation>
141+
<GenerateDebugInformation>false</GenerateDebugInformation>
139142
<SubSystem>Windows</SubSystem>
140143
<OptimizeReferences>true</OptimizeReferences>
141144
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -145,6 +148,8 @@
145148
</IgnoreAllDefaultLibraries>
146149
<AdditionalOptions>
147150
</AdditionalOptions>
151+
<DelayLoadDLLs>
152+
</DelayLoadDLLs>
148153
</Link>
149154
<ProjectReference>
150155
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
@@ -176,18 +181,9 @@
176181
</ItemDefinitionGroup>
177182
<ItemGroup>
178183
<ClCompile Include="main.c" />
179-
<ClCompile Include="phf\clapi.c" />
180-
<ClCompile Include="phf\runas.c" />
181-
<ClCompile Include="phf\svcapi.c" />
182-
<ClCompile Include="phf\svcapiport.c" />
183-
<ClCompile Include="phf\svcclient.c" />
184184
</ItemGroup>
185185
<ItemGroup>
186186
<ClInclude Include="main.h" />
187-
<ClInclude Include="phf\phsvc.h" />
188-
<ClInclude Include="phf\phsvcapi.h" />
189-
<ClInclude Include="phf\phsvccl.h" />
190-
<ClInclude Include="phf\runas.h" />
191187
<ClInclude Include="resource.h" />
192188
</ItemGroup>
193189
<ItemGroup>

Emergency.vcxproj.filters

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,11 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
44
<ClCompile Include="main.c" />
5-
<ClCompile Include="phf\clapi.c">
6-
<Filter>PH fragments</Filter>
7-
</ClCompile>
8-
<ClCompile Include="phf\svcapi.c">
9-
<Filter>PH fragments</Filter>
10-
</ClCompile>
11-
<ClCompile Include="phf\svcapiport.c">
12-
<Filter>PH fragments</Filter>
13-
</ClCompile>
14-
<ClCompile Include="phf\svcclient.c">
15-
<Filter>PH fragments</Filter>
16-
</ClCompile>
17-
<ClCompile Include="phf\runas.c">
18-
<Filter>PH fragments</Filter>
19-
</ClCompile>
205
</ItemGroup>
216
<ItemGroup>
227
<ClInclude Include="main.h" />
23-
<ClInclude Include="phf\phsvc.h">
24-
<Filter>PH fragments</Filter>
25-
</ClInclude>
26-
<ClInclude Include="phf\phsvcapi.h">
27-
<Filter>PH fragments</Filter>
28-
</ClInclude>
29-
<ClInclude Include="phf\phsvccl.h">
30-
<Filter>PH fragments</Filter>
31-
</ClInclude>
32-
<ClInclude Include="phf\runas.h">
33-
<Filter>PH fragments</Filter>
34-
</ClInclude>
358
<ClInclude Include="resource.h" />
369
</ItemGroup>
37-
<ItemGroup>
38-
<Filter Include="PH fragments">
39-
<UniqueIdentifier>{121fa5fa-6d66-4cdb-97b9-11c30967a4dd}</UniqueIdentifier>
40-
</Filter>
41-
</ItemGroup>
4210
<ItemGroup>
4311
<ResourceCompile Include="Emergency.rc" />
4412
</ItemGroup>

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
# ph-emergency
22
Plugin for Process Hacker 2. Brings up PH in emergency situations
3+
4+
[Forum thread](http://wj32.org/processhacker/forums/viewtopic.php?f=18&p=6187)
5+
6+
# Requirements:
7+
- > Windows XP
8+
- Process Hacker 2.36
9+
- Elevated Process Hacker running in background

main.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "main.h"
22
#include <phdk.h>
3-
#include "phf\runas.h"
43
#include "resource.h"
54

65
LOGICAL DllMain(
@@ -23,8 +22,17 @@ LOGICAL DllMain(
2322
info->DisplayName = L"Emergency";
2423
info->Author = L"TETYYS";
2524
info->Description = L"Brings up ProcessHacker in emergency situations";
25+
info->Url = L"http://wj32.org/processhacker/forums/viewtopic.php?f=18&t=1954";
2626
info->HasOptions = TRUE;
2727

28+
ULONG major, minor;
29+
PhGetPhVersionNumbers(&major, &minor, NULL, NULL);
30+
if (major < 2 || minor < 36) {
31+
PhShowMessage(NULL, MB_ICONERROR, L"%s%d%d%d%s", L"Your Process Hacker version is not supported by Emergency plugin, please update Process Hacker or plugin will stay disabled. (Requires revision 2.36)");
32+
info->HasOptions = FALSE;
33+
return FALSE;
34+
}
35+
2836
Switching = FALSE;
2937

3038
{
@@ -198,7 +206,9 @@ INT_PTR CALLBACK OptionsDlgProc(
198206
break;
199207
case IDOK:
200208
{
201-
PhSetStringSetting(DESKTOP_SETTING, PHA_GET_DLGITEM_TEXT(hwndDlg, IDC_DESKTOP)->Buffer);
209+
PPH_STRING setting = PhGetWindowText(GetDlgItem(hwndDlg, IDC_DESKTOP)); {
210+
PhSetStringSetting(DESKTOP_SETTING, setting->Buffer);
211+
} PhDereferenceObject(setting);
202212
EndDialog(hwndDlg, IDOK);
203213
}
204214
break;
@@ -249,7 +259,7 @@ LRESULT CALLBACK LowLevelKeyboardProc(
249259
_In_ LPARAM lParam
250260
)
251261
{
252-
ULONG identifier = wParam;
262+
WPARAM identifier = wParam;
253263
KBDLLHOOKSTRUCT *kbd = (KBDLLHOOKSTRUCT*)lParam;
254264
BOOL enabled;
255265

@@ -280,19 +290,17 @@ LRESULT CALLBACK LowLevelKeyboardProc(
280290
Switching = TRUE;
281291
// GO GO GO!
282292

283-
WCHAR fullPath[MAX_PATH];
284-
GetModuleFileName(NULL, fullPath, MAX_PATH);
285-
286293
ULONG sessId;
287294
PhGetProcessSessionId(GetCurrentProcess(), &sessId);
288-
289-
/*EmergencyDesktopFull = ;
290-
ULONG_PTR index = PhFindCharInString(EmergencyDesktopFull, 0, L'\\') + 1;
291-
EmergencyDesktop = PhSubstring(EmergencyDesktopFull, index, EmergencyDesktopFull->Length - index);*/
295+
292296
PPH_STRING desktopFull = PhGetStringSetting(DESKTOP_SETTING);
293297
ULONG_PTR index = PhFindCharInString(desktopFull, 0, L'\\') + 1;
294298
PPH_STRING desktop = PhSubstring(desktopFull, index, desktopFull->Length - index);
295-
PPH_STRING cmd = PhFormatString(L"--EmergencySwitch %s", desktop->Buffer);
299+
300+
PPH_STRING cmd;
301+
PPH_STRING app = PhGetApplicationFileName(); {
302+
cmd = PhFormatString(L"\"%s\" -newinstance --EmergencySwitch %s", app->Buffer, desktop->Buffer);
303+
} PhDereferenceObject(app);
296304

297305
if (!DesktopExists(desktop)) {
298306
if (CreateDesktop(desktop->Buffer, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL) == NULL) {
@@ -303,12 +311,12 @@ LRESULT CALLBACK LowLevelKeyboardProc(
303311
PhDereferenceObject(cmd);
304312
goto nextHook;
305313
}
314+
// do NOT close the desktop!
306315
}
307-
308-
PhExecuteRunAsCommand2(NULL, fullPath, cmd->Buffer, L"NT AUTHORITY\\SYSTEM", PhGetStringOrEmpty(NULL), LOGON32_LOGON_SERVICE, NULL, sessId, desktopFull->Buffer, FALSE);
309-
// do NOT close the desktop!
310-
311316
PhDereferenceObject(desktop);
317+
318+
PhExecuteRunAsCommand2(NULL, cmd->Buffer, L"NT AUTHORITY\\SYSTEM", PhGetStringOrEmpty(NULL), LOGON32_LOGON_SERVICE, NULL, sessId, desktopFull->Buffer, FALSE);
319+
312320
PhDereferenceObject(desktopFull);
313321
PhDereferenceObject(cmd);
314322
Sleep(2000);

0 commit comments

Comments
 (0)