Solved

Get serial number different for PPC2003 than WM5/5

Posted on 2009-07-01
2
550 Views
Last Modified: 2013-12-27
I use the following code to get the serial number for my WM5/6 devices:

typedef int (__cdecl *MYPROC)(LPBYTE, DWORD, DWORD, LPBYTE, DWORD *);

MYPROC ProcAdd;

// Attemp to load aygshell.dll
HMODULE hLib = LoadLibrary(_T("coredll.dll"));
if (hLib)
{            
      ProcAdd = (MYPROC)GetProcAddress(hLib, _T("GetDeviceUniqueID"));

      if(ProcAdd)
      {

                   HRESULT hr = NOERROR;      
                    const GUID     bApplicationData1  = { 0x8d552bd1, 0xe232, 0x4107, { 0xb7,  
                             0x2d, 0x38, 0xb6, 0xa4, 0x72, 0x64, 0x39 } };
               const DWORD    cbApplicationData1 = sizeof (bApplicationData1);

       // Buffers to hold the two device IDs we are going to generate
      BYTE                g_bDeviceID1[GETDEVICEUNIQUEID_V1_OUTPUT];
      // Lengths of the returned device IDs
      DWORD               g_cbDeviceID1;

      g_cbDeviceID1 = GETDEVICEUNIQUEID_V1_OUTPUT;
      hr = ProcAdd (reinterpret_cast<LPBYTE>(const_cast<LPGUID>
                            &bApplicationData1)), cbApplicationData1,GETDEVICEUNIQUEID_V1,
                                 g_bDeviceID1,
                                 &g_cbDeviceID1);

      TCHAR        szDeviceID[(GETDEVICEUNIQUEID_V1_OUTPUT * 2) + 1];
            
      if (SUCCEEDED (DeviceID2String (g_bDeviceID1, g_cbDeviceID1, szDeviceID,
                                                                                                    ARRAYSIZE (szDeviceID))))
      {
            sSerialNo = szDeviceID;
      }
                  
}
else
{
      AfxMessageBox(_T("GetSerialNumber Error: ProcAdd NULL"));
      sSerialNo.Empty();

}

CloseHandle(hLib);

This works fine in WM5/6 but in PPC2003 it fails here:
ProcAdd = (MYPROC)GetProcAddress(hLib, _T("GetDeviceUniqueID"));
if(ProcAdd)
{
    blah blah
}

Why is this and how can I go about it?

Thanks
0
Comment
Question by:Wanting2LearnMan
  • 2
2 Comments
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 24760380
You can retrieve the same data by using KernelIOControl API with IOCTL_HAL_GET_DEVICEID. PPC2003 does have the privilliged mode, so it is possible to call such API without any problem:
http://msdn.microsoft.com/en-us/library/aa446562.aspx
http://msdn.microsoft.com/en-us/library/ms880643.aspx
 http://forum.soft32.com/pda/device-id-unique-device-ftopict53543.html
 Other tricks about the subject:
1. GetDeviceCaps - you can retrieve OEM info and use it.
2. Phone number or IMEI if it is phone enabled PDA.
3. You can retrieve the serial number of the SD-card.
4. You can generate yourself a unique number and save on a persistent storage.
 
0
 
LVL 33

Assisted Solution

by:pgnatyuk
pgnatyuk earned 500 total points
ID: 24784132
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reset Kindle Fire HD 7 2 121
zeroMAx challenge 20 101
wordappend challenge 8 177
Header Errors LNK2019, LNK1120 - Unresolved Externals 4 136
Let me explain this picture a little bit.  First, in case you haven't already guessed, you are looking at my 2 phones, an Android Samsung Galaxy S5 on the left and an iPhone 5 on the right.  They are on their respective cradles on my desk.  But, you…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question