delphi单元使用关键如下:
implementation
//////////////////// ASSEMBLER, DISASSEMBLER AND EXPRESSIONS ///////////////////
const
MAXCMDSIZE = 16; // Maximal length of 80x86 command
MAXCALSIZE = 8; // Max length of CALL without prefixes
NMODELS = 8; // Number of assembler search models
TEXTLEN = 255; // Maximal length of text string
asmdll = 'assembl.dll';
type
TAsmModel = packed record // Model to search for assembler command
code:array[0..MAXCMDSIZE-1] of byte; // Binary code
mask:array[0..MAXCMDSIZE-1] of byte; // Mask for binary code (0: bit ignored)
length:SmallInt; // Length of code, bytes (0: empty)
jmpsize:SmallInt; // Offset size if relative jump
jmpoffset:SmallInt; // Offset relative to IP
jmppos:SmallInt; // Position of jump offset in command
end;
PAsmModel = ^TAsmModel;
//调用
procedure TForm1.BnClick(Sender: PObj);
var
myModel: TAsmModel;
s : PChar;
Input : String;
TmpStr, ErrBuf : array[0..TEXTLEN] of Char;
i: Integer;
begin
if EB1.Text <> '' then
begin
FillChar(TmpStr, TEXTLEN, 0);
FillChar(myModel, SizeOf(myModel), 0);
s := @TmpStr[0];
Input := EB1^.Text;
for i:=1 to Length(Input) do begin
s^ := Input[i];
inc(s);
if i>TEXTLEN then break;
end;
Input := ''; //函数出来后,Input已经变了
EB2.Clear ; //指针也变错了
if myModel.length >0 then
begin
for i:=1 to myModel.length do
Input := Input + Format('%s', [myModel.code[i]] );
EB2.Text := Input;
end
else
EB2^.Text := ErrBuf;
end;
end;
const
MAXCMDSIZE = 16; // Maximal length of 80x86 command
MAXCALSIZE = 8; // Max length of CALL without prefixes
NMODELS = 8; // Number of assembler search models
TEXTLEN = 255; // Maximal length of text string
asmdll = 'assembl.dll';
type
TAsmModel = packed record // Model to search for assembler command
code:array[0..MAXCMDSIZE-1] of byte; // Binary code
mask:array[0..MAXCMDSIZE-1] of byte; // Mask for binary code (0: bit ignored)
//下面的变量溢出了,将下面的SmallInt改成Integer即可。
length:SmallInt; // Length of code, bytes (0: empty)
jmpsize:SmallInt; // Offset size if relative jump
jmpoffset:SmallInt; // Offset relative to IP
jmppos:SmallInt; // Position of jump offset in command
end;
PAsmModel = ^TAsmModel;
//调用
procedure TForm1.BnClick(Sender: PObj);
var
myModel: TAsmModel;
s : PChar;
Input : String;
TmpStr, ErrBuf : array[0..TEXTLEN] of Char;
i: Integer;
begin
if EB1.Text <> '' then
begin
FillChar(TmpStr, TEXTLEN, 0); //将TEXTLEN改成TEXTLEN+1
FillChar(myModel, SizeOf(myModel), 0);
s := @TmpStr[0];
Input := EB1^.Text; //EB1^.Text??,Edit控件可以这样用指针访问吗?你的是Delphi几?
for i:=1 to Length(Input) do begin
s^ := Input[i];
inc(s);
if i>TEXTLEN then break;
end;