RIL_GetEquipmentInfo Problems - Windows Mobile Development and Hacking General

Trying to understand RIL and how to pass all the handles and various parameters. In my code i try to initialize RIL and then use the RIL_GetEquipmentInfo function to try and get some results from it. However when i try my application out , i get something like each time i press the command button ....
406
408
40B
411
....
it seems to increment and i thought i was ment to get something like HIMALAYAS back ... Where am i wrong ???
*********************************************
bool CTerminalDlg::RIL_Initialize(DWORD dwIndex)
{
TCHAR szString[256];
CEdit* pEditShow = (CEdit*)GetDlgItem(IDC_EDIT3);
result = ::RIL_Initialize(1, OnResultCallback, OnNotifyCallback, dwNotificationClasses, g_dwParam, &g_hRil);
HRESULT test = RIL_GetEquipmentInfo(g_hRil);
::wsprintf(szString, L" %X", test);
pEditShow->SetWindowText(szString);
return g_hRil != NULL;
}

the result is returned asyncronously via the OnResultCallback function.

alright i get ya ......... so that means the answer i should get ( HTC ) will be passed to a parameter inside the OnResultCallback function ? How would i display it in a message box though ?
thanks for your help i'm struggling here.

1)http://forum.xda-developers.com/viewtopic.php?t=28835
2)there is bad idea to show message box from callback
i think this callback execute in internal RIL thread
get data that you needed from RILEQUIPMENTINFO struct and put to temp buffer
show data from temp buffer in your main thread
for example:
in main thread
1)reset Event
2)call Ril_GetEquipmentInfo
3)wait Event
4)show MessgeBox
in callback
1)store data from RILEQUIPMENTINFO to temp buffer
2)set Event
3)return

Related

call dll by number

Hi,
How could I call an dll function using the number instead of name?
You need to get a handle to the module (DLL) that contains the function that you want to call, this is either done via LoadLibrary or GetModuleHandle function calls. You can then call GetProcAddress to get a pointer to the function.
For example assume you want to call:
int testfunc(int param) ;
You can do:
typedef int(* funcptr)(int) ;
hModule = LoadLibrary("dll name") ;
funcptr = GetProcAddress(hModule, MAKELONG(<ordinal>, 0)) ;
ret = funcptr(<param>) ;
Obviously you need to add error handling there, but thats the general idea.
thanks so much

help to intialize - RIL initialize ??

Hey, i'm trying to Use some RIL functions in an MFC application. However i dont understand how to initialize it (RIL_Initialize) could i get some help ??? I'm trying to write an app which would change the PIN code of the SIM card as described in the RIL patent. Using this function.
HRESULT RIL_ChangeLockingPassword(
HRIL hRil,
DWORD dwFacility,
LPCSTR lpszOldPassword,
LPCSTR lpszNewPassword
);
My problem is the HRIL hRil , @parm handle to RIL instance returned by <f RIL_Initialize>
No too sure how to do it !!! Need Help !!!!
static void CALLBACK s_Notify(DWORD dwCode,
const void *lpData,
DWORD cbData,
DWORD dwParam);
static void CALLBACK s_Result(DWORD dwCode,
HRESULT hrCmdID,
const void *lpData,
DWORD cbData,
DWORD dwParam);
HRIL hRil;
HRESULT hr = RIL_Initialize(1, s_Result, s_Notify, 0xFFFFFFFF, NULL, &hRil);
OK thanks.
Question 1:
------------
What values would HRESULT hr variable take ?? ( what value will i get if i print it out )
Question 2:
------------
When the functions says , @parm handle to RIL instance returned by <f RIL_Initialize> , does that mean it should be the returned parameter hr ?? or the hRil ?? What is the difference ??
Thanks for your help!
for most functions returning a HRESULT, you have to check if the HRESULT contains an error, using IS_ERROR(hr).
other wise hr contains a function result identifier, for which the function results are returned back to your application via the RILRESULTCALLBACK function passed to RIL_Initialize. ... in the hrCmdID parameter.
see RilClass.cpp for an example.
willem
Thanks for the link , it helps quite a bit ... Now to use a practical example , i want to use the RIL_GetEquipmentInfo() function.
Code:
// Notify and Result Call back functions
void CALLBACK OnNotifyCallback(DWORD dwCode, const void *lpData, DWORD cbData, DWORD dwParam)
{
}
void CALLBACK OnResultCallback(DWORD dwCode, HRESULT hrCmdID, const void *lpData, DWORD cbData, DWORD dwParam)
{
}
// RIL initialize and GetEquipment Info
result = ::RIL_Initialize(1, OnResultCallback, OnNotifyCallback, dwNotificationClasses, g_dwParam, &g_hRil);
if (result)
{
IS_ERROR(result);
return false;
}
HRESULT test = RIL_GetEquipmentInfo(g_hRil);
Now i want to print the result from the RIL_GetEquipement Info !!! The answer should be HTC. I thought i would just need to wsprintf test however it does not print what i want. Could you help me out ? I think i'm missing something really.
Thank you for your help, i'm new to this , i'm trying to understand.
RIL_GetEquipmentInfo() is async function
after operation will complete ResultCallback will be called by RIL
1)check dwCode it must be RIL_RESULT_OK
2)check hrCmdID it must be equal to return value of RIL_GetEquipmentInfo()
3)lpData is pointer to RILEQUIPMENTINFO (you must convert void* to LPRILEQUIPMENTINFO)

RIL message

Ok lets say i want to use this RIL function ... where would i get the data back from ??? Any help ?? I tried the CALL BACK functions but it does not seem to return much just some hexa stuff
Code:
HRESULT RIL_ReadMsg(
HRIL hRil, // @parm handle to RIL instance returned by <f RIL_Initialize>
DWORD dwIndex // @parm index of the message to be read
);

