Пример #1
0
            /// <summary>
            /// Create a HarmonyLibrary from a subset of the given byte array, which should contain the bytes of
            /// an unmanaged EXE or an unmanaged DLL.
            /// </summary>
            /// <param name="rawDll">An array of bytes that contains the EXE or DLL to load.</param>
            /// <param name="offset">Where within the raw byte array the actual EXE or DLL starts.</param>
            /// <param name="length">The length of the EXE or DLL bytes starting at the given offset in the array.</param>
            /// <param name="name">(optional) The name of the library we're loading (to be used when resolving other libraries).</param>
            /// <param name="loadFlags">(optional) Flags to control how this loading is performed.</param>
            /// <param name="otherLibraries">(optional) Any other HarmonyLibraries to use when resolving this library's imports.</param>
            /// <returns>A HarmonyLibrary instance.</returns>
            /// <throws cref="LoadFailedException">Thrown when the library cannot be loaded (if, for example, it is corrupt
            /// data, or if one of its imports cannot be resolved).  The exception message will provide details to explain
            /// why the library-load failed.</throws>
            public static HarmonyLibrary CreateFromBytes(byte[] rawDll, uint offset, uint length, string name = null,
                                                         HarmonyLoadFlags loadFlags = 0, IEnumerable <HarmonyLibrary> otherLibraries = null)
            {
                LibraryLoader  libraryLoader = new LibraryLoader(loadFlags, otherLibraries);
                HarmonyLibrary library       = libraryLoader.CreateLibrary(rawDll, offset, length, name);

                return(library);
            }