Пример #1
0
 public void LoadFunctionStandard()
 {
     using (var handle = ModuleMethods.LoadLibrary(GetNativeTestLibraryLocation(), LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH))
     {
         handle.IsInvalid.Should().BeFalse();
         var doubler = ModuleMethods.GetFunctionDelegate <DoubleDelegateStandard>(handle, "DoubleStdCall");
         doubler(2).Should().Be(4);
     }
 }
Пример #2
0
        public void LoadFunctionFromLongPath()
        {
            using (var cleaner = new TestFileCleaner())
            {
                string longPath = @"\\?\" + PathGenerator.CreatePathOfLength(cleaner.TempFolder, 500);
                FileHelper.CreateDirectoryRecursive(longPath);
                string longPathLibrary = Paths.Combine(longPath, "LoadFunctionFromLongPath.dll");
                FileMethods.CopyFile(GetNativeTestLibraryLocation(), longPathLibrary);

                using (var handle = ModuleMethods.LoadLibrary(longPathLibrary, 0))
                {
                    handle.IsInvalid.Should().BeFalse();
                    var doubler = ModuleMethods.GetFunctionDelegate <DoubleDelegate>(handle, "Double");
                    doubler(2).Should().Be(4);
                }
            }
        }