Здраствуйте! у меня такой вопрос: вот мы подменили *.exe какого нибудь win сервиса как его перезапустить? Я юзаю функции ControlService() StartService(). Не получается. Если кто знает покажите пример.
Пример надо показать на столько же содержательный, насколько описание проблемы?) Как именно не получается?
выкл Код (Text): invoke lstrcmp,addr Result,CTXT("serv stop") .if eax == 0 invoke SetLastError,0 invoke OpenSCManager,0,0,SC_MANAGER_ALL_ACCESS mov hSCManager,eax invoke OpenService,hSCManager,addr ServName,SERVICE_ALL_ACCESS mov SHandle,eax invoke ControlService,SHandle,SERVICE_CONTROL_STOP,addr eRR invoke SetLastError,0 invoke CloseServiceHandle,SHandle ret вкл Код (Text): invoke lstrcmp,addr Result,CTXT("serv start") .if eax == 0 invoke SetLastError,0 invoke OpenSCManager,0,0,SC_MANAGER_ALL_ACCESS mov hSCManager,eax invoke OpenService,hSCManager,addr ServName,SERVICE_ALL_ACCESS mov SHandle,eax invoke ControlService,SHandle,SERVICE_CONTROL_START,addr eRR invoke SetLastError,0 invoke CloseServiceHandle,SHandle ret
и еще.... Код (Text): .ELSEIF uMsg == WM_COMMAND mov eax,wParam .IF lParam != 0 .IF ax == button2ID shr eax,16 .IF ax == BN_CLICKED invoke RtlZeroMemory,addr buffer1,512 invoke SetLastError,0 invoke OpenSCManager,0,0,SC_MANAGER_ALL_ACCESS mov hSCManager,eax invoke SendMessage,hwndcombobox1,WM_GETTEXT,255,addr Combo invoke SendMessage,hwndedit1,WM_GETTEXT,4,addr edit .if byte ptr [Combo] == 55h invoke OpenService,hSCManager,addr ServName,SERVICE_ALL_ACCESS mov SHandle,eax invoke ControlService,SHandle,SERVICE_CONTROL_STOP,addr eRR invoke SetLastError,0 invoke CloseServiceHandle,SHandle invoke OpenService,hSCManager,addr ServName,SERVICE_ALL_ACCESS mov SHandle,eax invoke DeleteService,SHandle invoke GetLastError .if eax != 0 mov ecx,eax invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM ,0,ecx,0,addr buffer1,255,0 invoke MessageBox,hWnd,addr buffer1,CTXT("0"),MB_OK .endif invoke CloseServiceHandle,SHandle .elseif byte ptr [Combo] == 49h invoke CreateService,hSCManager,addr ServName,addr ServName,\ SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS or SERVICE_INTERACTIVE_PROCESS,\ SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,\ CommandLine,0,0,0,0,0 mov SHandle,eax invoke SetLastError,0 mov Action0.aType, SC_ACTION_RESTART mov Action0.Delay, 0h mov Action1.aType, SC_ACTION_RESTART mov Action1.Delay, 0h mov Action2.aType, SC_ACTION_RESTART mov Action2.Delay, 0h mov lpInfo1.dwResetPeriod, 0h mov lpInfo1.lpRebootMsg, 0 mov lpInfo1.lpCommand, 0 mov lpInfo1.cActions, 3 lea eax, Action0 mov lpInfo1.lpsaActions, eax invoke ChangeServiceConfig2, SHandle, 2, addr lpInfo1 invoke GetLastError .if eax != 0 mov ecx,eax invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM ,0,ecx,0,addr buffer1,255,0 invoke MessageBox,hWnd,addr buffer1,CTXT("1"),MB_OK .endif invoke CloseServiceHandle,SHandle invoke OpenService,hSCManager,addr ServName,SERVICE_ALL_ACCESS mov SHandle,eax invoke StartService,SHandle,0,NULL invoke GetLastError .if eax != 0 mov ecx,eax invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM ,0,ecx,0,addr buffer1,255,0 invoke MessageBox,hWnd,addr buffer1,CTXT("2"),MB_OK .endif invoke CloseServiceHandle,SHandle .endif invoke CloseServiceHandle, hSCManager .ENDIF invoke SendMessage,hWnd,WM_DESTROY,0,0 .ENDIF .ENDIF .ELSE invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .ENDIF структуры. Код (Text): SC_ACTION struct aType dd ? Delay dd ? SC_ACTION ends SERVICE_FAILURE_ACTIONS struct dwResetPeriod dd ? lpRebootMsg dd ? lpCommand dd ? cActions dd ? lpsaActions dd ? SERVICE_FAILURE_ACTIONS ends SERVICE_DESCRIPTION struct lpDescription dd ? SERVICE_DESCRIPTION ends и еще хз не помню для чего SC_ACTION_NONE equ 0 SC_ACTION_RESTART equ 1 SC_ACTION_REBOOT equ 2 SC_ACTION_RUN_COMMAND equ 3