-
Notifications
You must be signed in to change notification settings - Fork 5
/
WindowsMemPageDelta.cpp
76 lines (56 loc) · 1.49 KB
/
WindowsMemPageDelta.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
A Microsoft Windows memory page delta tool
Released as open source by NCC Group Plc - http://www.nccgroup.com/
Developed by Ollie Whitehouse, ollie dot whitehouse at nccgroup dot com
https://github.com/nccgroup/WindowsMemPageDelta
Released under AGPL see LICENSE for more information
*/
// Includes
#include "stdafx.h"
bool bService = false;
bool bConsole = false;
// Globals
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
///
int _tmain(int argc, _TCHAR* argv[])
{
RegisterEvent();
if (lstrcmpi(argv[1], TEXT("-i")) == 0)
{
fwprintf(stdout,L"Installing service\n");
SvcInstall();
return 0;
}
else if (lstrcmpi(argv[1], TEXT("-c")) == 0)
{
bConsole = true;
fwprintf(stdout, L"Running ... \n");
// Loop
while (true) {
EnumerateProcesses();
if (bFirstRun == true) bFirstRun = false;
Sleep(30000);
}
}
else if (lstrcmpi(argv[1], TEXT("-s")) == 0)
{
bService = true;
WriteEvent((LPWSTR)TEXT("Service Starting.."));
// TO_DO: Add any additional services for the process to this table.
SERVICE_TABLE_ENTRY DispatchTable[] =
{
{ (LPWSTR)SVCNAME, (LPSERVICE_MAIN_FUNCTION)SvcMain },
{ NULL, NULL }
};
// This call returns when the service has stopped.
// The process should simply terminate when the call returns.
if (!StartServiceCtrlDispatcher(DispatchTable))
{
fwprintf(stdout, L"Error doing dispatch\n");
}
WriteEvent((LPWSTR)TEXT("Shutting down"));
fwprintf(stdout, L"Finished service\n");
}
UnRegisterEvent();
return 0;
}