Thread.Sleep (.NET) vs Sleep Function (WinAPI)

Thread.Sleep is a sign of a poorly designed program.

by Peter Ritchie.

Thread.Sleep has it’s use: simulating lengthy operations while testing/debugging on an MTA thread.  In .NET there’s no other reason to use it.

Thread.Sleep(n) means block the current thread for at least the number of timeslices (or thread quantums) that can occur within n milliseconds.  The length of a timeslice is different on different versions/types of Windows and different processors and generally ranges from 15 to 30 milliseconds.  This means the thread is almost guaranteed to block for more than n milliseconds.  The likelihood that your thread will re-awaken exactly after n milliseconds is about as impossible as impossible can be.  So, Thread.Sleep is pointless for timing.  Read the rest of this entry »

VB.NET ListView Tutorial. Add, Edit and Delete

I was searching for some tutorial on how to use ListView in VB .NET a few minutes ago and this was the solution that I gotten from Google search engine.  I have to complete my project of a Parental Control Software in 40 days, I wonder whether I can complete them in the remaining amount of time.  Although the project looks easy, it is not something I am coding for my own interest which makes me feel lazy everytime I turn on Visual Studio 2008.  But whatever, let us hope I can get the things done at the right time!


Creating application with a single instance in C and VB .NET

Most of us prefer to have single instances application to make it look professional or probably some other personal reason especially making malicious applications too.  Here is the source code for the 2 languages that has been mentioned.


#include <windows.h>

int main()
	char *mutex = "some name here";

	HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, mutex);
	if(hMutex == NULL)
		hMutex = CreateMutex(NULL, FALSE, mutex);
		MessageBox(0, "Instance Exists!", 0, 0);
		return 0;

	return 0;


Function PrevInstance() As Boolean
	If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
            Return True
            Return False
        End If
End Function

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	If PrevInstance() = True Then
            MsgBox("Instance Exists!")
        End If
End Sub

Sorting Registries in VB .NET

So there’s this guy from that needed some help getting a function created for him to breakup a single string that contains Name, Registry Key and Registry Data and appends the strings into a richtextbox.

AutoCAD 2010|Serial=HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\ACAD-8001:409\=SerialNumber


RichTextBox1.AppendText(“Autocad 2010” & vbNewLine)
Dim ammSteal01 As String = Registry.GetValue(“HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\ACAD-8001:409”, “SerialNumber”, Nothing)

So i created a simple function called
Private Sub AppendStringToRichTextBox2(ByVal str As String, ByVal txtbox As RichTextBox)

which does

        Dim title As String = ""
        Dim key As String = ""
        Dim data As String = ""

        Dim str_arr As String() = str.Split("=")

        key = str_arr(1)
        data = str_arr(2)

        For i = 0 To str_arr(0).Length - 1
            If str_arr(0)(i) = "|" Then
                Exit For
            End If

            title += str_arr(0)(i)

        txtbox.AppendText(title & vbNewLine)
        txtbox.AppendText(Microsoft.Win32.Registry.GetValue(key, data, Nothing))

The function generally appends the name of the application and the value of the key that have been called via Registry.GetValue. Well it’s nothing hard so port it to your own use if you need it.

.NET and its vulnerabilities

Well i continued programming in VB .NET for the last 2 months and i finally got my own masterpiece! I’m able to sell the product but i have many doubts in mind especially crackers. I googled and searched various methods to get it safely encrypted as well as decompiling it (working both ways is so what gray hat does). Well i had found a variety of method of doing so and i’m pretty satisfied with the outcome! I never knew decompiling was so fun as well as injecting codes into it. Now’s the time to do some nasty art! Oh well.. luckily i’m a 90% most of the time C person… leave the 10% to VB .NET