diff --git a/GetPermissionToExec.sln b/GetPermissionToExec.sln new file mode 100644 index 0000000..1e35db6 --- /dev/null +++ b/GetPermissionToExec.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2003 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetPermissionToExec", "GetPermissionToExec\GetPermissionToExec.csproj", "{B56A27A6-563B-4EE9-B179-FC10DA68BE16}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B56A27A6-563B-4EE9-B179-FC10DA68BE16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B56A27A6-563B-4EE9-B179-FC10DA68BE16}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B56A27A6-563B-4EE9-B179-FC10DA68BE16}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B56A27A6-563B-4EE9-B179-FC10DA68BE16}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DEC00797-CA19-4283-B51C-33E953FE439D} + EndGlobalSection +EndGlobal diff --git a/GetPermissionToExec/App.config b/GetPermissionToExec/App.config new file mode 100644 index 0000000..00bfd11 --- /dev/null +++ b/GetPermissionToExec/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GetPermissionToExec/GetPermissionToExec.csproj b/GetPermissionToExec/GetPermissionToExec.csproj new file mode 100644 index 0000000..7c4ba6f --- /dev/null +++ b/GetPermissionToExec/GetPermissionToExec.csproj @@ -0,0 +1,54 @@ + + + + + Debug + AnyCPU + {B56A27A6-563B-4EE9-B179-FC10DA68BE16} + Exe + GetPermissionToExec + FreeGMAssetCompiler + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GetPermissionToExec/MethodInvoker.cs b/GetPermissionToExec/MethodInvoker.cs new file mode 100644 index 0000000..f3199b8 --- /dev/null +++ b/GetPermissionToExec/MethodInvoker.cs @@ -0,0 +1,14 @@ +using System; + +namespace GetPermissionToExec +{ + internal class MethodInvoker + { + private Func p; + + public MethodInvoker(Func p) + { + this.p = p; + } + } +} \ No newline at end of file diff --git a/GetPermissionToExec/Program.cs b/GetPermissionToExec/Program.cs new file mode 100644 index 0000000..0fd891e --- /dev/null +++ b/GetPermissionToExec/Program.cs @@ -0,0 +1,116 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; + +namespace GetPermissionToExec +{ + class Program + { + + public enum FileMapProtection : uint + { + PageReadonly = 0x02, + PageReadWrite = 0x04, + PageWriteCopy = 0x08, + PageExecuteRead = 0x20, + PageExecuteReadWrite = 0x40, + SectionCommit = 0x8000000, + SectionImage = 0x1000000, + SectionNoCache = 0x10000000, + SectionReserve = 0x4000000, + } + + public enum FileMapAccess : uint + { + FileMapCopy = 0x0001, + FileMapWrite = 0x0002, + FileMapRead = 0x0004, + FileMapReadWrite = 0x0006, + FileMapAllAccess = 0x001f, + FileMapExecute = 0x0020, + } + + [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] + public static extern IntPtr CreateFileMapping( + IntPtr hFile, + IntPtr lpFileMappingAttributes, + FileMapProtection flProtect, + uint dwMaximumSizeHigh, + uint dwMaximumSizeLow, + string lpName + ); + + [DllImport("kernel32", SetLastError = true)] + public static extern IntPtr MapViewOfFile(IntPtr intptr_0, FileMapAccess dwDesiredAccess, int int_5, int int_6, IntPtr intptr_1); + + [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)] + public static extern IntPtr OpenFileMapping( + FileMapAccess dwDesiredAccess, + bool bInheritHandle, + string lpName + ); + + [DllImport("kernel32", SetLastError = true)] + public static extern bool CloseHandle(IntPtr intptr_0); + + private static void Main(string[] args) + { + + Console.Write("$ GMAssetCompiler "); + String Args; + if(args.Length == 0) + { + Stream inputStream = Console.OpenStandardInput(8024); + Console.SetIn(new StreamReader(inputStream)); + Args = Console.ReadLine(); + } + else + { + Args = String.Join(" ",args); + } + + + + IntPtr Create = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, FileMapProtection.PageReadWrite, 0x0, 0x1000, "YYMappingFileTestYY"); + IntPtr DaFile = OpenFileMapping(FileMapAccess.FileMapWrite, false, "YYMappingFileTestYY"); + IntPtr MapView = MapViewOfFile(DaFile, FileMapAccess.FileMapWrite, 0, 0, new IntPtr(4)); + + Marshal.WriteInt32(MapView, (int)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds); + + CloseHandle(DaFile); + + Process GMAC = new Process(); + String AppData = Environment.GetEnvironmentVariable("appdata"); + GMAC.StartInfo.FileName = AppData+"\\GameMaker-Studio\\GMAssetCompiler.exe"; + GMAC.StartInfo.UseShellExecute = false; + GMAC.StartInfo.RedirectStandardOutput = true; + GMAC.StartInfo.RedirectStandardError = true; + GMAC.OutputDataReceived += new DataReceivedEventHandler(gmacWrite); + GMAC.ErrorDataReceived += new DataReceivedEventHandler(gmacError); + GMAC.StartInfo.Arguments = Args; + GMAC.Start(); + GMAC.BeginOutputReadLine(); + GMAC.BeginErrorReadLine(); + GMAC.WaitForExit(); + if(args.Length == 0) + { + Main(new String[0]); + } + + } + + private static void gmacError(object sender, DataReceivedEventArgs e) + { + String StdErr = e.Data; + Console.WriteLine(StdErr); + } + + private static void gmacWrite(object sender, DataReceivedEventArgs e) + { + String StdOut = e.Data; + Console.WriteLine(StdOut); + } + } +} diff --git a/GetPermissionToExec/Properties/AssemblyInfo.cs b/GetPermissionToExec/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5f5ec83 --- /dev/null +++ b/GetPermissionToExec/Properties/AssemblyInfo.cs @@ -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("GetPermissionToExec")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GetPermissionToExec")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[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("b56a27a6-563b-4ee9-b179-fc10da68be16")] + +// 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")]