// Token: 0x0600051E RID: 1310 RVA: 0x0005281C File Offset: 0x00050A1C public string GetMacAddress() { string text = ""; try { Hardware.NCB ncb = default(Hardware.NCB); ncb.ncb_command = 55; int num = Marshal.SizeOf(typeof(Hardware.LANA_ENUM)); ncb.ncb_buffer = Marshal.AllocHGlobal(num); ncb.ncb_length = (ushort)num; char c = Hardware.Win32API.Netbios(ref ncb); Hardware.LANA_ENUM lana_ENUM = (Hardware.LANA_ENUM)Marshal.PtrToStructure(ncb.ncb_buffer, typeof(Hardware.LANA_ENUM)); Marshal.FreeHGlobal(ncb.ncb_buffer); if (c != '\0') { return(""); } for (int i = 0; i < (int)lana_ENUM.length; i++) { ncb.ncb_command = 50; ncb.ncb_lana_num = lana_ENUM.lana[i]; c = Hardware.Win32API.Netbios(ref ncb); if (c != '\0') { return(""); } ncb.ncb_command = 51; ncb.ncb_lana_num = lana_ENUM.lana[i]; ncb.ncb_callname[0] = 42; num = Marshal.SizeOf(typeof(Hardware.ADAPTER_STATUS)) + Marshal.SizeOf(typeof(Hardware.NAME_BUFFER)) * 30; ncb.ncb_buffer = Marshal.AllocHGlobal(num); ncb.ncb_length = (ushort)num; c = Hardware.Win32API.Netbios(ref ncb); Hardware.ASTAT astat; astat.adapt = (Hardware.ADAPTER_STATUS)Marshal.PtrToStructure(ncb.ncb_buffer, typeof(Hardware.ADAPTER_STATUS)); Marshal.FreeHGlobal(ncb.ncb_buffer); if (c == '\0') { if (i > 0) { text += ":"; } text = string.Format("{0,2:X}{1,2:X}{2,2:X}{3,2:X}{4,2:X}{5,2:X}", new object[] { astat.adapt.adapter_address[0], astat.adapt.adapter_address[1], astat.adapt.adapter_address[2], astat.adapt.adapter_address[3], astat.adapt.adapter_address[4], astat.adapt.adapter_address[5] }); } } } catch { } return(text.Replace(' ', '0')); }
public static extern char Netbios(ref Hardware.NCB ncb);