Click here to Skip to main content
Click here to Skip to main content

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

, 9 May 2011
Rate this:
Please Sign up or sign in to vote.
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, download tutorials from:

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

'-----------------------------------------------------
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)

Share

About the Author

skhurams

Pakistan Pakistan
simply vb dotnet lover

Comments and Discussions

 
SuggestionMessage Automatically Removed Pinmemberkamleshgs15-May-14 2:57 
QuestionGreat !!!!!!! PinmemberAmmiel8-Mar-13 5:07 
QuestionGreat articule PinmemberAmmiel8-Mar-13 5:07 
GeneralMy vote of 5 PinmemberRafael_Yousuf23-Sep-12 22:48 
GeneralMy vote of 5 Pinmembermanoj kumar choubey25-Apr-12 0:19 
GeneralMy vote of 4 PinmemberT_uRRiCA_N12-May-11 19:40 
GeneralRe: My vote of 4 Pinmemberskhurams2-Jun-11 0:27 
GeneralMy vote of 5 Pinmemberramez bouorm9-May-11 6:53 
Generali have updated the article Pinmemberskhurams9-May-11 5:22 
QuestionPart 1 not found Pinmemberrmfaizal22-Aug-07 0:45 
GeneralRe: Part 1 not found Pinmemberskhurams5-Dec-07 20:43 
QuestionWhy This Application Give the same value? Pinmemberadondon_amr16-Jan-07 0:05 
AnswerRe: Why This Application Give the same value? Pinmemberskhurams16-Jan-07 21:29 
GeneralRe: Why This Application Give the same value? Pinmemberskhurams5-Dec-07 20:41 
AnswerRe: Why This Application Give the same value? PinmemberLeilahedayat26-Nov-08 1:05 
GeneralRe: Why This Application Give the same value? Pinmemberskhurams28-Nov-08 6:50 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 9 May 2011
Article Copyright 2006 by skhurams
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid