By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,567 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

Help: Window Service App Error - Need Win Service Expert Help

P: n/a
Van
Developing in C++, .Net 2003 (7.1)
Running on Windows XP SP2

My delima is that all my windows services run fine until I STOP the service
at which time I get a "The windows service terminated unexpectidly" and the
"Send error to microsoft window." I debugged through MY code and it appears
to clean itself up properly. I don't see any memory leaks. The error occurs
after my ServiceMain exits. I can't debug any further as it appears to be in
the kernel.dll.

Is there something special (not disclosed in the docs or examples) that I
must do to keep this from happening?

Here is the last lines of my ServiceMain:

// Report our status one last time.
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCheckPoint += 1;
ServiceStatus.dwWaitHint = 0;
SetServiceStatus(hStatus, &ServiceStatus);
} // ServiceMain

And here is the message from the EventLog:

Faulting application OSSExecute.EXE, version 0.0.0.0, faulting module
unknown, version 0.0.0.0, fault address 0x0012e7dc.

This is really annoying me as I can't figure out what the cause is.... Any
help would be appreciated.

Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Van
FYI for those who find this post later.

The problem was my 'ServiceMain' function was *NOT* using the Windows API
calling convention. The MSDN documentation does show the calling convention
syntax however, the MSDN example (the one I have anyways) does NOT show using
the Windows API calling convention.

I had to change my ServiceMain function declaration from:

void ServiceMain(int argc, char* argv[])

to

VOID WINAPI ServiceMain(DWORD argc, LPSTR* argv)

and that fixed my problem.

Explaination (as it was told to me):

The calling method of 'void ServiceMain' is '__cdecl' and it does not clean
up on its own and thus was corrupting the stacks.
"Van" wrote:
Developing in C++, .Net 2003 (7.1)
Running on Windows XP SP2

My delima is that all my windows services run fine until I STOP the service
at which time I get a "The windows service terminated unexpectidly" and the
"Send error to microsoft window." I debugged through MY code and it appears
to clean itself up properly. I don't see any memory leaks. The error occurs
after my ServiceMain exits. I can't debug any further as it appears to be in
the kernel.dll.

Is there something special (not disclosed in the docs or examples) that I
must do to keep this from happening?

Here is the last lines of my ServiceMain:

// Report our status one last time.
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCheckPoint += 1;
ServiceStatus.dwWaitHint = 0;
SetServiceStatus(hStatus, &ServiceStatus);
} // ServiceMain

And here is the message from the EventLog:

Faulting application OSSExecute.EXE, version 0.0.0.0, faulting module
unknown, version 0.0.0.0, fault address 0x0012e7dc.

This is really annoying me as I can't figure out what the cause is.... Any
help would be appreciated.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.