Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 팁&트릭
Delphi Programming Tip&Tricks
[237] 시스템에 로딩된 드라이버 리스트
박지훈.임프 [cbuilder] 4778 읽음    2008-04-02 14:51
다음 페이지에서 퍼온 내용입니다.
http://www.swissdelphicenter.ch/torry/showcode.php?id=961

{
  This code takes advantage of the undocumented NtQuerySystemInformation
  API to obtain a list of loaded drivers under Windows NT.

  Dieser Code verwendet die undokumentiere NtQuerySystemInformation API Funktion
  um eine Liste aller geladenen Treiber unter Windows NT zu ermitteln.
}

const
  DRIVER_INFORMATION = 11;

type
  TPDWord = ^DWORD;

  TDriverInfo = packed record
    Address: Pointer;
    Unknown1: DWORD;
    Unknown2: DWORD;
    EntryIndex: DWORD;
    Unknown4: DWORD;
    Name: array [0..MAX_PATH + 3] of Char;
  end;

var
  NtQuerySystemInformation: function (infoClass: DWORD;
  buffer: Pointer;
  bufSize: DWORD;
  returnSize: TPDword): DWORD; stdcall = nil;

  function GetDriverInfo: string;
  var 
    temp, Index, numBytes, numEntries: DWORD;
    buf: TPDword;
    driverInfo: ^TDriverInfo;
  begin
    if @NtQuerySystemInformation = nil then
      NtQuerySystemInformation := GetProcAddress(GetModuleHandle('ntdll.dll'),
        'NtQuerySystemInformation');

    // Obtain required buffer size
    NtQuerySystemInformation(DRIVER_INFORMATION, @temp, 0, @numBytes);
    // Allocate buffer
    buf := AllocMem(numBytes * 2);

    NtQuerySystemInformation(DRIVER_INFORMATION, buf, numBytes * 2, @numBytes);
    numEntries := buf^;
    driverInfo := Pointer(DWORD(buf) + 12);
    Result     := '';
    for Index := 1 to numEntries do 
    begin
      Result := Result + #$D#$A + 'Address: $' + IntToHex(DWORD(driverInfo^.Address), 8) +
        'Name: "' + (driverInfo^.Name) + '"';
      Inc(driverInfo);
    end;
    Delete(Result, 1, 2);
    FreeMem(buf);
  end;

  procedure TForm1.Button1Click(Sender: TObject);
  begin
    ListBox1.Items.Add(GetDriverInfo)
  end;


  // Thanks to Madshi for helping me translate from C++ Code
  // Original Code (C++) :
  //                             NtDriverList v1.0
  //                      Copyright 1998, 1999 Yariv Kaplan
  //                             WWW.INTERNALS.COM

+ -

관련 글 리스트
237 시스템에 로딩된 드라이버 리스트 박지훈.임프 4778 2008/04/02
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.