您正在使用一款已经过时的浏览器!部分功能不能正常使用。
请尝试升级或使用
其他浏览器。
金山词霸里那个屏幕取词的库文件怎么用?(100分)
macrolen
Unregistered / Unconfirmed
GUEST, unregistred user!
听说可以直接调用金山词霸里的一个库文件,就能实现屏幕取词,该怎么弄呀!
yaya8163
Unregistered / Unconfirmed
GUEST, unregistred user!
AME
Unregistered / Unconfirmed
GUEST, unregistred user!
dfs
Unregistered / Unconfirmed
GUEST, unregistred user!
YB_unique
Unregistered / Unconfirmed
GUEST, unregistred user!
晨晨
Unregistered / Unconfirmed
GUEST, unregistred user!
macrolen
Unregistered / Unconfirmed
GUEST, unregistred user!
我用exescope看了,还是一头雾水,有人有delphi的原程序么?发我一份吧!<br>macrolen@163.net
酷尔贝塔
Unregistered / Unconfirmed
GUEST, unregistred user!
godzhou
Unregistered / Unconfirmed
GUEST, unregistred user!
去csdn找找<br>我记得以前下过一个老外(可能是)写的源程序,不过是文本文件的方式,不是.pas,<br>但是当我把这些代码粘贴到delphi中,运行后没什么用。可能是我的方法有问题。<br>可是现在再去csdn搜这篇文章,找不到了。不过上面还是有几篇屏幕取词的文章的,<br>不知道有没有什么用。<br><br>谁成功了告诉我一声!<br>godzhou@163.net
jbas
Unregistered / Unconfirmed
GUEST, unregistred user!
macrolen
Unregistered / Unconfirmed
GUEST, unregistred user!
我在CSDN找到了一篇:<br><br>Yes. I already posted the answer before you<br>asked the question, under "Answer: Hook TextOut and other API" But here it is again, for delphi 3 under windows 95<br>(and I've heard it works in Delphi 5 under windows 2000)<br><br>As for books about internal windows stuff, the two authors you are after are Matt Pietrek, and Jeffrey Richter. I think Jeffrey Richter's book you are after is now called something like Developing Applications for Windows,<br>but it used to have a different name "Advanced Windows". Actually I haven't read either of their latest books. This is all my own work and not really based on anything of theirs.<br><br>From:<br> Carl Kenner <carl_kenner@hotmail.com><br><br>Tue 3:01<br><br>Subject:<br> Answer: Hook TextOut and other API<br><br>I finally worked out how to hook all windows functions<br>and replace them with my own. To demonstrate I made<br>a delphi program that will hook into all the TextOut<br>functions in all of your programs, so that all the text<br>displayed on the screen is in Pig Latin.<br><br>This program has only been tested on WINDOWS 95<br>Let me know if it works on 98 or Me or NT or 2000<br><br>Enjoy!<br><br>Carl Kenner<br><br>PS. It took me a whole year of research to work this<br>out, so if you give me some credit I will be happy.<br>=================================<br><br>library PigLatinDll;<br><br>uses<br> Windows,<br> SysUtils,<br> Classes,<br> HookTextUnit in 'HookTextUnit.pas';<br><br>function PigLatinWord(s: String): String;<br>Var start: String; Capitalize, AllCapitals: Boolean; i: Integer; begin<br> Result:=s;<br> if length(s)<=1 then exit;<br> Capitalize:=IsCharUpper(s[1]);<br> AllCapitals:=True;<br> for i:=1 to length(s) do begin<br> if IsCharLower(s
) then begin<br> AllCapitals:=False; break;<br> end;<br> end;<br> start:=lowercase(copy(s,1,2));<br> if (start[1]<'a') or (start[1]>'z') then exit;<br> if (start[1] in ['a','e','i','o','u']) then start:='';<br> if (start<>'ch') and (start<>'th') and (start<>'sh') and (start<>'wh') <br><br> and (start<>'qu') and (start<>'kn') and (start<>'wr') then delete(start,2,1);<br> Result:=copy(s,length(start)+1,length(s))+start;<br> if start='' then Result:=Result+'yay' else Result:=Result+'ay'; if AllCapitals then result:=Uppercase(Result) else<br> if Capitalize then result[1]:=Upcase(result[1]);<br>end;<br><br>function IntToRoman(n: Integer): String;<br>Var i, units, tens, hundreds, thousands: Integer;<br>begin<br> If (n>=5000) or (n<=0) then Result:=IntToStr else begin thousands:=n div 1000; n:=n mod 1000;<br> hundreds:=n div 100; n:=n mod 100;<br> tens:=n div 10; n:=n mod 10;<br> units:=n;<br> Result:='';<br> for i:=1 to Thousands do begin<br> Result:=Result+'M';<br> end;<br> Case Hundreds of<br> 1: Result:=Result+'C';<br> 2: Result:=Result+'CC';<br> 3: Result:=Result+'CCC';<br> 4: Result:=Result+'CD';<br> 5: Result:=Result+'D';<br> 6: Result:=Result+'DC';<br> 7: Result:=Result+'DCC';<br> 8: Result:=Result+'DCCC';<br> 9: Result:=Result+'CM';<br> end;<br> Case Tens of<br> 1: Result:=Result+'X';<br> 2: Result:=Result+'XX';<br> 3: Result:=Result+'XXX';<br> 4: Result:=Result+'XL';<br> 5: Result:=Result+'L';<br> 6: Result:=Result+'LX';<br> 7: Result:=Result+'LXX';<br> 8: Result:=Result+'LXXX';<br> 9: Result:=Result+'XC';<br> end;<br> Case Units of<br> 1: Result:=Result+'I';<br> 2: Result:=Result+'II';<br> 3: Result:=Result+'III';<br> 4: Result:=Result+'IV';<br> 5: Result:=Result+'V';<br> 6: Result:=Result+'VI';<br> 7: Result:=Result+'VII';<br> 8: Result:=Result+'VIII';<br> 9: Result:=Result+'IX';<br> end;<br> end;<br>end;<br><br>function LatinNumber(s: String): String;<br>Var n: Integer;<br>begin<br> try<br> n:=StrToInt(s);<br> Result:=IntToRoman;<br> except<br> Result:=s;<br> end;<br>end;<br><br>function Conv(s: String): String;<br>Var i: Integer; w: String;<br>begin<br> Result:='';<br> try<br> if s='' then exit;<br> i:=1;<br> while (i<=length(s)) do begin<br> while (i<=length(s)) and (s<=' ') do begin<br> Result:=Result+s;<br> Inc(i);<br> end;<br><br> // convert any numbers into latin numbers<br> w:='';<br> while (i<=length(s)) and (s>='0') and (s<='9') do begin w:=w+s;<br> Inc(i);<br> end;<br> Result:=Result+LatinNumber(w);<br><br> // add any other symbols unchanged (for now)<br> w:='';<br> while (i<=length(s)) and not IsCharAlphaNumeric(s) do begin w:=w+s;<br> Inc(i);<br> end;<br> Result:=Result+w;<br><br> // convert whole words into pig latin<br> w:='';<br> while (i<=length(s)) and IsCharAlpha(s) do begin<br> w:=w+s;<br> Inc(i);<br> end;<br> Result:=Result+PigLatinWord(w);<br> end;<br> except<br> end;<br>end;<br><br>function GetMsgProc(code: integer; removal: integer; msg: Pointer): Integer; stdcall;<br>begin<br> Result:=0;<br>end;<br><br>Var HookHandle: THandle;<br><br>procedure StartHook; stdcall;<br>begin<br> HookHandle:=SetWindowsHookEx(WH_GETMESSAGE, @GetMsgProc, HInstance, 0);<br>end;<br><br>procedure StopHook; stdcall;<br>begin<br> UnhookWindowsHookEx(HookHandle);<br>end;<br><br>exports StartHook, StopHook;<br><br>begin<br> HookTextOut(Conv);<br>end.<br><br>====================================================<br><br>unit HookTextUnit;<br><br>interface<br>uses Windows, SysUtils, Classes, PEStuff;<br><br>type<br> TConvertTextFunction = function(text: String): String;<br> TTextOutA = function(hdc: HDC; x,y: Integer; text: PAnsiChar; len: Integer): BOOL; stdcall;<br> TTextOutW = function(hdc: HDC; x,y: Integer; text: PWideChar; len: Integer): BOOL; stdcall;<br> TExtTextOutA = function(hdc: HDC; x,y: Integer; Options: DWORD; Clip: PRect;<br> text: PAnsiChar; len: Integer; dx: PInteger): BOOL; stdcall;<br> TExtTextOutW = function(hdc: HDC; x,y: Integer; Options: DWORD; Clip: PRect;<br> text: PWideChar; len: Integer; dx: PInteger): BOOL; stdcall;<br> TDrawTextA = function(hdc: HDC; text: PAnsiChar; len: Integer; rect: PRect;<br> Format: DWORD): Integer; stdcall;<br> TDrawTextW = function(hdc: HDC; text: PWideChar; len: Integer; rect: PRect;<br> Format: DWORD): Integer; stdcall;<br> TDrawTextExA = function(hdc: HDC; text: PAnsiChar; len: Integer; rect: PRect;<br> Format: DWORD; DTParams: PDrawTextParams): Integer; stdcall;<br> TDrawTextExW = function(hdc: HDC; text: PWideChar; len: Integer; rect: PRect;<br> Format: DWORD; DTParams: PDrawTextParams): Integer; stdcall;<br><br> TTabbedTextOutA = function(hdc: HDC; x,y: Integer; text: PAnsiChar; len: Integer;<br> TabCount: Integer; TabPositions: PInteger; TabOrigin: Integer): Integer; stdcall;<br> TTabbedTextOutW = function(hdc: HDC; x,y: Integer; text: PWideChar; len: Integer;<br> TabCount: Integer; TabPositions: PInteger; TabOrigin: Integer): Integer; stdcall;<br> TPolyTextOutA = function(hdc: HDC; pptxt: PPOLYTEXTA; count: Integer): BOOL; stdcall;<br> TPolyTextOutW = function(hdc: HDC; pptxt: PPOLYTEXTW; count: Integer): BOOL; stdcall;<br><br> TGetTextExtentExPointA = function(hdc: HDC; text: PAnsiChar; len: Integer;<br> maxExtent: Integer; Fit: PInteger; Dx: PInteger; Size: Pointer): BOOL; stdcall;<br> TGetTextExtentExPointW = function(hdc: HDC; text: PWideChar; len: Integer;<br> maxExtent: Integer; Fit: PInteger; Dx: PInteger; Size: Pointer): BOOL; stdcall;<br> TGetTextExtentPoint32A = function(hdc: HDC; text: PAnsiChar; len: Integer; Size: Pointer): BOOL; stdcall;<br> TGetTextExtentPoint32W = function(hdc: HDC; text: PWideChar; len: Integer; Size: Pointer): BOOL; stdcall;<br> TGetTextExtentPointA = function(hdc: HDC; text: PAnsiChar; len: Integer; Size: Pointer): BOOL; stdcall;<br> TGetTextExtentPointW = function(hdc: HDC; text: PWideChar; len: Integer; Size: Pointer): BOOL; stdcall;<br><br> PPointer = ^Pointer;<br><br> TImportCode = packed record<br> JumpInstruction: Word; // should be $25FF<br> AddressOfPointerToFunction: PPointer;<br> end;<br> PImportCode = ^TImportCode;<br><br>procedure HookTextOut(ConvertFunction: TConvertTextFunction);<br>procedure UnhookTextOut;<br><br>implementation<br><br>Var<br> ConvertTextFunction: TConvertTextFunction = nil;<br> OldTextOutA: TTextOutA = nil;<br> OldTextOutW: TTextOutW = nil;<br> OldExtTextOutA: TExtTextOutA = nil;<br> OldExtTextOutW: TExtTextOutW = nil;<br> OldDrawTextA: TDrawTextA = nil;<br> OldDrawTextW: TDrawTextW = nil;<br> OldDrawTextExA: TDrawTextExA = nil;<br> OldDrawTextExW: TDrawTextExW = nil;<br> OldTabbedTextOutA: TTabbedTextOutA = nil;<br> OldTabbedTextOutW: TTabbedTextOutW = nil;<br> OldPolyTextOutA: TPolyTextOutA = nil;<br> OldPolyTextOutW: TPolyTextOutW = nil;<br> OldGetTextExtentExPointA: TGetTextExtentExPointA = nil;<br> OldGetTextExtentExPointW: TGetTextExtentExPointW = nil;<br> OldGetTextExtentPoint32A: TGetTextExtentPoint32A = nil;<br> OldGetTextExtentPoint32W: TGetTextExtentPoint32W = nil;<br> OldGetTextExtentPointA: TGetTextExtentPointA = nil;<br> OldGetTextExtentPointW: TGetTextExtentPointW = nil;<br><br>function StrLenW(s: PWideChar): Integer;<br>Var i: Integer;<br>begin<br> if s=nil then begin<br> Result:=0; exit;<br> end;<br> i:=0;<br> try<br> while (s<>#0) do inc(i);<br> except<br> end;<br> Result:=i;<br>end;<br><br>function NewTextOutA(hdc: HDC; x,y: Integer; text: PAnsiChar; len: Integer): BOOL; stdcall;<br>Var s: String;<br>begin<br> try<br> if Len<0 then Len:=strlen(text);<br> If Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldTextOutA<>nil then<br> Result:=OldTextOutA(hdc,x,y,PAnsiChar(s),length(s))<br> else<br> Result:=False;<br> end else Result:=OldTextOutA(hdc,x,y,PAnsiChar(s),0);<br> except<br> Result:=False;<br> end;<br>end;<br><br>function NewTextOutW(hdc: HDC; x,y: Integer; text: PWideChar; len: Integer): BOOL; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> If Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len*2);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldTextOutW<>nil then<br> Result:=OldTextOutW(hdc,x,y,PWideChar(s),length(s))<br> else<br> Result:=False;<br> end else Result:=OldTextOutW(hdc,x,y,PWideChar(s),0);<br> except<br> Result:=False;<br> end;<br>end;<br>function NewExtTextOutA(hdc: HDC; x,y: Integer; Options: DWORD; Clip: PRect;<br> text: PAnsiChar; len: Integer; dx: PInteger): BOOL; stdcall;<br>Var s: String;<br>begin<br> try<br> if Len<0 then Len:=strlen(text); // ???<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then s:=ConvertTextFunction(s); if @OldExtTextOutA<>nil then<br><br>Result:=OldExtTextOutA(hdc,x,y,Options,Clip,PAnsiChar(s),length(s),dx) else Result:=False;<br> end else Result:=OldExtTextOutA(hdc,x,y,Options,Clip,text,0,dx); except<br> Result:=False;<br> end;<br>end;<br><br>function NewExtTextOutW(hdc: HDC; x,y: Integer; Options: DWORD; Clip: PRect;<br> text: PWideChar; len: Integer; dx: PInteger): BOOL; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> If Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len*2);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldExtTextOutW<>nil then<br><br>Result:=OldExtTextOutW(hdc,x,y,Options,Clip,PWideChar(s),length(s),dx) else Result:=False;<br> end else Result:=OldExtTextOutW(hdc,x,y,Options,Clip,text,0,dx); except<br> Result:=False;<br> end;<br>end;<br><br>function NewDrawTextA(hdc: HDC; text: PAnsiChar; len: Integer; rect: PRect;<br> Format: DWORD): Integer; stdcall;<br>Var s: String;<br>begin<br> try<br> if Len<0 then Len:=strlen(text); // ???<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldDrawTextA<>nil then<br> Result:=OldDrawTextA(hdc,PAnsiChar(s),length(s),rect,Format) else Result:=0;<br> end else Result:=OldDrawTextA(hdc,text,0,rect,Format);<br> except<br> Result:=0;<br> end;<br>end;<br><br>function NewDrawTextW(hdc: HDC; text: PWideChar; len: Integer; rect: PRect;<br> Format: DWORD): Integer; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> if len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len*2);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldDrawTextW<>nil then<br> Result:=OldDrawTextW(hdc,PWideChar(s),length(s),rect,Format) else Result:=0;<br> end else Result:=OldDrawTextW(hdc,text,0,rect,Format);<br> except<br> Result:=0;<br> end;<br>end;<br><br>function NewDrawTextExA(hdc: HDC; text: PAnsiChar; len: Integer; rect: PRect;<br> Format: DWORD; DTParams: PDrawTextParams): Integer; stdcall;<br>Var s: String;<br>begin<br> try<br> if Len<0 then Len:=strlen(text);<br> if len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldDrawTextExA<>nil then<br><br>Result:=OldDrawTextExA(hdc,PAnsiChar(s),length(s),rect,Format,DTParams) else Result:=0;<br> end else Result:=OldDrawTextExA(hdc,text,0,rect,Format,DTParams); except<br> Result:=0;<br> end;<br>end;<br><br>function NewDrawTextExW(hdc: HDC; text: PWideChar; len: Integer; rect: PRect;<br> Format: DWORD; DTParams: PDrawTextParams): Integer; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len*2);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldDrawTextExW<>nil then<br><br>Result:=OldDrawTextExW(hdc,PWideChar(s),length(s),rect,Format,DTParams) else Result:=0;<br> end else Result:=OldDrawTextExW(hdc,text,0,rect,Format,DTParams); except<br> Result:=0;<br> end;<br>end;<br><br>function NewTabbedTextOutA(hdc: HDC; x,y: Integer; text: PAnsiChar; len: Integer;<br> TabCount: Integer; TabPositions: PInteger; TabOrigin: Integer): Integer; stdcall;<br>Var s: AnsiString;<br>begin<br> try<br> if Len<0 then Len:=strlen(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldTabbedTextOutA<>nil then<br><br>Result:=OldTabbedTextOutA(hdc,x,y,PAnsiChar(s),length(s),TabCount,TabPositions,TabOrigin) <br><br> else Result:=0;<br> end else<br>Result:=OldTabbedTextOutA(hdc,x,y,text,0,TabCount,TabPositions,TabOrigin); <br><br> except<br> Result:=0;<br> end;<br>end;<br><br>function NewTabbedTextOutW(hdc: HDC; x,y: Integer; text: PWideChar; len: Integer;<br> TabCount: Integer; TabPositions: PInteger; TabOrigin: Integer): Integer; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len*2);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldTabbedTextOutW<>nil then<br>Result:=OldTabbedTextOutW(hdc,x,y,PWideChar(s),length(s),TabCount,TabPositions,TabOrigin) <br><br> else Result:=0;<br> end else<br>Result:=OldTabbedTextOutW(hdc,x,y,text,0,TabCount,TabPositions,TabOrigin); <br><br> except<br> Result:=0;<br> end;<br>end;<br><br>function NewPolyTextOutA(hdc: HDC; pptxt: PPOLYTEXTA; count: Integer): BOOL; stdcall;<br>Var s: String; i: Integer; ppnew: PPOLYTEXTA;<br>begin<br> ppnew:=nil;<br> try<br> Result:=False;<br> if Count<0 then exit;<br> if Count=0 then begin Result:=True; exit; end;<br> GetMem(ppnew,count*sizeof(TPOLYTEXTA));<br> For i:=1 to count do begin<br> ppnew^:=pptxt^;<br> if ppnew^.n<0 then ppnew^.n:=strlen(ppnew^.PAnsiChar);<br> if ppnew^.n>0 then begin<br> SetLength(s,ppnew^.n);<br> FillChar(s[1],ppnew^.n+1,0);<br> Move(ppnew^.PAnsiChar,s[1],ppnew^.n);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> ppnew^.PAnsiChar:=PAnsiChar(s);<br> ppnew^.n:=length(s);<br> if @OldPolyTextOutA<>nil then<br> Result:=OldPolyTextOutA(hdc,ppnew,1);<br> end;<br> Inc(pptxt);<br> end;<br> except<br> Result:=False;<br> end;<br> if ppnew<>nil then FreeMem(ppnew);<br>end;<br><br>function NewPolyTextOutW(hdc: HDC; pptxt: PPOLYTEXTW; count: Integer): BOOL; stdcall;<br>begin<br> Result:=OldPolyTextOutW(hdc,pptxt,count);<br>end;<br><br>function NewGetTextExtentExPointA(hdc: HDC; text: PAnsiChar; len: Integer;<br> maxExtent: Integer; Fit: PInteger; Dx: PInteger; Size: Pointer): BOOL; stdcall;<br>Var s: AnsiString;<br>begin<br> try<br> if Len<0 then Len:=strlen(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldGetTextExtentExPointA<>nil then<br><br>Result:=OldGetTextExtentExPointA(hdc,PAnsiChar(s),length(s),maxExtent,Fit,Dx,Size) <br><br> else Result:=False;<br> end else<br>Result:=OldGetTextExtentExPointA(hdc,text,0,maxExtent,Fit,Dx,Size); except<br> Result:=False;<br> end;<br>end;<br><br>Function NewGetTextExtentExPointW(hdc: HDC; text: PWideChar; len: Integer;<br> maxExtent: Integer; Fit: PInteger; Dx: PInteger; Size: Pointer): BOOL; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldGetTextExtentExPointW<>nil then<br><br>Result:=OldGetTextExtentExPointW(hdc,PWideChar(s),length(s),maxExtent,Fit,Dx,Size) <br><br> else Result:=False;<br> end else<br>Result:=OldGetTextExtentExPointW(hdc,text,0,maxExtent,Fit,Dx,Size); except<br> Result:=False;<br> end;<br>end;<br><br>function NewGetTextExtentPoint32A(hdc: HDC; text: PAnsiChar; len: Integer; Size: Pointer): BOOL; stdcall;<br>Var s: AnsiString;<br>begin<br> try<br> if Len<0 then Len:=strlen(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldGetTextExtentPoint32A<>nil then<br><br>Result:=OldGetTextExtentPoint32A(hdc,PAnsiChar(s),length(s),Size) else Result:=False;<br> end else Result:=OldGetTextExtentPoint32A(hdc,text,0,Size);<br> except<br> Result:=False;<br> end;<br>end;<br><br>function NewGetTextExtentPoint32W(hdc: HDC; text: PWideChar; len: Integer; Size: Pointer): BOOL; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldGetTextExtentPoint32W<>nil then<br><br>Result:=OldGetTextExtentPoint32W(hdc,PWideChar(s),length(s),Size) else Result:=False;<br> end else Result:=OldGetTextExtentPoint32W(hdc,text,0,Size);<br> except<br> Result:=False;<br> end;<br>end;<br>function NewGetTextExtentPointA(hdc: HDC; text: PAnsiChar; len: Integer; Size: Pointer): BOOL; stdcall;<br>Var s: AnsiString;<br>begin<br> try<br> if Len<0 then Len:=strlen(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len+1,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldGetTextExtentPointA<>nil then<br> Result:=OldGetTextExtentPointA(hdc,PAnsiChar(s),length(s),Size) else Result:=False;<br> end else Result:=OldGetTextExtentPointA(hdc,text,0,Size);<br> except<br> Result:=False;<br> end;<br>end;<br><br><br>function NewGetTextExtentPointW(hdc: HDC; text: PWideChar; len: Integer; Size: Pointer): BOOL; stdcall;<br>Var s: WideString;<br>begin<br> try<br> if Len<0 then Len:=strlenW(text);<br> if Len>0 then begin<br> SetLength(s,len);<br> FillChar(s[1],len*2+2,0);<br> Move(text^,s[1],len);<br> if @ConvertTextFunction<>nil then<br> s:=ConvertTextFunction(s);<br> if @OldGetTextExtentPoint32W<>nil then<br> Result:=OldGetTextExtentPointW(hdc,PWideChar(s),length(s),Size) else Result:=False;<br> end else Result:=OldGetTextExtentPointW(hdc,text,0,Size);<br> except<br> Result:=False;<br> end;<br>end;<br><br>function PointerToFunctionAddress(Code: Pointer): PPointer;<br>Var func: PImportCode;<br>begin<br> Result:=nil;<br> if Code=nil then exit;<br> try<br> func:=code;<br> if (func.JumpInstruction=$25FF) then begin<br> Result:=func.AddressOfPointerToFunction;<br> end;<br> except<br> Result:=nil;<br> end;<br>end;<br><br>function FinalFunctionAddress(Code: Pointer): Pointer;<br>Var func: PImportCode;<br>begin<br> Result:=Code;<br> if Code=nil then exit;<br> try<br> func:=code;<br> if (func.JumpInstruction=$25FF) then begin<br> Result:=func.AddressOfPointerToFunction^;<br> end;<br> except<br> Result:=nil;<br> end;<br>end;<br><br><br>Function PatchAddress(OldFunc, NewFunc: Pointer): Integer;<br>Var BeenDone: TList;<br><br>Function PatchAddressInModule(hModule: THandle; OldFunc, NewFunc: Pointer): Integer;<br>Var Dos: PImageDosHeader; NT: PImageNTHeaders;<br>ImportDesc: PImage_Import_Entry; rva: DWORD;<br>Func: PPointer; DLL: String; f: Pointer; written: DWORD;<br>begin<br> Result:=0;<br> Dos:=Pointer(hModule);<br> if BeenDone.IndexOf(Dos)>=0 then exit;<br> BeenDone.Add(Dos);<br> OldFunc:=FinalFunctionAddress(OldFunc);<br> if IsBadReadPtr(Dos,SizeOf(TImageDosHeader)) then exit;<br> if Dos.e_magic<>IMAGE_DOS_SIGNATURE then exit;<br> NT :=Pointer(Integer(Dos) + dos._lfanew);<br>// if IsBadReadPtr(NT,SizeOf(TImageNtHeaders)) then exit;<br><br>RVA:=NT^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; <br><br> if RVA=0 then exit;<br> ImportDesc := pointer(integer(Dos)+RVA);<br> While (ImportDesc^.Name<>0) do begin<br> DLL:=PChar(Integer(Dos)+ImportDesc^.Name);<br> PatchAddressInModule(GetModuleHandle(PChar(DLL)),OldFunc,NewFunc); Func:=Pointer(Integer(DOS)+ImportDesc.LookupTable);<br> While Func^<>nil do begin<br> f:=FinalFunctionAddress(Func^);<br> if f=OldFunc then begin<br> WriteProcessMemory(GetCurrentProcess,Func,@NewFunc,4,written); If Written>0 then Inc(Result);<br> end;<br> Inc(Func);<br> end;<br> Inc(ImportDesc);<br> end;<br>end;<br><br><br>begin<br> BeenDone:=TList.Create;<br> try<br> Result:=PatchAddressInModule(GetModuleHandle(nil),OldFunc,NewFunc); finally<br> BeenDone.Free;<br> end;<br>end;<br><br>procedure HookTextOut(ConvertFunction: TConvertTextFunction);<br>begin<br> if @OldTextOutA=nil then<br> @OldTextOutA:=FinalFunctionAddress(@TextOutA);<br> if @OldTextOutW=nil then<br> @OldTextOutW:=FinalFunctionAddress(@TextOutW);<br><br> if @OldExtTextOutA=nil then<br> @OldExtTextOutA:=FinalFunctionAddress(@ExtTextOutA);<br> if @OldExtTextOutW=nil then<br> @OldExtTextOutW:=FinalFunctionAddress(@ExtTextOutW);<br><br> if @OldDrawTextA=nil then<br> @OldDrawTextA:=FinalFunctionAddress(@DrawTextA);<br> if @OldDrawTextW=nil then<br> @OldDrawTextW:=FinalFunctionAddress(@DrawTextW);<br><br> if @OldDrawTextExA=nil then<br> @OldDrawTextExA:=FinalFunctionAddress(@DrawTextExA);<br> if @OldDrawTextExW=nil then<br> @OldDrawTextExW:=FinalFunctionAddress(@DrawTextExW);<br><br> if @OldTabbedTextOutA=nil then<br> @OldTabbedTextOutA:=FinalFunctionAddress(@TabbedTextOutA);<br> if @OldTabbedTextOutW=nil then<br> @OldTabbedTextOutW:=FinalFunctionAddress(@TabbedTextOutW);<br><br> if @OldPolyTextOutA=nil then<br> @OldPolyTextOutA:=FinalFunctionAddress(@PolyTextOutA);<br> if @OldPolyTextOutW=nil then<br> @OldPolyTextOutW:=FinalFunctionAddress(@PolyTextOutW);<br><br> if @OldGetTextExtentExPointA=nil then<br><br>@OldGetTextExtentExPointA:=FinalFunctionAddress(@GetTextExtentExPointA); <br><br> if @OldGetTextExtentExPointW=nil then<br><br>@OldGetTextExtentExPointW:=FinalFunctionAddress(@GetTextExtentExPointW); <br><br> if @OldGetTextExtentPoint32A=nil then<br><br>@OldGetTextExtentPoint32A:=FinalFunctionAddress(@GetTextExtentPoint32A); <br><br> if @OldGetTextExtentPoint32W=nil then<br><br>@OldGetTextExtentPoint32W:=FinalFunctionAddress(@GetTextExtentPoint32W); <br><br><br> if @OldGetTextExtentPointA=nil then<br> @OldGetTextExtentPointA:=FinalFunctionAddress(@GetTextExtentPointA); <br><br> if @OldGetTextExtentPointW=nil then<br> @OldGetTextExtentPointW:=FinalFunctionAddress(@GetTextExtentPointW); <br><br><br><br> @ConvertTextFunction:=@ConvertFunction;<br><br> PatchAddress(@OldTextOutA, @NewTextOutA);<br> PatchAddress(@OldTextOutW, @NewTextOutW);<br> PatchAddress(@OldExtTextOutA, @NewExtTextOutA);<br> PatchAddress(@OldExtTextOutW, @NewExtTextOutW);<br> PatchAddress(@OldDrawTextA, @NewDrawTextA);<br> PatchAddress(@OldDrawTextW, @NewDrawTextW);<br> PatchAddress(@OldDrawTextExA, @NewDrawTextExA);<br> PatchAddress(@OldDrawTextExW, @NewDrawTextExW);<br> PatchAddress(@OldTabbedTextOutA, @NewTabbedTextOutA);<br> PatchAddress(@OldTabbedTextOutW, @NewTabbedTextOutW);<br> PatchAddress(@OldPolyTextOutA, @NewPolyTextOutA);<br> PatchAddress(@OldPolyTextOutW, @NewPolyTextOutW);<br> PatchAddress(@OldGetTextExtentExPointA, @NewGetTextExtentExPointA); PatchAddress(@OldGetTextExtentExPointW, @NewGetTextExtentExPointW); PatchAddress(@OldGetTextExtentPoint32A, @NewGetTextExtentPoint32A); PatchAddress(@OldGetTextExtentPoint32W, @NewGetTextExtentPoint32W); PatchAddress(@OldGetTextExtentPointA, @NewGetTextExtentPointA); PatchAddress(@OldGetTextExtentPointW, @NewGetTextExtentPointW); end;<br><br>procedure UnhookTextOut;<br>begin<br> If @OldTextOutA<>nil then begin<br> PatchAddress(@NewTextOutA, @OldTextOutA);<br> PatchAddress(@NewTextOutW, @OldTextOutW);<br> PatchAddress(@NewExtTextOutA, @OldExtTextOutA);<br> PatchAddress(@NewExtTextOutW, @OldExtTextOutW);<br> PatchAddress(@NewDrawTextA, @OldDrawTextA);<br> PatchAddress(@NewDrawTextW, @OldDrawTextW);<br> PatchAddress(@NewDrawTextExA, @OldDrawTextExA);<br> PatchAddress(@NewDrawTextExW, @OldDrawTextExW);<br> PatchAddress(@NewTabbedTextOutA, @OldTabbedTextOutA);<br> PatchAddress(@NewTabbedTextOutW, @OldTabbedTextOutW);<br> PatchAddress(@NewPolyTextOutA, @OldPolyTextOutA);<br> PatchAddress(@NewPolyTextOutW, @OldPolyTextOutW);<br> PatchAddress(@NewGetTextExtentExPointA, @OldGetTextExtentExPointA); PatchAddress(@NewGetTextExtentExPointW, @OldGetTextExtentExPointW); PatchAddress(@NewGetTextExtentPoint32A, @OldGetTextExtentPoint32A); PatchAddress(@NewGetTextExtentPoint32W, @OldGetTextExtentPoint32W); PatchAddress(@NewGetTextExtentPointA, @OldGetTextExtentPointA); PatchAddress(@NewGetTextExtentPointW, @OldGetTextExtentPointW); end;<br>end;<br><br>initialization<br>finalization<br> UnhookTextOut;<br>end.<br><br>===================================================<br>unit PEStuff;<br><br>interface<br>uses Windows;<br><br>type<br> PImageDosHeader = ^TImageDosHeader;<br> _IMAGE_DOS_HEADER = packed record { DOS .EXE<br>header }<br> e_magic: Word; { Magic<br>number }<br> e_cblp: Word; { Bytes on last page of file }<br> e_cp: Word; { Pages in<br>file }<br> e_crlc: Word; {<br>Relocations }<br> e_cparhdr: Word; { Size of header in<br>paragraphs }<br> e_minalloc: Word; { Minimum extra paragraphs needed }<br> e_maxalloc: Word; { Maximum extra paragraphs needed }<br> e_ss: Word; { Initial (relative) SS value }<br> e_sp: Word; { Initial SP<br>value }<br> e_csum: Word; {<br>Checksum }<br> e_ip: Word; { Initial IP<br>value }<br> e_cs: Word; { Initial (relative) CS value }<br> e_lfarlc: Word; { File address of relocation table }<br> e_ovno: Word; { Overlay<br>number }<br> e_res: array [0..3] of Word; { Reserved<br>words }<br> e_oemid: Word; { OEM identifier (for<br>e_oeminfo) }<br> e_oeminfo: Word; { OEM information; e_oemid specific}<br> e_res2: array [0..9] of Word; { Reserved<br>words }<br> _lfanew: LongInt; { File address of new exe header }<br> end;<br> TImageDosHeader = _IMAGE_DOS_HEADER;<br><br> PIMAGE_FILE_HEADER = ^IMAGE_FILE_HEADER;<br> IMAGE_FILE_HEADER = packed record<br> Machine : WORD;<br> NumberOfSections : WORD;<br> TimeDateStamp : DWORD;<br> PointerToSymbolTable : DWORD;<br> NumberOfSymbols : DWORD;<br> SizeOfOptionalHeader : WORD;<br> Characteristics : WORD;<br> end;<br><br> PIMAGE_DATA_DIRECTORY = ^IMAGE_DATA_DIRECTORY;<br> IMAGE_DATA_DIRECTORY = packed record<br> VirtualAddress : DWORD;<br> Size : DWORD;<br> end;<br><br> PIMAGE_SECTION_HEADER = ^IMAGE_SECTION_HEADER;<br> IMAGE_SECTION_HEADER = packed record<br> Name : packed array [0..IMAGE_SIZEOF_SHORT_NAME-1] of Char;<br> VirtualSize : DWORD; // or VirtualSize (union);<br> VirtualAddress : DWORD;<br> SizeOfRawData : DWORD;<br> PointerToRawData : DWORD;<br> PointerToRelocations : DWORD;<br> PointerToLinenumbers : DWORD;<br> NumberOfRelocations : WORD;<br> NumberOfLinenumbers : WORD;<br> Characteristics : DWORD;<br> end;<br><br> PIMAGE_OPTIONAL_HEADER = ^IMAGE_OPTIONAL_HEADER;<br> IMAGE_OPTIONAL_HEADER = packed record<br> { Standard fields. }<br> Magic : WORD;<br> MajorLinkerVersion : Byte;<br> MinorLinkerVersion : Byte;<br> SizeOfCode : DWORD;<br> SizeOfInitializedData : DWORD;<br> SizeOfUninitializedData : DWORD;<br> AddressOfEntryPoint : DWORD;<br> BaseOfCode : DWORD;<br> BaseOfData : DWORD;<br> { NT additional fields. }<br> ImageBase : DWORD;<br> SectionAlignment : DWORD;<br> FileAlignment : DWORD;<br> MajorOperatingSystemVersion : WORD;<br> MinorOperatingSystemVersion : WORD;<br> MajorImageVersion : WORD;<br> MinorImageVersion : WORD;<br> MajorSubsystemVersion : WORD;<br> MinorSubsystemVersion : WORD;<br> Reserved1 : DWORD;<br> SizeOfImage : DWORD;<br> SizeOfHeaders : DWORD;<br> CheckSum : DWORD;<br> Subsystem : WORD;<br> DllCharacteristics : WORD;<br> SizeOfStackReserve : DWORD;<br> SizeOfStackCommit : DWORD;<br> SizeOfHeapReserve : DWORD;<br> SizeOfHeapCommit : DWORD;<br> LoaderFlags : DWORD;<br> NumberOfRvaAndSizes : DWORD;<br> DataDirectory : packed array<br>[0..IMAGE_NUMBEROF_DIRECTORY_ENTRIES-1] of IMAGE_DATA_DIRECTORY; Sections: packed array [0..9999] of IMAGE_SECTION_HEADER;<br> end;<br><br> PIMAGE_NT_HEADERS = ^IMAGE_NT_HEADERS;<br> IMAGE_NT_HEADERS = packed record<br> Signature : DWORD;<br> FileHeader : IMAGE_FILE_HEADER;<br> OptionalHeader : IMAGE_OPTIONAL_HEADER;<br> end;<br> PImageNtHeaders = PIMAGE_NT_HEADERS;<br> TImageNtHeaders = IMAGE_NT_HEADERS;<br><br>{ PIMAGE_IMPORT_DESCRIPTOR = ^IMAGE_IMPORT_DESCRIPTOR;<br> IMAGE_IMPORT_DESCRIPTOR = packed record<br> Characteristics: DWORD; // or original first thunk // 0 for<br>terminating null import descriptor // RVA to original unbound IAT TimeDateStamp: DWORD; // 0 if not bound,<br> // -1 if bound, and real date/time stamp // in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND)<br> // O.W. date/time stamp of DLL bound to (Old BIND)<br> Name: DWORD;<br> FirstThunk: DWORD; // PIMAGE_THUNK_DATA // RVA to IAT (if bound this IAT has actual addresses)<br> ForwarderChain: DWORD; // -1 if no forwarders<br> end;<br> TImageImportDescriptor = IMAGE_IMPORT_DESCRIPTOR;<br> PImageImportDescriptor = PIMAGE_IMPORT_DESCRIPTOR;}<br><br> PIMAGE_IMPORT_BY_NAME = ^IMAGE_IMPORT_BY_NAME;<br> IMAGE_IMPORT_BY_NAME = record<br> Hint: Word;<br> Name: Array[0..0] of Char;<br> end;<br><br> PIMAGE_THUNK_DATA = ^IMAGE_THUNK_DATA;<br> IMAGE_THUNK_DATA = record<br> Whatever: DWORD;<br> end;<br><br> PImage_Import_Entry = ^Image_Import_Entry;<br> Image_Import_Entry = record<br> Characteristics: DWORD;<br> TimeDateStamp: DWORD;<br> MajorVersion: Word;<br> MinorVersion: Word;<br> Name: DWORD;<br> LookupTable: DWORD;<br> end;<br><br><br>const<br>IMAGE_DOS_SIGNATURE = $5A4D; // MZ<br>IMAGE_OS2_SIGNATURE = $454E; // NE<br>IMAGE_OS2_SIGNATURE_LE = $454C; // LE<br>IMAGE_VXD_SIGNATURE = $454C; // LE<br>IMAGE_NT_SIGNATURE = $00004550; // PE00<br><br>implementation<br><br>end.<br><br>=================================================<br>Create a new project with one form, with two buttons.<br>=================================================<br><br><br>unit PigLatinUnit;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>procedure StartHook; stdcall; external 'PigLatinDll.DLL';<br>procedure StopHook; stdcall; external 'PigLatinDll.DLL';<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> WindowState:=wsMaximized;<br> StartHook;<br> Sleep(1000);<br> WindowState:=wsNormal;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> WindowState:=wsMaximized;<br> StopHook;<br> Sleep(1000);<br> WindowState:=wsNormal;<br>end;<br><br>initialization<br>finalization<br> StopHook;<br>end. <br>可编译库文件的时候需要这个:PEStuff.dcu,这是什么东西?[]<br>大家帮忙问问呀,有没有实际点的,小弟先谢过了。<br><br>
macrolen
Unregistered / Unconfirmed
GUEST, unregistred user!
怎么没人响应了?喂....各位高手,在那里呀?帮帮小弟一把.....(是不是分太少了?)<br>[
]
acjin
Unregistered / Unconfirmed
GUEST, unregistred user!
要新建一个单元,把PEStuff这个单元代码也粘贴进去<br>我已经编译成功了(需要的话可以留下EMAIL),可是使用的时候,系统容易出错
godzhou
Unregistered / Unconfirmed
GUEST, unregistred user!
能不能把dll发给我<br>godzhou@163.net
netwang
Unregistered / Unconfirmed
GUEST, unregistred user!
DreamLand
Unregistered / Unconfirmed
GUEST, unregistred user!
acjin
Unregistered / Unconfirmed
GUEST, unregistred user!
山泉
Unregistered / Unconfirmed
GUEST, unregistred user!
acjin,可以给一份吗?<br>xhonghui@21cn.com
acjin
Unregistered / Unconfirmed
GUEST, unregistred user!
山泉:给你发过去了<br>研究出来后别忘了给我一份
macrolen
Unregistered / Unconfirmed
GUEST, unregistred user!
非常感谢大家的帮助,这镇子放假回家没什么机会上网,等开学后再发分了。再次感谢!