private void TestLoadKernel32()
 {
     using (var dll = new UnmanagedDll("kernel32.dll"))
     {
         var beep = dll.GetFunction <Beep>();
         Assert.NotNull(beep);
         //beep(400, 1000);
         var areFileApisAnsi = dll.GetFunction <AreFileApisANSI>();
         var b = areFileApisAnsi(); // does not throw.
     }
 }
Beispiel #2
0
 static void LowLevelTest(string[] args)
 {
     var nat = new UnmanagedDll ("libdl.so");
     var open = nat.GetFunction<dlopen> ("dlopen");
     var error = nat.GetFunction<dlerror> ("dlerror");
     IntPtr handle = open (args [0], 0x01);
     if (IntPtr.Zero == handle) {
         Console.WriteLine ("failed!!");
         var msg = error ();
         if (!string.IsNullOrEmpty (msg))
             Console.WriteLine (msg);
     }
     else {
         Console.WriteLine ("Success!!");
     }
 }
        private static void LaunchLongLivedNativeTask()
        {
            var doTask = myNativeDll.GetFunction <DoLongLivedTask>("do_long_lived_task");

            //if not using DynamicInterop you would be using a call such as :

            doTask();
        }
Beispiel #4
0
 public RclrUnmanagedDll(string dllName)
 {
     if (!File.Exists(dllName))
     {
         throw new FileNotFoundException(dllName);
     }
     this.dll = new UnmanagedDll(dllName);
     this.ClrObjectToSexp = dll.GetFunction<ClrObjectToSexpDelegate>("clr_object_to_SEXP");
 }
        private void TestLoadLibc()
        {
            // TODO: obviously need to generalize this.

            //nm -D --defined-only /lib/x86_64-linux-gnu/libc.so.6 | less
            using (var dll = new UnmanagedDll("/lib/x86_64-linux-gnu/libc.so.6"))
            {
                var m = dll.GetFunction <malloc>();
                Assert.NotNull(m);
            }
        }
Beispiel #6
0
        static void LowLevelTest(string[] args)
        {
            var    nat    = new UnmanagedDll("libdl.so");
            var    open   = nat.GetFunction <dlopen> ("dlopen");
            var    error  = nat.GetFunction <dlerror> ("dlerror");
            IntPtr handle = open(args [0], 0x01);

            if (IntPtr.Zero == handle)
            {
                Console.WriteLine("failed!!");
                var msg = error();
                if (!string.IsNullOrEmpty(msg))
                {
                    Console.WriteLine(msg);
                }
            }
            else
            {
                Console.WriteLine("Success!!");
            }
        }