请问如何得知其他程序调用GetVersion,并修改返回结果?(200分)

  • 主题发起人 主题发起人 daWolf
  • 开始时间 开始时间
D

daWolf

Unregistered / Unconfirmed
GUEST, unregistred user!
程序A调用GetVersionEx获得系统版本信息<br>procedure TMainForm.btn1Click(Sender: TObject);<br>var<br> &nbsp;OSVerInfo: OSVERSIONINFO;<br>begin<br> &nbsp;OSVerInfo.dwOSVersionInfoSize := SizeOf(OSVerInfo);<br> &nbsp;GetVersionEx(OSVerInfo);<br> &nbsp;mem1.Lines.Add(IntToStr(OSVerInfo.dwOSVersionInfoSize));<br> &nbsp;mem1.Lines.Add(IntToStr(OSVerInfo.dwMajorVersion));<br> &nbsp;mem1.Lines.Add(IntToStr(OSVerInfo.dwMinorVersion));<br> &nbsp;mem1.Lines.Add(IntToStr(OSVerInfo.dwBuildNumber));<br> &nbsp;mem1.Lines.Add(IntToStr(OSVerInfo.dwPlatformId));<br> &nbsp;mem1.Lines.Add(OSVerInfo.szCSDVersion);<br>end;<br>那么程序B中如何得知A调用了GetVersionEx并修改返回的信息呢?<br>进一步来说,B中如何得知A调用了某一API并修改返回的结果呢?<br>初次提问还请各位先辈多多帮助~~
 
//取版本号<br>function TClientThread.GetVersions(FileName: String): string;<br> &nbsp;var<br> &nbsp; &nbsp;FileName: string;<br> &nbsp; &nbsp;InfoSize, Wnd: LongWord;<br> &nbsp; &nbsp;VerBuf: Pointer;<br> &nbsp; &nbsp;FI: PVSFixedFileInfo;<br> &nbsp; &nbsp;VerSize: LongWord;<br> &nbsp; &nbsp;ProcName:string;<br> &nbsp;begin<br> &nbsp; &nbsp;ProcName:='TDlgLoginFrm.BtnOkClick.GetVersions';<br> &nbsp; &nbsp;FileName := ExtractFilePath(ParamStr(0))+'cycomputer.exe' &nbsp;;<br> &nbsp; &nbsp;InfoSize := GetFileVersionInfoSize(PChar(FileName), Wnd);<br> &nbsp; &nbsp;if InfoSize &lt;&gt; 0 then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;GetMem(VerBuf, InfoSize);<br> &nbsp; &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp; &nbsp;if GetFileVersionInfo(PChar(FileName), Wnd, InfoSize, VerBuf) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if VerQueryValue(VerBuf, '/', Pointer(FI), VerSize) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := inttostr(DWORD(LOBYTE(HIWORD(FI.dwFileVersionMS))));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result :=Result +'.'+ inttostr(DWORD(LOWORD(LOWORD(FI.dwFileVersionMS))));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result :=Result +'.'+ inttostr(DWORD(LOBYTE(HIWORD(FI.dwFileVersionLS))));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result :=Result +'.'+ inttostr(DWORD(LOWORD(LOWORD(FI.dwFileVersionLS))));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end else Result :='0.0.0.0'<br> &nbsp; &nbsp; &nbsp; &nbsp;else Result :='0.0.0.0';<br> &nbsp; &nbsp; &nbsp;except<br> &nbsp; &nbsp; &nbsp; &nbsp;on E:exception do<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WriteErrorLog(E,ProcName);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Raise;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp; &nbsp;FreeMem(VerBuf);<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;end else Result :='0.0.0.0';<br> &nbsp;end;<br> &nbsp;<br>function GetApplicationVersion:String; &nbsp;// Added &nbsp;取得程序版本号<br>var FileName:String; <br> &nbsp; InfoSize,Wnd:DWORD; <br> &nbsp; VerBuf:Pointer; <br> &nbsp; VerInfo:^VS_FIXEDFILEINFO;<br>begin<br> Result:='0.0.0.0';<br> FileName:=Application.ExeName;<br> InfoSize:=GetFileVersionInfoSize(PChar(FileName),Wnd);<br> if InfoSize&lt;&gt;0 then<br> begin<br> &nbsp; GetMem(VerBuf,InfoSize);<br> &nbsp; try<br> &nbsp; &nbsp; if GetFileVersionInfo(PChar(FileName),Wnd,InfoSize,VerBuf) then<br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; VerInfo:=nil;<br> &nbsp; &nbsp; &nbsp; VerQueryValue(VerBuf,'/',Pointer(VerInfo),Wnd);<br> &nbsp; &nbsp; &nbsp; if VerInfo&lt;&gt;nil then Result:=Format('%d.%d.%d.%d',[VerInfo^.dwFileVersionMS shr 16,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VerInfo^.dwFileVersionMS and $0000ffff,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VerInfo^.dwFileVersionLS shr 16,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VerInfo^.dwFileVersionLS and $0000ffff]);<br> &nbsp; &nbsp; end;<br> &nbsp; finally<br> &nbsp; &nbsp; FreeMem(VerBuf,InfoSize);<br> &nbsp; end;<br> end;<br>end;
 
好复杂.<br>是不是要用到API HOOK.
 
to:myhby 不是这样子的,我没说清楚,要修改的是其他程序通过GetVersion返回的操作系统版本号<br>to:iseek 我是这样想的,监视对GetVersion的调用,调用的话就返回自定义的OSVERSIONINFO
 
API HOOK吧
 
to:Mike1234567890 估计是,但如何作呢?一般hook键盘的那套是没用了
 
自己提一下,下周一来看
 
浏览到200还没答案就结贴放分
 
直接修改 B。exe 就行了, 用winHex
 
谢谢lxggc<br>不过如果是msi呢?难道修改windows的msiexec.exe?<br>修改exe只能跳过版本检测,但并不能统一提供解决方案,我想的是找到种方法直接挂钩修改GetVersion返回的结果,这样对所有使用GetVersion判断系统的程序都有效
 
没用的,好的安装程序会监测文件的版本信息,不是就。。。
 
这样做好危险的。。。。。。。会出问题的
 
工作丢了,散分
 
hook native api
 
鐑﹀姵鍝?綅鐪嬪埌浜嗘寚鐐逛笅濡備綍缁撹创[:D]
 
后退
顶部