⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directxhook.pas

📁 冒险岛吸怪源码UCE的制作材料 用于冒险岛游戏的外挂
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        locking:=false;
        texturelistcs.Leave;
      end;
    end;



    try
      texturelistcs.Enter;
      try
        if (texturepointer<>-1) and (texturelist[texturepointer].locked) then
        begin
          if checkkeycombo(keys.IncreaseX) then
          for i:=0 to length(lockedtexturelist)-1 do
            if lockedtexturelist[i].texturehandle=texturelist[texturepointer].texturehandle then
            begin
              lockedtexturelist[i].xdelta:=lockedtexturelist[i].xdelta+1;
              texturelist[texturepointer].xdelta:=texturelist[texturepointer].xdelta+1;
              break;
            end;


          if checkkeycombo(keys.Increasey) then
            for i:=0 to length(lockedtexturelist)-1 do
              if lockedtexturelist[i].texturehandle=texturelist[texturepointer].texturehandle then
              begin
                lockedtexturelist[i].ydelta:=lockedtexturelist[i].ydelta+1;
                texturelist[texturepointer].ydelta:=texturelist[texturepointer].ydelta+1;
                break;
              end;

          if checkkeycombo(keys.Increasez) then
            for i:=0 to length(lockedtexturelist)-1 do
              if lockedtexturelist[i].texturehandle=texturelist[texturepointer].texturehandle then
              begin
                lockedtexturelist[i].zdelta:=lockedtexturelist[i].zdelta+1;
                texturelist[texturepointer].zdelta:=texturelist[texturepointer].zdelta+1;
                break;
              end;

          if checkkeycombo(keys.DecreaseX) then
            for i:=0 to length(lockedtexturelist)-1 do
              if lockedtexturelist[i].texturehandle=texturelist[texturepointer].texturehandle then
              begin
                lockedtexturelist[i].xdelta:=lockedtexturelist[i].xdelta-1;
                texturelist[texturepointer].xdelta:=texturelist[texturepointer].xdelta-1;
                break;
              end;

          if checkkeycombo(keys.Decreasey) then
            for i:=0 to length(lockedtexturelist)-1 do
              if lockedtexturelist[i].texturehandle=texturelist[texturepointer].texturehandle then
              begin
                lockedtexturelist[i].ydelta:=lockedtexturelist[i].ydelta-1;
                texturelist[texturepointer].ydelta:=texturelist[texturepointer].ydelta-1;
                break;
              end;

          if checkkeycombo(keys.Decreasez) then
            for i:=0 to length(lockedtexturelist)-1 do
              if lockedtexturelist[i].texturehandle=texturelist[texturepointer].texturehandle then
              begin
                lockedtexturelist[i].zdelta:=lockedtexturelist[i].zdelta-1;
                texturelist[texturepointer].zdelta:=texturelist[texturepointer].zdelta-1;
                break;
              end;

        end;
      finally
        texturelistcs.Leave;
      end;
    except
      outputdebugstring('error in handlekeypresses(dx8)');
    end;
  end;
end;

procedure SaveLockedTextureInfo8(aimconfigfile: string);
var i,j,k: integer;
    tr: TD3DLocked_Rect;
    aimsettings: tfilestream;
    lr:TD3DLocked_Rect;
    bts: array of byte;
    s: string;

    total: dword;
    pdesc: td3dsurface_desc;
begin
  try
    aimsettings:=tfilestream.Create((keys.cedir+aimconfigfile+'.cta'),fmCreate);
    lockedtexturelistcs.Enter;
    try
      total:=length(lockedtexturelist);
      aimsettings.WriteBuffer(total,4);
      for i:=0 to length(lockedtexturelist)-1 do
      begin
        //save the levels
        aimsettings.WriteBuffer(lockedtexturelist[i],sizeof(TTextureInfo));

        try
          if lockedtexturelist[i].texturehandle.LockRect(0,tr,nil,{0}D3DLOCK_NOSYSLOCK)=0 then
          begin
            try
              lockedtexturelist[i].texturehandle.GetLevelDesc(0,pdesc);

              s:='Width='+IntToStr(lockedtexturelist[i].Width)+' Height='+IntToStr(lockedtexturelist[i].Height)+' pitch='+IntToStr(tr.Pitch)+' format='+IntToStr(lockedtexturelist[i].Format)+' size='+inttostr(pdesc.Size)+' levels='+inttostr(lockedtexturelist[i].Levels);

              total:=pdesc.Size;
              aimsettings.WriteBuffer(total,4);

              try
                aimsettings.WriteBuffer(tr.pBits^,total);
              except

              end;
            finally
              lockedtexturelist[i].texturehandle.UnlockRect(0);
            end;
          end;
        except
          //something went wrong, but try to not screw up
          total:=0;
          aimsettings.WriteBuffer(total,4);
        end;
      end;
    finally
      aimsettings.free;
      lockedtexturelistcs.Leave;
    end;


  except
    outputdebugstring('error in savelockedtextureinfo8');
  end;

end;

procedure LoadLockedTextureInfo8(aimconfigfile:string);
var aimsettings,aimsettings2: tfilestream;
    images: array of array of byte;
    i,j: integer;
    tempimage: array of byte;

    imageloaded:boolean;
    total: dword;
    tr: TD3DLocked_Rect;
    pdesc: td3dsurface_desc;
begin
  try
    LockedtexturelistCS.Enter;
    try
      for i:=0 to length(lockedtexturelist)-1 do
      begin
        try
          lockedtexturelist[i].texturehandle._Release;
        except

        end;
        zeromemory(@lockedtexturelist[i],sizeof(TTextureInfo));
      end;
      setlength(lockedtexturelist,0);
    finally
      LockedtexturelistCS.Leave;
    end;

    texturelistCS.Enter;
    try
      for i:=0 to length(texturelist)-1 do
      begin
        try
          texturelist[i].locked:=false;
        except

        end;
      end;
    finally
      texturelistCS.Leave;
    end;
  except

  end;

  LoadPhase:=1;

  try
    try
      aimsettings:=tfilestream.Create(keys.cedir+aimconfigfile+'.cta',fmOpenRead);
      try
        aimsettings.ReadBuffer(total,4);

        lockedtexturelistcs.Enter;
        try
          setlength(lockedtexturelist,total);
          setlength(images,total);

          maxposition:=length(lockedtexturelist)-1;
          for i:=0 to length(lockedtexturelist)-1 do
          begin
            currentposition:=i;

            aimsettings.ReadBuffer(lockedtexturelist[i],sizeof(TTextureInfo));
            lockedtexturelist[i].locked:=false;
            try
              aimsettings.ReadBuffer(total,4);
              setlength(images[i],total);
              aimsettings.ReadBuffer(images[i][0],total);
            except
              exit; //failed to load.....
            end;
            sleep(1);
          end;
        finally
          lockedtexturelistcs.Leave;
        end;
      finally
        aimsettings.free;
      end;

      //check the texturelist for these textures

      loadphase:=2;
      lockedtexturelistcs.Enter;
      texturelistcs.enter;
      try
        maxposition:=length(texturelist);
        for i:=0 to length(texturelist)-1 do
        begin
          currentposition:=i;
          imageloaded:=false;

          //check the lockedtextures to see if this is a texture that has to be locked
          for j:=0 to length(lockedtexturelist)-1 do
          begin
            if texturelist[i].Width<>lockedtexturelist[j].width then continue;
            if texturelist[i].Height<>lockedtexturelist[j].Height then continue;
            if texturelist[i].Levels<>lockedtexturelist[j].Levels then continue;
            if texturelist[i].Usage<>lockedtexturelist[j].Usage then continue;
            if texturelist[i].Format<>lockedtexturelist[j].Format then continue;
            if texturelist[i].Pool<>lockedtexturelist[j].pool then continue;


            if not imageloaded then
            begin
              //copy the memory of the texture to a local var
              try
                if texturelist[i].texturehandle.LockRect(0,tr,nil,{0}D3DLOCK_NOSYSLOCK  )=0 then
                begin
                  try
                    texturelist[i].texturehandle.GetLevelDesc(0,pdesc);
                    total:=pdesc.Size;

                    if total<>length(images[j]) then continue;
                    setlength(tempimage,total);
                    copymemory(@tempimage[0],tr.pBits,total);
                    imageloaded:=true;
                  finally
                    texturelist[i].texturehandle.UnlockRect(0);
                    sleep(5);
                  end;
                end;
              except
                //doesn't exist
              end;

            end;

            if comparemem(@tempimage[0],@images[j][0],length(tempimage)) then
            begin
             // lockedtexturelist[j].zdelta:=lockedtexturelist[j].zdelta+5;

              texturelist[i].locked:=true;
              texturelist[i].xdelta:=lockedtexturelist[j].xdelta;
              texturelist[i].ydelta:=lockedtexturelist[j].ydelta;
              texturelist[i].zdelta:=lockedtexturelist[j].zdelta;

              copymemory(@lockedtexturelist[j].texturehandle,@texturelist[i].texturehandle,4);
              try
                lockedtexturelist[j].texturehandle._AddRef;
              except

              end;
              lockedtexturelist[j].locked:=true;
            end;
            sleep(1);
          end;
          sleep(1);
        end;
      finally
        lockedtexturelistcs.Leave;
        texturelistcs.Leave;
      end;
    except

    end;
  finally
    for i:=0 to length(images)-1 do
      setlength(images[i],0);
      
    setlength(images,0);
    setlength(tempimage,0);
  end;

end;


function multiplymatrix(const A: td3dmatrix;const b:td3dmatrix):td3dmatrix;
begin
  result._11:=a._11*b._11+a._12*b._21+a._13*b._31+a._14*b._41;
  result._12:=a._11*b._12+a._12*b._22+a._13*b._32+a._14*b._42;
  result._13:=a._11*b._13+a._12*b._23+a._13*b._33+a._14*b._43;
  result._14:=a._11*b._14+a._12*b._24+a._13*b._34+a._14*b._44;

  result._21:=a._21*b._11+a._22*b._21+a._23*b._31+a._24*b._41;
  result._22:=a._21*b._12+a._22*b._22+a._23*b._32+a._24*b._42;
  result._23:=a._21*b._13+a._22*b._23+a._23*b._33+a._24*b._43;
  result._24:=a._21*b._14+a._22*b._24+a._23*b._34+a._24*b._44;

  result._31:=a._31*b._11+a._32*b._21+a._33*b._31+a._34*b._41;
  result._32:=a._31*b._12+a._32*b._22+a._33*b._32+a._34*b._42;
  result._33:=a._31*b._13+a._32*b._23+a._33*b._33+a._34*b._43;
  result._34:=a._31*b._14+a._32*b._24+a._33*b._34+a._34*b._44;

  result._41:=a._41*b._11+a._42*b._21+a._43*b._31+a._44*b._41;
  result._42:=a._41*b._12+a._42*b._22+a._43*b._32+a._44*b._42;
  result._43:=a._41*b._13+a._42*b._23+a._43*b._33+a._44*b._43;
  result._44:=a._41*b._14+a._42*b._24+a._43*b._34+a._44*b._44;
end;


{
0=addref
4=release
8=queryInterface
c=RegisterSoftwareDevice(pInitializeFunction : Pointer) : HResult; stdcall;

⌨️ 快捷键说明

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