Subversion Repositories Kolibri OS

Rev

Rev 616 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 616 Rev 763
Line 255... Line 255...
255
  ImageBase, ImageSize, Size: DWord;
255
  ImageBase, ImageSize, Size: DWord;
256
  Buffer: Pointer;
256
  Buffer: Pointer;
257
  i: Integer;
257
  i: Integer;
258
begin
258
begin
259
  ExeImage := TExeImage.Create(InputFile);
259
  ExeImage := TExeImage.Create(InputFile);
-
 
260
 
-
 
261
{$ifdef debug}
260
  WriteHead('NT Header');
262
  WriteHead('NT Header');
261
  WriteLn(Format('Size of Code: %d', [ExeImage.SizeOfCode]));
263
  WriteLn(Format('Size of Code: %d', [ExeImage.SizeOfCode]));
262
  WriteLn(Format('Size of Init Data: %d', [ExeImage.SizeOfInitializedData]));
264
  WriteLn(Format('Size of Init Data: %d', [ExeImage.SizeOfInitializedData]));
263
  WriteLn(Format('Size of UnInit Data: %d', [ExeImage.SizeOfUninitializedData]));
265
  WriteLn(Format('Size of UnInit Data: %d', [ExeImage.SizeOfUninitializedData]));
264
  WriteLn(Format('Entry Point: 0x%x', [ExeImage.EntryPoint]));
266
  WriteLn(Format('Entry Point: 0x%x', [ExeImage.EntryPoint]));
265
  WriteLn(Format('Image Base: 0x%x', [ExeImage.ImageBase]));
267
  WriteLn(Format('Image Base: 0x%x', [ExeImage.ImageBase]));
266
  WriteLn(Format('Object Align: %d; File Align: %d', [ExeImage.ObjectAlign, ExeImage.FileAlign]));
268
  WriteLn(Format('Object Align: %d; File Align: %d', [ExeImage.ObjectAlign, ExeImage.FileAlign]));
267
  WriteLn(Format('Image Size: %d; Header Size: %d', [ExeImage.ImageSize, ExeImage.HeaderSize]));
269
  WriteLn(Format('Image Size: %d; Header Size: %d', [ExeImage.ImageSize, ExeImage.HeaderSize]));
268
  WriteLn(Format('Stack Reserve Size: %d; Stack Commit Size: %d', [ExeImage.StackReserveSize, ExeImage.StackCommitSize]));
270
  WriteLn(Format('Stack Reserve Size: %d; Stack Commit Size: %d', [ExeImage.StackReserveSize, ExeImage.StackCommitSize]));
269
  WriteLn(Format('Heap Reserve Size: %d; Heap Comit Size: %d', [ExeImage.HeapReserveSize, ExeImage.HeapCommitSize]));
271
  WriteLn(Format('Heap Reserve Size: %d; Heap Comit Size: %d', [ExeImage.HeapReserveSize, ExeImage.HeapCommitSize]));
-
 
272
{$endif}
Line 270... Line 273...
270
 
273
 
271
  ImageBase := ExeImage.ImageBase;
274
  ImageBase := ExeImage.ImageBase;
Line 272... Line 275...
272
  ImageSize := 0;
275
  ImageSize := 0;
273
 
276
 
274
  { çàïèñü ñåêöèé }
277
  { çàïèñü ñåêöèé }
275
  FileStream := TFileStream.Create(OutputFile, fmCreate);
278
  FileStream := TFileStream.Create(OutputFile, fmCreate);
276
  for i:=0 to ExeImage.Sections.Count-1 do
279
  for i:=0 to ExeImage.Sections.Count-1 do
-
 
280
  with ExeImage.Sections[i] do
-
 
281
  begin
277
  with ExeImage.Sections[i] do
282
 
278
  begin
283
{$ifdef debug}
279
    WriteHead(Format('Section %s (0x%x)', [Name, ObjectFlags]));
284
    WriteHead(Format('Section %s (0x%x)', [Name, ObjectFlags]));
-
 
285
    WriteLn(Format('Section RVA/Size: 0x%x / %d', [SectionRVA, VirtualSize]));
Line 280... Line 286...
280
    WriteLn(Format('Section RVA/Size: 0x%x / %d', [SectionRVA, VirtualSize]));
286
    WriteLn(Format('Physical Offset/Size: 0x%x / %d', [PhysicalOffset, PhysicalSize]));
281
    WriteLn(Format('Physical Offset/Size: 0x%x / %d', [PhysicalOffset, PhysicalSize]));
287
{$endif}
282
 
288
 
283
    Size := ImageBase + SectionRVA;
289
    Size := ImageBase + SectionRVA;
Line 290... Line 296...
290
      GetMem(Buffer, PhysicalSize);
296
      GetMem(Buffer, PhysicalSize);
291
      Read(Buffer^);
297
      Read(Buffer^);
292
      FileStream.Write(Buffer^, PhysicalSize);
298
      FileStream.Write(Buffer^, PhysicalSize);
293
      FreeMem(Buffer);
299
      FreeMem(Buffer);
294
    end;
300
    end;
295
    {if VirtualSize - PhysicalSize > 0 then
-
 
296
    begin
-
 
297
      GetMem(Buffer, VirtualSize - PhysicalSize);
-
 
298
      FillByte(Buffer^, VirtualSize - PhysicalSize, 0);
-
 
299
      FileStream.Write(Buffer^, VirtualSize - PhysicalSize);
-
 
300
      FreeMem(Buffer);
-
 
301
    end;}
-
 
302
  end;
301
  end;
Line 303... Line 302...
303
 
302
 
304
  FillByte(KosHeader, SizeOf(KosHeader), 0);
303
  FillByte(KosHeader, SizeOf(KosHeader), 0);
305
  with KosHeader do
304
  with KosHeader do