netripper

netripper

Jun 18th, 2009
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. // Only used to determine Code
  2.     [StructLayout(LayoutKind.Sequential)]
  3.     internal struct TagFM_NOTIFICATION_INTERNAL
  4.     {
  5.         public FMN_ACTIONS Code;
  6.         public uint Timestamp;
  7.         public IntPtr DataPtr;
  8.     }
  9.  
  10. // Based on code, Ptr is marshalled to FREQ
  11.     [StructLayout(LayoutKind.Sequential)]
  12.     internal struct TagFM_NOTIFICATION_FREQ_INTERNAL
  13.     {
  14.         public FMN_ACTIONS Code;
  15.         public uint Timestamp;
  16.         public FMN_FREQUENT_CHANGED FreqData;
  17.     }
  18.  
  19. // Or to RDS
  20.     [StructLayout(LayoutKind.Sequential)]
  21.     internal struct TagFM_NOTIFICATION_RDS_INTERNAL
  22.     {
  23.         public FMN_ACTIONS Code;
  24.         public uint Timestamp;
  25.         public FMN_RDS_RECEIVED_INTERNAL RdsData;
  26.     }
  27.  
  28. // RDSData is another IntPtr as it points to an array
  29.     [StructLayout(LayoutKind.Sequential)]
  30.     internal struct FMN_RDS_RECEIVED_INTERNAL
  31.     {
  32.         public ushort RDSCount;
  33.         public IntPtr RDSData;
  34.     }
  35.  
  36. // Marshalling each group and adding it to a list
  37.                     List<FM_RDS_GROUP> groups = new List<FM_RDS_GROUP>();
  38.                     for (int i = 0; i < iRdsNotify.RdsData.RDSCount; i++)
  39.                     {
  40.                         IntPtr ptr = iRdsNotify.RdsData.RDSData;
  41.                         int intptr = (int)ptr;
  42.                         intptr += i * Marshal.SizeOf(typeof(FM_RDS_GROUP));
  43.                         ptr = (IntPtr)intptr;
  44.  
  45.                         FM_RDS_GROUP group = (FM_RDS_GROUP)Marshal.PtrToStructure(ptr, typeof(FM_RDS_GROUP));
  46.                         groups.Add(group);
  47.                     }
  48.  
Add Comment
Please, Sign In to add comment