Здравствуйте, мою преведущую тему о сервисах Windows закрыли поэтому создаю новую. Хочу научица создавать сервисы.Пока это не особо получается. Хочу разобраца со всеми тонкастями.У меня вопрос сейчас просто по синтаксису FASM, как передать функции адрес структуры ? Не пинайте сильно. Код (Text): format PE64 GUI 5.0 entry Main include 'win64a.inc' SC_MANAGER_CREATE_SERVICE = 0002h SERVICE_WIN32_OWN_PROCESS = 00000010h SERVICE_DEMAND_START = 00000003h SERVICE_ERROR_IGNORE = 00000000h SERVICE_CONFIG_DESCRIPTION = 00000001h struct SERVICE_DESCRIPTION lpDescription dq ? ends section '.data' data readable writeable szServiceName db 'Test service',0 szDisplayName db 'Test service 123',0 lpDescription db 'Test service description',0 szFileName db 'C:\TestService.exe',0 schSCManager dq ? svcSCManager dq ? scherror db 'ошибка OpenSCManager().',0 svcerror db 'ошибка CreateService.()',0 svccreate db '*** сервис создан.',0 section '.code' code readable executable proc Main invoke OpenSCManagerA,NULL,NULL,SC_MANAGER_CREATE_SERVICE cmp rax,0 je .scherror mov [schSCManager],rax invoke CreateServiceA,[schSCManager],szServiceName,szDisplayName,\ STANDARD_RIGHTS_REQUIRED,SERVICE_WIN32_OWN_PROCESS,SERVICE_DEMAND_START,SERVICE_ERROR_IGNORE,\ szFileName,NULL,NULL,NULL,NULL,NULL cmp rax,0 je .svcerror mov [svcSCManager],rax mov [SERVICE_DESCRIPTION.lpDescription],lpDescription invoke ChangeServiceConfig2A,[svcSCManager],SERVICE_CONFIG_DESCRIPTION,SERVICE_DESCRIPTION invoke CloseServiceHandle,[schSCManager] invoke CloseServiceHandle,[svcSCManager] invoke MessageBoxA,0,svccreate,0,MB_ICONWARNING jmp .exit .svcerror: invoke MessageBoxA,0,scherror,0,MB_ICONERROR jmp .exit .scherror: invoke MessageBoxA,0,svcerror,0,MB_ICONERROR .exit: invoke ExitProcess,rax endp section '.idata' import data readable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ advapi,'ADVAPI32.DLL' import advapi,\ OpenSCManagerA,'OpenSCManagerA',\ CreateServiceA,'CreateServiceA',\ ChangeServiceConfig2A,'ChangeServiceConfig2A',\ CloseServiceHandle,'CloseServiceHandle' import kernel,\ ExitProcess,'ExitProcess' import user,\ MessageBoxA,'MessageBoxA' Нада заполнить структуру и передать её ChangeServiceConfig2A , помогите пожалуйста.
Еще такой вопрос , почему то немогу удалить сервис. Код (Text): format PE64 GUI 5.0 entry Main include 'win64a.inc' SC_MANAGER_ALL_ACCESS = 0F003Fh section '.data' data readable writeable szServiceName db 'Test service',0 schSCManager dq ? svcSCManager dq ? scherror db 'ошибка OpenSCManager().',0 svcerror db 'ошибка OpenServiceA()',0 svcdelete db '*** сервис удалён.',0 section '.code' code readable executable proc Main invoke OpenSCManagerA,NULL,NULL,SC_MANAGER_ALL_ACCESS cmp rax,0 je .scherror mov [schSCManager],rax invoke OpenServiceA,[schSCManager],szServiceName,SC_MANAGER_ALL_ACCESS cmp rax,0 je .svcerror mov [svcSCManager],rax invoke DeleteService,[svcSCManager] invoke CloseServiceHandle,[schSCManager] invoke CloseServiceHandle,[svcSCManager] invoke MessageBoxA,0,svcdelete,0,MB_ICONWARNING jmp .exit .svcerror: invoke MessageBoxA,0,scherror,0,MB_ICONERROR jmp .exit .scherror: invoke MessageBoxA,0,svcerror,0,MB_ICONERROR .exit: invoke ExitProcess,rax endp section '.idata' import data readable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ advapi,'ADVAPI32.DLL' import advapi,\ OpenSCManagerA,'OpenSCManagerA',\ OpenServiceA,'OpenServiceA',\ DeleteService,'DeleteService',\ CloseServiceHandle,'CloseServiceHandle' import kernel,\ ExitProcess,'ExitProcess' import user,\ MessageBoxA,'MessageBoxA' Тему наверное надо было создавать в разделе для новечков Перенисите её пожалуйста. С удалением разобрался , код правельный , WIndows удалила службу после перезагрузки компьютера.
Код (Text): mov [SERVICE_DESCRIPTION.lpDescription],lpDescription invoke ChangeServiceConfig2A,[svcSCManager],SERVICE_CONFIG_DESCRIPTION,SERVICE_DESCRIPTION Где у вас объявлена структура с типом SERVICE_DESCRIPTION?
Всё , получилось зарегистрировать Код (Text): format PE64 GUI 5.0 entry Main include 'win64a.inc' SC_MANAGER_CREATE_SERVICE = 0002h SERVICE_CHANGE_CONFIG = 0002h SERVICE_WIN32_OWN_PROCESS = 00000010h SERVICE_DEMAND_START = 00000003h SERVICE_ERROR_IGNORE = 00000000h SERVICE_CONFIG_DESCRIPTION = 00000001h section '.data' data readable writeable struct SERVICE_DESCRIPTION lpDescription dq ? ends SERV_DESC SERVICE_DESCRIPTION szServiceName db 'Test service',0 szDisplayName db 'Test service 123',0 lpDescription db 'Test service description',0 szFileName db 'C:\TestService.exe',0 schSCManager dq ? svcSCManager dq ? scherror db 'ошибка OpenSCManager().',0 svcerror db 'ошибка CreateService().',0 svccreate db '*** сервис создан.',0 section '.code' code readable executable proc Main invoke OpenSCManagerA,NULL,NULL,SC_MANAGER_CREATE_SERVICE or SERVICE_CHANGE_CONFIG cmp rax,0 je .scherror mov [schSCManager],rax invoke CreateServiceA,[schSCManager],szServiceName,szDisplayName,\ STANDARD_RIGHTS_REQUIRED or SERVICE_CHANGE_CONFIG,SERVICE_WIN32_OWN_PROCESS,SERVICE_DEMAND_START,SERVICE_ERROR_IGNORE,\ szFileName,NULL,NULL,NULL,NULL,NULL cmp rax,0 je .svcerror mov [svcSCManager],rax mov [SERV_DESC.lpDescription],lpDescription invoke ChangeServiceConfig2A,[svcSCManager],SERVICE_CONFIG_DESCRIPTION,SERV_DESC invoke CloseServiceHandle,[schSCManager] invoke CloseServiceHandle,[svcSCManager] invoke MessageBoxA,0,svccreate,0,MB_ICONWARNING jmp .exit .svcerror: invoke MessageBoxA,0,svcerror,0,MB_ICONERROR jmp .exit .scherror: invoke MessageBoxA,0,scherror,0,MB_ICONERROR .exit: invoke ExitProcess,rax endp section '.idata' import data readable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ advapi,'ADVAPI32.DLL' import advapi,\ OpenSCManagerA,'OpenSCManagerA',\ CreateServiceA,'CreateServiceA',\ ChangeServiceConfig2A,'ChangeServiceConfig2A',\ CloseServiceHandle,'CloseServiceHandle' import kernel,\ ExitProcess,'ExitProcess' import user,\ MessageBoxA,'MessageBoxA' Помогиет дописать сам сервис, я так понимаю по логике он будет начинаца типа: Код (Text): format PE64 GUI 5.0 entry Main include 'win64a.inc' SERVICE_WIN32_OWN_PROCESS = 00000010h SERVICE_INTERACTIVE_PROCESS = 00000100h SERVICE_START_PENDING = 00000002h SERVICE_ACCEPT_STOP = 00000001h SERVICE_ACCEPT_SHUTDOWN = 00000004h SERVICE_RUNNING = 00000004h SERVICE_CONTROL_STOP = 00000001h NO_ERROR = 0h section '.data' data readable writeable struct SERVICE_TABLE_ENTRY lpServiceName dq ? lpServiceProc dq ? ends ServiceTable SERVICE_TABLE_ENTRY struct SERVICE_STATUS dwServiceType dd ? dwCurrentState dd ? dwControlsAccepted dd ? dwWin32ExitCode dd ? dwServiceSpecificExitCode dd ? dwCheckPoint dd ? dwWaitHint dd ? ends ServiceStatus SERVICE_STATUS hStatus dq ? hello db 'Hello, world!',0 ServiceName db 'Test service',0 section '.code' code readable executable proc Main mov [ServiceTable.lpServiceName],ServiceName mov [ServiceTable.lpServiceProc],ServiceMain invoke StartServiceCtrlDispatcher,ServiceTable endp proc ServiceMain dwArgc:DWORD, lpszArgv:QWORD invoke RegisterServiceCtrlHandler,ServiceName,ServiceCtrlHandler mov [hStatus],rax mov [ServiceStatus.dwServiceType],SERVICE_WIN32_OWN_PROCESS or SERVICE_INTERACTIVE_PROCESS mov [ServiceStatus.dwCurrentState],SERVICE_START_PENDING mov [ServiceStatus.dwControlsAccepted],SERVICE_ACCEPT_STOP or SERVICE_ACCEPT_SHUTDOWN invoke SetServiceStatus,[hStatus],ServiceStatus mov [ServiceStatus.dwCurrentState],SERVICE_RUNNING mov [ServiceStatus.dwWin32ExitCode],NO_ERROR invoke SetServiceStatus,[hStatus],ServiceStatus call ServiceProc endp proc ServiceCtrlHandler dwControl:DWORD cmp [dwControl],SERVICE_CONTROL_STOP mov [ServiceStatus.dwCurrentState],SERVICE_RUNNING invoke SetServiceStatus,[hStatus],ServiceStatus ret endp proc ServiceProc .rep: invoke Sleep,3000 invoke MessageBoxA,0,hello,0,MB_ICONWARNING jmp .rep endp section '.idata' import data readable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ advapi,'ADVAPI32.DLL' import advapi,\ OpenSCManagerA,'OpenSCManagerA',\ CreateServiceA,'CreateServiceA',\ ChangeServiceConfig2A,'ChangeServiceConfig2A',\ CloseServiceHandle,'CloseServiceHandle',\ StartServiceCtrlDispatcher,'StartServiceCtrlDispatcherA',\ RegisterServiceCtrlHandler,'RegisterServiceCtrlHandlerA',\ SetServiceStatus,'SetServiceStatus' import kernel,\ ExitProcess,'ExitProcess',\ Sleep,'Sleep' import user,\ MessageBoxA,'MessageBoxA' помогите пожалуйста