From bb9a6bb420ca33197d4bfe81260b49ab1cb219eb Mon Sep 17 00:00:00 2001 From: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com> Date: Mon, 21 Jun 2021 18:48:37 +0200 Subject: [PATCH] Add InpOut source and license --- InpOut/InpOut32.Net/CSharpExample.cs | 274 ++++++++ InpOut/InstallDriver/InstallDriver.cpp | 35 + InpOut/InstallDriver/InstallDriver.h | 3 + InpOut/InstallDriver/InstallDriver.manifest | 13 + InpOut/InstallDriver/InstallDriver.rc | 113 ++++ InpOut/InstallDriver/InstallDriver.vcproj | 254 +++++++ InpOut/InstallDriver/ReadMe.txt | 46 ++ InpOut/InstallDriver/Resource.h | 17 + InpOut/InstallDriver/stdafx.cpp | 8 + InpOut/InstallDriver/stdafx.h | 27 + InpOut/ReadMe.txt | 24 + InpOut/StdAfx.cpp | 8 + InpOut/StdAfx.h | 39 ++ InpOut/hwinterfacedrv.h | 29 + InpOut/inpout32.h | 32 + InpOut/inpout32.sys | Bin 0 -> 11936 bytes InpOut/inpout32drv.cpp | 691 ++++++++++++++++++++ InpOut/inpout32drv.def | 18 + InpOut/inpout32drv.rc | 125 ++++ InpOut/inpout32drv.sln | 100 +++ InpOut/inpout32drv.vcproj | 621 ++++++++++++++++++ InpOut/inpoutx64.sys | Bin 0 -> 15008 bytes InpOut/license.txt | 24 + InpOut/osversion.cpp | 78 +++ InpOut/resource.h | 18 + Licenses/License.html | 33 +- 26 files changed, 2614 insertions(+), 16 deletions(-) create mode 100644 InpOut/InpOut32.Net/CSharpExample.cs create mode 100644 InpOut/InstallDriver/InstallDriver.cpp create mode 100644 InpOut/InstallDriver/InstallDriver.h create mode 100644 InpOut/InstallDriver/InstallDriver.manifest create mode 100644 InpOut/InstallDriver/InstallDriver.rc create mode 100644 InpOut/InstallDriver/InstallDriver.vcproj create mode 100644 InpOut/InstallDriver/ReadMe.txt create mode 100644 InpOut/InstallDriver/Resource.h create mode 100644 InpOut/InstallDriver/stdafx.cpp create mode 100644 InpOut/InstallDriver/stdafx.h create mode 100644 InpOut/ReadMe.txt create mode 100644 InpOut/StdAfx.cpp create mode 100644 InpOut/StdAfx.h create mode 100644 InpOut/hwinterfacedrv.h create mode 100644 InpOut/inpout32.h create mode 100644 InpOut/inpout32.sys create mode 100644 InpOut/inpout32drv.cpp create mode 100644 InpOut/inpout32drv.def create mode 100644 InpOut/inpout32drv.rc create mode 100644 InpOut/inpout32drv.sln create mode 100644 InpOut/inpout32drv.vcproj create mode 100644 InpOut/inpoutx64.sys create mode 100644 InpOut/license.txt create mode 100644 InpOut/osversion.cpp create mode 100644 InpOut/resource.h diff --git a/InpOut/InpOut32.Net/CSharpExample.cs b/InpOut/InpOut32.Net/CSharpExample.cs new file mode 100644 index 0000000..28b4ff2 --- /dev/null +++ b/InpOut/InpOut32.Net/CSharpExample.cs @@ -0,0 +1,274 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using System.Runtime.InteropServices; + +namespace InpOut32.Net +{ + public partial class CSharpExample : Form + { + + [DllImport("inpout32.dll")] + private static extern UInt32 IsInpOutDriverOpen(); + [DllImport("inpout32.dll")] + private static extern void Out32(short PortAddress, short Data); + [DllImport("inpout32.dll")] + private static extern char Inp32(short PortAddress); + + [DllImport("inpout32.dll")] + private static extern void DlPortWritePortUshort(short PortAddress, ushort Data); + [DllImport("inpout32.dll")] + private static extern ushort DlPortReadPortUshort(short PortAddress); + + [DllImport("inpout32.dll")] + private static extern void DlPortWritePortUlong(int PortAddress, uint Data); + [DllImport("inpout32.dll")] + private static extern uint DlPortReadPortUlong(int PortAddress); + + [DllImport("inpoutx64.dll")] + private static extern bool GetPhysLong(ref int PortAddress, ref uint Data); + [DllImport("inpoutx64.dll")] + private static extern bool SetPhysLong(ref int PortAddress, ref uint Data); + + + [DllImport("inpoutx64.dll", EntryPoint="IsInpOutDriverOpen")] + private static extern UInt32 IsInpOutDriverOpen_x64(); + [DllImport("inpoutx64.dll", EntryPoint = "Out32")] + private static extern void Out32_x64(short PortAddress, short Data); + [DllImport("inpoutx64.dll", EntryPoint = "Inp32")] + private static extern char Inp32_x64(short PortAddress); + + [DllImport("inpoutx64.dll", EntryPoint = "DlPortWritePortUshort")] + private static extern void DlPortWritePortUshort_x64(short PortAddress, ushort Data); + [DllImport("inpoutx64.dll", EntryPoint = "DlPortReadPortUshort")] + private static extern ushort DlPortReadPortUshort_x64(short PortAddress); + + [DllImport("inpoutx64.dll", EntryPoint = "DlPortWritePortUlong")] + private static extern void DlPortWritePortUlong_x64(int PortAddress, uint Data); + [DllImport("inpoutx64.dll", EntryPoint = "DlPortReadPortUlong")] + private static extern uint DlPortReadPortUlong_x64(int PortAddress); + + [DllImport("inpoutx64.dll", EntryPoint = "GetPhysLong")] + private static extern bool GetPhysLong_x64(ref int PortAddress, ref uint Data); + [DllImport("inpoutx64.dll", EntryPoint = "SetPhysLong")] + private static extern bool SetPhysLong_x64(ref int PortAddress, ref uint Data); + + + bool m_bX64 = false; + + public CSharpExample() + { + InitializeComponent(); + try + { + uint nResult = 0; + try + { + nResult = IsInpOutDriverOpen(); + } + catch (BadImageFormatException) + { + nResult = IsInpOutDriverOpen_x64(); + if (nResult != 0) + m_bX64 = true; + + } + + if (nResult == 0) + { + lblMessage.Text = "Unable to open InpOut32 driver"; + button1.Enabled = false; + button2.Enabled = false; + button3.Enabled = false; + button4.Enabled = false; + button5.Enabled = false; + button6.Enabled = false; + button7.Enabled = false; + } + } + catch (DllNotFoundException ex) + { + System.Diagnostics.Debug.WriteLine(ex.ToString()); + lblMessage.Text = "Unable to find InpOut32.dll"; + button1.Enabled = false; + button2.Enabled = false; + button3.Enabled = false; + button4.Enabled = false; + button5.Enabled = false; + button6.Enabled = false; + button7.Enabled = false; + } + } + + private void button1_Click(object sender, EventArgs e) + { + try + { + short iPort = Convert.ToInt16(textBox1.Text); + + char c; + if (m_bX64) + c = Inp32_x64(iPort); + else + c = Inp32(iPort); + + textBox2.Text = Convert.ToInt32(c).ToString(); + } + catch (Exception ex) + { + MessageBox.Show("An error occured:\n" + ex.Message); + } + } + + private void button2_Click(object sender, EventArgs e) + { + try + { + short iPort = Convert.ToInt16(textBox1.Text); + short iData = Convert.ToInt16(textBox2.Text); + textBox2.Text = ""; + if (m_bX64) + Out32_x64(iPort, iData); + else + Out32(iPort, iData); + + + } + catch (Exception ex) + { + MessageBox.Show("An error occured:\n" + ex.Message); + } + } + + private void button3_Click(object sender, EventArgs e) + { + try + { + short iPort = Convert.ToInt16(textBox1.Text); + ushort s; + if (m_bX64) + s = DlPortReadPortUshort_x64(iPort); + else + s = DlPortReadPortUshort(iPort); + + textBox2.Text = Convert.ToUInt16(s).ToString(); + } + catch (Exception ex) + { + MessageBox.Show("An error occured:\n" + ex.Message); + } + } + + private void button4_Click(object sender, EventArgs e) + { + try + { + int nPort = Convert.ToInt32(textBox1.Text); + + uint l; + if (m_bX64) + l = DlPortReadPortUlong_x64(nPort); + else + l = DlPortReadPortUlong(nPort); + + textBox2.Text = l.ToString(); + } + catch (Exception ex) + { + MessageBox.Show("An error occured:\n" + ex.Message); + } + } + + private void button5_Click(object sender, EventArgs e) + { + try + { + short sPort = Convert.ToInt16(textBox1.Text); + ushort iData = Convert.ToUInt16(textBox2.Text); + textBox2.Text = ""; + + if (m_bX64) + DlPortWritePortUshort_x64(sPort, iData); + else + DlPortWritePortUshort(sPort, iData); + } + catch (Exception ex) + { + MessageBox.Show("An error occured:\n" + ex.Message); + } + } + + private void button6_Click(object sender, EventArgs e) + { + try + { + int nPort = Convert.ToInt32(textBox1.Text); + uint nData = Convert.ToUInt32(textBox2.Text); + textBox2.Text = ""; + if (m_bX64) + DlPortWritePortUlong_x64(nPort, nData); + else + DlPortWritePortUlong(nPort, nData); + } + catch (Exception ex) + { + MessageBox.Show("An error occured:\n" + ex.Message); + } + } + + private void Beep(uint freq) + { + if (m_bX64) + { + Out32_x64(0x43, 0xB6); + Out32_x64(0x42, (byte)(freq & 0xFF)); + Out32_x64(0x42, (byte)(freq >> 9)); + System.Threading.Thread.Sleep(10); + Out32_x64(0x61, (byte)(Convert.ToByte(Inp32_x64(0x61)) | 0x03)); + } + else + { + Out32(0x43, 0xB6); + Out32(0x42, (byte)(freq & 0xFF)); + Out32(0x42, (byte)(freq >> 9)); + System.Threading.Thread.Sleep(10); + Out32(0x61, (byte)(Convert.ToByte(Inp32(0x61)) | 0x03)); + } + } + + private void StopBeep() + { + if (m_bX64) + Out32_x64(0x61, (byte)(Convert.ToByte(Inp32_x64(0x61)) & 0xFC)); + else + Out32(0x61, (byte)(Convert.ToByte(Inp32(0x61)) & 0xFC)); + } + + private void CSharpExample_Load(object sender, EventArgs e) + { + button7_Click(this, null); + } + + + private void ThreadBeeper() + { + for (uint i = 440000; i < 500000; i += 1000) + { + uint freq = 1193180000 / i; // 440Hz + Beep(freq); + } + StopBeep(); + } + + private void button7_Click(object sender, EventArgs e) + { + System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadBeeper)); + t.Start(); + } + } +} \ No newline at end of file diff --git a/InpOut/InstallDriver/InstallDriver.cpp b/InpOut/InstallDriver/InstallDriver.cpp new file mode 100644 index 0000000..142571c --- /dev/null +++ b/InpOut/InstallDriver/InstallDriver.cpp @@ -0,0 +1,35 @@ +// InstallDriver.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" +#include "InstallDriver.h" +#include "..\inpout32.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// The one and only application object +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + int nRetCode = 0; + BOOL bResult = IsInpOutDriverOpen(); + + if (IsXP64Bit()) + { + if (bResult) + MessageBox(NULL, _T("Successfully installed and opened\n64bit InpOut driver InpOutx64.sys."), _T("InpOut Installation"), 0); + else + MessageBox(NULL, _T("Unable to install or open the\n64bit InpOut driver InpOutx64.sys.\n\nPlease try running as Administrator"), _T("InpOut Installation"), 0); + } + else + { + if (bResult) + MessageBox(NULL, _T("Successfully installed and opened\n32bit InpOut driver InpOut32.sys."), _T("InpOut Installation"), 0); + else + MessageBox(NULL, _T("Unable to install or open the\n32bit InpOut driver InpOut32.sys.\n\nPlease try running as Administrator"), _T("InpOut Installation"), 0); + } + return nRetCode; +} diff --git a/InpOut/InstallDriver/InstallDriver.h b/InpOut/InstallDriver/InstallDriver.h new file mode 100644 index 0000000..d00d47e --- /dev/null +++ b/InpOut/InstallDriver/InstallDriver.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/InpOut/InstallDriver/InstallDriver.manifest b/InpOut/InstallDriver/InstallDriver.manifest new file mode 100644 index 0000000..c4b6440 --- /dev/null +++ b/InpOut/InstallDriver/InstallDriver.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/InpOut/InstallDriver/InstallDriver.rc b/InpOut/InstallDriver/InstallDriver.rc new file mode 100644 index 0000000..21ebcee --- /dev/null +++ b/InpOut/InstallDriver/InstallDriver.rc @@ -0,0 +1,113 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.K.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,4,0,0 + PRODUCTVERSION 1,4,0,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "CompanyName", "Highresolution Enterprises" + VALUE "FileDescription", "InstallDriver Windows Vista/7 support application" + VALUE "FileVersion", "1, 4, 0, 0" + VALUE "InternalName", "InstallDriver" + VALUE "LegalCopyright", "Copyright (C) 2007-2011 Highresolution Enterprises" + VALUE "OriginalFilename", "InstallDriver.exe" + VALUE "ProductName", "InstallDriver Application" + VALUE "ProductVersion", "1, 4, 0, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_APP_TITLE "InstallDriver" +END + +#endif // English (U.K.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/InpOut/InstallDriver/InstallDriver.vcproj b/InpOut/InstallDriver/InstallDriver.vcproj new file mode 100644 index 0000000..4990c69 --- /dev/null +++ b/InpOut/InstallDriver/InstallDriver.vcproj @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InpOut/InstallDriver/ReadMe.txt b/InpOut/InstallDriver/ReadMe.txt new file mode 100644 index 0000000..d6dc61e --- /dev/null +++ b/InpOut/InstallDriver/ReadMe.txt @@ -0,0 +1,46 @@ +======================================================================== + CONSOLE APPLICATION : InstallDriver Project Overview +======================================================================== + +AppWizard has created this InstallDriver application for you. + +This file contains a summary of what you will find in each of the files that +make up your InstallDriver application. + + +InstallDriver.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +InstallDriver.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +AppWizard has created the following resources: + +InstallDriver.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named InstallDriver.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/InpOut/InstallDriver/Resource.h b/InpOut/InstallDriver/Resource.h new file mode 100644 index 0000000..0d098f8 --- /dev/null +++ b/InpOut/InstallDriver/Resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by InstallDriver.rc +// +#define IDR_MANIFEST 1 +#define IDS_APP_TITLE 103 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/InpOut/InstallDriver/stdafx.cpp b/InpOut/InstallDriver/stdafx.cpp new file mode 100644 index 0000000..ceedb5d --- /dev/null +++ b/InpOut/InstallDriver/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// InstallDriver.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/InpOut/InstallDriver/stdafx.h b/InpOut/InstallDriver/stdafx.h new file mode 100644 index 0000000..42732dc --- /dev/null +++ b/InpOut/InstallDriver/stdafx.h @@ -0,0 +1,27 @@ +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows XP or later. +#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. +#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. +#endif + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + +// C RunTime Header Files +#include +#include +#include +#include \ No newline at end of file diff --git a/InpOut/ReadMe.txt b/InpOut/ReadMe.txt new file mode 100644 index 0000000..c6e0f8d --- /dev/null +++ b/InpOut/ReadMe.txt @@ -0,0 +1,24 @@ +InpOut32Drv Driver Interface DLL +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Modified for x64 compatibility and built by Phillip Gibbons (Phil@highrez.co.uk). +See http://www.highrez.co.uk/Downloads/InpOut32 or the Highrez Forums (http://forums.highrez.co.uk) for information. +Many thanks to Red Fox UK for supporting the community and providing Driver signatures allowing Vista/7 x64 compatibility. + + + +Based on the original written by Logix4U (www.logix4u.net). + + +Notes: + + The InpOut32 device driver supports writing to "old fashioned" hardware port addresses. + It does NOT support USB devices such as USB Parallel ports or even PCI parallel ports (as I am lead to believe). + + + The device driver is installed at runtime. To do this however needs administrator privileges. + On Vista & later, using UAC, you can run the InstallDriver.exe in the \Win32 folder to install the driver + appropriate for your OS. Doing so will request elevation and ask for your permission (or for the administrator + password). Once the driver is installed for the first time, it can then be used by any user *without* + administrator privileges + diff --git a/InpOut/StdAfx.cpp b/InpOut/StdAfx.cpp new file mode 100644 index 0000000..6b6294f --- /dev/null +++ b/InpOut/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// inpout32drv.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/InpOut/StdAfx.h b/InpOut/StdAfx.h new file mode 100644 index 0000000..92e3273 --- /dev/null +++ b/InpOut/StdAfx.h @@ -0,0 +1,39 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__7ACF5BF3_42A3_43EB_9034_6218487B5231__INCLUDED_) +#define AFX_STDAFX_H__7ACF5BF3_42A3_43EB_9034_6218487B5231__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +#ifndef WINVER +#define WINVER 0x0400 +#endif + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif + +#ifndef _WIN32_WINDOWS +#define _WIN32_WINDOWS 0x0410 +#endif + +#ifndef _WIN32_IE +#define _WIN32_IE 0x0600 +#endif + +#define WIN32_LEAN_AND_MEAN +#include +#include + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__7ACF5BF3_42A3_43EB_9034_6218487B5231__INCLUDED_) diff --git a/InpOut/hwinterfacedrv.h b/InpOut/hwinterfacedrv.h new file mode 100644 index 0000000..9fd4043 --- /dev/null +++ b/InpOut/hwinterfacedrv.h @@ -0,0 +1,29 @@ + +#define IOCTL_READ_PORT_UCHAR -1673519100 //CTL_CODE(40000, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_WRITE_PORT_UCHAR -1673519096 //CTL_CODE(40000, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_READ_PORT_USHORT -1673519092 //CTL_CODE(40000, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_WRITE_PORT_USHORT -1673519088 //CTL_CODE(40000, 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_READ_PORT_ULONG -1673519084 //CTL_CODE(40000, 0x805, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_WRITE_PORT_ULONG -1673519080 //CTL_CODE(40000, 0x806, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_WINIO_MAPPHYSTOLIN -1673519076 +#define IOCTL_WINIO_UNMAPPHYSADDR -1673519072 + +BOOL _stdcall IsXP64Bit(); +int SystemVersion(); +BOOL DisableWOW64(PVOID* oldValue); +BOOL RevertWOW64(PVOID* oldValue); + +#pragma pack(push) +#pragma pack(1) + +struct tagPhys32Struct +{ + HANDLE PhysicalMemoryHandle; + SIZE_T dwPhysMemSizeInBytes; + PVOID pvPhysAddress; + PVOID pvPhysMemLin; +}; + +extern struct tagPhys32Struct Phys32Struct; + +#pragma pack(pop) \ No newline at end of file diff --git a/InpOut/inpout32.h b/InpOut/inpout32.h new file mode 100644 index 0000000..65df096 --- /dev/null +++ b/InpOut/inpout32.h @@ -0,0 +1,32 @@ +#pragma once + +//Functions exported from DLL. +//For easy inclusion is user projects. +//Original InpOut32 function support +void _stdcall Out32(short PortAddress, short data); +short _stdcall Inp32(short PortAddress); + +//My extra functions for making life easy +BOOL _stdcall IsInpOutDriverOpen(); //Returns TRUE if the InpOut driver was opened successfully +BOOL _stdcall IsXP64Bit(); //Returns TRUE if the OS is 64bit (x64) Windows. + +//DLLPortIO function support +UCHAR _stdcall DlPortReadPortUchar (USHORT port); +void _stdcall DlPortWritePortUchar(USHORT port, UCHAR Value); + +USHORT _stdcall DlPortReadPortUshort (USHORT port); +void _stdcall DlPortWritePortUshort(USHORT port, USHORT Value); + +ULONG _stdcall DlPortReadPortUlong(ULONG port); +void _stdcall DlPortWritePortUlong(ULONG port, ULONG Value); + +//WinIO function support (Untested and probably does NOT work - esp. on x64!) +PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle); +BOOL _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr); +BOOL _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal); +BOOL _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal); + + + + + diff --git a/InpOut/inpout32.sys b/InpOut/inpout32.sys new file mode 100644 index 0000000000000000000000000000000000000000..0f68c5e6ca488b7433e14b6b6090790d9e1569bd GIT binary patch literal 11936 zcmeHt30PCfvT$bs!j1xpiVzhA7s3f)6&b-00cDf0D1sP5fCwa*MQ}kOC=w$&jN>|v zqN3wA=#1i3TtHk<+#NS`T*tYhFpB%em{)y50G)Z>`R;$`f8YDQ*P&0JuCA`GuCA)C z?n8LOmxzWCqC?hd5!wqSP66ce^N;aVge)AZEzoY`GyV2b!p`)I$q>t#IWlRwOpwhK z3M3M#f|(*>%9IkOSi%g7C1It_G3Kv`gckPo1C zB%o8?8*0`FB|MTW4f+DlyMQvgCILL)+BaJ>X6D*s8_EL|7%K(H%v1FnwDIhMy0FV{QA1=G30Kn@~{eO7XXk#@knsBosfjue` z*dh0eTH7cS3gXlz)iGe5f{+x+;VDAXkQfP}lmk?ZBq#@3lt_U%$Q{N%O(v3BQH#$y zx+w+mHA#%P_$ek64pq=8s5Jll^Nng=TPg2+R4MO7RN6+ZZ2$~}-?g?u@TQg1wYDMf zq6u$Ho;0y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BU)?4*p`AVUXu`<)<{`Yw z%_$Sz&`RHJyOZTd7%c_e76)4_9%9YCTV|LNyI))Fzh#U6Aj`^z{1lCCtoq8=9^qF+ zY!$5uhk;ZIg(y7vzckFFTKyq>?Yv(vFMJLmoBkf&n8r5ivPsgxO?PgYrfdtiK<%vC z5(7Fr(%Epnn7L}hgt@9kLDDB*Y`MnqUzBhvaUW6mRhK?y?7|{Aag;|Cgnj0VArra6 z*DCy#CI_zb_5W>$zxzqxJJQE3dB_WStYZ}nYxe>8fSn;u&ya~`fCpeHGu=|9xsoiY zAXVwcAkNwN0&dHTCy%N_^kE0;j`}yTERvG zA3I#8%B_;;ryTa(w{n*I9E$krvq@*iT+X$0n%l$Wa$CO#jWcJoEgw}gVEq))spSJ% zHP@evZ(eJ;^D9Ze^AUXomx;hK&)D@P_ft3Xf7is0eAxTd)#q=QoH&v4Ugoq;MS<@h zlo_28HDs$OnE*=1%9sAPd~5iVFC1ou4Ba;wDqJR&Pk>`(7u_)Js2EW|H9A@h*p|AJ z1lxxo*k1T6g=1$co!y;oHT|ngjupEmWzSw&)o3tv_{%@8Kt$pN=EgI9i+b*iMj8(j zPmP_y*8DWu%mwEv=bL!`_UhLkR!S!wTYlPg!}3_I>Dq?30jq1JKW3YZcot|Kk^d^B z+I7W?mwA_CU%38saqA$(+{@nz@5P`C-~N6}Yr7#hzS(2kxE5inWzII1#rt%xvDWLJ XI}~a*E$MaMD5towfjhbVi`Rbv%yAAu literal 0 HcmV?d00001 diff --git a/InpOut/inpout32drv.cpp b/InpOut/inpout32drv.cpp new file mode 100644 index 0000000..bdbc248 --- /dev/null +++ b/InpOut/inpout32drv.cpp @@ -0,0 +1,691 @@ +/***********************************************************************\ +* * +* InpOut32drv.cpp * +* * +* The entry point for the InpOut DLL * +* Provides the 32 and 64bit implementation of InpOut32 DLL to install * +* and call the appropriate driver and write directly to hardware ports. * +* * +* Written by Phillip Gibbons (Highrez.co.uk) * +* Based on orriginal, written by Logix4U (www.logix4u.net) * +* * +\***********************************************************************/ + +#include "stdafx.h" +#include +#include +#include + +#include "hwinterfacedrv.h" +#include "resource.h" + +int inst32(); +int inst64(); +int start(LPCTSTR pszDriver); + +//First, lets set the DRIVERNAME depending on our configuraiton. +#define DRIVERNAMEx64 _T("inpoutx64\0") +#define DRIVERNAMEi386 _T("inpout32\0") + +char str[10]; +int vv; + +HANDLE hdriver=NULL; +TCHAR path[MAX_PATH]; +HINSTANCE hmodule; +SECURITY_ATTRIBUTES sa; +int sysver; + +int Opendriver(BOOL bX64); +void Closedriver(void); + +BOOL APIENTRY DllMain( HINSTANCE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + hmodule = hModule; + BOOL bx64 = IsXP64Bit(); + switch(ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + { + sysver = SystemVersion(); + if(sysver==2) + { + Opendriver(bx64); + } + } + + break; + case DLL_PROCESS_DETACH: + { + if(sysver==2) + { + Closedriver(); + } + } + break; + } + return TRUE; +} + +/***********************************************************************/ + +void Closedriver(void) +{ + if (hdriver) + { + OutputDebugString(_T("Closing InpOut driver...\n")); + CloseHandle(hdriver); + hdriver=NULL; + } +} + +void _stdcall Out32(short PortAddress, short data) +{ + { + switch(sysver) + { + case 1: +#ifdef _M_IX86 + _outp( PortAddress,data); //Will ONLY compile on i386 architecture +#endif + break; + case 2: + unsigned int error; + DWORD BytesReturned; + BYTE Buffer[3]={NULL}; + unsigned short* pBuffer; + pBuffer = (unsigned short *)&Buffer[0]; + *pBuffer = LOWORD(PortAddress); + Buffer[2] = LOBYTE(data); + + error = DeviceIoControl(hdriver, + IOCTL_WRITE_PORT_UCHAR, + &Buffer, + 3, + NULL, + 0, + &BytesReturned, + NULL); + break; + } + } +} + +/*********************************************************************/ + +short _stdcall Inp32(short PortAddress) +{ + { + BYTE retval(0); + switch(sysver) + { + case 1: +#ifdef _M_IX86 + retval = _inp(PortAddress); +#endif + return retval; + break; + case 2: + unsigned int error; + DWORD BytesReturned; + unsigned char Buffer[3]={NULL}; + unsigned short * pBuffer; + pBuffer = (unsigned short *)&Buffer; + *pBuffer = LOWORD(PortAddress); + Buffer[2] = 0; + error = DeviceIoControl(hdriver, + IOCTL_READ_PORT_UCHAR, + &Buffer, + 2, + &Buffer, + 1, + &BytesReturned, + NULL); + + if (error==0) + { + DWORD dwError = GetLastError(); + TCHAR tszError[255]; + _stprintf_s(tszError, 255, _T("Error %d\n"), dwError); + OutputDebugString(tszError); + } + + //Do this to ensure only the first byte is returned, we dont really want to return a short as were only reading a byte. + //but we also dont want to change the InpOut interface! + UCHAR ucRes = (UCHAR)Buffer[0]; + return ucRes; + + break; + } + } + return 0; +} + +/*********************************************************************/ + +int Opendriver(BOOL bX64) +{ + OutputDebugString(_T("Attempting to open InpOut driver...\n")); + TCHAR szFileName[MAX_PATH] = {NULL}; + _stprintf_s(szFileName, MAX_PATH, _T("\\\\.\\%s"), bX64 ? DRIVERNAMEx64 : DRIVERNAMEi386); + + hdriver = CreateFile(szFileName, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if(hdriver == INVALID_HANDLE_VALUE) + { + if(start(bX64 ? DRIVERNAMEx64 : DRIVERNAMEi386)) + { + if (bX64) + inst64(); //Install the x64 driver + else + inst32(); //Install the i386 driver + + int nResult = start(bX64 ? DRIVERNAMEx64 : DRIVERNAMEi386); + + if (nResult == ERROR_SUCCESS) + { + hdriver = CreateFile(szFileName, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if(hdriver != INVALID_HANDLE_VALUE) + { + OutputDebugString(_T("Successfully opened ")); + OutputDebugString(bX64 ? DRIVERNAMEx64 : DRIVERNAMEi386); + OutputDebugString(_T(" driver\n")); + return 0; + } + } + else + { + TCHAR szMsg[MAX_PATH] = {NULL}; + _stprintf_s(szMsg, MAX_PATH, _T("Unable to open %s driver. Error code %d.\n"), bX64 ? DRIVERNAMEx64 : DRIVERNAMEi386, nResult); + OutputDebugString(szMsg); + + //RemoveDriver(); + } + } + return 1; + } + OutputDebugString(_T("Successfully opened ")); + OutputDebugString(bX64 ? DRIVERNAMEx64 : DRIVERNAMEi386); + OutputDebugString(_T(" driver\n")); + return 0; +} + +/***********************************************************************/ +int inst32() +{ + TCHAR szDriverSys[MAX_PATH]; + _tcscpy_s(szDriverSys, MAX_PATH, DRIVERNAMEi386); + _tcscat_s(szDriverSys, MAX_PATH, _T(".sys\0")); + + SC_HANDLE Mgr; + SC_HANDLE Ser; + GetSystemDirectory(path, MAX_PATH); + HRSRC hResource = FindResource(hmodule, MAKEINTRESOURCE(IDR_INPOUT32), _T("bin")); + if(hResource) + { + HGLOBAL binGlob = LoadResource(hmodule, hResource); + + if(binGlob) + { + void *binData = LockResource(binGlob); + + if(binData) + { + HANDLE file; + + _tcscat_s(path, sizeof(path), _T("\\Drivers\\")); + _tcscat_s(path, sizeof(path), szDriverSys); + + file = CreateFile(path, + GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + 0, + NULL); + + if (file && file != INVALID_HANDLE_VALUE) + { + DWORD size, written; + size = SizeofResource(hmodule, hResource); + WriteFile(file, binData, size, &written, NULL); + CloseHandle(file); + } + else + { + //Error + } + } + } + } + + Mgr = OpenSCManager (NULL, NULL,SC_MANAGER_ALL_ACCESS); + if (Mgr == NULL) + { //No permission to create service + if (GetLastError() == ERROR_ACCESS_DENIED) + { + return 5; // error access denied + } + } + else + { + TCHAR szFullPath[MAX_PATH] = _T("System32\\Drivers\\\0"); + _tcscat_s(szFullPath, MAX_PATH, szDriverSys); + Ser = CreateService (Mgr, + DRIVERNAMEi386, + DRIVERNAMEi386, + SERVICE_ALL_ACCESS, + SERVICE_KERNEL_DRIVER, + SERVICE_AUTO_START, + SERVICE_ERROR_NORMAL, + szFullPath, + NULL, + NULL, + NULL, + NULL, + NULL + ); + } + CloseServiceHandle(Ser); + CloseServiceHandle(Mgr); + + return 0; +} + +int inst64() +{ + TCHAR szDriverSys[MAX_PATH]; + _tcscpy_s(szDriverSys, MAX_PATH, DRIVERNAMEx64); + _tcscat_s(szDriverSys, MAX_PATH, _T(".sys\0")); + + SC_HANDLE Mgr; + SC_HANDLE Ser; + GetSystemDirectory(path, MAX_PATH); + HRSRC hResource = FindResource(hmodule, MAKEINTRESOURCE(IDR_INPOUTX64), _T("bin")); + if(hResource) + { + HGLOBAL binGlob = LoadResource(hmodule, hResource); + + if(binGlob) + { + void *binData = LockResource(binGlob); + + if(binData) + { + HANDLE file; + _tcscat_s(path, sizeof(path), _T("\\Drivers\\")); + _tcscat_s(path, sizeof(path), szDriverSys); + + PVOID OldValue; + DisableWOW64(&OldValue); + file = CreateFile(path, + GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + 0, + NULL); + + if(file && file != INVALID_HANDLE_VALUE) + { + DWORD size, written; + + size = SizeofResource(hmodule, hResource); + WriteFile(file, binData, size, &written, NULL); + CloseHandle(file); + } + else + { + //error + } + RevertWOW64(&OldValue); + } + } + } + + Mgr = OpenSCManager (NULL, NULL,SC_MANAGER_ALL_ACCESS); + if (Mgr == NULL) + { //No permission to create service + if (GetLastError() == ERROR_ACCESS_DENIED) + { + return 5; // error access denied + } + } + else + { + TCHAR szFullPath[MAX_PATH] = _T("System32\\Drivers\\\0"); + _tcscat_s(szFullPath, MAX_PATH, szDriverSys); + Ser = CreateService (Mgr, + DRIVERNAMEx64, + DRIVERNAMEx64, + SERVICE_ALL_ACCESS, + SERVICE_KERNEL_DRIVER, + SERVICE_AUTO_START, + SERVICE_ERROR_NORMAL, + szFullPath, + NULL, + NULL, + NULL, + NULL, + NULL + ); + } + CloseServiceHandle(Ser); + CloseServiceHandle(Mgr); + + return 0; +} + +/**************************************************************************/ +int start(LPCTSTR pszDriver) +{ + SC_HANDLE Mgr; + SC_HANDLE Ser; + + Mgr = OpenSCManager (NULL, NULL,SC_MANAGER_ALL_ACCESS); + + if (Mgr == NULL) + { //No permission to create service + if (GetLastError() == ERROR_ACCESS_DENIED) + { + Mgr = OpenSCManager (NULL, NULL, GENERIC_READ); + Ser = OpenService(Mgr, pszDriver, GENERIC_EXECUTE); + if (Ser) + { // we have permission to start the service + if(!StartService(Ser,0,NULL)) + { + CloseServiceHandle (Ser); + return 4; // we could open the service but unable to start + } + } + } + } + else + {// Successfuly opened Service Manager with full access + Ser = OpenService(Mgr, pszDriver, SERVICE_ALL_ACCESS); + if (Ser) + { + if(!StartService(Ser,0,NULL)) + { + CloseServiceHandle (Ser); + return 3; // opened the Service handle with full access permission, but unable to start + } + else + { + CloseServiceHandle (Ser); + return 0; + } + } + } + return 1; +} + +BOOL _stdcall IsInpOutDriverOpen() +{ + sysver = SystemVersion(); + if (sysver==2) + { + if (hdriver!=INVALID_HANDLE_VALUE && hdriver != NULL) + return TRUE; + } + else if (sysver==1) + { + return TRUE; + } + return FALSE; +} + +UCHAR _stdcall DlPortReadPortUchar (USHORT port) +{ + UCHAR retval(0); + switch(sysver) + { + case 1: +#ifdef _M_IX86 + retval = _inp((USHORT)port); +#endif + return retval; + break; + case 2: + unsigned int error; + DWORD BytesReturned; + BYTE Buffer[3]={NULL}; + unsigned short * pBuffer; + pBuffer = (unsigned short *)&Buffer; + *pBuffer = port; + Buffer[2] = 0; + error = DeviceIoControl(hdriver, + IOCTL_READ_PORT_UCHAR, + &Buffer, + sizeof(Buffer), + &Buffer, + sizeof(Buffer), + &BytesReturned, + NULL); + + return((UCHAR)Buffer[0]); + + break; + } + return 0; +} + +void _stdcall DlPortWritePortUchar (USHORT port, UCHAR Value) +{ + switch(sysver) + { + case 1: +#ifdef _M_IX86 + _outp((UINT)port,Value); //Will ONLY compile on i386 architecture +#endif + break; + case 2: + unsigned int error; + DWORD BytesReturned; + BYTE Buffer[3]={NULL}; + unsigned short * pBuffer; + pBuffer = (unsigned short *)&Buffer[0]; + *pBuffer = port; + Buffer[2] = Value; + + error = DeviceIoControl(hdriver, + IOCTL_WRITE_PORT_UCHAR, + &Buffer, + sizeof(Buffer), + NULL, + 0, + &BytesReturned, + NULL); + break; + } +} + +USHORT _stdcall DlPortReadPortUshort (USHORT port) +{ + if (sysver!=2) + return 0; + + ULONG retval(0); + unsigned int error; + DWORD BytesReturned; + unsigned short sPort=port; + error = DeviceIoControl(hdriver, + IOCTL_READ_PORT_USHORT, + &sPort, + sizeof(unsigned short), + &sPort, + sizeof(unsigned short), + &BytesReturned, + NULL); + return(sPort); +} + +void _stdcall DlPortWritePortUshort (USHORT port, USHORT Value) +{ + if (sysver!=2) + return; + + unsigned int error; + DWORD BytesReturned; + BYTE Buffer[5]={NULL}; + unsigned short * pBuffer; + pBuffer = (unsigned short *)&Buffer[0]; + *pBuffer = LOWORD(port); + *(pBuffer+1) = Value; + + error = DeviceIoControl(hdriver, + IOCTL_WRITE_PORT_USHORT, + &Buffer, + sizeof(Buffer), + NULL, + 0, + &BytesReturned, + NULL); +} + +ULONG _stdcall DlPortReadPortUlong(ULONG port) +{ + if (sysver!=2) + return 0; + + ULONG retval(0); + unsigned int error; + DWORD BytesReturned; + unsigned long lPort=port; + + PULONG ulBuffer; + ulBuffer = (PULONG)&lPort; + ULONG test = ulBuffer[0]; + + error = DeviceIoControl(hdriver, + IOCTL_READ_PORT_ULONG, + &lPort, + sizeof(unsigned long), + &lPort, + sizeof(unsigned long), + &BytesReturned, + NULL); + return(lPort); +} + +void _stdcall DlPortWritePortUlong (ULONG port, ULONG Value) +{ + if (sysver!=2) + return; + + unsigned int error; + DWORD BytesReturned; + BYTE Buffer[8] = {NULL}; + unsigned long* pBuffer; + pBuffer = (unsigned long*)&Buffer[0]; + *pBuffer = port; + *(pBuffer+1) = Value; + + error = DeviceIoControl(hdriver, + IOCTL_WRITE_PORT_ULONG, + &Buffer, + sizeof(Buffer), + NULL, + 0, + &BytesReturned, + NULL); +} + + +// Support functions for WinIO +PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle) +{ + PBYTE pbLinAddr; + tagPhys32Struct Phys32Struct; + DWORD dwBytesReturned; + + if (sysver!=2) + return false; + + Phys32Struct.dwPhysMemSizeInBytes = dwPhysSize; + Phys32Struct.pvPhysAddress = pbPhysAddr; + + if (!DeviceIoControl(hdriver, IOCTL_WINIO_MAPPHYSTOLIN, &Phys32Struct, + sizeof(tagPhys32Struct), &Phys32Struct, sizeof(tagPhys32Struct), + &dwBytesReturned, NULL)) + return NULL; + else + { +#ifdef _M_X64 + pbLinAddr = (PBYTE)((LONGLONG)Phys32Struct.pvPhysMemLin + (LONGLONG)pbPhysAddr - (LONGLONG)Phys32Struct.pvPhysAddress); +#else + pbLinAddr = (PBYTE)((DWORD)Phys32Struct.pvPhysMemLin + (DWORD)pbPhysAddr - (DWORD)Phys32Struct.pvPhysAddress); +#endif + *pPhysicalMemoryHandle = Phys32Struct.PhysicalMemoryHandle; + } + return pbLinAddr; +} + + +BOOL _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr) +{ + tagPhys32Struct Phys32Struct; + DWORD dwBytesReturned; + + if (sysver!=2) + return false; + + Phys32Struct.PhysicalMemoryHandle = PhysicalMemoryHandle; + Phys32Struct.pvPhysMemLin = pbLinAddr; + + if (!DeviceIoControl(hdriver, IOCTL_WINIO_UNMAPPHYSADDR, &Phys32Struct, + sizeof(tagPhys32Struct), NULL, 0, &dwBytesReturned, NULL)) + return false; + + return true; +} + +BOOL _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal) +{ + PDWORD pdwLinAddr; + HANDLE PhysicalMemoryHandle; + + if (sysver!=2) + return false; + + pdwLinAddr = (PDWORD)MapPhysToLin(pbPhysAddr, 4, &PhysicalMemoryHandle); + if (pdwLinAddr == NULL) + return false; + + *pdwPhysVal = *pdwLinAddr; + UnmapPhysicalMemory(PhysicalMemoryHandle, (PBYTE)pdwLinAddr); + return true; +} + + +BOOL _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal) +{ + PDWORD pdwLinAddr; + HANDLE PhysicalMemoryHandle; + if (sysver!=2) + return false; + + pdwLinAddr = (PDWORD)MapPhysToLin(pbPhysAddr, 4, &PhysicalMemoryHandle); + if (pdwLinAddr == NULL) + return false; + + *pdwLinAddr = dwPhysVal; + UnmapPhysicalMemory(PhysicalMemoryHandle, (PBYTE)pdwLinAddr); + return true; +} diff --git a/InpOut/inpout32drv.def b/InpOut/inpout32drv.def new file mode 100644 index 0000000..e2b60cf --- /dev/null +++ b/InpOut/inpout32drv.def @@ -0,0 +1,18 @@ +EXPORTS + +Inp32 @1 +Out32 @2 +IsInpOutDriverOpen @3 + +DlPortReadPortUchar @4 +DlPortWritePortUchar @5 +DlPortReadPortUshort @6 +DlPortWritePortUshort @7 +DlPortReadPortUlong @8 +DlPortWritePortUlong @9 +IsXP64Bit @10 + +MapPhysToLin @11 +UnmapPhysicalMemory @12 +GetPhysLong @13 +SetPhysLong @14 \ No newline at end of file diff --git a/InpOut/inpout32drv.rc b/InpOut/inpout32drv.rc new file mode 100644 index 0000000..700ac33 --- /dev/null +++ b/InpOut/inpout32drv.rc @@ -0,0 +1,125 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,5,0,0 + PRODUCTVERSION 1,5,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x21L +#else + FILEFLAGS 0x20L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080004b0" + BEGIN + VALUE "Comments", "Includes signed x64 drivers for Vista compatibility." + VALUE "CompanyName", "Highresolution Enterprises" + VALUE "FileDescription", "inpout32/64" + VALUE "FileVersion", "1, 5, 0, 0" + VALUE "InternalName", "inpout32" + VALUE "LegalCopyright", "Freeware" + VALUE "LegalTrademarks", "Copyright © 2008-2011 Highresolution Enterprises. Portions Copyright Logix4U" + VALUE "OriginalFilename", "inpout32.dll" + VALUE "ProductName", "inpout32" + VALUE "ProductVersion", "1, 5, 0, 0" + VALUE "SpecialBuild", "x64 Compatible build\r\nIncludes basic DLPortIO Compatibility\r\nIncludes signed drivers (Thanks to Red Fox UK) for Vista x64 compatiblity.\r\n" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x800, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Neutral (Sys. Default) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// BIN +// + +IDR_INPOUT32 BIN "inpout32.sys" +IDR_INPOUTX64 BIN "inpoutx64.sys" +#endif // Neutral (Sys. Default) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/InpOut/inpout32drv.sln b/InpOut/inpout32drv.sln new file mode 100644 index 0000000..9d797be --- /dev/null +++ b/InpOut/inpout32drv.sln @@ -0,0 +1,100 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "inpout32drv", "inpout32drv.vcproj", "{18AEFF0B-D208-45B0-88E1-7057B9BA78F3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InstallDriver", "InstallDriver\InstallDriver.vcproj", "{233B1347-4B15-42DC-AC23-C2FE2ABEAF54}" + ProjectSection(ProjectDependencies) = postProject + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3} = {18AEFF0B-D208-45B0-88E1-7057B9BA78F3} + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InpOut32.VB.Net", "InpOut32.Net\InpOut32.VB.Net\InpOut32.VB.Net.vbproj", "{F90F25E7-E912-4948-B9CE-168FFA3014C8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InpOut32.CSharp.Net", "InpOut32.Net\InpOut32.CSharp.Net\InpOut32.CSharp.Net.csproj", "{784B3C36-7CAD-4B06-82A5-E60D17193F27}" +EndProject +Global + GlobalSection(SourceCodeControl) = preSolution + SccNumberOfProjects = 5 + SccLocalPath0 = . + SccProjectUniqueName1 = inpout32drv.vcproj + SccLocalPath1 = . + SccProjectUniqueName2 = InstallDriver\\InstallDriver.vcproj + SccLocalPath2 = . + SccProjectFilePathRelativizedFromConnection2 = InstallDriver\\ + SccProjectUniqueName3 = InpOut32.Net\\InpOut32.VB.Net\\InpOut32.VB.Net.vbproj + SccLocalPath3 = . + SccProjectFilePathRelativizedFromConnection3 = InpOut32.Net\\InpOut32.VB.Net\\ + SccProjectUniqueName4 = InpOut32.Net\\InpOut32.CSharp.Net\\InpOut32.CSharp.Net.csproj + SccProjectName4 = \u0022$/inpout32drv.root/inpout32drv/InpOut32.Net/InpOut32.CSharp.Net\u0022,\u0020DHHAAAAA + SccLocalPath4 = InpOut32.Net\\InpOut32.CSharp.Net + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Debug|Any CPU.ActiveCfg = Debug|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Debug|Mixed Platforms.Build.0 = Debug|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Debug|Win32.ActiveCfg = Debug|Win32 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Debug|Win32.Build.0 = Debug|Win32 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Debug|x64.ActiveCfg = Debug|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Debug|x64.Build.0 = Debug|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Release|Any CPU.ActiveCfg = Release|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Release|Mixed Platforms.Build.0 = Release|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Release|Win32.ActiveCfg = Release|Win32 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Release|Win32.Build.0 = Release|Win32 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Release|x64.ActiveCfg = Release|x64 + {18AEFF0B-D208-45B0-88E1-7057B9BA78F3}.Release|x64.Build.0 = Release|x64 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Debug|Win32.ActiveCfg = Debug|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Debug|Win32.Build.0 = Debug|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Debug|x64.ActiveCfg = Debug|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Release|Any CPU.ActiveCfg = Release|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Release|Mixed Platforms.Build.0 = Release|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Release|Win32.ActiveCfg = Release|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Release|Win32.Build.0 = Release|Win32 + {233B1347-4B15-42DC-AC23-C2FE2ABEAF54}.Release|x64.ActiveCfg = Release|Win32 + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|Win32.ActiveCfg = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|Win32.Build.0 = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|x64.ActiveCfg = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Debug|x64.Build.0 = Debug|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|Any CPU.Build.0 = Release|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|Win32.ActiveCfg = Release|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|Win32.Build.0 = Release|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|x64.ActiveCfg = Release|Any CPU + {F90F25E7-E912-4948-B9CE-168FFA3014C8}.Release|x64.Build.0 = Release|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Debug|Any CPU.Build.0 = Debug|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Debug|Win32.ActiveCfg = Debug|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Debug|x64.ActiveCfg = Debug|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Release|Any CPU.ActiveCfg = Release|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Release|Any CPU.Build.0 = Release|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Release|Win32.ActiveCfg = Release|Any CPU + {784B3C36-7CAD-4B06-82A5-E60D17193F27}.Release|x64.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/InpOut/inpout32drv.vcproj b/InpOut/inpout32drv.vcproj new file mode 100644 index 0000000..be97fea --- /dev/null +++ b/InpOut/inpout32drv.vcproj @@ -0,0 +1,621 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InpOut/inpoutx64.sys b/InpOut/inpoutx64.sys new file mode 100644 index 0000000000000000000000000000000000000000..4ddbcbb23e48b2e99c755d7e352d870785d15fec GIT binary patch literal 15008 zcmeG@30PA{x08i^2?{6*O4O*h05=3#Tv_EtgCdJsL?J*RsgPh6!5zXPF{0Aewf>4q z{avYl-Kny;f!3vJwW2LzYghyyPXi3wx|Z9bLl&0?9HR*?4Tu&?6zmMSELAQ{XD11z zQkjySC}PW1Qnp0O4w)LoPM0N%JZx+%IR?~QbtfO)*>b(2vs|mV3H|+yT^03IT~<*? z)fE-Dpmr)Qs<=({_fmDFBuR|d{%4d%gd&t&V2Z}}c|{uMw4#B?if)dO9YC!0P`e1I zaUanP0I28)nZS>+Py-q83(V^C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558Ayni%uBu6*3?-Q$L^$}TKP)H=p!Zhqt)epAF%Ga7LiNT<<= zob!LtFpqBctMIk+{d!5x&k(X1-@{ulxYk`RNhY}I&MVW3YYQ(>JNu5rpw5L%F60-L zH|{A%F05E}^+#G{-JS>ZCob@B>T^Emvc{U5lM5L~$&_rt?|iXjBX{^phQA19!0UYc z9h66XGsItmlHVDjz9Vk)$R26%0XV@HOH##h(L(S59;&&X$+AponoO9i@YMf9Jf4?l z*INu;nlW>-SqmTT|E8!t-+fuL;73!_!7d|R6v;=j0=MdRJz7}5ICMh7`xn=Et=jRC z==(ilk8vyFxKFbJVt2-RhrQRf{?elKIMYpO$$bV#wg*&dhYYYjE^etUKR99e9WOht zbsyZ!(k*?gSo8SxFDdmIWN)r&bWq&p>(}2O5TICvWsq5b#%;Vpc)+`CR~<2li>Oh1l+?u zvEalzMw#56OgrZ!+Z}Pvv#x$<5q^RYEZzNU3DDzNZrPU;(aq%nHr12p)am@IcUbzr)@vIsqv}9*zp_fgf{z9tlo<`@@k!3X7*ka z)%sD-*UFz{sM+n$&59>YJ?%5by8g|cJ-s&1xjv{i*L7XXtpF literal 0 HcmV?d00001 diff --git a/InpOut/license.txt b/InpOut/license.txt new file mode 100644 index 0000000..e6b145a --- /dev/null +++ b/InpOut/license.txt @@ -0,0 +1,24 @@ +Copyright (c) <2003-2015> Phil Gibbons +Portions Copyright (c) <2000> + +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. \ No newline at end of file diff --git a/InpOut/osversion.cpp b/InpOut/osversion.cpp new file mode 100644 index 0000000..b5e0ead --- /dev/null +++ b/InpOut/osversion.cpp @@ -0,0 +1,78 @@ +#include "stdafx.h" +#include "hwinterfacedrv.h" + +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); +typedef BOOL (WINAPI *LPFN_WOW64DISABLE) (PVOID*); +typedef BOOL (WINAPI *LPFN_WOW64REVERT) (PVOID); + +LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(_T("kernel32")),"IsWow64Process"); +LPFN_WOW64DISABLE fnWow64Disable = (LPFN_WOW64DISABLE)GetProcAddress(GetModuleHandle(_T("kernel32")),"Wow64DisableWow64FsRedirection"); +LPFN_WOW64REVERT fnWow64Revert = (LPFN_WOW64REVERT)GetProcAddress(GetModuleHandle(_T("kernel32")),"Wow64RevertWow64FsRedirection"); + +//Purpose: Return TRUE if we are running in WOW64 (i.e. a 32bit process on XP x64 edition) +BOOL _stdcall IsXP64Bit() +{ +#ifdef _M_X64 + return TRUE; //Urrr if its a x64 build of the DLL, we MUST be running on X64 nativly! +#endif + + BOOL bIsWow64 = FALSE; + if (NULL != fnIsWow64Process) + { + if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) + { + // handle error + } + } + return bIsWow64; +} + +BOOL DisableWOW64(PVOID* oldValue) +{ +#ifdef _M_X64 + return TRUE; // If were 64b under x64, we dont wanna do anything! +#endif + return fnWow64Disable(oldValue); +} + +BOOL RevertWOW64(PVOID* oldValue) +{ +#ifdef _M_X64 + return TRUE; // If were 64b under x64, we dont wanna do anything! +#endif + return fnWow64Revert (oldValue); +} + +int SystemVersion() +{ + OSVERSIONINFOEX osvi; + BOOL bOsVersionInfoEx; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) + { + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + + if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) + return 0; + } + + switch (osvi.dwPlatformId) + { + case VER_PLATFORM_WIN32_NT: + + return 2; //WINNT + + break; + + case VER_PLATFORM_WIN32_WINDOWS: + + return 1; //WIN9X + + break; + + } + return 0; +} diff --git a/InpOut/resource.h b/InpOut/resource.h new file mode 100644 index 0000000..3e0ae19 --- /dev/null +++ b/InpOut/resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by inpout32drv.rc +// +#define IDR_BIN1 101 +#define IDR_INPOUT32 101 +#define IDR_INPOUTX64 104 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Licenses/License.html b/Licenses/License.html index 79ae19a..62092de 100644 --- a/Licenses/License.html +++ b/Licenses/License.html @@ -70,7 +70,7 @@ The remainder of the software which is not under the Mozilla Public License 2.0
@@ -269,29 +269,30 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-

OxyPlot License

+

InpOut License

-This license applies to the OxyPlot library. +This license applies to the InpOut library.

-Copyright (c) 2012 Oystein Bjorke
+Copyright (c) <2003-2015> Phil Gibbons 
+Portions Copyright (c) <2000> 
 
-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 
+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 
+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 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.