Creating a new device layout - ViRb3/nMAC GitHub Wiki
If you know where your MAC file resides and you know how to code in C#, you can create the device layout for nMAC yourself! I've tried my best to make the implementation as easy and fast as possible.
Steps
There is a base abstract class DeviceModel
. Its members must be overridden to implement a new MAC layout.
- Check if we support the MAC file found on the device
Even if we find a MAC file in our layout's location, the content might be different than what we expect. Thus, it is very important that we match the whole file to ensure it will be supported.
Regex FileSyntax
- Can be used in the methods below to match string
content. User-added new lines and spaces should be tolerated by this regex.
bool CheckFile(byte[] content)
- takes the content of the MAC file as byte[]
and returns whether the file is supported.
bool CheckFile(string content)
- same as above, but an automatic conversion to a string
is done first.
You can override either of these two methods, depending on the way your MAC address is stored.
-
Extract a MAC address in the form
AABBCCDDEEFF
from the MAC file
string ExtractMACFromFile(byte[] content)
- returns MAC address asstring
.
string ExtractMACFromFile(string content)
-
Write a new MAC address in the above form to the MAC file
void WriteMAC(ref byte[] content, string MAC)
- writes thestring
MAC address to thebyte[]
content of the MAC file.
void WriteMAC(ref string content, string MAC)
-
Add the newly created
DeviceModel
to the list inMACFunctions/DetectDevice()
Once finished and tested, please submit a pull request. I will try to review and accept it ASAP. Thanks!