//////////////////////////////////////////////////////////////////////////
//
//
//
//
//////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
#pragma hdrstop
#pragma warning(disable:4312)
//
// #include "winio.h"
#include "IDE_DISK.H"
///////////////////////////////////
#define KBC_KEY_CMD 0x64 // keyboard command port
#define KBC_KEY_DATA 0x60 // keyboard data port
#define KEY_UP_CODE 0x80 // key down value OR this value means that release the key which has down
#define KEY_CMD_WRITE 0xD2 // tell the keyboard that data will be written
#define KEY_EXTERN_FLAG 0xE0 // shows that the key will be down is the extern key such as left,right,up,down,F1......
#define KEY_F1 0x70
#define KEY_CAPSLOCK 0x14
///////////////////////////////////////
//
// void Sound(DWORD freq)
// {
// DWORD data = 1;
// if ((freq > 20)&&(freq<20000))
// {
// freq = 1193181/freq;
// GetPortVal(0x61, &data, 1);
// // if (data & 3 ==0)
// // {
// SetPortVal(0x61, 0xff, 1); // port 61 is the speaker -----SetPortVal(0x61, 0xff, 1);//just 0xff can sound
// SetPortVal(0x43, 0x80, 1); //port 0x43 is the 8253/8254 timer controller port -----SetPortVal(0x43, 0xb6, 1)
// // }
// SetPortVal(0x42, (UCHAR)freq%256, 1); //port 0x42 is the 8253/8254 timer channel 2 port
// SetPortVal(0x42, (UCHAR)freq/256, 1);
// }
// }
//
// void NoSound(void)
// {
// DWORD data;
// GetPortVal(0x61,&data,1);
// SetPortVal(0x61,data&0xfc,1);
// }
//
//////////////////////////////////////////////////////////////////////////
//
//
//
//
//////////////////////////////////////////////////////////////////////////
void Sound(DWORD freq)
{
DWORD data = 100;
if ((freq > 20)&&(freq<20000))
{
freq = 1193181/freq;
GetPortVal(0x61, &data, 1);
if ((data & 3) ==0)
{
SetPortVal(0x61, 0xff, 1); // port 61 is the speaker -----SetPortVal(0x61, 0xff, 1);//just 0xff can sound
SetPortVal(0x43, 0xb6, 1); //port 0x43 is the 8253/8254 timer controller port -----SetPortVal(0x43, 0xb6, 1)
}
SetPortVal(0x42, (UCHAR)freq%256, 1); //port 0x42 is the 8253/8254 timer channel 2 port
SetPortVal(0x42, (UCHAR)freq/256, 1);
}
}
void NoSound(void)
{
DWORD data;
GetPortVal(0x61,&data,2);
SetPortVal(0x61,data&0xfc,2);
}
void PlayRhythm()
{
// music 1-2-3-4-5-6-7-8-8-7-6-5-4-3-2-1
Sound(204);
Sleep(600);
NoSound();
Sound(262);
Sleep(600);
NoSound();
Sound(320);
Sleep(600);
NoSound();
Sound(378);
Sleep(600);
NoSound();
Sound(436);
Sleep(600);
NoSound();
Sound(494);
Sleep(600);
NoSound();
Sound(554);
Sleep(600);
NoSound();
Sound(612);
Sleep(600);
NoSound();
Sleep(1000);
Sound(612);
Sleep(600);
NoSound();
Sound(554);
Sleep(600);
NoSound();
Sound(494);
Sleep(600);
NoSound();
Sound(436);
Sleep(600);
NoSound();
Sound(378);
Sleep(600);
NoSound();
Sound(320);
Sleep(600);
NoSound();
Sound(262);
Sleep(600);
NoSound();
Sound(204);
Sleep(600);
NoSound();
}
//////////////////////////////////////////////////////////////////////////
//
//
//
//
//////////////////////////////////////////////////////////////////////////
void kbcWait4IBE()
{
DWORD dwRegVal = 0;
do
{
GetPortVal(0x64,&dwRegVal,1);
// if(dwRegVal!=0)
// {
// TCHAR szBuf[1024];
// wsprintf(szBuf,
// "Data of keyboard port:%d", dwRegVal);
// MessageBox(NULL, szBuf, "Result", MB_OK);
// }
} while (dwRegVal&0x00000002);
}
void KeyDownEx(BYTE bvKeyCode)
{
DWORD dwScanCode_bvKeyCode;
dwScanCode_bvKeyCode = MapVirtualKey(bvKeyCode,0);
kbcWait4IBE();
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_DATA,KEY_EXTERN_FLAG,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_DATA,dwScanCode_bvKeyCode,1);
}
void KeyUpEx(BYTE bvKeyCode)
{
DWORD dwScanCode_bvKeyCode;
dwScanCode_bvKeyCode = MapVirtualKey(bvKeyCode,0);
kbcWait4IBE();
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_DATA,KEY_EXTERN_FLAG,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_DATA,(dwScanCode_bvKeyCode|KEY_UP_CODE),1);
}
void KeyDown(BYTE bvKeyCode)
{
DWORD dwScanCode_bvKeyCode;
dwScanCode_bvKeyCode = MapVirtualKey(bvKeyCode,0);
kbcWait4IBE();
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_DATA,dwScanCode_bvKeyCode,1);
}
void KeyUp(BYTE bvKeyCode)
{
DWORD dwScanCode_bvKeyCode;
dwScanCode_bvKeyCode = MapVirtualKey(bvKeyCode,0);
kbcWait4IBE();
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
kbcWait4IBE();
SetPortVal(KBC_KEY_DATA,(dwScanCode_bvKeyCode|KEY_UP_CODE),1);
}
void Key_Down_Release(BYTE bvKeyCode)
{
KeyDown(bvKeyCode);
Sleep(100);
KeyUp(bvKeyCode);
}
void Key_Down_Release_Ex(BYTE bvKeyCode)
{
KeyDownEx(bvKeyCode);
Sleep(100);
KeyUpEx(bvKeyCode);
}
void Key_Down_Release_After_Ex(BYTE bvKeyCode)
{
KeyDown(bvKeyCode);
KeyDown(bvKeyCode);
Sleep(100);
KeyUp(bvKeyCode);
}
void KeyBoardCapsLock()
{
DWORD dwScanCode_KEY_CAPSLOCK;
kbcWait4IBE();
dwScanCode_KEY_CAPSLOCK = MapVirtualKey(KEY_CAPSLOCK,0);
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
SetPortVal(KBC_KEY_DATA,dwScanCode_KEY_CAPSLOCK,1);
Sleep(100);
SetPortVal(KBC_KEY_CMD,KEY_CMD_WRITE,1);
SetPortVal(KBC_KEY_DATA,(dwScanCode_KEY_CAPSLOCK|KEY_UP_CODE),1);
}
//////////////////////////////////////////////////////////////////////////
//
//
//
//
//////////////////////////////////////////////////////////////////////////
void ReadHDParams(void)
{
TIdePortAddrItem ControllerPorts[] = {IDE1_Port, IDE2_Port};
char *ControllerNames[] = {"IDE0", "IDE1"};
char *HardDiskNames[] = {"主盘", "从盘"};
char HardDiskDetected; //bit 0:master, bit 1:slave
TIDE_ID_Inf IDE_Info;
char Str[128];
for(int i=0; i<2; i++)
{
HardDiskDetected=DetectHDD(ControllerPorts[i]);
switch(HardDiskDetected&3)
{
case 0: MessageBox(NULL,"没检测到硬盘","Message",MB_OK); break;
case 1: MessageBox(NULL,"检测到主盘","Message",MB_OK); break;
case 2: MessageBox(NULL,"检测到从盘","Message",MB_OK); break;
case 3: MessageBox(NULL,"检测到主盘和从盘","Message",MB_OK); break;
}
for(int k=0;k<2;k++) //primary/slave disk
if(HardDiskDetected & (1<<k))
{
TCHAR szBuf[1024];
GetHDDInfo(&IDE_Info, k, ControllerPorts[i]);
WordToStr((UCHAR*)Str, IDE_Info.nModel, 20);
wsprintf(szBuf,"Model: %s",Str);
MessageBox(NULL, szBuf,"Message",MB_OK);//型 号
WordToStr((UCHAR*)Str, IDE_Info.Serial, 10);
wsprintf(szBuf,"SerialNO: %s",Str);
MessageBox(NULL, szBuf,"Message",MB_OK);//序 列 号
WordToStr((UCHAR*)Str, IDE_Info.Revisn, 4);
wsprintf(szBuf,"Firmware Version: %s",Str);
MessageBox(NULL, szBuf,"Message",MB_OK);//固件版本
//---------- capacity
unsigned long LbaCap = (IDE_Info.LBASec)/2048, \
NomCap = ((unsigned long)(IDE_Info.L_Cyln)*(IDE_Info.L_Head)*(IDE_Info.L_Sect))/2048;
wsprintf(szBuf,"%lu Mb",LbaCap>NomCap?LbaCap:NomCap);
MessageBox(NULL, szBuf,"Message",MB_OK);
wsprintf(szBuf,"Cylinder NO.: %u", IDE_Info.L_Cyln);
MessageBox(NULL, szBuf,"Message",MB_OK);
}
}
}
//////////////////////////////////////////////////////////////////////////
//
//
//
//
//////////////////////////////////////////////////////////////////////////
//
// void main()
int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nShowCmd )
{
// DWORD dwPortVal;
DWORD dwMemVal;
bool bResult;
HANDLE hPhysicalMemory;
PBYTE pbLinAddr;
// Call InitializeWinIo to initialize the WinIo library.
bResult
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Include winio.sys,winio.dll,winio.lib,winiotest.exe and a sign tool, signtool.exe,winio.h,winiotest.cpp.you can use this .dll and .sys to directio as the winiotest.cpp does.
资源推荐
资源详情
资源评论
收起资源包目录
winio64.zip (8个子文件)
Realse
DriverSignatureBat.bat 394B
WinIo.lib 3KB
WinIoTest.cpp 9KB
winio.sys 11KB
WinIo.dll 548KB
signtool.exe 101KB
WinIo.h 1KB
WinIoTest.exe 543KB
共 8 条
- 1
资源评论
- menger7772014-06-08不知道怎么用,所以觉得没有用
世间一尘埃
- 粉丝: 0
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功