elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  [Delphi] PEFileSize function
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Delphi] PEFileSize function  (Leído 1,965 veces)
Khronos14


Desconectado Desconectado

Mensajes: 443


A lie is a lie


Ver Perfil WWW
[Delphi] PEFileSize function
« en: 25 Enero 2011, 17:52 pm »

Código
  1. (*
  2.  * PEFileSize function, inspired by The Swash
  3.  * by Khronos
  4. *)
  5.  
  6. function PEFileSize(FileName: string): Cardinal;
  7. var
  8. i: integer;
  9. FileStream: TFileStream;
  10. IDH: IMAGE_DOS_HEADER;
  11. INH: IMAGE_NT_HEADERS;
  12. ISH: IMAGE_SECTION_HEADER;
  13. begin
  14. result:= 0;
  15.  try
  16.    FileStream:= TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  17.    FileStream.Read(IDH, SizeOf(IDH));
  18.    if IDH.e_magic = IMAGE_DOS_SIGNATURE then
  19.      begin
  20.        FileStream.Seek(IDH._lfanew, 0);
  21.        FileStream.Read(INH, SizeOf(INH));
  22.        if INH.Signature = IMAGE_NT_SIGNATURE then
  23.          begin
  24.            for I := 0 to INH.FileHeader.NumberOfSections - 1 do
  25.              begin
  26.                FileStream.Seek(IDH._lfanew + SizeOf(INH) + SizeOf(ISH) * i, 0);
  27.                FileStream.Read(ISH, SizeOf(ISH));
  28.                result:= result + ISH.SizeOfRawData;
  29.              end;
  30.            result:= result + INH.OptionalHeader.SizeOfHeaders;
  31.          end;
  32.      end;
  33.  finally
  34.    FileStream.Free;
  35.  end;
  36. end;
  37.  

Saludos.


En línea

The Swash

Desconectado Desconectado

Mensajes: 194


Programmer


Ver Perfil WWW
Re: [Delphi] PEFileSize function
« Respuesta #1 en: 25 Enero 2011, 17:53 pm »

Muy bien Khronos, gracias por la traducción y me alegra que te aya gustado.
 ;D


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Descarga] CodeGear RAD Studio - Delphi 2007 + Delphi for PHP « 1 2 3 »
Software
GroK 26 25,420 Último mensaje 14 Mayo 2014, 17:51 pm
por sebaseok
No me va (Function)
PHP
Erik# 5 2,734 Último mensaje 20 Noviembre 2008, 20:48 pm
por Erik#
Function FileCreate [VB6]
Programación Visual Basic
The Swash 0 1,451 Último mensaje 22 Enero 2010, 17:53 pm
por The Swash
FiletoString Function [VB6]
Programación Visual Basic
The Swash 4 4,616 Último mensaje 9 Abril 2010, 06:55 am
por BlackZeroX
[C] PEFileSize function
Programación C/C++
The Swash 4 2,774 Último mensaje 27 Enero 2011, 01:16 am
por The Swash
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines