emulator uid

Greetings to all, I am trying to identify of unique form PPC. Well, so far everythings ok, I have found code that gets the MAC to me from a phisical device, but the problem I have at the time of getting something that identifies of unique form the emulator to me of the PPC.

In this page it says to me how to do so that the most real PPC
http://blogs.msdn.com/vsdteam/archive/2005/10/07/478295.aspx
In this other says to me that there's no way
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=9997&SiteID=1


I need something that is unique and each emulator can identify me.

I let the code to get the MAC to you from the physical device, in case somebody has this problem, because solved.

[DllImport("coredll.dll")]
private static extern bool KernelIoControl(Int32 IoControlCode, IntPtr
InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer, Int32
OutputBufferSize, ref Int32 BytesReturned);


public static string GetDeviceID()
{
byte[] OutputBuffer = new byte[256];
Int32 OutputBufferSize, BytesReturned;
OutputBufferSize = OutputBuffer.Length;
BytesReturned = 0;

// Call KernelIoControl passing the previously defined
// IOCTL_HAL_GET_DEVICEID parameter
// We don’t need to pass any input buffers to this call
// so InputBuffer and InputBufferSize are set to their null
// values
bool retVal = KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero, 0, OutputBuffer, OutputBufferSize, ref BytesReturned);

// If the request failed, exit the method now
if (retVal == false)
{
return null;
}

// Examine the OutputBuffer byte array to find the start of the
// Preset ID and Platform ID, as well as the size of the
// PlatformID.
// PresetIDOffset – The number of bytes the preset ID is offset
// from the beginning of the structure
// PlatformIDOffset - The number of bytes the platform ID is
// offset from the beginning of the structure
// PlatformIDSize - The number of bytes used to store the
// platform ID
// Use BitConverter.ToInt32() to convert from byte[] to int
Int32 PresetIDOffset = BitConverter.ToInt32(OutputBuffer, 4);
Int32 PlatformIDOffset = BitConverter.ToInt32(OutputBuffer, 0xc);
Int32 PlatformIDSize = BitConverter.ToInt32(OutputBuffer, 0x10);

// Convert the Preset ID segments into a string so they can be
// displayed easily.
StringBuilder sb = new StringBuilder();
sb.Append(String.Format("{0:X8}-{1:X4}-{2:X4}-{3:X4}-",
BitConverter.ToInt32(OutputBuffer, PresetIDOffset),
BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 4),
BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 6),
BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 8)));

// Break the Platform ID down into 2-digit hexadecimal numbers
// and append them to the Preset ID. This will result in a
// string-formatted Device ID
for (int i = PlatformIDOffset; i < PlatformIDOffset + PlatformIDSize; i++)
{
sb.Append(String.Format("{0:X2}", OutputBufferIdea));
}

// return the Device ID string
return sb.ToString();
}

The problem is in which the call that does to the KernelIoControl gives back false when you are with the emulator. I suppose that constant IOCTL_HAL_GET_DEVICEID will take the information to say to him if it is or not an emulator which is being handled, but... I remain there.

thanks for all.



Answer this question

emulator uid

  • rronny

    Ok, thanks, but.... is there another option to identify the emulator I need to distribute a license to my code, and need to identify the emulator.


  • EricSmith

    Thanks Michael, but the only information I can get with SystemParametersInfo is "Microsoft DeviceEmulator" and as you suposed, it don't solve my problem. I am tryin' to get more information using constants that are defined here http://msdn2.microsoft.com/en-us/library/ms942638.aspx.


  • Dan_Brownlow

    Hi

    The emulator do not support this IOCTL - that's why you KernerlIoControl returns false.

    Some more infos see:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=10089&SiteID=1

    Michael



  • enric vives

    I think the hashcode from the ROM's device is unique, although I develop using emulator device, but.... hahaha, how can i access to ROM's device


  • Cla82

    One option might be to use OEM device info (Model and Manufacturer).
    Call the Win32 API SystemParametersInfo with uiAction = SPI_GETOEMINFO. to get the model infos.

    I'd suggest you evaulate this option whether this meets your requirements.



  • emulator uid