views:

63

answers:

1

hi, in first exe i have defined array of char with some special bytes as label, i mapping it to memory from another exe, finding needed label and putting in it new data, but this data could be shorter then defined array, so i want to cut this array to needed size! how can i do it?

+1  A: 

There is no fine and simple way to cut out pieces of PE file.

Obvious solution is to additionally define a length field in the original (in your terms first) exe and mark it with another label. Then additional work of second exe would be to write to this field actual data length.


EDIT: If cutting is your primary goal you must also keep in mind that:

  • Control sum of a PE will change. Location of control sum field in PE header is not hard to find though.
  • PE file is aligned. All sections are aligned. The alignment could be found in the header too.
  • If you cut one section it would cause great consequences. Take a look at PE file header structure.

header

Reference: http://msdn.microsoft.com/en-us/library/ms809762.aspx

Keynslug