?? audiorouting.cpp
字號:
pC->hThread = NULL;
}
}
DeleteCriticalSection( &pC->cs );
LocalFree( pC );
pC=NULL;
}
FUNCTRACEOUT();
return TRUE;
}
extern "C" __declspec(dllexport) ULONG ARS_Init(
ULONG Data
)
{
ARSCONTEXT *Context;
FUNCTRACEIN();
Context = (ARSCONTEXT*)LocalAlloc(LPTR, sizeof(ARSCONTEXT));
if ( Context )
{
InitializeCriticalSection( &Context->cs );
Context->hDllCoredll = LoadLibrary(TEXT("coredll.dll"));
if ( Context->hDllCoredll )
{
Context->pfnKernelIoControl = (_KernelIoControl)GetProcAddress(Context->hDllCoredll,TEXT("KernelIoControl"));
if ( NULL == Context->pfnKernelIoControl )
{
DebugMsg(L"Could not grab KernelIoControl\r\n");
ARS_Deinit( (ULONG)Context );
Context = NULL;
goto ErrorExit;
}
// Get CPU type
PROCESSOR_INFO pi;
ULONG bytesWritten;
BOOL bRet = Context->pfnKernelIoControl( IOCTL_PROCESSOR_INFORMATION, NULL, 0, &pi, sizeof( pi ), &bytesWritten);
if (bRet)
{
// look for OMAP730,850 or 1030
if ( wcsstr( pi.szProcessorName, L"OMAP730")
|| wcsstr( pi.szProcessorName, L"OMAP850")
|| wcsstr( pi.szProcessorName, L"OMAP1030") )
{
DebugMsg(L"ProcName: %s\r\n", pi.szProcessorName );
// Go with omap
Context->AudioRouting = (CAudioRouting *) new CAudioRoutingTIOmap();
bool boolRet = Context->AudioRouting->Init();
if ( !boolRet )
{
DebugMsg(L"Could not grab KernelIoControl\r\n");
delete Context->AudioRouting;
Context->AudioRouting = NULL;
ARS_Deinit( (ULONG)Context );
Context = NULL;
goto ErrorExit;
}
}
}
else
{
DebugMsg(L"KernelIoControl call failed %d", GetLastError() );
}
}
#if 0
// Start the service
if (StartService( Context ))
{
Context->ServiceStatus = SERVICE_STATE_ON;
}
#endif
}
ErrorExit:
FUNCTRACEOUT();
return (ULONG)Context;
}
extern "C" __declspec(dllexport) ULONG ARS_Open(
ULONG Data,
ULONG Access,
ULONG ShareMode
)
{
return Data;
}
extern "C" __declspec(dllexport) BOOL ARS_Close(
ULONG Data
)
{
return TRUE;
}
extern "C" __declspec(dllexport) ULONG ARS_Read(
ULONG Data,
LPVOID Buffer,
ULONG Length
)
{
return 0;
}
extern "C" __declspec(dllexport) ULONG ARS_Write(
ULONG Data,
LPVOID Buffer,
ULONG Length
)
{
return 0;
}
//______________________________________________________
extern "C" __declspec(dllexport) BOOL ARS_IOControl(
ULONG Data,
ULONG Code,
PBYTE pBufIn,
ULONG LenIn,
PBYTE pBufOut,
ULONG LenOut,
ULONG *pActualOut
)
{
ARSCONTEXT *pC = (ARSCONTEXT*)Data;
ULONG ErrorCode = ERROR_INVALID_PARAMETER;
BOOL bRet=FALSE;
FUNCTRACEIN();
DebugMsg(L"IOCTL_SERVICE_STATUS: %x (code:%x)\r\n", IOCTL_SERVICE_STATUS, Code);
switch (Code)
{
case IOCTL_SERVICE_START:
DebugMsg(L"IOCTL_SERVICE_START\r\n");
if ( SERVICE_STATE_ON == pC->ServiceStatus )
{
ErrorCode=ERROR_SERVICE_ALREADY_RUNNING;
}
else
{
if (StartService(pC))
{
pC->ServiceStatus = SERVICE_STATE_ON;
ErrorCode=ERROR_SUCCESS;
bRet = TRUE;
}
}
break;
case IOCTL_SERVICE_STOP:
DebugMsg(L"IOCTL_SERVICE_STOP\r\n");
if (SERVICE_STATE_ON == pC->ServiceStatus)
{
if (StopService(pC))
{
pC->ServiceStatus = SERVICE_STATE_OFF;
ErrorCode=ERROR_SUCCESS;
bRet = TRUE;
}
}
else
{
ErrorCode = ERROR_SERVICE_NOT_ACTIVE;
}
break;
case IOCTL_SERVICE_STATUS:
DebugMsg(L"IOCTL_SERVICE_STATUS\r\n");
if (pBufOut && (LenOut>=sizeof(ULONG)) )
{
*(ULONG*)pBufOut = pC->ServiceStatus;
if (pActualOut)
{
DebugMsg(L"ServiceStatus: %x\r\n",pC->ServiceStatus);
*pActualOut = sizeof(ULONG);
bRet=TRUE;
ErrorCode=ERROR_SUCCESS;
}
}
break;
case IOCTL_SERVICE_QUERY_CAN_DEINIT:
DebugMsg(L"IOCTL_SERVICE_QUERY_CAN_DEINIT\r\n");
if (pBufOut && (LenOut>=sizeof(ULONG)) )
{
*(ULONG*)pBufOut = TRUE;
if (pActualOut)
{
*pActualOut = sizeof(ULONG);
bRet=TRUE;
ErrorCode=ERROR_SUCCESS;
}
}
break;
case IOCTL_SERVICE_INSTALL:
DebugMsg(L"IOCTL_SERVICE_INSTALL\r\n");
break;
case IOCTL_SERVICE_UNINSTALL:
DebugMsg(L"IOCTL_SERVICE_UNINSTALL\r\n");
break;
default:
DebugMsg(L"ARS_IOControl: Unhandled IOCTL 0x%x\r\n", (Code >> 2) & 0x3fff);
break;
}
FUNCTRACEOUT();
SetLastError(ErrorCode);
return bRet;
}
extern "C" __declspec(dllexport) BOOL PopulateAudioRoutingServiceRegistry(void)
{
FUNCTRACEIN();
HKEY hKey;
ULONG Dispo;
long r=RegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", 0, NULL, 0, NULL, NULL, &hKey, &Dispo);
if (ERROR_SUCCESS!=r)
{
DebugMsg(L"Could not create HCConfigService key (%d)\r\n", GetLastError());
}
else
{
RegCloseKey(hKey);
}
HRESULT hr = RegistrySetString( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"Dll", L"AudioRouting.dll");
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n", L"Dll");
}
hr = RegistrySetString( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"Prefix", L"ARS");
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n", L"Prefix");
}
hr = RegistrySetString( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"DisplayName", L"ColumbusAudio");
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n", L"DisplayName");
}
hr = RegistrySetString( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"Description", L"Columbus Audio Rotuing Service");
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n", L"Description");
}
hr = RegistrySetDWORD( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"Flags", 0);
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n", L"Flags");
}
hr = RegistrySetDWORD( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"Index", 1);
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n", L"Index");
}
hr = RegistrySetDWORD( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"Keep", 1);
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n",L"Keep" );
}
hr = RegistrySetDWORD( HKEY_LOCAL_MACHINE, L"Services\\AudioRouting", L"Index", 80);
if (S_OK != hr)
{
DebugMsg(L"Failed to write reg key %s\r\n",L"Index" );
}
FUNCTRACEOUT();
return TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -