CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    2

    Process Checksum

    Hello guys,

    Does someone know how I can get a checksum (in C#) of a running process and probably locked, like svchost or a program in use, like FireFox? I get access denied when trying to open it using this method:

    protected string GetMD5HashFromFile(string fileName)
    {
    FileStream file = new FileStream(fileName, FileMode.Open);
    MD5 md5 = new MD5CryptoServiceProvider();
    byte[] retVal = md5.ComputeHash(file);
    file.Close();

    ASCIIEncoding enc = new ASCIIEncoding();
    return enc.GetString(retVal);
    }

    Source: http://sharpertutorials.com/calculat...checksum-file/

    AntiVirus programs compare file hashes to check the files legitimacy, so it must be possible.

    Thanks in advance.

    Regards,
    John

  2. #2
    Join Date
    Jul 2009
    Posts
    2

    Re: Process Checksum

    Noone?

  3. #3
    Join Date
    Jul 2006
    Posts
    297

    Re: Process Checksum

    Try this... It works for me. Though the encoding was all messed up for me on the hash, but you're not trying to read these checksums i assume right?

    Code:
    FileStream file = new FileInfo(fileName).OpenRead();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured