473,549 Members | 2,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameter "ReturnLeng th" always "0" when NtQuerySystemIn formation is called,...

Hi,

the topic says all. I use this code from C# to call the
NtQuerySystemIn formation.
When i call NtQuerySystemIn formation the first time with zero buffer length
to
get the buffer size needed for the information i get a
STATUS_INFO_LEN GTH_MISMATCH
which is -1073741820 in number, this is ok, but why does the function not
store the required
buffer size in "ReturnLeng th"? Its always zero,...why? Is something wrong
with my declaration:

[DllImport("ntdl l.dll",
EntryPoint = "NtQuerySystemI nformation",
SetLastError = true,
CharSet = CharSet.Unicode ,
ExactSpelling = true,
CallingConventi on = CallingConventi on.Winapi)]
public static extern int NtQuerySystemIn formation(
SYSTEM_INFORMAT ION_CLASS SystemInformati onClass,
IntPtr SystemInformati on,
uint SystemInformati onLength,
out uint ReturnLength);

uint l = 0;
IntPtr ptrBuffer = Marshal.AllocHG lobal(10000000) ; //just some "buffer"
space, not used
int err = DRWin32APIClass .NtQuerySystemI nformation(
DRWin32APIClass .SYSTEM_INFORMA TION_CLASS.Syst emBasicInformat ion,
ptrBuffer,
10000000,
out l);

MessageBox.Show (DRWin32APIClas s.NtStatusToWin 32Exception(err ).Message + "\n"
+ err.ToString() + "\n" + l.ToString());

Marshal.FreeHGl obal(ptrBuffer) ;

The "ReturnLeng th" is always zero (0),...very strange. I am doing something
wrong here,...

I know that i can use for this class the Win32 API GetSystemInfo(. ..), but
the
call fails on any class, no matter if i want some Handles/Objects, etc
Information,...
Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Aug 23 '08 #1
2 3025
>the topic says all. I use this code from C# to call the
NtQuerySystemI nformation.
When i call NtQuerySystemIn formation the first time with zero buffer length
to
get the buffer size needed for the information i get a
STATUS_INFO_LE NGTH_MISMATCH
which is -1073741820 in number, this is ok, but why does the function not
store the required
buffer size in "ReturnLeng th"? Its always zero,...why?

It is (or was) a bug in the function implementation. Don't know which
OS version you're running, but it looks like they've fixed it in
Vista.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 5 '08 #2
Hi Matthias,

thanks for the reply. I use XP SP3 up2date and i cant
get it work, still cant get it work and it is really not
clear to me, why this fails,...

If you have any idea how i can fix this, please
let me know, or know an alternative to enumerate
all kernel objects on a system like mutants, mutexes,
etc,...

I could write a writer for this and use a user defined
IOCTL to move the data from Kernel to Userland,
but since this can be done, at least what i need here,
with User Mode Code, there is no need for a Driver
so far,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Mattias Sjögren" <ma************ ********@mvps.o rgschrieb im Newsbeitrag
news:eS******** ******@TK2MSFTN GP04.phx.gbl...
>
>>the topic says all. I use this code from C# to call the
NtQuerySystem Information.
When i call NtQuerySystemIn formation the first time with zero buffer
length
to
get the buffer size needed for the information i get a
STATUS_INFO_L ENGTH_MISMATCH
which is -1073741820 in number, this is ok, but why does the function not
store the required
buffer size in "ReturnLeng th"? Its always zero,...why?


It is (or was) a bug in the function implementation. Don't know which
OS version you're running, but it looks like they've fixed it in
Vista.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 6 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1497
by: Paul Fairless | last post by:
I have a form called frmCustSearch to search for customers against an SQL Server database. The form contains a simple textbox into which the Customers surname is typed, and a datagrid then becomes visible on the form containing the CustID, Surname, Forename and address of all people with that surname. The correct customer is then selected...
0
1605
by: KGrein | last post by:
Hi. I have a form that contains a combo box with customer number & customer name in it. The form is called F_DeleteUSCust and the combo box is named CB_getUScust It picks up the information for Row Source from a distinct query. I have the column count as 2 and bound column 1 (saving customer number). I have 2 buttons on the form, one to...
4
3606
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's useful to help me to solve some basic problem which I may not perceive before. I appreciate your help, sincerely.
0
3729
by: Dino Hadzic | last post by:
Hallo csharp'ers I am trying to call a function on a COM (dll) object from managed c# code, which will send data to another node using an already existing bluetooth connection. However, I get a "System.ArgumentException" with explanation "The parameter is incorrect" when calling L2C_SendData_Issue(...) The function declaration in C#:...
3
7914
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory but the tray icon is not there. If I start the program after Windows has booted up the icon shows every time. I am assuming that the reason is...
1
1798
by: Garfield | last post by:
I use Sax2 in xerces-c 2.7. I know when is called "validateElement" method. I know simply that is called before "startElement" until now. but I was wrong!!!! there is not always called "validateElement" before "startElement".
3
5438
by: myemail.an | last post by:
Hi all, I use Access 2007 and have come across this error a number of times. I have two tables (customer information) which should contain - ideally - the same data. I create a query to compare them based on customer code. The fields are something like: Customer code Balance - Table 1 Balance - Table 2
35
1921
by: Rick Giuly | last post by:
Hello All, Why is python designed so that b and c (according to code below) actually share the same list object? It seems more natural to me that each object would be created with a new list object in the points variable. class Blob: def __init__(self, points=): self._points = points
0
7521
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7959
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.