Пример #1
0
        /// <summary>
        /// Contains the implementation of our NtCreateFile hook.
        /// Simply prints the file name to the console and calls + returns the original function.
        /// </summary>
        /// <returns></returns>
        private static int NtCreateFileImpl(out IntPtr filehandle, FileAccess access, ref OBJECT_ATTRIBUTES objectAttributes, ref IO_STATUS_BLOCK ioStatus, ref long allocSize, uint fileattributes, FileShare share, uint createDisposition, uint createOptions, IntPtr eaBuffer, uint eaLength)
        {
            Bindings.PrintInfo($"[NTCF] Loading File {objectAttributes.ObjectName.ToString()}");

            return(IntPtr.Size == 4 ?
                   _ntCreateFileHook.OriginalFunction(out filehandle, access, ref objectAttributes, ref ioStatus, ref allocSize, fileattributes, share, createDisposition, createOptions, eaBuffer, eaLength) :
                   _ntCreateFileHook64.OriginalFunction(out filehandle, access, ref objectAttributes, ref ioStatus, ref allocSize, fileattributes, share, createDisposition, createOptions, eaBuffer, eaLength));
        }
Пример #2
0
        /// <summary>
        /// Contains the implementation of the CreateFileW hook.
        /// Simply prints the file name to the console and calls + returns the original function.
        /// </summary>
        private static IntPtr CreateFileWImpl(string filename, FileAccess access, FileShare share, IntPtr securityAttributes, FileMode creationDisposition, FileAttributes flagsAndAttributes, IntPtr templateFile)
        {
            // This function delegate is automatically assigned by the Reloaded DLL Template Initializer
            // It simply prints to the console of the Mod Loader's Loader (which is a local server).
            // The if statement filters out non-files such as HID devices.
            if (!filename.StartsWith(@"\\?\"))
            {
                Bindings.PrintInfo($"[CFW] Loading File {filename}");
            }

            return(IntPtr.Size == 4 ?
                   _createFileWHook.OriginalFunction(filename, access, share, securityAttributes, creationDisposition, flagsAndAttributes, templateFile) :
                   _createFileWHook64.OriginalFunction(filename, access, share, securityAttributes, creationDisposition, flagsAndAttributes, templateFile));
        }