Slasti Strasti Propasti Windows Mobile

  • View
    2.192

  • Download
    3

Embed Size (px)

DESCRIPTION

 

Text of Slasti Strasti Propasti Windows Mobile

  • 1. Ren Stein Senior Software Architect http://renestein.net http://blog.renestein.net

2. Mobil n zazen Standard Windows Mobile Tablet PC jin svt Professional Classic

  • Gadgety

3. GPS Intermediate Driver

  • Pstup k GPS pouze z jedn aplikace pmo pes sriov port ped Windows Mobile 5.0
    • Znte Franson GPS Gate
  • GPS Intermediatedriver
    • Parsov n NMEA zprv z GPS ($GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A )
    • Doruen do vce aplikac
  • GPSOpenDevice()
  • GPSCloseDevice()
  • GPSGetPosition()
  • GPSGetDeviceState()

4.

  • HANDLE g_hGPSDevice;
  • g_hGPSDevice = GPSOpenDevice(NULL,NULL,NULL,0);
  • GPS_DEVICE gpsDevice;
  • ZeroMemory(&gpsDevice,sizeof(GPS_DEVICE)); gpsDevice.dwVersion=GPS_VERSION_1; gpsDevice.dwSize=sizeof(GPS_DEVICE); DWORD result=GPSGetDeviceState(&gpsDevice);
  • Je mon se nechat notifikovat o pchozch datech /stavu GPS(CreateEvent).

5. Zskn pozice

  • GPS_POSITION gpsPosition; ZeroMemory(&gpsPosition,sizeof(GPS_POSITION)); gpsPosition.dwVersion=GPS_VERSION_1; gpsPosition.dwSize=sizeof(GPS_POSITION); DWORD result= GPSGetPosition (g_hGPSDevice,&gpsPosition,10000,0);
  • gpsPositionValid.dblLatitude
  • gpsPositionValid.dblLongitude

6. Managed kd pes P /Invoke

  • public const int LMEM_ZEROINIT = 0x40; [System.Runtime.InteropServices.DllImport("coredll.dll", EntryPoint = "#33", SetLastError = true) ] public static extern IntPtr LocalAlloc(int flags, int byteCount); [System.Runtime.InteropServices.DllImport("coredll.dll", EntryPoint = "#36", SetLastError = true) ] public static extern IntPtr LocalFree(IntPtr hMem); [DllImport("gpsapi.dll") ] static extern IntPtr GPSOpenDevice(IntPtr hNewLocationData, IntPtr hDeviceStateChange, string szDeviceName, int dwFlags); [DllImport("gpsapi.dll") ] static extern int GPSCloseDevice(IntPtr hGPSDevice); [DllImport("gpsapi.dll") ] static extern int GPSGetPosition(IntPtr hGPSDevice, IntPtr pGPSPosition, int dwMaximumAge, int dwFlags); [DllImport("gpsapi.dll") ] static extern int GPSGetDeviceState(IntPtr pGPSDevice);
  • KOMPLETN PKLAD je v SDK (C #, zkompilovan na XDA-Developers)

7. A te strasti...

  • GPS ID API je hezk API. Alespo na prvn pohled...
  • Ale:
  • Na nkterch zazench s WM6GPSGetPositionvrac chybu87 (ERROR_INVALID_PARAMETER).
    • Dvod: OEM partnei a Microsoft potaj s jinou velikost struktury GPS_POSITION.
    • Obezlika:
    • BYTE gpsPositionRaw[376]; GPS_POSITION *pGpsLocation = (GPS_POSITION*)gpsPositionRaw; pGpsLocation->dwVersion = GPS_VERSION_1; pGpsLocation->dwSize = sizeof(gpsPositionRaw);

8. Dal strasti.

  • Na HTC Artemis (MDA Vario III) je nekompletn signalizace EV_RXCHAR na sriovm portu.
  • To znamen, e nikdynedostanete informaci o poloze,co je u GPS API podstatn chyba:-)
  • Obe zliky :
    • Nvrat ke komunikaci pes sriov port
    • Pouit API ReadFile a v pravidelnch intervalech se pokusit st z portu.
  • Zkuste si na HTC Kaiser pipojit extern GPS nebo si jen pohrt s nastavenm driveru.

9. Komunikace pes bluetooth

  • Vtina zazen pouv MS BT Stack
    • Widcomm Stack
  • Lid obecn internetov m za obtnho bernka Microsoft
    • M lo podporovanch BT protokol
    • Chybn implementace BT profil
    • Vyazen nkterch protokol z OS BT DUN
    • Nejsou podporovny vechny specialitky BT profil (BT Handsfree)
    • Propojen BT s nastavenm IrDA
    • Nesmysln omezen u BT Handsfree (autordio Pioneer oekv BT class Smartphone)
    • patn vyladn drivery od dodavatele HW HTC Kaiser.
  • Widcomm a Ipaq
    • WM_HIBERNATE a pot odstelen ovldac konzole, kter zpsobilo i nefunknost driveru !!!!!

10. Contents Contents 11. Podpora Bluetooth pes winsock

  • BTHGetState
  • BTHSetState
  • Znte problmy s nastavenm bluetooth do reimu Discoverable Viditeln?
  • Enumerace zazen a slueb
    • WSALookupServiceBegin
    • WSALookupServiceBegin
  • Nijak zvl pvtiv kd. Ukzka.

12. Vlastn protokoly

  • Bthnscreate.exe pro snadn vytvoen struktury SDP zznamu (recordu) bohuel pouze soust Platform Builderu.
  • #define SDP_HF_RECORD_SIZE0x00000048
  • BYTE rgbSdpRecordHeadsetHF[] = {
  • 0x35, 0x46, 0x09, 0x00, 0x01, 0x35, 0x06, 0x19,
  • 0x11, 0x1f, 0x19, 0x12, 0x03, 0x09, 0x00, 0x04,
  • 0x35, 0x0c, 0x35, 0x03, 0x19, 0x01, 0x00, 0x35,
  • 0x05, 0x19, 0x00, 0x03, 0x08, 0x0a, 0x09, 0x00,
  • 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x1e,
  • 0x09, 0x01, 0x01, 0x09, 0x01, 0x00, 0x25, 0x0d,
  • 0x56, 0x6f, 0x69, 0x63, 0x65, 0x20, 0x47, 0x61,
  • 0x74, 0x65, 0x77, 0x61, 0x79, 0x09, 0x03, 0x01,
  • 0x08, 0x01, 0x09, 0x03, 0x11, 0x09, 0x00, 0x00
  • };

13. Vlastn Audio Gateway- HF profile

  • typedef DWORD (*PFN_SendATCommand) (LPSTR szCommand, DWORD cbCommand);
  • BOOL BthAGATHandler(LPSTR szCommand, DWORD cbCommand);
  • void BthAGATSetCallback(PFN_SendATCommand pfn);
  • typedef DWORD (*PFN_SendATCommand) (LPSTR szCommand, DWORD cbCommand);
  • DWORD BthAGOnVoiceTag(BOOL fOn);
  • HKEY_LOCAL_MACHINEOFTWAREicrosoftluetoothudioGatewayTAGExtModule
  • Nepln dokumentace na MSDn

14. Komunikace pes WiFi

  • Vtina vvoj pedpokld, e Microsoft poskytne njak API pro sprvu WiFi. dn zvazn API neexistuje.
  • Pouze OEM partn e i jsou odpovdn za WiFimodula jeho monosti.
  • OEMAPI nen veejn.
  • Voliteln podpora WZC, NDIS...

15. Probl my

  • Pi zmn IP adresy, DHCP, masce stmuste vtinou resetovat PDA.
  • Wifi Profily aplikuj profil ihned bez resetu.
  • U nkterch zazen (MDA Vario) problmy s nahrnm ovladae WiFi.
  • Zmna

16. Reinicializace adaptru pes NDIS /IO

  • HANDLE hDevice = CreateFile(DD_NDIS_DEVICE_NAME, GENERIC_READ |GENERIC_WRITE,F ILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
  • 0,
  • NULL);
  • if (hDevice == INVALID_HANDLE_VALUE)
  • {
        • return false;
  • }
  • int adapterNamefullLength = adapterName.GetLength() + 2;
  • WCHAR* pAdapterName = new WCHAR[adapterNamefullLength];
  • if (!pAdapterName)
  • {
  • return false;
  • }
  • wcscpy(pAdapterName , adapterName);
  • pAdapterName[adapterNamefullLength - 2] = L'';
  • pAdapterName[adapterNamefullLength - 1] = L'';
  • bool result = true;
  • if (!DeviceIoControl(hDevice, IOCTL_NDIS_REBIND_ADAPTER, pAdapterName,adapt erNamefullLength * sizeof(WCHAR),
  • NULL,
  • NULL,
  • NULL,
  • NULL))
  • {
  • result = false;
  • }
  • CloseHandle(hDevice);

17. Spoutn Wifi od Windows Mobile 5- nedokumentovno !!

  • g_DllWrlspwr = LoadLibrary(TEXT("ossvcs.dll"));
  • if (g_DllWrlspwr == NULL)
  • return FALSE;
  • pGetWirelessDevices= (_GetWirelessDevices)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(GetWirelessDevice_ORDINAL));
  • if (pGetWirelessDevices == NULL)
  • return FALSE;
  • pChangeRadioState= (_ChangeRadioState)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(ChangeRadioState_ORDINAL));
  • if (pChangeRadioState == NULL)
  • return FALSE;
  • pFreeDeviceList = (_FreeDeviceList)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(FreeDeviceList_ORDINAL));
  • if (pFreeDeviceList == NULL)
  • return FALSE;
  • return TRUE;

18. Pro hack funguje? Odpovd je pravdpodobn SNAPI. 19. SNAPI v Compact .Net Frameworku

  • SystemS tatestate= new SystemState(SystemProperty.DisplayRotation );
  • state.Changed += new ChangeEventHandler(state_Changed);

20. Informace z telefonn sti GSM modulu

  • Microsoft podporuje pro vvoje aplikac pouze TAPI.
  • Pes TAPI uskutente hovor, zjistte informace o lince, ale urit se nedostanete k dajm jako jsou Cell Id, LAC apod.
  • Pomoc cell id lze napklad zjistit, kde se piblin nachzme. (Google Maps Mobile).
  • Ale jak se k tmto dajm dostat?