示例#1
0
        internal static DelegateType GetFunctionDelegate <DelegateType>(SafeLibraryHandle library, string methodName)
        {
            IntPtr method = Private.GetProcAddress(library, methodName);

            if (method == IntPtr.Zero)
            {
                int error = Marshal.GetLastWin32Error();
                throw GetIoExceptionForError(error, methodName);
            }

            return((DelegateType)(object)Marshal.GetDelegateForFunctionPointer(method, typeof(DelegateType)));
        }
示例#2
0
        unsafe internal static string LoadString(SafeLibraryHandle library, int identifier)
        {
            // Passing 0 will give us a read only handle to the string resource
            char *buffer;
            int   result = Private.LoadStringW(library, identifier, out buffer, 0);

            if (result <= 0)
            {
                int error = Marshal.GetLastWin32Error();
                throw GetIoExceptionForError(error, identifier.ToString());
            }

            // Null is not included in the result
            return(new string(buffer, 0, result));
        }
示例#3
0
 internal static extern IntPtr GetProcAddress(
     SafeLibraryHandle hModule,
     [MarshalAs(UnmanagedType.LPStr)] string methodName);
示例#4
0
        //[DllImport("ntdll.dll", SetLastError = true)]
        //public static extern uint NtQueryObject(IntPtr handle, ObjectInformationClass objectInformationClass,
        //    IntPtr objectInformation, uint objectInformationLength, out uint returnLength);

        internal static bool FreeLibrary(SafeLibraryHandle handle)
        {
            return(Private.FreeLibrary(handle.DangerousGetHandle()));
        }
示例#5
0
 unsafe internal static extern int LoadStringW(
     SafeLibraryHandle hInstance,
     int uID,
     out char *lpBuffer,
     int nBufferMax);