Jump to content
Tuts 4 You

storing data in a new pe section


StreamLine

Recommended Posts

Posted

as the title says, i am creating a new section and storing data in it, i would like to know the best way to store a large amount of data and read it back, perfer delphi, but any lang would be good. :wub:

Posted

In my opinion, the best way of storing a huge amount of data is doing it on disk. The performance of your target gets slower when you use memory space to store it, especially when you are manging huge amount of data, as you stated.

Then, if you want to read data of the new section for being managed by your tool, the fastest way (for a good performance) is to choose not loading very large blocks in memory. I usually load blocks of 0x10000.

And talking about language, this is my way, there could be of course a lot of better ways...

type
bufType : array of Byte;procedure DumpingData (var buf : bufType; FileName : AnsiString; offset : Integer);
var
dump : TFileStream;begin
try
dump := TFileStream.Create (FileName,fmCreate);
dump.Seek (offset,soFromBeginning);
dump.Write (buf[0],Length(buf));
finally
dump.Free;
end;
end;

So, FileName should contain the entire path to your file, and buf should contain your wanted data to be stored. There could be done lots of previous checks, to be sure the file is accessible, the buffer is not empty, and so on...

To retrieve the data from disk, just change fmCreate by fmOpenRead and dump.Write by dump.Read...

Is this answering your question?

Cheers

Nacho_dj

Posted (edited)

for instance if i wanted to save a group of settings, strings,integers etc inside a new pe section, what would the best way to write it be?

type
TSettings =record
setting1:string;
setting2:integer;
end;var
set : TSettings;
begin
set.setting1 := 'hello world';
set.setting2 := 20;
end;

say i wanted to write the simple data above into my new section. since i dont know the size of my record or my string snce the string is varialbe.? i was thinking about storing a dll or plugins in size a new section, just playing with ides atm. cheers.

Edited by StreamLine
Posted

You can define the length of string allocated, that way you know the size of the record.

e.g

TSettings =record
setting1: string[60];
setting2: integer;
end;
Posted

whats the point in that unless its a "packed" record?

Posted

defining the length of the string wont help since im not sure what it will be, if i define it at 255, it wastes space or doesnt hold enough space, i cant tell how big the string will be,

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...