Skip to content

ethanmoffat/PELoaderLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

PELoaderLib is a library for loading compiled resources out of windows portable executable files.

Much of the implementation is based on the description of the file format here.

Build Status

Build Status

Usage

Operations may throw a number of exceptions. For specific exception types, consult the source code.

v1.5 and earlier

using (IPEFile file = new PEFile("somefile.dll"))
{
    file.Initialize();

    var fileBytes = file.GetEmbeddedBitmapResourceByID(123);

    if (fileBytes.Length == 0)
    {
        throw new Exception("Failed to load resource!");
    }

    using var ms = new MemoryStream(fileBytes);
    using var image = (Bitmap)Image.FromStream(ms);
    //do something with image
}

v1.6 and later

// The following Nuget package is required for high performance conversion of Memory<byte> to Stream
// using CommunityToolkit.HighPerformance;

using (IPEFile file = new PEFile("somefile.dll"))
{
    file.Initialize();

    var bitmapData = file.GetEmbeddedBitmapResourceByID(123);

    if (fileBytes.Length == 0)
    {
        throw new Exception("Failed to load resource!");
    }

    // if using CommunityToolkit.HighPerformance:
    using var ms = fileBytes.AsStream();
    // otherwise:
    // using var ms = new MemoryStream(fileBytes.ToArray());
    using var image = (Bitmap)Image.FromStream(ms);
    //do something with image

    var resourceData = file.GetResourceByID(ResourceType.RCData, 123);
    var dataAsString = Encoding.Unicode.GetString(rawMetadata);
    // do something with string RCData
}

Contributing

Guidelines here

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages