[Q] some question about Heathcliff74 's native code tutorial - Windows Phone 7 Q&A, Help & Troubleshooting

i believe many people have read the tutorial about developing homebrew apps by Heathcliff74.But did every sussess in doing that. In fact,i failed.
i failed in this step in his article.
INative MyNativeCodeInstance = (INative)new CNative();
however,the return value of the Microsoft.Phone.InteropServices.ComBridge.RegisterComDll if 0 whicn means it success.but when his code running here the app will exits at once even i use try{}catch{}.
soem info of my device:HTC schubert t9292
OS:winphone 7.5
does anyone have the same probelm with me?
@Heathcliff74
how do you think why somebody failed when following these steps.now ,i think it may caused by my device.

If instantiating the COM object is causing a crash, the most likely problem is a bug in your object's definition. I assume you have the WPInteropManifest and all? In that case, it's almost certainly a problem in your native code.
However, without seeing your code, I can't tell you what the problem is.

Related

Ril and smartphone

Hi,
I follow every comment present in this form about using ril.dll for accessing cellID and so on.
I still have a problem with RIL. All compilation process work well but when I start my application on Phone (MPX220) an error responce occurs...
Thanks
Hi,
what error exactly?
error: 80004005
Using the code present in itsutils from xda-developpers.com after calling RIL_Initialize....
Hi,
Unfortunately, 80004005 is defined as 'Unspecified error' (E_FAIL), which doesn't help much. However, given that you are using a Smartphone, the probable cause is that you are using a Priviledged function. Smartphones require applications to be signed in order to use priviledged functions.
For further information about this, see here.
Thanks!! now it seem works even though some other error code 80004001 or 80070057...
Hi,
Error 800004001 is 'Not implemented error' (E_NOTIMPL) which means that a function you are trying to use is not supported by the service provider.
Error 80070057 is 'One or more arguments are not valid error' (E_INVALIDARG) which means that either an argument you are providing to a function is incorrect, or that you have not specified the valid argument specifiers (dwParams) required by some structures used in some functions.
A good place to look for what errors mean is here
thanks a lot...
One more question:
- How can I get the information that Ril_CellTowerInfo should be able to provide?
on my phone exist one process "tstutil" that is the engineering mode menu...

Two questions in one piece for S5600

First question : Is there any accelerometer bublle level like the incredible android one for Jave J2M Samsung S5600 (Player Star) phone ? Or anyway, is there any solution to port this app from adroid to java Mobile ? I got the source jar if anyone is interested to have a look inside. It does not lauch on my mobile, certainly due to protection and very different Android OS...
Second question :
I would like to find a way for overriding the Exe/jave/games/folder to point it to my mmc sdcard ? Is there a way to do it via nv_default.ini without bricking the phone ? A better solution would be to offer both databse update search and and thos two path in ?!
I'm really not familliar with this phone OS, so if there anyone who can tell me if this system is modifiable or modable, just let me know...
Free Bonus Question : I also have a nice HTC touch P3450, wich has been succesfully updated to the latest avaible firmware. I dont know if this phone have an accelerometer ? Can anyone tell it to me ? I don't think so because none of the apps are hanging this feature, but i'm asking it also

[Q] Can a P/Invoke be used to call native APIs?

