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 0000000..0f68c5e Binary files /dev/null and b/InpOut/inpout32.sys differ 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 0000000..4ddbcbb Binary files /dev/null and b/InpOut/inpoutx64.sys differ 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.