/* (C) 2003 XDA Developers itsme@xs4all.nl * * $Header$ */ // web: http://www.xs4all.nl/~itsme/projects/xda/rilhook.html // // this logs all ril events and results, while running some // tests, and calling our own newly installed ioctl. // #include #include "debug.h" #include "stringutils.h" #include "ril.h" #include "riltest.h" // this function is called after the DeviceIoControl in ril.dll // typedef void (*PFN_UnknownRilFN)(DWORD r0, HRIL hRil); PFN_UnknownRilFN unknownrilfn; RilTest::RilTest() { m_hRil= 0; m_hRilDev= NULL; unknownrilfn= (PFN_UnknownRilFN)0xcd2d48; } RilTest::~RilTest() { close(); } bool RilTest::open(DWORD dwIndex) { HRESULT res= RIL_Initialize(dwIndex, &ResultProc, &NotifyProc, -1, (DWORD)this, &m_hRil); if (res) { error("RIL_Initialize: %08lx\n", res); return false; } m_hRilDev= CreateFile(L"RIL1:", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0); if (m_hRilDev==NULL || m_hRilDev==INVALID_HANDLE_VALUE) { error("CreateFile('RIL1:')"); m_hRilDev= NULL; return false; } return true; } bool RilTest::close() { bool bRes= true; if (m_hRil) { HRESULT res= RIL_Deinitialize(m_hRil); if (res) { error("RIL_Deinitialize: %08lx\n", res); bRes= false; } m_hRil= 0; } if (m_hRilDev) { CloseHandle(m_hRilDev); m_hRilDev= NULL; } return bRes; } void RilTest::ResultProc(DWORD dwCode, HRESULT hrCmdID, const void *lpData, DWORD cbdata, DWORD dwParam) { ((RilTest*)dwParam)->HandleResult(dwCode, hrCmdID, lpData, cbdata); } void RilTest::NotifyProc(DWORD dwCode, const void *lpData, DWORD cbdata, DWORD dwParam) { ((RilTest*)dwParam)->HandleNotify(dwCode, lpData, cbdata); } void RilTest::HandleResult(DWORD dwCode, HRESULT hrCmdID, const void *lpData, DWORD cbdata) { debug("RES: %08lx %08lx %hs\n", dwCode, hrCmdID, hexdump((const BYTE*)lpData, cbdata).c_str()); } void RilTest::HandleNotify(DWORD dwCode, const void *lpData, DWORD cbdata) { debug("NOT: %08lx %hs\n", dwCode, hexdump((const BYTE*)lpData, cbdata).c_str()); } bool RilTest::testnonioctl() { DWORD prm[2]; prm[0]= 0; prm[1]= 100; DWORD rildevresult; DWORD nReturned; if (!DeviceIoControl(m_hRilDev, 0x03000800L,prm,sizeof(prm), &rildevresult, sizeof(rildevresult), &nReturned,0)) { error("DeviceIoControl('RIL1:', 0x03000800L)"); return false; } debug("ioctl(%08lx, 03000800) : res=%08lx nret=%08lx\n", m_hRilDev, rildevresult, nReturned); unknownrilfn(((DWORD)m_hRil)+0x23c, m_hRil); return true; } bool RilTest::testioctlmsgcfg() { DWORD rildevresult; DWORD nReturned; if (!DeviceIoControl(m_hRilDev, 0x030000fc,NULL,0, &rildevresult, sizeof(rildevresult), &nReturned,0)) { error("DeviceIoControl('RIL1:', 0x030000fc)"); return false; } debug("ioctl(%08lx, 030000fc) : res=%08lx nret=%08lx\n", m_hRilDev, rildevresult, nReturned); return true; } void RilTest::testmostril() { //HRESULT RIL_GetCallBarringStatus(HRIL hRil, DWORD dwType, DWORD dwInfoClass, LPCSTR lpszPassword); //HRESULT RIL_GetCallForwardingSettings(HRIL hRil, DWORD dwReason, DWORD dwAddressId); //HRESULT RIL_GetLockingStatus(HRIL hRil, DWORD dwFacility, LPCSTR lpszPassword); for (DWORD cmd=0 ; cmd<35 ; cmd++) { Sleep(500); debug("RIL_DevSpecific(%d): %08lx\n", cmd, RIL_DevSpecific(m_hRil, (BYTE*)&cmd, sizeof(cmd))); } Sleep(500); debug("RIL_GetCCBSStatus(1): %08lx\n", RIL_GetCCBSStatus(m_hRil, 0)); Sleep(500); debug("RIL_GetCurrentOperator(1): %08lx\n", RIL_GetCurrentOperator(m_hRil, 0)); Sleep(500); debug("RIL_GetDevCaps(1): %08lx\n", RIL_GetDevCaps(m_hRil, 0)); Sleep(500); debug("RIL_GetGPRSAddress(1): %08lx\n", RIL_GetGPRSAddress(m_hRil, 0)); Sleep(500); debug("RIL_GetPreferredOperatorList(1): %08lx\n", RIL_GetPreferredOperatorList(m_hRil, 0)); DWORD radioPresence; Sleep(500); debug("RIL_GetRadioPresence: %08lx\n", RIL_GetRadioPresence(m_hRil, &radioPresence)); Sleep(500); debug(" radioPresence= %08lx\n", radioPresence); HANDLE handle; Sleep(500); debug("RIL_GetSerialPortHandle: %08lx\n", RIL_GetSerialPortHandle(m_hRil, &handle)); Sleep(500); debug(" handle=%08lx\n", handle); RILSERIALPORTSTATS stats; stats.cbSize= sizeof(RILSERIALPORTSTATS); Sleep(500); debug("RIL_GetSerialPortStatistics: %08lx\n", RIL_GetSerialPortStatistics(m_hRil, &stats)); Sleep(500); debug(" stats: params=%08lx readbps=%d writebps=%d\n", stats.dwParams, stats.dwReadBitsPerSecond, stats.dwWrittenBitsPerSecond); for (DWORD iSimRec= 0 ; iSimRec<10 ; iSimRec++) { Sleep(500); debug("RIL_GetSimRecordStatus(%d): %08lx\n", iSimRec, RIL_GetSimRecordStatus(m_hRil, iSimRec)); } for (DWORD iMsg= 0 ; iMsg<10 ; iMsg++) { Sleep(500); debug("RIL_ReadMsg(%d): %08lx\n", iMsg, RIL_ReadMsg(m_hRil, iMsg)); } Sleep(500); debug("RIL_ReadPhonebookEntries(0,10: %08lx\n", RIL_ReadPhonebookEntries(m_hRil, 0, 10)); Sleep(500); debug("RIL_SendSimCmd: %08lx\n", RIL_SendSimCmd(m_hRil, (BYTE*)"AT%UREG?0,10", 12)); // Sleep(500); debug("RIL_SendSimToolkitCmdResponse: %08lx\n", RIL_SendSimToolkitCmdResponse(m_hRil, (BYTE*)"AT%UREG?0,10", 12)); Sleep(500); debug("RIL_SendSimToolkitEnvelopeCmd: %08lx\n", RIL_SendSimToolkitEnvelopeCmd(m_hRil, (BYTE*)"AT%UREG?0,10", 12)); Sleep(500); debug("RIL_SendSupServiceData: %08lx\n", RIL_SendSupServiceData(m_hRil, (BYTE*)"AT%UREG?0,10", 12)); Sleep(500); debug("RIL_FetchSimToolkitCmd: %08lx\n", RIL_FetchSimToolkitCmd(m_hRil)); Sleep(500); debug("RIL_GetAudioDevices: %08lx\n", RIL_GetAudioDevices(m_hRil)); Sleep(500); debug("RIL_GetAudioGain: %08lx\n", RIL_GetAudioGain(m_hRil)); Sleep(500); debug("RIL_GetAudioMuting: %08lx\n", RIL_GetAudioMuting(m_hRil)); Sleep(500); debug("RIL_GetBearerServiceOptions: %08lx\n", RIL_GetBearerServiceOptions(m_hRil)); Sleep(500); debug("RIL_GetCallerIdSettings: %08lx\n", RIL_GetCallerIdSettings(m_hRil)); Sleep(500); debug("RIL_GetCallList: %08lx\n", RIL_GetCallList(m_hRil)); Sleep(500); debug("RIL_GetCallWaitingSettings: %08lx\n", RIL_GetCallWaitingSettings(m_hRil, 0xff)); Sleep(500); debug("RIL_GetCellBroadcastMsgConfig: %08lx\n", RIL_GetCellBroadcastMsgConfig(m_hRil)); Sleep(500); debug("RIL_GetCellTowerInfo: %08lx\n", RIL_GetCellTowerInfo(m_hRil)); Sleep(500); debug("RIL_GetClosedGroupSettings: %08lx\n", RIL_GetClosedGroupSettings(m_hRil)); Sleep(500); debug("RIL_GetCostInfo: %08lx\n", RIL_GetCostInfo(m_hRil)); Sleep(500); debug("RIL_GetCurrentAddressId: %08lx\n", RIL_GetCurrentAddressId(m_hRil)); Sleep(500); debug("RIL_GetDataCompression: %08lx\n", RIL_GetDataCompression(m_hRil)); Sleep(500); debug("RIL_GetDialedIdSettings: %08lx\n", RIL_GetDialedIdSettings(m_hRil)); //Sleep(500); debug("RIL_GetDriverVersion: %08lx\n", RIL_GetDriverVersion(m_hRil)); Sleep(500); debug("RIL_GetEquipmentInfo: %08lx\n", RIL_GetEquipmentInfo(m_hRil)); Sleep(500); debug("RIL_GetEquipmentState: %08lx\n", RIL_GetEquipmentState(m_hRil)); Sleep(500); debug("RIL_GetErrorCorrection: %08lx\n", RIL_GetErrorCorrection(m_hRil)); Sleep(500); debug("RIL_GetGPRSAttached: %08lx\n", RIL_GetGPRSAttached(m_hRil)); Sleep(500); debug("RIL_GetGPRSClass: %08lx\n", RIL_GetGPRSClass(m_hRil)); Sleep(500); debug("RIL_GetGPRSContextActivatedList: %08lx\n", RIL_GetGPRSContextActivatedList(m_hRil)); Sleep(500); debug("RIL_GetGPRSContextList: %08lx\n", RIL_GetGPRSContextList(m_hRil)); Sleep(500); debug("RIL_GetGPRSRegistrationStatus: %08lx\n", RIL_GetGPRSRegistrationStatus(m_hRil)); Sleep(500); debug("RIL_GetHideConnectedIdSettings: %08lx\n", RIL_GetHideConnectedIdSettings(m_hRil)); Sleep(500); debug("RIL_GetHideIdSettings: %08lx\n", RIL_GetHideIdSettings(m_hRil)); Sleep(500); debug("RIL_GetHSCSDCallSettings: %08lx\n", RIL_GetHSCSDCallSettings(m_hRil)); Sleep(500); debug("RIL_GetHSCSDOptions: %08lx\n", RIL_GetHSCSDOptions(m_hRil)); Sleep(500); debug("RIL_GetLineStatus: %08lx\n", RIL_GetLineStatus(m_hRil)); Sleep(500); debug("RIL_GetMinimumQualityOfServiceList: %08lx\n", RIL_GetMinimumQualityOfServiceList(m_hRil)); Sleep(500); debug("RIL_GetMOSMSService: %08lx\n", RIL_GetMOSMSService(m_hRil)); Sleep(500); debug("RIL_GetMsgConfig: %08lx\n", RIL_GetMsgConfig(m_hRil)); Sleep(500); debug("RIL_GetMsgServiceOptions: %08lx\n", RIL_GetMsgServiceOptions(m_hRil)); Sleep(500); debug("RIL_GetOperatorList: %08lx\n", RIL_GetOperatorList(m_hRil)); Sleep(500); debug("RIL_GetPhonebookOptions: %08lx\n", RIL_GetPhonebookOptions(m_hRil)); Sleep(500); debug("RIL_GetPhoneLockedState: %08lx\n", RIL_GetPhoneLockedState(m_hRil)); Sleep(500); debug("RIL_GetRegistrationStatus: %08lx\n", RIL_GetRegistrationStatus(m_hRil)); Sleep(500); debug("RIL_GetRequestedQualityOfServiceList: %08lx\n", RIL_GetRequestedQualityOfServiceList(m_hRil)); Sleep(500); debug("RIL_GetRLPOptions: %08lx\n", RIL_GetRLPOptions(m_hRil)); Sleep(500); debug("RIL_GetSignalQuality: %08lx\n", RIL_GetSignalQuality(m_hRil)); Sleep(500); debug("RIL_GetSimToolkitProfile: %08lx\n", RIL_GetSimToolkitProfile(m_hRil)); Sleep(500); debug("RIL_GetSubscriberNumbers: %08lx\n", RIL_GetSubscriberNumbers(m_hRil)); Sleep(500); debug("RIL_GetSystemTime: %08lx\n", RIL_GetSystemTime(m_hRil)); Sleep(500); debug("RIL_GetUserIdentity: %08lx\n", RIL_GetUserIdentity(m_hRil)); } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DebugSetLogfile("riltest.log"); RilTest ril; debug("starting test\n"); ril.open(1); Sleep(1000); ril.testmostril(); //Sleep(1000); ril.testnonioctl(); Sleep(1000); ril.testioctlmsgcfg(); Sleep(300000); ril.close(); Sleep(5000); debug("test done\n"); return 0; }