This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy


Investigating a Process’s Module Set



Download 21,46 Mb.
Pdf ko'rish
bet1095/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   1091   1092   1093   1094   1095   1096   1097   1098   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

Investigating a Process’s Module Set

Next up, let’s check out how to iterate over the number of loaded modules that are hosted within a

given process. Recall that a 

module is a generic name used to describe a given *.dll (or the *.exe

itself ) that is hosted by a specific process. When you access the ProcessModuleCollection via the

Process.Module property, you are able to enumerate over all modules hosted within a process: .NET-

based, COM-based, or traditional C-based libraries. Ponder the following additional helper function

that will enumerate the modules in a specific process based on the PID:

static void EnumModsForPid(int pID)

{

Process theProc = null;



try

{

theProc = Process.GetProcessById(pID);



}

catch


{

Console.WriteLine("-> Sorry...bad PID!");

Console.WriteLine("************************************\n");

return;


}

Console.WriteLine("Here are the loaded modules for: {0}",

theProc.ProcessName);

try


{

ProcessModuleCollection theMods = theProc.Modules;

foreach(ProcessModule pm in theMods)

{

string info = string.Format("-> Mod Name: {0}", pm.ModuleName);



Console.WriteLine(info);

}

Console.WriteLine("************************************\n");



}

catch


{

Console.WriteLine("No mods!");

}

}

To see some possible output, let’s check out the loaded modules for the process hosting



the current example program (ProcessManipulator). To do so, run the application, identify the

PID assigned to ProcessManipulator.exe (via the Task Manager) and pass this value to the

EnumModsForPid() method (be sure to update your Main() method accordingly). Once you do,

you may be surprised to see the list of *.dlls used for a simple Console Application (GDI32.dll,

USER32.dll, ole32.dll, and so forth). Figure 17-5 shows a test run.

C H A P T E R   1 7  




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   1091   1092   1093   1094   1095   1096   1097   1098   ...   1830




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish