/// <summary>
        /// Opens a library. If 'filename' is not a fully-qualified path, the default search path is used.
        /// </summary>
        public static SafeLibraryHandle Open(string filename)
        {
            const uint LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800U; // from libloaderapi.h

            SafeLibraryHandle handle = UnsafeNativeMethods.LoadLibraryEx(filename, IntPtr.Zero, LOAD_LIBRARY_SEARCH_SYSTEM32);

            if (handle == null || handle.IsInvalid)
            {
                UnsafeNativeMethods.ThrowExceptionForLastWin32Error();
            }
            return(handle);
        }
示例#2
0
        private static void InitHttpApi(ushort majorVersion, ushort minorVersion)
        {
            version.HttpApiMajorVersion = majorVersion;
            version.HttpApiMinorVersion = minorVersion;

            var statusCode = HttpInitialize(version, (uint)(HTTP_FLAGS.HTTP_INITIALIZE_SERVER | HTTP_FLAGS.HTTP_INITIALIZE_CONFIG), null);

            supported = statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS;

            if (supported)
            {
                HttpApiModule          = SafeLibraryHandle.Open(HTTPAPI);
                HttpSetRequestProperty = HttpApiModule.GetProcAddress <HttpSetRequestPropertyInvoker>("HttpSetRequestProperty", throwIfNotFound: false);
                SupportsReset          = HttpSetRequestProperty != null;
                SupportsTrailers       = IsFeatureSupported(HTTP_FEATURE_ID.HttpFeatureResponseTrailers);
                SupportsDelegation     = IsFeatureSupported(HTTP_FEATURE_ID.HttpFeatureDelegateEx);
            }
        }
示例#3
0
        private static void InitHttpApi(ushort majorVersion, ushort minorVersion)
        {
            version.HttpApiMajorVersion = majorVersion;
            version.HttpApiMinorVersion = minorVersion;

            var statusCode = HttpInitialize(version, (uint)HTTP_FLAGS.HTTP_INITIALIZE_SERVER, null);

            supported = statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS;

            if (supported)
            {
                HttpApiModule          = SafeLibraryHandle.Open(HTTPAPI);
                HttpSetRequestProperty = HttpApiModule.GetProcAddress <HttpSetRequestPropertyInvoker>("HttpSetRequestProperty", throwIfNotFound: false);

                SupportsReset = HttpSetRequestProperty != null;
                // Trailers support was added in the same release as Reset, but there's no method we can export to check it directly.
                SupportsTrailers = SupportsReset;
            }
        }
 internal static extern IntPtr GetProcAddress(
     [In] SafeLibraryHandle hModule,
     [In, MarshalAs(UnmanagedType.LPStr)] string lpProcName);