im still a bit new on c#, but ive got an minor issue where im trying to look for an module in a process, in order to filter it out in a list of processes..example, if i get a list of chrome processes, and want to filter out the ones that currently running flash player.. here is my sample code:
Process[] myProcess = null;
foreach (Process localAll in Process.GetProcesses())
{
try
{
if (localAll.ProcessName.Contains(processName))
{
myProcess = Process.GetProcessesByName(localAll.ProcessName);
}
}
catch { }
}
Process[] processList;
if (myProcess.Any())
{
if (moduleName != null)
{
processList = myProcess
.Where(process => process.Modules.OfType<ProcessModule>()
.Any(module => module.ModuleName.Contains(moduleName))).ToArray();
}
else
{
processList = myProcess;
}
if (!processList.Any())
{
return;
}
as im still new , i might still have some more errors to fix, but my main issue atm is :"A 32 bit processes cannot access modules of a 64 bit process" while im running a test app and entered the required info. regards ==edit
exception thrown:
System.ComponentModel.Win32Exception occurred HResult=0x80004005 Message=A 32 bit processes cannot access modules of a 64 bit process. Source=System StackTrace: at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, >Boolean firstModuleOnly) at System.Diagnostics.ProcessManager.GetModuleInfos(Int32 processId) at System.Diagnostics.Process.get_Modules() at ModuleTester.ProcessBox2.<>c__DisplayClass23_0.<.ctor>b__0(Process >process) in C:\Users\Ludwig\Desktop\ModuleTester - Copy\ModuleTester\ProcessBox2.cs:line 63 at System.Linq.Enumerable.WhereArrayIterator
1.MoveNext() at System.Linq.Buffer
1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source) at ModuleTester.ProcessBox2..ctor(String processName, String moduleName, >String testAob, UInt32 PiDd) in C:\Users\Ludwig\Desktop\ModuleTester - >Copy\ModuleTester\ProcessBox2.cs:line 62 at ModuleTester.Program.MProces(String process, String aob, String >module, UInt32 ppid, String t_aob) in C:\Users\Ludwig\Desktop\ModuleTester - >Copy\ModuleTester\Program.cs:line 35 at ModuleTester.Program.Main(String[] args) in C:\Users\Ludwig\Desktop>\ModuleTester - Copy\ModuleTester\Program.cs:line 27