拿回家吧,我刚鼓捣的反转机器码
本帖最后由 冥界3大法王 于 2021-4-24 12:29 编辑目的:为了反转00 80 90 80 63 75为 756380908000
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Edit2: TEdit;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
StrUtils;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text := reversestring(Edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
strs: TStrings;
i: Integer;
begin
memo1.Clear;
strs := TStringList.Create;
strs.CommaText := Edit2.Text;
for i := strs.Count - 1 downto 0 do
begin
//ShowMessage(strs);
memo1.SelLength := 0;
memo1.SelText := strs;
end;
Edit2.Text := memo1.Text;
end;
end.
缺点,多用了一个Memo1控件
In : a = "abcdef"
In : b = a[::-1]
In : b
Out: 'fedcba'
In : 看不懂。。。。 加一个:
var
T1: string;
T1 := T1 + strs;
就一个解决了。
来来来,python的:
var
amstr:string;
Amarr:TArray<string>;
i:integer;
begin
AmStr:='00 80 90 80 63 75';
amarr:= amstr.Split([' ']);
amstr:='';
for I := high(amarr) downto 0 do
begin
amstr:=amstr+amarr;
end;
memostr.Text:=amstr;
end;
我也来玩一下!:lol 本帖最后由 goastship 于 2022-3-15 00:13 编辑
//-----------------------------------------------
//16进制字符转整数,16进制字符与字符串转换中间函数
//-----------------------------------------------
function HexToInt(hex: string): integer;
var
i: integer;
function Ncf(num, f: integer): integer;
var
i: integer;
begin
Result := 1;
if f = 0 then exit;
for i := 1 to f do
result := result * num;
end;
function HexCharToInt(HexToken: char): integer;
begin
if HexToken > #97 then
HexToken := Chr(Ord(HexToken) - 32);
Result := 0;
if (HexToken > #47) and (HexToken < #58) then { chars 0....9 }
Result := Ord(HexToken) - 48
else if (HexToken > #64) and (HexToken < #71) then { chars A....F }
Result := Ord(HexToken) - 65 + 10;
end;
begin
result := 0;
hex := ansiuppercase(trim(hex));
if hex = '' then
exit;
for i := 1 to length(hex) do
result := result + HexCharToInt(hex) * ncf(16, length(hex) - i);
end;
//Delphi 文件静态补丁
//Example: ModifyFile('a.exe', '00044570', 'C20C006A');
// 参数1: 文件名; 参数2: 偏移量; 参数3: 值(Byte)(注意高低位顺序)
procedure ModifyFileByte(MemoryStream: TMemoryStream; OffSet, ByteData: String);
var
Pos: Integer;
bufferByte: Byte;
begin
try
if (Length(ByteData) Mod 2) = 0 then
begin
Pos := 1;
while Pos <= Length(ByteData) Div 2 do
begin
bufferByte := HexToInt(Copy(ByteData, Pos * 2 - 1, 2));
(PByte(MemoryStream.Memory) + HexToInt(OffSet) + Pos - 1)^ := bufferByte;
Pos := Pos + 1;
end;
end;
finally
end;
end;
页:
[1]