-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathUnsafeNativeMethods.cs
More file actions
49 lines (37 loc) · 3.21 KB
/
UnsafeNativeMethods.cs
File metadata and controls
49 lines (37 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//------------------------------------------------------------------------------
// <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ServiceProcess {
using System;
using System.Text;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
[
ComVisible(false),
SuppressUnmanagedCodeSecurityAttribute()
]
internal static class UnsafeNativeMethods {
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public unsafe extern static bool ControlService(IntPtr serviceHandle, int control, NativeMethods.SERVICE_STATUS *pStatus);
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public static extern unsafe bool QueryServiceStatus(IntPtr serviceHandle, NativeMethods.SERVICE_STATUS *pStatus);
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public extern static bool EnumServicesStatus(IntPtr databaseHandle, int serviceType, int serviceState,
IntPtr status, int size, out int bytesNeeded, out int servicesReturned, ref int resumeHandle);
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public extern static bool EnumServicesStatusEx(IntPtr databaseHandle, int infolevel, int serviceType, int serviceState,
IntPtr status, int size, out int bytesNeeded, out int servicesReturned, ref int resumeHandle, string group);
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public extern static IntPtr OpenService(IntPtr databaseHandle, string serviceName, int access);
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public extern static bool StartService(IntPtr serviceHandle, int argNum, IntPtr argPtrs);
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public extern static bool EnumDependentServices(IntPtr serviceHandle, int serviceState, IntPtr bufferOfENUM_SERVICE_STATUS,
int bufSize, ref int bytesNeeded, ref int numEnumerated);
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
public extern static bool QueryServiceConfig(IntPtr serviceHandle, IntPtr query_service_config_ptr, int bufferSize, out int bytesNeeded);
}
}