/************************************************************************************
* InpOut32 InputTest.cpp hacking
* 说明:
* 跟一下InputTest.cpp中InpOut32怎么使用。
*
* 2017-6-5 深圳 龙华樟坑村 曾剑锋
***********************************************************************************/ // InpoutTest.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include "windows.h"
#include "stdio.h" // 函数类型指针定义
typedef void (__stdcall *lpOut32)(short, short);
typedef short (__stdcall *lpInp32)(short);
typedef BOOL (__stdcall *lpIsInpOutDriverOpen)(void);
typedef BOOL (__stdcall *lpIsXP64Bit)(void); //Some global function pointers (messy but fine for an example)
// 函数指针声明,gfpOut32 = global function pointer Inpout32
lpOut32 gfpOut32;
lpInp32 gfpInp32;
lpIsInpOutDriverOpen gfpIsInpOutDriverOpen;
lpIsXP64Bit gfpIsXP64Bit; /**
* 下面链接中有解释以下Beep、StopBeep代码中的含义:
* How does the following code make PC beeps?
* https://stackoverflow.com/questions/5987683/how-does-the-following-code-make-pc-beeps
*/
void Beep(unsigned int freq)
{
gfpOut32(0x43, 0xB6);
gfpOut32(0x42, (freq & 0xFF));
gfpOut32(0x42, (freq >> ));
Sleep();
gfpOut32(0x61, gfpInp32(0x61) | 0x03);
} void StopBeep()
{
gfpOut32(0x61, (gfpInp32(0x61) & 0xFC));
} int main(int argc, char* argv[])
{
if(argc<)
{
//too few command line arguments, show usage
printf("Error : too few arguments\n\n***** Usage *****\n\nInpoutTest read <ADDRESS> \nor \nInpoutTest write <ADDRESS> <DATA>\n\n\n\n\n");
}
else
{
//Dynamically load the DLL at runtime (not linked at compile time)
// 在运行的时候动态加载DLL
HINSTANCE hInpOutDll ;
hInpOutDll = LoadLibrary ( "InpOut32.DLL" ) ; //The 32bit DLL. If we are building x64 C++
//applicaiton then use InpOutx64.dll
if ( hInpOutDll != NULL )
{
// 获取函数操作指针
gfpOut32 = (lpOut32)GetProcAddress(hInpOutDll, "Out32");
gfpInp32 = (lpInp32)GetProcAddress(hInpOutDll, "Inp32");
gfpIsInpOutDriverOpen = (lpIsInpOutDriverOpen)GetProcAddress(hInpOutDll, "IsInpOutDriverOpen");
gfpIsXP64Bit = (lpIsXP64Bit)GetProcAddress(hInpOutDll, "IsXP64Bit"); if (gfpIsInpOutDriverOpen())
{
//Make some noise through the PC Speaker - hey it can do more that a single beep using InpOut32
// 制造一些不同频率的噪声
Beep();
Sleep();
Beep();
Sleep();
Beep();
Sleep();
StopBeep(); if(!strcmp(argv[],"read"))
{
// 字符串转数字,并读取相关地址上的数据
short iPort = atoi(argv[]);
WORD wData = gfpInp32(iPort); //Read the port
printf("Data read from address %s is %d \n\n\n\n", argv[], wData);
}
else if(!strcmp(argv[],"write"))
{
if(argc<)
{
printf("Error in arguments supplied");
printf("\n***** Usage *****\n\nInpoutTest read <ADDRESS> \nor \nInpoutTest write <ADDRESS> <DATA>\n\n\n\n\n");
}
else
{
// 字符串转数字,并写入数据到相关地址上
short iPort = atoi(argv[]);
WORD wData = atoi(argv[]);
gfpOut32(iPort, wData);
printf("data written to %s\n\n\n", argv[]);
}
}
}
else
{
printf("Unable to open InpOut32 Driver!\n");
} //All done
FreeLibrary ( hInpOutDll ) ;
return ;
}
else
{
printf("Unable to load InpOut32 DLL!\n");
return -;
}
}
return -;
}

InpOut32 InputTest.cpp hacking的更多相关文章

  1. InpOut32 CSharpExample.cs hacking

    /************************************************************************************ * InpOut32 CSh ...

  2. Qt 控制watchdog app hacking

    /************************************************************************** * Qt 控制watchdog app hack ...

  3. Qt 获取usb设备信息 hacking

    /************************************************************************** * Qt 获取usb设备信息 hacking * ...

  4. eclipse mingw cpp开发环境

    Eclipse开发c++ 对比:微软的VC++6.0:太老了,对win7兼容不好, 现在微软的Visual Studio:安装包太大,好几个G,装了一堆你不需要的东西,要钱,教 育版申请麻烦 DOS下 ...

  5. OK335xS Qt network hacking

    /********************************************************************** * OK335xS Qt network hacking ...

  6. Android Mokoid Open Source Project hacking

    /***************************************************************************** * Android Mokoid Open ...

  7. Qt Quick Hello World hacking

    /********************************************************************************************* * Qt ...

  8. Qt QML referenceexamples attached Demo hacking

    /********************************************************************************************* * Qt ...

  9. 使用“Cocos引擎”创建的cpp工程如何在VS中调试Cocos2d-x源码

    前段时间Cocos2d-x更新了一个Cocos引擎,这是一个集合源码,IDE,Studio这一家老小的整合包,我们可以使用这个Cocos引擎来创建我们的项目. 在Cocos2d-x被整合到Cocos引 ...

随机推荐

  1. springmvc RequestParam、RequestHeader

    /** * 了解: * * @CookieValue: 映射一个 Cookie 值. 属性同 @RequestParam */ @RequestMapping("/testCookieVal ...

  2. menubar下面的选项不可以输入中文

    这是一个QT5的bug. 1.不用中文,使用英文: 2.先输入中文,然后在属性Action里面的text里改成中文.

  3. centos7下安装ngnix1.8.1

    参考 http://www.linuxidc.com/Linux/2016-09/134907.htm 安装依赖 openssl zlib pcre gcc 下载安装包 [root@localhost ...

  4. cf780c

                                                                                             C. Andryush ...

  5. LeetCode——Detect Capital

    LeetCode--Detect Capital Question Given a word, you need to judge whether the usage of capitals in i ...

  6. git原理学习

    http://git.oschina.net/progit/   这一点值得牢记:Git 会把工作目录的内容恢复为检出某分支时它所指向的那个提交对象的快照.它会自动添加.删除和修改文件以确保目录的内容 ...

  7. 对拷 使用scp命令在两台linux上对拷文件或者文件夹

    以前一直是在服务器上tar打包压缩,下载到本地电脑上,再上传到另外一台服务器上,再解压. 其实使用scp命令就可以直接对拷文件或者文件夹了. scp就是secure copy,是用来进行远程文件拷贝的 ...

  8. spring的cglib代理

    1.被代理类Person.java package com.xiaostudy; /** * @desc 被代理类 * * @author xiaostudy * */ public class Pe ...

  9. eclipse——添加Tomcat7.0服务器

    首先要安装好Tomcat 然后在eclipse中添加Tomcat 步骤如下 详细可参考这篇博客https://blog.csdn.net/u014079773/article/details/5139 ...

  10. Java解析XML的四种方法详解 - 转载

    XML现在已经成为一种通用的数据交换格式,平台的无关性使得很多场合都需要用到XML.本文将详细介绍用Java解析XML的四种方法 在做一般的XML数据交换过程中,我更乐意传递XML字符串,而不是格式化 ...