StartService API failing with Error 2

Hi!
I am a newbie to writing drivers. So i started with a NT style KernelMode
Driver. I followed some MS articles on how to load this driver using SCM.

I followed the following code sequence…

bool CDriverInstall::InstallDriver ()
{
SC_HANDLE hSCMService = NULL;
SERVICE_STATUS status;
DWORD dwError = 0;

::CloseServiceHandle (m_hSCMHandle);

m_hSCMHandle = ::OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);

// Create the service.
hSCMService = ::CreateService (
m_hSCMHandle, // Handle To SCM
m_strDriverName, // Name of service to start
m_strDriverName, // Display name
SERVICE_ALL_ACCESS, // Access rights
SERVICE_KERNEL_DRIVER,// Type of service
SERVICE_DEMAND_START, // Mode of start
// SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, // Severity of error failure
m_strDriverFilePath, // Binary path name
NULL, // Load ordering group
NULL, // Tag identifier
NULL, // Dependencies
NULL, // LocalSystem account
NULL // Password
);

if (NULL == hSCMService)
{
TRACE (_T (“Failed to create service - %s in SCM\n”), m_strDriverName);
return false;
}

if (0 == ::StartService (hSCMService, 0, NULL))
{
dwError = ::GetLastError ();
if (dwError == ERROR_PATH_NOT_FOUND)
{
TRACE (_T (“Path not found\n”));
}

if (dwError == ERROR_INVALID_HANDLE)
{
TRACE (_T (“Invalid handle\n”));
}

if (dwError == ERROR_SERVICE_DISABLED)
{
TRACE (_T (“Service Disabled\n”));
}

if (dwError == ERROR_ACCESS_DENIED)
{
TRACE (_T (“Access denied\n”));
}

}

Sleep (1000);

int nTries = 0;
while (true)
{
if (::QueryServiceStatus (hSCMService, &status))
{
if (status.dwCurrentState == SERVICE_RUNNING)
{
break;
}

nTries++;
Sleep (1000);
if (nTries > 5)
{
break;
}
}
else
{
break;
}
}
// Query the service status.
if (::QueryServiceStatus (hSCMService, &status))
{
if (status.dwServiceType == SERVICE_KERNEL_DRIVER)
{
TRACE (_T(“Service is Kernel Mode Driver\n”));
}

if (status.dwCurrentState == SERVICE_RUNNING)
{
TRACE (_T (“Service is running\n”));
}

if (status.dwCurrentState == SERVICE_STOPPED)
{
TRACE (_T (“Service is stopped\n”));
}

if (status.dwCurrentState == SERVICE_START_PENDING)
{
TRACE (_T (“Service is starting\n”));
}
}

// Make sure that service handle is closed.
::CloseServiceHandle (hSCMService);

return true;
}

But evry time i try this piece of code to start my driver, the call to
StartService API returns with an error and GetLastError gives me error code
2. That says, file does not exist.
I am working with Admin previleges on the machine.

Could someone please help me in getting over this hump of StartService? Any
help will be much appreciated.

Thanks!


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Exactly which calls fails with error 2? Is your driver file named correctly
and in the correct directory? Are these calls supposed to be Unicode (I
don’t know, it’s just a thought)?

Greg


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> But evry time i try this piece of code to start my driver, the call to

StartService API returns with an error and GetLastError gives me error
code
2. That says, file does not exist.
I am working with Admin previleges on the machine.

YourDriver.sys file must be in WIN\SYSTEM32 directory.

Daniel


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Well actually the driver does not have to be in system32\Drivers, but you do
have to tell the service control manager api where the driver is if it not
in system32\Drivers. Also, if get that part right but you are giving the
service control manager api a network path, then that won’t work either, as
it is explicitly disallowed.

Mark Roddy
xxxxx@hollistech.com
www.hollistech.com
603 321 1032
WindowsNT Windows 2000 Consulting Services

-----Original Message-----
From: Daniel Pop [mailto:xxxxx@optsol.ro]
Sent: Thursday, March 29, 2001 1:41 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

But evry time i try this piece of code to start my driver, the call to
StartService API returns with an error and GetLastError gives me error
code
2. That says, file does not exist.
I am working with Admin previleges on the machine.

YourDriver.sys file must be in WIN\SYSTEM32 directory.

Daniel


You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> ----------

From: Daniel Pop[SMTP:xxxxx@optsol.ro]
Reply To: NT Developers Interest List
Sent: Thursday, March 29, 2001 8:41 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

> But evry time i try this piece of code to start my driver, the call to
> StartService API returns with an error and GetLastError gives me error
code
> 2. That says, file does not exist.
> I am working with Admin previleges on the machine.
>
YourDriver.sys file must be in WIN\SYSTEM32 directory.

Why? It can be in any directory. Standard location is
%SystemRoot%\System32\Drivers but it isn’t mandatory and for debugging
pusposes it can be better to have it somewhere else.

Error 2 can be cause by missing driver’s binary, incorrent ImagePart syntax
(where ‘incorrect’ can depend on actual loader) or DriverEntry return code.
If you have SoftICE, it displays loaded modules so look if driver was loaded
(and unloaded immediately) or not.

A hint: try sc resource kit utility.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Here is some more information…
-I am trying this on Win2K Prof Release Build system
-Just making sure that if copying SYS file to WinNt/System32/Drivers folder
make any difference, i copied the file to both locations too.

I ran the following query on my system…

sc query KsKeDrv

Here is the result…

SERVICE_NAME: KsKeDrv
Type :1 KERNEL_DRIVER
STATE:1 STOPPED
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE: 1077
SERVICE_EXIT_CODE: 0 (0x0)
CHECKPOINT: 0x0
WAIT_HINT: 0x0

Still i have the same problem…

On 03/29/01, ““Vodicka, Michal” ” wrote:
> > ----------
> > From: Daniel Pop[SMTP:xxxxx@optsol.ro]
> > Reply To: NT Developers Interest List
> > Sent: Thursday, March 29, 2001 8:41 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: StartService API failing with Error 2
> >
> >
> > > But evry time i try this piece of code to start my driver, the call to
> > > StartService API returns with an error and GetLastError gives me error
> > code
> > > 2. That says, file does not exist.
> > > I am working with Admin previleges on the machine.
> > >
> > YourDriver.sys file must be in WIN\SYSTEM32 directory.
> >
> Why? It can be in any directory. Standard location is
> %SystemRoot%\System32\Drivers but it isn’t mandatory and for debugging
> pusposes it can be better to have it somewhere else.
>
> Error 2 can be cause by missing driver’s binary, incorrent ImagePart syntax
> (where ‘incorrect’ can depend on actual loader) or DriverEntry return code.
> If you have SoftICE, it displays loaded modules so look if driver was loaded
> (and unloaded immediately) or not.
>
> A hint: try sc resource kit utility.
>
> Best regards,
>
> Michal Vodicka
> Veridicom
> (RKK - Skytale)
> [WWW: http://www.veridicom.com , http://www.skytale.com]
>
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

OK, start regedt32, go to HKLM\System\CurrentControlSet\Services\KsKeDrv and
examine ImagePath value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
Reply To: NT Developers Interest List
Sent: Thursday, March 29, 2001 3:00 AM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Here is some more information…
-I am trying this on Win2K Prof Release Build system
-Just making sure that if copying SYS file to WinNt/System32/Drivers
folder
make any difference, i copied the file to both locations too.

I ran the following query on my system…

>sc query KsKeDrv

Here is the result…

SERVICE_NAME: KsKeDrv
Type :1 KERNEL_DRIVER
STATE:1 STOPPED
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE: 1077
SERVICE_EXIT_CODE: 0 (0x0)
CHECKPOINT: 0x0
WAIT_HINT: 0x0

Still i have the same problem…


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi Michal,
Here is the dump of registry node for KsKeDrv. Let me know if it gives any
cluse. One thing I noticeis that INITSTRATFAILED value is set to 1. doe this
mean that some entry point in driver failed?

Thanks!
Naveen

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
“DisplayName”=“KSKeDrv”
“ErrorControl”=dword:00000001
“ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00,53,00,59,
00, 53,00,00,00
“Start”=dword:00000003
“Type”=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
“Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,00,00,00,0
2,
00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00,
00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,00,00,00,
05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,00,00,05,
20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,00,00,00,
00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,00,00,00,
00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,12,00,00, 00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
“Count”=dword:00000000
“INITSTARTFAILED”=dword:00000001
“NextInstance”=dword:00000000

-----Original Message-----
From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
Sent: Thursday, March 29, 2001 2:27 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

OK, start regedt32, go to HKLM\System\CurrentControlSet\Services\KsKeDrv and
examine ImagePath value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
Reply To: NT Developers Interest List
Sent: Thursday, March 29, 2001 3:00 AM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Here is some more information…
-I am trying this on Win2K Prof Release Build system
-Just making sure that if copying SYS file to WinNt/System32/Drivers
folder make any difference, i copied the file to both locations too.

I ran the following query on my system…

>sc query KsKeDrv

Here is the result…

SERVICE_NAME: KsKeDrv
Type :1 KERNEL_DRIVER
STATE:1 STOPPED
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE: 1077
SERVICE_EXIT_CODE: 0 (0x0)
CHECKPOINT: 0x0
WAIT_HINT: 0x0

Still i have the same problem…


You are currently subscribed to ntdev as: xxxxx@pumatech.com To unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

If I read ImagePath correctly (well, I prefer chars over hex values for
strings), it is plain file name i.e. kskedrv.sys. It probably should work if
your driver is in the system32\drivers directory. Anyway, if you examine
other drivers, their image path is usually System32\Drivers\Driver.sys or
\SystemRoot\System32\Drivers\Driver.sys. Try to change it via your app or sc
utility. I don’t know what exactly INITSTARTFAILED mean, it is descriptive
but doesn’t show the reason :slight_smile:

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


From: Naveen Kohli[SMTP:xxxxx@pumatech.com]
Reply To: NT Developers Interest List
Sent: Thursday, March 29, 2001 10:12 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Hi Michal,
Here is the dump of registry node for KsKeDrv. Let me know if it gives any
cluse. One thing I noticeis that INITSTRATFAILED value is set to 1. doe
this
mean that some entry point in driver failed?

Thanks!
Naveen

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
“DisplayName”=“KSKeDrv”
“ErrorControl”=dword:00000001
“ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00,53,00,5
9,
00,\
53,00,00,00
“Start”=dword:00000003
“Type”=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
“Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,00,00,00
,0
2,\

00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00
,\

00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,00,00,00
,\

05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,00,00,05
,\

20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,00,00,00
,\

00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,00,00,00
,\

00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,12,00,00
,\
00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
“Count”=dword:00000000
“INITSTARTFAILED”=dword:00000001
“NextInstance”=dword:00000000

-----Original Message-----
From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
Sent: Thursday, March 29, 2001 2:27 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

OK, start regedt32, go to HKLM\System\CurrentControlSet\Services\KsKeDrv
and
examine ImagePath value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]

> ----------
> From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> Reply To: NT Developers Interest List
> Sent: Thursday, March 29, 2001 3:00 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: StartService API failing with Error 2
>
> Here is some more information…
> -I am trying this on Win2K Prof Release Build system
> -Just making sure that if copying SYS file to WinNt/System32/Drivers
> folder make any difference, i copied the file to both locations too.
>
> I ran the following query on my system…
>
> >sc query KsKeDrv
>
> Here is the result…
>
> SERVICE_NAME: KsKeDrv
> Type :1 KERNEL_DRIVER
> STATE:1 STOPPED
> (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> WIN32_EXIT_CODE: 1077
> SERVICE_EXIT_CODE: 0 (0x0)
> CHECKPOINT: 0x0
> WAIT_HINT: 0x0
>
> Still i have the same problem…
>


You are currently subscribed to ntdev as: xxxxx@pumatech.com To
unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@rkk.cz
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Shouldn’t the ImagePath be a string instead of hex?

Greg

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Naveen Kohli
Sent: Thursday, March 29, 2001 2:12 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Hi Michal,
Here is the dump of registry node for KsKeDrv. Let me know if it gives any
cluse. One thing I noticeis that INITSTRATFAILED value is set to

  1. doe this
    mean that some entry point in driver failed?

Thanks!
Naveen

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
“DisplayName”=“KSKeDrv”
“ErrorControl”=dword:00000001
“ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00
,53,00,59,
00,> 53,00,00,00
“Start”=dword:00000003
“Type”=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
“Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,
00,00,00,0
2,>
00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,
01,00,00,>
00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,
00,00,00,>
05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,
00,00,05,>
20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,
00,00,00,>
00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,
00,00,00,>
00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,
12,00,00,> 00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
“Count”=dword:00000000
“INITSTARTFAILED”=dword:00000001
“NextInstance”=dword:00000000

-----Original Message-----
From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
Sent: Thursday, March 29, 2001 2:27 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

OK, start regedt32, go to
HKLM\System\CurrentControlSet\Services\KsKeDrv and
examine ImagePath value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]

> ----------
> From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> Reply To: NT Developers Interest List
> Sent: Thursday, March 29, 2001 3:00 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: StartService API failing with Error 2
>
> Here is some more information…
> -I am trying this on Win2K Prof Release Build system
> -Just making sure that if copying SYS file to WinNt/System32/Drivers
> folder make any difference, i copied the file to both locations too.
>
> I ran the following query on my system…
>
> >sc query KsKeDrv
>
> Here is the result…
>
> SERVICE_NAME: KsKeDrv
> Type :1 KERNEL_DRIVER
> STATE:1 STOPPED
> (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> WIN32_EXIT_CODE: 1077
> SERVICE_EXIT_CODE: 0 (0x0)
> CHECKPOINT: 0x0
> WAIT_HINT: 0x0
>
> Still i have the same problem…
>


You are currently subscribed to ntdev as: xxxxx@pumatech.com To
unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@pdq.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Naveen,

I have a test program which works well. If you want, I can send to
you.

Susan

-----Original Message-----
From: Naveen Kohli [SMTP:xxxxx@pumatech.com]
Sent: Thursday, March 29, 2001 12:12 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Hi Michal,
Here is the dump of registry node for KsKeDrv. Let me know if it gives any
cluse. One thing I noticeis that INITSTRATFAILED value is set to 1. doe
this
mean that some entry point in driver failed?

Thanks!
Naveen

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
“DisplayName”=“KSKeDrv”
“ErrorControl”=dword:00000001
“ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00,53,00,5
9,
00,> 53,00,00,00
“Start”=dword:00000003
“Type”=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
“Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,00,00,00
,0
2,>
00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00
,>
00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,00,00,00
,>
05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,00,00,05
,>
20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,00,00,00
,>
00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,00,00,00
,>
00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,12,00,00
,> 00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
“Count”=dword:00000000
“INITSTARTFAILED”=dword:00000001
“NextInstance”=dword:00000000

-----Original Message-----
From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
Sent: Thursday, March 29, 2001 2:27 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

OK, start regedt32, go to HKLM\System\CurrentControlSet\Services\KsKeDrv
and
examine ImagePath value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]

> ----------
> From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> Reply To: NT Developers Interest List
> Sent: Thursday, March 29, 2001 3:00 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: StartService API failing with Error 2
>
> Here is some more information…
> -I am trying this on Win2K Prof Release Build system
> -Just making sure that if copying SYS file to WinNt/System32/Drivers
> folder make any difference, i copied the file to both locations too.
>
> I ran the following query on my system…
>
> >sc query KsKeDrv
>
> Here is the result…
>
> SERVICE_NAME: KsKeDrv
> Type :1 KERNEL_DRIVER
> STATE:1 STOPPED
> (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> WIN32_EXIT_CODE: 1077
> SERVICE_EXIT_CODE: 0 (0x0)
> CHECKPOINT: 0x0
> WAIT_HINT: 0x0
>
> Still i have the same problem…
>


You are currently subscribed to ntdev as: xxxxx@pumatech.com To
unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@nai.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi Susan,
It would be great if you could send me your test programme. I just want my
first driver to work. Its like my Hello World programme.

Naveen

On 03/29/01, ““Chen, Susan” ” wrote:
> Naveen,
>
> I have a test program which works well. If you want, I can send to
> you.
>
> Susan
>
>
> > -----Original Message-----
> > From: Naveen Kohli [SMTP:xxxxx@pumatech.com]
> > Sent: Thursday, March 29, 2001 12:12 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: StartService API failing with Error 2
> >
> > Hi Michal,
> > Here is the dump of registry node for KsKeDrv. Let me know if it gives any
> > cluse. One thing I noticeis that INITSTRATFAILED value is set to 1. doe
> > this
> > mean that some entry point in driver failed?
> >
> > Thanks!
> > Naveen
> >
> > Windows Registry Editor Version 5.00
> >
> > [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
> > “DisplayName”=“KSKeDrv”
> > “ErrorControl”=dword:00000001
> > “ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00,53,00,5
> > 9,
> > 00,<br>> > 53,00,00,00
> > “Start”=dword:00000003
> > “Type”=dword:00000001
> >
> > [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
> > “Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,00,00,00
> > ,0
> > 2,<br>> >
> > 00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00
> > ,<br>> >
> > 00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,00,00,00
> > ,<br>> >
> > 05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,00,00,05
> > ,<br>> >
> > 20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,00,00,00
> > ,<br>> >
> > 00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,00,00,00
> > ,<br>> >
> > 00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,12,00,00
> > ,<br>> > 00,01,01,00,00,00,00,00,05,12,00,00,00
> >
> > [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
> > “Count”=dword:00000000
> > “INITSTARTFAILED”=dword:00000001
> > “NextInstance”=dword:00000000
> >
> > -----Original Message-----
> > From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
> > Sent: Thursday, March 29, 2001 2:27 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: StartService API failing with Error 2
> >
> >
> > OK, start regedt32, go to HKLM\System\CurrentControlSet\Services\KsKeDrv
> > and
> > examine ImagePath value. Also try sc start KsKeDrv.
> >
> > Best regards,
> >
> > Michal Vodicka
> > Veridicom
> > (RKK - Skytale)
> > [WWW: http://www.veridicom.com , http://www.skytale.com]
> >
> >
> >
> > > ----------
> > > From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> > > Reply To: NT Developers Interest List
> > > Sent: Thursday, March 29, 2001 3:00 AM
> > > To: NT Developers Interest List
> > > Subject: [ntdev] Re: StartService API failing with Error 2
> > >
> > > Here is some more information…
> > > -I am trying this on Win2K Prof Release Build system
> > > -Just making sure that if copying SYS file to WinNt/System32/Drivers
> > > folder make any difference, i copied the file to both locations too.
> > >
> > > I ran the following query on my system…
> > >
> > > >sc query KsKeDrv
> > >
> > > Here is the result…
> > >
> > > SERVICE_NAME: KsKeDrv
> > > Type :1 KERNEL_DRIVER
> > > STATE:1 STOPPED
> > > (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> > > WIN32_EXIT_CODE: 1077
> > > SERVICE_EXIT_CODE: 0 (0x0)
> > > CHECKPOINT: 0x0
> > > WAIT_HINT: 0x0
> > >
> > > Still i have the same problem…
> > >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@pumatech.com To
> > unsubscribe
> > send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@nai.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi Greg,
In registry editor this value is entered as “REG_EXPAND_SZ” and is
KSKEDRV.SYS. So i guess this is a string, may be multilined value.

Naveen

On 03/29/01, ““Gregory G. Dyess” ” wrote:
> Shouldn’t the ImagePath be a string instead of hex?
>
> Greg
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Naveen Kohli
> > Sent: Thursday, March 29, 2001 2:12 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: StartService API failing with Error 2
> >
> >
> > Hi Michal,
> > Here is the dump of registry node for KsKeDrv. Let me know if it gives any
> > cluse. One thing I noticeis that INITSTRATFAILED value is set to
> > 1. doe this
> > mean that some entry point in driver failed?
> >
> > Thanks!
> > Naveen
> >
> > Windows Registry Editor Version 5.00
> >
> > [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
> > “DisplayName”=“KSKeDrv”
> > “ErrorControl”=dword:00000001
> > “ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00
> > ,53,00,59,
> > 00,<br>> > 53,00,00,00
> > “Start”=dword:00000003
> > “Type”=dword:00000001
> >
> > [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
> > “Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,
> > 00,00,00,0
> > 2,<br>> >
> > 00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,
> > 01,00,00,<br>> >
> > 00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,
> > 00,00,00,<br>> >
> > 05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,
> > 00,00,05,<br>> >
> > 20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,
> > 00,00,00,<br>> >
> > 00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,
> > 00,00,00,<br>> >
> > 00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,
> > 12,00,00,<br>> > 00,01,01,00,00,00,00,00,05,12,00,00,00
> >
> > [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
> > “Count”=dword:00000000
> > “INITSTARTFAILED”=dword:00000001
> > “NextInstance”=dword:00000000
> >
> > -----Original Message-----
> > From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
> > Sent: Thursday, March 29, 2001 2:27 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: StartService API failing with Error 2
> >
> >
> > OK, start regedt32, go to
> > HKLM\System\CurrentControlSet\Services\KsKeDrv and
> > examine ImagePath value. Also try sc start KsKeDrv.
> >
> > Best regards,
> >
> > Michal Vodicka
> > Veridicom
> > (RKK - Skytale)
> > [WWW: http://www.veridicom.com , http://www.skytale.com]
> >
> >
> >
> > > ----------
> > > From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> > > Reply To: NT Developers Interest List
> > > Sent: Thursday, March 29, 2001 3:00 AM
> > > To: NT Developers Interest List
> > > Subject: [ntdev] Re: StartService API failing with Error 2
> > >
> > > Here is some more information…
> > > -I am trying this on Win2K Prof Release Build system
> > > -Just making sure that if copying SYS file to WinNt/System32/Drivers
> > > folder make any difference, i copied the file to both locations too.
> > >
> > > I ran the following query on my system…
> > >
> > > >sc query KsKeDrv
> > >
> > > Here is the result…
> > >
> > > SERVICE_NAME: KsKeDrv
> > > Type :1 KERNEL_DRIVER
> > > STATE:1 STOPPED
> > > (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> > > WIN32_EXIT_CODE: 1077
> > > SERVICE_EXIT_CODE: 0 (0x0)
> > > CHECKPOINT: 0x0
> > > WAIT_HINT: 0x0
> > >
> > > Still i have the same problem…
> > >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@pumatech.com To
> > unsubscribe
> > send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@pdq.net
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

hex(2) is regedit’s way of dealing with REG_EXPAND_SZ. REG_MULTI_SZ shows
up as hex(7). Regdmp doesn’t have this problem.

Phil

-----Original Message-----
From: Gregory G. Dyess [mailto:xxxxx@pdq.net]
Sent: Thursday, March 29, 2001 12:35 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Shouldn’t the ImagePath be a string instead of hex?

Greg

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Naveen Kohli
Sent: Thursday, March 29, 2001 2:12 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Hi Michal,
Here is the dump of registry node for KsKeDrv. Let me know if it gives any
cluse. One thing I noticeis that INITSTRATFAILED value is set to

  1. doe this
    mean that some entry point in driver failed?

Thanks!
Naveen

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
“DisplayName”=“KSKeDrv”
“ErrorControl”=dword:00000001
“ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00
,53,00,59,
00,\
53,00,00,00
“Start”=dword:00000003
“Type”=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
“Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,
00,00,00,0
2,\

00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,
01,00,00,\

00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,
00,00,00,\

05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,
00,00,05,\

20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,
00,00,00,\

00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,
00,00,00,\

00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,
12,00,00,\
00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
“Count”=dword:00000000
“INITSTARTFAILED”=dword:00000001
“NextInstance”=dword:00000000

-----Original Message-----
From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
Sent: Thursday, March 29, 2001 2:27 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

OK, start regedt32, go to
HKLM\System\CurrentControlSet\Services\KsKeDrv and
examine ImagePath value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]

> ----------
> From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> Reply To: NT Developers Interest List
> Sent: Thursday, March 29, 2001 3:00 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: StartService API failing with Error 2
>
> Here is some more information…
> -I am trying this on Win2K Prof Release Build system
> -Just making sure that if copying SYS file to WinNt/System32/Drivers
> folder make any difference, i copied the file to both locations too.
>
> I ran the following query on my system…
>
> >sc query KsKeDrv
>
> Here is the result…
>
> SERVICE_NAME: KsKeDrv
> Type :1 KERNEL_DRIVER
> STATE:1 STOPPED
> (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> WIN32_EXIT_CODE: 1077
> SERVICE_EXIT_CODE: 0 (0x0)
> CHECKPOINT: 0x0
> WAIT_HINT: 0x0
>
> Still i have the same problem…
>


You are currently subscribed to ntdev as: xxxxx@pumatech.com To
unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@pdq.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@intel.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Here is the implementation of my simple DriverEntry routine… I guess I have
implemented it correctly…

NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
KdPrint (("KSQuery - "
“Entering DriverEntry : DriverObject %8.8lX\n”,
DriverObject));

NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT pDeviceObject = NULL;
UNICODE_STRING ustrDrvName;
UNICODE_STRING ustrDvcName;

// Initialize the counted unicode string and
// Set the driver name.
RtlInitUnicodeString (&ustrDrvName, L"\Device\KSKeDrv");

// Create the device object and make sure that call succeeds.
Otherwise
// return the error code.
ntStatus = IoCreateDevice (DriverObject,0,&ustrDrvName,
FILE_DEVICE_UNKNOWN, 0, FALSE,
&pDeviceObject);
if (STATUS_SUCCESS != ntStatus)
{
return ntStatus;
}

// Initialize and set the device name.
RtlInitUnicodeString (&ustrDvcName, L"\DosDevices\KSKeDrv");

// Create the symbolic link to the user-visible name.
ntStatus = IoCreateSymbolicLink (&ustrDvcName, // User visible name
&ustrDrvName // Name
created by driver
);
if (STATUS_SUCCESS != ntStatus)
{
// Make sure to delete the created device.
IoDeleteDevice (pDeviceObject);
return ntStatus;
}

// Set the various entry point functions for various
// message handling.

DriverObject->DriverUnload = KSDriverUnload;

// Add the IRP_MJ_xxx request function…
DriverObject->MajorFunction[IRP_MJ_CREATE] = KSDriverCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = KSDriverClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = KSDriverCleanUp;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
KSDriverDeviceControl;

return STATUS_SUCCESS;
}

Naveen

-----Original Message-----
From: Gregory G. Dyess [mailto:xxxxx@pdq.net]
Sent: Thursday, March 29, 2001 3:35 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Shouldn’t the ImagePath be a string instead of hex?

Greg

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Naveen Kohli
Sent: Thursday, March 29, 2001 2:12 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Hi Michal,
Here is the dump of registry node for KsKeDrv. Let me know if it gives
any cluse. One thing I noticeis that INITSTRATFAILED value is set to

  1. doe this mean that some entry point in driver failed?

Thanks!
Naveen

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
“DisplayName”=“KSKeDrv”
“ErrorControl”=dword:00000001
“ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00
,53,00,59,
00,\
53,00,00,00
“Start”=dword:00000003
“Type”=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security
]
“Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,
00,00,00,0
2,\

00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,
01,00,00,\

00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,
00,00,00,\

05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,
00,00,05,\

20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,
00,00,00,\

00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,
00,00,00,\

00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,
12,00,00,\
00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
“Count”=dword:00000000
“INITSTARTFAILED”=dword:00000001 “NextInstance”=dword:00000000

-----Original Message-----
From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
Sent: Thursday, March 29, 2001 2:27 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

OK, start regedt32, go to
HKLM\System\CurrentControlSet\Services\KsKeDrv and examine ImagePath
value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]

> ----------
> From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> Reply To: NT Developers Interest List
> Sent: Thursday, March 29, 2001 3:00 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: StartService API failing with Error 2
>
> Here is some more information…
> -I am trying this on Win2K Prof Release Build system
> -Just making sure that if copying SYS file to WinNt/System32/Drivers
> folder make any difference, i copied the file to both locations too.
>
> I ran the following query on my system…
>
> >sc query KsKeDrv
>
> Here is the result…
>
> SERVICE_NAME: KsKeDrv
> Type :1 KERNEL_DRIVER
> STATE:1 STOPPED
> (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> WIN32_EXIT_CODE: 1077
> SERVICE_EXIT_CODE: 0 (0x0)
> CHECKPOINT: 0x0
> WAIT_HINT: 0x0
>
> Still i have the same problem…
>


You are currently subscribed to ntdev as: xxxxx@pumatech.com To
unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@pdq.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@pumatech.com To unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

If it helps… Here is the complete implementation of my bare minimum
driver. This one has the same problem that i have been talking about for
KSKeDrv.

My environment…

Win2K Prof SP1 Retail Build
Win2K DDK Build 2195
Platform SDK Build 2296.5
VC6 SP5

After compiling Driver… i copy it to the MFC app folder from where SCM APIs
are called…

I would be very greatful if somebody could help me understand this
probelm… :frowning:

Thanks!
Naveen



#include “ntddk.h”

void FooUnloadDriver(PDRIVER_OBJECT DriverObject);
NTSTATUS FooCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);

NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING
RegistryPath)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
UNICODE_STRING uszDriverString;
UNICODE_STRING uszDeviceString;
PDEVICE_OBJECT pDeviceObject = NULL;

// Point uszDriverString at the driver name
RtlInitUnicodeString(&uszDriverString, L"\Device\FooDrvr");

// Create and initialize device object
ntStatus = IoCreateDevice(DriverObject,
0,
&uszDriverString,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&pDeviceObject);
if (ntStatus != STATUS_SUCCESS)
{
return ntStatus;
}

// Point uszDeviceString at the device name
RtlInitUnicodeString(&uszDeviceString, L"\DosDevices\FooDrvr");

// Create symbolic link to the user-visible name
ntStatus = IoCreateSymbolicLink(&uszDeviceString, &uszDriverString);
if (ntStatus != STATUS_SUCCESS)
{
// Delete device object if not successful
IoDeleteDevice(pDeviceObject);
return ntStatus;
}

// Load structure to point to IRP handlers…
DriverObject->DriverUnload = FooUnloadDriver;
DriverObject->MajorFunction[IRP_MJ_CREATE] = FooCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = FooCreateClose;

// Return success
return ntStatus;
}

NTSTATUS FooCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);

return STATUS_SUCCESS;
}

void FooUnloadDriver(PDRIVER_OBJECT DriverObject)
{
UNICODE_STRING uszDeviceString;

IoDeleteDevice(DriverObject->DeviceObject);

RtlInitUnicodeString(&uszDeviceString, L"\DosDevices\FooDrvr");
IoDeleteSymbolicLink(&uszDeviceString);
}

-----Original Message-----
From: Gregory G. Dyess [mailto:xxxxx@pdq.net]
Sent: Thursday, March 29, 2001 3:35 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Shouldn’t the ImagePath be a string instead of hex?

Greg

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Naveen Kohli
Sent: Thursday, March 29, 2001 2:12 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

Hi Michal,
Here is the dump of registry node for KsKeDrv. Let me know if it gives any
cluse. One thing I noticeis that INITSTRATFAILED value is set to

  1. doe this
    mean that some entry point in driver failed?

Thanks!
Naveen

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv]
“DisplayName”=“KSKeDrv”
“ErrorControl”=dword:00000001
“ImagePath”=hex(2):4b,00,53,00,4b,00,45,00,44,00,52,00,56,00,2e,00
,53,00,59,
00,\
53,00,00,00
“Start”=dword:00000003
“Type”=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Security]
“Security”=hex:01,00,14,80,a0,00,00,00,ac,00,00,00,14,00,00,00,30,
00,00,00,0
2,\

00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,
01,00,00,\

00,00,02,00,70,00,04,00,00,00,00,00,18,00,fd,01,02,00,01,01,00,00,
00,00,00,\

05,12,00,00,00,00,00,00,00,00,00,1c,00,ff,01,0f,00,01,02,00,00,00,
00,00,05,\

20,00,00,00,20,02,00,00,64,02,00,00,00,00,18,00,8d,01,02,00,01,01,
00,00,00,\

00,00,05,0b,00,00,00,20,02,00,00,00,00,1c,00,fd,01,02,00,01,02,00,
00,00,00,\

00,05,20,00,00,00,23,02,00,00,64,02,00,00,01,01,00,00,00,00,00,05,
12,00,00,\
00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KSKeDrv\Enum]
“Count”=dword:00000000
“INITSTARTFAILED”=dword:00000001
“NextInstance”=dword:00000000

-----Original Message-----
From: Vodicka, Michal [mailto:xxxxx@rkk.cz]
Sent: Thursday, March 29, 2001 2:27 PM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

OK, start regedt32, go to
HKLM\System\CurrentControlSet\Services\KsKeDrv and
examine ImagePath value. Also try sc start KsKeDrv.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]

> ----------
> From: xxxxx@pumatech.com[SMTP:xxxxx@pumatech.com]
> Reply To: NT Developers Interest List
> Sent: Thursday, March 29, 2001 3:00 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: StartService API failing with Error 2
>
> Here is some more information…
> -I am trying this on Win2K Prof Release Build system
> -Just making sure that if copying SYS file to WinNt/System32/Drivers
> folder make any difference, i copied the file to both locations too.
>
> I ran the following query on my system…
>
> >sc query KsKeDrv
>
> Here is the result…
>
> SERVICE_NAME: KsKeDrv
> Type :1 KERNEL_DRIVER
> STATE:1 STOPPED
> (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
> WIN32_EXIT_CODE: 1077
> SERVICE_EXIT_CODE: 0 (0x0)
> CHECKPOINT: 0x0
> WAIT_HINT: 0x0
>
> Still i have the same problem…
>


You are currently subscribed to ntdev as: xxxxx@pumatech.com To
unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@pdq.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@pumatech.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

On Thursday, March 29, 2001 1:17 PM “Naveen Kohli” wrote:
[Subject: [ntdev] StartService API failing with Error 2]

Hi!
I am a newbie to writing drivers. So i started with a NT style
KernelMode
Driver. I followed some MS articles on how to load this driver using
SCM.

I followed the following code sequence…

bool CDriverInstall::InstallDriver ()
{
SC_HANDLE hSCMService = NULL;
SERVICE_STATUS status;
DWORD dwError = 0;

::CloseServiceHandle (m_hSCMHandle);

m_hSCMHandle = ::OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);

// Create the service.
hSCMService = ::CreateService (…)

Hi, Naveen.
In addition to all the good advices ppl in this list gave you concerning
the driver
itself, consider this minor change in your .cpp code sequence - run it
again and
see if helps… :wink:

bool CDriverInstall::InstallDriver ()
{
SC_HANDLE hSCMService = NULL;
SERVICE_STATUS status;
DWORD dwError = 0;

::CloseServiceHandle (m_hSCMHandle);

// m_hSCMHandle = ::OpenSCManager(NULL, NULL,
SC_MANAGER_CREATE_SERVICE); /* Your old call */
//
// — The minor change starts
HERE… ----------------------------------
//
m_hSCMHandle = ::OpenSCManager (NULL, SERVICES_ACTIVE_DATABASE,
SC_MANAGER_ALL_ACCESS);
if (NULL == m_hSCMHandle)
{
TRACE (_T (“Failed to connect %s to local SCM\n”), m_strDriverName);
return false;
}
//
// —… and ends
HERE -------------------------------------------------
//

// Create the service.
hSCMService = ::CreateService (…)

Miguel Monteiro
xxxxx@criticalsoftware.com
www.criticalsoftware.com

«Humour and love are God’s answers
to Human weaknesses»


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Thaks Miguel for the suggestion… But this also did not work…
I guess I should give up on this method working for me…

-----Original Message-----
From: Miguel Monteiro [mailto:xxxxx@criticalsoftware.com]
Sent: Friday, March 30, 2001 4:40 AM
To: NT Developers Interest List
Subject: [ntdev] Re: StartService API failing with Error 2

On Thursday, March 29, 2001 1:17 PM “Naveen Kohli” wrote:
[Subject: [ntdev] StartService API failing with Error 2]

Hi!
I am a newbie to writing drivers. So i started with a NT style
KernelMode
Driver. I followed some MS articles on how to load this driver using
SCM.

I followed the following code sequence…

bool CDriverInstall::InstallDriver ()
{
SC_HANDLE hSCMService = NULL;
SERVICE_STATUS status;
DWORD dwError = 0;

::CloseServiceHandle (m_hSCMHandle);

m_hSCMHandle = ::OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);

// Create the service.
hSCMService = ::CreateService (…)

Hi, Naveen.
In addition to all the good advices ppl in this list gave you concerning the
driver itself, consider this minor change in your .cpp code sequence - run
it again and see if helps… :wink:

bool CDriverInstall::InstallDriver ()
{
SC_HANDLE hSCMService = NULL;
SERVICE_STATUS status;
DWORD dwError = 0;

::CloseServiceHandle (m_hSCMHandle);

// m_hSCMHandle = ::OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE); /*
Your old call */ // // — The minor change starts HERE…

//
m_hSCMHandle = ::OpenSCManager (NULL, SERVICES_ACTIVE_DATABASE,
SC_MANAGER_ALL_ACCESS); if (NULL == m_hSCMHandle) { TRACE (_T (“Failed to
connect %s to local SCM\n”), m_strDriverName); return false; } // // —…
and ends HERE -------------------------------------------------
//

// Create the service.
hSCMService = ::CreateService (…)

Miguel Monteiro
xxxxx@criticalsoftware.com
www.criticalsoftware.com

to Human weaknesses>
------------------------------------------------------------


You are currently subscribed to ntdev as: xxxxx@pumatech.com To unsubscribe
send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I’ve found the SCM method flakey the first few times I try it for a new
legacy (NT4-style) driver. So: Start regedit, then go to
HKLM\System\CurrentControlSet\Services and see if there’s an entry for your
driver. If there is, delete it. Reboot. Try the whole business again.

James Antognini
IBM Research

Internet address – antognini@us.ibm.com
Notes address – James Antognini/Watson/xxxxx@IBMUS

Phone – external: 914-784-7258; tieline: 863-7258s


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com