الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Just For Ci :system Loaded Modules

مغلق
بدأه tmaaa في 23 أكتوبر 2002 · 2 رد · 665 مشاهدة · في لغة Delphi
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

الكود الأتي يعطي قائمة بـSystem Loaded Modules وبعض المعلومات عنها .

الكود يستعمل الداله NtQuerySystemInformation وبعض التراكيب التي يمكن الاطلاع على معلومات اكثر عنها بالرجوع الى كتاب Gary Nebbett المسمى "Windows NT/2000 Native API ".

Just for NT/2K/XP . Tested in WINXP .

//--------------------------------------------------------

Add Button & ListView to a form

 
const 
STATUS_INFO_LENGTH_MISMATCH=$C0000004; 
SystemModuleInformation=11; 
... 
  Type 
  USHORT=WORD; 
  TSystem_Module_Information=packed record 
        Base:Pointer; 
        Size:ULONG; 
        Flags:ULONG; 
        Index:USHORT; 
        Unknown:USHORT; 
        LoadCount:USHORT; 
        ModuleNameOffset:USHORT; 
        ImageName: array [0..MAX_PATH + 3] of Char; 
  end; 
  PSystem_Module_Information=^TSystem_Module_Information; 
... 
function  NtQuerySystemInformation  (infoClass: DWORD; 
  buffer: Pointer; 
  bufSize: DWORD; 
  returnSize: PDword): DWORD; stdcall; external'ntdll.dll' name 'NtQuerySystemInformation'; 
... 
procedure GetDriverInfo(MyListView:TListView); 
  var 
    Index, numEntries: DWORD; 
    driverInfo,p: PSystem_Module_Information; 
    ListItem: TListItem; 
    ret,Size: DWORD; 
    NewColumn: TListColumn; 
begin 
  Size:=sizeof(TSystem_Module_Information); 
  driverInfo:=allocMem( Size); 
  ret := NtQuerySystemInformation(11, 
  driverInfo, Size, nil); 
  while ret = STATUS_INFO_LENGTH_MISMATCH do 
  begin 
    Inc(Size, Size); 
    ReallocMem(driverInfo, Size); 
    ret := NtQuerySystemInformation(SystemModuleInformation, 
   driverInfo, Size, nil); 
  end; 
   p:=driverInfo; 
   numEntries:=ULONG(driverInfo.base); 
   driverInfo:=PSystem_Module_Information(ULONG(driverInfo)+12); 
   //why 12? ;-)   wanna know ? check Nebbett's book. 
   with MyListView do 
   begin 
     // You can do this in the design time 
     Align:=alLeft; 
     ViewStyle:=VsReport; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'Base'; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'Size'; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'Flags'; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'Index'; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'Unknown'; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'LoadCount'; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'NameOffset'; 
     NewColumn := Columns.Add; 
     NewColumn.Caption := 'Name'; 
     for Index := 1 to numEntries do 
     begin 
        ListItem := Items.Add; 
        ListItem.Caption := IntToHex(DWORD(driverInfo.Base),8); 
        ListItem.SubItems.Add(IntToStr(DriverInfo.Size)); 
        ListItem.SubItems.Add(IntToStr(DriverInfo.Flags)); 
        ListItem.SubItems.Add(IntToStr(DriverInfo.Index)); 
        ListItem.SubItems.Add(IntToStr(DriverInfo.Unknown)); 
        ListItem.SubItems.Add(IntToStr(DriverInfo.LoadCount)); 
        ListItem.SubItems.Add(IntToStr(DriverInfo.ModuleNameOffset)); 
        ListItem.SubItems.Add(DriverInfo.ImageName); 
        driverInfo:=PSystem_Module_Information( 
        ULONG(driverInfo)+sizeof(TSystem_Module_Information)); 
     end; 
    end; 
    driverInfo:=p;   // <---why? check delphi help "FreeMem procedure". 
    FreeMem(driverInfo); 
end; 
//-------------------------------------------------------------- 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  GetDriverInfo(ListView1); 
end;

(f)

CIONO1

هناك حتى الأحلام أصبحت ممنوعة ...

إنه لعار أن ننتمي لهكذا أوطان ... لكن ... ربما العار أن نكون نحن أبناء لتلكم أوطان .. من يدري ؟!!

ليعلم أولئك ... إنّ الشعوب إنْ هي استيقظت تسحق ظُلامََهَا ...

There, even in dreams u r wanted

To be a programmer, how a nice dream it was

Leaving ...

أعيدوا لإسمي لونه المفضل

#2

السلام عليكم

مشكور كتير،، انا كنت بحاول علي كود قديم :D واحصل علي خرابيط

وثاني شي الي افادني

driverInfo:=PSystem_Module_Information(ULONG(driverInfo)+12);

ما كنت اعرف كيف اغير القيمة التي تشير إليها المؤشر بهذه السهولة :)

مع تحيات CIONO2

#3

السلام عليكم

كما كنت أتوقع لا أحد تمعن في الكود :D .

يفضل تعديل الداله GetDriverInfo كالاتي :

procedure GetDriverInfo(MyListView:TListView);

  var

    Index, numEntries: DWORD;

    driverInfo,p: PSystem_Module_Information;

    ListItem: TListItem;

    ret,Size: DWORD;

    NewColumn: TListColumn;

begin

  Size:=sizeof(TSystem_Module_Information);

  driverInfo:=allocMem( Size);

  ret := NtQuerySystemInformation(11,

  driverInfo, Size, nil);

  while ret = STATUS_INFO_LENGTH_MISMATCH do

  begin

    Inc(Size, Size);

    ReallocMem(driverInfo, Size);

    ret := NtQuerySystemInformation(SystemModuleInformation,

   driverInfo, Size, nil);

  end;

   numEntries:=ULONG(driverInfo.base);

   p:=PSystem_Module_Information(ULONG(driverInfo)+12);

   //why 12?;-)   wanna know ? check Nebbett's book.

   with MyListView do

   begin

     Align:=alLeft;

     ViewStyle:=VsReport;

     NewColumn := Columns.Add;

     NewColumn.Caption := 'Base';

     NewColumn := Columns.Add;

     NewColumn.Caption := 'Size';

     NewColumn := Columns.Add;

     NewColumn.Caption := 'Flags';

     NewColumn := Columns.Add;

     NewColumn.Caption := 'Index';

     NewColumn := Columns.Add;

     NewColumn.Caption := 'Unknown';

     NewColumn := Columns.Add;

     NewColumn.Caption := 'LoadCount';

     NewColumn := Columns.Add;

     NewColumn.Caption := 'NameOffset';

     NewColumn := Columns.Add;

     NewColumn.Caption := 'Name';

     for Index := 1 to numEntries do

     begin

        ListItem := Items.Add;

        ListItem.Caption := IntToHex(DWORD(p.Base),8);

        ListItem.SubItems.Add(IntToStr(p.Size));

        ListItem.SubItems.Add(IntToStr(p.Flags));

        ListItem.SubItems.Add(IntToStr(p.Index));

        ListItem.SubItems.Add(IntToStr(p.Unknown));

        ListItem.SubItems.Add(IntToStr(p.LoadCount));

        ListItem.SubItems.Add(IntToStr(p.ModuleNameOffset));

        ListItem.SubItems.Add(p.ImageName);

        p:=PSystem_Module_Information(

        ULONG(p)+sizeof(TSystem_Module_Information));

     end;

    end;

    FreeMem(driverInfo);

end;

(f)

CIONO1

هناك حتى الأحلام أصبحت ممنوعة ...

إنه لعار أن ننتمي لهكذا أوطان ... لكن ... ربما العار أن نكون نحن أبناء لتلكم أوطان .. من يدري ؟!!

ليعلم أولئك ... إنّ الشعوب إنْ هي استيقظت تسحق ظُلامََهَا ...

There, even in dreams u r wanted

To be a programmer, how a nice dream it was

Leaving ...

أعيدوا لإسمي لونه المفضل

هذا الموضوع مغلق.

مواضيع مشابهة