Форум программистов «Весельчак У»
  *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

  • Рекомендуем проверить настройки временной зоны в вашем профиле (страница "Внешний вид форума", пункт "Часовой пояс:").
  • У нас больше нет рассылок. Если вам приходят письма от наших бывших рассылок mail.ru и subscribe.ru, то знайте, что это не мы рассылаем.
   Начало  
Наши сайты
Помощь Поиск Календарь Почта Войти Регистрация  
 
Страниц: [1]   Вниз
  Печать  
Автор Тема: Системные сервисы  (Прочитано 15618 раз)
0 Пользователей и 1 Гость смотрят эту тему.
Helium
Гость
« : 31-10-2003 19:52 » 

:?: У кого нить есть опыт написания системных сервисов под WinNT?
Хотелось бы перенять сей ценный опыт или разжиться документацией, або сцылками. Отлично
Записан
maaaaaad
Гость
« Ответ #1 : 01-11-2003 06:01 » 

читай книжку программирование серверных приложений, там это самая интересная тема. Раелизация сервиса, приведенного там совешенно дурацкая (реализованна через 2 класса) поэтому самому придется все переделать (если конечно понять захочешь) ....я переделал.......Кроме того там поставлены ПРОБЛЕМЫ разработки, которые там достаточно серьезные (синхронизация диспечера и выполняемого потока).......рекомендую не юзать НИКАКИХ КЛАССОВ и НЕ ИСПОЛЬЗОВАТЬ никаких примеров (которых в нете я встречал ооочень много)........потому что....сакс  Отлично  :oops:
Записан
Helium
Гость
« Ответ #2 : 02-11-2003 10:24 » 

А в электронном виде она (эта книжка) есть?
Записан
maaaaaad
Гость
« Ответ #3 : 02-11-2003 11:53 » 

Есть на англицком - PrgServer-SideApps.chm 5.56mb
Есть на русском в книжном, синенькая такая с рихтером в гравной роли ~ 200ре

Еще есть статьи написанные по этой книжке на www.rsdn.ru, но как я сказал этими классами рекомендую не пользоваться. (тама вроде одна часть, вторую предлагают купить за $$ - агсл нщг, агслштп црщку!!! )

на соурсах и на кодепрожект помойму видал несколько примеров сервисов....
Записан
Helium
Гость
« Ответ #4 : 02-11-2003 21:45 » 

Все нашел. Бальшое пасибо. Отлично  Буду изучать и пробовать...
Записан
Diletant
Помогающий

de
Offline Offline

« Ответ #5 : 06-11-2003 13:04 » 

IMHO, серверная книга Рихтера - далеко не лучшая по данной теме. Лучше поискать в сети книгу Marshal Brain, Ron Reeves "Win32 System Services: The Heart of Windows® 98 and Windows® 2000." Гораздо понятнее и короче изложено. И примеры вполне работоспособны.
Записан
Diletant
Помогающий

de
Offline Offline

« Ответ #6 : 06-11-2003 15:24 » 

Кстати, а почему тему переместили в Драйвера? Системный сервис отнюдь не обязан быть драйвером.
Записан
Гром
Птычк. Тьфу, птычник... Вот!
Готовлюсь к пенсии

il
Offline Offline
Пол: Мужской
Бодрый птах


« Ответ #7 : 06-11-2003 16:37 » 

Diletant, ИМХО - здесь быстрее будут ответы, чем в других форумах - к этой теме он ближе...
Записан

А птичку нашу прошу не обижать!!!
Helium
Гость
« Ответ #8 : 07-11-2003 07:29 » 

Цитата

Marshal Brain, Ron Reeves "Win32 System Services: The Heart of Windows® 98 and Windows® 2000." Гораздо понятнее и короче изложено

Ну не знаю. Помоему, Рихтер очень даже ничего пишет. Во всяком случае про сервисы вполне даже прилично изложено.
В любом случае за указание книги пасибо.
Записан
Helium
Гость
« Ответ #9 : 07-11-2003 18:45 » 

Счас, конечно же, прозвучит глупый вопрос  :oops: , так что тем, кто был обо мне хорошего мнения лучше его не читать.
 :?: Из-за чего мой сервис не хочет запускаться из-под отладчика ?
В умных книжках написано, что такой фокус не пройдет, а почему - нет. Это все из-за оконной станции, ДА?
Записан
SlavaI
Главный специалист

ru
Offline Offline

« Ответ #10 : 10-11-2003 06:16 » 

Цитата

В умных книжках написано, что такой фокус не пройдет, а почему - нет. Это все из-за оконной станции, ДА?


Нет. У Рихтера и Кларка написано почему. Вот тебе описание из Рихтера & Кларка, раздел Debugging a Service. Внимательнее надо читать книжку.

Debugging a service is a bit more tricky than debugging a normal application for several reasons. First, the debugger cannot start the service; the SCM must start the service. Second, many services start before a user logs on to the machine. For this reason, setting an automatic service to manual while you're debugging it is a good idea. Third, services run in their own window station and desktop, which is not visible to an interactive user.

So how can you debug a service? The best way is to run it as a regular executable instead of as a service. Inside your service's (w)main or (w)WinMain function, check for a special command-line switch of your own devising and, if this switch is present, call your service's ServiceMain function directly instead of calling StartServiceCtrlDispatcher. This technique, of course, has several disadvantages:


If your executable contains several services, you can debug only one service at a time.


The executable is running under your (the interactive user's) account instead of the account that the SCM would have used. This might restrict access to resources that normally would be granted.


You cannot send pause, continue, stop, shut down, or any user-defined notifications to the service, prohibiting the testing of the execution paths.

The approach just described makes debugging your service very easy, but a better approach is to connect a debugger to the service while the service is running. Most debuggers offer the ability to connect to a process while it is running. If you already have a debugger installed on your system, you can open the Task Manager, right-click on the service's process name, and select the Debug option from the context menu. This spawns the debugger and attaches it to your service. You can now set breakpoints, debug the service code, and even test how your service responds to control notifications. Here are a few problems with connecting the debugger to the service:


The account you've used to log on to the system must have the debug privilege granted. By default, this privilege is granted to administrators only. If you are logged on as Power User or some other account, you must have an administrator grant you the debug privilege.


You won't be able to debug your initialization code because the debugger will connect after the service is up and running.

If you really want to use this approach to debug your service's initialization code, you can do it easily enough by simply adding a call to the DebugBreak function inside your (w)main or (w)WinMain function. However, this technique works only if your service runs under the LocalSystem account. If you run your service under a different user account, your debugger will not work properly because the system won't allow it to interact with the interactive window station and desktop.

Here is another technique you can use to debug a service: Windows offers the ability to invoke a debugger whenever a process starts. To have the system do this, you must first create a subkey under the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\
   CurrentVersion\Image File Execution Options

 


Under this key, create a subkey that is the name of your service's executable (without the path). In the executable name subkey, add a string value whose name is Debugger, and set this value equal to the full pathname of your debugger (for example, "C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\msdev.exe").

Once you have all this set up, you can go to the Services snap-in and start the service. The SCM will launch the debugger instead of the service executable. At this point, open your source code file, set breakpoints, and then let the service go. Note that you will have just 30 seconds to do this before the SCM forcibly terminates the debugger (since the service will not have called StartServiceCtrlDispatcher).

If all of these limitations are bothering you, and you want to be able to debug the service in its most natural environment without having to interact with the desktop or worry about which user account the service is logged on to, you can use a kernel debugger.
Записан
SlavaI
Главный специалист

ru
Offline Offline

« Ответ #11 : 10-11-2003 06:17 » 

Чтобы отладить код сервиса сделай возможным его запуск как простого пользовательского приложения- тут только не отладить взаимодействие с SCM, но все остальное можно отладить. В примере у Рихтера и Кларка так и сделано.
Записан
Helium
Гость
« Ответ #12 : 10-11-2003 12:27 » 

Ну и я так же делал. Но это в моем случае не оччень удобно.
Да, ключевую фразу я пропустил
 :arrow: the SCM must start the service
Типа УПС :?  :oops:
Записан
Страниц: [1]   Вверх
  Печать  
 

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines