Successful TCP Connection via CoreCon - Windows Phone 7 Development and Hacking

So during my break today I added a few more registry paths to check on my HTC Radar and I found HKCU\Software\Microsoft\ConMan\HostLauncher\HostData\. There I found a few Service entries:
Code:
7ABBE0D5-B437-42CA-B57B-CEED61680E4F
11EE50CA-6CD3-45BA-9D65-46E133CFF009
B2FC26AB-D6EC-4426-91FA-9E039F92A639
The first entry did not take me any where but the other two did.
Running those in my test application sent back:
Code:
Int32Type: 0
Int32Type: -2147024809
I know it isnt much and I am not sure what to send to the ConMan so if someone does please tell me:
Code:
private static void ExecutionTest()
{
#region Create Objects
ObjectId DeviceID = new ObjectId("30F105C9-681E-420b-A277-7C086EAD8A4E");
Platform platform = datastoremanager.GetPlatform(PlatformObjectID);
Device device = platform.GetDevice(DeviceID);
#endregion
try
{
//Connect to the device.
device.Connect();
if (device.IsConnected())
{
RemoteAgent ra = device.GetRemoteAgent(new ObjectId("910DCB1B-487B-452b-87FC-73852B5A239C"));
DevicePacketStream ps = ra.CreatePacketStream(new ObjectId(new Guid("11EE50CA-6CD3-45BA-9D65-46E133CFF009")));
// Create and write a packet of data.
Packet packet;
packet = new Packet();
for (int i = 0; i < 4; i++) packet.WriteInt32(i);
packet.WriteString("Hello Smart Device");
ps.Write(packet);
#region While stream is connected, try to read a packet.
while (ps.IsConnected())
{
if (ps.IsPacketAvailable())
{
packet = ps.Read();
while (!packet.IsEndOfPacket())
{
switch (packet.ReadDataType())
{
case DataType.BoolType: bool boolValue = packet.ReadBool(); break;
case DataType.ByteArrayType: byte[] buffer = packet.ReadBytes(); break;
case DataType.ByteType: byte byteValue = packet.ReadByte(); break;
case DataType.CharType: char charValue = packet.ReadChar(); break;
case DataType.Int32Type: Console.WriteLine("Int32Type: " + packet.ReadInt32().ToString()); break;
case DataType.StringType: Console.WriteLine("String: " + packet.ReadString()); break;
default: break;
}
}
break;
}
System.Threading.Thread.Sleep(1000);
}
#endregion
}
}
catch (Exception ex)
{
throw ex;
}
finally { device.Disconnect(); }
}

Huh, you got the remote "GetRemoteAgent" working. Right?
I think i might know how to resolve what to call in to the packet. VS2010 talks to wp7, and uses one of those GUID's; meaning one should be able do binary search all files (in a rom) to see who owns the GUID (what dll handler), disassemble that dll (to ASM/c), and extract "what it wants".
Or if MS has a hidden caller class somewhere
Ill look further into this, thanks

fiinix said:
Huh, you got the remote "GetRemoteAgent" working. Right?
I think i might know how to resolve what to call in to the packet. VS2010 talks to wp7, and uses one of those GUID's; meaning one should be able do binary search all files (in a rom) to see who owns the GUID (what dll handler), disassemble that dll (to ASM/c), and extract "what it wants".
Or if MS has a hidden caller class somewhere
Ill look further into this, thanks
Click to expand...
Click to collapse
Yes I did . Yeah I just need to know what to actually send to to the device. I know Visual Studio communicates this way.

MJCS said:
Yes I did . Yeah I just need to know what to actually send to to the device. I know Visual Studio communicates this way.
Click to expand...
Click to collapse
Great
I, myself tried 20+ GUID's once (from wp7 that _could_ be); all threw exceptions (aka not a remote agent handler).
It feels better now knowing what GUID's i can use.
Well the reg path was quite obvious; why did i not stumble upon that one earlier..

fiinix said:
Great
I, myself tried 20+ GUID's once (from wp7 that _could_ be); all threw exceptions (aka not a remote agent handler).
It feels better now knowing what GUID's i can use.
Well the reg path was quite obvious; why did i not stumble upon that one earlier..
Click to expand...
Click to collapse
Well I only found it since I know have an HTC Radar. My Dell venue pro requires you to manually enter in registry paths to see if they exist or not. I was able to decompile an older HTC registry viewer and then fix it so it didnt require interop unlock.

It should be possible to do registry browsing (but not editing) just fine on a DVP using the standard tools, unless there's a check that specifically blocks them. The browsing uses a native homebrew DLL that doesn't require ID_CAP_INTEROPSERVICES and has no device-specific dependencies. It's the editing that requires interop-unlock and device-specific DLLs.

GoodDayToDie said:
It should be possible to do registry browsing (but not editing) just fine on a DVP using the standard tools, unless there's a check that specifically blocks them. The browsing uses a native homebrew DLL that doesn't require ID_CAP_INTEROPSERVICES and has no device-specific dependencies. It's the editing that requires interop-unlock and device-specific DLLs.
Click to expand...
Click to collapse
There is no GetSubKeys method...anyways lets get back on topic.

I've been trying for weeks to get anything out of this. Nothing so far. I did find out that the Developer unlock is just a byte array of a cookie taken from Microsoft's auth server.

Has anyone had any success with this socket method yet? I really don't know enough about sockets to try.

BTW you have to have a core con connection to the device already open either from app debugging or some other method

Related

Help me understand C++ code with notifications (beers offered)

Hi,
I need to use the C++ version of this. The code should gather information and show this in a notification.
The notification works but I want to receive the choice the user made in the html form.
I know I need to use the hwsink, a message map, and some events but cannot find info (book, example, etc.) how.
Could some one finish this code so I can test what has been chosen. If NOT, please give me an C++ example from which I can learn/copy. I have been searching on google for days now
Thx, for your help
BTW:
I started with this http://www.krvarma.com/?p=146 downloaded code but was a bit to complicated. In it is all I need but i would like it to be in 1 cpp file.
I'm offering 2 beers if you have the solution
Code:
#include "stdafx.h"
#include <stdlib.h>
#include "resource.h"
// {4E8A9888-D15C-4395-9C9A-B4B572F20081}
static const GUID NOTIFICATION_GUID =
{ 0x4e8a9888, 0xd15c, 0x4395, { 0x9c, 0x9a, 0xb4, 0xb5, 0x72, 0xf2, 0x0, 0x81 } };
int _tmain(int argc, _TCHAR* argv[])
{
SHNOTIFICATIONDATA stcNtData = {0};
stcNtData.cbStruct = sizeof(stcNtData);
stcNtData.dwID = 1;
stcNtData.npPriority = SHNP_INFORM;
stcNtData.csDuration = 15;
// stcNtData.hicon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON2));
stcNtData.clsid = NOTIFICATION_GUID;
//What todo here... stcNtData.hwndSink = hWnd;
stcNtData.grfFlags = SHNF_SILENT | SHNF_TITLETIME | SHNF_CRITICAL | SHNF_FORCEMESSAGE;
stcNtData.pszTitle = L"ReRemind";
//stcNtData.pszHTML = TEXT("<html><body>This is a sample application to show the SHNotificationAdd API")
// TEXT("<p><b>This line should be bold</b>.<br><i>This one should be italics.</i><br>")
// TEXT("This is a line with a <a href='cmd:10000'>link</a></p>")
// TEXT("<p>This is a line with <input type='button' name='cmd:10001' value='Click'></p><br><br><br><br>");
stcNtData.pszHTML = TEXT("<form method='get' action='TestBubble://Test'>")
TEXT("<table width=100% cellspacing=0 cellpadding=0>")
TEXT("<tr><td colspan=2>")
TEXT("<b>Choose a fruit:</b><p>")
TEXT("<input type='radio' value='0' id='Apples' checked name='Fruit'><label for='Apples'>Apples</label><br>")
TEXT("<input type='radio' value='1' id='Oranges' name='Fruit'><label for='Oranges'>Oranges</label></p></td><td>")
TEXT("<input type='submit' value='Submit' name='Submit'>")
TEXT("</td></tr><tr><td width=42>")
TEXT("<a href='cmd:12288'>Settings</a></td></tr></table></form><br><br><br><br>");
SHNotificationAdd(&stcNtData);
Sleep(15000);
SHNotificationRemove(&NOTIFICATION_GUID, 1);
return 0;
}
I'm offering beers now. No need to finish it, just give me some hints
Hi,
as I understand your article (http://www.krvarma.com/?p=146)
you need to create window, then assign it's HWND
to SHNOTIFICATIONDATA member HWND hwndSink;
then "The system will send WM_COMMAND with wParam set to 1000 to the hwndSink window." so - you need to handle WM_COMMAND in your window and check wParam - if it is equal to your parameter, then this message means "system sends you user choice from your html".
serfer222 said:
Hi,
as I understand your article (http://www.krvarma.com/?p=146)
you need to create window, then assign it's HWND
to SHNOTIFICATIONDATA member HWND hwndSink;
then "The system will send WM_COMMAND with wParam set to 1000 to the hwndSink window." so - you need to handle WM_COMMAND in your window and check wParam - if it is equal to your parameter, then this message means "system sends you user choice from your html".
Click to expand...
Click to collapse
Exactly as i understand it.
So I tried copying code from that article into my code but got stuck with really not understandable compiler errors. I think I need to find a good book explaining this message map.
The first thing I do not understand is that I only want to show the notification bubble (is working). If I create a windows handle (how?) will this overwrite the current screen (this is something I do not want).
window can be invisible.
I'm Win32 programmer, and I don't know exactly about WinCE.
If you are using VisualC++, I think you should use MFC, it's very easy to create window and then create message handler for this window.
search google for some
"WinCE c++ tutorial" and you will find how to create window and setup message loop. (add "Hello world" phrase to your search - this is usually used as very first example)
for example: http://www.codeproject.com/KB/mobile/ltwtdlg.aspx
serfer222 said:
window can be invisible.
I'm Win32 programmer, and I don't know exactly about WinCE.
If you are using VisualC++, I think you should use MFC, it's very easy to create window and then create message handler for this window.
search google for some
"WinCE c++ tutorial" and you will find how to create window and setup message loop. (add "Hello world" phrase to your search - this is usually used as very first example)
for example: http://www.codeproject.com/KB/mobile/ltwtdlg.aspx
Click to expand...
Click to collapse
Can you switch between MFC, ATL, etc. ? I know they are some kind of libraries but thought "don't look at it, there too much to learn/understand anyway ".
I've search but somehow you think there is the solution and then you learn the hard way, it's very old code. Will search further offcourse and I am reading a chapter on classes and if I can find; messages.
it's already very easy to handle messages without any MFC overload. Just check the uMsg parameter in your DefWindowProc. If you create a new Win32 project in Visual C++ wizard then you see what it's looking like. This is mandatory knowledge. Usually first thing you learn after Hello World. If you didn't know about message processing in Windows/Wince then it's the same like sitting in a car and don't know how to turn the keys.
Do you know how to open dsm file in textbox???
RAMMANN said:
it's already very easy to handle messages without any MFC overload. Just check the uMsg parameter in your DefWindowProc. If you create a new Win32 project in Visual C++ wizard then you see what it's looking like. This is mandatory knowledge. Usually first thing you learn after Hello World. If you didn't know about message processing in Windows/Wince then it's the same like sitting in a car and don't know how to turn the keys.
Click to expand...
Click to collapse
Thats how I feel exactly. It's strange. I read quickly thru 3 books about C++ and no mention of these messages. C#/Basic are easier to understand because of all the examples.
Found these:
- http://www.youtube.com/watch?v=kWVGqV2Yklw
- http://www.youtube.com/watch?v=cbe6yxBHEiU
The video does explain that the linked example doesn't look so different. What a lot of source code Ms creates for you..
If created a WIN32 smart device project and DefWindowsProc is only called when to pass the message to other programs. I need the windows handle for the notification and NOT display the window.
But again it's a bit to much for me at this moment. I haven't got a solution yet..Could somebody help me with not displaying this window. I would still like to use the windows handle to make sure I get the callbakcs to the WM_COMMAND.
Yes - I think you only need at end of WinMain before SHNotificationRemove
to add:
Code:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hacc, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Then a new function:
Code:
/* Redefine generic HANDLE_WM_ACTIVATE macro for Pocket PC */
#undef HANDLE_WM_ACTIVATE
#define HANDLE_WM_ACTIVATE(hwnd,wParam,lParam,fn) \
(SHHandleWMActivate((hwnd), (wParam), (lParam), &g_sai, 0), /*return*/ 0L)
/* Redefine generic HANDLE_WM_SETTINGCHANGE macro for Pocket PC */
#undef HANDLE_WM_SETTINGCHANGE
#define HANDLE_WM_SETTINGCHANGE(hwnd,wParam,lParam,fn) \
(SHHandleWMSettingChange((hwnd), (wParam), (lParam), &g_sai), /*return*/ 0L)
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
HANDLE_MSG(hwnd, WM_CREATE, Main_OnCreate);
HANDLE_MSG(hwnd, WM_ACTIVATE, /* SHHandleWMActivate()*/ 0);
HANDLE_MSG(hwnd, WM_SETTINGCHANGE, /* SHHandleWMSettingChange() */ 0);
HANDLE_MSG(hwnd, WM_PAINT, Main_OnPaint);
HANDLE_MSG(hwnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hwnd, WM_DESTROY, Main_OnDestroy);
[B]// Remark: Here you can add more messages - also for what user has chosen.[/B]
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
and then the message handlers like this:
Code:
static BOOL Main_OnCreate(HWND hwnd, CREATESTRUCT *pcs)
{
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(mbi));
mbi.cbSize = sizeof(mbi);
mbi.hwndParent = hwnd;
mbi.nToolBarId = IDR_MNU_MAIN;
mbi.hInstRes = g_hInstance;
if (!SHCreateMenuBar(&mbi)) /* create the menu bar */
return FALSE;
g_hwndMB = mbi.hwndMB;
return TRUE;
}
But your Compiler should already make such a project by default and you can simple add the code fom _tmain to WinMain, which you've posted above.
Greetz
Micha
Thank you, yesterday I debugged and and debugged trying to understand how this works but the debugger doesn't stop always in all source code.
If f.i. you click on the screen I expected this to be an event, but the debugger didn't stop at all. Is there a command to always stop when a line of code is processed? Now it only stops when I have set a break point. I want to see every line processed...
I will try to implement your suggestions. For a newby it still looks difficult I hope someday I will look back to this and say "wow, that was so easy".
ajhvdb said:
Thank you, yesterday I debugged and and debugged trying to understand how this works but the debugger doesn't stop always in all source code.
If f.i. you click on the screen I expected this to be an event, but the debugger didn't stop at all. Is there a command to always stop when a line of code is processed? Now it only stops when I have set a break point. I want to see every line processed...
I will try to implement your suggestions. For a newby it still looks difficult I hope someday I will look back to this and say "wow, that was so easy".
Click to expand...
Click to collapse
Well, actually that's the reason why breakpoints exist. To stop the debugger and allow you look at the running code..... or what else did you think??
RAMMANN said:
Well, actually that's the reason why breakpoints exist. To stop the debugger and allow you look at the running code..... or what else did you think??
Click to expand...
Click to collapse
I want to say "stop and show at the current code line".
For example you start your program, goto the appropiate window, type in some data and NOW before you click on SAVE. You say to your debugger "catch this/coming event".
Debugger would stop if you'd handle this event and set break point to 1st command of this function.
then yo can go step by step through each line of code.
and hey: it's not soo easy,which I posted.But your Compiler (vs2008 or PellesC or whatever) would make this automatically for you and you only have to copy your part of code into WinMain of this automatic processed code.
The "Managers" then can help you also to add eventhandlers automatically.
you only have to set Breakpoints to the automatic processed Event-Handle-Function - them you can see,if this event is triggered like you want it.
You only think from the wrong direction
Ok, I learned a lot.
(The VS2008 debugger has bugs. If I set a breakpoint on line 100, and start debug, line 109 has the breakpoint. It looks like only the original code can be debugged)
I did start a new project and used the tips from above. I can catch a click on a link ahref field in the notification bubble.
I have disabled the screen so only the bubble is shown
Now I need to catch the menu button and more important the data in the html form (input type radio) in the notification bubble. For this I need to convert the param to a structure...!
I also need to extend the "while getmessage" loop with a timer. If 15 seconds have passed, I need to step out of the loop and quit automatically.
A lot of searching again.
BTW.
Thx all for helping me. Not really one tip did it, you all guided me a bit. If you think your tip helped me a lot then send me a PM with your paypal code. You can also send me your address/or your businessaddress. I will send you a small present/surprise related to my country (Holland).
in Germany we have a good cheese, too and the sense of a community like this great one,is for helping each other-especially beneath developers.
And it's always a question of finding out,how to manage something new
All the best for your further development.
Micha
Attached is the code of my subproject. I will update it if those last points are done. Hope it helps others.
If someone has a link or example code for those points. (or improvements of my code) please let me know.

[Q] [Resolved] [.Net CF 3.5] How do i create a treeview based file browser

I have a problem with a project i'm working on and that is:
How do i create a TreeView based file browser that can export a selected path and filename to a textbox and a Process.Start call at the same time. That's it in a nut shell. The main part if the tree view bit but i haven't figured out how to do variables yet and i'm gonna need one for the second part. I have spent hours googling and i have this question posted on a dedicated VB forum.
I'm using Visual Basic 2008 as the IDE and .Net CF 3.5 as the language (obviously)
If anyone has any ideas on this i'll gladly hear them coz i am really stuck. I found writting code to soft reset a device was easier
TreeNodeCollection tr=treeView1.Nodes;
TreeNode tn;
foreach (string dirs in System.IO.Directory.GetDirectories(System.IO.Directory.GetDirectoryRoot(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName)))
{
tn = new TreeNode(dirs);
//tr = new TreeNodeCollection();
tr.Add(tn);
}
ergintiravoglu said:
TreeNodeCollection tr=treeView1.Nodes;
TreeNode tn;
foreach (string dirs in System.IO.Directory.GetDirectories(System.IO.Directory.GetDirectoryRoot(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName)))
{
tn = new TreeNode(dirs);
//tr = new TreeNodeCollection();
tr.Add(tn);
}
Click to expand...
Click to collapse
Is that C# code or VB?
M3PH said:
Is that C# code or VB?
Click to expand...
Click to collapse
C#....VB don't have the curly brackets
So i've come back to this question after a few months avoiding VB. I'm now working on a new product and the lack of an folderbrowserdialog object in .Net CF is killing me.
What i need is this (oh and thanks to everyone that posted above but i can't make that solution work). A way to list all the folders on a device and then select one that can be passed to a variable so it's path can be used elsewhere. Maybe also pass the path to a textbox just so it's clear what you have selected. I've spent 2 days googling this and i did find a few things. Most don't work and the rest are in c# which is not much good. So if anyone wants to help me out i would really appreciate it.
Get your head round this.........
O.K. Here's how it's done, with a crash course in one of the most powerful of programming techniques - Recursion. It can confuse the hell out of rookie programmers, as they just can't get their heads round what's going on. It is dependant on a function's local variables and fortunately, .NET's stack based architecture allows us to use it to the full.
You will need, 1.) a TreeView object - named "treeView1" and 2.), a label named "label1" placed underneath it. The label is only there to prove the point that we can get at the full pathname of the selected directory in the Treeview. In reality it can be dropped, just put your processing code directly in the TreeView's AfterSelect() event.
The Form_Load() event gets the directories in the root directory, by calling GetDirList with an initial directory of "\".
GetDirList() adds the directories to the TreeView then calls GetDirList again on each directory to get any subdirectories, and again on each subdirectory, ad nauseum. Keep going until there are no more directories returned.
When completed TreeView contains a list of every directory/subdirectory on the device.
When you select an item from the TreeView the full pathname is displayed in the label. The image at the bottom shows it running under debug on the WinMo 5.0 emulator. There are several directories you would not normally see on your device.
Good Luck, stephj.
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Me.GetDirList("\")
End Sub
Private Sub GetDirList(ByVal PathName As String)
Dim dirs As String
For Each dirs In Directory.GetDirectories(PathName)
Dim tn As New TreeNode(dirs)
Me.treeView1.Nodes.Add(tn)
Me.GetDirList(tn.FullPath)
Next
End Sub
Private Sub treeView1_AfterSelect(ByVal sender As Object, ByVal e As TreeViewEventArgs)
Me.label1.Text = e.Node.FullPath
End Sub
P.S.
You will need the VB equivalent of using System.IO adding to your project.
This stuff has been around since .NET CF 1.1
The original project was written in C#, I used .NET Reflector to translate it into VB from the original. The original C# is included here:-
Code:
using System;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GetDirList("\\");
}
private void GetDirList(string PathName)
{
foreach (string dirs in System.IO.Directory.GetDirectories(PathName))
{
TreeNode tn = new TreeNode(dirs);
treeView1.Nodes.Add(tn);
GetDirList(tn.FullPath);
}
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
label1.Text = e.Node.FullPath;
}
}
}
cool thanks. I'll have a look at coding this tomorrow (i having some fun time right now).
I did have a look at doing this with a list box yesterday but i was getting errors left, right and centre so i really do appreciate the help.
Just an FYI the VB equivelent of "using" is "imports" otherwise most of the objects are the same but i don't nee to worry about adding it as the program is already interacting with the file system.
Again thanks very much. I really appreciate you taking the time to help me out.
I've just had a look at implementing this but i'm having trouble getting the treeview to populate with the folder list. What am i doing wrong? the object names all match up and i can't see why it's not working. Am i just being plain dense?
What i have Is pretty much what you posted except for a few changes to allow for the fact that the treeview object is in a tabcontrol and i already have a bunch of labels knocking around so the label is called label28 and not label1.
I'm sorry if it appears like i'm not trying or i'm asking you to do all the work but i am genuinely really stuck. I get the recursion principal, That's not an issue but i'm trying to create something from scratch that should really have been included in .net CF and i'm just not that good a programmer yet
Should work..... but without seeing the actual code it's rather hard to remotely debug it.
To prove the point, here's the complete VS2008 VB .NET CF 3.5 project.
In the \bin\release directory is the actual executable. If you have .NET CF 3.5 on your device, drop DirList.exe onto it and run it.
I had a look at the project you posted and just copied the coded over. I did make some tweaks so it only loaded the folder list when the tab the treeview was on was clicked but that didn't work so i repated the code in as is and voila! it works. Now all i need is to create a variable to store the selected path in but i think i can manage that.
Again a huge thanks.
Hierarchical view......
Here's the project to indent, compress, and expand the directory tree structure.
I was just playing around with this and i noticed that when you click on a directory below "\" the path becomes "\\this\path". This is obviously not a valid windows mobile path and it is causing an IOexception and I have no idea how to fix it. Google suggests lots of c# pages that say to use a regular expression to strip out the illegal characters but the example i found was for the entire path and it seemed to check each character against a variable of illegal values. I'm sure if that would work for me. Heres the link.
Let me know what you think.
I have no idea where the \\this is coming from, I can't replicate it.
To filter out the extra leading slash use this:-
Code:
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
If TreeView1.SelectedNode.FullPath.Length() = 1 Then
Label1.Text = TreeView1.SelectedNode.FullPath
Else
Label1.Text = TreeView1.SelectedNode.FullPath.Substring(1)
End If
Interesting new problem has cropped up with this code. It doesn't seem to work on rhodiums. It works fine in the emulator, my HD2 and all of CajunFlavouredBob's devices but i have a user that has a rhodium that get the error posted here. I can't replicte it and i don't have a rhodium to test it with. Any ideas?
Hmmmmm another tricky one. Without seeing the device actually throw the error, it can be a bit difficult.
Does this machine actually report the storage card as "\Storage Card"? Some machines don't. In which case you may have to use some storage card enumeration trick to get hold of the real name it uses. This may not apply in this case.
Also, to make things trickier still, the stack dump shows 'GetInternalDirectoryNames()' as the function throwing the error first. This is a level below your call of GetDirectories(), and is being used by the OS to actually go get the info. You may have to create a test version of EXCT2 full of Try...Catch programming blocks, to try to get to the real point where the error is being thrown.
well this turned out to be a memory related issue. So instead of using the folder browser we now use the stock winmo savedialog. because it uses less memory and allows us access to the locations we need.
Thanks for helping though steph.

[Q] Windows Phone 7 Benchmark

I have a simple benchmark that I have been running on Windows Mobile devices for years. I don't have a Windows Phone 7 device myself, so I'm wondering if someone has a few minutes to run a test. I think the results may be interesting.
Here's the snippit: (in VB.NET, but C++ equivalent is fine):
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim limit, counter
limit = DateAdd("S", 10, Now)
counter = 0
Do Until Now > limit
counter = counter + 1
Loop
MsgBox(counter / 10, 0, "iterations")
End Sub
As benchmarks goes, it's as simple as it gets.
Post your results here - and I'll add them to the table and give a link.
I'm too lazy to convert it to C#, and windows phone 7 only runs C#. If you convert it to C# I will run it on two different phones.
athompson said:
I'm too lazy to convert it to C#, and windows phone 7 only runs C#. If you convert it to C# I will run it on two different phones.
Click to expand...
Click to collapse
Code:
private void Button1_Click(System.Object sender, System.EventArgs e)
{
dynamic limit = null;
dynamic counter = null;
limit = DateAndTime.DateAdd("S", 10, DateAndTime.Now);
counter = 0;
while (!(DateAndTime.Now > limit)) {
counter = counter + 1;
}
Interaction.MsgBox(counter / 10, 0, "iterations");
}
Developer Fusion has a converter. I can't link to it because I don't have good enough reputation yet.
Cheers!
DateAndTime doesn't seem to be available on windows phone 7 (Interation isn't either but I can work around that easily enough. Not sure what you'd want me to do with the DateAndTime problem).
Hmm, just posted it into a windows phone project. There are quite a few errors. I'll see if I can get it working
Code:
private void button1_Click(object sender, RoutedEventArgs e)
{
double counter;
DateTime limit = DateTime.Now.AddSeconds(10.0);
counter = 0;
while (!(DateTime.Now > limit))
{
counter = counter + 1;
}
MessageBox.Show(counter / 10 + " iterations");
}
I think this is what he was trying to accomplish, but in C#?
In the Samsung SGH-i917 I got 31702.2. Sorry, I forgot my other phone has something messed up and I can't load apps on it right now.
FWIW the emulator gets 55272.4 on my 64 bit 3.2GHZ computer.
Great progress! If you get a chance to post your project somewhere so other can run it to see if there is much variation between devices.
Meanwhile, try this out on your device:
nsbasic.com/speedtest.htm
It's the same test in JavaScript. I managed to run it on some sort of Samsung Windows Phone 7 device: it scored 40,000. Hmmm... JavaScript is faster than C#?
The same test on an Android device gets 400,000. The clock speed of the devices is the same.
We can't run C++ on these devices. If we could, I expect the result would be in the 2,000,000 range.
Wow, you're right. On my SGH-i917 I got 35,903 on the nsbasic.com/speedtest.htm . The IE team must feel proud of themselves.
But the times are fairly close, so it probably has more to do with the precise functions we are using than with the speed of javascript or C# in general applications.
Checking the DateTime each and every loop is a killer for performance. I'm not able to test a WP7 solution right now, but simply dropping the DateTime system and replacing it with an Async Timer running in it's own thread in a .NET 4.0 Console app running on my netbook made it jump from 720287 loops/sec, to a huge 241633375 loops/sec. A performance increase of 33546%.
In JS, the date functions are more optimised than in .NET, mainly because date and date manipulation functions make up a reasonable portion of Sunspider, which developers use, among other benchmarks, to track performance improvements in JS. In .NET, besides not really being tracked in the same way, DateTime's rarely used in performance-critical situations, particularly to track the passage of time, which is where MS recommend the usage of timers where suitable.
Code of C# implementation with Timers:
Code:
class Program
{
static bool loop = true;
static void Main(string[] args)
{
int count = 0;
DateTime finish = DateTime.Now.AddSeconds(10);
System.Timers.Timer time = new System.Timers.Timer(1000);
time.Elapsed += new System.Timers.ElapsedEventHandler(time_Elapsed);
time.Start();
while (loop)
count++;
Console.WriteLine("{0} Iterations", count);
}
static void time_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
loop = false;
}
}
athompson said:
Wow, you're right. On my SGH-i917 I got 35,903 on the nsbasic.com/speedtest.htm .
Click to expand...
Click to collapse
I got 40,995 on my HD7
Hounsell makes a good point, one which exposes the weakness of any benchmark: they really do not tell you how your own app will perform.
I urge everyone reading this to treat it as just for fun. If you need a benchmark that applies to your app, you should construct something that is relevant to your situation.
ghenne said:
Meanwhile, try this out on your device:
nsbasic.com/speedtest.htm
It's the same test in JavaScript. I managed to run it on some sort of Samsung Windows Phone 7 device: it scored 40,000. Hmmm... JavaScript is faster than C#?
The same test on an Android device gets 400,000. The clock speed of the devices is the same.
Click to expand...
Click to collapse
my HD2 running an mdeejay build of android sense with the s6.1 kernel just scored 385000 in the regular windows mobile it ranked only 98317.
I got a 40,995 on my Samsung SGH-i917 Focus.
Here is a WP7 Benchmark tool

