public static handleItemInfo getHandleItemInfo(int handle) { IntPtr ObjectInformation = Marshal.AllocHGlobal(512); ulong Length = 512; ulong ResultLength = 0; long callReturnValue = NtQueryObject(handle,OBJECT_INFORMATION_CLASS.ObjectNameInformation,ObjectInformation ,Length,ref ResultLength); if (callReturnValue !=0 && callReturnValue != 0xc0000008) { //listOfHandlesNames.Add(":::::ERROR::::: on Item " + Convert.ToString(i*4,16).ToString() + " the error " + Convert.ToString(callReturnValue,16).ToString() + " occured"); (":::::ERROR::::: on Item " + Convert.ToString(handle,16).ToString() + " the error " + Convert.ToString(callReturnValue,16).ToString() + " occured").error(); } if (callReturnValue ==0) { NAME_QUERY objectName = new NAME_QUERY(); objectName = (NAME_QUERY)Marshal.PtrToStructure(ObjectInformation,objectName.GetType()); if (objectName.noIdeaWhatThisIs != "") { handleItemInfo tempHandleItemInfo = new handleItemInfo( handle, objectName.Name, objectName.noIdeaWhatThisIs); return tempHandleItemInfo; } /* else { handleItemInfo tempHandleItemInfo = new handleItemInfo( 0, objectName.Name, objectName.noIdeaWhatThisIs); listOfHandlesNames.Add(tempHandleItemInfo); }*/ } return null; }
public static handleItemInfo getHandleItemInfo(int handle) { IntPtr ObjectInformation = Marshal.AllocHGlobal(512); ulong Length = 512; ulong ResultLength = 0; long callReturnValue = NtQueryObject(handle, OBJECT_INFORMATION_CLASS.ObjectNameInformation, ObjectInformation, Length, ref ResultLength); if (callReturnValue != 0 && callReturnValue != 0xc0000008) { //listOfHandlesNames.Add(":::::ERROR::::: on Item " + Convert.ToString(i*4,16).ToString() + " the error " + Convert.ToString(callReturnValue,16).ToString() + " occured"); (":::::ERROR::::: on Item " + Convert.ToString(handle, 16).ToString() + " the error " + Convert.ToString(callReturnValue, 16).ToString() + " occured").error(); } if (callReturnValue == 0) { NAME_QUERY objectName = new NAME_QUERY(); objectName = (NAME_QUERY)Marshal.PtrToStructure(ObjectInformation, objectName.GetType()); if (objectName.noIdeaWhatThisIs != "") { handleItemInfo tempHandleItemInfo = new handleItemInfo(handle, objectName.Name, objectName.noIdeaWhatThisIs); return(tempHandleItemInfo); } /* else * { * handleItemInfo tempHandleItemInfo = new handleItemInfo( 0, objectName.Name, objectName.noIdeaWhatThisIs); * listOfHandlesNames.Add(tempHandleItemInfo); * }*/ } return(null); }
public static ArrayList returnArrayListWithCurrentHandles_usingBruteForceMethod(int numberOfHandlesToTry) { ArrayList listOfHandlesNames = new ArrayList(); IntPtr ObjectInformation = Marshal.AllocHGlobal(512); ulong Length = 512; ulong ResultLength = 0; int numberOfHandlesProcessed = 0; int numberOfHandlesPrinted = 0; for (int i=0; i<numberOfHandlesToTry;i++) { long callReturnValue = NtQueryObject(i*4,OBJECT_INFORMATION_CLASS.ObjectNameInformation,ObjectInformation ,Length,ref ResultLength); if (callReturnValue !=0 && callReturnValue != 0xc0000008) { listOfHandlesNames.Add(":::::ERROR::::: on Item " + Convert.ToString(i*4,16).ToString() + " the error " + Convert.ToString(callReturnValue,16).ToString() + " occured"); } if (callReturnValue ==0) { numberOfHandlesProcessed++; NAME_QUERY objectName = new NAME_QUERY(); objectName = (NAME_QUERY)Marshal.PtrToStructure(ObjectInformation,objectName.GetType()); if (objectName.noIdeaWhatThisIs != "") { numberOfHandlesPrinted++; //Console.WriteLine(objectName.Name); handleItemInfo tempHandleItemInfo = new handleItemInfo( i*4, objectName.Name); listOfHandlesNames.Add(tempHandleItemInfo); //listOfHandlesNames.Add(objectName.Name); } else { handleItemInfo tempHandleItemInfo = new handleItemInfo( 0, ""); listOfHandlesNames.Add(tempHandleItemInfo); } } } //Console.WriteLine("Processed {0} Handles and Printed {1}",numberOfHandlesProcessed, numberOfHandlesPrinted); return listOfHandlesNames; }
static public ArrayList returnArrayListWithCurrentHandles_usingBruteForceMethod(int numberOfHandlesToTry) { ArrayList listOfHandlesNames = new ArrayList(); IntPtr ObjectInformation = Marshal.AllocHGlobal(512); ulong Length = 512; ulong ResultLength = 0; for (int i = 0; i < numberOfHandlesToTry; i++) { long callReturnValue = NtQueryObject(i * 4, OBJECT_INFORMATION_CLASS.ObjectNameInformation, ObjectInformation, Length, ref ResultLength); if (callReturnValue != 0 && callReturnValue != 0xc0000008) { listOfHandlesNames.Add(":::::ERROR::::: on Item " + Convert.ToString(i * 4, 16).ToString() + " the error " + Convert.ToString(callReturnValue, 16).ToString() + " occured"); } if (callReturnValue == 0) { NAME_QUERY objectName = new NAME_QUERY(); objectName = (NAME_QUERY)Marshal.PtrToStructure(ObjectInformation, objectName.GetType()); if (objectName.noIdeaWhatThisIs != "") { handleItemInfo tempHandleItemInfo = new handleItemInfo(i * 4, objectName.Name); listOfHandlesNames.Add(tempHandleItemInfo); } else { handleItemInfo tempHandleItemInfo = new handleItemInfo(0, ""); listOfHandlesNames.Add(tempHandleItemInfo); } } } return(listOfHandlesNames); }