Skip to content

Commit a51a7d8

Browse files
committed
Implement a native TTY interface for Windows
Use the Kernel32 console APIs to directly read/write from the CONIN$ and CONOUT$ devices (the attached console, if available). Most of this code was ported from the GCM Windows project.
1 parent f4adac4 commit a51a7d8

File tree

7 files changed

+968
-57
lines changed

7 files changed

+968
-57
lines changed

src/shared/Microsoft.Git.CredentialManager/CommandContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private ITerminal CreateTerminal()
172172

173173
if (PlatformUtils.IsWindows())
174174
{
175-
throw new NotImplementedException();
175+
return new WindowsTerminal(Trace);
176176
}
177177

178178
throw new PlatformNotSupportedException();

src/shared/Microsoft.Git.CredentialManager/Interop/Windows/Native/Advapi32.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,27 @@ namespace Microsoft.Git.CredentialManager.Interop.Windows.Native
1111
// https://docs.microsoft.com/en-us/windows/desktop/api/wincred/
1212
public static class Advapi32
1313
{
14-
[DllImport("advapi32.dll", EntryPoint = "CredReadW", CharSet = CharSet.Unicode, SetLastError = true)]
14+
private const string LibraryName = "advapi32.dll";
15+
16+
[DllImport(LibraryName, EntryPoint = "CredReadW", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
1517
public static extern bool CredRead(
1618
string target,
1719
CredentialType type,
1820
int reserved,
1921
out IntPtr credential);
2022

21-
[DllImport("advapi32.dll", EntryPoint = "CredWriteW", CharSet = CharSet.Unicode, SetLastError = true)]
23+
[DllImport(LibraryName, EntryPoint = "CredWriteW", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
2224
public static extern bool CredWrite(
2325
ref Win32Credential credential,
2426
int flags);
2527

26-
[DllImport("advapi32.dll", EntryPoint = "CredDeleteW", CharSet = CharSet.Unicode, SetLastError = true)]
28+
[DllImport(LibraryName, EntryPoint = "CredDeleteW", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
2729
public static extern bool CredDelete(
2830
string target,
2931
CredentialType type,
3032
int flags);
3133

32-
[DllImport("advapi32.dll", EntryPoint = "CredFree", CharSet = CharSet.Unicode, SetLastError = true)]
34+
[DllImport(LibraryName, EntryPoint = "CredFree", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
3335
internal static extern void CredFree(
3436
IntPtr credential);
3537
}

src/shared/Microsoft.Git.CredentialManager/Interop/Windows/Native/Common.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)