[Q] PhoneGap and Ajax with database?

Hi all,
I recently finished learning how to create an APK using PhoneGap with code written using HTML5, CSS3 and Javascript.
Now, I would like to create a simple database app but I am not sure how to proceed. From what I learned about PhoneGap, everything can only be written in HTML5, CSS and Javascript coding. How do I get information from a database(flat-file or MySQL), display the data and edit it similar to how one would do using Ajax(I currently don't know how to code in ajax)? Is this possible with PhoneGap? How? Do I need a framework like JQuery Mobile to do this?
There would only be one page/view:
- displaying what is in the table
- and editing/adding new data to the table
Thank you.
using frameworks such as jquery mobile is a better option. u can use ajax calls to server to populate data. create a server side code that responds to ajax calls from app and fetch data from my sql and sends back the data either as json or xml
Falen said:
Hi all,
I recently finished learning how to create an APK using PhoneGap with code written using HTML5, CSS3 and Javascript.
Now, I would like to create a simple database app but I am not sure how to proceed. From what I learned about PhoneGap, everything can only be written in HTML5, CSS and Javascript coding. How do I get information from a database(flat-file or MySQL), display the data and edit it similar to how one would do using Ajax(I currently don't know how to code in ajax)? Is this possible with PhoneGap? How? Do I need a framework like JQuery Mobile to do this?
There would only be one page/view:
- displaying what is in the table
- and editing/adding new data to the table
Thank you.
Click to expand...
Click to collapse
If you just want your app to have a local database then HTML5 already does that for you. I've used this library in the past and had no problems with it at all...
http://html5sql.com/
I wrote an app that imported a CSV file into a database. It was a very basic app, written as proof of concept for a bigger project when I first started developing web apps for mobile. Here's a basic version of importing a CSV and using html5sql to create a table with it...
Code:
function createDatabase() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("/sdcard/external_sd/temp/PRODUCTS.CSV", null, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.file(gotFile, fail);
}
function gotFile(file){
readAsText(file);
}
function readAsText(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
var csv = evt.target.result;
var lines = csv.split("\n");
var i = 1;
html5sql.openDatabase("com.archer.testapp.db", "Test DB", _dbSize);
html5sql.process("DROP TABLE IF EXISTS products; " +
"CREATE TABLE IF NOT EXISTS products (linecode int, description varchar(255), barcode varchar(25), price int, stock int); ", function() {
function addRow() {
var line = lines[i].split(",");
var sql = "INSERT INTO products (linecode, description, barcode, price, stock) values (" +
line[0] + ", " +
"'" + line[2] + "', " +
"'" + line[1] + "', " +
line[6] + "," +
line[13] + ")";
html5sql.process(sql);
var pd = i / lines.length * 100;
$(".progress-bar").css("width", pd + "%");
i++;
if (i < lines.length) {
setTimeout(addRow, 2);
}
}
addRow();
}, function(error, failingQuery) {
alert("Error : " + error.message + "\r\n" + failingQuery);
});
};
reader.readAsText(file);
}
There's obviously stuff in there that won't be relevant and you'll need to change. Also I had a global variable, _dbSize, that was the initial size (in bytes) of the database, and there's some stuff in there about a progress bar. Use it or delete it - it won't affect the database being created.
Also, note the use of the addRow() function that calls itself. This was to enable the function to run asynchronously, which is needed if you want to be UI friendly (nothing will update whilst doing the import if you just import everything in one go).
However, since you mention AJAX then that may not be relevant. In which case you're just looking at API calls for whatever service is holding your database.
Hi friend ! If you're new to hybrid development, I highly recommend you to take a look at Ionic. It would help you on so many levels ! http://ionicframework.com/
About your issue, you can always define a REST API using your favorite backend (I know it can be done very easily with Laravel framework in PHP using MySQL DB). I prefer using Firebase ! https://www.firebase.com/
Firebase and Ionic framework based on AngularJS are such perfect match that half your code is already done before you knows it.
Happy coding !

Get Device Id used by an App

Hi,
I'm trying to hack an old game (it isn't available in the store anymore) for fun and learning purposes. I'm running W10 but the app is targeted for WP7.
The game encrypts all the files it saves with AES, using the Device Unique Id as the key. It gets the DUID with the following code:
Code:
private string DeviceId
{
get
{
if (string.IsNullOrEmpty(this.id))
{
byte[] numArray = (byte[]) DeviceExtendedProperties.GetValue("DeviceUniqueId");
this.id = "";
foreach (byte num in numArray)
this.id += num.ToString("X2");
if (string.IsNullOrEmpty(this.id))
this.id = "0D0FC36982524EBB25E1CA471F32824286B90F47";
}
return this.id;
}
}
The thing is I don't know how to get that ID from outside the app, which might be unique for the device and publisher. I've searched in all the app files in AppData and seems like it doesn't record the ID anywhere.
I've tried for days and considered other approaches with no luck. Ideas? Suggestions? Any help? Thanks.

Categories

Resources