static NativeFile() { // Initialize all the DllImports at once, since we are going to use all of them anyway. ReadFile = (ReadFileDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.ReadFile()), typeof(ReadFileDelegate)); FlushFileBuffers = (FlushFileBuffersDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.FlushFileBuffers()), typeof(FlushFileBuffersDelegate)); WriteFile = (WriteFileDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.WriteFile()), typeof(WriteFileDelegate)); SetFilePointerEx = (SetFilePointerExDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.SetFilePointerEx()), typeof(SetFilePointerExDelegate)); SetEndOfFile = (SetEndOfFileDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.SetEndOfFile()), typeof(SetEndOfFileDelegate)); Create = (CreateDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.CreateFile2()), typeof(CreateDelegate)); GetFileInformationByHandleEx = (GetFileInformationByHandleExDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.GetFileInformationByHandleEx()), typeof(GetFileInformationByHandleExDelegate)); GetFileAttributesEx = (GetFileAttributesExDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.GetFileAttributesExW()), typeof(GetFileAttributesExDelegate)); }
protected DokanDefaultImplementation(CreateFileDelegate onCreateFile = null, OpenDirectoryDelegate onOpenDirectory = null, CreateDirectoryDelegate onCreateDirectory = null, CleanupDelegate onCleanup = null, CloseFileDelegate onCloseFile = null, ReadFileDelegate onReadFile = null, WriteFileDelegate onWriteFile = null, FlushFileBuffersDelegate onFlushFileBuffers = null, GetFileInformationDelegate onGetFileInformation = null, FindFilesDelegate onFindFiles = null, SetFileAttributesDelegate onSetFileAttributes = null, SetFileTimeDelegate onSetFileTime = null, DeleteFileDelegate onDeleteFile = null, DeleteDirectoryDelegate onDeleteDirectory = null, MoveFileDelegate onMoveFile = null, SetEndOfFileDelegate onSetEndOfFile = null, SetAllocationSizeDelegate onSetAllocationSize = null, LockFileDelegate onLockFile = null, UnlockFileDelegate onUnlockFile = null, GetDiskFreeSpaceDelegate onGetDiskFreeSpace = null, UnmountDelegate onUnmount = null) { OnCreateFile = onCreateFile; OnOpenDirectory = onOpenDirectory; OnCreateDirectory = onCreateDirectory; OnCleanup = onCleanup; OnCloseFile = onCloseFile; OnReadFile = onReadFile; OnWriteFile = onWriteFile; OnFlushFileBuffers = onFlushFileBuffers; OnGetFileInformation = onGetFileInformation; OnFindFiles = onFindFiles; OnSetFileAttributes = onSetFileAttributes; OnSetFileTime = onSetFileTime; OnDeleteFile = onDeleteFile; OnDeleteDirectory = onDeleteDirectory; OnMoveFile = onMoveFile; OnSetEndOfFile = onSetEndOfFile; OnSetAllocationSize = onSetAllocationSize; OnLockFile = onLockFile; OnUnlockFile = onUnlockFile; OnGetDiskFreeSpace = onGetDiskFreeSpace; OnUnmount = onUnmount; }
internal static void InitHookEngine(IntPtr contextHandle, uint dumpSizeLimit, int lsassPid, IntPtr lsassHandle) { hookEngine = new HookEngine(); dumpContexts[contextHandle] = new DumpContext(dumpSizeLimit); MiniDumpToMem.lsassPid = lsassPid; MiniDumpToMem.lsassHandle = lsassHandle; SetFilePointer_detour = new SetFilePointerDelegate(SetFilePointer); GetFileSize_detour = new GetFileSizeDelegate(GetFileSize); WriteFile_detour = new WriteFileDelegate(WriteFile); NtOpenProcess_detour = new NtOpenProcessDelegate(NtOpenProcess); NtOpenProcess_orig = hookEngine.CreateHook("ntdll.dll", "NtOpenProcess", NtOpenProcess_detour); SetFilePointer_orig = hookEngine.CreateHook("kernelbase.dll", "SetFilePointer", SetFilePointer_detour); GetFileSize_orig = hookEngine.CreateHook("kernelbase.dll", "GetFileSize", GetFileSize_detour); WriteFile_orig = hookEngine.CreateHook("kernelbase.dll", "WriteFile", WriteFile_detour); hookEngine.EnableHooks(); }
static public void writeFileOverrideInThread(string path, byte[] content, WriteFileDelegate callback) { Async main = Async.runInThread(delegate(Async thread) { try { File.writeFileOverride(path, content); thread.pushEvent("WroteFileOverride", true); } catch { thread.pushEvent("WroteFileOverride", false); } }); main.onEvent("WroteFileOverride", delegate(object datas) { bool success = (bool)datas; callback(success); }); }
public void setWriteFunction(WriteFileDelegate newFunction) { this.writeFileCurrentFunction = newFunction; }
static NativeFile() { // Initialize all the DllImports at once, since we are going to use all of them anyway. ReadFile = (ReadFileDelegate) Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.ReadFile()), typeof (ReadFileDelegate)); FlushFileBuffers = (FlushFileBuffersDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.FlushFileBuffers()), typeof(FlushFileBuffersDelegate)); WriteFile = (WriteFileDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.WriteFile()), typeof(WriteFileDelegate)); SetFilePointerEx = (SetFilePointerExDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.SetFilePointerEx()), typeof(SetFilePointerExDelegate)); SetEndOfFile = (SetEndOfFileDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.SetEndOfFile()), typeof(SetEndOfFileDelegate)); Create = (CreateDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.CreateFile2()), typeof(CreateDelegate)); GetFileInformationByHandleEx = (GetFileInformationByHandleExDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.GetFileInformationByHandleEx()), typeof(GetFileInformationByHandleExDelegate)); GetFileAttributesEx = (GetFileAttributesExDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(SharpDX.WP8.Interop.GetFileAttributesExW()), typeof(GetFileAttributesExDelegate)); }