imgwalk.dpr

来自「一本已经绝版的好书」· DPR 代码 · 共 43 行

DPR
43
字号

// Module name: ImgWalk.C ->> ImgWalk.dpr
// Notices: Copyright (c) 1995-1997 Jeffrey Richter
// Translator: 刘麻子, Liu_mazi@126.com

library ImgWalk;

uses Windows, CmnHdr in '..\CmnHdr.pas', Other in '..\Other.pas';

var
  lp: PByte = nil;
  nLen: Integer;
  mbi: TMemoryBasicInformation;
  szBuf: array[0..MAX_PATH * 30] of Char = '';
  szModName: array[0..MAX_PATH] of Char = '';

  // DLL 入口
begin
  while VirtualQuery(lp, mbi, SizeOf(mbi)) = SizeOf(mbi) do
  begin
    if (mbi.State = MEM_FREE) then mbi.AllocationBase := mbi.BaseAddress;

    if (DWORD(mbi.AllocationBase) = HInstance) or // 1. If this region contains this DLL
       (mbi.AllocationBase <> mbi.BaseAddress) or // 2. If this block is NOT the beginning of a region
       (mbi.AllocationBase = nil) then            // 3. If the address is NULL
    begin
      nLen := 0;
    end else
    begin
      nLen := GetModuleFileName(DWORD(mbi.AllocationBase), szModName, chDIMOF(szModName));
    end;

    if (nLen > 0) then
    begin
      _wvsprintf(StrChr(szBuf, #0), #13#10'%08X-%s', [ DWORD(mbi.AllocationBase), DWORD(@szModName) ]);
    end;  

    Inc(lp, mbi.RegionSize);
  end;

  chMB(szBuf, 'ImgWalk');
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?