Код: Код (Text): .386p option casemap:none .model flat, stdcall includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib includelib C:\masm32\lib\gdi32.lib includelib C:\masm32\lib\advapi32.lib includelib C:\masm32\lib\dinput.lib includelib C:\masm32\lib\dxguid.lib includelib C:\masm32\lib\Uuid.Lib includelib C:\masm32\lib\oldnames.lib include C:\masm32\include\Kernel32.inc include C:\masm32\include\gdi32.inc include C:\masm32\include\advapi32.inc include C:\masm32\include\user32.inc extrn DirectInputCreateA@16:near mServiceMain PROTO STDCALL :DWORD, :DWORD Handler PROTO STDCALL :DWORD .const SERVICE_CONTROL_SHUTDOWN = 000000005h SERVICE_WIN32_OWN_PROCESS = 000000010h SERVICE_RUNNING = 000000004h SERVICE_ACCEPT_SHUTDOWN = 000000004h NO_ERROR = 000000000h .data dwServiceType dd ? dwCurrentState dd ? dwControlsAccepted dd ? dwWin32ExitCode dd ? dwServiceSpecificExitCode dd ? dwCheckPoint dd ? dwWaitHint dd ? mServiceTableEntry dd offset mServiceName, offset mServiceMain, 0, 0 diini dd ? hService dd ? lpdi dd 0 ; ServiceStatus SERVICE_STATUS ? mServiceName db "Dinmouse",0 titleprog db "Иницилизация мыши",0 msbtxt1 db "Выполнено успешно",0 dinputerr db "Ошибка при иницилизации DirectInputCreate",0 msgmouseerr db "Ошибка при иницилизации мыши",0 msghandleerr db "Ошибка при получении хендла",0 FALSE equ 0 TRUE equ 1 .code main: invoke StartServiceCtrlDispatcher, addr mServiceTableEntry invoke mServiceMain, 0, 0 mServiceMain proc dwNU1:dword, dwNU2:dword ;Register service invoke RegisterServiceCtrlHandler, addr mServiceName, addr Handler mov hService, eax ; invoke RtlZeroMemory, status, sizeof.SERVICE_STATUS mov dwServiceType, SERVICE_WIN32_OWN_PROCESS mov dwCurrentState, SERVICE_RUNNING mov dwControlsAccepted, SERVICE_ACCEPT_SHUTDOWN mov dwWin32ExitCode, NO_ERROR invoke SetServiceStatus, hService, addr dwServiceType push 0 call GetModuleHandleA cmp eax,0 je errhandle mov diini,eax push 0 push offset lpdi push 0500h push diini call DirectInputCreateA@16 ;============================= ; Test for an error creating ;============================= .if eax != 0 jmp err .endif done: ;=================== ; Выполнено успешно ;=================== push 0 push offset titleprog push offset msbtxt1 push 0 call MessageBoxA ret err: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset dinputerr push 0 call MessageBoxA jmp exproc0 errhandle: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset msghandleerr push 0 call MessageBoxA exproc0: invoke ExitProcess, 0 ret mServiceMain endp Handler proc dwAction:dword cmp dwAction, SERVICE_CONTROL_SHUTDOWN jz exproc ret exproc: invoke ExitProcess, 0 ret Handler endp end main Параметры запуска в реестре: ErrorControl (1) ImagePath \??\C:\Program Files\Mkkm\Dinmouse.exe Start (2) Type (16) Ошибка: "Не удаётся найти указанный файл" Что я сделал не так? Переводил с TASM`а, а читал о создании служб на Делфи
Llirik Могу дать рабочий код на С from the book "Win32 System Services: The Heart of Windows NT" by Marshall Brain Выложить ? Там все структурно и достаточно популярно.
Ну тогда задай в гугле запрос типа - "invoke RegisterServiceCtrlHandler". Найдешь массу рабочих примеров, зуб даю
http://sheva740.narod.ru/c_services.rar pass for extracting: serv В vs c++ 6.0 собирается и прошу к экспериментированию Книгу ... надо порыться, но наверное меня тут накажут за такой порыв
Это всё хорошо, но почему Windows сообщает, что файл не найден, хотя он существует? Выходит, что дело даже до запуска не доходит?
Llirik ... вот вроде работает , только паузу, стоп, продолжить прикрути Код (Text): .686 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\advapi32.inc include \masm32\include\user32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\advapi32.lib includelib \masm32\lib\user32.lib LOAD MACRO dest, src mov eax, src mov dest, eax ENDM .data SERVICE_NAME BYTE "BeepService",0 sTable SERVICE_TABLE_ENTRY < 0, 0 > .code start: mov sTable.lpServiceProc, offset ServiceMain LOAD sTable.lpServiceName, offset SERVICE_NAME invoke StartServiceCtrlDispatcher, ADDR sTable invoke ExitProcess, eax ;------------------------------------------------------------ ;------------------------------------------------------------ Thread proc param:DWORD lop: invoke Beep, 1000,500 invoke Sleep, 1000 jmp lop xor eax, eax ret Thread endp ;------------------------------------------------------------ ;------------------------------------------------------------ SendStatus proc dwCurrentState:DWORD, dwWin32ExitCode:DWORD,dwServiceSpecificExitCode:DWORD, dwCheckPoint:DWORD,dwWaitHint:DWORD .data? hStatus DWORD ? sStatus SERVICE_STATUS <> .code mov sStatus.dwServiceType, SERVICE_WIN32_OWN_PROCESS LOAD sStatus.dwCurrentState, dwCurrentState mov sStatus.dwControlsAccepted, 0 .IF dwServiceSpecificExitCode == 0 LOAD sStatus.dwWin32ExitCode, dwWin32ExitCode .ELSE mov sStatus.dwWin32ExitCode, \ ERROR_SERVICE_SPECIFIC_ERROR .ENDIF LOAD sStatus.dwServiceSpecificExitCode, dwServiceSpecificExitCode LOAD sStatus.dwCheckPoint, dwCheckPoint LOAD sStatus.dwWaitHint, dwWaitHint invoke SetServiceStatus, hStatus, ADDR sStatus mov eax, 1 ret SendStatus endp ;------------------------------------------------------------ ;------------------------------------------------------------ SCHandler proc controlCode:DWORD ret SCHandler endp ;------------------------------------------------------------ ;------------------------------------------------------------ ServiceMain proc LOCAL hThreadID:DWORD .data hThread HANDLE NULL .code INVOKE RegisterServiceCtrlHandler, ADDR SERVICE_NAME,offset SCHandler mov hStatus, eax INVOKE SendStatus, SERVICE_START_PENDING, NO_ERROR, 0, 1, 5000 INVOKE SendStatus, SERVICE_START_PENDING, NO_ERROR, 0, 2, 1000 INVOKE SendStatus, SERVICE_START_PENDING, NO_ERROR, 0, 3, 5000 INVOKE CreateThread,0,0,ADDR Thread,0,0,ADDR hThreadID mov hThread, eax INVOKE SendStatus, SERVICE_RUNNING, NO_ERROR, 0, 0, 0 INVOKE WaitForSingleObject, hThread, INFINITE ret ServiceMain endp ;------------------------------------------------------------ ;------------------------------------------------------------ END START
Оказывается в реестре надо ещё прописать ObjectName LocalSystem, и моя служба запустилась) теперь вопрос другой. почему не работает это? Код (Text): .386p option casemap:none .model flat, stdcall includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib includelib C:\masm32\lib\gdi32.lib includelib C:\masm32\lib\advapi32.lib includelib C:\masm32\lib\dinput.lib includelib C:\masm32\lib\dxguid.lib includelib C:\masm32\lib\Uuid.Lib includelib C:\masm32\lib\oldnames.lib include C:\masm32\include\Windows.inc include C:\masm32\include\Kernel32.inc include C:\masm32\include\gdi32.inc include C:\masm32\include\advapi32.inc include C:\masm32\include\user32.inc include C:\masm32\include\dinput.inc include \masm32\Macros\Strings.mac mServiceMain PROTO STDCALL :DWORD, :DWORD Handler PROTO STDCALL :DWORD .const SERVICE_CONTROL_SHUTDOWN = 000000005h SERVICE_WIN32_OWN_PROCESS = 000000010h SERVICE_RUNNING = 000000004h SERVICE_ACCEPT_SHUTDOWN = 000000004h NO_ERROR = 000000000h .data dwServiceType dd ? dwCurrentState dd ? dwControlsAccepted dd ? dwWin32ExitCode dd ? dwServiceSpecificExitCode dd ? dwCheckPoint dd ? dwWaitHint dd ? mServiceTableEntry dd offset mServiceName, offset mServiceMain, 0, 0 diini dd ? hService dd ? lpdi LPDIRECTINPUT 0 xx dd 0 yy dd 0 ; ServiceStatus SERVICE_STATUS ? lpdimouse LPDIRECTINPUTDEVICE ? ; dinput mouse mouse_state DIMOUSESTATE <> ; contains state of mouse mServiceName db "Dinmouse",0 titleprog db "Иницилизация мыши",0 msbtxt1 db "Выполнено успешно",0 dinputerr db "Ошибка при иницилизации DirectInputCreate",0 msgmouseerr db "Ошибка при иницилизации мыши",0 msghandleerr db "Ошибка при получении хендла",0 sghandleerr db "Ошибка прYYYYYYYYYYYYYY",0 CorpLevel db "Ошибка CorpLevel",0 msgformaterr db "Ошибка Формата",0 FALSE equ 0 TRUE equ 1 .code main: call RegisterAndStartDriver invoke StartServiceCtrlDispatcher, addr mServiceTableEntry invoke mServiceMain, 0, 0 mServiceMain proc dwNU1:dword, dwNU2:dword ;Register service invoke RegisterServiceCtrlHandler, addr mServiceName, addr Handler mov hService, eax ; invoke RtlZeroMemory, status, sizeof.SERVICE_STATUS mov dwServiceType, SERVICE_WIN32_OWN_PROCESS mov dwCurrentState, SERVICE_RUNNING mov dwControlsAccepted, SERVICE_ACCEPT_SHUTDOWN mov dwWin32ExitCode, NO_ERROR invoke SetServiceStatus, hService, addr dwServiceType push 0 call GetModuleHandleA cmp eax,0 je errhandle mov diini,eax push 0 push offset lpdi push 0500h push diini call DirectInputCreateA .if eax != 0 jmp err .endif DIINVOKE CreateDevice, lpdi, ADDR GUID_SysMouse, ADDR lpdimouse, 0 ;============================ ; Test for an error creating ;============================ .if eax != DI_OK jmp errCm .endif ;========================== ; Set the coop level ;========================== ; DIDEVINVOKE SetCooperativeLevel, lpdimouse, 0, \ ; DISCL_NONEXCLUSIVE or DISCL_FOREGROUND ;============================ ; Test for an error querying ;============================ ; .if eax != DI_OK ;; jmp errco ; .endif ;========================== ; Set the data format ;========================== DIDEVINVOKE SetDataFormat, lpdimouse, ADDR c_dfDIMouse ;============================ ; Test for an error querying ;============================ .if eax != DI_OK jmp errfo .endif ; Выполнено успешно ;=================== ; push 0 ; push offset titleprog ; push offset msbtxt1 ; push 0 ; call MessageBoxA ret err: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset dinputerr push 0 call MessageBoxA jmp exproc0 ret errco: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset CorpLevel push 0 call MessageBoxA jmp exproc0 errfo: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset msgformaterr push 0 call MessageBoxA jmp exproc0 errCm: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset msgmouseerr push 0 call MessageBoxA jmp exproc0 errhandle: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset msghandleerr push 0 call MessageBoxA exproc0: invoke ExitProcess, 0 ret mServiceMain endp Handler proc dwAction:dword cmp dwAction, SERVICE_CONTROL_SHUTDOWN jz exproc cmp dwAction, SERVICE_CONTROL_STOP jz exproc push 0 push offset titleprog push offset sghandleerr push 0 call MessageBoxA DIDEVINVOKE GetDeviceState, lpdimouse, sizeof(DIMOUSESTATE), ADDR mouse_state ret exproc: invoke ExitProcess, 0 ret Handler endp RegisterAndStartDriver proc local hSCManager:HANDLE local hhService:HANDLE invoke OpenSCManager, NULL, NULL, SC_MANAGER_ALL_ACCESS mov hSCManager, eax invoke GetCommandLine invoke CreateService, hSCManager, $CTA0("Dinmouse"), $CTA0("Mouse DirectX"), \ SERVICE_START, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, \ SERVICE_ERROR_IGNORE, eax, NULL, NULL, NULL, NULL, NULL mov hhService, eax invoke StartService, hhService, 0, NULL invoke CloseServiceHandle, hhService invoke CloseServiceHandle, hSCManager ret RegisterAndStartDriver endp end main Ведь по идее постоянно должен выскакивать Messagebox, а этого не происходит
Или вот это почему Код (Text): .386p option casemap:none .model flat, stdcall includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib includelib C:\masm32\lib\gdi32.lib includelib C:\masm32\lib\advapi32.lib includelib C:\masm32\lib\dinput.lib includelib C:\masm32\lib\dxguid.lib includelib C:\masm32\lib\Uuid.Lib includelib C:\masm32\lib\oldnames.lib include C:\masm32\include\Windows.inc include C:\masm32\include\Kernel32.inc include C:\masm32\include\gdi32.inc include C:\masm32\include\advapi32.inc include C:\masm32\include\user32.inc extrn DirectInputCreateA@16:near ServiceControlHandler PROTO :DWORD MyFunction PROTO ServiceMain PROTO .DATA Message db "It worked ;-))",0 AppName db "Test",0 .DATA? startinfo STARTUPINFO <> secat SECURITY_ATTRIBUTES <> procinfo PROCESS_INFORMATION <> ServStat SERVICE_STATUS <> ServTable SERVICE_TABLE_ENTRY <> hServStat DWORD ? stopServiceEvent DWORD ? .CODE start: mov ServTable.lpServiceName,offset AppName mov ServTable.lpServiceProc,offset ServiceMain invoke StartServiceCtrlDispatcher,addr ServTable .IF eax==NULL invoke GetLastError .IF eax==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT invoke MyFunction .ENDIF .ELSE invoke ServiceMain .ENDIF invoke ExitProcess,0 ServiceMain PROC mov ServStat.dwServiceType,SERVICE_WIN32 ;mov ServStat.dwCurrentState,SERVICE_STOPPED mov ServStat.dwControlsAccepted,0 mov ServStat.dwWin32ExitCode,NO_ERROR mov ServStat.dwServiceSpecificExitCode,NO_ERROR mov ServStat.dwCheckPoint,0 mov ServStat.dwWaitHint,0 invoke RegisterServiceCtrlHandler,addr AppName,addr ServiceControlHandler mov hServStat,eax .IF eax!=NULL mov ServStat.dwCurrentState,SERVICE_START_PENDING invoke SetServiceStatus,hServStat,addr ServStat invoke CreateEvent,0,FALSE,FALSE,0 mov stopServiceEvent,eax mov ServStat.dwControlsAccepted,SERVICE_ACCEPT_STOP+SERVICE_ACCEPT_SHUTDOWN mov ServStat.dwCurrentState,SERVICE_RUNNING invoke SetServiceStatus,hServStat,addr ServStat ; invoke MyFunction mov ServStat.dwCurrentState,SERVICE_STOP_PENDING invoke SetServiceStatus,hServStat,addr ServStat invoke CloseHandle,stopServiceEvent mov stopServiceEvent,0 mov ServStat.dwControlsAccepted,SERVICE_ACCEPT_STOP+SERVICE_ACCEPT_SHUTDOWN mov ServStat.dwCurrentState,SERVICE_STOPPED invoke SetServiceStatus,hServStat,addr ServStat .ENDIF ret ServiceMain ENDP ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;The procedure to handle the service controls ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ServiceControlHandler PROC controlcode:DWORD invoke MessageBoxA,NULL,addr Message,addr AppName,MB_OK .IF controlcode==SERVICE_CONTROL_INTERROGATE jmp next .ELSEIF controlcode==SERVICE_CONTROL_SHUTDOWN || controlcode==SERVICE_CONTROL_STOP mov ServStat.dwCurrentState,SERVICE_STOP_PENDING invoke SetServiceStatus,addr hServStat,addr ServStat invoke SetEvent,addr stopServiceEvent ret .ELSEIF controlcode==SERVICE_CONTROL_PAUSE jmp next .ELSEIF controlcode==SERVICE_CONTROL_CONTINUE jmp next .ENDIF next: invoke SetServiceStatus,hServStat,addr ServStat ret ServiceControlHandler ENDP ;----------------------------------------------------- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;My function ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MyFunction PROC ret MyFunction ENDP ;----------------------------------------------------- end start
Llirik Вы что, тег Code не видите???? Исправьте все ваши сообщения использую тег "["code]" "[\code]" PS> кавычки тока уберите.
_sheva740, я написал код по Вашему примеру, но он почему-то тоже не работает( Код (Text): .386p option casemap:none .model flat, stdcall includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib includelib C:\masm32\lib\gdi32.lib includelib C:\masm32\lib\advapi32.lib includelib C:\masm32\lib\dinput.lib includelib C:\masm32\lib\dxguid.lib includelib C:\masm32\lib\Uuid.Lib includelib C:\masm32\lib\oldnames.lib include C:\masm32\include\Windows.inc include C:\masm32\include\Kernel32.inc include C:\masm32\include\gdi32.inc include C:\masm32\include\advapi32.inc include C:\masm32\include\user32.inc include C:\masm32\include\dinput.inc include \masm32\Macros\Strings.mac LOAD MACRO dest, src mov eax, src mov dest, eax ENDM .data sTable SERVICE_TABLE_ENTRY < 0, 0 > diini dd ? hService dd ? lpdi LPDIRECTINPUT 0 xx dd 0 yy dd 0 ServStat SERVICE_STATUS <> lpdimouse LPDIRECTINPUTDEVICE ? ; dinput mouse mouse_state DIMOUSESTATE <> ; contains state of mouse mServiceName db "Dinmouse",0 titleprog db "Иницилизация мыши",0 msbtxt1 db "Выполнено успешно",0 dinputerr db "Ошибка при иницилизации DirectInputCreate",0 msgmouseerr db "Ошибка при иницилизации мыши",0 msghandleerr db "Ошибка при получении хендла",0 sghandleerr db "Ошибка прYYYYYYYYYYYYYY",0 CorpLevel db "Ошибка CorpLevel",0 msgformaterr db "Ошибка Формата",0 FALSE equ 0 TRUE equ 1 .code main: mov sTable.lpServiceProc, offset mServiceMain LOAD sTable.lpServiceName, offset mServiceName invoke StartServiceCtrlDispatcher, ADDR sTable invoke ExitProcess, eax sHandler proc dwAction:dword cmp dwAction, SERVICE_CONTROL_SHUTDOWN jz exproc cmp dwAction, SERVICE_CONTROL_STOP jz exproc push 0 push offset titleprog push offset sghandleerr push 0 call MessageBoxA DIDEVINVOKE GetDeviceState, lpdimouse, sizeof(DIMOUSESTATE), ADDR mouse_state ret exproc: invoke ExitProcess, 0 ret sHandler endp mServiceMain proc ;dwNU1:dword, dwNU2:dword ;Register service invoke RegisterServiceCtrlHandler, addr mServiceName, offset sHandler mov hService, eax ; invoke RtlZeroMemory, status, sizeof.SERVICE_STATUS mov ServStat.dwServiceType, SERVICE_WIN32_OWN_PROCESS mov ServStat.dwCurrentState, SERVICE_RUNNING mov ServStat.dwControlsAccepted, SERVICE_ACCEPT_SHUTDOWN mov ServStat.dwWin32ExitCode, NO_ERROR invoke SetServiceStatus, hService, addr ServStat push 0 call GetModuleHandleA cmp eax,0 je errhandle mov diini,eax push 0 push offset lpdi push 0500h push diini call DirectInputCreateA .if eax != 0 jmp err .endif DIINVOKE CreateDevice, lpdi, ADDR GUID_SysMouse, ADDR lpdimouse, 0 ;============================ ; Test for an error creating ;============================ .if eax != DI_OK jmp errCm .endif ;========================== ; Set the coop level ;========================== ; DIDEVINVOKE SetCooperativeLevel, lpdimouse, 0, \ ; DISCL_NONEXCLUSIVE or DISCL_FOREGROUND ;============================ ; Test for an error querying ;============================ ; .if eax != DI_OK ;; jmp errco ; .endif ;========================== ; Set the data format ;========================== DIDEVINVOKE SetDataFormat, lpdimouse, ADDR c_dfDIMouse ;============================ ; Test for an error querying ;============================ .if eax != DI_OK jmp errfo .endif ; Выполнено успешно ;=================== push 0 push offset titleprog push offset msbtxt1 push 0 call MessageBoxA ret err: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset dinputerr push 0 call MessageBoxA jmp exproc0 ret errco: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset CorpLevel push 0 call MessageBoxA jmp exproc0 errfo: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset msgformaterr push 0 call MessageBoxA jmp exproc0 errCm: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset msgmouseerr push 0 call MessageBoxA jmp exproc0 errhandle: ;=================== ; Вывести сообщение об ошибке ;=================== push 0 push offset titleprog push offset msghandleerr push 0 call MessageBoxA exproc0: invoke ExitProcess, 0 ret mServiceMain endp end main
Со службами я кажется разобрался. Вот мой пример Код (Text): .386p option casemap:none .model flat, stdcall includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib includelib C:\masm32\lib\gdi32.lib includelib C:\masm32\lib\advapi32.lib includelib C:\masm32\lib\dinput.lib includelib C:\masm32\lib\dxguid.lib includelib C:\masm32\lib\Uuid.Lib includelib C:\masm32\lib\oldnames.lib include C:\masm32\include\Windows.inc include C:\masm32\include\Kernel32.inc include C:\masm32\include\gdi32.inc include C:\masm32\include\advapi32.inc include C:\masm32\include\user32.inc extrn DirectInputCreateA@16:near mServiceMain PROTO STDCALL :DWORD, :DWORD Handler PROTO STDCALL :DWORD .data mServiceTableEntry dd offset mServiceName, offset mServiceMain, 0, 0 diini dd ? hService dd ? hThread HANDLE NULL lpdi dd 0 ServStat SERVICE_STATUS <> mServiceName db "Dinmouse",0 titleprog db "Иницилизация мыши",0 msbtxt1 db "Выполнено успешно",0 dinputerr db "Ошибка при иницилизации DirectInputCreate",0 msgmouseerr db "Ошибка при иницилизации мыши",0 msghandleerr db "Ошибка при получении хендла",0 FALSE equ 0 TRUE equ 1 .code main: invoke StartServiceCtrlDispatcher, addr mServiceTableEntry invoke ExitProcess,0 Handler proc dwAction:dword cmp dwAction, SERVICE_CONTROL_SHUTDOWN jz exproc cmp dwAction, SERVICE_CONTROL_STOP jz exproc ;;DIDEVINVOKE GetDeviceState, lpdimouse, sizeof(DIMOUSESTATE), ADDR mouse_state invoke mouse_event, MOUSEEVENTF_MOVE, 100, 100, NULL, NULL ret exproc: mov ServStat.dwCurrentState,SERVICE_STOPPED mov ServStat.dwWin32ExitCode,0 mov ServStat.dwCheckPoint,0 mov ServStat.dwWaitHint,0 invoke SetServiceStatus, hService, addr ServStat ret Handler endp mServiceMain proc dwNU1:dword, dwNU2:dword LOCAL hThreadID:DWORD ;Register service invoke RegisterServiceCtrlHandler, addr mServiceName, addr Handler mov hService, eax mov ServStat.dwServiceType,SERVICE_WIN32 ;mov ServStat.dwCurrentState,SERVICE_STOPPED mov ServStat.dwControlsAccepted,SERVICE_ACCEPT_STOP+SERVICE_ACCEPT_SHUTDOWN mov ServStat.dwWin32ExitCode,NO_ERROR mov ServStat.dwServiceSpecificExitCode,NO_ERROR mov ServStat.dwCheckPoint,0 mov ServStat.dwWaitHint,0 .IF eax!=NULL mov ServStat.dwCurrentState,SERVICE_RUNNING invoke SetServiceStatus, hService, addr ServStat ;call mServiceMy .endif Ret mServiceMain endp end main Только остался вопрос. Почему некоторые API например, как mouse_event, в службах не желают работать?? Я уж пытался и Тред с ней сделать. всё-равно не работает(
Llirik Ну тут ты прав. Я вот заметил что из под сервиса не работают просто некоторые функции-клиенты для COM компонентов, мож поможет и в твоем случае? http://www.wasm.ru/forum/viewtopic.php?id=39247 Мне , если либ нужных не найду придется на сокетах все переписавать (((