Re: BatClass.h



OK, now THAT'S useful.

Note that DEVICE_OBJECT is a kernel type, not a user type. Therefore, its use in an
application program is deeply suspect.

The error message you get is the typical error message presented when an undefined data
type is used. So that's the giveaway as to what is wrong. It tells you instantly that
PDEVICE_OBJECT is not defined.

In fact, there is no user-level header file that defines PDEVICE_OBJECT. Nor would it
make sense to have one, because a DEVICE_OBJECT exists *only* in the kernel.

I'm not sure why batclass.h even appears in the platform sdk; it looks like it is a kernel
header file somebody threw in by mistake.

Since you can never define that field, its presence is suspect. I strongly suspect that
this call cannot be used from user space.

You could use

typedef LPVOID PDEVICE_OBJECT;

which then leaves you with UNICODE_STRING as a data type to cause problems.

Note that you could never set PDEVICE_OBJECT to a meaningful value, so if you use other
than NULL here it would be an error.

Similarly, an IRP is solely and exclusively a kernel data type. It cannot exist in user
application space (it might exist in user space in a user-mode device driver, but we are
far from using that here!)

I strongly suspect that nearly everything in batclass.h (on a cursory reading) is
completely meaningless in user space, and its inclusion in the platform sdk header files
is a colossal mistake.

Note that including ntddk.h will cause more problems than it is worth; ntddk.h is
incompatible with user header files and will cause multiply-defined symbol errors and
other problems, and in any case, even though the symbols could be defined, the actual
things referenced cannot exist in user space and it would be meaningless to refer to them
from user space.

Someone at Microsoft screwed up on this one.
joe



On 9 Dec 2006 22:13:03 -0800, "HK" <HKahwaji@xxxxxxxxxxxxxx> wrote:




Here are the errors:

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Battery_IOCTL_Sample\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Battery_IOCTL_Sample\Makefile.win" all
gcc.exe -D__DEBUG__ -c main.c -o main.o -I"C:/Dev-Cpp/include" -g3


In file included from main.c:9:
C:/Dev-Cpp/include/Batclass.h:290: error: syntax error before
"PDEVICE_OBJECT"
C:/Dev-Cpp/include/Batclass.h:290: warning: no semicolon at end of
struct or union
C:/Dev-Cpp/include/Batclass.h:292: error: syntax error before '}' token

C:/Dev-Cpp/include/Batclass.h:292: warning: data definition has no type

or storage class
C:/Dev-Cpp/include/Batclass.h:391: error: syntax error before
"MiniportInfo"
C:/Dev-Cpp/include/Batclass.h:405: error: syntax error before "PIRP"
C:/Dev-Cpp/include/Batclass.h:413: error: syntax error before
"PDEVICE_OBJECT"
C:/Dev-Cpp/include/Batclass.h:422: error: syntax error before
"PDEVICE_OBJECT"


make.exe: *** [main.o] Error 1





Joseph M. Newcomer wrote:
I seriously doubt you are getting "all kinds of errors". I strongly suspect you are
getting very specific error messages. Without seeing them, there is no way to guess what
might be wrong. Otherwise, your question is unanswerable.
joe

On 8 Dec 2006 16:08:40 -0800, "HK" <HKahwaji@xxxxxxxxxxxxxx> wrote:

Hi all,

I am experimenting in IOCTL_BATTERY_QUERY_INFORMATION to get more
detailed infromation about the battery and I was able to get good
information from MSDN.

1. My application has enumerated all devices that has battery class 2.
Created the handle after aquiring the name of the battery 3. Use
IOCTL_Battery_Query_tag to get the tag value and use that in
IOCTL_BATTERY_QUERY_INFORMATION

However I am looking at MSDN information and its says to include
BatClass.h. Unfortunately, when I do so I am getting all kinds of
errors within BatClass.h. Errors include syntax errors as well.

Any suggestions or ideas are appreciated

I am including <windows.h>
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Checkpoint/restart (was Re: [PATCH 0/4] - v2 - Object creation with a specified id)
    ... kernel representation. ... If the state can be inferred from user space it is visible to user ... In the worst case today we can restore a checkpoint by replaying all of ... Checkpoints coordinated between multiple containers or real ...
    (Linux-Kernel)
  • Re: [OT] ALSA userspace API complexity
    ... Why we have X servers in user space (and only some supporting code is in the kernel) then? ... Can you do this with ALSA way? ... comercial OSS have ALSA emulation and ALSA have OSS emulation. ...
    (Linux-Kernel)
  • Re: Things that Longhorn seems to be doing right
    ... Updating a user space database every time ... >is just as bad as putting an SQL optimizer into the kernel. ... Well, since I don't think that SQL belongs in the filesystem, and I ...
    (Linux-Kernel)
  • Re: [Devel] Re: [PATCH 0/9] OpenVZ kernel based checkpointing/restart
    ... That is why we prefer in OpenVZ to do all the job in kernel. ... with the same distribution. ... The distributed protocol used for restart is ... from user space, ...
    (Linux-Kernel)
  • Re: syscalls implementation
    ... In user space, the system calls are stubs in a library that traps into ... the vector code generated from syscalls.master in the kernel. ... stack, and then a trap is issued by ... argument pointer are passed to the system call. ...
    (freebsd-hackers)