?? ioctrl_s.cpp
字號(hào):
{
PrintLine("Please input port number correctly.");
return IOCTRL_NORMAL;
}
wPort = LOWORD(dwPort); //Now,wPort contains the port where to output.
if(!Str2Hex(lpCmdObj->Parameter[2],&dwPort))
{
PrintLine("Please input the value to output correctly.");
return IOCTRL_NORMAL;
}
bt = LOBYTE(LOWORD(dwPort));
WriteByteToPort(bt,wPort); //Write the byte to port.
return IOCTRL_NORMAL;
}
static DWORD outputw(__CMD_PARA_OBJ* lpCmdObj)
{
WORD wr = 0;
WORD wPort = 0;
DWORD dwPort = 0;
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 3) //Not enough parameters.
{
PrintLine("Please input the port and value.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwPort))
{
PrintLine("Please input port number correctly.");
return IOCTRL_NORMAL;
}
wPort = LOWORD(dwPort); //Now,wPort contains the port where to output.
if(!Str2Hex(lpCmdObj->Parameter[2],&dwPort))
{
PrintLine("Please input the value to output correctly.");
return IOCTRL_NORMAL;
}
wr = LOWORD(dwPort);
WriteWordToPort(wr,wPort); //Write the byte to port.
return IOCTRL_NORMAL;
}
//
//The implementation of outputd.
//
static DWORD outputd(__CMD_PARA_OBJ* lpCmdObj)
{
WORD wPort = 0;
DWORD dwVal = 0L;
DWORD dwPort = 0L;
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 3) //Without enough parameter.
{
PrintLine("Please input the port and value.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwPort)) //Can not convert the port to hex.
{
PrintLine("Please input the port value correctly.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[2],&dwVal)) //Can not convert the value to hex.
{
PrintLine("Please input the value correctly.");
return IOCTRL_NORMAL;
}
wPort = LOWORD(dwPort);
#ifdef __I386
__asm{ //Output the double value to port.
push edx
push eax
mov dx,wPort
mov eax,dwVal
out dx,eax
pop eax
pop edx
}
#elif
#endif
return IOCTRL_NORMAL;
}
static DWORD outputsb(__CMD_PARA_OBJ* lpCmdObj)
{
return 0L;
}
static DWORD outputsw(__CMD_PARA_OBJ* lpCmdObj)
{
return 0L;
}
static DWORD memalloc(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwMemSize = 0L;
LPVOID lpMemAddr = NULL;
BYTE strBuffer[16];
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 2) //Not enough parameters.
{
PrintLine("Please input the memory size to be allocated.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwMemSize)) //Invalid size value.
{
PrintLine("Invalid memory size value.");
return IOCTRL_NORMAL;
}
lpMemAddr = KMemAlloc(dwMemSize,KMEM_SIZE_TYPE_ANY);
if(NULL == lpMemAddr) //Failed to allocate memory.
{
PrintLine("Can not allocate memory.");
return IOCTRL_NORMAL;
}
Hex2Str((DWORD)lpMemAddr,&strBuffer[4]); //Convert to string.
strBuffer[0] = ' ';
strBuffer[1] = ' ';
strBuffer[2] = '0';
strBuffer[3] = 'x';
PrintLine(strBuffer); //Print out the result.
return IOCTRL_NORMAL;
}
static DWORD memrels(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwMemAddr = 0L;
if(NULL == lpCmdObj)
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 2) //Not enough parameters.
{
PrintLine("Please input the memory address to be released.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwMemAddr)) //Invalid address value.
{
PrintLine("Please input the address correctly.");
return IOCTRL_NORMAL;
}
KMemFree((LPVOID)dwMemAddr,KMEM_SIZE_TYPE_ANY,0L); //Release the memory.
return IOCTRL_NORMAL;
}
static DWORD memwb(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwAddress = 0L;
BYTE bt = 0;
DWORD dwTmp = 0L;
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 3)
{
PrintLine("Please input the address and value together.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwAddress)) //Can not convert the address string to
//valid address.
{
PrintLine(" Please input correct address.");
return IOCTRL_NORMAL;
} //Now,dwAddress contains the target address to be write.
if(!Str2Hex(lpCmdObj->Parameter[2],&dwTmp)) //Invalid value.
{
PrintLine(" Please input the correct value.");
return IOCTRL_NORMAL;
}
bt = LOBYTE(LOWORD(dwTmp));
*((BYTE*)dwAddress) = bt; //Write the byte to the appropriate address.
return IOCTRL_NORMAL;
}
static DWORD memww(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwAddress = 0L;
WORD wr = 0;
DWORD dwTmp = 0L;
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 3)
{
PrintLine("Please input the address and value together.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwAddress)) //Can not convert the address string to
//valid address.
{
PrintLine(" Please input correct address.");
return IOCTRL_NORMAL;
} //Now,dwAddress contains the target address to be write.
if(!Str2Hex(lpCmdObj->Parameter[2],&dwTmp)) //Invalid value.
{
PrintLine(" Please input the correct value.");
return IOCTRL_NORMAL;
}
wr = LOWORD(dwTmp);
*((WORD*)dwAddress) = wr; //Write the byte to the appropriate address.
return IOCTRL_NORMAL;
}
static DWORD memwd(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwAddress = 0L;
//DWORD dwValue = 0;
DWORD dwTmp = 0L;
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 3)
{
PrintLine("Please input the address and value together.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwAddress)) //Can not convert the address string to
//valid address.
{
PrintLine(" Please input correct address.");
return IOCTRL_NORMAL;
} //Now,dwAddress contains the target address to be write.
if(!Str2Hex(lpCmdObj->Parameter[2],&dwTmp)) //Invalid value.
{
PrintLine(" Please input the correct value.");
return IOCTRL_NORMAL;
}
*((DWORD*)dwAddress) = dwTmp; //Write the byte to the appropriate address.
return IOCTRL_NORMAL;
}
static DWORD memrb(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwAddress = 0L;
BYTE bt = 0;
DWORD dwTmp = 0L;
BYTE strBuffer[16];
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 2) //Not enough parameter.
{
PrintLine("Please input the address where to read.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwAddress)) //Invalid address value.
{
PrintLine("Please input the correct address.");
return IOCTRL_NORMAL;
}
bt = *((BYTE*)dwAddress);
dwTmp += bt;
Hex2Str(dwTmp,&strBuffer[4]); //Convert to string.
strBuffer[0] = ' ';
strBuffer[1] = ' ';
strBuffer[2] = '0';
strBuffer[3] = 'x';
PrintLine(strBuffer); //Print out the result.
return IOCTRL_NORMAL;
}
static DWORD memrw(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwAddress = 0L;
WORD wr = 0;
DWORD dwTmp = 0L;
BYTE strBuffer[16];
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 2) //Not enough parameter.
{
PrintLine("Please input the address where to read.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwAddress)) //Invalid address value.
{
PrintLine("Please input the correct address.");
return IOCTRL_NORMAL;
}
wr = *((WORD*)dwAddress);
dwTmp += wr;
Hex2Str(dwTmp,&strBuffer[4]); //Convert to string.
strBuffer[0] = ' ';
strBuffer[1] = ' ';
strBuffer[2] = '0';
strBuffer[3] = 'x';
PrintLine(strBuffer); //Print out the result.
return IOCTRL_NORMAL;
}
static DWORD memrd(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwAddress = 0L;
DWORD dwTmp = 0L;
BYTE strBuffer[16];
if(NULL == lpCmdObj) //Parameter check.
return IOCTRL_TERMINAL;
if(lpCmdObj->byParameterNum < 2) //Not enough parameter.
{
PrintLine("Please input the address where to read.");
return IOCTRL_NORMAL;
}
if(!Str2Hex(lpCmdObj->Parameter[1],&dwAddress)) //Invalid address value.
{
PrintLine("Please input the correct address.");
return IOCTRL_NORMAL;
}
dwTmp = *((DWORD*)dwAddress);
Hex2Str(dwTmp,&strBuffer[4]); //Convert to string.
strBuffer[0] = ' ';
strBuffer[1] = ' ';
strBuffer[2] = '0';
strBuffer[3] = 'x';
PrintLine(strBuffer); //Print out the result.
return IOCTRL_NORMAL;
}
static DWORD help(__CMD_PARA_OBJ* lpCmdObj)
{
DWORD dwMapIndex = 0L;
PrintLine("Application is used to control IO port:");
while(IOCtrlCmdMap[dwMapIndex].lpszHelpInfo)
{
PrintLine(IOCtrlCmdMap[dwMapIndex].lpszHelpInfo);
dwMapIndex ++;
}
return 0L;
}
static DWORD exit(__CMD_PARA_OBJ* lpCmdObj)
{
return IOCTRL_TERMINAL;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -