Добрий день, помогите пожалуста, непонимаю почему я немогу запустить сервис: Код (Text): .386 .model flat, stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\advapi32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\advapi32.lib include \masm32\Macros\Strings.mac .code start proc local hSCManager:HANDLE local hService:HANDLE local acDriverPath[MAX_PATH]:CHAR invoke OpenSCManager, NULL, NULL, SC_MANAGER_CREATE_SERVICE .if eax != NULL mov hSCManager, eax push eax invoke GetFullPathName, $CTA0("PS2Versuch1.sys"), sizeof acDriverPath, addr acDriverPath, esp pop eax invoke CreateService, hSCManager, $CTA0("PS2Versuch1.sys"), $CTA0("Maus kapput"), \ SC_MANAGER_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, \ SERVICE_ERROR_IGNORE, addr acDriverPath, NULL, NULL, NULL, NULL, NULL .if eax != NULL mov hService, eax invoke StartService, hService, 0, NULL invoke DeleteService, hService invoke CloseServiceHandle, hService .else invoke MessageBox, NULL, $CTA0("Can't register driver."), NULL, MB_ICONSTOP .endif invoke CloseServiceHandle, hSCManager .else invoke MessageBox, NULL, $CTA0("Can't connect to Service Control Manager."), \ NULL, MB_ICONSTOP .endif invoke ExitProcess, 0 start endp end start после вызова GetLastError , вадает ошибку 1073.
Удали старый сервис перед тем как устанавливать его снова. Это проще для отладки (когда требуется многократное изменение и перезапуск кода). Или пользуйся уже установленным сервисом не инсталлируя заново Код (Text): mov hService, eax .if (!eax) invoke GetLastError .if (eax==ERROR_SERVICE_EXISTS || eax==ERROR_DUPLICATE_SERVICE_NAME) invoke OpenService, hManager, addr szDisplayName, SERVICE_ALL_ACCESS mov hService, eax .endif .endif
Я писал сервис но возникли сложности с процедурой управления сервисом, поможите ? http://www.wasm.ru/forum/viewtopic.php?id=40432 вот код на fasm для удаления сервиса, где то был еще 32-ух битный Код (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' вот на masm Код (Text): .686 .model flat,stdcall option casemap:none includelib library\kernel32.lib includelib library\user32.lib includelib library\shell32.lib includelib library\Advapi32.lib .data? schSCManager dd ? .data szServiceName db "szServiceName",0 .code start: OpenSCManagerA PROTO :DWORD,:DWORD,:DWORD push 0F003Fh push 0 push 0 call OpenSCManagerA mov schSCManager,eax OpenServiceA PROTO :DWORD,:DWORD,:DWORD push 10000h push offset szServiceName push schSCManager DeleteService PROTO :DWORD push eax call DeleteService CloseServiceHandle PROTO :DWORD push schSCManager call CloseServiceHandle ExitProcess PROTO :DWORD push eax call ExitProcess end start