public bool Apply() { if (!IsApplied) { using (MemoryOperation) { if (MemoryOperation.Apply()) { OriginalInstructions = MemoryEditor.ReadBytes(OriginalFunctionPtr, instructionLength); IsApplied = MemoryEditor.Write(OriginalFunctionPtr, DetourInstructions.ToArray()); } } } return(IsApplied); }
public bool WriteProtected <T>(IntPtr ptr, T value) where T : struct { using (var memoryOperation = new MemoryProtectionOperation(ptr, Marshal.SizeOf <T>())) { if (memoryOperation.Apply()) { return(Write(ptr, value)); } } return(false); }