Moved Microsoft stuff into its own plugin

This commit is contained in:
Michael Becker 2014-08-06 15:35:46 -04:00
parent b1bf5be3df
commit 7b88fa3665
13 changed files with 395 additions and 5 deletions

View File

@ -3,7 +3,7 @@
<Languages DefaultLanguageID="English">
<Language ID="English">
<StringTable>
<StringTableEntry ID="ApplicationTitle" Value="Universal Editor" />
<StringTableEntry ID="ApplicationTitle" Value="Concertroid Studio" />
</StringTable>
<OptionPanels>
<OptionPanel ID="{6B7D5857-CDC7-482E-A6D1-A13E0E273C45}" Title="Application">

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.FileSystem.MSCompressed
namespace UniversalEditor.DataFormats.FileSystem.Microsoft.MSCompressed
{
public enum MSCompressedCompressionMethod
{

View File

@ -5,7 +5,7 @@ using System.Text;
using UniversalEditor.Accessors;
using UniversalEditor.ObjectModels.FileSystem;
namespace UniversalEditor.DataFormats.FileSystem.MSCompressed
namespace UniversalEditor.DataFormats.FileSystem.Microsoft.MSCompressed
{
public class MSCompressedDataFormat : DataFormat
{

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.FileSystem.MSCompressed
namespace UniversalEditor.DataFormats.FileSystem.Microsoft.MSCompressed
{
public enum MSCompressedKWAJCompressionMethod
{

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.FileSystem.MSCompressed
namespace UniversalEditor.DataFormats.FileSystem.Microsoft.MSCompressed
{
[Flags()]
public enum MSCompressedKWAJHeaderFlags

View File

@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Shortcut.Microsoft
{
[Flags()]
public enum LNKDataFlags
{
None = 0x00000000,
/// <summary>
/// The LNK file contains a link target identifier.
/// </summary>
HasTargetIDList = 0x00000001,
/// <summary>
/// The LNK file contains location information.
/// </summary>
HasLinkInfo = 0x00000002,
/// <summary>
/// The LNK file contains a description data string.
/// </summary>
HasName = 0x00000004,
/// <summary>
/// The LNK file contains a relative path data string.
/// </summary>
HasRelativePath = 0x00000008,
/// <summary>
/// The LNK file contains a working directory data string.
/// </summary>
HasWorkingDir = 0x00000010,
/// <summary>
/// The LNK file contains a command line arguments data string.
/// </summary>
HasArguments = 0x00000020,
/// <summary>
/// The LNK file contains a custom icon location.
/// </summary>
HasIconLocation = 0x00000040,
/// <summary>
/// The data strings in the LNK file are stored in Unicode (UTF-16 little-endian) instead of ASCII.
/// </summary>
IsUnicode = 0x00000080,
/// <summary>
/// The location information is ignored.
/// </summary>
ForceNoLinkInfo = 0x00000100,
/// <summary>
/// The LNK file contains environment variables that should be expanded.
/// </summary>
HasExpString = 0x00000200,
/// <summary>
/// A 16-bit target application is run in a separate virtual machine.
/// </summary>
RunInSeparateProcess = 0x00000400,
// Reserved = 0x00000800,
/// <summary>
/// The LNK file contains a Darwin (Mac OS-X) properties data block.
/// </summary>
HasDarwinID = 0x00001000,
/// <summary>
/// The target application is run as a different user.
/// </summary>
RunAsUser = 0x00002000,
/// <summary>
/// The LNK file contains an icon location data block.
/// </summary>
HasExpIcon = 0x00004000,
/// <summary>
/// The file system location is represented in the shell namespace when the path to an
/// item is parsed into the link target identifiers.
/// Contains a known folder location data block ?
/// </summary>
NoPidlAlias = 0x00008000,
// Reserved = 0x00010000,
// Windows Vista and later?
/// <summary>
/// The target application is run with the shim layer. The LNK file contains shim layer
/// properties data block.
/// </summary>
RunWithShimLayer = 0x00020000,
/// <summary>
/// The LNK does not contain a distributed link tracking data block. Note that LNK files
/// in Windows XP and earlier do not use the ForceNoLinkTrack flag.
/// </summary>
ForceNoLinkTrack = 0x00040000,
/// <summary>
/// The LNK file contains a metadata property store data block.
/// </summary>
EnableTargetMetadata = 0x00080000,
/// <summary>
/// The environment variables location block should be ignored.
/// </summary>
DisableLinkPathTracking = 0x00100000,
DisableKnownFolderTracking = 0x00200000,
DisableKnownFolderAlias = 0x00400000,
AllowLinkToLink = 0x00800000,
UnaliasOnSave = 0x01000000,
PreferEnvironmentPath = 0x02000000,
KeepLocalIDListForUNCTarget = 0x04000000
}
}

View File

@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniversalEditor.IO;
using UniversalEditor.ObjectModels.Shortcut;
namespace UniversalEditor.DataFormats.Shortcut.Microsoft
{
public class LNKDataFormat : DataFormat
{
private static readonly Guid LNK_CLASSID = new Guid("00021401-0000-0000-00c0-000000000046}");
private static DataFormatReference _dfr = null;
public override DataFormatReference MakeReference()
{
if (_dfr == null)
{
_dfr = base.MakeReference();
_dfr.Capabilities.Add(typeof(ShortcutObjectModel), DataFormatCapabilities.All);
_dfr.Sources.Add("https://03132e779c908f66a75b1162132f53bf2761aa1a.googledrive.com/host/0B3fBvzttpiiSQmluVC1YeDVvZWM/Windows%20Shortcut%20File%20%28LNK%29%20format.pdf");
_dfr.Filters.Add("Microsoft shortcut", new byte?[][] { new byte?[] { 0x4C, 0x00, 0x00, 0x00 } }, new string[] { "*.lnk" });
}
return _dfr;
}
protected override void LoadInternal(ref ObjectModel objectModel)
{
ShortcutObjectModel shortcut = (objectModel as ShortcutObjectModel);
if (shortcut == null) throw new ObjectModelNotSupportedException();
Reader reader = base.Accessor.Reader;
#region File header
uint headerSize = reader.ReadUInt32();
if (headerSize != 0x0000004C) throw new InvalidDataFormatException("Invalid header size for shortcut file (not 0x0000004C)");
Guid classID = reader.ReadGuid();
if (classID.Equals(LNK_CLASSID)) throw new InvalidDataFormatException("Class ID '" + classID.ToString("B") + "' does not match LNK class ID '" + LNK_CLASSID.ToString("B") + "'");
LNKDataFlags dataFlags = (LNKDataFlags)reader.ReadUInt32();
LNKFileAttributeFlags fileAttributeFlags = (LNKFileAttributeFlags)reader.ReadUInt32();
long creationFILETIME = reader.ReadInt64();
long accessedFILETIME = reader.ReadInt64();
long modifiedFILETIME = reader.ReadInt64();
int filesize = reader.ReadInt32();
int iconindex = reader.ReadInt32();
LNKWindowState windowState = (LNKWindowState)reader.ReadInt32();
LNKHotkey hotkey = (LNKHotkey)reader.ReadInt16();
short reserved1 = reader.ReadInt16();
int reserved2 = reader.ReadInt32();
int reserved3 = reader.ReadInt32();
#endregion
#region Shell item identifiers list (Link target identifier)
if ((dataFlags & LNKDataFlags.HasTargetIDList) == LNKDataFlags.HasTargetIDList)
{
// The size of the link target identifier shell item identifiers list
ushort targetIDListSize = reader.ReadUInt16();
// shell item identifiers (LIBFWSI)
}
#endregion
#region Location information
if ((dataFlags & LNKDataFlags.HasLinkInfo) == LNKDataFlags.HasLinkInfo)
{
uint locationInfoSize = reader.ReadUInt32();
#region Location information header
uint locationInfoHeaderSize = reader.ReadUInt32();
LNKLocationFlags locationFlags = (LNKLocationFlags)reader.ReadUInt32();
// Offset to the volume information. The offset is relative to the start of the
// location information.
uint volumeInformationOffset = reader.ReadUInt32();
// Offset to the local path. The offset is relative to the start of the location
// information.
uint localPathOffset = reader.ReadUInt32();
// Offset to the network share information. The offset is relative to the start of
// the location information.
uint networkShareInformationOffset = reader.ReadUInt32();
// Offset to the common path. The offset is relative to the start of the location
// information.
uint commonPathOffset = reader.ReadUInt32();
if (locationInfoHeaderSize > 28)
{
// Offset to the Unicode local path.
uint unicodeLocalPathOffset = reader.ReadUInt32();
if (locationInfoHeaderSize > 32)
{
// Offset to the Unicode common path.
uint unicodeCommonPathOffset = reader.ReadUInt32();
}
}
#endregion
// The full filename can be determined by:
// • combining the local path and the common path
// • combining the network share name (in the network share information) with
// the common path
// Note that the network share name is not necessarily terminated by a path
// separator. Currently it is assumed that the same applies to the local path.
// Also, the file can contain an empty common path where the local path contains
// the full path.
}
#endregion
#region Data strings
#endregion
#region Extra data blocks
#endregion
}
protected override void SaveInternal(ObjectModel objectModel)
{
ShortcutObjectModel shortcut = (objectModel as ShortcutObjectModel);
if (shortcut == null) throw new ObjectModelNotSupportedException();
Writer writer = base.Accessor.Writer;
writer.WriteUInt32(0x0000004C);
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Shortcut.Microsoft
{
[Flags()]
public enum LNKFileAttributeFlags
{
None = 0
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Shortcut.Microsoft
{
public enum LNKHotkey : short
{
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Shortcut.Microsoft
{
[Flags()]
public enum LNKLocationFlags
{
None = 0x00000000,
/// <summary>
/// The linked file is on a volume. If set, the volume information and the local path
/// contain data.
/// </summary>
VolumeIDAndLocalBasePath = 0x0001,
/// <summary>
/// The linked file is on a network share. If set, the network share information and
/// common path contain data.
/// </summary>
/// <remarks>
/// Although [MS-SHLLINK] states that when the CommonNetworkRelativeLinkAndPathSuffix
/// location flag is not set the offset to the network share information should be zero,
/// the value can still be set, but is not necessarily valid. This behavior was seen on
/// Windows 95.
/// </remarks>
CommonNetworkRelativeLinkAndPathSuffix = 0x0002
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Shortcut.Microsoft
{
public enum LNKWindowState
{
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UniversalEditor.Plugins.Microsoft")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("City of Orlando")]
[assembly: AssemblyProduct("UniversalEditor.Plugins.Microsoft")]
[assembly: AssemblyCopyright("Copyright © City of Orlando 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("40fdeaf4-17e9-4b69-80ab-3221452736fb")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4698BC3F-EC29-42EB-9AED-3D8F9983A108}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UniversalEditor</RootNamespace>
<AssemblyName>UniversalEditor.Plugins.Microsoft</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataFormats\FileSystem\Microsoft\MSCompressed\MSCompressedCompressionMethod.cs" />
<Compile Include="DataFormats\FileSystem\Microsoft\MSCompressed\MSCompressedDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\Microsoft\MSCompressed\MSCompressedKWAJCompressionMethod.cs" />
<Compile Include="DataFormats\FileSystem\Microsoft\MSCompressed\MSCompressedKWAJHeaderFlags.cs" />
<Compile Include="DataFormats\Shortcut\Microsoft\LNKDataFormat.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
<Project>{2d4737e6-6d95-408a-90db-8dff38147e85}</Project>
<Name>UniversalEditor.Core</Name>
</ProjectReference>
<ProjectReference Include="..\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
<Project>{30467e5c-05bc-4856-aadc-13906ef4cadd}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>