📄 1394api.c
字号:
if (!dwRet) {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
else {
dwRet = ERROR_SUCCESS;
}
// free up resources
CloseHandle(hDevice);
}
else {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
TRACE(TL_TRACE, (hWnd, "Exit BusReset = %d\r\n", dwRet));
return(dwRet);
} // BusReset
ULONG
WINAPI
GetGenerationCount(
HWND hWnd,
PSTR szDeviceName,
PULONG GenerationCount
)
{
HANDLE hDevice;
DWORD dwRet, dwBytesRet;
TRACE(TL_TRACE, (hWnd, "Enter GetGenerationCount\r\n"));
hDevice = OpenDevice(hWnd, szDeviceName, FALSE);
if (hDevice != INVALID_HANDLE_VALUE) {
dwRet = DeviceIoControl( hDevice,
IOCTL_GET_GENERATION_COUNT,
GenerationCount,
sizeof(ULONG),
GenerationCount,
sizeof(ULONG),
&dwBytesRet,
NULL
);
if (dwRet) {
dwRet = ERROR_SUCCESS;
TRACE(TL_TRACE, (hWnd, "GenerationCount = 0x%x\r\n", *GenerationCount));
}
else {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = %d\r\n", dwRet));
}
// free up resources
CloseHandle(hDevice);
}
else {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
TRACE(TL_TRACE, (hWnd, "Exit GetGenerationCount = %d\r\n", dwRet));
return(dwRet);
} // GetGenerationCount
ULONG
WINAPI
SendPhyConfigurationPacket(
HWND hWnd,
PSTR szDeviceName,
PPHY_CONFIGURATION_PACKET PhyConfigurationPacket
)
{
HANDLE hDevice;
DWORD dwRet, dwBytesRet;
TRACE(TL_TRACE, (hWnd, "Enter SendPhyConfigurationPacket\r\n"));
TRACE(TL_TRACE, (hWnd, "PCP_Phys_ID = 0x%x\r\n", PhyConfigurationPacket->PCP_Phys_ID));
TRACE(TL_TRACE, (hWnd, "PCP_Packet_ID = 0x%x\r\n", PhyConfigurationPacket->PCP_Packet_ID));
TRACE(TL_TRACE, (hWnd, "PCP_Gap_Count = 0x%x\r\n", PhyConfigurationPacket->PCP_Gap_Count));
TRACE(TL_TRACE, (hWnd, "PCP_Set_Gap_Count = 0x%x\r\n", PhyConfigurationPacket->PCP_Set_Gap_Count));
TRACE(TL_TRACE, (hWnd, "PCP_Force_Root = 0x%x\r\n", PhyConfigurationPacket->PCP_Force_Root));
TRACE(TL_TRACE, (hWnd, "PCP_Reserved1 = 0x%x\r\n", PhyConfigurationPacket->PCP_Reserved1));
TRACE(TL_TRACE, (hWnd, "PCP_Reserved2 = 0x%x\r\n", PhyConfigurationPacket->PCP_Reserved2));
TRACE(TL_TRACE, (hWnd, "PCP_Inverse = 0x%x\r\n", PhyConfigurationPacket->PCP_Inverse));
hDevice = OpenDevice(hWnd, szDeviceName, FALSE);
if (hDevice != INVALID_HANDLE_VALUE) {
dwRet = DeviceIoControl( hDevice,
IOCTL_SEND_PHY_CONFIGURATION_PACKET,
PhyConfigurationPacket,
sizeof(PHY_CONFIGURATION_PACKET),
NULL,
0,
&dwBytesRet,
NULL
);
if (!dwRet) {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
else {
dwRet = ERROR_SUCCESS;
}
// free up resources
CloseHandle(hDevice);
}
else {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
TRACE(TL_TRACE, (hWnd, "Exit SendPhyConfigurationPacket = %d\r\n", dwRet));
return(dwRet);
} // SendPhyConfigurationPacket
ULONG
WINAPI
BusResetNotification(
HWND hWnd,
PSTR szDeviceName,
ULONG fulFlags
)
{
HANDLE hDevice;
DWORD dwRet, dwBytesRet;
TRACE(TL_TRACE, (hWnd, "Enter BusResetNotification\r\n"));
TRACE(TL_TRACE, (hWnd, "fulFlags = 0x%x\r\n", fulFlags));
hDevice = OpenDevice(hWnd, szDeviceName, FALSE);
if (hDevice != INVALID_HANDLE_VALUE) {
dwRet = DeviceIoControl( hDevice,
IOCTL_BUS_RESET_NOTIFICATION,
&fulFlags,
sizeof(ULONG),
NULL,
0,
&dwBytesRet,
NULL
);
if (!dwRet) {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
else {
dwRet = ERROR_SUCCESS;
}
// free up resources
CloseHandle(hDevice);
}
else {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
TRACE(TL_TRACE, (hWnd, "Exit BusResetNotification = %d\r\n", dwRet));
return(dwRet);
} // BusResetNotification
ULONG
WINAPI
SetLocalHostInformation(
HWND hWnd,
PSTR szDeviceName,
PSET_LOCAL_HOST_INFORMATION SetLocalHostInfo
)
{
HANDLE hDevice;
DWORD dwRet, dwBytesRet;
TRACE(TL_TRACE, (hWnd, "Enter SetLocalHostInformation\r\n"));
TRACE(TL_TRACE, (hWnd, "nLevel = 0x%x\r\n", SetLocalHostInfo->nLevel));
TRACE(TL_TRACE, (hWnd, "ulBufferSize = 0x%x\r\n", SetLocalHostInfo->ulBufferSize));
if (SetLocalHostInfo->nLevel == SET_LOCAL_HOST_PROPERTIES_GAP_COUNT) {
PSET_LOCAL_HOST_PROPS2 LocalHostProps2;
LocalHostProps2 = (PSET_LOCAL_HOST_PROPS2)&SetLocalHostInfo->Information;
TRACE(TL_TRACE, (hWnd, "GapCountLowerBound = 0x%x\r\n", LocalHostProps2->GapCountLowerBound));
}
else if (SetLocalHostInfo->nLevel == SET_LOCAL_HOST_PROPERTIES_MODIFY_CROM) {
PSET_LOCAL_HOST_PROPS3 LocalHostProps3;
LocalHostProps3 = (PSET_LOCAL_HOST_PROPS3)&SetLocalHostInfo->Information;
TRACE(TL_TRACE, (hWnd, "fulFlags = 0x%x\r\n", LocalHostProps3->fulFlags));
if (LocalHostProps3->fulFlags == SLHP_FLAG_ADD_CROM_DATA) {
PULONG pUlong;
ULONG i;
TRACE(TL_TRACE, (hWnd, "nLength = 0x%x\r\n", LocalHostProps3->nLength));
pUlong = (PULONG)&LocalHostProps3->Buffer;
for (i=0; i<(LocalHostProps3->nLength/sizeof(ULONG)); i++) {
TRACE(TL_TRACE, (hWnd, "Buffer[0x%x] = 0x%x\r\n", i, *pUlong));
pUlong++;
}
}
else if (LocalHostProps3->fulFlags == SLHP_FLAG_REMOVE_CROM_DATA) {
TRACE(TL_TRACE, (hWnd, "hCromData = 0x%x\r\n", LocalHostProps3->hCromData));
}
}
TRACE(TL_TRACE, (hWnd, "SetLocalHostInfo = 0x%x\r\n", SetLocalHostInfo));
dwRet = 0;
hDevice = OpenDevice(hWnd, szDeviceName, FALSE);
if (hDevice != INVALID_HANDLE_VALUE) {
dwRet = DeviceIoControl( hDevice,
IOCTL_SET_LOCAL_HOST_INFORMATION,
SetLocalHostInfo,
sizeof(SET_LOCAL_HOST_INFORMATION)+SetLocalHostInfo->ulBufferSize,
SetLocalHostInfo,
sizeof(SET_LOCAL_HOST_INFORMATION)+SetLocalHostInfo->ulBufferSize,
&dwBytesRet,
NULL
);
if (!dwRet) {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
else {
PSET_LOCAL_HOST_PROPS3 LocalHostProps3;
LocalHostProps3 = (PSET_LOCAL_HOST_PROPS3)&SetLocalHostInfo->Information;
dwRet = ERROR_SUCCESS;
if (SetLocalHostInfo->nLevel == SET_LOCAL_HOST_PROPERTIES_MODIFY_CROM) {
if (LocalHostProps3->fulFlags == SLHP_FLAG_ADD_CROM_DATA) {
TRACE(TL_TRACE, (hWnd, "hCromData = 0x%x\r\n", LocalHostProps3->hCromData));
}
}
}
// free up resources
CloseHandle(hDevice);
}
else {
dwRet = GetLastError();
TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
}
TRACE(TL_TRACE, (hWnd, "Exit SetLocalHostInformation = %d\r\n", dwRet));
return(dwRet);
} // SetLocalHostInformation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -