NtQuerySystemInformation - SystemObjectInformation always fails

Hi,

I’m trying to make a call to NtQuerySystemInformation with the
SystemObjectInformation class from an user mode application and it always
fails. I’ve tried adjusting the buffer size and all the other parameters but
still no luck. On the other hand when I’ve tried other
SYSTEM_INFORMATION_CLASS parameters like SystemHandleInformation it worked.
Does anyone know a way to get this call working with SystemObjectInformation
? Thank you.

Best regards,
Lucian Mocanasu

Lucian Mocanasu wrote:

I’m trying to make a call to NtQuerySystemInformation with the
SystemObjectInformation class from an user mode application and it
always fails.
>

Sorry, my ESP is broken today. Perhaps you can tell us the status
that’s being returned by NtQuerySystemInformation.

You also might wanna post the BRIEFEST POSSIBLE code segment, showing
your call.

Peter
OSR

Hi Peter,

Thank you for replying to my inquiry. Here is the piece of code:

DWORD dwSize = 0;
HRESULT hRslt = S_OK;

// allocate initial buffer size 1M
PVOID pBuffer = LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, 1024*1024);
//pBuffer = malloc(1024*1024);

if (!pBuffer){
strDebug.Format(“Error allocating mem 0x%X”,
GetLastError());
logfile.WriteString(strDebug);
hRslt = S_FALSE;
goto Cleanup;
}
// get the data

hRslt = fNtQuerySystemInformation(SystemObjectInformation, pBuffer,
1024*1024, &dwSize);
if(hRslt != S_OK){

The errors I get are 0xC0000004 - STATUS_INFO_LENGTH_MISMATCH (if I specify
a buffer of length less than 56 bytes - instead of 1024*1024) and 0xC0000001

  • STATUS_UNSUCCESSFUL (if I specify buffer a buffer size larger than 55
    bytes); in both cases the last param (dwSize) which should hold the required
    buffer size remains 0.

fNtQuerySystemInformation is a pointer to NtQuerySystemInformation function
from ntdll.dll which is loaded at run time via LoadLibrary. I remind you
that the call succeeds with other values of the first param like
SystemHandleInformation, SystemBasicInformation, etc…

For your information, I’m using an XP Pro machine with SP 1 and the code is
part of a MFC application.

BTW: I’ve also seen an example of app which retrieves handle information
from the system. It uses the same call but with SystemHandleInformation as
first param. It also sets SeDebugPrivilege before getting the data. I’ve
tried that on my application but it didn’t work.

If you need more info please let me know. Thank you.

Best regards,

Lucian Mocanasu

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of PeterGV
Sent: Wednesday, July 28, 2004 6:40 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] NtQuerySystemInformation - SystemObjectInformation
always fails

Lucian Mocanasu wrote:

I’m trying to make a call to NtQuerySystemInformation with the
SystemObjectInformation class from an user mode application and it
always fails.
>

Sorry, my ESP is broken today. Perhaps you can tell us the status
that’s being returned by NtQuerySystemInformation.

You also might wanna post the BRIEFEST POSSIBLE code segment, showing
your call.

Peter
OSR


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@gfitemasoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Lucian Mocanasu wrote:

Hi Peter,

Thank you for replying to my inquiry. Here is the piece of code:
The errors I get are 0xC0000004 - STATUS_INFO_LENGTH_MISMATCH (if I specify
a buffer of length less than 56 bytes - instead of 1024*1024) and 0xC0000001

  • STATUS_UNSUCCESSFUL (if I specify buffer a buffer size larger than 55
    bytes); in both cases the last param (dwSize) which should hold the required
    buffer size remains 0.

The only thing I can suggest – and this is a guess – is that this is
one of those functions that requires the object type list to be maintained.

Try enabling “maintain object type list” with gflags and reboot. THEN
try it. If you’re not familiar with gflags:

http://www.microsoft.com/resources/documentation/WindowsServ/2003/all/techref/en-us/Default.asp?url=/resources/documentation/windowsServ/2003/all/techref/en-us/gflags_flags.asp

Hope that helps,

Peter
OSR

Hi Peter,

I set the flag and it worked. Thank you !

Best regards,

Lucian Mocanasu

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of PeterGV
Sent: Friday, July 30, 2004 12:18 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] NtQuerySystemInformation - SystemObjectInformation
always fails

Lucian Mocanasu wrote:

Hi Peter,

Thank you for replying to my inquiry. Here is the piece of code:
The errors I get are 0xC0000004 - STATUS_INFO_LENGTH_MISMATCH (if I
specify
a buffer of length less than 56 bytes - instead of 1024*1024) and
0xC0000001

  • STATUS_UNSUCCESSFUL (if I specify buffer a buffer size larger than 55
    bytes); in both cases the last param (dwSize) which should hold the
    required
    buffer size remains 0.

The only thing I can suggest – and this is a guess – is that this is
one of those functions that requires the object type list to be maintained.

Try enabling “maintain object type list” with gflags and reboot. THEN
try it. If you’re not familiar with gflags:

http://www.microsoft.com/resources/documentation/WindowsServ/2003/all/techre
f/en-us/Default.asp?url=/resources/documentation/windowsServ/2003/all/techre
f/en-us/gflags_flags.asp

Hope that helps,

Peter
OSR


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@gfitemasoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com