InpOut32 InputTest.cpp hacking
/************************************************************************************
* 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的更多相关文章
- InpOut32 CSharpExample.cs hacking
/************************************************************************************ * InpOut32 CSh ...
- Qt 控制watchdog app hacking
/************************************************************************** * Qt 控制watchdog app hack ...
- Qt 获取usb设备信息 hacking
/************************************************************************** * Qt 获取usb设备信息 hacking * ...
- eclipse mingw cpp开发环境
Eclipse开发c++ 对比:微软的VC++6.0:太老了,对win7兼容不好, 现在微软的Visual Studio:安装包太大,好几个G,装了一堆你不需要的东西,要钱,教 育版申请麻烦 DOS下 ...
- OK335xS Qt network hacking
/********************************************************************** * OK335xS Qt network hacking ...
- Android Mokoid Open Source Project hacking
/***************************************************************************** * Android Mokoid Open ...
- Qt Quick Hello World hacking
/********************************************************************************************* * Qt ...
- Qt QML referenceexamples attached Demo hacking
/********************************************************************************************* * Qt ...
- 使用“Cocos引擎”创建的cpp工程如何在VS中调试Cocos2d-x源码
前段时间Cocos2d-x更新了一个Cocos引擎,这是一个集合源码,IDE,Studio这一家老小的整合包,我们可以使用这个Cocos引擎来创建我们的项目. 在Cocos2d-x被整合到Cocos引 ...
随机推荐
- [翻译]Feedback on the Go Challenge solutions
第一次Go Challenge比赛,中国区只有3人参赛. 赛后收到邮件,是一个审阅者的反馈,“Feedback on the Go Challenge solutions”,摘录如下: 保持简单粗暴 ...
- LightOJ - 1370 Bi-shoe and Phi-shoe (欧拉函数打表)
题意:给N个数,求对每个数ai都满足最小的phi[x]>=ai的x之和. 分析:先预处理出每个数的欧拉函数值phi[x].对于每个数ai对应的最小x值,既可以二分逼近求出,也可以预处理打表求. ...
- 在Ubuntu上安装Brackets的步骤(加源和移除源)
学习编写接口开发和测试时需要用到编写HTML页面,在Windows下采用的是HBuilder,但是无Ubuntu版本.安装一个网上推荐的Brackets 安装步骤:参见http://www.xiton ...
- poj2993
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; stru ...
- jQuery多级联动美化版Select下拉框
在线演示 本地下载
- Percona-Server-5.7.16 启动错误
基于:percona-server-5.7.16 启动报错: [root@monitor mysql]# ./bin/mysqld_safe --defaults-file=/data/config ...
- Spring_使用外部属性文件
beans-properties.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns ...
- 基于mysql数据库集群的360度水平切割
1.why sharding? 我们都知道,信息行业发展日益迅速,积累下来的数据信息越来越多,互联网公司门要维护的数据日益庞大.设想一下,假如腾讯公司只用一个数据库的一张表格来存储所有qq注册用户的登 ...
- 从reduce函数说起...
reduce函数: 方法接收一个函数作为累加器(accumulator),数组中的每个值(从左到右)开始缩减,最终为一个值, 最终返回的要看函数内部return的内容. 1. 累加器: var ar ...
- Hebernate -- 映射继承关系
1. Employee 为基类, 派生出HourEmployee 和 SalaryEmployee两个类. 采用 subclass 元素的继承映射(1) 采用 subclass 的继承映射可以实现对于 ...