Skip to content

Service Path reversion on failure #8

Description

@mepher

In the C# version, around line 233, the following change means the service path will be reverted to the original, even on failure to launch. just a suggestion.

        bResult = StartService(schService, 0, null);
        uint dwResult = GetLastError();
        if (!bResult && dwResult != 1053)
        {
            Console.WriteLine("[!] StartServiceA failed to start the service. Error:{0}", GetLastError());
            Console.WriteLine("[*] Service path being reverted anyway");
            bResult = ChangeServiceConfigA(schService, SERVICE_NO_CHANGE, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, originalBinaryPath, null, null, null, null, null, null);
            if (!bResult)
            {
                Console.WriteLine("[!] ChangeServiceConfigA failed to revert the service path. Error:{0}", GetLastError());
                Environment.Exit(0);
            }
            Console.WriteLine("[*] Service path was restored to \"{0}\"", originalBinaryPath);
            Environment.Exit(0);
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions