Introduction
A long time ago, I felt that there is no protection of our application when we sell to our clients, so I got some ideas and I just gave some logic.
Somehow, the first part got deleted and from then, there are a lot of changes made in .NET, so I didn't try and re-upload Part 1.
Anyhow, if you are interested, I will give you some logic and you will try it on your own. If you have any trouble, just email me.
So let's begin. You should download WMI creator from Microsoft site. Here is the link:
Note: It can generate code both in C# and VB.NET.
Then, visit this page with more tools:
Third, read this article:
Now the basic idea is that Windows Media Instrument WMI class directly communicates with hardware.
For example, if you want to get the OS information, you can use class OperatingSystem
and you will get all the OS information; e.g. when the OS was installed, virtual memory used by OS, etc.
Now how to generate these classes. Use WMI code generator which I mentioned to download first.
Now if you got the id of any hardware, for e.g., Harddisk or processor, you can compare it with hardcoded id and compare it and thus making your application secure.
Once I try this, I hardcode the Network Mac address and compare it with your code (generate code to get mac address of your network card through WMI code generator).
You may also try it on USB. Give your client a specific USB and get its id from WMI Code generator and make your application run only when you insert that specific USB.
Last thing is that there are certain other ways you can generate a WMI Class directly from Visual Studio 2008 server explorer.
I developed a main form and the comparison of ids in Part 1.
I have been emailed and asked to submit the source code for the processorid.dll.
Copy this code and paste in new project naming HardwareProcessorId
. Add a new class and name it CPUId
for fetching processor id.
Imports System
Imports System.Management
Namespace nsProcessorID
Public Class CPUId
Public Shared Function GetProcessorId() As String
Dim strProcessorId As String
Dim query As New SelectQuery("Win32_processor")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strProcessorId = info("processorId").ToString()
Next
Return strProcessorId
End Function
End Class
End Namespace
For motherboard id:
Add a new project and name it HardwareMotherboardID
. Copy and paste the following source code into new class MotherBoardID.vb.
Imports System
Imports System.Management
Namespace nsMotherBoardID
Public Class MotherBoardID
Public Shared Function GetMotherBoardID() As String
Dim strMotherBoardID As String
Dim query As New SelectQuery("Win32_BaseBoard")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strMotherBoardID = info("SerialNumber").ToString()
Next
Return strMotherBoardID
End Function
End Class
End Namespace
NOTE: I have used scriptomatic or WMI Creator from microsoft.com. You can use it to find other query, e.g., usb and harddisk, etc.