小弟在编写游戏辅助的时候,通过注入DLL,呼出辅助界面注入.exe---->选择游戏注入hook.dll到游戏进程myDLl.pas里面写有各种过程,并有FORM1现在的情况是myDLl.pas创建线程Unit2来实现form1.Edit3.Text:='aaa';编译代码没问题,现在功能form1.Edit3.Text:='aaa';没有实现。求解决。代码如下---------------------------------------------------------------------------->>>
hook部分代码library Hook;
uses
  Windows,
  Messages,
  SysUtils,
  Variants,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  StrUtils,
  myDLl in 'myDLl.pas' {Form1},
  UnitBaseInfo in 'UnitBaseInfo.pas',
  Unit2 in 'Unit2.pas';var
  hHk:HHOOK=0;
  hThread:Cardinal;
  hmod:Pointer;
//===========接收按键F12开呼出隐藏窗口==================  
function HookProc(nCode:Integer;WParam: WPARAM;LParam:LPARAM):LRESULT;stdcall;
label
  theExit;
begin
  if nCode < 0 then
    goto theExit;
  if (nCode <> HC_ACTION) then
    goto theExit;
  if ((lParam and $80000000) = 0) { or (GetAsyncKeyState(VK_Control)=0) } then
    goto theExit;
  case wParam of VK_F12:  
      begin
        if form1 <> nil then
          begin
            if form1.Visible = true then
              Form1.Hide
            else
              Form1.Show;
          end
        else //窗体还没有加载
          Form1:=TForm1.Create(Application);
      end;
  end;
  theExit:
  result := CallNextHookEx(hHk, nCode, wParam, lParam);
end;
//------------------------------------------------------------------------------
function HookOn(lpHwnd:HWND):Longint;stdcall;export;//安装钩子
begin
  hThread :=GetWindowThreadProcessId(lpHwnd,hmod);
  if lpHwnd<>0 then hHk :=SetWindowsHookEx(WH_KEYBOARD,@HookProc,hInstance,hThread);
  Result :=hHk
end;
//------------------------------------------------------------------------------
function HookOff:Boolean;stdcall;export; //卸载钩子
begin
  if hHk<>0 then
    begin
      UnHookWindowsHookEx(hHk);
      hHk :=0;
      Result :=true;
    end
  else
    Result :=false;
end;
//------------------------------------------------------------------------------
{$R *.res}exports
HookOn,HookOff;
begin
{Application.Initialize;
Application.Run; }
end.以下是mydll.pas的部分代码------------------------------------------------------>unit myDLl;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls , ComCtrls, XPMan, Grids,StrUtils;type
TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Button1: TButton;
    Button3: TButton;
    ListView1: TListView;
    Button4: TButton;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Timer1: TTimer;
    Edit3: TEdit;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
  ProcessID:Thandle;
  //Ghwnd:Thandle;
  //dwProcId:DWORD;
  Ghwnd:hwnd;
  dwProcId:cardinal;const base = $B675FC;//游戏基址
implementationuses UnitBaseInfo,Unit2;var
//基本信息线程
  MyBaseInfo:BaseInfo;
  mytest:test;
{$R *.dfm}//部分功能代码略去//
procedure TForm1.FormCreate(Sender: TObject);
begin
  Ghwnd:=FindWindow('ElementClient Window','武林');
  GetWindowThreadProcessID(Ghwnd,@dwProcId); //获得进程ID
  //myBaseInfo:=BaseInfo.Create(false);//创建BaseInfo线程
  mytest:=test.Create(false);
  if Ghwnd=0 then
  begin
    ShowMessage('游戏未启动');
    Application.Terminate ();
  end;
  //GetWindowThreadProcessId(Ghwnd,PID);
  ProcessID:=OpenProcess(PROCESS_ALL_ACCESS,False,dwProcId);
  if ProcessID=0 then
  begin
    ShowMessage('无法打开线程');
    Application.Terminate ();
  end;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
   mytest.Destroy;
end;end.
以下是unit2的代码--------------------------------------------------------->unit Unit2;interfaceuses
  Classes,SysUtils,windows,myDLl;type
  test = class(TThread)
  private
    { Private declarations }
    procedure GetInfo;
  protected
    procedure Execute; override;
  end;
var
Ghwnd:hwnd;implementation{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,      Synchronize(UpdateCaption);  and UpdateCaption could look like,    procedure test.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }{ test }procedure test.Execute;
begin
  { Place thread code here }
     while not Terminated do//当线程不终止时一址循环
  begin
    GetInfo;
    Sleep(500);
  end;
end;//得到信息
procedure test.GetInfo;
begin
form1.Edit3.Text:='aaa';
end;end.
不知道什么原因,功能无法实现,请大哥大姐弟弟妹妹们帮忙,非常感激。