delphi 写的一个读内存函数,大家来看下错在哪里!
function ReadWideStr(add: Integer; size: Integer): string;var
i: Integer;
begin
i := 0;
Result := '';
add := PInt(add)^;
while i < size do
begin
Result := Result + pWideChar(add + i)^;
inc(i, 2);
end;
end;
前提:DLL以成功注入游戏,数据类型都可以读出,现在读中文的数据,报错,请大家指正,为谢! add := PInt(add)^;
这句不需要吧
你的参数应该是地址了吧! 另外,你取的是WideChar,但是函数定义的是string
Result := Result + pWideChar(add + i)^; string 不是char的组合吗?可以看成 string=一个char数组,反回因该没有错 function ReadWideStr(add: Integer; size: Integer): Widestring; //这里要改为宽字符
var
i: Integer;
begin
i := 0;
Result := '';
add := PInt(add)^;
while i < size do
begin
Result := Result + pWideChar(add + i)^;
inc(i, 2);
end;
end; 谢谢收到问题以解决
页:
[1]