GithubHelp home page GithubHelp logo

ied206 / joveler.filemagician Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 0.0 11.77 MB

Cross-platform libmagic pinvoke library for .NET.

License: Other

C# 13.72% Batchfile 0.03% Shell 0.91% Makefile 0.61% C 80.73% PowerShell 0.89% M4 0.78% Roff 2.34%

joveler.filemagician's People

Contributors

ied206 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

joveler.filemagician's Issues

Debug assertion fails in Joveler.FileMagician.Cli's BinaryDetector on parsing format flags for .NET 8.0 executable

This issue can be demonstrated by analyzing a .NET 8.0-targeted version of the Joveler.FileMagician.Cli executable itself.

Steps to reproduce:

  1. Clone Joveler.FileMagician
  2. Port the solution to .NET 8.0 by updating TargetFrameworks in each of the solution's 3 .csproj files:
<TargetFrameworks>net8.0</TargetFrameworks>
  1. For some reason, this may change the "Copy to Output Directory" property of Joveler.FileMagician's bundled runtimes to "None". In this case, select each bundled runtime under this project's runtimes/ directory (all libmagic.so files, libmagic.dylib, lingnurx-0.dll, etc..), and change their "Copy to Output Directory" property to "Copy if newer".
  2. Replace Program.cs in Joveler.FileMagician.Cli with the following code intended to illustrate the issue:
using Joveler.FileMagician.Samples;
using System.Diagnostics;

namespace Joveler.FileMagician.Cli
{
    public class Program
    {
        public static void Main(string[] args)
        {
            using (var bd = new BinaryDetector())
            {
                using (var process = Process.GetCurrentProcess())
                {
                    var result = bd.InspectBinary(process.MainModule.FileName);
                }
            }
        }
    }
}
  1. F5 Joveler.FileMagician.Cli
  2. Observe the following debug assertion failing on BinaryDetector line 408:
                if (typeStr.Contains("Mono/.Net assembly", StringComparison.Ordinal))
                    formatFlags |= PEFormatFlags.NetAssembly;
                Debug.Assert(formatFlags.HasFlag(PEFormatFlags.NetAssembly) &&
                             binFlags.HasFlag(BinFlags.Bit32));

I may be misreading, but looks like it's assuming all .NET assemblies should be 32-bit?

Separately -- I wonder if this assert is meant to be included in the if statement above it?

Mobile OS support

In this age of modern .NET miracles, I wonder if support for Android and iOS has been considered?

[Feature request] Create overrides for Magic.Open() and Magic.GlobalInit() that take stream parameter

Happy 2024! I started taking a look at requirements for #2, and it seems that a (seemingly) small enhancement could open the door to achieving it.

In .NET MAUI, the modern mobile development framework for .NET, "Content" is not a valid build action for magic.mgc and magic.src.

Instead, in this case it's necessary to use the new "MauiAsset" build action to include these files in the build.

Following this, you'd access magic.mgc like so:

async Task LoadMauiAsset()
{
	using var stream = await FileSystem.OpenAppPackageFileAsync("magic.mgc");
	using var reader = new StreamReader(stream);
	
	var contents = reader.ReadToEnd();
}

This has to do with how MAUI manages assets and abstracts away details of the device's underlying file system.

So, if overrides for Magic.Open() and Magic.GlobalInit() were added that could accept a stream like this as the parameter, then native binaries for iOS and Android could be added, and voila!

I hope you'll consider making this enhancement. I'm at your disposal to assist in any way.

  • Feel free to close this and move the request into #2 if more appropriate

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.