Home » Community » Forums » » Creating a Windows NT/2000/XP Service
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Creating a Windows NT/2000/XP Service
Post Reply 
Hey Dean, excellent article!

Don't have a computer with MSVC, etc, accessible, so I can't test anything, but I do have one quick question. There's a Win32 API called ServiceMain, right? How does that factor in the mix? And all the calls in the article, where exactly are they made (are they inside the ServiceMain, at global scope...)?

Thanks a ton.

P.S. I should send you some ARMS-type email soon, once I get a prototype of something related to those Next Generation Computing threads up.

 User Rating: 2027   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Wow, I wrote this article sooo long ago

ServiceMain is the name of a placeholder function which you define and pass to StartServiceCtrlDispatcher. I called it ServiceDispatch in the article.

All the functions are called from the regular main (or WinMain - it doesn't matter if it's a console app or a Windows app) function.

There's nothing special about a service, it just has to call a few extra methods when it starts to update it's status in the service control manager...

Looking forward to the ARMS stuff I've been looking into diff-like algorithms lately, something which would be useful for ARMS (though I'd probably prefer a 3rd-party diff tool - I just can't find one that I like, which is GPL or otherwise free )

If I had my way, I'd have all of you shot!


codeka.com - Just click it.

 User Rating: 1297   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

One thing that would have been useful to mention: any service running on the settings you've detailed and which has an associated GUI is a serious security risk via the WM_TIMER route.

For example, until the security patches, RunAs had this problem.

ld

 User Rating: 1139   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Good article Dean! I wish GameDev would have posted it a little earlier, as I had the task of converting our server into a service just last week. This would have made my job a little easier .

One thing you could have mentioned, however, is how to allow the service to log error messages to the Windows Event Log.


- Houdini

 User Rating: 1111   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Perhaps you should write an add-on. ;-)

Bosso

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by liquiddark
One thing that would have been useful to mention: any service running on the settings you've detailed and which has an associated GUI is a serious security risk via the WM_TIMER route.



Yes, but I mentioned running in interactive mode only for debugging (so you can see popups and such). Besides, I wrote the article before that vulnerability was known about

For anyone who is interested, here's the microsoft article which talks about this vulnerability.

If I had my way, I'd have all of you shot!


codeka.com - Just click it.

[edited by - Dean Harding on March 21, 2003 5:32:50 PM]

 User Rating: 1297   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Very good service framework (much more detailed than presented one in this article) can be found on here.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

It's a great article. Very instructive and easy to learn..

Good work!!!!

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Talk about spewing MSDN documentation! If you're going to write an article, please be somewhat original. I know developing services is really quite simple once you get into it but come on. I expect articles to have more 'meat' than MSDN and this one failed miserably.

Granted, it did provide service implementation in a more condensed form but I find that the ATL Service Wizard to be highly effective in creating the basics of a service.


 User Rating: 1074   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Thanks for the great tutorial,

but I have a question, I am trying to define a pure virtual function in the basic template to force any derived classes into some kind of standardised usage. but I get an error as saying this is not possible.

Can this be done?

error

Main.cpp
C:\ShadowMgr\ServiceMgr\Main.cpp(8) : error C2259: 'CService' : cannot instantiate abstract class due to following members:
c:\shadowmgr\servicemgr\service.h(13) : see declaration of 'CService'
C:\ShadowMgr\ServiceMgr\Main.cpp(8) : warning C4259: 'bool __thiscall CService::RunTest(void)' : pure virtual function was not defined
c:\shadowmgr\servicemgr\service.h(38) : see declaration of 'RunTest'

Thanks in advanced

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: