[D3D9] Маски некоторых D3D функций.

Тема в разделе Гайды, исходы от местных кодеров, создана пользователем Ve4niySooN, 28 фев 2016.

Войдите для ответа
  1. Ve4niySooN Разработчик

    Ve4niySooN
    Команда форума
    Статус:
    Вне сети
    Сообщения:
    58
    Симпатии:
    62
    Регистрация:
    01.06.15
    Маска для поиска Reset и EndScene функций Direct3D9;

      Mask_D3DReset_7:  array [0..14] of Byte = ($57,$FF,$15,$FF,$FF,$FF,$FF,$8B,$45,$0C,$33,$F6,$39,$70,$20);
      Mask_D3DReset_8:  array [0..18] of Byte = ($33,$C9,$39,$4F,$20,$75,$79,$8D,$44,$24,$38,$89,$44,$24,$1C,$32,$C0,$8B,$DE);
      Mask_D3DReset_9:  array [0..12] of Byte = ($8B,$CE,$E8,$FF,$FF,$FF,$FF,$8B,$4E,$0C,$48,$F7,$D8);
      Mask_D3DReset_0:  array [0..12] of Byte = ($8B,$CE,$E8,$FF,$FF,$FF,$FF,$8B,$4E,$0C,$48,$F7,$D8);
    
      Mask_D3DEScene_7: array [0..53] of Byte = ($57,$FF,$15,$FF,$FF,$FF,$FF,$E9,$FF,$FF,$FF,$FF,$39,$5F,$18,$74,$07,$57,$FF,$15,$FF,$FF,$FF,$FF,$B8,$FF,$FF,$FF,$FF,$8B,$4D,$F4,$64,$89,$0D,$FF,$FF,$FF,$FF,$59,$5F,$5E,$5B,$8B,$E5,$5D,$C2,$04,$00,$68,$AD,$06,$FF,$FF);
      Mask_D3DEScene_8: array [0..22] of Byte = ($33,$C0,$E8,$FF,$FF,$FF,$FF,$C2,$04,$00,$8B,$DF,$EB,$8E,$53,$FF,$15,$FF,$FF,$FF,$FF,$EB,$90);
      Mask_D3DEScene_9: array [0..22] of Byte = ($33,$C0,$E8,$FF,$FF,$FF,$FF,$C2,$04,$00,$8B,$DF,$EB,$8E,$53,$FF,$15,$FF,$FF,$FF,$FF,$EB,$90);
      Mask_D3DEScene_0: array [0..22] of Byte = ($33,$C0,$E8,$FF,$FF,$FF,$FF,$C2,$04,$00,$8B,$DF,$EB,$8E,$53,$FF,$15,$FF,$FF,$FF,$FF,$EB,$90);
    Префиксы в конце означают версию Windows.
    _7 = Windows 7
    _8 = Windows 8
    _9 = Windows 8.1
    _0 = Windows 10

    $FF = это любой байт, в поиске его пропускайте.

    function THMemory.Compare(Address, Pattern, Size: Cardinal): Boolean;
    var
    B: Byte;
    i: Cardinal;
    begin
      for i := 0 to Size - 1 do
      begin
        B := PByte(Pattern + i)^;
        if (PByte(Address + i)^ <> B) and (B <> $FF) then
        begin
          Result := False;
          Exit;
        end;
      end;
      Result := True;
    end;
    
    function THMemory.FindPattern(StartAddr, EndAddr: Cardinal; const Pattern: Pointer; PatternSize: Cardinal; Offset: Longint): Pointer;
    var
      i: Cardinal;
    begin
      for i := StartAddr to EndAddr - (1 + PatternSize) do
      if Mem.Compare(i, Cardinal(Pattern), PatternSize) then
      begin
        Result := Pointer(i + Offset);
        Exit;
      end;
      Result := nil;
    end;
    function THFind.D3DReset(wversion: Cardinal): Pointer;
    begin
      case wversion of
        7:  Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DReset_7, SizeOf(Mask_D3DReset_7), 0);
        8:  Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DReset_8, SizeOf(Mask_D3DReset_8), 0);
        9:  Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DReset_9, SizeOf(Mask_D3DReset_9), 0);
        10: Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DReset_0, SizeOf(Mask_D3DReset_0), 0);
      end;
    end;
    
    function THFind.D3DEndScene(wversion: Cardinal): Pointer;
    begin
      case wversion of
        7:  Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DEScene_7, SizeOf(Mask_D3DEScene_7), 0);
        8:  Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DEScene_8, SizeOf(Mask_D3DEScene_8), 0);
        9:  Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DEScene_9, SizeOf(Mask_D3DEScene_9), 0);
        10: Result := Mem.FindPattern(D3DLib.Address, D3DLib.Address + $1FF000, @Mask_D3DEScene_0, SizeOf(Mask_D3DEScene_0), 0);
      end;
    end;
    Получаем адрес функции EndScene на Windows 7:
    Address := Find.D3DEndScene(7);
    
    Получаем адрес функции Reset на Windows 8.1:
    Address := Find.D3DReset(9);
    
     
    28 фев 2016 #1
Top