UserCreateHeap: use SIZE_T for parameter, also use SIZE_T for MmMapViewOfSection
[reactos.git] / irc / TechBot / TechBot.Library / Commands / NtStatusCommand.cs
1 using System;
2 using System.Xml;
3
4 namespace TechBot.Library
5 {
6 [Command("ntstatus", Help = "!ntstatus <value>")]
7 public class NtStatusCommand : XmlLookupCommand
8 {
9 public NtStatusCommand()
10 {
11 }
12
13 public override string XmlFile
14 {
15 get { return Settings.Default.NtStatusXml; }
16 }
17
18 public override void ExecuteCommand()
19 {
20 if (Text.Equals(String.Empty))
21 {
22 TechBot.ServiceOutput.WriteLine(Context,
23 "Please provide a valid NTSTATUS value.");
24 return;
25 }
26
27 NumberParser np = new NumberParser();
28 long ntstatus = np.Parse(Text);
29 if (np.Error)
30 {
31 TechBot.ServiceOutput.WriteLine(Context,
32 String.Format("{0} is not a valid NTSTATUS value.",
33 Text));
34 return;
35 }
36
37 string description = GetNtstatusDescription(ntstatus);
38 if (description != null)
39 {
40 TechBot.ServiceOutput.WriteLine(Context,
41 String.Format("{0} is {1}.",
42 Text,
43 description));
44 }
45 else
46 {
47 TechBot.ServiceOutput.WriteLine(Context,
48 String.Format("I don't know about NTSTATUS {0}.",
49 Text));
50 }
51 }
52
53 public string GetNtstatusDescription(long ntstatus)
54 {
55 XmlElement root = base.m_XmlDocument.DocumentElement;
56 XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
57 ntstatus.ToString("X8")));
58 if (node != null)
59 {
60 XmlAttribute text = node.Attributes["text"];
61 if (text == null)
62 throw new Exception("Node has no text attribute.");
63 return text.Value;
64 }
65 else
66 return null;
67 }
68 }
69 }