forked from vic4key/Vutils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample.Service.h
More file actions
83 lines (61 loc) · 2.31 KB
/
Sample.Service.h
File metadata and controls
83 lines (61 loc) · 2.31 KB
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
76
77
78
79
80
81
82
83
#pragma once
#include "Vutils.h"
#include <conio.h>
#include <vu>
#include <algorithm>
using namespace vu;
DEF_SAMPLE(ServiceManager)
{
if (!vu::IsAdministrator())
{
std::tcout << _T("You are not Administrator") << std::endl;
}
else
{
std::tstring driver_name = _T("WKE Driver");
std::tstring driver_display_name = _T("Windows Kernel Explorer Driver");
std::tstring driver_path = vu::GetCurDirectory();
#ifdef _WIN64
driver_path += _T("WKE64.sys");
#else // _WIN32
driver_path += _T("WKE32.sys");
#endif // _WIN64
// Create / Start / Stop / Delete
std::tcout << _T("Press any key to create service ...") << std::endl; _getch();
CServiceManager::Instance().Create(driver_path, driver_name, driver_display_name);
std::tcout << _T("Press any key to start service ...") << std::endl; _getch();
CServiceManager::Instance().Start(driver_name);
std::tcout << _T("Press any key to stop service ...") << std::endl; _getch();
vu::CServiceManager::Instance().Stop(driver_name);
std::tcout << _T("Press any key to delete service ...") << std::endl; _getch();
CServiceManager::Instance().Delete(driver_name);
// Dependents / Dependencies
std::tstring example = _T("WSearch");
std::tcout << example << std::endl;
std::tcout << _T("*Dependents:") << std::endl;
auto dependents = CServiceManager::Instance().GetDependents(example);
for (auto& dependent : dependents)
{
std::tcout << _T(" ")
<< dependent.lpServiceName << _T(" - ") << dependent.lpDisplayName << std::endl;
}
std::tcout << _T("*Dependencies:") << std::endl;
auto dependencies = CServiceManager::Instance().GetDependencies(example);
for (auto& dependency : dependencies)
{
std::tcout << _T(" ")
<< dependency.lpServiceName << _T(" - ") << dependency.lpDisplayName << std::endl;
}
// List Services
std::tcout << _T("*Services:") << std::endl;
auto pService = vu::CServiceManager::Instance().Query(example);
assert(pService != nullptr);
auto services = vu::CServiceManager::Instance().GetServices(VU_SERVICE_ALL_TYPES, SERVICE_RUNNING);
for (auto& e : services)
{
std::tcout << _T(" ")
<< e.lpServiceName << _T(" - ") << e.lpDisplayName << std::endl;
}
}
return vu::VU_OK;
}