mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 08:53:01 -05:00
src: dotnet: Service improvements
This commit is contained in:
parent
075a2b6e4c
commit
de61eaf6b8
@ -389,6 +389,7 @@ namespace Fsp.Interop
|
|||||||
{
|
{
|
||||||
internal struct Proto
|
internal struct Proto
|
||||||
{
|
{
|
||||||
|
/* FileSystem */
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
internal delegate Int32 FspFileSystemPreflight(
|
internal delegate Int32 FspFileSystemPreflight(
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String DevicePath,
|
[MarshalAs(UnmanagedType.LPWStr)] String DevicePath,
|
||||||
@ -439,6 +440,8 @@ namespace Fsp.Interop
|
|||||||
out IoStatusBlock PIoStatus,
|
out IoStatusBlock PIoStatus,
|
||||||
IntPtr Buffer,
|
IntPtr Buffer,
|
||||||
ref UIntPtr PSize);
|
ref UIntPtr PSize);
|
||||||
|
|
||||||
|
/* Service */
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
internal delegate Int32 FspServiceCreate(
|
internal delegate Int32 FspServiceCreate(
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String ServiceName,
|
[MarshalAs(UnmanagedType.LPWStr)] String ServiceName,
|
||||||
@ -453,6 +456,14 @@ namespace Fsp.Interop
|
|||||||
internal delegate void FspServiceAllowConsoleMode(
|
internal delegate void FspServiceAllowConsoleMode(
|
||||||
IntPtr Service);
|
IntPtr Service);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
internal delegate void FspServiceRequestTime(
|
||||||
|
IntPtr Service,
|
||||||
|
UInt32 Time);
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
internal delegate void FspServiceSetExitCode(
|
||||||
|
IntPtr Service,
|
||||||
|
UInt32 ExitCode);
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
internal delegate UInt32 FspServiceGetExitCode(
|
internal delegate UInt32 FspServiceGetExitCode(
|
||||||
IntPtr Service);
|
IntPtr Service);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
@ -466,6 +477,8 @@ namespace Fsp.Interop
|
|||||||
UInt32 Type,
|
UInt32 Type,
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String Format,
|
[MarshalAs(UnmanagedType.LPWStr)] String Format,
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String Message);
|
[MarshalAs(UnmanagedType.LPWStr)] String Message);
|
||||||
|
|
||||||
|
/* utility */
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
internal delegate Int32 FspVersion(
|
internal delegate Int32 FspVersion(
|
||||||
out UInt32 PVersion);
|
out UInt32 PVersion);
|
||||||
@ -517,6 +530,8 @@ namespace Fsp.Interop
|
|||||||
internal static Proto.FspServiceCreate FspServiceCreate;
|
internal static Proto.FspServiceCreate FspServiceCreate;
|
||||||
internal static Proto.FspServiceDelete FspServiceDelete;
|
internal static Proto.FspServiceDelete FspServiceDelete;
|
||||||
internal static Proto.FspServiceAllowConsoleMode FspServiceAllowConsoleMode;
|
internal static Proto.FspServiceAllowConsoleMode FspServiceAllowConsoleMode;
|
||||||
|
internal static Proto.FspServiceRequestTime FspServiceRequestTime;
|
||||||
|
internal static Proto.FspServiceSetExitCode FspServiceSetExitCode;
|
||||||
internal static Proto.FspServiceGetExitCode FspServiceGetExitCode;
|
internal static Proto.FspServiceGetExitCode FspServiceGetExitCode;
|
||||||
internal static Proto.FspServiceLoop FspServiceLoop;
|
internal static Proto.FspServiceLoop FspServiceLoop;
|
||||||
internal static Proto.FspServiceStop FspServiceStop;
|
internal static Proto.FspServiceStop FspServiceStop;
|
||||||
@ -697,6 +712,8 @@ namespace Fsp.Interop
|
|||||||
FspServiceCreate = GetEntryPoint<Proto.FspServiceCreate>(Module);
|
FspServiceCreate = GetEntryPoint<Proto.FspServiceCreate>(Module);
|
||||||
FspServiceDelete = GetEntryPoint<Proto.FspServiceDelete>(Module);
|
FspServiceDelete = GetEntryPoint<Proto.FspServiceDelete>(Module);
|
||||||
FspServiceAllowConsoleMode = GetEntryPoint<Proto.FspServiceAllowConsoleMode>(Module);
|
FspServiceAllowConsoleMode = GetEntryPoint<Proto.FspServiceAllowConsoleMode>(Module);
|
||||||
|
FspServiceRequestTime = GetEntryPoint<Proto.FspServiceRequestTime>(Module);
|
||||||
|
FspServiceSetExitCode = GetEntryPoint<Proto.FspServiceSetExitCode>(Module);
|
||||||
FspServiceGetExitCode = GetEntryPoint<Proto.FspServiceGetExitCode>(Module);
|
FspServiceGetExitCode = GetEntryPoint<Proto.FspServiceGetExitCode>(Module);
|
||||||
FspServiceLoop = GetEntryPoint<Proto.FspServiceLoop>(Module);
|
FspServiceLoop = GetEntryPoint<Proto.FspServiceLoop>(Module);
|
||||||
FspServiceStop = GetEntryPoint<Proto.FspServiceStop>(Module);
|
FspServiceStop = GetEntryPoint<Proto.FspServiceStop>(Module);
|
||||||
|
@ -65,12 +65,21 @@ namespace Fsp
|
|||||||
}
|
}
|
||||||
return (int)ExitCode;
|
return (int)ExitCode;
|
||||||
}
|
}
|
||||||
void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
if (0 > _CreateResult)
|
if (0 > _CreateResult)
|
||||||
return;
|
return;
|
||||||
Api.FspServiceStop(_Service);
|
Api.FspServiceStop(_Service);
|
||||||
}
|
}
|
||||||
|
public void RequestTime(UInt32 Time)
|
||||||
|
{
|
||||||
|
Api.FspServiceRequestTime(_Service, Time);
|
||||||
|
}
|
||||||
|
public int ExitCode
|
||||||
|
{
|
||||||
|
get { return (int)Api.FspServiceGetExitCode(_Service); }
|
||||||
|
set { Api.FspServiceSetExitCode(_Service, (UInt32)value); }
|
||||||
|
}
|
||||||
public static void Log(UInt32 Type, String Message)
|
public static void Log(UInt32 Type, String Message)
|
||||||
{
|
{
|
||||||
Api.FspServiceLog(Type, "%s", Message);
|
Api.FspServiceLog(Type, "%s", Message);
|
||||||
@ -81,13 +90,11 @@ namespace Fsp
|
|||||||
{
|
{
|
||||||
return unchecked((Int32)0xE0434f4D)/*STATUS_CLR_EXCEPTION*/;
|
return unchecked((Int32)0xE0434f4D)/*STATUS_CLR_EXCEPTION*/;
|
||||||
}
|
}
|
||||||
protected virtual Int32 OnStart(String[] Args)
|
protected virtual void OnStart(String[] Args)
|
||||||
{
|
{
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
protected virtual Int32 OnStop()
|
protected virtual void OnStop()
|
||||||
{
|
{
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
@ -99,8 +106,9 @@ namespace Fsp
|
|||||||
Service self = (Service)Api.GetUserContext(Service);
|
Service self = (Service)Api.GetUserContext(Service);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return self.OnStart(
|
self.OnStart(
|
||||||
Argv);
|
Argv);
|
||||||
|
return 0/*STATUS_SUCCESS*/;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -113,7 +121,8 @@ namespace Fsp
|
|||||||
Service self = (Service)Api.GetUserContext(Service);
|
Service self = (Service)Api.GetUserContext(Service);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return self.OnStop();
|
self.OnStop();
|
||||||
|
return 0/*STATUS_SUCCESS*/;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user