Exemplo n.º 1
0
		private static unsafe string EncodeObject(ref object data, UnsafeNativeMethods.EventData* dataDescriptor, byte* dataBuffer)
		{
			(*(dataDescriptor)).Reserved = 0;
			string str = data as string;
			if (str == null)
			{
				if (data as IntPtr == 0)
				{
					if (data as int == 0)
					{
						if (data as long == 0)
						{
							if (data as uint == 0)
							{
								if (data as ulong == 0)
								{
									if (data as char == 0)
									{
										if (data as byte == 0)
										{
											if (data as short == 0)
											{
												if (data as sbyte == 0)
												{
													if (data as ushort == 0)
													{
														if (data as float == 0)
														{
															if (data as double == 0)
															{
																if (!data as bool)
																{
																	if (data as Guid == null)
																	{
																		if (data as decimal == null)
																		{
																			if (!data as bool)
																			{
																				str = data.ToString();
																				(*(dataDescriptor)).Size = (str.Length + 1) * 2;
																				return str;
																			}
																			else
																			{
																				(*(dataDescriptor)).Size = 1;
																				*((bool*)dataBuffer) = (bool)data;
																				(*(dataDescriptor)).DataPointer = (ulong)((bool*)dataBuffer);
																			}
																		}
																		else
																		{
																			(*(dataDescriptor)).Size = 16;
																			*((decimal*)dataBuffer) = (decimal)data;
																			(*(dataDescriptor)).DataPointer = (ulong)((decimal*)dataBuffer);
																		}
																	}
																	else
																	{
																		(*(dataDescriptor)).Size = sizeof(Guid);
																		*((Guid*)dataBuffer) = (Guid)data;
																		(*(dataDescriptor)).DataPointer = (ulong)((Guid*)dataBuffer);
																	}
																}
																else
																{
																	(*(dataDescriptor)).Size = 1;
																	*((bool*)dataBuffer) = (bool)data;
																	(*(dataDescriptor)).DataPointer = (ulong)((bool*)dataBuffer);
																}
															}
															else
															{
																(*(dataDescriptor)).Size = 8;
																*((double*)dataBuffer) = (double)data;
																(*(dataDescriptor)).DataPointer = (ulong)((double*)dataBuffer);
															}
														}
														else
														{
															(*(dataDescriptor)).Size = 4;
															*((float*)dataBuffer) = (float)data;
															(*(dataDescriptor)).DataPointer = (ulong)((float*)dataBuffer);
														}
													}
													else
													{
														(*(dataDescriptor)).Size = 2;
														*((ushort*)dataBuffer) = (ushort)data;
														(*(dataDescriptor)).DataPointer = (ulong)((ushort*)dataBuffer);
													}
												}
												else
												{
													(*(dataDescriptor)).Size = 1;
													*((sbyte*)dataBuffer) = (sbyte)data;
													(*(dataDescriptor)).DataPointer = (ulong)((sbyte*)dataBuffer);
												}
											}
											else
											{
												(*(dataDescriptor)).Size = 2;
												*((short*)dataBuffer) = (short)data;
												(*(dataDescriptor)).DataPointer = (ulong)((short*)dataBuffer);
											}
										}
										else
										{
											(*(dataDescriptor)).Size = 1;
											*(dataBuffer) = (byte)data;
											(*(dataDescriptor)).DataPointer = (ulong)dataBuffer;
										}
									}
									else
									{
										(*(dataDescriptor)).Size = 2;
										*((char*)dataBuffer) = (char)data;
										(*(dataDescriptor)).DataPointer = (ulong)((char*)dataBuffer);
									}
								}
								else
								{
									(*(dataDescriptor)).Size = 8;
									*((ulong*)dataBuffer) = (ulong)data;
									(*(dataDescriptor)).DataPointer = (ulong)((ulong*)dataBuffer);
								}
							}
							else
							{
								(*(dataDescriptor)).Size = 4;
								*((uint*)dataBuffer) = (uint)data;
								(*(dataDescriptor)).DataPointer = (ulong)((uint*)dataBuffer);
							}
						}
						else
						{
							(*(dataDescriptor)).Size = 8;
							*((long*)dataBuffer) = (long)data;
							(*(dataDescriptor)).DataPointer = (ulong)((long*)dataBuffer);
						}
					}
					else
					{
						(*(dataDescriptor)).Size = 4;
						*((int*)dataBuffer) = (int)data;
						(*(dataDescriptor)).DataPointer = (ulong)((int*)dataBuffer);
					}
				}
				else
				{
					(*(dataDescriptor)).Size = sizeof(IntPtr);
					*((IntPtr*)dataBuffer) = (IntPtr)data;
					(*(dataDescriptor)).DataPointer = (ulong)((IntPtr*)dataBuffer);
				}
				return null;
			}
			else
			{
				(*(dataDescriptor)).Size = (str.Length + 1) * 2;
				return str;
			}
		}
Exemplo n.º 2
0
		internal static extern unsafe uint EventWrite(long registrationHandle, ref System.Runtime.Diagnostics.EventDescriptor eventDescriptor, uint userDataCount, UnsafeNativeMethods.EventData* userData);
Exemplo n.º 3
0
		internal static extern unsafe uint EventWriteTransfer(long registrationHandle, ref System.Runtime.Diagnostics.EventDescriptor eventDescriptor, ref Guid activityId, ref Guid relatedActivityId, uint userDataCount, UnsafeNativeMethods.EventData* userData);
Exemplo n.º 4
0
		internal static extern unsafe uint EventRegister(ref Guid providerId, UnsafeNativeMethods.EtwEnableCallback enableCallback, void* callbackContext, out long registrationHandle);