-
Notifications
You must be signed in to change notification settings - Fork 3
/
uMemReader.pas
92 lines (73 loc) · 1.6 KB
/
uMemReader.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
unit uMemReader;
interface
uses
Classes, SysUtils;
type
TExplorerMemoryStream = class (TMemoryStream)
private
public
function ReadByte: byte;
function ReadWord: word;
function ReadDWord: longword;
function ReadBlockName: string;
function ReadBuffer(var Buffer; Count: longint): longint;
function ReadString(Length: integer): string;
function ReadStringAlt(Length: integer): string;
constructor Create;
destructor Destroy; override;
end;
implementation
function TExplorerMemoryStream.ReadByte: byte;
begin
Read(result,1);
end;
function TExplorerMemoryStream.ReadWord: word;
begin
Read(result,2);
end;
function TExplorerMemoryStream.ReadDWord: longword;
begin
Read(result,4);
end;
function TExplorerMemoryStream.ReadBlockName: string;
begin
result:=chr(ReadByte)+chr(ReadByte)+chr(ReadByte)+chr(ReadByte);
end;
function TExplorerMemoryStream.ReadBuffer(var Buffer; Count:longint): longint;
begin
result:=Read(Buffer,Count);
end;
function TExplorerMemoryStream.ReadString(Length: integer): string;
var
n: longword;
begin
SetLength(result,length);
for n:=1 to length do
begin
result[n]:=Chr(ReadByte);
end;
end;
function TExplorerMemoryStream.ReadStringAlt(Length: integer): string;
var //Replaces #0 chars
n: longword;
Rchar: char;
begin
SetLength(result,length);
for n:=0 to length -1 do
begin
RChar:=Chr(ReadByte);
if RChar=#0 then
result[n]:='x'
else
result[n]:=rchar;
end;
end;
constructor TExplorerMemoryStream.Create;
begin
inherited Create;
end;
destructor TExplorerMemoryStream.Destroy;
begin
inherited;
end;
end.