Since I'm not strong in C++, is it possible in a native/hybrid app to use a P/Invoke call to call native APIs from C# code?
So far what I have seen is COM interop where you have to code the bulk of what you want to do in native C++.
Any possibility here and if so how?
No. At least not that we know of. You have to create COM wrappers for native functions.
Various Marshaling APIs, which makes P/Invoke tick, are off-limits.
WP7 apps run under silverlight - the best place to learn about the security model and why p/invoke is not possible is here:
http://msdn.microsoft.com/en-us/library/dd470128(v=vs.95).aspx
As you can see the restriction is quite deep routed in the framework.
It still might be possible to run proper .NET CF executables in the future though if we can get it installed.
pInvoke
I just met a guy today, who successfully published WP7 app, that uses pInvoke - he just filled the Technical Exception form and ... done
It's used for muting system volume when the phone is in range of specified WiFi network (using BG agent) - for example when in range of school Wifi, turn the speaker off.
http://www.windowsphone.com/en-US/apps/6813ea1f-8d71-4ad5-a6d2-f80c193c6ac9
Can anybody confirm this actually works? He haven't tested it, because it won't work in emulator and even not in default developer unlock.
Here's the code he used, disassembled from the app:
http://pastebin.com/PfFm9Wxg
Do you know about any other apps, except apps from OEMs and Microsoft, that use pInvoke?
This gave me an idea, what else could be possible using small use of pInvoke? Maybe even something lot of users are asking for, like battery status on the start screen, who knows?
Thread Moved To WP7 Q&A​
This is a development section, not Q&A. Please post in the correct section!​
OK, a few things:
P/Invoke not working is *very* well documented. The DllImport attribute *appears* to be available, but calling a function that uses it invariably fails. The work-around for native code access is to use COM. There's also a project to re-implement DllImport.
Native code access has been available to homebrew developers for about a year, now. There are many apps which use it, ranging from web servers to registery browsers to yes, even an app that shows your battery status as a live tile on your Start screen...
These apps are not, however, permitted by Microsoft's Marketplace rules. It may be possible to get an exemption (some Marketplace apps do use native code) but by default, all apps that try to use native APIs (either via COM or P/Invoke) are automatically detected and rejected during analysis of the app prior to its approval.
As for the code you linked, it doesn't even compile (WP7 doesn't include CharSet.None, apparently). If you remove the CharSet directive, or if you set it to CharSet.Auto, it will compile but fails when used. You also didn't include any of the #using directives (OK, without the # in C#). Better would have been to just send us the XAP directly (yes we can get it, but a copy/pasted smidge is a lot less useful)
Downloaded the XAP. It's a paid app, so many tools won't find it.
Examining now. Nothing exotic so far. Possibly P/Invoke only works on signed apps?
The actual message signature that I see:
[PreserveSig]
[DllImport("coredll.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int waveOutGetVolume(IntPtr device, out uint volume);
Note that CharSet.Ansi still doesn't seem to exist. That said, this might simply be due to an outdated interop library that shipped with NoDo, and the Mango one does support this? More investigation...
"Possibly P/Invoke only works on signed apps?"
That's the question! If this actually works, it's possible we can get exception for more pInvoke calls and it might be even possible to certify app in marketplace for showing battery status or similar goodies. It won't be possible using that dllImport project, that's more than sure, but if we use only well defined set of safe pInvoke calls, we might get submission exception. It's definitely worth finding it out, what's possible here

[Q] Is it possible to use MS.Internal somehow in a normal app?

Is it possible to somehow use classes from the MS.Internal namespace, things like MS.Internal.TextBoxView which is the type of a sub-object of the ContentControl of a textbox?
I mean use them in a "normal" app on a locked end-user phone, and getting away with it as far as certification is concerned so it can appear normally in the Marketplace?
The Visual Studio debugger is able to display information about such objects somehow, that's where I got the knowledge of the existence of this TextBoxView class in the first place, but of course that does not mean that a normal app can do likewise.
Googling for "WP7 reflection" showed me hits in other places like StackOverflow with info that probably this will just run into security exceptions anyway, because MS does not want devs to use "undocumented APIs", but I am curious whether somebody here has tried to "hack" this and can report first-hand.
rbrunner7 said:
Is it possible to somehow use classes from the MS.Internal namespace, things like MS.Internal.TextBoxView which is the type of a sub-object of the ContentControl of a textbox?
I mean use them in a "normal" app on a locked end-user phone, and getting away with it as far as certification is concerned so it can appear normally in the Marketplace?
The Visual Studio debugger is able to display information about such objects somehow, that's where I got the knowledge of the existence of this TextBoxView class in the first place, but of course that does not mean that a normal app can do likewise.
Googling for "WP7 reflection" showed me hits in other places like StackOverflow with info that probably this will just run into security exceptions anyway, because MS does not want devs to use "undocumented APIs", but I am curious whether somebody here has tried to "hack" this and can report first-hand.
Click to expand...
Click to collapse
I highly doubt.. more towards no for this. Microsoft pretty much will deny anything in the low level APIs from being accepted in the Marketplace. A way to check this is to use the Marketplace Test Kit in VS 2010 (Project -> Open Marketplace Test Kit). It will tell you if something you're using will fail as it does the same type of quick test that happens when you upload a XAP for submission.

Starting an Application/Process or a part (service,etc.) of it as root (su)

I'm writing my thesis and hope you can help me in finding an approach to my problem.
First of all: I am not a professional in the field of Android development.
I would like to monitor on my Android device accesses to the file system, in particular on the folder "/data/data". Therefore I use the class "File Observer".
So according to the scheme:
...
observe = new RecursiveFileObserver (this, "/data/data");
observe.startWatching ();
...
Of course, the generated instance need for that root privileges, but unfortunately, I don't know how...is there a chance at all? Can you give me a hint for get implemented this? I've scoured some forums but have not found anything, yet. The produce, to create a process that generates a shell instance, is unfortunately not purposeful, I think.
Perhaps, do I have to create a similar service, that will run with root privileges ... is this possible?
Can you help me?
Thanks a lot and best regards

Categories

Resources