博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
InpOut32 InputTest.cpp hacking
阅读量:7283 次
发布时间:2019-06-30

本文共 3613 字,大约阅读时间需要 12 分钟。

/************************************************************************************ *                       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 Inpout32lpOut32 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 >> 9));    Sleep(10);    gfpOut32(0x61, gfpInp32(0x61) | 0x03);}void StopBeep(){    gfpOut32(0x61, (gfpInp32(0x61) & 0xFC));}int main(int argc, char* argv[]){    if(argc<3)    {        //too few command line arguments, show usage        printf("Error : too few arguments\n\n***** Usage *****\n\nInpoutTest read 
\nor \nInpoutTest write
\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(2000); Sleep(200); Beep(1000); Sleep(300); Beep(2000); Sleep(250); StopBeep(); if(!strcmp(argv[1],"read")) { // 字符串转数字,并读取相关地址上的数据 short iPort = atoi(argv[2]); WORD wData = gfpInp32(iPort); //Read the port printf("Data read from address %s is %d \n\n\n\n", argv[2], wData); } else if(!strcmp(argv[1],"write")) { if(argc<4) { printf("Error in arguments supplied"); printf("\n***** Usage *****\n\nInpoutTest read
\nor \nInpoutTest write
\n\n\n\n\n"); } else { // 字符串转数字,并写入数据到相关地址上 short iPort = atoi(argv[2]); WORD wData = atoi(argv[3]); gfpOut32(iPort, wData); printf("data written to %s\n\n\n", argv[2]); } } } else { printf("Unable to open InpOut32 Driver!\n"); } //All done FreeLibrary ( hInpOutDll ) ; return 0; } else { printf("Unable to load InpOut32 DLL!\n"); return -1; } } return -2;}

 

转载地址:http://rwkjm.baihongyu.com/

你可能感兴趣的文章
令一个内容为数字字符串转换为对应的数字
查看>>
day18集合便利删除
查看>>
极简主义!让手机壁纸,惊现高级脸Feel~
查看>>
解决SQLite database is locked
查看>>
JAVA 添加、修改和删除PDF书签
查看>>
怎样配置主从同步结构
查看>>
开启mysql慢查询日志并使用mysqldumpslow命令查看
查看>>
centos下配置nginx支持php
查看>>
Linux服务器性能评估
查看>>
查看oracle当前连接数(转)
查看>>
14 用户组和权限管理4
查看>>
vmstat命令使用
查看>>
S9300端口流镜像
查看>>
mongoDB添加用户认证及简单的配置说明
查看>>
初始化的顺序
查看>>
我的友情链接
查看>>
美国主机商Webhostingpad推出中文站进军中国市场
查看>>
关于VMware HA的一些文章链接
查看>>
我的友情链接
查看>>
IDC简报:7月上旬国外最佳虚拟主机提供商Top5
查看>>