mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -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
|
||||
{
|
||||
/* FileSystem */
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate Int32 FspFileSystemPreflight(
|
||||
[MarshalAs(UnmanagedType.LPWStr)] String DevicePath,
|
||||
@ -439,6 +440,8 @@ namespace Fsp.Interop
|
||||
out IoStatusBlock PIoStatus,
|
||||
IntPtr Buffer,
|
||||
ref UIntPtr PSize);
|
||||
|
||||
/* Service */
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate Int32 FspServiceCreate(
|
||||
[MarshalAs(UnmanagedType.LPWStr)] String ServiceName,
|
||||
@ -453,6 +456,14 @@ namespace Fsp.Interop
|
||||
internal delegate void FspServiceAllowConsoleMode(
|
||||
IntPtr Service);
|
||||
[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(
|
||||
IntPtr Service);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
@ -466,6 +477,8 @@ namespace Fsp.Interop
|
||||
UInt32 Type,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] String Format,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] String Message);
|
||||
|
||||
/* utility */
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate Int32 FspVersion(
|
||||
out UInt32 PVersion);
|
||||
@ -517,6 +530,8 @@ namespace Fsp.Interop
|
||||
internal static Proto.FspServiceCreate FspServiceCreate;
|
||||
internal static Proto.FspServiceDelete FspServiceDelete;
|
||||
internal static Proto.FspServiceAllowConsoleMode FspServiceAllowConsoleMode;
|
||||
internal static Proto.FspServiceRequestTime FspServiceRequestTime;
|
||||
internal static Proto.FspServiceSetExitCode FspServiceSetExitCode;
|
||||
internal static Proto.FspServiceGetExitCode FspServiceGetExitCode;
|
||||
internal static Proto.FspServiceLoop FspServiceLoop;
|
||||
internal static Proto.FspServiceStop FspServiceStop;
|
||||
@ -697,6 +712,8 @@ namespace Fsp.Interop
|
||||
FspServiceCreate = GetEntryPoint<Proto.FspServiceCreate>(Module);
|
||||
FspServiceDelete = GetEntryPoint<Proto.FspServiceDelete>(Module);
|
||||
FspServiceAllowConsoleMode = GetEntryPoint<Proto.FspServiceAllowConsoleMode>(Module);
|
||||
FspServiceRequestTime = GetEntryPoint<Proto.FspServiceRequestTime>(Module);
|
||||
FspServiceSetExitCode = GetEntryPoint<Proto.FspServiceSetExitCode>(Module);
|
||||
FspServiceGetExitCode = GetEntryPoint<Proto.FspServiceGetExitCode>(Module);
|
||||
FspServiceLoop = GetEntryPoint<Proto.FspServiceLoop>(Module);
|
||||
FspServiceStop = GetEntryPoint<Proto.FspServiceStop>(Module);
|
||||
|
@ -65,12 +65,21 @@ namespace Fsp
|
||||
}
|
||||
return (int)ExitCode;
|
||||
}
|
||||
void Stop()
|
||||
public void Stop()
|
||||
{
|
||||
if (0 > _CreateResult)
|
||||
return;
|
||||
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)
|
||||
{
|
||||
Api.FspServiceLog(Type, "%s", Message);
|
||||
@ -81,13 +90,11 @@ namespace Fsp
|
||||
{
|
||||
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 */
|
||||
@ -99,8 +106,9 @@ namespace Fsp
|
||||
Service self = (Service)Api.GetUserContext(Service);
|
||||
try
|
||||
{
|
||||
return self.OnStart(
|
||||
self.OnStart(
|
||||
Argv);
|
||||
return 0/*STATUS_SUCCESS*/;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -113,7 +121,8 @@ namespace Fsp
|
||||
Service self = (Service)Api.GetUserContext(Service);
|
||||
try
|
||||
{
|
||||
return self.OnStop();
|
||||
self.OnStop();
|
||||
return 0/*STATUS_SUCCESS*/;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user