⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winservice.cs

📁 一个抓包工具
💻 CS
📖 第 1 页 / 共 2 页
字号:
			uint dwServiceType,
			uint dwStartType,
			uint dwErrorControl,
			string lpBinaryPathName,
			string lpLoadOrderGroup,
			ref uint lpdwTagId,
			string lpDependencies,
			string lpServiceStartName,
			string lpPassword );

		[DllImport("advapi32.dll")] public static extern int
			CreateService(int hSCManager,
			ref string lpServiceName,
			ref string lpDisplayName,
			uint dwDesiredAccess,
			uint dwServiceType,
			uint dwStartType,
			uint dwErrorControl,
			ref string lpBinaryPathName,
			ref string lpLoadOrderGroup,
			ref uint lpdwTagId,
			ref string lpDependencies,
			ref string lpServiceStartName,
			ref string lpPassword );


		[DllImport("advapi32.dll")] public static extern int
			CreateService(int hSCManager,
			int lpServiceName,
			int lpDisplayName,
			uint dwDesiredAccess,
			uint dwServiceType,
			uint dwStartType,
			uint dwErrorControl,
			int lpBinaryPathName,
			int lpLoadOrderGroup,
			ref uint lpdwTagId,
			int lpDependencies,
			int lpServiceStartName,
			int lpPassword );

		[DllImport("advapi32.dll")] public static extern int
			CreateService(int hSCManager,
			int lpServiceName,
			int lpDisplayName,
			uint dwDesiredAccess,
			uint dwServiceType,
			uint dwStartType,
			uint dwErrorControl,
			int lpBinaryPathName,
			int lpLoadOrderGroup,
			int lpdwTagId,
			int lpDependencies,
			int lpServiceStartName,
			int lpPassword );

		//******************************************************************************
		//BOOL DeleteService(
		//
		//    SC_HANDLE hService  // handle to service
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			DeleteService( int hService );

		//******************************************************************************
		//BOOL EnumDependentServices(
		//
		//    SC_HANDLE hService, // handle to service
		//    DWORD dwServiceState,   // state of services to enumerate
		//    LPENUM_SERVICE_STATUS lpServices,   // pointer to service status buffer
		//    DWORD cbBufSize,    // size of service status buffer
		//    LPDWORD pcbBytesNeeded, // pointer to variable for bytes needed
		//    LPDWORD lpServicesReturned  // pointer to variable for number returned
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			EnumDependentServicesW( int hService,
			uint dwServiceState,
			ref ENUM_SERVICE_STATUS [] lpServices,
			uint cbBuffSize,
			ref uint pcbBytesNeeded,
			ref uint lpServicesReturned );
		//******************************************************************************
		//BOOL EnumServicesStatus(
		//
		//    SC_HANDLE hSCManager,   // handle to service control manager database
		//    DWORD dwServiceType,    // type of services to enumerate
		//    DWORD dwServiceState,   // state of services to enumerate
		//    LPENUM_SERVICE_STATUS lpServices,   // pointer to service status buffer
		//    DWORD cbBufSize,    // size of service status buffer
		//    LPDWORD pcbBytesNeeded, // pointer to variable for bytes needed
		//    LPDWORD lpServicesReturned, // pointer to variable for number returned
		//    LPDWORD lpResumeHandle  // pointer to variable for next entry
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			EnumServicesStatusW(int hSCManager,
			uint dwServiceType,
			uint dwServiceState,
			ref ENUM_SERVICE_STATUS lpServices,
			uint cbBufSize,
			ref uint pcbBytesNeeded,
			ref uint lpServicesReturned,
			ref uint lpResumeHandle );
		//******************************************************************************
		//BOOL GetServiceDisplayName(
		//
		//    SC_HANDLE hSCManager,   // handle to a service control manager database
		//    LPCTSTR lpServiceName,  // the service name
		//    LPTSTR lpDisplayName,   // buffer to receive the service//s display name
		//    LPDWORD lpcchBuffer     // size of display name buffer and display name
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			GetServiceDisplayNameW( int hSCManager,
			string lpServiceName,
			string lpDisplayName,
			ref uint lpcchBuffer );
		//******************************************************************************
		//BOOL GetServiceKeyName(
		//
		//    SC_HANDLE hSCManager,   // handle to a service control manager database
		//    LPCTSTR lpDisplayName,  // the service//s display name
		//    LPTSTR lpServiceName,   // buffer to receive the service name
		//    LPDWORD lpcchBuffer     // size of service name buffer and service name
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			GetServiceKeyNameW( int hSCManager,
			string lpDisplayName,
			string lpServiceName,
			ref uint lpcchBuffer );
		//******************************************************************************
		//VOID WINAPI Handler(
		//
		//    DWORD fdwControl    // requested control code
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			Handler( uint fdwControl );
		//******************************************************************************
		//SC_LOCK LockServiceDatabase(
		//
		//    SC_HANDLE hSCManager    // handle of service control manager database
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			LockServiceDatabase( int hSCManager );
		//******************************************************************************
		//BOOL NotifyBootConfigStatus(
		//
		//    BOOL BootAcceptable     // indicates acceptability of boot configuration
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			NotifyBootConfigStatus( uint BootAcceptable );
		//******************************************************************************
		//SC_HANDLE OpenSCManager(
		//
		//    LPCTSTR lpMachineName,  // pointer to machine name string
		//    LPCTSTR lpDatabaseName, // pointer to database name string
		//    DWORD dwDesiredAccess   // type of access
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			OpenSCManagerW( string lpMachineName,
			string lpDatabaseName,
			uint dwDesiredAccess );
		//******************************************************************************
		//SC_HANDLE OpenService(
		//
		//    SC_HANDLE hSCManager,   // handle to service control manager database
		//    LPCTSTR lpServiceName,  // pointer to name of service to start
		//    DWORD dwDesiredAccess   // type of access to service
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll", EntryPoint="OpenServiceW")] public static extern int
			OpenService(int hSCManager,
			string lpServiceName,
			uint dwDesiredAccess );

		[DllImport("advapi32.dll", EntryPoint="OpenServiceW")] public static extern int
			OpenService(int hSCManager,
			int lpServiceName,
			uint dwDesiredAccess );

		//******************************************************************************
		//BOOL QueryServiceConfig(
		//
		//    SC_HANDLE hService, // handle of service
		//    LPQUERY_SERVICE_CONFIG lpServiceConfig, // address of service config. structure
		//    DWORD cbBufSize,    // size of service configuration buffer
		//    LPDWORD pcbBytesNeeded  // address of variable for bytes needed
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			QueryServiceConfigW(int hService,
			ref QUERY_SERVICE_CONFIG lpServiceConfig,
			uint cbBufSize,
			ref uint pcbBytesNeeded );
		//******************************************************************************
		//BOOL QueryServiceLockStatus(
		//
		//    SC_HANDLE hSCManager,   // handle of svc. ctrl. mgr. database
		//    LPQUERY_SERVICE_LOCK_STATUS lpLockStatus,   // address of lock status structure
		//    DWORD cbBufSize,    // size of service configuration buffer
		//    LPDWORD pcbBytesNeeded  // address of variable for bytes needed
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			QueryServiceLockStatusW(int hSCManager,
			uint lpLockStatus,
			uint cbBufSize,
			ref uint pcbBytesNeeded );
		//******************************************************************************
		//BOOL QueryServiceObjectSecurity(
		//
		//    SC_HANDLE hService, // handle of service
		//    SECURITY_INFORMATION dwSecurityInformation, // type of security information requested
		//    PSECURITY_DESCRIPTOR lpSecurityDescriptor,  // address of security descriptor
		//    DWORD cbBufSize,    // size of security descriptor buffer
		//    LPDWORD pcbBytesNeeded  // address of variable for bytes needed
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			QueryServiceObjectSecurity(	int hService,
			uint dwSecurityInformation,
			uint lpSecurityDiscriptor,
			uint cbBufSize,
			ref uint pcbBytesNeeded );
		//******************************************************************************
		//BOOL QueryServiceStatus(

		//    SC_HANDLE hService, // handle of service
		//    LPSERVICE_STATUS lpServiceStatus    // address of service status structure
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			QueryServiceStatus( int hService,
			ref SERVICE_STATUS lpServiceStatus );
		//******************************************************************************
		//SERVICE_STATUS_HANDLE RegisterServiceCtrlHandler(
		//
		//    LPCTSTR lpServiceName,  // address of name of service
		//    LPHANDLER_FUNCTION lpHandlerProc    // address of handler function
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			RegisterServiceCtrlHandlerW( string lpServiceName,
			ServiceHandler lpHandlerProc );
		//******************************************************************************
		//VOID WINAPI ServiceMain(
		//
		//    DWORD dwArgc,   // number of arguments
		//    LPTSTR *lpszArgv    // address of array of argument string pointers
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			ServiceMain( uint dwArgc,
			uint lpszArgv );
		//******************************************************************************
		//BOOL SetServiceBits(
		//
		//    SERVICE_STATUS_HANDLE hServiceStatus,   // service status handle
		//    DWORD dwServiceBits,    // service type bits to set or clear
		//    BOOL bSetBitsOn,    // flag to set or clear the service type bits
		//    BOOL bUpdateImmediately // flag to announce server type immediately
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			SetServiceBits( int hServiceStatus,
			uint dwServiceBits,
			uint bSetBitsOn,
			uint bUpdateImmediately );
		//******************************************************************************
		//BOOL SetServiceObjectSecurity(
		//
		//    SC_HANDLE hService, // handle of service
		//    SECURITY_INFORMATION dwSecurityInformation, // type of security information requested
		//    PSECURITY_DESCRIPTOR lpSecurityDescriptor   // address of security descriptor
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			SetServiceObjectSecurity( int hService,
			uint dwSecurityInformation,
			uint lpSecurityDescriptor );
		//******************************************************************************
		//BOOL SetServiceStatus(
		//
		//    SERVICE_STATUS_HANDLE hServiceStatus~,  // service status handle
		//    LPSERVICE_STATUS lpServiceStatus    // address of status structure
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			SetServiceStatus( int hServiceStatus,
			ref SERVICE_STATUS lpServiceStatus );
		//******************************************************************************
		//BOOL StartService(
		//
		//    SC_HANDLE hService, // handle of service
		//    DWORD dwNumServiceArgs, // number of arguments
		//    LPCTSTR *lpServiceArgVectors    // address of array of argument string pointers
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll", EntryPoint="StartServiceW")] public static extern int
			StartService(  int hService,
			uint dwNumServiceArgs,
			ref string lpServiceArgVectors );

		[DllImport("advapi32.dll", EntryPoint="StartServiceW")] public static extern int
			StartService(  int hService,
			uint dwNumServiceArgs,
			int lpServiceArgVectors );

		//******************************************************************************
		//BOOL StartServiceCtrlDispatcher(
		//
		//    LPSERVICE_TABLE_ENTRY lpServiceStartTable   // address of service table
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			StartServiceCtrlDispatcherW( uint lpServiceStartTable );
		//******************************************************************************
		//BOOL UnlockServiceDatabase(
		//
		//    SC_LOCK ScLock  // service control manager database lock to be released
		//   );
		//------------------------------------------------------------------------------
		[DllImport("advapi32.dll")] public static extern int
			UnlockServiceDatabase( uint ScLock );
		//******************************************************************************


		public WinService()
		{

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -