-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
157 lines (133 loc) · 4.99 KB
/
test.c
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <windows.h>
#include <stdio.h>
#include <winsvc.h>
#define IDC_LISTBOX 1001
#define IDC_BTN_SERVICES 1002
#define IDC_BTN_CLEANRAM 1003
#define IDC_BTN_OPENURL 1004
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void EnumServices(HWND hwndList);
void CleanRam();
void OpenURL();
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
const char CLASS_NAME[] = "RikerServicesWindowClass";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
RegisterClass(&wc);
HWND hwnd = CreateWindowEx(
0,
CLASS_NAME,
"Riker Services Dashboard",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, // <-- Taille de la fenêtre augmentée
NULL,
NULL,
hInstance,
NULL
);
if (hwnd == NULL) {
return 0;
}
ShowWindow(hwnd, nCmdShow);
MSG msg = { };
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
static HWND hwndList, hwndBtnServices, hwndBtnCleanRam, hwndBtnOpenURL, hwndTitle;
switch (uMsg) {
case WM_CREATE:
{
hwndTitle = CreateWindowW(
L"STATIC", L"RIKER SERVICES",
WS_CHILD | WS_VISIBLE | SS_CENTER,
200, 10, 400, 40, // <-- Taille et position ajustées
hwnd, NULL, NULL, NULL
);
hwndBtnServices = CreateWindowW(
L"BUTTON", L"Afficher Services",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
50, 60, 200, 40, // <-- Taille et position ajustées
hwnd, (HMENU)IDC_BTN_SERVICES, GetModuleHandle(NULL), NULL
);
hwndBtnCleanRam = CreateWindowW(
L"BUTTON", L"Nettoyer RAM",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
300, 60, 200, 40, // <-- Taille et position ajustées
hwnd, (HMENU)IDC_BTN_CLEANRAM, GetModuleHandle(NULL), NULL
);
hwndBtnOpenURL = CreateWindowW(
L"BUTTON", L"Ouvrir le Site",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
550, 60, 200, 40, // <-- Taille et position ajustées
hwnd, (HMENU)IDC_BTN_OPENURL, GetModuleHandle(NULL), NULL
);
hwndList = CreateWindowW(
L"LISTBOX", NULL,
WS_CHILD | WS_VISIBLE | LBS_STANDARD,
10, 120, 760, 420, // <-- Taille et position ajustées
hwnd, (HMENU)IDC_LISTBOX, NULL, NULL
);
return 0;
}
case WM_COMMAND:
if (LOWORD(wParam) == IDC_BTN_SERVICES) {
EnumServices(hwndList);
} else if (LOWORD(wParam) == IDC_BTN_CLEANRAM) {
CleanRam();
} else if (LOWORD(wParam) == IDC_BTN_OPENURL) {
OpenURL();
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
void EnumServices(HWND hwndList) {
SendMessage(hwndList, LB_RESETCONTENT, 0, 0);
SC_HANDLE hSCManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE);
if (hSCManager == NULL) {
MessageBox(NULL, "OpenSCManager failed", "Error", MB_OK | MB_ICONERROR);
return;
}
ENUM_SERVICE_STATUS ssStatus[1024];
DWORD dwBytesNeeded, dwServicesReturned, dwResumeHandle = 0;
BOOL bEnumResult;
do {
bEnumResult = EnumServicesStatus(
hSCManager,
SERVICE_WIN32,
SERVICE_STATE_ALL,
ssStatus,
sizeof(ssStatus),
&dwBytesNeeded,
&dwServicesReturned,
&dwResumeHandle);
if (!bEnumResult) {
if (GetLastError() != ERROR_MORE_DATA) {
MessageBox(NULL, "EnumServicesStatus failed", "Error", MB_OK | MB_ICONERROR);
CloseServiceHandle(hSCManager);
return;
}
}
for (DWORD i = 0; i < dwServicesReturned; i++) {
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)ssStatus[i].lpServiceName);
}
} while (!bEnumResult);
CloseServiceHandle(hSCManager);
}
void CleanRam() {
SetProcessWorkingSetSize(GetCurrentProcess(), (SIZE_T)-1, (SIZE_T)-1);
MessageBox(NULL, "Nettoyage de la RAM effectué!", "Information", MB_OK | MB_ICONINFORMATION);
}
void OpenURL() {
ShellExecute(0, 0, "https://tikbisness2.wixsite.com/rikerservice-secure", 0, 0, SW_SHOW);
}