From cd9e916391efcf42a8bd05ac33a5d70771922549 Mon Sep 17 00:00:00 2001 From: Hong-She Liang Date: Sun, 7 Jan 2018 13:31:53 +0800 Subject: [PATCH] Import WinIo 3.0 --- Examples/C/WinIoTest/WinIoTest.cpp | 60 --- Examples/C/WinIoTest/WinIoTest.dsp | 104 ---- Examples/C/WinIoTest/WinIoTest.dsw | 29 -- Examples/VB/VBDumpPhys32/MSSCCPRJ.SCC | 6 - Examples/VB/VBDumpPhys32/VBDumpPhys32.Vbp | 43 -- Examples/VB/VBDumpPhys32/VBDumpPhys32.frm | 240 --------- Examples/VB/VBDumpPhys32/VBDumpPhys32.vbw | 2 - Examples/VB/VBDumpPhys32/WinIo.Bas | 12 - Examples/VB/VBDumpPort32/MSSCCPRJ.SCC | 6 - Examples/VB/VBDumpPort32/VBDumpPort32.Vbp | 43 -- Examples/VB/VBDumpPort32/VBDumpPort32.frm | 240 --------- Examples/VB/VBDumpPort32/VBDumpPort32.vbw | 2 - Examples/VB/VBDumpPort32/WinIo.Bas | 12 - Samples/DumpPhys/DumpPhys.sln | 26 + Samples/DumpPhys/DumpPhys.suo | Bin 0 -> 24576 bytes Samples/DumpPhys/DumpPhys/DumpPhys.csproj | 142 ++++++ Samples/DumpPhys/DumpPhys/DumpPhys.manifest | 10 + Samples/DumpPhys/DumpPhys/Form1.Designer.cs | 174 +++++++ Samples/DumpPhys/DumpPhys/Form1.cs | 157 ++++++ Samples/DumpPhys/DumpPhys/Form1.resx | 120 +++++ Samples/DumpPhys/DumpPhys/Program.cs | 20 + .../DumpPhys/Properties/AssemblyInfo.cs | 33 ++ .../DumpPhys/Properties/Resources.Designer.cs | 63 +++ .../DumpPhys/Properties/Resources.resx | 117 +++++ .../DumpPhys/Properties/Settings.Designer.cs | 26 + .../DumpPhys/Properties/Settings.settings | 7 + Samples/DumpPort/DumpPort.sln | 26 + Samples/DumpPort/DumpPort.suo | Bin 0 -> 13824 bytes Samples/DumpPort/DumpPort/DumpPort.csproj | 142 ++++++ Samples/DumpPort/DumpPort/DumpPort.manifest | 10 + Samples/DumpPort/DumpPort/Form1.Designer.cs | 176 +++++++ Samples/DumpPort/DumpPort/Form1.cs | 154 ++++++ Samples/DumpPort/DumpPort/Form1.resx | 120 +++++ Samples/DumpPort/DumpPort/Program.cs | 20 + .../DumpPort/Properties/AssemblyInfo.cs | 33 ++ .../DumpPort/Properties/Resources.Designer.cs | 63 +++ .../DumpPort/Properties/Resources.resx | 117 +++++ .../DumpPort/Properties/Settings.Designer.cs | 26 + .../DumpPort/Properties/Settings.settings | 7 + Source/Dll/InstDrv.cpp | 236 +++++---- Source/Dll/K32Call.h | 9 - Source/Dll/Phys32.cpp | 173 +++---- Source/Dll/Port32.cpp | 158 +++--- Source/Dll/WinIo.aps | Bin 0 -> 33948 bytes Source/Dll/WinIo.cpp | 212 ++++---- Source/Dll/WinIo.def | 3 - Source/Dll/WinIo.dsp | 129 ----- Source/Dll/WinIo.dsw | 29 -- Source/Dll/WinIo.h | 31 -- Source/Dll/WinIo.rc | 39 +- Source/Dll/WinIo.sln | 26 + Source/Dll/WinIo.suo | Bin 0 -> 20480 bytes Source/Dll/WinIo.vcproj | 379 ++++++++++++++ Source/Dll/k32exp.c | 92 ---- Source/Dll/k32exp.h | 113 ----- .../C/WinIoTest/WinIo.h => Source/Dll/winio.h | 16 +- Source/Drv/9x/WINIO.DEF | 27 - Source/Drv/9x/WINIO.VRC | 9 - Source/Drv/9x/WINIO.exp | Bin 1576 -> 0 bytes Source/Drv/9x/WinIo.c | 104 ---- Source/Drv/9x/WinIo.h | 6 - Source/Drv/9x/WinIo_9x.h | 16 - Source/Drv/9x/winio.mak | 13 - Source/Drv/{NT => }/MAKEFILE | 0 Source/Drv/NT/WinIo.c | 406 --------------- Source/Drv/NT/WinIo_NT.h | 50 -- Source/Drv/{NT => }/SOURCES | 0 Source/Drv/WinIo.c | 478 ++++++++++++++++++ Source/Drv/winio_nt.h | 69 +++ 69 files changed, 3186 insertions(+), 2225 deletions(-) delete mode 100644 Examples/C/WinIoTest/WinIoTest.cpp delete mode 100644 Examples/C/WinIoTest/WinIoTest.dsp delete mode 100644 Examples/C/WinIoTest/WinIoTest.dsw delete mode 100644 Examples/VB/VBDumpPhys32/MSSCCPRJ.SCC delete mode 100644 Examples/VB/VBDumpPhys32/VBDumpPhys32.Vbp delete mode 100644 Examples/VB/VBDumpPhys32/VBDumpPhys32.frm delete mode 100644 Examples/VB/VBDumpPhys32/VBDumpPhys32.vbw delete mode 100644 Examples/VB/VBDumpPhys32/WinIo.Bas delete mode 100644 Examples/VB/VBDumpPort32/MSSCCPRJ.SCC delete mode 100644 Examples/VB/VBDumpPort32/VBDumpPort32.Vbp delete mode 100644 Examples/VB/VBDumpPort32/VBDumpPort32.frm delete mode 100644 Examples/VB/VBDumpPort32/VBDumpPort32.vbw delete mode 100644 Examples/VB/VBDumpPort32/WinIo.Bas create mode 100644 Samples/DumpPhys/DumpPhys.sln create mode 100644 Samples/DumpPhys/DumpPhys.suo create mode 100644 Samples/DumpPhys/DumpPhys/DumpPhys.csproj create mode 100644 Samples/DumpPhys/DumpPhys/DumpPhys.manifest create mode 100644 Samples/DumpPhys/DumpPhys/Form1.Designer.cs create mode 100644 Samples/DumpPhys/DumpPhys/Form1.cs create mode 100644 Samples/DumpPhys/DumpPhys/Form1.resx create mode 100644 Samples/DumpPhys/DumpPhys/Program.cs create mode 100644 Samples/DumpPhys/DumpPhys/Properties/AssemblyInfo.cs create mode 100644 Samples/DumpPhys/DumpPhys/Properties/Resources.Designer.cs create mode 100644 Samples/DumpPhys/DumpPhys/Properties/Resources.resx create mode 100644 Samples/DumpPhys/DumpPhys/Properties/Settings.Designer.cs create mode 100644 Samples/DumpPhys/DumpPhys/Properties/Settings.settings create mode 100644 Samples/DumpPort/DumpPort.sln create mode 100644 Samples/DumpPort/DumpPort.suo create mode 100644 Samples/DumpPort/DumpPort/DumpPort.csproj create mode 100644 Samples/DumpPort/DumpPort/DumpPort.manifest create mode 100644 Samples/DumpPort/DumpPort/Form1.Designer.cs create mode 100644 Samples/DumpPort/DumpPort/Form1.cs create mode 100644 Samples/DumpPort/DumpPort/Form1.resx create mode 100644 Samples/DumpPort/DumpPort/Program.cs create mode 100644 Samples/DumpPort/DumpPort/Properties/AssemblyInfo.cs create mode 100644 Samples/DumpPort/DumpPort/Properties/Resources.Designer.cs create mode 100644 Samples/DumpPort/DumpPort/Properties/Resources.resx create mode 100644 Samples/DumpPort/DumpPort/Properties/Settings.Designer.cs create mode 100644 Samples/DumpPort/DumpPort/Properties/Settings.settings delete mode 100644 Source/Dll/K32Call.h create mode 100644 Source/Dll/WinIo.aps delete mode 100644 Source/Dll/WinIo.dsp delete mode 100644 Source/Dll/WinIo.dsw delete mode 100644 Source/Dll/WinIo.h create mode 100644 Source/Dll/WinIo.sln create mode 100644 Source/Dll/WinIo.suo create mode 100644 Source/Dll/WinIo.vcproj delete mode 100644 Source/Dll/k32exp.c delete mode 100644 Source/Dll/k32exp.h rename Examples/C/WinIoTest/WinIo.h => Source/Dll/winio.h (62%) delete mode 100644 Source/Drv/9x/WINIO.DEF delete mode 100644 Source/Drv/9x/WINIO.VRC delete mode 100644 Source/Drv/9x/WINIO.exp delete mode 100644 Source/Drv/9x/WinIo.c delete mode 100644 Source/Drv/9x/WinIo.h delete mode 100644 Source/Drv/9x/WinIo_9x.h delete mode 100644 Source/Drv/9x/winio.mak rename Source/Drv/{NT => }/MAKEFILE (100%) delete mode 100644 Source/Drv/NT/WinIo.c delete mode 100644 Source/Drv/NT/WinIo_NT.h rename Source/Drv/{NT => }/SOURCES (100%) create mode 100644 Source/Drv/WinIo.c create mode 100644 Source/Drv/winio_nt.h diff --git a/Examples/C/WinIoTest/WinIoTest.cpp b/Examples/C/WinIoTest/WinIoTest.cpp deleted file mode 100644 index cc4caf7..0000000 --- a/Examples/C/WinIoTest/WinIoTest.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include "winio.h" - -void main() -{ - DWORD dwPortVal; - DWORD dwMemVal; - bool bResult; - HANDLE hPhysicalMemory; - PBYTE pbLinAddr; - - // Call InitializeWinIo to initialize the WinIo library. - - bResult = InitializeWinIo(); - - if (bResult) - { - // Under Windows NT/2000/XP, after calling InitializeWinIo, - // you can call _inp/_outp instead of using GetPortVal/SetPortVal - - GetPortVal(0x378, &dwPortVal, 4); - - SetPortVal(0x378, 10, 4); - - // Map physical addresses 0xA0000 - 0xAFFFF into the linear address space - // of the application. The value returned from the call to MapPhysToLin is - // a linear address corresponding to physical address 0xA0000. In case of - // an error, the return value is NULL. - - pbLinAddr = MapPhysToLin((PBYTE)0xA0000, 65536, &hPhysicalMemory); - - if (pbLinAddr) - { - // Now we can use pbLinAddr to access physical address 0xA0000 - - *pbLinAddr = 10; - - // When you're done with pbLinAddr, call UnmapPhysicalMemory - - UnmapPhysicalMemory(hPhysicalMemory, pbLinAddr); - } - - // Instead of using MapPhysToLin, we can use GetPhysLong/SetPhysLong - - GetPhysLong((PBYTE)0xA0000, &dwMemVal); - - SetPhysLong((PBYTE)0xA0000, 10); - - // When you're done using WinIo, call ShutdownWinIo - - ShutdownWinIo(); - } - else - { - printf("Error during initialization of WinIo.\n"); - exit(1); - } -} - diff --git a/Examples/C/WinIoTest/WinIoTest.dsp b/Examples/C/WinIoTest/WinIoTest.dsp deleted file mode 100644 index 4b2a88c..0000000 --- a/Examples/C/WinIoTest/WinIoTest.dsp +++ /dev/null @@ -1,104 +0,0 @@ -# Microsoft Developer Studio Project File - Name="WinIoTest" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=WinIoTest - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "WinIoTest.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "WinIoTest.mak" CFG="WinIoTest - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "WinIoTest - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "WinIoTest - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "WinIoTest - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "WinIoTest - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "WinIoTest - Win32 Release" -# Name "WinIoTest - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\WinIoTest.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\WinIo.lib -# End Source File -# End Target -# End Project diff --git a/Examples/C/WinIoTest/WinIoTest.dsw b/Examples/C/WinIoTest/WinIoTest.dsw deleted file mode 100644 index 2f2f0f2..0000000 --- a/Examples/C/WinIoTest/WinIoTest.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "WinIoTest"=.\WinIoTest.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/Examples/VB/VBDumpPhys32/MSSCCPRJ.SCC b/Examples/VB/VBDumpPhys32/MSSCCPRJ.SCC deleted file mode 100644 index df778fb..0000000 --- a/Examples/VB/VBDumpPhys32/MSSCCPRJ.SCC +++ /dev/null @@ -1,6 +0,0 @@ -[SCC] -SCC=This is a source code control file - -[VBDumpPhys32.Vbp] -SCC_Project_Name=this project is not under source code control -SCC_Aux_Path= diff --git a/Examples/VB/VBDumpPhys32/VBDumpPhys32.Vbp b/Examples/VB/VBDumpPhys32/VBDumpPhys32.Vbp deleted file mode 100644 index 9befcd1..0000000 --- a/Examples/VB/VBDumpPhys32/VBDumpPhys32.Vbp +++ /dev/null @@ -1,43 +0,0 @@ -Type=Exe -Form=VBDumpPhys32.frm -Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCX -Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; TABCTL32.OCX -Object={3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0; RICHTX32.OCX -Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0; COMCTL32.OCX -Object={FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0; DBLIST32.OCX -Object={00028C01-0000-0000-0000-000000000046}#1.0#0; DBGRID32.OCX -Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINDOWS\SYSTEM\StdOle2.Tlb#Standard OLE Types -Reference=*\G{00025E01-0000-0000-C000-000000000046}#4.0#0#..\..\..\..\PROGRAM FILES\COMMON FILES\MICROSOFT SHARED\DAO\DAO350.DLL#Microsoft DAO 3.0 Object Library -Module=Module1; WinIo.Bas -IconForm="FrmVBDumpPhys32" -Startup="FrmVBDumpPhys32" -HelpFile="" -Title="VBDumpPhys32" -ExeName32="VBDumpPhys32.exe" -Command32="" -Name="Project1" -HelpContextID="0" -CompatibleMode="0" -MajorVer=1 -MinorVer=0 -RevisionVer=0 -AutoIncrementVer=0 -ServerSupportFiles=0 -VersionCompanyName="WWW.INTERNALS.COM" -VersionLegalCopyright="Copyright 1997, 1998 Yariv Kaplan" -VersionProductName="VBDumpPhys32" -CompilationType=0 -OptimizationType=0 -FavorPentiumPro(tm)=0 -CodeViewDebugInfo=0 -NoAliasing=0 -BoundsCheck=0 -OverflowCheck=0 -FlPointCheck=0 -FDIVCheck=0 -UnroundedFP=0 -StartMode=0 -Unattended=0 -Retained=0 -ThreadPerObject=0 -MaxNumberOfThreads=1 diff --git a/Examples/VB/VBDumpPhys32/VBDumpPhys32.frm b/Examples/VB/VBDumpPhys32/VBDumpPhys32.frm deleted file mode 100644 index 744f5bc..0000000 --- a/Examples/VB/VBDumpPhys32/VBDumpPhys32.frm +++ /dev/null @@ -1,240 +0,0 @@ -VERSION 5.00 -Begin VB.Form FrmVBDumpPhys32 - BackColor = &H00FF0000& - BorderStyle = 1 'Fixed Single - Caption = "VBDumpPhys32" - ClientHeight = 4215 - ClientLeft = 2295 - ClientTop = 2385 - ClientWidth = 5295 - LinkTopic = "Form1" - MaxButton = 0 'False - MinButton = 0 'False - PaletteMode = 1 'UseZOrder - ScaleHeight = 4215 - ScaleWidth = 5295 - Begin VB.TextBox TxtPhysVal - Height = 288 - Left = 1560 - MaxLength = 8 - TabIndex = 10 - Text = "0" - Top = 2640 - Width = 975 - End - Begin VB.CommandButton BtnQuit - Caption = "&Quit" - Height = 372 - Left = 4020 - TabIndex = 5 - Top = 3540 - Width = 972 - End - Begin VB.CommandButton BtnSet - Caption = "&Set Value" - Height = 372 - Left = 2124 - TabIndex = 4 - Top = 3528 - Width = 972 - End - Begin VB.CommandButton BtnGet - Caption = "&Get Value" - Height = 372 - Left = 348 - TabIndex = 1 - Top = 3504 - Width = 852 - End - Begin VB.TextBox TxtPhysAddr - Height = 288 - Left = 3720 - MaxLength = 8 - TabIndex = 0 - Text = "0" - Top = 2052 - Width = 975 - End - Begin VB.Label Label6 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "http://www.internals.com" - BeginProperty Font - Name = "MS Sans Serif" - Size = 9.75 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H0000FFFF& - Height = 240 - Left = 1582 - TabIndex = 9 - Top = 1305 - Width = 2130 - End - Begin VB.Label Label5 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "Copyright 1998-2002 by Yariv Kaplan" - BeginProperty Font - Name = "MS Sans Serif" - Size = 9.75 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H0000FFFF& - Height = 240 - Left = 1005 - TabIndex = 8 - Top = 885 - Width = 3270 - End - Begin VB.Line Line1 - BorderColor = &H00FFFF80& - BorderWidth = 2 - X1 = 12 - X2 = 5292 - Y1 = 1788 - Y2 = 1788 - End - Begin VB.Label Label3 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "VBDumpPhys32" - BeginProperty Font - Name = "MS Sans Serif" - Size = 24 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H0000FFFF& - Height = 555 - Left = 885 - TabIndex = 6 - Top = 210 - Width = 3540 - End - Begin VB.Label Label4 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "VBDumpPhys32" - BeginProperty Font - Name = "MS Sans Serif" - Size = 24 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H00800000& - Height = 555 - Left = 885 - TabIndex = 7 - Top = 165 - Width = 3540 - End - Begin VB.Label Label2 - BackColor = &H00FF0000& - Caption = "Value (hex):" - BeginProperty Font - Name = "MS Sans Serif" - Size = 9.75 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H00FFFFFF& - Height = 252 - Left = 360 - TabIndex = 3 - Top = 2652 - Width = 1212 - End - Begin VB.Label Label1 - BackColor = &H00FF0000& - Caption = "Please enter physical address (hex):" - BeginProperty Font - Name = "MS Sans Serif" - Size = 9.75 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H00FFFFFF& - Height = 252 - Left = 360 - TabIndex = 2 - Top = 2052 - Width = 3252 - End -End -Attribute VB_Name = "FrmVBDumpPhys32" -Attribute VB_GlobalNameSpace = False -Attribute VB_Creatable = False -Attribute VB_PredeclaredId = True -Attribute VB_Exposed = False -Option Explicit -Private Sub BtnGet_Click() - Dim Result As Boolean - Dim PhysVal As Long - - Result = GetPhysLong(Val("&H" + TxtPhysAddr), PhysVal) - - If (Result = False) Then - MsgBox "Whoops ! There is a problem with GetPhysLong.", vbOKOnly + vbCritical, "VBDumpPhys32" - Unload FrmVBDumpPhys32 - Else - TxtPhysVal = Hex$(PhysVal) - End If -End Sub -Private Sub BtnQuit_Click() - Unload FrmVBDumpPhys32 -End Sub -Private Sub BtnSet_Click() - Dim Result As Boolean - - Result = SetPhysLong(Val("&H" + TxtPhysAddr), Val("&H" + TxtPhysVal)) - - If Result = False Then - MsgBox "Whoops ! There is a problem with SetPhysLong.", vbOKOnly + vbCritical, "VBDumpPhys32" - Unload FrmVBDumpPhys32 - End If -End Sub -Private Sub Form_Load() - If InitializeWinIo = False Then - MsgBox "Whoops ! There is a problem with InitializeWinIo.", vbOKOnly + vbCritical, "VBDumpPhys32" - Unload FrmVBDumpPhys32 - Else - Call BtnGet_Click - End If -End Sub -Private Sub Form_Unload(Cancel As Integer) - Call ShutdownWinIo -End Sub -Private Sub TxtPhysAddr_KeyPress(KeyAscii As Integer) - If KeyAscii = 13 Then - Call BtnGet_Click - End If -End Sub diff --git a/Examples/VB/VBDumpPhys32/VBDumpPhys32.vbw b/Examples/VB/VBDumpPhys32/VBDumpPhys32.vbw deleted file mode 100644 index d2d87a7..0000000 --- a/Examples/VB/VBDumpPhys32/VBDumpPhys32.vbw +++ /dev/null @@ -1,2 +0,0 @@ -FrmVBDumpPhys32 = 28, 15, 696, 566, C, 22, 22, 480, 435, C -Module1 = 0, 0, 0, 0, C diff --git a/Examples/VB/VBDumpPhys32/WinIo.Bas b/Examples/VB/VBDumpPhys32/WinIo.Bas deleted file mode 100644 index 2a67b0e..0000000 --- a/Examples/VB/VBDumpPhys32/WinIo.Bas +++ /dev/null @@ -1,12 +0,0 @@ -Attribute VB_Name = "Module1" -Option Explicit -Declare Function MapPhysToLin Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysSize As Long, ByRef PhysMemHandle) As Long -Declare Function UnmapPhysicalMemory Lib "WinIo.dll" (ByVal PhysMemHandle, ByVal LinAddr) As Boolean -Declare Function GetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByRef PhysVal As Long) As Boolean -Declare Function SetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysVal As Long) As Boolean -Declare Function GetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByRef PortVal As Long, ByVal bSize As Byte) As Boolean -Declare Function SetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByVal PortVal As Long, ByVal bSize As Byte) As Boolean -Declare Function InitializeWinIo Lib "WinIo.dll" () As Boolean -Declare Function ShutdownWinIo Lib "WinIo.dll" () As Boolean -Declare Function InstallWinIoDriver Lib "WinIo.dll" (ByVal DriverPath As String, ByVal Mode As Integer) As Boolean -Declare Function RemoveWinIoDriver Lib "WinIo.dll" () As Boolean diff --git a/Examples/VB/VBDumpPort32/MSSCCPRJ.SCC b/Examples/VB/VBDumpPort32/MSSCCPRJ.SCC deleted file mode 100644 index a51ffd2..0000000 --- a/Examples/VB/VBDumpPort32/MSSCCPRJ.SCC +++ /dev/null @@ -1,6 +0,0 @@ -[SCC] -SCC=This is a source code control file - -[VBDumpPort32.Vbp] -SCC_Project_Name=this project is not under source code control -SCC_Aux_Path= diff --git a/Examples/VB/VBDumpPort32/VBDumpPort32.Vbp b/Examples/VB/VBDumpPort32/VBDumpPort32.Vbp deleted file mode 100644 index 5451228..0000000 --- a/Examples/VB/VBDumpPort32/VBDumpPort32.Vbp +++ /dev/null @@ -1,43 +0,0 @@ -Type=Exe -Form=VBDumpPort32.frm -Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCX -Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; TABCTL32.OCX -Object={3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0; RICHTX32.OCX -Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0; COMCTL32.OCX -Object={FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0; DBLIST32.OCX -Object={00028C01-0000-0000-0000-000000000046}#1.0#0; DBGRID32.OCX -Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINDOWS\SYSTEM\StdOle2.Tlb#Standard OLE Types -Reference=*\G{00025E01-0000-0000-C000-000000000046}#4.0#0#..\..\..\..\PROGRAM FILES\COMMON FILES\MICROSOFT SHARED\DAO\DAO350.DLL#Microsoft DAO 3.0 Object Library -Module=Module1; WinIo.Bas -IconForm="FrmVBDumpPort32" -Startup="FrmVBDumpPort32" -HelpFile="" -Title="VBDumpPort32" -ExeName32="VBDumpPort32.exe" -Command32="" -Name="Project1" -HelpContextID="0" -CompatibleMode="0" -MajorVer=1 -MinorVer=0 -RevisionVer=0 -AutoIncrementVer=0 -ServerSupportFiles=0 -VersionCompanyName="WWW.INTERNALS.COM" -VersionLegalCopyright="Copyright 1997, 1998 Yariv Kaplan" -VersionProductName="VBDumpPort32" -CompilationType=0 -OptimizationType=0 -FavorPentiumPro(tm)=0 -CodeViewDebugInfo=0 -NoAliasing=0 -BoundsCheck=0 -OverflowCheck=0 -FlPointCheck=0 -FDIVCheck=0 -UnroundedFP=0 -StartMode=0 -Unattended=0 -Retained=0 -ThreadPerObject=0 -MaxNumberOfThreads=1 diff --git a/Examples/VB/VBDumpPort32/VBDumpPort32.frm b/Examples/VB/VBDumpPort32/VBDumpPort32.frm deleted file mode 100644 index 5e89d79..0000000 --- a/Examples/VB/VBDumpPort32/VBDumpPort32.frm +++ /dev/null @@ -1,240 +0,0 @@ -VERSION 5.00 -Begin VB.Form FrmVBDumpPort32 - BackColor = &H00FF0000& - BorderStyle = 1 'Fixed Single - Caption = "VBDumpPort32" - ClientHeight = 4215 - ClientLeft = 2295 - ClientTop = 2385 - ClientWidth = 5295 - LinkTopic = "Form1" - MaxButton = 0 'False - MinButton = 0 'False - PaletteMode = 1 'UseZOrder - ScaleHeight = 4215 - ScaleWidth = 5295 - Begin VB.TextBox TxtPortByte - Alignment = 2 'Center - Height = 288 - Left = 1560 - MaxLength = 2 - TabIndex = 10 - Top = 2652 - Width = 372 - End - Begin VB.CommandButton BtnQuit - Caption = "&Quit" - Height = 372 - Left = 4020 - TabIndex = 5 - Top = 3540 - Width = 972 - End - Begin VB.CommandButton BtnSet - Caption = "&Set Value" - Height = 372 - Left = 2124 - TabIndex = 4 - Top = 3528 - Width = 972 - End - Begin VB.CommandButton BtnGet - Caption = "&Get Value" - Height = 372 - Left = 348 - TabIndex = 1 - Top = 3504 - Width = 852 - End - Begin VB.TextBox TxtPortAddr - Height = 288 - Left = 3300 - MaxLength = 4 - TabIndex = 0 - Text = "0" - Top = 2040 - Width = 600 - End - Begin VB.Label Label6 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "http://www.internals.com" - BeginProperty Font - Name = "Verdana" - Size = 9.75 - Charset = 0 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H0000FFFF& - Height = 240 - Left = 1357 - TabIndex = 9 - Top = 1335 - Width = 2580 - End - Begin VB.Label Label5 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "Copyright 1998-2002 by Yariv Kaplan" - BeginProperty Font - Name = "Verdana" - Size = 9.75 - Charset = 0 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H0000FFFF& - Height = 240 - Left = 795 - TabIndex = 8 - Top = 885 - Width = 3690 - End - Begin VB.Line Line1 - BorderColor = &H00FFFF80& - BorderWidth = 2 - X1 = 12 - X2 = 5292 - Y1 = 1788 - Y2 = 1788 - End - Begin VB.Label Label3 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "VBDumpPort32" - BeginProperty Font - Name = "MS Sans Serif" - Size = 24 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H0000FFFF& - Height = 555 - Left = 945 - TabIndex = 6 - Top = 210 - Width = 3360 - End - Begin VB.Label Label4 - Alignment = 2 'Center - AutoSize = -1 'True - BackColor = &H00FFFFFF& - BackStyle = 0 'Transparent - Caption = "VBDumpPort32" - BeginProperty Font - Name = "MS Sans Serif" - Size = 24 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H00800000& - Height = 555 - Left = 915 - TabIndex = 7 - Top = 165 - Width = 3360 - End - Begin VB.Label Label2 - BackColor = &H00FF0000& - Caption = "Value (hex):" - BeginProperty Font - Name = "MS Sans Serif" - Size = 9.75 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H00FFFFFF& - Height = 252 - Left = 360 - TabIndex = 3 - Top = 2652 - Width = 1212 - End - Begin VB.Label Label1 - BackColor = &H00FF0000& - Caption = "Please enter port address (hex):" - BeginProperty Font - Name = "MS Sans Serif" - Size = 9.75 - Charset = 177 - Weight = 400 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - ForeColor = &H00FFFFFF& - Height = 252 - Left = 360 - TabIndex = 2 - Top = 2052 - Width = 2928 - End -End -Attribute VB_Name = "FrmVBDumpPort32" -Attribute VB_GlobalNameSpace = False -Attribute VB_Creatable = False -Attribute VB_PredeclaredId = True -Attribute VB_Exposed = False -Option Explicit -Private Sub BtnGet_Click() - Dim Result As Boolean - Dim PortVal As Long - - Result = GetPortVal(Val("&H" + TxtPortAddr), PortVal, 1) - - If (Result = False) Then - MsgBox "Whoops ! There is a problem with GetPortByte.", vbOKOnly + vbCritical, "VBDumpPort32" - Unload FrmVBDumpPort32 - Else - TxtPortByte = Hex$(PortVal And &HFF) - End If -End Sub -Private Sub BtnQuit_Click() - Unload FrmVBDumpPort32 -End Sub -Private Sub BtnSet_Click() - Dim Result As Boolean - - Result = SetPortVal(Val("&H" + TxtPortAddr), Val("&H" + TxtPortByte), 1) - - If (Result = False) Then - MsgBox "Whoops ! There is a problem with SetPortByte.", vbOKOnly + vbCritical, "VBDumpPort32" - Unload FrmVBDumpPort32 - End If -End Sub -Private Sub Form_Load() - If InitializeWinIo = False Then - MsgBox "Whoops ! There is a problem with InitializeWinIo.", vbOKOnly + vbCritical, "VBDumpPort32" - Unload FrmVBDumpPort32 - Else - Call BtnGet_Click - End If -End Sub -Private Sub Form_Unload(Cancel As Integer) - Call ShutdownWinIo -End Sub -Private Sub TxtPortAddr_KeyPress(KeyAscii As Integer) - If KeyAscii = 13 Then - Call BtnGet_Click - End If -End Sub diff --git a/Examples/VB/VBDumpPort32/VBDumpPort32.vbw b/Examples/VB/VBDumpPort32/VBDumpPort32.vbw deleted file mode 100644 index cdbecce..0000000 --- a/Examples/VB/VBDumpPort32/VBDumpPort32.vbw +++ /dev/null @@ -1,2 +0,0 @@ -FrmVBDumpPort32 = 44, 44, 557, 492, C, 22, 22, 473, 408, C -Module1 = 22, 22, 733, 297, C diff --git a/Examples/VB/VBDumpPort32/WinIo.Bas b/Examples/VB/VBDumpPort32/WinIo.Bas deleted file mode 100644 index 2a67b0e..0000000 --- a/Examples/VB/VBDumpPort32/WinIo.Bas +++ /dev/null @@ -1,12 +0,0 @@ -Attribute VB_Name = "Module1" -Option Explicit -Declare Function MapPhysToLin Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysSize As Long, ByRef PhysMemHandle) As Long -Declare Function UnmapPhysicalMemory Lib "WinIo.dll" (ByVal PhysMemHandle, ByVal LinAddr) As Boolean -Declare Function GetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByRef PhysVal As Long) As Boolean -Declare Function SetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysVal As Long) As Boolean -Declare Function GetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByRef PortVal As Long, ByVal bSize As Byte) As Boolean -Declare Function SetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByVal PortVal As Long, ByVal bSize As Byte) As Boolean -Declare Function InitializeWinIo Lib "WinIo.dll" () As Boolean -Declare Function ShutdownWinIo Lib "WinIo.dll" () As Boolean -Declare Function InstallWinIoDriver Lib "WinIo.dll" (ByVal DriverPath As String, ByVal Mode As Integer) As Boolean -Declare Function RemoveWinIoDriver Lib "WinIo.dll" () As Boolean diff --git a/Samples/DumpPhys/DumpPhys.sln b/Samples/DumpPhys/DumpPhys.sln new file mode 100644 index 0000000..a040e9d --- /dev/null +++ b/Samples/DumpPhys/DumpPhys.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DumpPhys", "DumpPhys\DumpPhys.csproj", "{1103585F-D85D-4599-8858-C0D3E9D7419F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Debug|x86.ActiveCfg = Debug|x86 + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Debug|x86.Build.0 = Debug|x86 + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Release|Any CPU.Build.0 = Release|Any CPU + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Release|x86.ActiveCfg = Release|x86 + {1103585F-D85D-4599-8858-C0D3E9D7419F}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/DumpPhys/DumpPhys.suo b/Samples/DumpPhys/DumpPhys.suo new file mode 100644 index 0000000000000000000000000000000000000000..45ff149b8942b1c3115dc138bce5e44f57cb0570 GIT binary patch literal 24576 zcmeHPUu+yl86PJlG%d9GM}W{KPU5zK)`#6ViQ^=0?7MRkY7;l-Bvy4La?W>-oBPMz zIf>N-0S{2ALE^3D0Rf`Cv{g|>K?13wMDRc*ln8`^5S7{o1bv|(AwYuW`2A*fZfAGz z_SWaKL&;9`?XGuc=KE&m`@Z@9%;nnEwQqgrl}&F8R~Zy5#f|D}vC4SgfoFm&YlK*V z2f~eNwW?kUfyc1Ck7nRK(0UsdZxeuP{Q*^${HtIs;v$cGNz7w*gO`oq7)=G&+poO!^ZtMT@b7PQtVE^P z$p9$hz*rDZiX*_D!BbpZP#*$bH$nqx{JaNjCi$0jC&ZK}i?d=>%;H`V$8k-ACjGwL zq{A+;qT>^&Lm3K+pE{H>#&QDqCgd7q#cA9xh=jy{4)mn()U0g7_$hys$DsJBvq>+D zmQCLIZnyPrzjdb$p!`!0)YAcMNBm|#TK=gY$P?5poFh~I58&@kzz~4)&-SMLQ*TfQ zG?M>M<694)7cdMk@yGG^9zZ`}FJJ($4-f;e-XQLe01g5U1Nbg#-E}{QjKA^Ow;V&= zgjL_SVw*maMqNJN0^TneZ4Mud{bA1w2cysR-;o&E@{dRHX+h<$QF6%5E0iVfRXbAy z$%**bcrrGZD~_L;FWV2}r9v@Xs?4U#$z$nqVXl-)mm{TgSt^=U`}1?zEI9%t9vw)c z_LJ#UrJOuDn?F)WCZ=-5ELt||miQM_*q%HX1(zmk+As~-uRt>-#YyOaJhWp0&k5+N zoG6Mc^a8)d#9U2|Tcu$VJ!XM-3K-AgI)lEC0!IaS3&0#e|4F?=eMX)PLI?H#W-1|+ z81S9OIA$c~62?0P+$nKJj#1U|yLPsq|7qjUR$+1DABOHvgNC!1gMyr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L?y4Ix@!%zP(chjsO z{@X!+iuvZC_;;c1<5tIh`01lJE8KtAqZ0R_p!i2n_j6XqW}KCl7x!arfzg`wkA6!1 zBkd37+=Ak#ovJm6BU3U`DCK(Vr$%-!BsJpG&w+*XqmwR?+*E!xlP*i5b;hQ1u9P1r zr_Q8vQ|0d5Y^qc!7c!OZR3SGoRnA4uF*7K-n~9FodSMgg38-B@4Xf0&K&w^eGYisZ zPYSm$It1Hf9@;AkeSN&CPx=UYS~{O}VYE<(4ndB}gW^6$1ss8iN87pGV=p)a{wNp~Z z%!A5KHO`DKoJ;6Y=v9hHJByf~dGo3Kix>;%k#a&$L}e^>CFRFUn{CH9+a+sBX7CsIJr++y8BySwD%}q~!+JbQ zzGUv$eVW3%LoHMW810<0EQFaF9aM1! z_F4kH+>ef8H_G6NnS?ZUT$Q2KRszS&^TgA#9-{_~>T|bcG21hSj??B~^k58f z!n0sJiCOYPEx!>zrIzPVg5swX>iDxd!L@juqjVp*o5hS_Fq zFF5O&^ak6HmM&BCrO6*$*QYAg%9jf1YBEoUGAVfp<0sS< zVf@6a?drWT<6mL?B#fW<$GN;QieUEYV(mq3H#>dy*5fBjTOn|7_R%HJ4|evN3)8h%0Vq>HyP^zM1iV|JW-sm@;OoVzCVKX4z$xf=fZLjV4x z$N2pTGx^M;+h?MA{-3#Yok784)6$0;I-cyGf8{SQ{0s7*HQc1Zzqb1N7;cw?R18>0 zk3A^#1^lq5F@y@CK zMM9Xp39~o!XzOuE=;8TiC&KKF|NMj=Ug+UD{|~jrpTP5zxiEXPuwN0>k21VJJ-l1P V!q+G7`Tr5NLze1gkpCao|G#P-*t!4! literal 0 HcmV?d00001 diff --git a/Samples/DumpPhys/DumpPhys/DumpPhys.csproj b/Samples/DumpPhys/DumpPhys/DumpPhys.csproj new file mode 100644 index 0000000..f827bce --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/DumpPhys.csproj @@ -0,0 +1,142 @@ + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {1103585F-D85D-4599-8858-C0D3E9D7419F} + WinExe + Properties + DumpPhys + DumpPhys + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + DumpPhys.manifest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + true + bin\x86\Debug\ + DEBUG;TRACE + true + full + x86 + prompt + + + bin\x86\Release\ + TRACE + true + true + pdbonly + x86 + prompt + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + + + + + \ No newline at end of file diff --git a/Samples/DumpPhys/DumpPhys/DumpPhys.manifest b/Samples/DumpPhys/DumpPhys/DumpPhys.manifest new file mode 100644 index 0000000..90b09a9 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/DumpPhys.manifest @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Samples/DumpPhys/DumpPhys/Form1.Designer.cs b/Samples/DumpPhys/DumpPhys/Form1.Designer.cs new file mode 100644 index 0000000..efe5584 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Form1.Designer.cs @@ -0,0 +1,174 @@ +namespace DumpPhys +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.btnGetValue = new System.Windows.Forms.Button(); + this.btnSetValue = new System.Windows.Forms.Button(); + this.btnQuit = new System.Windows.Forms.Button(); + this.txtPhysAddr = new System.Windows.Forms.TextBox(); + this.txtValue = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(30, 138); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(176, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Please enter physical address (hex):"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(30, 167); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(63, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Value (hex):"; + // + // btnGetValue + // + this.btnGetValue.Location = new System.Drawing.Point(32, 231); + this.btnGetValue.Name = "btnGetValue"; + this.btnGetValue.Size = new System.Drawing.Size(75, 23); + this.btnGetValue.TabIndex = 2; + this.btnGetValue.Text = "Get Value"; + this.btnGetValue.UseVisualStyleBackColor = true; + this.btnGetValue.Click += new System.EventHandler(this.btnGetValue_Click); + // + // btnSetValue + // + this.btnSetValue.Location = new System.Drawing.Point(138, 231); + this.btnSetValue.Name = "btnSetValue"; + this.btnSetValue.Size = new System.Drawing.Size(75, 23); + this.btnSetValue.TabIndex = 3; + this.btnSetValue.Text = "Set Value"; + this.btnSetValue.UseVisualStyleBackColor = true; + this.btnSetValue.Click += new System.EventHandler(this.btnSetValue_Click); + // + // btnQuit + // + this.btnQuit.Location = new System.Drawing.Point(244, 231); + this.btnQuit.Name = "btnQuit"; + this.btnQuit.Size = new System.Drawing.Size(75, 23); + this.btnQuit.TabIndex = 4; + this.btnQuit.Text = "Quit"; + this.btnQuit.UseVisualStyleBackColor = true; + this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click); + // + // txtPhysAddr + // + this.txtPhysAddr.Location = new System.Drawing.Point(212, 135); + this.txtPhysAddr.Name = "txtPhysAddr"; + this.txtPhysAddr.Size = new System.Drawing.Size(108, 20); + this.txtPhysAddr.TabIndex = 5; + // + // txtValue + // + this.txtValue.Location = new System.Drawing.Point(99, 164); + this.txtValue.MaxLength = 8; + this.txtValue.Name = "txtValue"; + this.txtValue.Size = new System.Drawing.Size(59, 20); + this.txtValue.TabIndex = 6; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(81, 22); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(188, 39); + this.label3.TabIndex = 7; + this.label3.Text = "DumpPhys"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(63, 73); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(225, 16); + this.label4.TabIndex = 8; + this.label4.Text = "Copyright 1998-2010 by Yariv Kaplan"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(117, 102); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(117, 16); + this.label5.TabIndex = 9; + this.label5.Text = "www.internals.com"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(350, 272); + this.ControlBox = false; + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.txtValue); + this.Controls.Add(this.txtPhysAddr); + this.Controls.Add(this.btnQuit); + this.Controls.Add(this.btnSetValue); + this.Controls.Add(this.btnGetValue); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "Form1"; + this.Text = "DumpPhys - www.internals.com"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnGetValue; + private System.Windows.Forms.Button btnSetValue; + private System.Windows.Forms.Button btnQuit; + private System.Windows.Forms.TextBox txtPhysAddr; + private System.Windows.Forms.TextBox txtValue; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + } +} + diff --git a/Samples/DumpPhys/DumpPhys/Form1.cs b/Samples/DumpPhys/DumpPhys/Form1.cs new file mode 100644 index 0000000..1a06c81 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Form1.cs @@ -0,0 +1,157 @@ +// ---------------------------------------------------- // +// WinIo v3.0 // +// Direct Hardware Access Under Windows // +// Copyright 1998-2010 Yariv Kaplan // +// http://www.internals.com // +// ---------------------------------------------------- // + +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; +using System.Diagnostics; + +namespace DumpPhys +{ + public unsafe partial class Form1 : Form + { + [DllImport("kernel32.dll")] + private extern static IntPtr LoadLibrary(String DllName); + + [DllImport("kernel32.dll")] + private extern static IntPtr GetProcAddress(IntPtr hModule, String ProcName); + + [DllImport("kernel32")] + private extern static bool FreeLibrary(IntPtr hModule); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool InitializeWinIoType(); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool GetPhysLongType(IntPtr PhysAddr, UInt32 *pPhysVal); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool SetPhysLongType(IntPtr PhysAddr, UInt32 PhysVal); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool ShutdownWinIoType(); + + IntPtr hMod; + + public Form1() + { + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + // Check if this is a 32 bit or 64 bit system + if (IntPtr.Size == 4) + { + hMod = LoadLibrary("WinIo32.dll"); + txtPhysAddr.MaxLength = 8; + txtPhysAddr.Text = "00000000"; + + } + else if (IntPtr.Size == 8) + { + hMod = LoadLibrary("WinIo64.dll"); + txtPhysAddr.MaxLength = 16; + txtPhysAddr.Text = "0000000000000000"; + } + + if (hMod == IntPtr.Zero) + { + MessageBox.Show("Can't find WinIo dll.\nMake sure the WinIo library files are located in the same directory as your executable file.", "DumpPhys", MessageBoxButtons.OK, MessageBoxIcon.Error); + this.Close(); + } + + IntPtr pFunc = GetProcAddress(hMod, "InitializeWinIo"); + + if (pFunc != IntPtr.Zero) + { + InitializeWinIoType InitializeWinIo = (InitializeWinIoType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(InitializeWinIoType)); + bool Result = InitializeWinIo(); + + if (!Result) + { + MessageBox.Show("Error returned from InitializeWinIo.\nMake sure you are running with administrative privileges and that the WinIo library files are located in the same directory as your executable file.", "DumpPhys", MessageBoxButtons.OK, MessageBoxIcon.Error); + FreeLibrary(hMod); + this.Close(); + } + } + + btnGetValue_Click(this, null); + } + + private void btnGetValue_Click(object sender, EventArgs e) + { + IntPtr pFunc = GetProcAddress(hMod, "GetPhysLong"); + + if (pFunc != IntPtr.Zero) + { + UInt32 PhysVal; + UInt64 PhysAddr64; + + PhysAddr64 = UInt64.Parse(txtPhysAddr.Text, System.Globalization.NumberStyles.HexNumber); + + GetPhysLongType GetPhysLong = (GetPhysLongType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(GetPhysLongType)); + + // Call WinIo to get value + bool Result = GetPhysLong((IntPtr)PhysAddr64, &PhysVal); + + if (Result) + { + txtValue.Text = PhysVal.ToString("X"); + } + else + { + MessageBox.Show("Error returned from GetPhysLong", "DumpPhys", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void btnQuit_Click(object sender, EventArgs e) + { + IntPtr pFunc = GetProcAddress(hMod, "ShutdownWinIo"); + + if (pFunc != IntPtr.Zero) + { + ShutdownWinIoType ShutdownWinIo = (ShutdownWinIoType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(ShutdownWinIoType)); + + ShutdownWinIo(); + FreeLibrary(hMod); + } + + this.Close(); + } + + private void btnSetValue_Click(object sender, EventArgs e) + { + IntPtr pFunc = GetProcAddress(hMod, "SetPhysLong"); + + if (pFunc != IntPtr.Zero) + { + UInt32 PhysVal; + UInt64 PhysAddr64; + + PhysAddr64 = UInt64.Parse(txtPhysAddr.Text, System.Globalization.NumberStyles.HexNumber); + PhysVal = UInt32.Parse(txtValue.Text, System.Globalization.NumberStyles.HexNumber); + + SetPhysLongType SetPhysLong = (SetPhysLongType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(SetPhysLongType)); + + // Call WinIo to set value + bool Result = SetPhysLong((IntPtr)PhysAddr64, PhysVal); + + if (!Result) + { + MessageBox.Show("Error returned from SetPhysLong", "DumpPhys", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} \ No newline at end of file diff --git a/Samples/DumpPhys/DumpPhys/Form1.resx b/Samples/DumpPhys/DumpPhys/Form1.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/DumpPhys/DumpPhys/Program.cs b/Samples/DumpPhys/DumpPhys/Program.cs new file mode 100644 index 0000000..3d2fe94 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace DumpPhys +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Samples/DumpPhys/DumpPhys/Properties/AssemblyInfo.cs b/Samples/DumpPhys/DumpPhys/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..348db56 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DumpPhys")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("www.internals.com")] +[assembly: AssemblyProduct("DumpPhys")] +[assembly: AssemblyCopyright("Copyright © Yariv Kaplan 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("16fd1afb-d769-4e14-89ba-eef3670c272b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Samples/DumpPhys/DumpPhys/Properties/Resources.Designer.cs b/Samples/DumpPhys/DumpPhys/Properties/Resources.Designer.cs new file mode 100644 index 0000000..a415ff5 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DumpPhys.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DumpPhys.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Samples/DumpPhys/DumpPhys/Properties/Resources.resx b/Samples/DumpPhys/DumpPhys/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/DumpPhys/DumpPhys/Properties/Settings.Designer.cs b/Samples/DumpPhys/DumpPhys/Properties/Settings.Designer.cs new file mode 100644 index 0000000..9886174 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DumpPhys.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Samples/DumpPhys/DumpPhys/Properties/Settings.settings b/Samples/DumpPhys/DumpPhys/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/Samples/DumpPhys/DumpPhys/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Samples/DumpPort/DumpPort.sln b/Samples/DumpPort/DumpPort.sln new file mode 100644 index 0000000..e28bb05 --- /dev/null +++ b/Samples/DumpPort/DumpPort.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DumpPort", "DumpPort\DumpPort.csproj", "{8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Debug|x86.ActiveCfg = Debug|x86 + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Debug|x86.Build.0 = Debug|x86 + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Release|Any CPU.Build.0 = Release|Any CPU + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Release|x86.ActiveCfg = Release|x86 + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/DumpPort/DumpPort.suo b/Samples/DumpPort/DumpPort.suo new file mode 100644 index 0000000000000000000000000000000000000000..0ca98e7b66a28fe0a016e7c2cc61a5b80c3ae3b7 GIT binary patch literal 13824 zcmeI2TWp+1701W9HEE%xO-M^<6O*KApvhtWAECI!ET(aa{)FKXT5eEuP@qN zC$V}_)tB-B2%$<;NR>be4@3ymmr5YD%Kg>0tuOK=)`gLVzF<~;YyCTZzkgr77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GqfmW>B7&ydh_8X7wmhUfNNFN2M#8?zYu8yx>JW_{Swo@C5fxao!)*&oe9+0U!T zhw^{QvB^S5wf{l-;S54`PC@+Skj++PRNk^Yf>HPse_mR(nVpR!ZwsU6biw(8wKE>u zvDV69kHew#aUA{>Pqy$A$GSFxv)8qIFCMz$$$`JG+V%C{|MW`l>-&ED$Q%9V-hCBk zsHZa--%Gd7vQ%ntPzOVKsIGhd5;HdJqoj$KNxsJoD7gg^)TaQCuUCE9|rT;W-ca}Qvd48Y&PhuHdHceh} zy#06fHf n?~2g59T?v^U3b| z9Z=p#kLv;~dY z`nurwk9^0K7H{gVp8BjmP_S8G#f08pkybd5Ckt1{@t8+Sb|Zt7x(LljRgy@ZCl1?o zk{Xv)oe+@<$m9xRB4UpbS7UrJ%2btc3;*oT5rKUXi-6X%}Bb^1~1H?*B;b? z94OYjXeDrj^>JII#;On3c@AM6Yw7V zD^HBC)Jbp2$ioMxZ1H4VN?&^{UUFp@r;!_F{^Xg>+6>DeUv)4R8#LIn$V1r1{nk?Y zC!Giilv!|m$jkP6W~=N)^)9Z+;ByB3%VJTX&XkSFQ>Dl-72>ygc4G9QekA)YniQF8 zDqc5KD^M1&dKTryXeS<_M{nnQI{SKcuDMie8T9bvafx2f64G-vf0_|0Zd24D->!qJ zVsd4DweG#lgZ>fVBuhN$tZq5xAiN8eInd6vR2;Zj@nuszDGOd31&R> z52|w9*(m?3{Plc5{;f$-v!dIm`KL>?eXZ1SBl + + Debug + AnyCPU + 9.0.21022 + 2.0 + {8E2C04F3-BDE2-49A4-8736-DE12944D5DDF} + WinExe + Properties + DumpPort + DumpPort + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + DumpPort.manifest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + true + bin\x86\Debug\ + DEBUG;TRACE + true + full + x86 + prompt + + + bin\x86\Release\ + TRACE + true + true + pdbonly + x86 + prompt + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + + + + + \ No newline at end of file diff --git a/Samples/DumpPort/DumpPort/DumpPort.manifest b/Samples/DumpPort/DumpPort/DumpPort.manifest new file mode 100644 index 0000000..90b09a9 --- /dev/null +++ b/Samples/DumpPort/DumpPort/DumpPort.manifest @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Samples/DumpPort/DumpPort/Form1.Designer.cs b/Samples/DumpPort/DumpPort/Form1.Designer.cs new file mode 100644 index 0000000..0153f06 --- /dev/null +++ b/Samples/DumpPort/DumpPort/Form1.Designer.cs @@ -0,0 +1,176 @@ +namespace DumpPort +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnGetValue = new System.Windows.Forms.Button(); + this.btnSetValue = new System.Windows.Forms.Button(); + this.btnQuit = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.txtPortAddr = new System.Windows.Forms.TextBox(); + this.txtValue = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btnGetValue + // + this.btnGetValue.Location = new System.Drawing.Point(32, 220); + this.btnGetValue.Name = "btnGetValue"; + this.btnGetValue.Size = new System.Drawing.Size(75, 23); + this.btnGetValue.TabIndex = 0; + this.btnGetValue.Text = "Get Value"; + this.btnGetValue.UseVisualStyleBackColor = true; + this.btnGetValue.Click += new System.EventHandler(this.btnGetValue_Click); + // + // btnSetValue + // + this.btnSetValue.Location = new System.Drawing.Point(137, 220); + this.btnSetValue.Name = "btnSetValue"; + this.btnSetValue.Size = new System.Drawing.Size(75, 23); + this.btnSetValue.TabIndex = 1; + this.btnSetValue.Text = "Set Value"; + this.btnSetValue.UseVisualStyleBackColor = true; + this.btnSetValue.Click += new System.EventHandler(this.btnSetValue_Click); + // + // btnQuit + // + this.btnQuit.Location = new System.Drawing.Point(242, 220); + this.btnQuit.Name = "btnQuit"; + this.btnQuit.Size = new System.Drawing.Size(75, 23); + this.btnQuit.TabIndex = 2; + this.btnQuit.Text = "Quit"; + this.btnQuit.UseVisualStyleBackColor = true; + this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(44, 140); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(156, 13); + this.label1.TabIndex = 3; + this.label1.Text = "Please enter port address (hex):"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(44, 170); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(63, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Value (hex):"; + // + // txtPortAddr + // + this.txtPortAddr.Location = new System.Drawing.Point(206, 137); + this.txtPortAddr.MaxLength = 4; + this.txtPortAddr.Name = "txtPortAddr"; + this.txtPortAddr.Size = new System.Drawing.Size(36, 20); + this.txtPortAddr.TabIndex = 5; + this.txtPortAddr.Text = "0"; + // + // txtValue + // + this.txtValue.Location = new System.Drawing.Point(113, 167); + this.txtValue.MaxLength = 2; + this.txtValue.Name = "txtValue"; + this.txtValue.Size = new System.Drawing.Size(23, 20); + this.txtValue.TabIndex = 6; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(87, 19); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(174, 39); + this.label3.TabIndex = 7; + this.label3.Text = "DumpPort"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(62, 69); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(225, 16); + this.label4.TabIndex = 8; + this.label4.Text = "Copyright 1998-2010 by Yariv Kaplan"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(116, 97); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(117, 16); + this.label5.TabIndex = 9; + this.label5.Text = "www.internals.com"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(348, 263); + this.ControlBox = false; + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.txtValue); + this.Controls.Add(this.txtPortAddr); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnQuit); + this.Controls.Add(this.btnSetValue); + this.Controls.Add(this.btnGetValue); + this.Name = "Form1"; + this.Text = "DumpPort - www.internals.com"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnGetValue; + private System.Windows.Forms.Button btnSetValue; + private System.Windows.Forms.Button btnQuit; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtPortAddr; + private System.Windows.Forms.TextBox txtValue; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + } +} + diff --git a/Samples/DumpPort/DumpPort/Form1.cs b/Samples/DumpPort/DumpPort/Form1.cs new file mode 100644 index 0000000..0f906e8 --- /dev/null +++ b/Samples/DumpPort/DumpPort/Form1.cs @@ -0,0 +1,154 @@ +// ---------------------------------------------------- // +// WinIo v3.0 // +// Direct Hardware Access Under Windows // +// Copyright 1998-2010 Yariv Kaplan // +// http://www.internals.com // +// ---------------------------------------------------- // + +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; +using System.Diagnostics; + + +namespace DumpPort +{ + public unsafe partial class Form1 : Form + { + [DllImport("kernel32.dll")] + private extern static IntPtr LoadLibrary(String DllName); + + [DllImport("kernel32.dll")] + private extern static IntPtr GetProcAddress(IntPtr hModule, String ProcName); + + [DllImport("kernel32")] + private extern static bool FreeLibrary(IntPtr hModule); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool InitializeWinIoType(); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool GetPortValType(UInt16 PortAddr, UInt32* pPortVal, UInt16 Size); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool SetPortValType(UInt16 PortAddr, UInt32 PortVal, UInt16 Size); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool ShutdownWinIoType(); + + IntPtr hMod; + + public Form1() + { + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + // Check if this is a 32 bit or 64 bit system + if (IntPtr.Size == 4) + { + hMod = LoadLibrary("WinIo32.dll"); + + } + else if (IntPtr.Size == 8) + { + hMod = LoadLibrary("WinIo64.dll"); + } + + if (hMod == IntPtr.Zero) + { + MessageBox.Show("Can't find WinIo dll.\nMake sure the WinIo library files are located in the same directory as your executable file.", "DumpPort", MessageBoxButtons.OK, MessageBoxIcon.Error); + this.Close(); + } + + IntPtr pFunc = GetProcAddress(hMod, "InitializeWinIo"); + + if (pFunc != IntPtr.Zero) + { + InitializeWinIoType InitializeWinIo = (InitializeWinIoType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(InitializeWinIoType)); + bool Result = InitializeWinIo(); + + if (!Result) + { + MessageBox.Show("Error returned from InitializeWinIo.\nMake sure you are running with administrative privileges and that the WinIo library files are located in the same directory as your executable file.", "DumpPort", MessageBoxButtons.OK, MessageBoxIcon.Error); + FreeLibrary(hMod); + this.Close(); + } + } + + btnGetValue_Click(this, null); + } + + private void btnQuit_Click(object sender, EventArgs e) + { + IntPtr pFunc = GetProcAddress(hMod, "ShutdownWinIo"); + + if (pFunc != IntPtr.Zero) + { + ShutdownWinIoType ShutdownWinIo = (ShutdownWinIoType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(ShutdownWinIoType)); + + ShutdownWinIo(); + FreeLibrary(hMod); + } + + this.Close(); + } + + private void btnGetValue_Click(object sender, EventArgs e) + { + IntPtr pFunc = GetProcAddress(hMod, "GetPortVal"); + + if (pFunc != IntPtr.Zero) + { + UInt16 PortAddr; + UInt32 PortVal; + + PortAddr = UInt16.Parse(txtPortAddr.Text, System.Globalization.NumberStyles.HexNumber); + + GetPortValType GetPortVal = (GetPortValType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(GetPortValType)); + + // Call WinIo to get value + bool Result = GetPortVal(PortAddr, &PortVal, 1); + + if (Result) + { + txtValue.Text = PortVal.ToString("X"); + } + else + { + MessageBox.Show("Error returned from GetPortVal", "DumpPort", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void btnSetValue_Click(object sender, EventArgs e) + { + IntPtr pFunc = GetProcAddress(hMod, "SetPortVal"); + + if (pFunc != IntPtr.Zero) + { + UInt16 PortAddr; + UInt32 PortVal; + + PortAddr = UInt16.Parse(txtPortAddr.Text, System.Globalization.NumberStyles.HexNumber); + PortVal = UInt32.Parse(txtValue.Text, System.Globalization.NumberStyles.HexNumber); + + SetPortValType SetPortVal = (SetPortValType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(SetPortValType)); + + // Call WinIo to set value + bool Result = SetPortVal(PortAddr, PortVal, 1 ); + + if (!Result) + { + MessageBox.Show("Error returned from SetPortVal", "DumpPort", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} \ No newline at end of file diff --git a/Samples/DumpPort/DumpPort/Form1.resx b/Samples/DumpPort/DumpPort/Form1.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Samples/DumpPort/DumpPort/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/DumpPort/DumpPort/Program.cs b/Samples/DumpPort/DumpPort/Program.cs new file mode 100644 index 0000000..8773ce8 --- /dev/null +++ b/Samples/DumpPort/DumpPort/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace DumpPort +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Samples/DumpPort/DumpPort/Properties/AssemblyInfo.cs b/Samples/DumpPort/DumpPort/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9f5d056 --- /dev/null +++ b/Samples/DumpPort/DumpPort/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DumpPort")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("www.internals.com")] +[assembly: AssemblyProduct("DumpPort")] +[assembly: AssemblyCopyright("Copyright © Yariv Kaplan 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e4aa10c8-3c4e-4ea5-8461-4da84bf602f5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Samples/DumpPort/DumpPort/Properties/Resources.Designer.cs b/Samples/DumpPort/DumpPort/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c469264 --- /dev/null +++ b/Samples/DumpPort/DumpPort/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DumpPort.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DumpPort.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Samples/DumpPort/DumpPort/Properties/Resources.resx b/Samples/DumpPort/DumpPort/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/Samples/DumpPort/DumpPort/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/DumpPort/DumpPort/Properties/Settings.Designer.cs b/Samples/DumpPort/DumpPort/Properties/Settings.Designer.cs new file mode 100644 index 0000000..61893fd --- /dev/null +++ b/Samples/DumpPort/DumpPort/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DumpPort.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Samples/DumpPort/DumpPort/Properties/Settings.settings b/Samples/DumpPort/DumpPort/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/Samples/DumpPort/DumpPort/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Source/Dll/InstDrv.cpp b/Source/Dll/InstDrv.cpp index c65d70c..1eae4fe 100644 --- a/Source/Dll/InstDrv.cpp +++ b/Source/Dll/InstDrv.cpp @@ -1,146 +1,166 @@ // ---------------------------------------------------- // -// WinIo v2.0 // -// Direct Hardware Access Under Windows 9x/NT/2000/XP // -// Copyright 1998-2002 Yariv Kaplan // +// WinIo v3.0 // +// Direct Hardware Access Under Windows // +// Copyright 1998-2010 Yariv Kaplan // // http://www.internals.com // // ---------------------------------------------------- // #include #include "winio.h" -bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded) +bool _stdcall InstallWinIoDriver(PWSTR pszWinIoDriverPath, bool IsDemandLoaded) { - SC_HANDLE hSCManager; - SC_HANDLE hService; - - // Remove any previous instance of the driver - - RemoveWinIoDriver(); - - hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - - if (hSCManager) - { - // Install the driver - - hService = CreateService(hSCManager, - "WINIO", - "WINIO", - SERVICE_ALL_ACCESS, - SERVICE_KERNEL_DRIVER, - (IsDemandLoaded == true) ? SERVICE_DEMAND_START : SERVICE_SYSTEM_START, - SERVICE_ERROR_NORMAL, - pszWinIoDriverPath, - NULL, - NULL, - NULL, - NULL, - NULL); - - CloseServiceHandle(hSCManager); - - if (hService == NULL) - return false; - } - else - return false; - - CloseServiceHandle(hService); - - return true; -} + SC_HANDLE hSCManager; + SC_HANDLE hService; + // Remove any previous instance of the driver -bool _stdcall RemoveWinIoDriver() -{ - SC_HANDLE hSCManager; - SC_HANDLE hService; - bool bResult; + RemoveWinIoDriver(); + + hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + + if (hSCManager) + { + // Install the driver + + hService = CreateService(hSCManager, + L"WINIO", + L"WINIO", + SERVICE_ALL_ACCESS, + SERVICE_KERNEL_DRIVER, + (IsDemandLoaded == true) ? SERVICE_DEMAND_START : SERVICE_SYSTEM_START, + SERVICE_ERROR_NORMAL, + pszWinIoDriverPath, + NULL, + NULL, + NULL, + NULL, + NULL); - StopWinIoDriver(); + CloseServiceHandle(hSCManager); - hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (hService == NULL) + return false; + } + else + return false; - if (hSCManager) - { - hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS); + CloseServiceHandle(hService); - CloseServiceHandle(hSCManager); + return true; +} - if (hService) - { - bResult = DeleteService(hService); - - CloseServiceHandle(hService); - } - else - return false; - } - else - return false; - return bResult; +bool _stdcall RemoveWinIoDriver() +{ + SC_HANDLE hSCManager; + SC_HANDLE hService; + LPQUERY_SERVICE_CONFIG pServiceConfig; + DWORD dwBytesNeeded; + DWORD cbBufSize; + bool bResult; + + StopWinIoDriver(); + + hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + + if (!hSCManager) + { + return false; + } + + hService = OpenService(hSCManager, L"WINIO", SERVICE_ALL_ACCESS); + CloseServiceHandle(hSCManager); + + if (!hService) + { + return false; + } + + bResult = QueryServiceConfig(hService, NULL, 0, &dwBytesNeeded); + + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + cbBufSize = dwBytesNeeded; + pServiceConfig = (LPQUERY_SERVICE_CONFIG)malloc(cbBufSize); + bResult = QueryServiceConfig(hService, pServiceConfig, cbBufSize, &dwBytesNeeded); + + if (!bResult) + { + free(pServiceConfig); + CloseServiceHandle(hService); + return bResult; + } + + // If service is set to load automatically, don't delete it! + if (pServiceConfig->dwStartType == SERVICE_DEMAND_START) + { + bResult = DeleteService(hService); + } + } + + CloseServiceHandle(hService); + + return bResult; } bool _stdcall StartWinIoDriver() { - SC_HANDLE hSCManager; - SC_HANDLE hService; - bool bResult; + SC_HANDLE hSCManager; + SC_HANDLE hService; + bool bResult; - hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (hSCManager) - { - hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS); + if (hSCManager) + { + hService = OpenService(hSCManager, L"WINIO", SERVICE_ALL_ACCESS); - CloseServiceHandle(hSCManager); + CloseServiceHandle(hSCManager); - if (hService) - { - bResult = StartService(hService, 0, NULL) || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING; + if (hService) + { + bResult = StartService(hService, 0, NULL) || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING; - CloseServiceHandle(hService); - } - else - return false; - } - else - return false; + CloseServiceHandle(hService); + } + else + return false; + } + else + return false; - return bResult; + return bResult; } bool _stdcall StopWinIoDriver() { - SC_HANDLE hSCManager; - SC_HANDLE hService; - SERVICE_STATUS ServiceStatus; - bool bResult; + SC_HANDLE hSCManager; + SC_HANDLE hService; + SERVICE_STATUS ServiceStatus; + bool bResult; - hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (hSCManager) - { - hService = OpenService(hSCManager, "WINIO", SERVICE_ALL_ACCESS); + if (hSCManager) + { + hService = OpenService(hSCManager, L"WINIO", SERVICE_ALL_ACCESS); - CloseServiceHandle(hSCManager); + CloseServiceHandle(hSCManager); - if (hService) - { - bResult = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus); - - CloseServiceHandle(hService); - } - else - return false; - } - else - return false; - - return bResult; -} + if (hService) + { + bResult = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus); + CloseServiceHandle(hService); + } + else + return false; + } + else + return false; + return bResult; +} \ No newline at end of file diff --git a/Source/Dll/K32Call.h b/Source/Dll/K32Call.h deleted file mode 100644 index 92fb1ea..0000000 --- a/Source/Dll/K32Call.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef K32CALL_H -#define K32CALL_H - -extern "C" -{ - DWORD WINAPI GetK32ProcAddress(int ord); -} - -#endif diff --git a/Source/Dll/Phys32.cpp b/Source/Dll/Phys32.cpp index 2571081..4117643 100644 --- a/Source/Dll/Phys32.cpp +++ b/Source/Dll/Phys32.cpp @@ -1,142 +1,117 @@ // ---------------------------------------------------- // -// WinIo v2.0 // -// Direct Hardware Access Under Windows 9x/NT/2000/XP // -// Copyright 1998-2002 Yariv Kaplan // +// WinIo v3.0 // +// Direct Hardware Access Under Windows // +// Copyright 1998-2010 Yariv Kaplan // // http://www.internals.com // // ---------------------------------------------------- // #include #include #include "phys32.h" -#include "..\drv\nt\winio_nt.h" +#include "..\drv\winio_nt.h" #include "winio.h" -// VWIN32 DPMI services -#define VWIN32_DPMI_CALL 0x2A0029 - -// KERNEL32's undocumented VxDCall function is exported as ordinal #1 - -DWORD (WINAPI *VxDCall)(DWORD Service, DWORD EAX_Reg, DWORD ECX_Reg); +PBYTE _stdcall MapPhysToLin(tagPhysStruct &PhysStruct) +{ + PBYTE pbLinAddr = NULL; + DWORD dwBytesReturned; -#define DPMICall(EAX_Reg, ECX_Reg) VxDCall(VWIN32_DPMI_CALL, EAX_Reg, ECX_Reg) + if (!IsWinIoInitialized) + return false; + if (!DeviceIoControl(hDriver, IOCTL_WINIO_MAPPHYSTOLIN, &PhysStruct, + sizeof(tagPhysStruct), &PhysStruct, sizeof(tagPhysStruct), + &dwBytesReturned, NULL)) + { + return NULL; + } -PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle) -{ - PBYTE pbLinAddr; - tagPhys32Struct Phys32Struct; - DWORD dwBytesReturned; - - if (!IsWinIoInitialized) - return false; - - if (IsNT) - { - Phys32Struct.dwPhysMemSizeInBytes = dwPhysSize; - Phys32Struct.pvPhysAddress = pbPhysAddr; - - if (!DeviceIoControl(hDriver, IOCTL_WINIO_MAPPHYSTOLIN, &Phys32Struct, - sizeof(tagPhys32Struct), &Phys32Struct, sizeof(tagPhys32Struct), - &dwBytesReturned, NULL)) - return NULL; - else - { - pbLinAddr = (PBYTE)((DWORD)Phys32Struct.pvPhysMemLin + (DWORD)pbPhysAddr - (DWORD)Phys32Struct.pvPhysAddress); - *pPhysicalMemoryHandle = Phys32Struct.PhysicalMemoryHandle; - } - } - else - { - _asm - { - Mov BX, WORD PTR [pbPhysAddr + 2] - Mov CX, WORD PTR [pbPhysAddr] - Mov SI, WORD PTR [dwPhysSize + 2] - Mov DI, WORD PTR [dwPhysSize] - } - - // Call DPMI function MapPhysicalToLinear - - DPMICall(0x800, (DWORD)pbPhysAddr); - - _asm - { - Jnc Success - Xor BX, BX - Xor CX, CX - - Success: - - Mov WORD PTR [pbLinAddr + 2], BX - Mov WORD PTR [pbLinAddr], CX - } - } - - return pbLinAddr; + return (PBYTE)PhysStruct.pvPhysMemLin; } -bool _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr) +bool _stdcall UnmapPhysicalMemory(tagPhysStruct &PhysStruct) { - tagPhys32Struct Phys32Struct; - DWORD dwBytesReturned; - - if (IsNT) - { - if (!IsWinIoInitialized) - return false; + DWORD dwBytesReturned; - Phys32Struct.PhysicalMemoryHandle = PhysicalMemoryHandle; - Phys32Struct.pvPhysMemLin = pbLinAddr; + if (!IsWinIoInitialized) + { + return false; + } - if (!DeviceIoControl(hDriver, IOCTL_WINIO_UNMAPPHYSADDR, &Phys32Struct, - sizeof(tagPhys32Struct), NULL, 0, &dwBytesReturned, NULL)) - return false; - } + if (!DeviceIoControl(hDriver, IOCTL_WINIO_UNMAPPHYSADDR, &PhysStruct, + sizeof(tagPhysStruct), NULL, 0, &dwBytesReturned, NULL)) + { + return false; + } - return true; + return true; } -// Support functions for Visual-Basic users +// Support functions bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal) { - PDWORD pdwLinAddr; - HANDLE PhysicalMemoryHandle; + PDWORD pdwLinAddr; + tagPhysStruct PhysStruct; - if (!IsWinIoInitialized) - return false; + if (!IsWinIoInitialized) + return false; - pdwLinAddr = (PDWORD)MapPhysToLin(pbPhysAddr, 4, &PhysicalMemoryHandle); + if (g_Is64BitOS) + { + PhysStruct.pvPhysAddress = (DWORD64)pbPhysAddr; + } + else + { + // Avoid sign extension issues + PhysStruct.pvPhysAddress = (DWORD64)(DWORD32)pbPhysAddr; + } - if (pdwLinAddr == NULL) - return false; + PhysStruct.dwPhysMemSizeInBytes = 4; - *pdwPhysVal = *pdwLinAddr; + pdwLinAddr = (PDWORD)MapPhysToLin(PhysStruct); - UnmapPhysicalMemory(PhysicalMemoryHandle, (PBYTE)pdwLinAddr); + if (pdwLinAddr == NULL) + return false; - return true; + *pdwPhysVal = *pdwLinAddr; + + UnmapPhysicalMemory(PhysStruct); + + return true; } bool _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal) { - PDWORD pdwLinAddr; - HANDLE PhysicalMemoryHandle; + PDWORD pdwLinAddr; + tagPhysStruct PhysStruct; + + if (!IsWinIoInitialized) + return false; + + if (g_Is64BitOS) + { + PhysStruct.pvPhysAddress = (DWORD64)pbPhysAddr; + } + else + { + // Avoid sign extension issues + PhysStruct.pvPhysAddress = (DWORD64)(DWORD32)pbPhysAddr; + } - if (!IsWinIoInitialized) - return false; + PhysStruct.dwPhysMemSizeInBytes = 4; - pdwLinAddr = (PDWORD)MapPhysToLin(pbPhysAddr, 4, &PhysicalMemoryHandle); + pdwLinAddr = (PDWORD)MapPhysToLin(PhysStruct); - if (pdwLinAddr == NULL) - return false; + if (pdwLinAddr == NULL) + return false; - *pdwLinAddr = dwPhysVal; + *pdwLinAddr = dwPhysVal; - UnmapPhysicalMemory(PhysicalMemoryHandle, (PBYTE)pdwLinAddr); + UnmapPhysicalMemory(PhysStruct); - return true; + return true; } diff --git a/Source/Dll/Port32.cpp b/Source/Dll/Port32.cpp index 8e887e6..d347e26 100644 --- a/Source/Dll/Port32.cpp +++ b/Source/Dll/Port32.cpp @@ -1,7 +1,7 @@ // ---------------------------------------------------- // -// WinIo v2.0 // -// Direct Hardware Access Under Windows 9x/NT/2000/XP // -// Copyright 1998-2002 Yariv Kaplan // +// WinIo v3.0 // +// Direct Hardware Access Under Windows // +// Copyright 1998-2010 Yariv Kaplan // // http://www.internals.com // // ---------------------------------------------------- // @@ -9,95 +9,125 @@ #include #include #include "port32.h" -#include "..\drv\nt\winio_nt.h" -#include "..\drv\9x\winio_9x.h" +#include "..\drv\winio_nt.h" #include "winio.h" bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize) { - tagPort32Struct Port32Struct; - DWORD dwBytesReturned; - - if (!IsWinIoInitialized) - return false; + if (!IsWinIoInitialized) + { + return false; + } - if (IsNT) - { - switch (bSize) - { - case 1: +#ifdef _WIN64 + tagPortStruct PortStruct; + DWORD dwBytesReturned; - *pdwPortVal = _inp(wPortAddr); + PortStruct.bSize = bSize; + PortStruct.wPortAddr = wPortAddr; - break; + return DeviceIoControl(hDriver, IOCTL_WINIO_READPORT, &PortStruct, sizeof(PortStruct), + pdwPortVal, sizeof(DWORD), &dwBytesReturned, NULL); - case 2: - *pdwPortVal = _inpw(wPortAddr); +#elif _WIN32 + // If this is a 64 bit OS, we must use the driver to access I/O ports even if the application is 32 bit + if (g_Is64BitOS) + { + tagPortStruct PortStruct; + DWORD dwBytesReturned; - break; + PortStruct.bSize = bSize; + PortStruct.wPortAddr = wPortAddr; - case 4: + return DeviceIoControl(hDriver, IOCTL_WINIO_READPORT, &PortStruct, sizeof(PortStruct), + pdwPortVal, sizeof(DWORD), &dwBytesReturned, NULL); + } + else + { + switch (bSize) + { + case 1: - *pdwPortVal = _inpd(wPortAddr); + *pdwPortVal = _inp(wPortAddr); - break; - } - } - else - { - Port32Struct.bSize = bSize; - Port32Struct.wPortAddr = wPortAddr; - - return DeviceIoControl(hDriver, WINIO_READPORT, &Port32Struct, sizeof(Port32Struct), - pdwPortVal, sizeof(DWORD), &dwBytesReturned, NULL); - } + break; - return true; + case 2: + + *pdwPortVal = _inpw(wPortAddr); + + break; + + case 4: + + *pdwPortVal = _inpd(wPortAddr); + + break; + } + } +#endif + + return true; } bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize) { - tagPort32Struct Port32Struct; - DWORD dwBytesReturned; + if (!IsWinIoInitialized) + { + return false; + } + +#ifdef _WIN64 + tagPortStruct PortStruct; + DWORD dwBytesReturned; + + PortStruct.bSize = bSize; + PortStruct.dwPortVal = dwPortVal; + PortStruct.wPortAddr = wPortAddr; + + return DeviceIoControl(hDriver, IOCTL_WINIO_WRITEPORT, &PortStruct, sizeof(PortStruct), + NULL, 0, &dwBytesReturned, NULL); +#elif _WIN32 + // If this is a 64 bit OS, we must use the driver to access I/O ports even if the application is 32 bit + if (g_Is64BitOS) + { + tagPortStruct PortStruct; + DWORD dwBytesReturned; + + PortStruct.bSize = bSize; + PortStruct.dwPortVal = dwPortVal; + PortStruct.wPortAddr = wPortAddr; - if (!IsWinIoInitialized) - return false; + return DeviceIoControl(hDriver, IOCTL_WINIO_WRITEPORT, &PortStruct, sizeof(PortStruct), + NULL, 0, &dwBytesReturned, NULL); + } + else + { + switch (bSize) + { + case 1: - if (IsNT) - { - switch (bSize) - { - case 1: + _outp(wPortAddr, dwPortVal); - _outp(wPortAddr, dwPortVal); + break; - break; + case 2: - case 2: + _outpw(wPortAddr, (WORD)dwPortVal); - _outpw(wPortAddr, (WORD)dwPortVal); + break; - break; + case 4: - case 4: + _outpd(wPortAddr, dwPortVal); - _outpd(wPortAddr, dwPortVal); + break; + } + } +#endif - break; - } - } - else - { - Port32Struct.bSize = bSize; - Port32Struct.dwPortVal = dwPortVal; - Port32Struct.wPortAddr = wPortAddr; - - return DeviceIoControl(hDriver, WINIO_WRITEPORT, &Port32Struct, sizeof(Port32Struct), - NULL, 0, &dwBytesReturned, NULL); - } - - return true; + return true; } diff --git a/Source/Dll/WinIo.aps b/Source/Dll/WinIo.aps new file mode 100644 index 0000000000000000000000000000000000000000..979c512da442ab9451a7b77345c9fbedc21d07b9 GIT binary patch literal 33948 zcmc(Id%R>>Ro?2E4$8nNkw+8|XLvc2Fm0VvRrgj6D4eP~b?>pO>J(LV@9o>Rl#`yG zp{1vL?4E%!B2n@XjV31gQ}Ym!BnX-S@)`y45kV0J@eop9pvS?1mU)KJb_RQ47*Ib0Uejdc0k6(!`v zGYN&Qi}`XrD^IP~i*i}-Er#WKznJWml(jOtPU6FQIxS`+19w_25FX?cW~)U#Y4W#P z^k9iE52vNg&eE^v+UPpncE^3Fma5UQ8|gXcFY4c}p=0~Y^?tcnR`qOM&Birl^c8fh z8V%RWRk5mubki-_&2%#%7g}>{I9M###iZJqttaJpMXmcX)N?{x9<-|GKyrm_d&r{N z+2vf^x(W3>Y*4RO^%P)Ffqf4wW`{t=3c1xFgL*M47q%iT)MP?W@iASK7OFC#ulFHa zl@{tUp>OcPrYHmZijs$Q(IB%uS!Z9umN z&=6~u#xgn=V6#2`M3F70I|67qTyTE_Ytx+pR`2sX0@NWai>RZk$fD%w3aCrx1L$Ni zD>Sx6->R@>IWHDme`?VMI#!HN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bck$J8G!=Dp8 MG9NiIPds-27s$ljtpET3 literal 0 HcmV?d00001 diff --git a/Source/Dll/WinIo.cpp b/Source/Dll/WinIo.cpp index a615488..a51787b 100644 --- a/Source/Dll/WinIo.cpp +++ b/Source/Dll/WinIo.cpp @@ -1,144 +1,176 @@ // ---------------------------------------------------- // -// WinIo v2.0 // -// Direct Hardware Access Under Windows 9x/NT/2000/XP // -// Copyright 1998-2002 Yariv Kaplan // +// WinIo v3.0 // +// Direct Hardware Access Under Windows // +// Copyright 1998-2010 Yariv Kaplan // // http://www.internals.com // // ---------------------------------------------------- // +#define _WIN32_WINNT 0x0501 + #include #include -#include "k32call.h" #include "phys32.h" -#include "..\drv\nt\winio_nt.h" +#include "..\drv\winio_nt.h" #include "winio.h" HANDLE hDriver = INVALID_HANDLE_VALUE; -bool IsNT; bool IsWinIoInitialized = false; -char szWinIoDriverPath[MAX_PATH]; - - -bool IsWinNT() -{ - OSVERSIONINFO OSVersionInfo; +wchar_t szWinIoDriverPath[32768]; +bool g_Is64BitOS; - OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&OSVersionInfo); +typedef UINT (WINAPI* GETSYSTEMWOW64DIRECTORY)(LPTSTR, UINT); - return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT; +BOOL Is64BitOS() +{ +#ifdef _WIN64 + return TRUE; +#else + GETSYSTEMWOW64DIRECTORY getSystemWow64Directory; + HMODULE hKernel32; + TCHAR Wow64Directory[32767]; + + hKernel32 = GetModuleHandle(TEXT("kernel32.dll")); + if (hKernel32 == NULL) + { + // + // This shouldn't happen, but if we can't get + // kernel32's module handle then assume we are + // on x86. We won't ever install 32-bit drivers + // on 64-bit machines, we just want to catch it + // up front to give users a better error message. + // + return FALSE; + } + + getSystemWow64Directory = (GETSYSTEMWOW64DIRECTORY)GetProcAddress(hKernel32, "GetSystemWow64DirectoryW"); + + if (getSystemWow64Directory == NULL) + { + // + // This most likely means we are running + // on Windows 2000, which didn't have this API + // and didn't have a 64-bit counterpart. + // + return FALSE; + } + + if ((getSystemWow64Directory(Wow64Directory, _countof(Wow64Directory)) == 0) && + (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) { + return FALSE; + } + + // + // GetSystemWow64Directory succeeded + // so we are on a 64-bit OS. + // + return TRUE; +#endif } bool GetDriverPath() { - PSTR pszSlash; + PWSTR pszSlash; - if (!GetModuleFileName(GetModuleHandle(NULL), szWinIoDriverPath, sizeof(szWinIoDriverPath))) - return false; + if (!GetModuleFileName(GetModuleHandle(NULL), szWinIoDriverPath, sizeof(szWinIoDriverPath))) + return false; - pszSlash = strrchr(szWinIoDriverPath, '\\'); + pszSlash = wcsrchr(szWinIoDriverPath, '\\'); - if (pszSlash) - pszSlash[1] = 0; - else - return false; + if (pszSlash) + pszSlash[1] = 0; + else + return false; - strcat(szWinIoDriverPath, "winio.sys"); + if (g_Is64BitOS) + wcscat(szWinIoDriverPath, L"winio64.sys"); + else + wcscat(szWinIoDriverPath, L"winio32.sys"); - return true; + return true; } -bool _stdcall InitializeWinIo() +bool __stdcall InitializeWinIo() { - bool bResult; - DWORD dwBytesReturned; - - IsNT = IsWinNT(); - - if (IsNT) - { - hDriver = CreateFile("\\\\.\\WINIO", - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - // If the driver is not running, install it + bool bResult; + DWORD dwBytesReturned; - if (hDriver == INVALID_HANDLE_VALUE) - { - GetDriverPath(); + g_Is64BitOS = Is64BitOS(); - bResult = InstallWinIoDriver(szWinIoDriverPath, true); + hDriver = CreateFile(L"\\\\.\\WINIO", + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); - if (!bResult) - return false; + // If the driver is not running, install it - bResult = StartWinIoDriver(); + if (hDriver == INVALID_HANDLE_VALUE) + { + GetDriverPath(); - if (!bResult) - return false; + bResult = InstallWinIoDriver(szWinIoDriverPath, true); - hDriver = CreateFile("\\\\.\\WINIO", - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); + if (!bResult) + return false; - if (hDriver == INVALID_HANDLE_VALUE) - return false; - } + bResult = StartWinIoDriver(); - // Enable I/O port access for this process + if (!bResult) + return false; - if (!DeviceIoControl(hDriver, IOCTL_WINIO_ENABLEDIRECTIO, NULL, - 0, NULL, 0, &dwBytesReturned, NULL)) - return false; + hDriver = CreateFile(L"\\\\.\\WINIO", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); - } - else - { - VxDCall = (DWORD (WINAPI *)(DWORD,DWORD,DWORD))GetK32ProcAddress(1); + if (hDriver == INVALID_HANDLE_VALUE) + return false; + } - hDriver = CreateFile("\\\\.\\WINIO.VXD", 0, 0, 0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); + // Enable I/O port access for this process if running on a 32 bit OS - if (hDriver == INVALID_HANDLE_VALUE) - return false; - } + if (!g_Is64BitOS) + { + if (!DeviceIoControl(hDriver, IOCTL_WINIO_ENABLEDIRECTIO, NULL, + 0, NULL, 0, &dwBytesReturned, NULL)) + { + return false; + } + } - IsWinIoInitialized = true; + IsWinIoInitialized = true; - return true; + return true; } void _stdcall ShutdownWinIo() { - DWORD dwBytesReturned; + DWORD dwBytesReturned; - if (IsNT) - { - if (hDriver != INVALID_HANDLE_VALUE) - { - // Disable I/O port access + if (hDriver != INVALID_HANDLE_VALUE) + { + // Disable I/O port access if running on a 32 bit OS - DeviceIoControl(hDriver, IOCTL_WINIO_DISABLEDIRECTIO, NULL, - 0, NULL, 0, &dwBytesReturned, NULL); + if (!g_Is64BitOS) + { + DeviceIoControl(hDriver, IOCTL_WINIO_DISABLEDIRECTIO, NULL, + 0, NULL, 0, &dwBytesReturned, NULL); + } - CloseHandle(hDriver); + CloseHandle(hDriver); - } + } - RemoveWinIoDriver(); - } - else - CloseHandle(hDriver); + RemoveWinIoDriver(); - IsWinIoInitialized = false; + IsWinIoInitialized = false; } diff --git a/Source/Dll/WinIo.def b/Source/Dll/WinIo.def index 292088c..cf0f712 100644 --- a/Source/Dll/WinIo.def +++ b/Source/Dll/WinIo.def @@ -1,7 +1,4 @@ -LIBRARY WINIO - EXPORTS - InitializeWinIo ShutdownWinIo MapPhysToLin diff --git a/Source/Dll/WinIo.dsp b/Source/Dll/WinIo.dsp deleted file mode 100644 index 01d07d7..0000000 --- a/Source/Dll/WinIo.dsp +++ /dev/null @@ -1,129 +0,0 @@ -# Microsoft Developer Studio Project File - Name="WinIo" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=WinIo - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "WinIo.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "WinIo.mak" CFG="WinIo - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "WinIo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "WinIo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "WinIo - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINIO_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINIO_EXPORTS" /D "WINIO_DLL" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "WinIo - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINIO_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINIO_EXPORTS" /D "WINIO_DLL" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "WinIo - Win32 Release" -# Name "WinIo - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\Instdrv.cpp -# End Source File -# Begin Source File - -SOURCE=.\k32exp.c -# End Source File -# Begin Source File - -SOURCE=.\Phys32.cpp -# End Source File -# Begin Source File - -SOURCE=.\Port32.cpp -# End Source File -# Begin Source File - -SOURCE=.\WinIo.cpp -# End Source File -# Begin Source File - -SOURCE=.\WinIo.def -# End Source File -# Begin Source File - -SOURCE=.\WinIo.rc -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/Source/Dll/WinIo.dsw b/Source/Dll/WinIo.dsw deleted file mode 100644 index d759e77..0000000 --- a/Source/Dll/WinIo.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "WinIo"=.\WinIo.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/Source/Dll/WinIo.h b/Source/Dll/WinIo.h deleted file mode 100644 index 27c7471..0000000 --- a/Source/Dll/WinIo.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef WINIO_H -#define WINIO_H - -#ifdef WINIO_DLL -#define WINIO_API _declspec(dllexport) -#else -#define WINIO_API _declspec(dllimport) -#endif - -extern "C" -{ - WINIO_API bool _stdcall InitializeWinIo(); - WINIO_API void _stdcall ShutdownWinIo(); - WINIO_API PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle); - WINIO_API bool _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr); - WINIO_API bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal); - WINIO_API bool _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal); - WINIO_API bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize); - WINIO_API bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize); - WINIO_API bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded = false); - WINIO_API bool _stdcall RemoveWinIoDriver(); -} - -extern bool IsNT; -extern HANDLE hDriver; -extern bool IsWinIoInitialized; - -bool _stdcall StartWinIoDriver(); -bool _stdcall StopWinIoDriver(); - -#endif diff --git a/Source/Dll/WinIo.rc b/Source/Dll/WinIo.rc index cbcda23..dd9ffbe 100644 --- a/Source/Dll/WinIo.rc +++ b/Source/Dll/WinIo.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // #include "resource.h" @@ -21,15 +21,14 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 -#ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,0,0 - PRODUCTVERSION 2,0,0,0 + FILEVERSION 3,0,0,0 + PRODUCTVERSION 3,0,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x29L @@ -44,18 +43,18 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", " \0" - VALUE "CompanyName", "http://www.internals.com\0" - VALUE "FileDescription", "WinIo\0" - VALUE "FileVersion", "2.0\0" - VALUE "InternalName", "WinIo\0" - VALUE "LegalCopyright", "Copyright © 1998-2002, Yariv Kaplan\0" - VALUE "LegalTrademarks", " \0" - VALUE "OriginalFilename", "WinIo.dll\0" - VALUE "PrivateBuild", " \0" - VALUE "ProductName", "WinIo\0" - VALUE "ProductVersion", "2.0\0" - VALUE "SpecialBuild", " \0" + VALUE "Comments", " " + VALUE "CompanyName", "www.internals.com" + VALUE "FileDescription", "WinIo" + VALUE "FileVersion", "3.0" + VALUE "InternalName", "WinIo" + VALUE "LegalCopyright", "Copyright © 1998-2010, Yariv Kaplan" + VALUE "LegalTrademarks", " " + VALUE "OriginalFilename", "WinIo.dll" + VALUE "PrivateBuild", " " + VALUE "ProductName", "WinIo" + VALUE "ProductVersion", "3.0" + VALUE "SpecialBuild", " " END END BLOCK "VarFileInfo" @@ -64,8 +63,6 @@ BEGIN END END -#endif // !_MAC - #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -73,18 +70,18 @@ END // TEXTINCLUDE // -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/Source/Dll/WinIo.sln b/Source/Dll/WinIo.sln new file mode 100644 index 0000000..f5117d5 --- /dev/null +++ b/Source/Dll/WinIo.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinIo", "WinIo.vcproj", "{DE9A75D4-D640-41B8-893B-A384FAF00738}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Debug|Win32.ActiveCfg = Debug|Win32 + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Debug|Win32.Build.0 = Debug|Win32 + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Debug|x64.ActiveCfg = Debug|x64 + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Debug|x64.Build.0 = Debug|x64 + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Release|Win32.ActiveCfg = Release|Win32 + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Release|Win32.Build.0 = Release|Win32 + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Release|x64.ActiveCfg = Release|x64 + {DE9A75D4-D640-41B8-893B-A384FAF00738}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Source/Dll/WinIo.suo b/Source/Dll/WinIo.suo new file mode 100644 index 0000000000000000000000000000000000000000..b2d749e63c8954ae3998b30e9ba9bf80b3693beb GIT binary pat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G@{a)qocD+YsjeIgBQML z*PwXR*sz?RXue)^Y4L%6U2`e4FP#-K)gj;3FYe2$E`h$>ug#*xN4Kv}Z@PW>Ve{`3 zu9Uv{|6KvhX}%*^Im?oG|6vXi4N@ky7F%r2a4KYrX~9Li@WXD6CsGr7@BHa$7g6dO)u zb9!%QdrK>SO|icDbbdaY+But=&u5eArr6;8NcyPat?@;Be$8?iUG7OYTM<2S8rA4d z#Xq&K2R@|2rWqtraQqp*1F!hYJx^q%NH@BLhWvb7&);eC1j}b1EtrV^?o<|5ic#f% zLU~ULP_X#Dx=HJN)rDct4S@1$>IP;k@Sr(JzA*->=5ExuxYHPpxCl~J7m{ce}AEI6D3=BMjBcxz@rwN*K*|) zV{y>nIRE{Qq5smOMP;zZOBsg**1Qn+%sPa!rscH2^6&}pu%hq)XKI+5J?0+Y#rG}L zr`PcC={E|{UV-=42%OtOCj@vgq3k21y_xJxTjj5gl(_;8IN$&Jua7;p@oW7rZu^JP zr~mWJ%@s1Kxz%F8j7|Yd|3`yF$pNJu7usA&*Mj{|_z67z&-xy&6>DF{d`9@+rK1^fKidD2QF-IR`z~Dd@Q&b@v<9f8ll9f<>ixg` zA$?;Mtk6x^Jb27>tPvCw;9VnZ5U?b10UopcIsv**fXBOhQG~UzUlj2!ySTjj9)W!Q z!T|w#pI~PO&!~sBhB0@C5$*=TMtf6A!;1;i0`!;w?^b~mNz%^=Udh8sLGyx@RY|^^ sspO|qca*h3Si1a@B5S&_arj5|7WKgVeaw{b1zl}x4C{@{GWWp$0tvBrH2?qr literal 0 HcmV?d00001 diff --git a/Source/Dll/WinIo.vcproj b/Source/Dll/WinIo.vcproj new file mode 100644 index 0000000..ff4d480 --- /dev/null +++ b/Source/Dll/WinIo.vcproj @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Dll/k32exp.c b/Source/Dll/k32exp.c deleted file mode 100644 index f347d31..0000000 --- a/Source/Dll/k32exp.c +++ /dev/null @@ -1,92 +0,0 @@ -/* -K32EXP.C -- Get32ProcAddress -Win32 code to import by ordinal from KERNEL32.DLL in Windows 95 - -Andrew Schulman -andrew@ora.com -http://www.ora.com/windows/ -ftp://ftp.ora.com/pub/examples/windows/win95.update/schulman.html -August 1995 - -After I wrote Unauthorized Windows 95 (IDG Books, 1994), KERNEL32.DLL -stopped exporting undocumented Win32 functions such as VxDCall() and -GetpWin16Lock() by name. The functions discussed in *Unauthorized* -continue to be exported by ordinal (for example, VxDCall is -KERNEL32.1 and GetpWin16Lock is KERNEL.93). However, KERNEL32 does -not allow imports by ordinal (Message from debug version: -"GetProcAddress: kernel32 by id not supported"). - -This module provides GetK32ProcAddress() to support import by ordinal -from KERNEL32. There's nothing undocumented in here, except for the -ordinal numbers themselves. GetModuleHandle() returns the address of -the executable image (see Matt Pietrek in *Microsoft Systems Journal*, -September 1995, p. 20), and the image is documented in the PE (Portable -Executable) file format. -*/ - -#include -#include -#include -#include "k32exp.h" - -#define ENEWHDR 0x003CL /* offset of new EXE header */ -#define EMAGIC 0x5A4D /* old EXE magic id: 'MZ' */ -#define PEMAGIC 0x4550 /* NT portable executable */ - -#define GET_DIR(x) (hdr->OptionalHeader.DataDirectory[x].VirtualAddress) - -DWORD WINAPI GetK32ProcAddress(int ord) -{ - static HANDLE hmod = 0; - IMAGE_NT_HEADERS *hdr; - IMAGE_EXPORT_DIRECTORY *exp; - DWORD *AddrFunc; - WORD enewhdr, *pw; - int did_load = 0, i; - BYTE *moddb; - - if (hmod == 0) // one-time static init - hmod = GetModuleHandle("KERNEL32"); - if (hmod == 0) // still - return 0; - - moddb = (BYTE *) hmod; - pw = (WORD *) &moddb[0]; - if (*pw != EMAGIC) - return 0; - pw = (WORD *) &moddb[ENEWHDR]; - enewhdr = *pw; - pw = (WORD *) &moddb[enewhdr]; - if (*pw != PEMAGIC) - return 0; - hdr = (IMAGE_NT_HEADERS *) pw; - - // Note: offset from moddb, *NOT* from hdr! - exp = (IMAGE_EXPORT_DIRECTORY *) (((DWORD) moddb) + - ((DWORD) GET_DIR(IMAGE_DIRECTORY_ENTRY_EXPORT))); - AddrFunc = (DWORD *) (moddb + (DWORD) exp->AddressOfFunctions); - - // should verify that e.g.: - // GetProcAddress(hmod, "VirtualAlloc") == GetK32ProcAddress(710); - - ord--; // table is 0-based, ordinals are 1-based - if (ord < exp->NumberOfFunctions) - return ((DWORD) (moddb + AddrFunc[ord])); - else - return 0; -} - -#ifdef STANDALONE -void fail(const char *s) { puts(s); exit(1); } - -main(int argc, char *argv[]) -{ - printf("KERNEL32!VxDCall = %08lX\n", - GetK32ProcAddress(VXDCALL_ORD)); - printf("KERNEL32!GetpWin16Lock = %08lX\n", - GetK32ProcAddress(GETPWIN16LOCK_ORD)); -} -#endif - - - diff --git a/Source/Dll/k32exp.h b/Source/Dll/k32exp.h deleted file mode 100644 index 4540650..0000000 --- a/Source/Dll/k32exp.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -K32EXP.H -- Get32ProcAddress -Win32 code to import by ordinal from KERNEL32.DLL in Windows 95 - -Andrew Schulman -Senior editor, O'Reilly & Associates (Sebastopol CA) -andrew@ora.com - -August 1995 - -See K32EXP.C for more information -*/ - -// KERNEL32.1 through KERNEL32.9 are all VxDCall -#define VXDCALL_ORD 1 - -// found these by examining RUNDLL32.EXE -#define LOADLIBRARY16_ORD 35 -#define FREELIBRARY16_ORD 36 -#define GETPROCADDRESS16_ORD 37 - -// found these by examining WOW32.DLL -// actually, these are documented: see GENTHUNK.TXT ("Windows NT -// Generic Thunk Overview") and WOWNT32.H in Microsoft's Win32 SDK -#define WOWCallback16_ORD 54 -#define WOWCallback16Ex_ORD 55 -#define WOWGetVDMPointer_ORD 56 -#define WOWHandle32_ORD 57 -#define WOWHandle16_ORD 58 -#define WOWGlobalAlloc16_ORD 59 -#define WOWGlobalLock16_ORD 60 -#define WOWGlobalUnlock16_ORD 61 -#define WOWGlobalFree16_ORD 62 -#define WOWGlobalAllocLock16_ORD 63 -#define WOWGlobalUnlockFree16_ORD 64 -#define WOWGlobalLockSize16_ORD 65 -#define WOWYield16_ORD 66 -#define WOWDirectedYield16_ORD 67 -#define WOWGetVDMPointerFix_ORD 68 -#define WOWGetVDMPointerUnfix_ORD 69 -#define WOW32_1_ORD 70 - -// found these by examining NTDLL.DLL (Win95) -#define RtlLargeIntegerAdd_ORD 72 -#define RtlEnlargedIntegerMultiply_ORD 73 -#define RtlEnlargedUnsignedMultiply_ORD 74 -#define RtlEnlargedUnsignedDivide_ORD 75 -#define RtlExtendedLargeIntegerDivide_ORD 76 -#define RtlExtendedMagicDivide_ORD 77 -#define RtlExtendedIntegerMultiply_ORD 78 -#define RtlLargeIntegerShiftLeft_ORD 79 -#define RtlLargeIntegerShiftRight_ORD 80 -#define RtlLargeIntegerArithmeticShift_ORD 81 -#define RtlLargeIntegerNegate_ORD 82 -#define RtlLargeIntegerSubtract_ORD 83 -#define RtlConvertLongToLargeInteger_ORD 84 -#define RtlConvertUlongToLargeInteger_ORD 85 - -#define GETPWIN16LOCK_ORD 93 -#define ENTERSYSLEVEL_ORD 97 -#define LEAVESYSLEVEL_ORD 98 - -DWORD WINAPI GetK32ProcAddress(int ord); - -// VxDCall is probably the most important undocumented Win32 API -DWORD (WINAPI *VxDCall)(DWORD srvc, DWORD eax, DWORD ecx); - -// Walking VxD chain shows that these are the VxDs that provide -// Win32 services -#define VMM_ID 0x0001 // 41 services -#define REBOOT_ID 0x0009 // 2 -#define VNETBIOS_ID 0x0014 // 2 -#define VWIN32_ID 0x002A // 79 -#define VCOMM_ID 0x002B // 27 -#define VCOND_ID 0x0038 // 53 -- Virtual CON (Console) - -// found these by examining ADVAPI32.DLL and REGSERV.EXE -// REGSERV.EXE calls these directly for remote registry services -#define RegOpenKeyEx_CALL 0x10011 -#define RegCreatKeyA_CALL 0x10012 -#define RegCloseKey_CALL 0x10013 -#define RegDeleteKey_CALL 0x10014 -#define RegSetValueA_CALL 0x10015 -#define RegDeleteValueA_CALL 0x10016 -#define RegQueryValueA_CALL 0x10017 -#define RegEnumKeyA_CALL 0x10018 -#define RegQueryValueEx_CALL 0x1001A -#define RegSetValueExA_CALL 0x1001B -#define RegFlushKey_CALL 0x1001C -#define RegLoadKeyA_CALL 0x10021 -#define RegUnloadKeyA_CALL 0x10022 -#define RegSaveKeyA_CALL 0x10023 -#define RegRemapPreDefKey_CALL 0x10024 -#define RegQueryMultipleValuesA_CALL 0x10026 -#define RegReplaceKeyA_CALL 0x10027 - -// two important VWIN32 services -#define VWIN32_INT21_CALL 0x2A0010 -#define VWIN32_INT31_CALL 0x2A0029 -#define DosCall(eax, ecx) VxDCall(VWIN32_INT21_CALL, (eax), (ecx)) -#define DPMICall(eax, ecx) VxDCall(VWIN32_INT31_CALL, (eax), (ecx)) - -// other undocumented interfaces -HINSTANCE (WINAPI *LoadLibrary16)(LPCSTR lpLibFileName); -int (WINAPI *FreeLibrary16)(HINSTANCE hModule); -FARPROC (WINAPI *GetProcAddress16)(HINSTANCE hModule, LPCSTR lpProcName); -void (WINAPI *GetpWin16Lock)(DWORD *pWin16Lock); -// int (WINAPI *_ConfirmWin16Lock)(void); // returns current lock count -void (WINAPI *_EnterSysLevel)(DWORD lock); -void (WINAPI *_LeaveSysLevel)(DWORD lock); - - - diff --git a/Examples/C/WinIoTest/WinIo.h b/Source/Dll/winio.h similarity index 62% rename from Examples/C/WinIoTest/WinIo.h rename to Source/Dll/winio.h index 27c7471..c47e5ee 100644 --- a/Examples/C/WinIoTest/WinIo.h +++ b/Source/Dll/winio.h @@ -1,29 +1,31 @@ #ifndef WINIO_H #define WINIO_H -#ifdef WINIO_DLL -#define WINIO_API _declspec(dllexport) -#else +#include "..\drv\winio_nt.h" + +#ifndef WINIO_DLL #define WINIO_API _declspec(dllimport) +#else +#define WINIO_API #endif extern "C" { WINIO_API bool _stdcall InitializeWinIo(); WINIO_API void _stdcall ShutdownWinIo(); - WINIO_API PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle); - WINIO_API bool _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr); + WINIO_API PBYTE _stdcall MapPhysToLin(tagPhysStruct &PhysStruct); + WINIO_API bool _stdcall UnmapPhysicalMemory(tagPhysStruct &PhysStruct); WINIO_API bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal); WINIO_API bool _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal); WINIO_API bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize); WINIO_API bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize); - WINIO_API bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded = false); + WINIO_API bool _stdcall InstallWinIoDriver(PWSTR pszWinIoDriverPath, bool IsDemandLoaded = false); WINIO_API bool _stdcall RemoveWinIoDriver(); } -extern bool IsNT; extern HANDLE hDriver; extern bool IsWinIoInitialized; +extern bool g_Is64BitOS; bool _stdcall StartWinIoDriver(); bool _stdcall StopWinIoDriver(); diff --git a/Source/Drv/9x/WINIO.DEF b/Source/Drv/9x/WINIO.DEF deleted file mode 100644 index b0633bd..0000000 --- a/Source/Drv/9x/WINIO.DEF +++ /dev/null @@ -1,27 +0,0 @@ -VXD WINIO DYNAMIC -SEGMENTS - _LTEXT CLASS 'LCODE' PRELOAD NONDISCARDABLE - _LDATA CLASS 'LCODE' PRELOAD NONDISCARDABLE - _TEXT CLASS 'LCODE' PRELOAD NONDISCARDABLE - _DATA CLASS 'LCODE' PRELOAD NONDISCARDABLE - _LPTEXT CLASS 'LCODE' PRELOAD NONDISCARDABLE - _CONST CLASS 'LCODE' PRELOAD NONDISCARDABLE - _BSS CLASS 'LCODE' PRELOAD NONDISCARDABLE - _TLS CLASS 'LCODE' PRELOAD NONDISCARDABLE - _ITEXT CLASS 'ICODE' DISCARDABLE - _IDATA CLASS 'ICODE' DISCARDABLE - _PTEXT CLASS 'PCODE' NONDISCARDABLE - _PDATA CLASS 'PCODE' NONDISCARDABLE - _STEXT CLASS 'SCODE' RESIDENT - _SDATA CLASS 'SCODE' RESIDENT - _MSGTABLE CLASS 'MCODE' PRELOAD NONDISCARDABLE IOPL - _MSGDATA CLASS 'MCODE' PRELOAD NONDISCARDABLE IOPL - _IMSGTABLE CLASS 'MCODE' PRELOAD DISCARDABLE IOPL - _IMSGDATA CLASS 'MCODE' PRELOAD DISCARDABLE IOPL - _DBOSTART CLASS 'DBOCODE' PRELOAD NONDISCARDABLE CONFORMING - _DBOCODE CLASS 'DBOCODE' PRELOAD NONDISCARDABLE CONFORMING - _DBODATA CLASS 'DBOCODE' PRELOAD NONDISCARDABLE CONFORMING - _16ICODE CLASS '16ICODE' PRELOAD DISCARDABLE - _RCODE CLASS 'RCODE' -EXPORTS - _The_DDB @1 diff --git a/Source/Drv/9x/WINIO.VRC b/Source/Drv/9x/WINIO.VRC deleted file mode 100644 index c2b0578..0000000 --- a/Source/Drv/9x/WINIO.VRC +++ /dev/null @@ -1,9 +0,0 @@ -CompanyName = "http://www.internals.com" -FileDescription = "WinIo" -FileVersion = "Version 2.00" -InternalName = "WinIo" -LegalCopyright = "Copyright \251 1998-2002, Yariv Kaplan" -OriginalFilename = "winio.vxd" -ProductName = "WinIo" -ProductVersion = "Version 2.00" -Translation = 0x409, 0x4E4 diff --git a/Source/Drv/9x/WINIO.exp b/Source/Drv/9x/WINIO.exp deleted file mode 100644 index fb0bd17a3dacfc16ef0da331c3b2298f7a846342..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1576 zcmbVM&1%~)99KKK(VoKk0v_y;f=K9LJD3_`TOt#cKd_W7?L{=Px8;(A#4Wk?W%g8k zm(nV-W!ZHg&3uvd|9$*FBt(yn!R_vJ%ht`_UX@7(Gp z7ZxSqHL&{8h}(tm=NMW2&<$|0xB7UD`Av*%bR(n0xB3kGoJ65b{Rm<4ut}G5NWVx` zfRiD%1?70mof`TM339o6n53PgNZ-q|O@5eFJ9%l9-sN|PS<$#%*S>lAQOFLQm&aJM zuCn0Cdfklg%gyNU1?&0~va(-RH1⁡a)Y%gE=@8UD< zzk%cGUNTj^fsDP0)#=LJK!zS@_vL&BDXDc3upxInik&*;okEpvpDvw2L`l^W*^w}v z?Mk>q_$FaphrG!2IEB=&^(ZmM-Gn<$l1bW(x5QiH|JACJoBk&6<@f5UE#|V-cgB!BTCya QcvN_S@*kt{T5P)luVlBs00000 diff --git a/Source/Drv/9x/WinIo.c b/Source/Drv/9x/WinIo.c deleted file mode 100644 index fe393b8..0000000 --- a/Source/Drv/9x/WinIo.c +++ /dev/null @@ -1,104 +0,0 @@ -// ---------------------------------------------------- // -// WinIo v2.0 // -// Direct Hardware Access Under Windows 9x/NT/2000/XP // -// Copyright 1998-2002 Yariv Kaplan // -// http://www.internals.com // -// ---------------------------------------------------- // - -#define DEVICE_MAIN - -#include "winio_9x.h" - -#undef DEVICE_MAIN - -#include "winio.h" - -Declare_Virtual_Device(WINIO) - -DefineControlHandler(SYS_DYNAMIC_DEVICE_INIT, OnSysDynamicDeviceInit); -DefineControlHandler(SYS_DYNAMIC_DEVICE_EXIT, OnSysDynamicDeviceExit); -DefineControlHandler(W32_DEVICEIOCONTROL, OnW32DeviceIoControl); - -BOOL ControlDispatcher(DWORD dwControlMessage, DWORD EBX, DWORD EDX, DWORD ESI, DWORD EDI, DWORD ECX) -{ - START_CONTROL_DISPATCH - - ON_SYS_DYNAMIC_DEVICE_INIT(OnSysDynamicDeviceInit); - ON_SYS_DYNAMIC_DEVICE_EXIT(OnSysDynamicDeviceExit); - ON_W32_DEVICEIOCONTROL(OnW32DeviceIoControl); - - END_CONTROL_DISPATCH - - return TRUE; -} - - -BOOL OnSysDynamicDeviceInit() -{ - return TRUE; -} - - -BOOL OnSysDynamicDeviceExit() -{ - return TRUE; -} - - -DWORD OnW32DeviceIoControl(PIOCTLPARAMS p) -{ - struct tagPort32Struct *pPort32Struct; - unsigned int *pdwPortVal; - - switch (p->dioc_IOCtlCode) - { - case DIOC_OPEN: - case DIOC_CLOSEHANDLE: - break; - - case WINIO_WRITEPORT: - - pPort32Struct = p->dioc_InBuf; - - switch (pPort32Struct->bSize) - { - case 1: - _outp(pPort32Struct->wPortAddr, pPort32Struct->dwPortVal); - break; - - case 2: - _outpw(pPort32Struct->wPortAddr, pPort32Struct->dwPortVal); - break; - - case 4: - _outpd(pPort32Struct->wPortAddr, pPort32Struct->dwPortVal); - break; - } - - break; - - case WINIO_READPORT: - - pPort32Struct = p->dioc_InBuf; - pdwPortVal = p->dioc_OutBuf; - - switch (pPort32Struct->bSize) - { - case 1: - *pdwPortVal = _inp(pPort32Struct->wPortAddr); - break; - - case 2: - *pdwPortVal = _inpw(pPort32Struct->wPortAddr); - break; - - case 4: - *pdwPortVal = _inpd(pPort32Struct->wPortAddr); - break; - } - - break; - } - - return 0; -} diff --git a/Source/Drv/9x/WinIo.h b/Source/Drv/9x/WinIo.h deleted file mode 100644 index fa97dfe..0000000 --- a/Source/Drv/9x/WinIo.h +++ /dev/null @@ -1,6 +0,0 @@ -#include - -#define WINIO_Major 2 -#define WINIO_Minor 0 -#define WINIO_DeviceID UNDEFINED_DEVICE_ID -#define WINIO_Init_Order UNDEFINED_INIT_ORDER diff --git a/Source/Drv/9x/WinIo_9x.h b/Source/Drv/9x/WinIo_9x.h deleted file mode 100644 index 0ad29a9..0000000 --- a/Source/Drv/9x/WinIo_9x.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef WINIO9X_H -#define WINIO9X_H - -#define WINIO_WRITEPORT CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_NEITHER, FILE_ANY_ACCESS) -#define WINIO_READPORT CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_NEITHER, FILE_ANY_ACCESS) - -#pragma pack(1) - -struct tagPort32Struct -{ - unsigned short wPortAddr; - unsigned int dwPortVal; - unsigned char bSize; -}; - -#endif diff --git a/Source/Drv/9x/winio.mak b/Source/Drv/9x/winio.mak deleted file mode 100644 index 38f9c0c..0000000 --- a/Source/Drv/9x/winio.mak +++ /dev/null @@ -1,13 +0,0 @@ -# winio.mak - makefile for WinIo VxD -# Copyright (c) 1998-2002 Yariv Kaplan - -DEVICENAME = WINIO -DYNAMIC = 1 -FRAMEWORK = C -DEBUG = 0 -OBJECTS = WINIO.OBJ - -!include $(VTOOLSD)\include\vtoolsd.mak -!include $(VTOOLSD)\include\vxdtarg.mak - -winio.obj: winio.c winio.h diff --git a/Source/Drv/NT/MAKEFILE b/Source/Drv/MAKEFILE similarity index 100% rename from Source/Drv/NT/MAKEFILE rename to Source/Drv/MAKEFILE diff --git a/Source/Drv/NT/WinIo.c b/Source/Drv/NT/WinIo.c deleted file mode 100644 index f106dce..0000000 --- a/Source/Drv/NT/WinIo.c +++ /dev/null @@ -1,406 +0,0 @@ -// ---------------------------------------------------- // -// WinIo v2.0 // -// Direct Hardware Access Under Windows 9x/NT/2000/XP // -// Copyright 1998-2002 Yariv Kaplan // -// http://www.internals.com // -// ---------------------------------------------------- // - -#include -#include "winio_nt.h" - -#define OutputDebugString - -#define IOPM_SIZE 0x2000 -typedef char IOPM[IOPM_SIZE]; -IOPM *pIOPM = NULL; - -// Function definition section -// ----------------------------------------------------------------- -NTSTATUS WinIoDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); -void WinIoUnload(IN PDRIVER_OBJECT DriverObject); -NTSTATUS UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PVOID pPhysMemLin); -NTSTATUS MapPhysicalMemoryToLinearSpace(PVOID pPhysAddress, - ULONG PhysMemSizeInBytes, - PVOID *ppPhysMemLin, - HANDLE *pPhysicalMemoryHandle); - -void Ke386SetIoAccessMap(int, IOPM *); -void Ke386QueryIoAccessMap(int, IOPM *); -void Ke386IoSetAccessProcess(PEPROCESS, int); - -// ----------------------------------------------------------------- - -// Installable driver initialization entry point. -// This entry point is called directly by the I/O system. - -NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath) -{ - UNICODE_STRING DeviceNameUnicodeString; - UNICODE_STRING DeviceLinkUnicodeString; - NTSTATUS ntStatus; - PDEVICE_OBJECT DeviceObject = NULL; - - OutputDebugString ("Entering DriverEntry"); - - RtlInitUnicodeString (&DeviceNameUnicodeString, L"\\Device\\WinIo"); - - // Create an EXCLUSIVE device object (only 1 thread at a time - // can make requests to this device). - - ntStatus = IoCreateDevice (DriverObject, - 0, - &DeviceNameUnicodeString, - FILE_DEVICE_WINIO, - 0, - TRUE, - &DeviceObject); - - if (NT_SUCCESS(ntStatus)) - { - // Create dispatch points for device control, create, close. - - DriverObject->MajorFunction[IRP_MJ_CREATE] = - DriverObject->MajorFunction[IRP_MJ_CLOSE] = - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = WinIoDispatch; - DriverObject->DriverUnload = WinIoUnload; - - // Create a symbolic link, e.g. a name that a Win32 app can specify - // to open the device. - - RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\WinIo"); - - ntStatus = IoCreateSymbolicLink (&DeviceLinkUnicodeString, - &DeviceNameUnicodeString); - - if (!NT_SUCCESS(ntStatus)) - { - // Symbolic link creation failed- note this & then delete the - // device object (it's useless if a Win32 app can't get at it). - - OutputDebugString ("ERROR: IoCreateSymbolicLink failed"); - - IoDeleteDevice (DeviceObject); - } - - } - else - { - OutputDebugString ("ERROR: IoCreateDevice failed"); - } - - OutputDebugString ("Leaving DriverEntry"); - - return ntStatus; -} - - -// Process the IRPs sent to this device - -NTSTATUS WinIoDispatch(IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -{ - PIO_STACK_LOCATION IrpStack; - ULONG dwInputBufferLength; - ULONG dwOutputBufferLength; - ULONG dwIoControlCode; - PVOID pvIOBuffer; - NTSTATUS ntStatus; - struct tagPhys32Struct Phys32Struct; - - OutputDebugString ("Entering WinIoDispatch"); - - // Init to default settings - - Irp->IoStatus.Status = STATUS_SUCCESS; - Irp->IoStatus.Information = 0; - - IrpStack = IoGetCurrentIrpStackLocation(Irp); - - // Get the pointer to the input/output buffer and it's length - - pvIOBuffer = Irp->AssociatedIrp.SystemBuffer; - dwInputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength; - dwOutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength; - - switch (IrpStack->MajorFunction) - { - case IRP_MJ_CREATE: - - OutputDebugString("IRP_MJ_CREATE"); - - break; - - case IRP_MJ_CLOSE: - - OutputDebugString("IRP_MJ_CLOSE"); - - break; - - case IRP_MJ_DEVICE_CONTROL: - - OutputDebugString("IRP_MJ_DEVICE_CONTROL"); - - dwIoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode; - - switch (dwIoControlCode) - { - case IOCTL_WINIO_ENABLEDIRECTIO: - - OutputDebugString("IOCTL_WINIO_ENABLEDIRECTIO"); - - pIOPM = MmAllocateNonCachedMemory(sizeof(IOPM)); - - if (pIOPM) - { - RtlZeroMemory(pIOPM, sizeof(IOPM)); - - Ke386IoSetAccessProcess(PsGetCurrentProcess(), 1); - Ke386SetIoAccessMap(1, pIOPM); - } - else - Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; - - break; - - case IOCTL_WINIO_DISABLEDIRECTIO: - - OutputDebugString("IOCTL_WINIO_DISABLEDIRECTIO"); - - if (pIOPM) - { - Ke386IoSetAccessProcess(PsGetCurrentProcess(), 0); - Ke386SetIoAccessMap(1, pIOPM); - - MmFreeNonCachedMemory(pIOPM, sizeof(IOPM)); - pIOPM = NULL; - } - - break; - - case IOCTL_WINIO_MAPPHYSTOLIN: - - OutputDebugString("IOCTL_WINIO_MAPPHYSTOLIN"); - - if (dwInputBufferLength) - { - memcpy (&Phys32Struct, pvIOBuffer, dwInputBufferLength); - - ntStatus = MapPhysicalMemoryToLinearSpace(Phys32Struct.pvPhysAddress, - Phys32Struct.dwPhysMemSizeInBytes, - &Phys32Struct.pvPhysMemLin, - &Phys32Struct.PhysicalMemoryHandle); - - if (NT_SUCCESS(ntStatus)) - { - memcpy (pvIOBuffer, &Phys32Struct, dwInputBufferLength); - Irp->IoStatus.Information = dwInputBufferLength; - } - - Irp->IoStatus.Status = ntStatus; - } - else - Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; - - break; - - case IOCTL_WINIO_UNMAPPHYSADDR: - - OutputDebugString("IOCTL_WINIO_UNMAPPHYSADDR"); - - if (dwInputBufferLength) - { - memcpy (&Phys32Struct, pvIOBuffer, dwInputBufferLength); - - ntStatus = UnmapPhysicalMemory(Phys32Struct.PhysicalMemoryHandle, Phys32Struct.pvPhysMemLin); - - Irp->IoStatus.Status = ntStatus; - } - else - Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; - - break; - - default: - - OutputDebugString("ERROR: Unknown IRP_MJ_DEVICE_CONTROL"); - - Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; - - break; - } - - break; - } - - // DON'T get cute and try to use the status field of the irp in the - // return status. That IRP IS GONE as soon as you call IoCompleteRequest. - - ntStatus = Irp->IoStatus.Status; - - IoCompleteRequest (Irp, IO_NO_INCREMENT); - - // We never have pending operation so always return the status code. - - OutputDebugString("Leaving WinIoDispatch"); - - return ntStatus; -} - -// Delete the associated device and return - -void WinIoUnload(IN PDRIVER_OBJECT DriverObject) -{ - UNICODE_STRING DeviceLinkUnicodeString; - NTSTATUS ntStatus; - - OutputDebugString ("Entering WinIoUnload"); - - RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\WinIo"); - - ntStatus = IoDeleteSymbolicLink (&DeviceLinkUnicodeString); - - if (NT_SUCCESS(ntStatus)) - { - IoDeleteDevice (DriverObject->DeviceObject); - } - else - { - OutputDebugString ("ERROR: IoDeleteSymbolicLink"); - } - - OutputDebugString ("Leaving WinIoUnload"); -} - - -NTSTATUS MapPhysicalMemoryToLinearSpace(PVOID pPhysAddress, - ULONG PhysMemSizeInBytes, - PVOID *ppPhysMemLin, - HANDLE *pPhysicalMemoryHandle) -{ - UNICODE_STRING PhysicalMemoryUnicodeString; - PVOID PhysicalMemorySection = NULL; - OBJECT_ATTRIBUTES ObjectAttributes; - PHYSICAL_ADDRESS ViewBase; - NTSTATUS ntStatus; - PHYSICAL_ADDRESS pStartPhysAddress; - PHYSICAL_ADDRESS pEndPhysAddress; - PHYSICAL_ADDRESS MappingLength; - BOOLEAN Result1, Result2; - ULONG IsIOSpace; - unsigned char *pbPhysMemLin = NULL; - - OutputDebugString ("Entering MapPhysicalMemoryToLinearSpace"); - - RtlInitUnicodeString (&PhysicalMemoryUnicodeString, - L"\\Device\\PhysicalMemory"); - - InitializeObjectAttributes (&ObjectAttributes, - &PhysicalMemoryUnicodeString, - OBJ_CASE_INSENSITIVE, - (HANDLE) NULL, - (PSECURITY_DESCRIPTOR) NULL); - - *pPhysicalMemoryHandle = NULL; - - ntStatus = ZwOpenSection (pPhysicalMemoryHandle, - SECTION_ALL_ACCESS, - &ObjectAttributes); - - if (NT_SUCCESS(ntStatus)) - { - - ntStatus = ObReferenceObjectByHandle (*pPhysicalMemoryHandle, - SECTION_ALL_ACCESS, - (POBJECT_TYPE) NULL, - KernelMode, - &PhysicalMemorySection, - (POBJECT_HANDLE_INFORMATION) NULL); - - if (NT_SUCCESS(ntStatus)) - { - - pStartPhysAddress.QuadPart = (ULONGLONG)pPhysAddress; - - pEndPhysAddress = RtlLargeIntegerAdd (pStartPhysAddress, - RtlConvertUlongToLargeInteger(PhysMemSizeInBytes)); - - IsIOSpace = 0; - - Result1 = HalTranslateBusAddress (1, 0, pStartPhysAddress, &IsIOSpace, &pStartPhysAddress); - - IsIOSpace = 0; - - Result2 = HalTranslateBusAddress (1, 0, pEndPhysAddress, &IsIOSpace, &pEndPhysAddress); - - if (Result1 && Result2) - { - - MappingLength = RtlLargeIntegerSubtract (pEndPhysAddress, pStartPhysAddress); - - if (MappingLength.LowPart) - { - - // Let ZwMapViewOfSection pick a linear address - - PhysMemSizeInBytes = MappingLength.LowPart; - - ViewBase = pStartPhysAddress; - - ntStatus = ZwMapViewOfSection (*pPhysicalMemoryHandle, - (HANDLE) -1, - &pbPhysMemLin, - 0L, - PhysMemSizeInBytes, - &ViewBase, - &PhysMemSizeInBytes, - ViewShare, - 0, - PAGE_READWRITE | PAGE_NOCACHE); - - if (!NT_SUCCESS(ntStatus)) - OutputDebugString ("ERROR: ZwMapViewOfSection failed"); - else - { - pbPhysMemLin += (ULONG)pStartPhysAddress.LowPart - (ULONG)ViewBase.LowPart; - *ppPhysMemLin = pbPhysMemLin; - } - } - else - OutputDebugString ("ERROR: RtlLargeIntegerSubtract failed"); - } - else - OutputDebugString ("ERROR: MappingLength = 0"); - } - else - OutputDebugString ("ERROR: ObReferenceObjectByHandle failed"); - } - else - OutputDebugString ("ERROR: ZwOpenSection failed"); - - if (!NT_SUCCESS(ntStatus)) - ZwClose(*pPhysicalMemoryHandle); - - OutputDebugString ("Leaving MapPhysicalMemoryToLinearSpace"); - - return ntStatus; -} - - -NTSTATUS UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PVOID pPhysMemLin) -{ - NTSTATUS ntStatus; - - OutputDebugString ("Entering UnmapPhysicalMemory"); - - ntStatus = ZwUnmapViewOfSection((HANDLE)-1, pPhysMemLin); - - if (!NT_SUCCESS(ntStatus)) - OutputDebugString ("ERROR: UnmapViewOfSection failed"); - - ZwClose(PhysicalMemoryHandle); - - OutputDebugString ("Leaving UnmapPhysicalMemory"); - - return ntStatus; -} diff --git a/Source/Drv/NT/WinIo_NT.h b/Source/Drv/NT/WinIo_NT.h deleted file mode 100644 index ca8b181..0000000 --- a/Source/Drv/NT/WinIo_NT.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef WINIONT_H -#define WINIONT_H - -// Define the various device type values. Note that values used by Microsoft -// Corporation are in the range 0-32767, and 32768-65535 are reserved for use -// by customers. - -#define FILE_DEVICE_WINIO 0x00008010 - -// Macro definition for defining IOCTL and FSCTL function control codes. -// Note that function codes 0-2047 are reserved for Microsoft Corporation, -// and 2048-4095 are reserved for customers. - -#define WINIO_IOCTL_INDEX 0x810 - -// Define our own private IOCTL - -#define IOCTL_WINIO_MAPPHYSTOLIN CTL_CODE(FILE_DEVICE_WINIO, \ - WINIO_IOCTL_INDEX, \ - METHOD_BUFFERED, \ - FILE_ANY_ACCESS) - -#define IOCTL_WINIO_UNMAPPHYSADDR CTL_CODE(FILE_DEVICE_WINIO, \ - WINIO_IOCTL_INDEX + 1, \ - METHOD_BUFFERED, \ - FILE_ANY_ACCESS) - -#define IOCTL_WINIO_ENABLEDIRECTIO CTL_CODE(FILE_DEVICE_WINIO, \ - WINIO_IOCTL_INDEX + 2, \ - METHOD_BUFFERED, \ - FILE_ANY_ACCESS) - -#define IOCTL_WINIO_DISABLEDIRECTIO CTL_CODE(FILE_DEVICE_WINIO, \ - WINIO_IOCTL_INDEX + 3, \ - METHOD_BUFFERED, \ - FILE_ANY_ACCESS) - -#pragma pack(1) - -struct tagPhys32Struct -{ - HANDLE PhysicalMemoryHandle; - ULONG dwPhysMemSizeInBytes; - PVOID pvPhysAddress; - PVOID pvPhysMemLin; -}; - -extern struct tagPhys32Struct Phys32Struct; - -#endif diff --git a/Source/Drv/NT/SOURCES b/Source/Drv/SOURCES similarity index 100% rename from Source/Drv/NT/SOURCES rename to Source/Drv/SOURCES diff --git a/Source/Drv/WinIo.c b/Source/Drv/WinIo.c new file mode 100644 index 0000000..93aa5b3 --- /dev/null +++ b/Source/Drv/WinIo.c @@ -0,0 +1,478 @@ +// ---------------------------------------------------- // +// WinIo v3.0 // +// Direct Hardware Access for Windows // +// Copyright 1998-2010 Yariv Kaplan // +// http://www.internals.com // +// ---------------------------------------------------- // + +#include +#include "winio_nt.h" + +#define IOPM_SIZE 0x2000 +typedef char IOPM[IOPM_SIZE]; + +// Function definition section +// ----------------------------------------------------------------- +NTSTATUS WinIoDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); +void WinIoUnload(IN PDRIVER_OBJECT DriverObject); +NTSTATUS UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PVOID pPhysMemLin, PVOID PhysSection); +NTSTATUS MapPhysicalMemoryToLinearSpace(PVOID pPhysAddress, + SIZE_T PhysMemSizeInBytes, + PVOID *ppPhysMemLin, + HANDLE *pPhysicalMemoryHandle, + PVOID *ppPhysSection); + +#ifndef AMD64 +void Ke386SetIoAccessMap(int, IOPM *); +void Ke386QueryIoAccessMap(int, IOPM *); +void Ke386IoSetAccessProcess(PEPROCESS, int); +#endif + +// ----------------------------------------------------------------- + +// Installable driver initialization entry point. +// This entry point is called directly by the I/O system. + +NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegistryPath) +{ + UNICODE_STRING DeviceNameUnicodeString; + UNICODE_STRING DeviceLinkUnicodeString; + NTSTATUS ntStatus; + PDEVICE_OBJECT DeviceObject = NULL; + + KdPrint(("Entering DriverEntry")); + + RtlInitUnicodeString (&DeviceNameUnicodeString, L"\\Device\\WinIo"); + + // Create a device object + + ntStatus = IoCreateDevice (DriverObject, + 0, + &DeviceNameUnicodeString, + FILE_DEVICE_WINIO, + 0, + FALSE, + &DeviceObject); + + if (NT_SUCCESS(ntStatus)) + { + // Create dispatch points for device control, create, close. + + DriverObject->MajorFunction[IRP_MJ_CREATE] = + DriverObject->MajorFunction[IRP_MJ_CLOSE] = + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = WinIoDispatch; + DriverObject->DriverUnload = WinIoUnload; + + // Create a symbolic link, e.g. a name that a Win32 app can specify + // to open the device. + + RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\WinIo"); + + ntStatus = IoCreateSymbolicLink (&DeviceLinkUnicodeString, + &DeviceNameUnicodeString); + + if (!NT_SUCCESS(ntStatus)) + { + // Symbolic link creation failed- note this & then delete the + // device object (it's useless if a Win32 app can't get at it). + + KdPrint(("ERROR: IoCreateSymbolicLink failed")); + + IoDeleteDevice (DeviceObject); + } + + } + else + { + KdPrint(("ERROR: IoCreateDevice failed")); + } + + KdPrint(("Leaving DriverEntry")); + + return ntStatus; +} + + +// Process the IRPs sent to this device + +NTSTATUS WinIoDispatch(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IrpStack; + ULONG dwInputBufferLength; + ULONG dwOutputBufferLength; + ULONG dwIoControlCode; + PVOID pvIOBuffer; + NTSTATUS ntStatus; + IOPM* pIOPM = NULL; + struct tagPhysStruct PhysStruct; + struct tagPortStruct PortStruct; + struct tagPhysStruct32 *pPhysStruct32 = NULL; + + KdPrint(("Entering WinIoDispatch")); + + // Init to default settings + + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + + IrpStack = IoGetCurrentIrpStackLocation(Irp); + + // Get the pointer to the input/output buffer and it's length + + pvIOBuffer = Irp->AssociatedIrp.SystemBuffer; + dwInputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength; + dwOutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength; + + switch (IrpStack->MajorFunction) + { + case IRP_MJ_CREATE: + + KdPrint(("IRP_MJ_CREATE")); + + break; + + case IRP_MJ_CLOSE: + + KdPrint(("IRP_MJ_CLOSE")); + + break; + + case IRP_MJ_DEVICE_CONTROL: + + KdPrint(("IRP_MJ_DEVICE_CONTROL")); + + dwIoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode; + + switch (dwIoControlCode) + { + // The Ke386 calls are no longer available on x64 Windows + +#ifndef AMD64 + case IOCTL_WINIO_ENABLEDIRECTIO: + + KdPrint(("IOCTL_WINIO_ENABLEDIRECTIO")); + + pIOPM = MmAllocateNonCachedMemory(sizeof(IOPM)); + + if (pIOPM) + { + RtlZeroMemory(pIOPM, sizeof(IOPM)); + + Ke386IoSetAccessProcess(PsGetCurrentProcess(), 1); + Ke386SetIoAccessMap(1, pIOPM); + IrpStack->FileObject->FsContext2 = pIOPM; + } + else + Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; + + break; + + case IOCTL_WINIO_DISABLEDIRECTIO: + + KdPrint(("IOCTL_WINIO_DISABLEDIRECTIO")); + + pIOPM = (IOPM *)IrpStack->FileObject->FsContext2; + + if (pIOPM) + { + Ke386IoSetAccessProcess(PsGetCurrentProcess(), 0); + Ke386SetIoAccessMap(1, pIOPM); + MmFreeNonCachedMemory(pIOPM, sizeof(IOPM)); + } + + break; +#endif + + case IOCTL_WINIO_WRITEPORT: + + KdPrint(("IOCTL_WINIO_WRITEPORT")); + + if (dwInputBufferLength) + { + memcpy (&PortStruct, pvIOBuffer, dwInputBufferLength); + + switch (PortStruct.bSize) + { + case 1: + WRITE_PORT_UCHAR((PUCHAR)(USHORT)PortStruct.wPortAddr, (UCHAR)PortStruct.dwPortVal); + break; + + case 2: + WRITE_PORT_USHORT((PUSHORT)(USHORT)PortStruct.wPortAddr, (USHORT)PortStruct.dwPortVal); + break; + + case 4: + WRITE_PORT_ULONG((PULONG)(USHORT)PortStruct.wPortAddr, PortStruct.dwPortVal); + break; + } + } + else + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + + break; + + case IOCTL_WINIO_READPORT: + + KdPrint(("IOCTL_WINIO_READPORT")); + + if (dwInputBufferLength) + { + memcpy (&PortStruct, pvIOBuffer, dwInputBufferLength); + + switch (PortStruct.bSize) + { + case 1: + PortStruct.dwPortVal = (ULONG)READ_PORT_UCHAR((PUCHAR)(USHORT)PortStruct.wPortAddr); + break; + + case 2: + PortStruct.dwPortVal = (ULONG)READ_PORT_USHORT((PUSHORT)(USHORT)PortStruct.wPortAddr); + break; + + case 4: + PortStruct.dwPortVal = READ_PORT_ULONG((PULONG)(USHORT)PortStruct.wPortAddr); + break; + } + + memcpy (pvIOBuffer, &PortStruct.dwPortVal, sizeof(PortStruct.dwPortVal)); + Irp->IoStatus.Information = sizeof(PortStruct.dwPortVal); + } + else + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + + break; + + case IOCTL_WINIO_MAPPHYSTOLIN: + + KdPrint(("IOCTL_WINIO_MAPPHYSTOLIN")); + + if (dwInputBufferLength) + { + memcpy (&PhysStruct, pvIOBuffer, dwInputBufferLength); + + ntStatus = MapPhysicalMemoryToLinearSpace((PVOID)PhysStruct.pvPhysAddress, + (SIZE_T)PhysStruct.dwPhysMemSizeInBytes, + (PVOID *)&PhysStruct.pvPhysMemLin, + (HANDLE *)&PhysStruct.PhysicalMemoryHandle, + (PVOID *)&PhysStruct.pvPhysSection); + + if (NT_SUCCESS(ntStatus)) + { + memcpy (pvIOBuffer, &PhysStruct, dwInputBufferLength); + Irp->IoStatus.Information = dwInputBufferLength; + } + + Irp->IoStatus.Status = ntStatus; + } + else + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + + break; + + case IOCTL_WINIO_UNMAPPHYSADDR: + + KdPrint(("IOCTL_WINIO_UNMAPPHYSADDR")); + + if (dwInputBufferLength) + { + memcpy (&PhysStruct, pvIOBuffer, dwInputBufferLength); + + ntStatus = UnmapPhysicalMemory((HANDLE)PhysStruct.PhysicalMemoryHandle, (PVOID)PhysStruct.pvPhysMemLin, (PVOID)PhysStruct.pvPhysSection); + + Irp->IoStatus.Status = ntStatus; + } + else + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + + break; + + default: + + KdPrint(("ERROR: Unknown IRP_MJ_DEVICE_CONTROL")); + + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + + break; + } + + break; + } + + // DON'T get cute and try to use the status field of the irp in the + // return status. That IRP IS GONE as soon as you call IoCompleteRequest. + + ntStatus = Irp->IoStatus.Status; + + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + // We never have pending operation so always return the status code. + + KdPrint(("Leaving WinIoDispatch")); + + return ntStatus; +} + +// Delete the associated device and return + +void WinIoUnload(IN PDRIVER_OBJECT DriverObject) +{ + UNICODE_STRING DeviceLinkUnicodeString; + NTSTATUS ntStatus; + + KdPrint(("Entering WinIoUnload")); + + RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\WinIo"); + + ntStatus = IoDeleteSymbolicLink (&DeviceLinkUnicodeString); + + if (NT_SUCCESS(ntStatus)) + { + IoDeleteDevice (DriverObject->DeviceObject); + } + else + { + KdPrint(("ERROR: IoDeleteSymbolicLink")); + } + + KdPrint(("Leaving WinIoUnload")); +} + + +NTSTATUS MapPhysicalMemoryToLinearSpace(PVOID pPhysAddress, + SIZE_T PhysMemSizeInBytes, + PVOID *ppPhysMemLin, + HANDLE *pPhysicalMemoryHandle, + PVOID *ppPhysSection) +{ + UNICODE_STRING PhysicalMemoryUnicodeString; + OBJECT_ATTRIBUTES ObjectAttributes; + PHYSICAL_ADDRESS ViewBase; + NTSTATUS ntStatus; + PHYSICAL_ADDRESS pStartPhysAddress; + PHYSICAL_ADDRESS pEndPhysAddress; + BOOLEAN Result1, Result2; + ULONG IsIOSpace; + unsigned char *pbPhysMemLin = NULL; + + KdPrint(("Entering MapPhysicalMemoryToLinearSpace")); + + RtlInitUnicodeString (&PhysicalMemoryUnicodeString, L"\\Device\\PhysicalMemory"); + + InitializeObjectAttributes (&ObjectAttributes, + &PhysicalMemoryUnicodeString, + OBJ_CASE_INSENSITIVE, + (HANDLE) NULL, + (PSECURITY_DESCRIPTOR) NULL); + + *pPhysicalMemoryHandle = NULL; + *ppPhysSection = NULL; + + ntStatus = ZwOpenSection (pPhysicalMemoryHandle, SECTION_ALL_ACCESS, &ObjectAttributes); + + if (NT_SUCCESS(ntStatus)) + { + + ntStatus = ObReferenceObjectByHandle (*pPhysicalMemoryHandle, + SECTION_ALL_ACCESS, + (POBJECT_TYPE) NULL, + KernelMode, + ppPhysSection, + (POBJECT_HANDLE_INFORMATION) NULL); + + if (NT_SUCCESS(ntStatus)) + { + pStartPhysAddress.QuadPart = (ULONGLONG)(ULONG_PTR)pPhysAddress; + + pEndPhysAddress.QuadPart = pStartPhysAddress.QuadPart + PhysMemSizeInBytes; + + IsIOSpace = 0; + + Result1 = HalTranslateBusAddress (1, 0, pStartPhysAddress, &IsIOSpace, &pStartPhysAddress); + + IsIOSpace = 0; + + Result2 = HalTranslateBusAddress (1, 0, pEndPhysAddress, &IsIOSpace, &pEndPhysAddress); + + if (Result1 && Result2) + { + // Let ZwMapViewOfSection pick a linear address + + PhysMemSizeInBytes = (SIZE_T)pEndPhysAddress.QuadPart - (SIZE_T)pStartPhysAddress.QuadPart; + + ViewBase = pStartPhysAddress; + + ntStatus = ZwMapViewOfSection (*pPhysicalMemoryHandle, + (HANDLE) -1, + &pbPhysMemLin, + 0L, + PhysMemSizeInBytes, + &ViewBase, + &PhysMemSizeInBytes, + ViewShare, + 0, + PAGE_READWRITE | PAGE_NOCACHE); + + // If the physical memory is already mapped with a different caching attribute, try again + if (ntStatus == STATUS_CONFLICTING_ADDRESSES) + { + ntStatus = ZwMapViewOfSection (*pPhysicalMemoryHandle, + (HANDLE) -1, + &pbPhysMemLin, + 0L, + PhysMemSizeInBytes, + &ViewBase, + &PhysMemSizeInBytes, + ViewShare, + 0, + PAGE_READWRITE); + } + + + if (!NT_SUCCESS(ntStatus)) + KdPrint(("ERROR: ZwMapViewOfSection failed")); + else + { + pbPhysMemLin += pStartPhysAddress.QuadPart - ViewBase.QuadPart; + *ppPhysMemLin = pbPhysMemLin; + } + } + else + KdPrint(("ERROR: HalTranslateBusAddress failed")); + } + else + KdPrint(("ERROR: ObReferenceObjectByHandle failed")); + } + else + KdPrint(("ERROR: ZwOpenSection failed")); + + if (!NT_SUCCESS(ntStatus)) + ZwClose(*pPhysicalMemoryHandle); + + KdPrint(("Leaving MapPhysicalMemoryToLinearSpace")); + + return ntStatus; +} + + +NTSTATUS UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PVOID pPhysMemLin, PVOID pPhysSection) +{ + NTSTATUS ntStatus; + + KdPrint(("Entering UnmapPhysicalMemory")); + + ntStatus = ZwUnmapViewOfSection((HANDLE)-1, pPhysMemLin); + + if (!NT_SUCCESS(ntStatus)) + KdPrint(("ERROR: UnmapViewOfSection failed")); + + if (pPhysSection) + ObDereferenceObject(pPhysSection); + + ZwClose(PhysicalMemoryHandle); + + KdPrint(("Leaving UnmapPhysicalMemory")); + + return ntStatus; +} diff --git a/Source/Drv/winio_nt.h b/Source/Drv/winio_nt.h new file mode 100644 index 0000000..58a050e --- /dev/null +++ b/Source/Drv/winio_nt.h @@ -0,0 +1,69 @@ +#ifndef WINIONT_H +#define WINIONT_H + +// Define the various device type values. Note that values used by Microsoft +// Corporation are in the range 0-32767, and 32768-65535 are reserved for use +// by customers. + +#define FILE_DEVICE_WINIO 0x00008010 + +// Macro definition for defining IOCTL and FSCTL function control codes. +// Note that function codes 0-2047 are reserved for Microsoft Corporation, +// and 2048-4095 are reserved for customers. + +#define WINIO_IOCTL_INDEX 0x810 + +// Define our own private IOCTL + +#define IOCTL_WINIO_MAPPHYSTOLIN CTL_CODE(FILE_DEVICE_WINIO, \ + WINIO_IOCTL_INDEX, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_WINIO_UNMAPPHYSADDR CTL_CODE(FILE_DEVICE_WINIO, \ + WINIO_IOCTL_INDEX + 1, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_WINIO_ENABLEDIRECTIO CTL_CODE(FILE_DEVICE_WINIO, \ + WINIO_IOCTL_INDEX + 2, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_WINIO_DISABLEDIRECTIO CTL_CODE(FILE_DEVICE_WINIO, \ + WINIO_IOCTL_INDEX + 3, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_WINIO_READPORT CTL_CODE(FILE_DEVICE_WINIO, \ + WINIO_IOCTL_INDEX + 4, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_WINIO_WRITEPORT CTL_CODE(FILE_DEVICE_WINIO, \ + WINIO_IOCTL_INDEX + 5, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#pragma pack(push) +#pragma pack(1) + +struct tagPhysStruct +{ + DWORD64 dwPhysMemSizeInBytes; + DWORD64 pvPhysAddress; + DWORD64 PhysicalMemoryHandle; + DWORD64 pvPhysMemLin; + DWORD64 pvPhysSection; +}; + +struct tagPortStruct +{ + USHORT wPortAddr; + ULONG dwPortVal; + UCHAR bSize; +}; + +#pragma pack(pop) + +#endif