Adresse MAC physique ou virtuelle ?

Le
Dexw
Bonjour,

Est-il possible avec Windev ou une API de contrôler si l'adresse MAC
est physique ou virtuelle ?

Le but étant de protéger un programme contre la copie.

Merci.
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
tjfromparis
Le #24068151
y'a ca (pas testé) :
faut juste faire la conversion :)

ManagementObjectSearcher mos = null;
// WHERE Manufacturer!='Microsoft' removes all of the
// Microsoft provided virtual adapters like tunneling, miniports, and
Wide Area Network adapters.
mos = new ManagementObjectSearcher(@"SELECT *
FROM Win32_NetworkAdapter
WHERE Manufacturer !=
'Microsoft'");

// Trying the ConfigManagerErrorCode and NetConnectionStatus
variations
// proved to still not be enough and it returns adapters installed by
// the virtualization software like VMWare and VirtualBox
// ConfigManagerErrorCode = 0 -> Device is working properly. This
covers enabled and/or disconnected devices
// ConfigManagerErrorCode = 22 AND NetConnectionStatus = 0 -> Device
is disabled and Disconnected.
// Some virtual devices report ConfigManagerErrorCode = 22 (disabled)
and some other NetConnectionStatus than 0
mos = new ManagementObjectSearcher(@"SELECT *
FROM Win32_NetworkAdapter
WHERE Manufacturer !=
'Microsoft'
AND
(ConfigManagerErrorCode = 0
OR
(ConfigManagerErrorCode = 22 AND NetConnectionStatus = 0))");

// Final solution with filtering on the Manufacturer and PNPDeviceID
not starting with "ROOT"
// Physical devices have PNPDeviceID starting with "PCI" or something
else besides "ROOT"
mos = new ManagementObjectSearcher(@"SELECT *
FROM Win32_NetworkAdapter
WHERE Manufacturer !=
'Microsoft'
AND NOT PNPDeviceID LIKE
'ROOT\%'");
// Get the physical adapters and sort them by their index.
// This is needed because they're not sorted by default
IList<ManagementObject> managementObjectList = mos.Get()
.Cast<ManagementObject>()
.OrderBy(p =>
Convert.ToUInt32(p.Properties["Index"].Value))
.ToList();

// Let's just show all the properties for all physical adapters.
foreach (ManagementObject mo in managementObjectList)
{
foreach (PropertyData pd in mo.Properties)
Console.WriteLine(pd.Name + ": " + (pd.Value ?? "N/A"));
}


On 14 déc, 09:48, Dexw
Bonjour,

Est-il possible avec Windev ou une API de contrôler si l'adresse MAC
est physique ou virtuelle ?

Le but étant de protéger un programme contre la copie.

Merci.
Fredo
Le #24069011
Le 14/12/2011 11:54, a écrit :
y'a ca (pas testé) :
faut juste faire la conversion :)

ManagementObjectSearcher mos = null;
// WHERE Manufacturer!='Microsoft' removes all of the
// Microsoft provided virtual adapters like tunneling, miniports, and
Wide Area Network adapters.
mos = new ManagementObjectSearcher(@"SELECT *
FROM Win32_NetworkAdapter
WHERE Manufacturer ! > 'Microsoft'");

// Trying the ConfigManagerErrorCode and NetConnectionStatus
variations
// proved to still not be enough and it returns adapters installed by
// the virtualization software like VMWare and VirtualBox
// ConfigManagerErrorCode = 0 -> Device is working properly. This
covers enabled and/or disconnected devices
// ConfigManagerErrorCode = 22 AND NetConnectionStatus = 0 -> Device
is disabled and Disconnected.
// Some virtual devices report ConfigManagerErrorCode = 22 (disabled)
and some other NetConnectionStatus than 0
mos = new ManagementObjectSearcher(@"SELECT *
FROM Win32_NetworkAdapter
WHERE Manufacturer ! > 'Microsoft'
AND
(ConfigManagerErrorCode = 0
OR
(ConfigManagerErrorCode = 22 AND NetConnectionStatus = 0))");

// Final solution with filtering on the Manufacturer and PNPDeviceID
not starting with "ROOT"
// Physical devices have PNPDeviceID starting with "PCI" or something
else besides "ROOT"
mos = new ManagementObjectSearcher(@"SELECT *
FROM Win32_NetworkAdapter
WHERE Manufacturer ! > 'Microsoft'
AND NOT PNPDeviceID LIKE
'ROOT\%'");
// Get the physical adapters and sort them by their index.
// This is needed because they're not sorted by default
IList<ManagementObject> managementObjectList = mos.Get()
.Cast<ManagementObject>()
.OrderBy(p =>
Convert.ToUInt32(p.Properties["Index"].Value))
.ToList();

// Let's just show all the properties for all physical adapters.
foreach (ManagementObject mo in managementObjectList)
{
foreach (PropertyData pd in mo.Properties)
Console.WriteLine(pd.Name + ": " + (pd.Value ?? "N/A"));
}


On 14 déc, 09:48, Dexw
Bonjour,

Est-il possible avec Windev ou une API de contrôler si l'adresse MAC
est physique ou virtuelle ?

Le but étant de protéger un programme contre la copie.

Merci.







Dans le même sujet, qu'en est-il des utilitaires qui permettent de
changer l'adresse Mac d'une carte réseau à la volé (trouvé en 30secondes
sur le net)

Nous ne nous sommes pas basés sur l'adresse mac pour calculer notre clé
de protection car nous n'arrivons pas à lire l'adresse "réelle" de la
carte mais uniquement celle "édité" ... elle doit pourtant toujours être
la car on peut remettre l'adresse d'origine.

Bon dev,

Fred
Publicité
Poster une réponse
Anonyme