/* Copyright (c) 2009 McDowell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package console.win32; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; /** * JNA interface. * * This interface was designed and tested on Windows XP. All methods map to * WIN32 API functions. * * @author McDowell * @see #INSTANCE */ public interface Kernel32 extends Library { /** * Interface instance. Not thread safe. */ public static Kernel32 INSTANCE = (Kernel32) Native .loadLibrary("Kernel32", Kernel32.class); /** @see #ReadFile(Pointer, byte[], int, IntByReference, Pointer) */ public static int ERROR_HANDLE_EOF = 38; /** @see #GetStdHandle(int) */ public static int STD_INPUT_HANDLE = -10; /** @see #GetStdHandle(int) */ public static int STD_OUTPUT_HANDLE = -11; /** @see #GetStdHandle(int) */ public static int STD_ERROR_HANDLE = -12; /** * @see #FormatMessageW(int, Pointer, int, int, char[], int, Pointer) */ public static int FORMAT_MESSAGE_FROM_SYSTEM = 4096; /** * @see #FormatMessageW(int, Pointer, int, int, char[], int, Pointer) */ public static int FORMAT_MESSAGE_IGNORE_INSERTS = 512; /** * @see Kernel32#WideCharToMultiByte(int, int, char[], int, byte[], int, * Pointer, Pointer) */ public static int CP_ACP = 0; /** * GetStdHandle */ public Pointer GetStdHandle(int nStdHandle); /** * WriteConsoleW */ public boolean WriteConsoleW(Pointer hConsoleOutput, char[] lpBuffer, int nNumberOfCharsToWrite, IntByReference lpNumberOfCharsWritten, Pointer lpReserved); /** * WriteFile */ public boolean WriteFile(Pointer hFile, byte[] lpBuffer, int nNumberOfBytesToWrite, IntByReference lpNumberOfBytesWritten, Pointer lpOverlapped); /** * GetConsoleCP */ public int GetConsoleCP(); /** * SetConsoleCP */ public boolean SetConsoleCP(int wCodePageID); /** * GetConsoleOutputCP */ public int GetConsoleOutputCP(); /** * SetConsoleOutputCP */ public boolean SetConsoleOutputCP(int wCodePageID); /** * GetConsoleMode */ public boolean GetConsoleMode(Pointer hConsoleHandle, IntByReference lpMode); /** * MultiByteToWideChar */ public int MultiByteToWideChar(int CodePage, int dwFlags, byte[] lpMultiByteStr, int cbMultiByte, char[] lpWideCharStr, int cchWideChar); /** * WideCharToMultiByte */ public int WideCharToMultiByte(int CodePage, int dwFlags, char[] lpWideCharStr, int cchWideChar, byte[] lpMultiByteStr, int cbMultiByte, Pointer lpDefaultChar, Pointer lpUsedDefaultChar); /** * ReadConsoleW */ public boolean ReadConsoleW(Pointer hConsoleInput, char[] lpBuffer, int nNumberOfCharsToRead, IntByReference lpNumberOfCharsRead, Pointer pInputControl); /** * ReadFile */ public boolean ReadFile(Pointer hFile, byte[] lpBuffer, int nNumberOfBytesToRead, IntByReference lpNumberOfBytesRead, Pointer lpOverlapped); /** * GetLastError */ public int GetLastError(); /** * FormatMessage */ public int FormatMessageW(int dwFlags, Pointer lpSource, int dwMessageId, int dwLanguageId, char[] lpBuffer, int nSize, Pointer Arguments); }