Implement cross-platform improvements from master

Contains fixes rebased from d2afe06 ... 9f4dcb6
This commit is contained in:
Bepis committed 2020-11-05 23:18:52 +11:00
1 parent 265f484447
commit 1c32115fa2
34 files changed
+1117 -257

No files matched your search

@@ -0,0 +1,51 @@
// --------------------------------------------------
// UnityInjector - ConsoleEncoding.PInvoke.cs
// Copyright (c) Usagirei 2015 - 2015
// --------------------------------------------------
using System;
using System.Runtime.InteropServices;
namespace UnityInjector.ConsoleUtil
{
// --------------------------------------------------
// Code ported from
// https://gist.github.com/asm256/9bfb88336a1433e2328a
// Which in turn was seemingly ported from
// http://jonskeet.uk/csharp/ebcdic/
// using only safe (managed) code
// --------------------------------------------------
internal partial class ConsoleEncoding
{
[DllImport("kernel32.dll")]
private static extern uint GetConsoleOutputCP();
[DllImport("kernel32.dll")]
private static extern uint GetACP();
[DllImport("kernel32.dll", SetLastError = true)]
private static extern int MultiByteToWideChar(
uint codePage,
uint dwFlags,
[In, MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr,
int cbMultiByte,
[Out, MarshalAs(UnmanagedType.LPWStr)]
char[] lpWideCharStr,
int cchWideChar);
[DllImport("kernel32.dll")]
private static extern IntPtr SetConsoleOutputCP(uint codepage);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern int WideCharToMultiByte(
uint codePage,
uint dwFlags,
[In, MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr,
int cchWideChar,
[Out, MarshalAs(UnmanagedType.LPArray)]
byte[] lpMultiByteStr,
int cbMultiByte,
IntPtr lpDefaultChar,
IntPtr lpUsedDefaultChar);
}
}