Click here to Skip to main content
15,881,559 members
Articles / Programming Languages / Visual Basic
Tip/Trick

How to Secure Your Application with Matching Processor Id Complete [the DLL source code]

Rate me:
Please Sign up or sign in to vote.
2.88/5 (18 votes)
23 Nov 2016CPOL2 min read 79.2K   2.4K   43   17
the source code is available

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.

VB.NET
'---------------------------------------------------------
Imports System
Imports System.Management
Namespace nsProcessorID
Public Class CPUId
'make a function which will get processor id from the system and return a string
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.

VB.NET
'-----------------------------------------------------
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Pakistan Pakistan
simply vb dotnet lover

Comments and Discussions

 
QuestionNot Working Pin
Member 1287961727-Dec-17 19:44
Member 1287961727-Dec-17 19:44 
QuestionGreat !!!!!!! Pin
Ammiel8-Mar-13 5:07
Ammiel8-Mar-13 5:07 
QuestionGreat articule Pin
Ammiel8-Mar-13 5:07
Ammiel8-Mar-13 5:07 
GeneralMy vote of 5 Pin
Rafael_Yousuf23-Sep-12 22:48
professionalRafael_Yousuf23-Sep-12 22:48 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey25-Apr-12 0:19
professionalManoj Kumar Choubey25-Apr-12 0:19 
GeneralMy vote of 4 Pin
T_uRRiCA_N12-May-11 19:40
professionalT_uRRiCA_N12-May-11 19:40 
GeneralRe: My vote of 4 Pin
skhurams2-Jun-11 0:27
skhurams2-Jun-11 0:27 
GeneralMy vote of 5 Pin
ramez bouorm9-May-11 6:53
ramez bouorm9-May-11 6:53 
Generali have updated the article Pin
skhurams9-May-11 5:22
skhurams9-May-11 5:22 
QuestionPart 1 not found Pin
rmfaizal22-Aug-07 0:45
rmfaizal22-Aug-07 0:45 
GeneralRe: Part 1 not found Pin
skhurams5-Dec-07 20:43
skhurams5-Dec-07 20:43 
QuestionWhy This Application Give the same value? Pin
adondon_amr16-Jan-07 0:05
adondon_amr16-Jan-07 0:05 
AnswerRe: Why This Application Give the same value? Pin
skhurams16-Jan-07 21:29
skhurams16-Jan-07 21:29 
GeneralRe: Why This Application Give the same value? Pin
skhurams5-Dec-07 20:41
skhurams5-Dec-07 20:41 
AnswerRe: Why This Application Give the same value? Pin
MehdiMousaviNezhad26-Nov-08 1:05
MehdiMousaviNezhad26-Nov-08 1:05 
GeneralRe: Why This Application Give the same value? Pin
skhurams28-Nov-08 6:50
skhurams28-Nov-08 6:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.