CeMountDBVolEx on mxip_swmgmt.vol results in ERROR_SHARING_VIOLATION

Due to some recent changes in WM 6.1, when I uninstall my cab via 'Remove Programs' and then later install it again, it says 'The current version will be removed before the new one is installed'. I am using the WM 6.1 emulator
The reason for this prompt to throw up is because the app name still exists in the \mxip_swmgmt.vol. I have verified this by opening the .vol with MemMaid. I was able to get around the prompt by deleting the respective record from mxip_swmgmt.vol using MemMaid.
Now I intend to achieve the same programatically. These are the API's used.
Code:
CEGUID ceGUID;
HANDLE hSession, hDatabase;
DWORD dwErr = 0;
DWORD dwErr1 = 0;
::CeFlushDBVol(0);
// Mount the vol
//
if (!::CeMountDBVolEx (&ceGUID, TEXT ("\mxip_swmgmt.vol"), NULL, OPEN_EXISTING))
{
dwErr = ::GetLastError();
return;
}
At this point it returns and the value in dwErr is 32 i.e. 'The process cannot access the file because it is being used by another process.'
I went one step ahead and stopped the SWMGMTSERVICE which I strongly believe is holding onto the mxip_swmgmt.vol.
The code now looks like
Code:
CEGUID ceGUID;
DWORD dwErr = 0;
DWORD dwErr1 = 0;
// Bring down the SWMGMTSERVICE so that we get a handle to pszVol
//
HANDLE hService = ::GetServiceHandle (TEXT ("SWM0:"), NULL, NULL);
if (hService != INVALID_HANDLE_VALUE)
{
if (!::DeregisterService (hService))
{
dwErr = ::GetLastError();
return;
}
}
::CeFlushDBVol(0);
// Mount the vol
//
if (!::CeMountDBVolEx (&ceGUID, TEXT ("\mxip_swmgmt.vol"), NULL, OPEN_EXISTING))
{
dwErr1 = ::GetLastError();
// restart the service and return
//
::RegisterService (TEXT ("SWM"), 0, TEXT ("swmgmtservice.dll"), 0);
return;
}
Now at this point dwErr1 contains the error code 1358 i.e. 'Unable to complete the requested operation because of either a catastrophic media failure or a data structure corruption on the disk.'
Any idea how I can get a handle to mxip_swmgmt.vol either by stopping or without stopping the relevant services ?
Thanks.
A gentle bump.
Any clues will certainly help.
have u got any workable solution? I am facing same problem.

Single quote in database

Can't get rid of this error:
android.database.sqlite.SQLiteException: near "s": syntax error: , while compiling:
Select correct from answers where correct = 'Between the airplane's climb angle and the horizon.'
Obviously, it's finding the single quote in ( airplane's ) and considering that the end of the statement.
I've tried:
correct.replaceAll(" ' ", " ''' "); //replace 1 with 3
correct.replaceAll(" ' ", " '' "); // replace 1 with 2
correct.replaceAll(" ' ", " "); // replace 1 with space
(NOTE: the spaces are NOT in the code, I just did that to make it readable)
I have no idea what's going on, IMO, it should work. Maybe I need to try:
String single = "'"; // single '
String double = "''" // double ''
correct.replaceAll(single, double); // ????
Everything I"ve read about sqlite3 is to replace one with two....
TIA,
Roots
\'
\ is the escape character for most languages
so airplane's would be airplane\'s
Also, are you binding your queries with the "question mark" bind?
I'll try the escape and post back later. There are 1,000 rows in the database and I"m pulling a random subset of that, so it's not that often I get one of those situations.
I'm not sure what you mean by "binding with ?" Isn't that what you use for bind variable unknown at runtime? I know my bind variables and just use it in my dbquery. Please enlighten me...always happy to learn something new
Sample code...answerOne would contain the single quote that's killing me
Code:
Cursor c;
c = myDataBase.rawQuery("Select correct from answers where correct = '" + answerOne + "'", null);
if(c.moveToFirst())
answer = "1";
c.close();
binding with question marks should take care of escaping for you.
Basically the question mark is a place holder for a variable in the query.
What you are doing is manually creating the query string. This is considered bad practice these days especially with regards to security. Mostly because it opens up the DB to a SQL injection attack.
So instead of using the rawQuery just use query and you can put a ? in and android will substitute the value for you, all properly escaped:
Code:
String tableName = "answers";
String selectArgs = "correct=[COLOR="Red"]?[/COLOR]";
// if answerOne is string dont need String.valueOf
String[] selectVals = { String.valueOf ( answerOne ) };
String[] columnsProjection= new String[] {"correct" };
Cursor c = db.query(tableName, columnsProjection, selectArgs,selectVals,null);
So in that code the OS will replace the ? in selectArgs with the values in selectVals
This may seem like more writing at first but once you get in the habit it will be easy, reliable and more secure. It also allows you to bind multiple variables to mutiple question marks. It just binds then in the order it gets them.
so something like this:
Code:
String answerOne= "one";
String selectArgs = "correct=? AND age=? AND smiling=?";
String[] selectVals = { answerOne, "21", "yes" };
Ok, I'll try it. There are about 50 different queries in this program...for some reason I just decided to do a rawQuery on this one. I'll change it to "db.query(table name, new String[] {}....yada, yada).
Because, it just crashed and I decided to come back here and check for a solution.
Thank you very much!!!
Roots
Glad to be of help, just remember to hit the thanks booton ya Rooster
Still getting the error
Example: column is in table as text. Say it's equal to:
The driver's last name
Error comes back as "syntax error near 's' when compiling select correct from answers where correct = 'The driver's last name'
That single quote in driver's is killing my SQL.

Categories

Resources