service code

4 views
Skip to first unread message

tomas.d...@gmail.com

unread,
Jan 2, 2026, 4:58:39 AMJan 2
to WinFsp
Hi,

Happy New Year.
And many help for all the guidance and excellent tool from you.

I struggling with having the code to register my filesystem as a service on Windows 2025.
It works on older versions, but not on Windows 2025.
The filesystem works fine when running as a process (console mode), so it is just the service registration and launching part that does not work.

I have in my service registration code (which I also use for start/stop/status) this
int __decl _tmain(int argc, TCHAR *argv[])
{
     ...
     return SvcInstall()
}

int SvcInstall()
{
...
    GetModuleName(...)
    OpenSCManager(... SC_MANAGER_ALL_ACCESS)
    CreateService(... SERVICE_WIN32_OWN_PROCESS...) // should this be something else for 64bit?
}

VOID WINAPI SvcMain( DWORD dwAargc, LPTSTR *lpszArgv)
{
    RegisterServiceCtrlHandler( serviceName, serviceCtrlHandler)
    ReportSvcStatus(...)
}

VOID SvcInit( DWORD dwArgc, LPTSTR *lpszArgv)
{
 ...
    CreateEvent(...)
           ReportSvcStatus(SERVICE_STOPPED...)

    CreateProcess(...)
           ReportSvcStatus(failed...)

    ReportSvcStatus(SERVICE_RUNNING...)
 
    WaitForSingleObject(...)

   ReportSvcStatus(SERVICE_STOPPED...)
}

VOID ReportSvcStatus( ....)
{
    SetServiceStatus(...)
}

VOID WINAPI SvcCtrlHandler(...)
{
     switch(...)
           case SERVICE_CONTROL_STOP:
                 ReportSvcStatus(SERVICE_STOP_PENDING...)
                 TerminateProcess(...)
}

VOID SvcReportEvent(..)
{
    RegisterEventSource(....)
    ReportEvent(...)
}


Reply all
Reply to author
Forward
0 new messages