Windows miniclass sample

Hi,

Is there any Battery miniclass driver samples available in wdk samples?

Regards,
ravish

IIRC battery miniclass drivers have been deprecated since Vista

d

Bent from my phone


From: Ravish Yadavmailto:xxxxx
Sent: ?9/?26/?2014 10:24 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] Windows miniclass sample

Hi,

Is there any Battery miniclass driver samples available in wdk samples?

Regards,
ravish
— NTDEV is sponsored by OSR Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

Hi doron,

Want some information regarding the attachment of device object of battery
mini class driver how the stack will look like, where will the miniport
driver will attached , will it be enumerated by the battery class driver
(battc.sys) or it will be attached to acpi driver.

Please suggest.

On Saturday, September 27, 2014, Doron Holan
wrote:

> IIRC battery miniclass drivers have been deprecated since Vista
>
> d
>
> Bent from my phone
> ------------------------------
> From: Ravish Yadav
> <javascript:_e>
> Sent: ‎9/‎26/‎2014 10:24 AM
> To: Windows System Software Devs Interest List
> <javascript:_e>
> Subject: [ntdev] Windows miniclass sample
>
> Hi,
>
> Is there any Battery miniclass driver samples available in wdk samples?
>
>
> Regards,
> ravish
> — NTDEV is sponsored by OSR Visit the list at:
> http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See
> http://www.osr.com/careers For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
></javascript:_e></javascript:_e>

Ravish Yadav wrote:

Hi doron,

Want some information regarding the attachment of device object of
battery mini class driver how the stack will look like, where will
the miniport driver will attached , will it be enumerated by the
battery class driver (battc.sys) or it will be attached to acpi driver.

Did you do any looking at all before you asked the question?

http://msdn.microsoft.com/en-us/library/windows/hardware/ff536298.aspx

The ACPI driver will enumerate the battery. Your driver will consist of
the battery class driver plus your miniclass, which calls into the
battery class driver to handle requests.

Doron has stated several times over the past few years that the battery
miniclass driver is no longer the approved method of handling batteries
(although I’ve never seen that in writing). The functions should all be
handled by ACPI.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,

Its for windows 8.1 there is a need for this.

I need some more help , I am not able to open the device by using create
file it is returning the
ERROR_INVALID_FUNCTION while using createfile.

I am registering the device under the battery class and the enumerator is
ACPI.
I am not sure how the flow work in this case please can you point out what
can be wrong.

The following code i am using .

// Returned value includes GBS_HASBATTERY if the system has a
// non-UPS battery, and GBS_ONBATTERY if the system is running on
// a battery.
//
// dwResult & GBS_ONBATTERY means we have not yet found AC power.
// dwResult & GBS_HASBATTERY means we have found a non-UPS battery.

DWORD dwResult = GBS_ONBATTERY;

// IOCTL_BATTERY_QUERY_INFORMATION,
// enumerate the batteries and ask each one for information.

HDEVINFO hdev =
SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY,
0,
0,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (INVALID_HANDLE_VALUE != hdev)
{
// Limit search to 100 batteries max
for (int idev = 0; idev < 100; idev++)
{
SP_DEVICE_INTERFACE_DATA did = {0};
did.cbSize = sizeof(did);

if (SetupDiEnumDeviceInterfaces(hdev,
0,
&GUID_DEVCLASS_BATTERY,
idev,
&did))
{
DWORD cbRequired = 0;

SetupDiGetDeviceInterfaceDetail(hdev,
&did,
0,
0,
&cbRequired,
0);
if (ERROR_INSUFFICIENT_BUFFER == GetLastError())
{
PSP_DEVICE_INTERFACE_DETAIL_DATA pdidd =
(PSP_DEVICE_INTERFACE_DETAIL_DATA)LocalAlloc(LPTR,
cbRequired);
if (pdidd)
{
pdidd->cbSize = sizeof(*pdidd);
if (SetupDiGetDeviceInterfaceDetail(hdev,
&did,
pdidd,
cbRequired,
&cbRequired,
0))
{
// Enumerated a battery. Ask it for information.

m_hBattery = CreateFile(pdidd->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (INVALID_HANDLE_VALUE != m_hBattery)
{

Regards,
Ravish

On Mon, Oct 6, 2014 at 11:15 PM, Tim Roberts wrote:

> Ravish Yadav wrote:
> > Hi doron,
> >
> > Want some information regarding the attachment of device object of
> > battery mini class driver how the stack will look like, where will
> > the miniport driver will attached , will it be enumerated by the
> > battery class driver (battc.sys) or it will be attached to acpi driver.
>
> Did you do any looking at all before you asked the question?
>
> http://msdn.microsoft.com/en-us/library/windows/hardware/ff536298.aspx
>
> The ACPI driver will enumerate the battery. Your driver will consist of
> the battery class driver plus your miniclass, which calls into the
> battery class driver to handle requests.
>
> Doron has stated several times over the past few years that the battery
> miniclass driver is no longer the approved method of handling batteries
> (although I’ve never seen that in writing). The functions should all be
> handled by ACPI.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Ravish Yadav wrote:

Its for windows 8.1 there is a need for this.

As I understand, everything that can be done in a battery miniclass
driver can be handled directly by ACPI with no driver involvement at
all. However, this is not my primary area of expertise.

I need some more help , I am not able to open the device by using
create file it is returning the
ERROR_INVALID_FUNCTION while using createfile.
*
*
I am registering the device under the battery class and the enumerator
is ACPI.
I am not sure how the flow work in this case please can you point out
what can be wrong.

Do you see your driver being loaded? Are you calling IoCreateDevice?
Are you calling BatteryClassInitializeDevice? Does it return success?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,

Driver gets loaded and BatteryClassInitializeDevice return SUCCESS. I am
calling WdfDeviceCreate which return SUCCESS.

I am not sure what is wrong.

Regards,
Rabish

On Mon, Oct 13, 2014 at 10:47 PM, Tim Roberts wrote:

> Ravish Yadav wrote:
>
>
> Its for windows 8.1 there is a need for this.
>
>
> As I understand, everything that can be done in a battery miniclass driver
> can be handled directly by ACPI with no driver involvement at all.
> However, this is not my primary area of expertise.
>
>
> I need some more help , I am not able to open the device by using create
> file it is returning the
> ERROR_INVALID_FUNCTION while using createfile.
>
> I am registering the device under the battery class and the enumerator
> is ACPI.
> I am not sure how the flow work in this case please can you point out what
> can be wrong.
>
>
> Do you see your driver being loaded? Are you calling IoCreateDevice? Are
> you calling BatteryClassInitializeDevice? Does it return success?
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Hi Tim,

Issue has been resolved after review of code thanks for the help.

Regards,
Rabish

On Tuesday, October 14, 2014, Ravish Yadav wrote:

> Hi Tim,
>
> Driver gets loaded and BatteryClassInitializeDevice return SUCCESS. I am
> calling WdfDeviceCreate which return SUCCESS.
>
> I am not sure what is wrong.
>
> Regards,
> Rabish
>
> On Mon, Oct 13, 2014 at 10:47 PM, Tim Roberts > <javascript:_e>> wrote:
>
>> Ravish Yadav wrote:
>>
>>
>> Its for windows 8.1 there is a need for this.
>>
>>
>> As I understand, everything that can be done in a battery miniclass
>> driver can be handled directly by ACPI with no driver involvement at all.
>> However, this is not my primary area of expertise.
>>
>>
>> I need some more help , I am not able to open the device by using
>> create file it is returning the
>> ERROR_INVALID_FUNCTION while using createfile.
>>
>> I am registering the device under the battery class and the enumerator
>> is ACPI.
>> I am not sure how the flow work in this case please can you point out
>> what can be wrong.
>>
>>
>> Do you see your driver being loaded? Are you calling IoCreateDevice?
>> Are you calling BatteryClassInitializeDevice? Does it return success?
>>
>> –
>> Tim Roberts, xxxxx@probo.com <javascript:_e>
>> Providenza & Boekelheide, Inc.
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>>
>> OSR is HIRING!! See http://www.osr.com/careers
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>
></javascript:_e></javascript:_e>