Operation of hardware ports under Windows---the use of Winio libraries

Source: Internet
Author: User

This article refers to an article on the Internet "VC 2010 under Winio 3.0 Direct Access I/O port";

Due to the kernel protection mechanism of windows, we cannot directly manipulate the hardware through the kernel, by using Winio, we can bypass this limitation and implement direct operation to the Windows hardware port or address. In practice, it is found that the Winio Library can operate on both normal I/O ports and Gpio.

There is a lot of reference on the Winio content network, which only records my own problems (points to note in the use):

You need to add a digital signature to the Winio.sys driver file under 1.64-bit operating systems.

2. Note the storage path of the two files for Winio.sys and WinIo.dll, which will cause the initialization to fail if the path is not correct.

3. Download down the Winio file has a DLL folder, if the failure to find initialization, we can break point tracking into the DLL to see where the problem. For example, when I use the win8.1 to find initialization failure, follow-up to find that the OpenSCManager () function returned false, is due to win8.1 user rights settings, by looking for the registry location of the response to initialize successfully (refer to the solution on the Internet).

4. Before using the Winio function we need to know which port to operate on, or the address location.

5. The DLL needs to be compiled based on the version of the response (32-bit/64-bit).

6. The operation Port needs to call the Getportval ()/setportval () function, and the Getphylong ()/setphylong () function should be called if the specific physical address is operational

Here is an example of a simple

1 //WinIoDemo.cpp: Defines the entry point of the console application.
4#include"stdafx.h"5#include <Windows.h>6#include <iostream>7#include"winio.h"8#include <conio.h>9#include"gpio_dll.h"Ten using namespacestd; One A #defineGpio_port 0xfed10000//assumed a specific object address - int_tmain (intARGC, _tchar*argv[]) - { + BOOLBresult; - +Bresult =Initializewinio (); A at if(!bresult) - { -cout<<"error to initialize Winio ..."<<Endl; - - return-1; - } in Else - { +UnsignedLongVal;
-UnsignedLongData;
theGetphyslong ((pbyte) gpio_port,&val);
*printf"Current Value:%4x \ n", Val); $ +Data = Val |0x02; Setting the Bit1 $ $printf"Current Value:%4x \ n", Data); - - BOOLBR =Setphyslong ((pbyte) gpio_port,data); the the Shutdownwinio (); the } theprintf"\npress AnyKey to continue ...");
the _getch ();
- return 0; in}

Operation of hardware ports under Windows---the use of Winio libraries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.