我要修改其内存数据,但是发现有时候地址不同,但是偏移是一样的,要先获得基址

解决方案 »

  1.   

    用Depend看一下,是VS自带的工具
    http://www.dependencywalker.com/
      

  2.   


    function GetModuleHandle2(ProcessID:Dword;sDllName: string): Dword;
    var
      th32handle: THandle;
      me32:TModuleEntry32;
      finded : Boolean;
    begin
      finded := False;
      th32handle:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,ProcessID);
      if th32handle = INVALID_HANDLE_VALUE then Exit;
      me32.dwSize := sizeof(TModuleEntry32);
      if Module32First( th32handle,me32 ) then
      repeat
        if AnsiStricomp(PChar(ExtractFilename(me32.szExePath )), PChar(ExtractFilename(sDllName))) = 0 then
        begin
          Result := me32.hModule ;
          break;
        end;
      until not Module32Next(th32handle,me32);
    end;