mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Moved logic to a shared library.
This commit is contained in:
@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "exeinfo", "exeinfo\exeinfo.csproj", "{504F0A15-25DC-42B1-81FE-BA22A8EF24B5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libexeinfo", "libexeinfo\libexeinfo.csproj", "{5DD22357-AEA1-4B1D-9CAB-F51873A3A5D0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
@@ -13,5 +15,9 @@ Global
|
||||
{504F0A15-25DC-42B1-81FE-BA22A8EF24B5}.Debug|x86.Build.0 = Debug|x86
|
||||
{504F0A15-25DC-42B1-81FE-BA22A8EF24B5}.Release|x86.ActiveCfg = Release|x86
|
||||
{504F0A15-25DC-42B1-81FE-BA22A8EF24B5}.Release|x86.Build.0 = Release|x86
|
||||
{5DD22357-AEA1-4B1D-9CAB-F51873A3A5D0}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5DD22357-AEA1-4B1D-9CAB-F51873A3A5D0}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5DD22357-AEA1-4B1D-9CAB-F51873A3A5D0}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{5DD22357-AEA1-4B1D-9CAB-F51873A3A5D0}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace exeinfo
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
static MZ.Header mzHdr;
|
||||
static NE.Header neHdr;
|
||||
static libexeinfo.MZ.Header mzHdr;
|
||||
static libexeinfo.NE.Header neHdr;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
@@ -25,53 +25,53 @@ namespace exeinfo
|
||||
|
||||
bool recognized = false;
|
||||
|
||||
byte[] buffer = new byte[Marshal.SizeOf(typeof(MZ.Header))];
|
||||
byte[] buffer = new byte[Marshal.SizeOf(typeof(libexeinfo.MZ.Header))];
|
||||
|
||||
exeFs.Read(buffer, 0, buffer.Length);
|
||||
IntPtr hdrPtr = Marshal.AllocHGlobal(buffer.Length);
|
||||
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
|
||||
mzHdr = (MZ.Header)Marshal.PtrToStructure(hdrPtr, typeof(MZ.Header));
|
||||
mzHdr = (libexeinfo.MZ.Header)Marshal.PtrToStructure(hdrPtr, typeof(libexeinfo.MZ.Header));
|
||||
Marshal.FreeHGlobal(hdrPtr);
|
||||
|
||||
if(mzHdr.signature == MZ.Consts.Signature)
|
||||
if(mzHdr.signature == libexeinfo.MZ.Consts.Signature)
|
||||
{
|
||||
recognized = true;
|
||||
MZ.Info.PrintInfo(mzHdr);
|
||||
libexeinfo.MZ.Info.PrintInfo(mzHdr);
|
||||
|
||||
if (mzHdr.new_offset < exeFs.Length)
|
||||
{
|
||||
exeFs.Seek(mzHdr.new_offset, SeekOrigin.Begin);
|
||||
|
||||
buffer = new byte[Marshal.SizeOf(typeof(NE.Header))];
|
||||
buffer = new byte[Marshal.SizeOf(typeof(libexeinfo.NE.Header))];
|
||||
exeFs.Read(buffer, 0, buffer.Length);
|
||||
hdrPtr = Marshal.AllocHGlobal(buffer.Length);
|
||||
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
|
||||
neHdr = (NE.Header)Marshal.PtrToStructure(hdrPtr, typeof(NE.Header));
|
||||
neHdr = (libexeinfo.NE.Header)Marshal.PtrToStructure(hdrPtr, typeof(libexeinfo.NE.Header));
|
||||
Marshal.FreeHGlobal(hdrPtr);
|
||||
|
||||
if (neHdr.signature == NE.Consts.Signature)
|
||||
if (neHdr.signature == libexeinfo.NE.Consts.Signature)
|
||||
{
|
||||
NE.Info.PrintInfo(neHdr);
|
||||
NE.ResourceTable resources = NE.Info.GetResources(exeFs, mzHdr.new_offset, neHdr.resource_table_offset);
|
||||
foreach(NE.ResourceType type in resources.types)
|
||||
libexeinfo.NE.Info.PrintInfo(neHdr);
|
||||
libexeinfo.NE.ResourceTable resources = libexeinfo.NE.Info.GetResources(exeFs, mzHdr.new_offset, neHdr.resource_table_offset);
|
||||
foreach(libexeinfo.NE.ResourceType type in resources.types)
|
||||
{
|
||||
if((type.id & 0x7FFF) == (int)NE.ResourceTypes.RT_VERSION)
|
||||
if((type.id & 0x7FFF) == (int)libexeinfo.NE.ResourceTypes.RT_VERSION)
|
||||
{
|
||||
foreach(NE.Resource resource in type.resources)
|
||||
foreach(libexeinfo.NE.Resource resource in type.resources)
|
||||
{
|
||||
NE.Version vers = new NE.Version(resource.data);
|
||||
libexeinfo.NE.Version vers = new libexeinfo.NE.Version(resource.data);
|
||||
Console.WriteLine("\tVersion resource {0}:", resource.name);
|
||||
Console.WriteLine("\t\tFile version: {0}", vers.FileVersion);
|
||||
Console.WriteLine("\t\tProduct version: {0}", vers.ProductVersion);
|
||||
Console.WriteLine("\t\tFile type: {0}", NE.Version.TypeToString(vers.FileType));
|
||||
if(vers.FileType == NE.VersionFileType.VFT_DRV)
|
||||
Console.WriteLine("\t\tFile subtype: {0} driver", NE.Version.DriverToString(vers.FileSubtype));
|
||||
else if (vers.FileType == NE.VersionFileType.VFT_DRV)
|
||||
Console.WriteLine("\t\tFile subtype: {0} font", NE.Version.FontToString(vers.FileSubtype));
|
||||
Console.WriteLine("\t\tFile type: {0}", libexeinfo.NE.Version.TypeToString(vers.FileType));
|
||||
if(vers.FileType == libexeinfo.NE.VersionFileType.VFT_DRV)
|
||||
Console.WriteLine("\t\tFile subtype: {0} driver", libexeinfo.NE.Version.DriverToString(vers.FileSubtype));
|
||||
else if (vers.FileType == libexeinfo.NE.VersionFileType.VFT_DRV)
|
||||
Console.WriteLine("\t\tFile subtype: {0} font", libexeinfo.NE.Version.FontToString(vers.FileSubtype));
|
||||
else if(vers.FileSubtype > 0)
|
||||
Console.WriteLine("\t\tFile subtype: {0}", (uint)vers.FileSubtype);
|
||||
Console.WriteLine("\t\tFile flags: {0}", vers.FileFlags);
|
||||
Console.WriteLine("\t\tFile OS: {0}", NE.Version.OsToString(vers.FileOS));
|
||||
Console.WriteLine("\t\tFile OS: {0}", libexeinfo.NE.Version.OsToString(vers.FileOS));
|
||||
|
||||
foreach (KeyValuePair<string, Dictionary<string, string>> strByLang in vers.StringsByLanguage)
|
||||
{
|
||||
|
||||
@@ -34,18 +34,12 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="NE\Version.cs" />
|
||||
<Compile Include="NE\Structs.cs" />
|
||||
<Compile Include="NE\Enums.cs" />
|
||||
<Compile Include="NE\Consts.cs" />
|
||||
<Compile Include="NE\Info.cs" />
|
||||
<Compile Include="MZ\Consts.cs" />
|
||||
<Compile Include="MZ\Info.cs" />
|
||||
<Compile Include="MZ\Structs.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="NE\" />
|
||||
<Folder Include="MZ\" />
|
||||
<ProjectReference Include="..\libexeinfo\libexeinfo.csproj">
|
||||
<Project>{5DD22357-AEA1-4B1D-9CAB-F51873A3A5D0}</Project>
|
||||
<Name>libexeinfo</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
namespace exeinfo.MZ
|
||||
namespace libexeinfo.MZ
|
||||
{
|
||||
public class Consts
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
namespace exeinfo.MZ
|
||||
namespace libexeinfo.MZ
|
||||
{
|
||||
public class Info
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace exeinfo.MZ
|
||||
namespace libexeinfo.MZ
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct Header
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
namespace exeinfo.NE
|
||||
namespace libexeinfo.NE
|
||||
{
|
||||
public static class Consts
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
namespace exeinfo.NE
|
||||
namespace libexeinfo.NE
|
||||
{
|
||||
[Flags]
|
||||
public enum ProgramFlags : byte
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace exeinfo.NE
|
||||
namespace libexeinfo.NE
|
||||
{
|
||||
public class Info
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace exeinfo.NE
|
||||
namespace libexeinfo.NE
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential/*, Pack = 2*/)]
|
||||
public struct Header
|
||||
@@ -4,7 +4,7 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace exeinfo.NE
|
||||
namespace libexeinfo.NE
|
||||
{
|
||||
public class Version
|
||||
{
|
||||
26
libexeinfo/Properties/AssemblyInfo.cs
Normal file
26
libexeinfo/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("libexeinfo")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Claunia.com")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("Copyright © Claunia.com")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
71
libexeinfo/libexeinfo.csproj
Normal file
71
libexeinfo/libexeinfo.csproj
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\NuGet.Build.Packaging.0.1.276\build\NuGet.Build.Packaging.props" Condition="Exists('..\packages\NuGet.Build.Packaging.0.1.276\build\NuGet.Build.Packaging.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5DD22357-AEA1-4B1D-9CAB-F51873A3A5D0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>libexeinfo</RootNamespace>
|
||||
<AssemblyName>libexeinfo</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<PackOnBuild>true</PackOnBuild>
|
||||
<PackageId>libexeinfo</PackageId>
|
||||
<PackageVersion>0.1</PackageVersion>
|
||||
<Authors>Natalia Portillo</Authors>
|
||||
<Owners>Natalia Portillo</Owners>
|
||||
<Summary>Library to get information about executable files.</Summary>
|
||||
<Title>libexeinfo</Title>
|
||||
<Description>Library to get information about executable files.</Description>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\libexeinfo.xml</DocumentationFile>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="MZ\Consts.cs" />
|
||||
<Compile Include="MZ\Info.cs" />
|
||||
<Compile Include="MZ\Structs.cs" />
|
||||
<Compile Include="NE\Consts.cs" />
|
||||
<Compile Include="NE\Enums.cs" />
|
||||
<Compile Include="NE\Info.cs" />
|
||||
<Compile Include="NE\Structs.cs" />
|
||||
<Compile Include="NE\Version.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="MZ\" />
|
||||
<Folder Include="NE\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\NuGet.Build.Packaging.0.1.276\build\NuGet.Build.Packaging.targets" Condition="Exists('..\packages\NuGet.Build.Packaging.0.1.276\build\NuGet.Build.Packaging.targets')" />
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<StandardHeader IncludeInNewFiles="True" Text="
${FileName}
 
Author:
 ${AuthorName} <${AuthorEmail}>

Copyright (c) ${Year} ${CopyrightHolder}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE." />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
4
libexeinfo/packages.config
Normal file
4
libexeinfo/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NuGet.Build.Packaging" version="0.1.276" targetFramework="net46" developmentDependency="true" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user