Re: Service Auto Start Problems in PPC2003

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: John Spaith [MS] (jspaith_at_ONLINE.microsoft.com)
Date: 11/30/04


Date: Tue, 30 Nov 2004 13:21:22 -0800

Hmm... this is the first I've ever heard of this problem. On a CE 5 image I
just created a service with a 43 character key length (not counting
"HKLM\Services" gunk) and it loaded just fine for me at init. I'm still
baffled by your problem.

Sorry you had to spend so many cycles on this. If I hear of problems like
this in the future, at least we have another thing for them to look into.

-- 
John Spaith
Software Design Engineer, Windows CE
Microsoft Corporation
Check out the new CE Networking Team Blog at http://blogs.msdn.com/cenet/.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2003 Microsoft Corporation. All rights 
reserved.
"Jeremy T." <JeremyT@discussions.microsoft.com> wrote in message 
news:2C6CCEE5-2D72-48C7-A479-A576A431F461@microsoft.com...
> Well I finally figured out the problem with why the service would not 
> start
> automatically. It appears that there is some sort of limitation somewhere 
> on
> the size of the key names under the services folder in the registry. My 
> key
> name was 18 characters long, which isn't a short name, but I knew of no
> limitation and in all my research I have never found any documentation 
> that
> would indicate there was one. When I shortened the key name to 3 to 5
> characters it always started up without issue. I didn't test to see what 
> the
> maximum key size was but it is definitely less then 18 characters.
>
> Jeremy T.
>
> "John Spaith [MS]" wrote:
>
>> Honest, we do reuse code at Microsoft :) and all services.exe does on
>> startup is call ActivateService() on a bunch of registry keys under
>> HKLM\Services.  So this is a hard case.
>>
>> Just so I understand - this skeleton service that you pasted below won't
>> startup at all?  It doesn't matter what you do in it?  If this is the 
>> case,
>> my thoughts keep drifting back to something being strange with the
>> platform/filesystem on boot.  I'm wondering if you could move a log 
>> report
>> to your DllMain() and not just the xxx_Init()?  To make sure it gets 
>> written
>> out to the log, call fflush(NULL) (I hope this is supported on PPC
>> platform!).  Also add fflush() to your xxx_Init() just in case something 
>> is
>> crashing at some stage.
>>
>> Another thought is maybe you're doing something strange in your DllMain()
>> that's failing at bootup.  Maybe you're trying to access some file or
>> service that isn't ready because the system isn't booted far enough.  If
>> your DllMain() returned FALSE, then your xxx_Init() will never get called
>> and your service would be unloaded immediadetly.  When you 
>> ActivateService()
>> later on, then whatever system stuff is running is ready and your 
>> DllMain()
>> returns TRUE.
>>
>> If all this fails, try it on another PocketPC device.
>>
>> Let me know how all this goes.
>>
>> -- 
>> John Spaith
>> Software Design Engineer, Windows CE
>> Microsoft Corporation
>>
>> Check out the new CE Networking Team Blog at 
>> http://blogs.msdn.com/cenet/.
>>
>> This posting is provided "AS IS" with no warranties, and confers no 
>> rights.
>> You assume all risk for your use. © 2003 Microsoft Corporation. All 
>> rights
>> reserved.
>>
>> "Jeremy T." <JeremyT@discussions.microsoft.com> wrote in message
>> news:EF54CA61-D75C-4139-90DF-F5DBD1C1BBDB@microsoft.com...
>> >I can clarify a few points for you. The serivce's name isn't actually 
>> >"My
>> > Service.dll", I just used that name to protect the innocent. The real 
>> > name
>> > has no spaces in it.
>> >
>> > Let me tell you a little about what it does and then maybe that will 
>> > give
>> > you some clues. The service is primarily used as a form of ipc for 
>> > sending
>> > and receiving data through a serial interface. The service in its init
>> > function calls another function that starts two threads that each
>> > respectively setup invisible windows that have their own message pumps
>> > that
>> > sit and listen for windows messages and at times send them.
>> >
>> > I don't think this specific functionality should inhibit the service 
>> > from
>> > starting though. Because as I said I can use activateservice and it 
>> > works
>> > fine. Inside the init function I have a logging statement that logs if 
>> > the
>> > method is entered at all. Nothing shows up on startup but when I do the
>> > activateservice call the logging also works. The logging method I use 
>> > will
>> > work even if the program crashes in my experience as long as the log
>> > statements are before the line that crashes. But there is nothing on
>> > startup
>> > so I'm thinking that init is never called. Thanks again for all your 
>> > help.
>> > It
>> > really seems bizarre to me that it doesn't work given activateservice's
>> > realiability.
>> >
>> > Jeremy T.
>> >
>> > "John Spaith [MS]" wrote:
>> >
>> >> You've stumped the guy that wrote services.exe :(.  I built your DLL 
>> >> and
>> >> used your registry settings and they loaded fine for me on startup. 
>> >> I'm
>> >> on
>> >> a different OS version and platform than you, so there must be some 
>> >> weird
>> >> difference here at PPC bootup.  But again, I don't see what that could
>> >> possibly be.
>> >>
>> >> Here's some ideas to try and get this working.
>> >> (1) Rename your DLL "MyService.dll" instead of "My Service.dll". 
>> >> Maybe
>> >> the
>> >> space is causing something weird to happen??
>> >>
>> >> (2) Go talk with your buddy who has his service working, copy and 
>> >> paste
>> >> it
>> >> and his reg settings, and only change the bare minimum of what you 
>> >> have
>> >> to
>> >> in order to get this working.
>> >>
>> >> If you ever have some flash of insight as to what's going wrong here
>> >> please
>> >> post to the newsgroup.  There's oodles of services out there and this 
>> >> is
>> >> the
>> >> first time I've ever heard of what you're seeing happening.  Sorry I
>> >> can't
>> >> give you a better answer here.
>> >>
>> >> -- 
>> >> John Spaith
>> >> Software Design Engineer, Windows CE
>> >> Microsoft Corporation
>> >>
>> >> Check out the new CE Networking Team Blog at
>> >> http://blogs.msdn.com/cenet/.
>> >>
>> >> This posting is provided "AS IS" with no warranties, and confers no
>> >> rights.
>> >> You assume all risk for your use. © 2003 Microsoft Corporation. All
>> >> rights
>> >> reserved.
>> >>
>> >> "Jeremy T." <JeremyT@discussions.microsoft.com> wrote in message
>> >> news:E380E9DE-D2A2-4583-82F5-B54310BC4AE5@microsoft.com...
>> >> > The dll is definately in the windows dir. Yes it is PPC 2003 on a
>> >> > siemens
>> >> > sx56 and hp 6132 I think is the number. The odd thing is, is a
>> >> > co-worker
>> >> > also
>> >> > has a service but his will auto start we've compared our services 
>> >> > and
>> >> > they
>> >> > seem identical. The thing that is baffling to me is ActivateService
>> >> > works
>> >> > which goes off the settings in the registry. Any input you have will
>> >> > help,
>> >> > thanks.
>> >> >
>> >> > "John Spaith [MS]" wrote:
>> >> >
>> >> >> Hmm... this is very strange.  Is your service DLL in the \windows
>> >> >> directory,
>> >> >> or is it by any chance on a storage card or on some other 
>> >> >> filesystem?
>> >> >> It's
>> >> >> possible that a storage card filesystem will be slow in starting up
>> >> >> and
>> >> >> that
>> >> >> when services.exe initializes and tries to load your service, the
>> >> >> underlying
>> >> >> filesystem isn't around yet.  When you ActivateService later on, 
>> >> >> then
>> >> >> the
>> >> >> filesystem is up.
>> >> >>
>> >> >> Also I want to confirm this is on a PocketPC 2003, correct?  Some 
>> >> >> 3rd
>> >> >> party
>> >> >> guys managed to emulate services.exe on pre-2003 devices, and while 
>> >> >> I
>> >> >> think
>> >> >> that's very cool it's not something I can support :).
>> >> >>
>> >> >> -- 
>> >> >> John Spaith
>> >> >> Software Design Engineer, Windows CE
>> >> >> Microsoft Corporation
>> >> >>
>> >> >> Check out the new CE Networking Team Blog at
>> >> >> http://blogs.msdn.com/cenet/.
>> >> >>
>> >> >> This posting is provided "AS IS" with no warranties, and confers no
>> >> >> rights.
>> >> >> You assume all risk for your use. © 2003 Microsoft Corporation. All
>> >> >> rights
>> >> >> reserved.
>> >> >>
>> >> >> "Jeremy T." <JeremyT@discussions.microsoft.com> wrote in message
>> >> >> news:3577DF90-B304-4FBE-BCF1-829B73F29541@microsoft.com...
>> >> >> >I cannot get my service to load automatically on startup. I can 
>> >> >> >load
>> >> >> >it
>> >> >> > manually using either registerservice or activateservice and I 
>> >> >> > can
>> >> >> > successfully unload it with deregister service. The service works
>> >> >> > great
>> >> >> > when
>> >> >> > I manually load it but not otherwise.  Here is my basic service 
>> >> >> > code
>> >> >> > below:
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) DWORD ADD_Close(DWORD dwData)
>> >> >> > {
>> >> >> >    return 0;
>> >> >> > }
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service. Called on destruction of the 
>> >> >> > service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) BOOL ADD_Deinit(DWORD dwData)
>> >> >> > {
>> >> >> > //basic unload code
>> >> >> > return 1;
>> >> >> > }
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service. Called on initialization of the
>> >> >> > service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) DWORD ADD_Init(DWORD dwData)
>> >> >> > {
>> >> >> > //very minimal startup here
>> >> >> > return 1;
>> >> >> > }
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) DWORD ADD_IOControl(
>> >> >> >   DWORD dwData,
>> >> >> >   DWORD dwCode,
>> >> >> >   PBYTE pBufIn,
>> >> >> >   DWORD dwLenIn,
>> >> >> >   PBYTE pBufOut,
>> >> >> >   DWORD dwLenOut,
>> >> >> >   PDWORD pdwActualOut)
>> >> >> > {
>> >> >> >
>> >> >> >    return 1;
>> >> >> > }
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) DWORD ADD_Open(
>> >> >> >   DWORD dwData,
>> >> >> >   DWORD dwAccess,
>> >> >> >   DWORD dwShareMode)
>> >> >> > {
>> >> >> >    return 0;
>> >> >> > }
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) DWORD ADD_Read(
>> >> >> >   DWORD dwData,
>> >> >> >   LPVOID pBuf,
>> >> >> >   DWORD dwLen)
>> >> >> > {
>> >> >> >
>> >> >> >    return 0;
>> >> >> > }
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) DWORD ADD_Seek(
>> >> >> >   DWORD dwData,
>> >> >> >   long pos,
>> >> >> >   DWORD type)
>> >> >> > {
>> >> >> >
>> >> >> >    return 0;
>> >> >> > }
>> >> >> >
>> >> >> > /**
>> >> >> > * Required method by service.
>> >> >> > */
>> >> >> > extern "C" __declspec(dllexport) DWORD ADD_Write(
>> >> >> >   DWORD dwData,
>> >> >> >   LPCVOID pInBuf,
>> >> >> >   DWORD dwInLen)
>> >> >> > {
>> >> >> >
>> >> >> >    return 0;
>> >> >> > }
>> >> >> >
>> >> >> > Here is the basic registry settings that correspond:
>> >> >> >
>> >> >> > in HKEY_LOCAL_MACHINE\Services\MyService
>> >> >> > DWORD Order = 10 (also tried it at 8)
>> >> >> > DWORD Flags = 0
>> >> >> > String Description = My Service
>> >> >> > String Display Name = My ServiceName
>> >> >> > DWORD Context = 0
>> >> >> > DWORD Index = 0
>> >> >> > String Prefix = ADD
>> >> >> > DWORD Keep = 1
>> >> >> > String Dll = My Service.dll
>> >> >> > -- 
>> >> >> > Jeremy T.
>> >> >> > Software Engineer
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>> 


Relevant Pages

  • Re: Services in WM5.0 - PLEASE, HELP!!!
    ... Microsoft Corporation ... This posting is provided "AS IS" with no warranties, and confers no rights. ... I've tryed using ActivateService, RegisterService and GetServiceHandle ... The registry entry actually exists at the very moment I try any of those ...
    (microsoft.public.pocketpc.developer)
  • Re: Using COM OutProc server on WinCE
    ... Microsoft Corporation ... This posting is provided "AS IS" with no warranties, and confers no rights. ... inproc server should be OK on WM5.0 ... nk.exe (kernel process) and you can't popup UI from nk.exe in CE 6.0. ...
    (microsoft.public.windowsce.app.development)
  • Error when I try to watch online movie or TV programs.
    ... PRODUCT_NAME="Microsoft® Windows® Operating System" ... LEGAL_COPYRIGHT="© Microsoft Corporation. ... All rights ... Apple Computer, Inc. 1992-2004" VERFILEDATEHI="0x0" ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • IE Error every time I close it. Please Help!!!
    ... PRODUCT_NAME="Microsoft® Windows® Operating System" ... LEGAL_COPYRIGHT="© Microsoft Corporation. ... All rights ... PRODUCT_NAME="QuickTime Plug-in 6.0.2" ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Inter Application Communication in WinCE
    ... Microsoft Corporation ... This posting is provided "AS IS" with no warranties, and confers no rights. ... A memory mapped file + named event would be the best ... communication is recommended? ...
    (microsoft.public.windowsce.embedded.vc)