ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/Win32/libWin32/Win32/Threading/ThreadControl.cs
(Generate patch)

Comparing trunk/Win32/libWin32/Win32/Threading/ThreadControl.cs (file contents):
Revision 100 by william, Thu May 10 09:03:13 2012 UTC vs.
Revision 101 by william, Thu May 10 09:53:16 2012 UTC

--- trunk/Win32/libWin32/Win32/Threading/ThreadControl.cs	2012/05/10 09:03:13	100
+++ trunk/Win32/libWin32/Win32/Threading/ThreadControl.cs	2012/05/10 09:53:16	101
@@ -16,17 +16,14 @@ namespace libWin32.Win32.Threading
         [DllImport("kernel32.dll")]
         static extern int ResumeThread(IntPtr hThread);
 
-
+        [DllImport("kernel32.dll")]
+        public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
         [DllImport("advapi32.dll", SetLastError = true)]
         public static extern bool OpenProcessToken(IntPtr ProcessHandle, UInt32 DesiredAccess, out IntPtr TokenHandle);
         [DllImport("kernel32.dll", SetLastError = true)]
         [return: MarshalAs(UnmanagedType.Bool)]
         public static extern bool CloseHandle(IntPtr hObject);
-        [DllImport("psapi.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
-        static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName, uint nSize);
 
-        [DllImport("psapi.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
-        public static extern int EnumProcessModules(IntPtr hProcess, [Out] IntPtr lphModule, uint cb, out uint lpcbNeeded);
 
         public static void SuspendProcess(int PID)
         {
@@ -67,7 +64,7 @@ namespace libWin32.Win32.Threading
             IsSystem = false;
             try
             {
-                ThreadControl.OpenProcessToken(handle, (uint)ThreadAccess.PROCESS_TOKEN_QUERY, out ph);
+                ThreadControl.OpenProcessToken(handle, (uint)ProcessTokenFlags.TOKEN_QUERY, out ph);
                 WindowsIdentity wi = new WindowsIdentity(ph);
                 IsSystem = wi.IsSystem;
                 string name = wi.Name;
@@ -85,45 +82,5 @@ namespace libWin32.Win32.Threading
             }
             return "";
         }
-
-        public static string GetProcessFilename(Process proc)
-        {
-            string filename = "";
-            Process[] procs = new Process[] { proc };
-            int mainModuleIndex = 0;
-            foreach (Process p in procs)
-            {
-                // Setting up the variable for the second argument for EnumProcessModules
-                IntPtr[] hMods = new IntPtr[1024];
-
-                GCHandle gch = GCHandle.Alloc(hMods, GCHandleType.Pinned); // Don't forget to free this later
-                IntPtr pModules = gch.AddrOfPinnedObject();
-
-                // Setting up the rest of the parameters for EnumProcessModules
-                uint uiSize = (uint)(Marshal.SizeOf(typeof(IntPtr)) * (hMods.Length));
-                uint cbNeeded = 0;
-
-                if (EnumProcessModules(p.Handle, pModules, uiSize, out cbNeeded) == 1)
-                {
-                    Int32 uiTotalNumberofModules = (Int32)(cbNeeded / (Marshal.SizeOf(typeof(IntPtr))));
-
-                    for (int i = 0; i < (int)uiTotalNumberofModules; i++)
-                    {
-                        StringBuilder strbld = new StringBuilder(1024);
-
-                        GetModuleFileNameEx(p.Handle, hMods[i], strbld, (uint)(strbld.Capacity));
-                        filename = strbld.ToString();
-                        if (i == mainModuleIndex)
-                            break;
-                    }
-                    //Console.WriteLine("Number of Modules: " + uiTotalNumberofModules);
-                    //Console.WriteLine();
-                }
-
-                // Must free the GCHandle object
-                gch.Free();               
-            }
-            return filename;
-        }
     }
 }