How can disable redirection on win64

c#, redirect, win64

Solution

There are Win32 functions available that can disable and enable redirection.

[DllImport("kernel32.dll", SetLastError = true)]
static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);

[DllImport("kernel32.dll", SetLastError = true)]
static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);

Example:

IntPtr wow64Value = IntPtr.Zero;

// Disable redirection.
Wow64DisableWow64FsRedirection(ref wow64Value);

// Do whatever you need
// .....................

// Re-enable redirection.
Wow64RevertWow64FsRedirection(wow64Value);

Problem

I want to copy `c:\Windows\regedit.exe` to same directory with `regedit2.exe` name But when I try to copy it,I take an error which say `regedit.exe` file not found" or sometimes copy it to under `windows\SysWOW64` directory. And actually I knıow `win64` is redirecting it But how can I disable redirecting and copy windows/regedit.exe to windows/regedit2.exe. My sample code is ``` if(File.Exists(@"c:\Windows\regedit.exe")) try { File.Copy(@"c:\Windows\regedit.exe", @"c:\Windows\regedit2.exe", true); } catch (Exception ex){} ``` İs there any one who can help me

Original source