public uint GetPropertyUint(string name) { if (this.Parser == null) { return(0); } if (!this.Parser.HasProperty(name)) { return(0); } uint offset, bsize; uint fieldId = this.Parser.Property(name); uint uRet, ulReturnLength; NmPropertyValueType vt; unsafe { byte[] uintBuffer = new byte[8]; fixed(byte *pbuf = uintBuffer) { if (0 == NetmonAPI.NmGetPropertyById(Parser.Handle, fieldId, 8, pbuf, out ulReturnLength, out vt, 0, null)) { //uintBuffer.to return(System.BitConverter.ToUInt32(uintBuffer, 0)); } } } return(0); }
public string GetPropertyString(string name) { if (this.Parser == null) { return(null); } if (!this.Parser.HasProperty(name)) { return(null); } uint fieldId = this.Parser.Property(name); uint ulLength = 255; NmPropertyValueType vt; unsafe { byte[] uintBuffer = new byte[255]; fixed(byte *pbuf = uintBuffer) { uint ret = NetmonAPI.NmGetPropertyById(Parser.Handle, fieldId, ulLength, pbuf, out ulLength, out vt, 0, null); if (ret == 122 && vt == NmPropertyValueType.PropertyValueString) { uintBuffer = new byte[ulLength]; fixed(byte *pbuf2 = uintBuffer) { if (0 == NetmonAPI.NmGetPropertyById(Parser.Handle, fieldId, ulLength, pbuf2, out ulLength, out vt, 0, null)) { //uintBuffer.to return(System.Text.Encoding.Unicode.GetString(uintBuffer, 0, (int)ulLength).Trim('\0')); } } } else if (ret == 0 && vt == NmPropertyValueType.PropertyValueString) { return(System.Text.Encoding.Unicode.GetString(uintBuffer, 0, (int)ulLength).Trim('\0')); } } } return(null); }
/// <summary> /// get all properties value by id /// </summary> private void GetPropertyValue() { foreach (KeyValuePair <string, uint> pair in _FrameInfoUnit.PropertyIdDict) { unsafe { uint ret1; IntPtr buff = Marshal.AllocHGlobal(2000); uint returnLen = 0; NmPropertyValueType value; string property = pair.Key; uint id = pair.Value; ret1 = NetmonAPI.NmGetPropertyById(_FrameInfoUnit.FrameParser, id, 2000, (byte *)buff, out returnLen, out value, 0, new CNmPropertyStorageKey[1]); //Console.WriteLine(value); if (value == NmPropertyValueType.PropertyValueSignedNumber) { PropertyValueDict.Add(property, Marshal.ReadInt64(buff)); } if (value == NmPropertyValueType.PropertyValueString) { PropertyValueDict.Add(property, Marshal.PtrToStringAuto(buff)); } if (value == NmPropertyValueType.PropertyValueUnsignedNumber) { PropertyValueDict.Add(property, Marshal.ReadInt64(buff)); } if (value == NmPropertyValueType.PropertyValueByteBlob)//to do here { } if (value == NmPropertyValueType.PropertyValueNone) // no such data in the frame { PropertyValueDict.Add(property, NoneTypeMatched); } Marshal.Release(buff); } } }