In one terminal run: mono foo.exe In anothr terminal run: kill -TERM [PID]
Created
October 23, 2019 15:57
-
-
Save lambdageek/1397cf5f5d4eec83888b88e5f3c8ad79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| void | |
| foo (void) | |
| { | |
| printf ("Hello\n"); | |
| } | |
| void | |
| bar (void) | |
| { | |
| while (1) { | |
| sleep (10); | |
| foo (); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.IO; | |
| using System.Reflection; | |
| using System.Runtime.InteropServices; | |
| public class Program | |
| { | |
| [DllImport("foo", EntryPoint="bar")] | |
| static extern void bar (); | |
| public static void EnableMERP (string pwd) { | |
| MethodInfo m = typeof (string).Assembly.GetType ("Mono.Runtime").GetMethod ("EnableMicrosoftTelemetry", BindingFlags.NonPublic | BindingFlags.Static); | |
| if (m == null) | |
| throw new Exception ("no meth"); | |
| m.Invoke (null, new object[] {"Merp", "Merp", "1.0", pwd, "unused", pwd, pwd + Path.DirectorySeparatorChar} ); | |
| } | |
| public static void WhitelistNative () { | |
| MethodInfo m = typeof (string).Assembly.GetType ("Mono.Runtime").GetMethod ("RegisterReportingForAllNativeLibs", BindingFlags.NonPublic | BindingFlags.Static); | |
| if (m == null) | |
| throw new Exception ("no whit"); | |
| m.Invoke (null, null); | |
| } | |
| public static void Main () | |
| { | |
| EnableMERP(Directory.GetCurrentDirectory()); | |
| WhitelistNative(); | |
| Console.WriteLine ("Ready:"); | |
| bar (); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| all: foo.exe | |
| .PHONY: all | |
| libfoo.dylib: foo.c | |
| clang -shared -fpic -o $@ $< | |
| foo.exe: foo.cs libfoo.dylib | |
| csc /target:exe /out:$@ foo.cs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment