Compaq/HP Laptop Notebook SATA

I just learned today while installing Windows XP SP2 in Compaq/HP laptop that when trying to install a fresh copy of Windows XP to this machine, it will cause you an error like this:

Unknown Device:
   There is no disk in this drive …

This is because SATA drivers for this laptop are not yet loaded upon installation. To fix this, just go to your BIOS setup\System Configuration\SATA Native Support. Change the status from ENABLED to DISABLED.

From here, try loading the bootable Windows XP SP2 and it will work just fine.

Vista Bubbles screensaver for Windows XP users

Yesterday, my friend asked me if I know a place where he could download a Bubbles screensaver that is only available on Vista OS. And I said I haven’t tried searching the net if there’s one ported for Windows XP.

But today, remembering that thought, I fire up my Firefox browser and try querying Google if there’s any. Voila! I did find some Vista screensavers that’s been ported for use in Windows XP machines.

Download Link:
http://www.softpedia.com/progDownload/Vista-Screensaver-Ported-to-XP-Download-44716.html

There you go, Bubbles for Windows XP!

Components4U .NET Components under Reflector

Disclaimer:
All the commercial programs used within this document have been used only for the purpose of demonstrating the theories and methods described. No distribution of patched applications has been done under any media or host. The applications used were most of the times already been patched, and cracked versions were available since a lot of time.

Every now and then, when I see components for .Net platform, I always try to download the Trial version and install it to study how the company implemented the Licensing of their product. Often times, you may be dismayed by how simple they implemented it and in just a matter of minutes, you already know the algorithm behind their licensing.

For this article, I will be taking .Net component products by Components4U.

Most of their .Net components are little utilities compiled into a separate DLL to stand as a component and be sold separately. I will be taking Credit Card Validator .NET Component as my target demonstration.

When you first run the application, the screen will show like this:

components4u_ccvalidator

You will notice that there’s no Nag message pop-ups on their 15-day Trial. So by adjusting our System clock manually, this will give us a throw message exception like this:

components4u_ccvalidator_expired

So, the question is, where does the application store the information for determining the number of days in my Trial period? By looking/browsing to the source code through Reflector, we will see that they are storing the information in the Windows Registry:

components4u_ccvalidator_registry

This tells us that the Time/Date data is stored on the CKV Registry entry for CCValidator component. And by looking again on the Reflector, the value of CKV is the Date and Time the component was first used.

   1: DateTime.Now.Ticks.ToString();

And the value of CKV will then test against the 15-days Trial limit. We can compute the Days remaining of CKV by:

   1: DateTime time = new DateTime(long.Parse(CKVValue));
   2:  
   3: long x = (((((DateTime.Now.Ticks - time.Ticks)/10000000)/60)/60)/24);

If the value of x is less than 15 days, the application will still run but if it reached greater than 15, the throw message exception will show signaling the component usage expiration.

With this information at hand, without much thinking, the .net component trial expiration can easily be bypassed by setting a negative value in the CKV. This is achieved by setting a DateTime greater than the Date today:

Giving a 1/1/9999 will give us

3155063616000000000 or equivalent to -2918491 Days remaining. Of course, a negative number will never reached a 15 Days Trial mark!

With this value copied to the CKV data in the Windows Registry, the CCValidator component be used until it reached 1/1/9999.

It’s very surprising to me that all their products uses the same Licensing scheme that can easily be bypassed in a minute. For me, a $120 worth of single component is not worth purchasing considering the fact that this can be done by Regular Expression alone and the security of the component is very very weak.

SQL Server Management Studio Tools Pack (SSMS Tools Pack)

If you develop most of your time using SSMS for your stored procedures, tables, etc. Try this wonderful piece of Tools pack that will spice up your daily SQL querying.

See it at SSMS Tools Pack

And if you like to create your own Addin for SSMS, read along on this good article:

The Black Art of Writing a SQL Server Management Studio 2005 Add-In

Using Reflector and Reflexil in VisualSVN 1.3.2

Disclaimer:
All the commercial programs used within this document have been used only for the purpose of demonstrating the theories and methods described. No distribution of patched applications has been done under any media or host. The applications used were most of the times already been patched, and cracked versions were available since a lot of time.

For a while, I’ve been playing with Reflector and the AddIn called Reflexil and found out that its very very easy to manipulate/change bits in the compiled binary to make it bypass security settings like the Serial number, License number requirement. Reflexil allows you to add/modify/delete bytes and save it into another file making your Reflector so powerful!

With this, I tested a .Net component called VisualSVN 1.3.2 and see if I could bypass the registration.

1. Open the VisualSVN.Core.dll into Reflector

vsvn1

2. It looks like the Licensing can be found on the selected namespace. I found out that there are 6 types of Licenses.

vsvn2 

3. I would like to test if I can get the Corporate License of this component by patching several bytes to the DLL.
4. After searching what to change, I found the IsRegistered() method that returns a boolean value. This method is under VisualSVN.Core.Protector class. By opening the Reflexil, it shows me this window:

vsvn3 
5. For this article, I just wanted the function to return true always without any validation required. What I did was removed the call to EnsureLicenseCached() and hard coded the return value to be true. We changed the OpCode ldarg,0 to ldc,i4,1 and remove lines 1 to 3. The ldc,i4, 1 operation will always return a true value. So the modified data would be:

vsvn4

6. Up to this point, we could simply save the changes to file and overwrite the original DLL:

vsvn5

7. If we try to run Visual Studio and use the VisualSVN, the patched worked as expected but wait, if we go to VisualSVN/About VisualSVN, we don’t see any indication of what type of License do we have. So we need to do another byte patching on the file. Load again the DLL to our favorite tool, Reflector and we go the the VisualSVN.Core.Licensing.LicenseInformationFormatting class and we will see that this class formats and display equivalent LicenseType based on the License information the user will give.

vsvn6

8. Since we just patched the IsRegistration() method, the only routine we will get on the Format() method is the license will always be null, thus, satisfying the first condition which result to “No license”. So what do we do? The return of this method is simple a string and no validation is being made on the return data, we could just simple changed the string “No license” into “License type: Corporate” making it look like our license is for corporate. Simple open the Reflexil and modify the text as shown below:

vsvn7

7. Save the modified DLL via Reflexil Save dialog and overwriting the original DLL. Firing up VS Studio to see if the changes we made reflected on the application. Just go to VisualSVN/About VisualSVN and it shows:

vsvn8

8. That’s it. the DLL component is now patched and ready for use without any worry of expiration.

This article showed us how .net applications can be easily decompiled using the right tools and a simple logical thinking. That’s why there are Obfuscator tools out in the market that will help companies secure their code but not 100% fool proof because there’s no such thing as 100% secure! The only good thing about obfuscating your code is prolonging the time to stay in the market uncracked/unpatched and making it harder to read by a common user. But any determined user can bypass it with the help of Reflector, Reflexil and other tools.

Design a Table in SQL Management Studio with ease

Recently, Rick Strahl blog about how we can use Database Diagram Designer as an alternative way to design our table. This is in fact, saves a lot of time as compared with the default Table Design window that SMSE offers. Read his cool article at Easier Table Design in SMSE.

I would just like to add on his cool trick the ability to just save the table and not the Diagram. We can achieve this by actually clicking the File/Save Selection menu but it will be much easier if we can just click an icon rather than going to Menu toolbar, isn’t?

Just go to Tools/Customize or just right-click the open space on the icon toolbars and click Customize. On the Categories, choose File and on the right pane, go down until you see the Save Selection command. Just drag the command beside your Save All icon and there you have it!

customize

Your toolbar will look like this:

customize2

VS2008 Color Scheme for SQL 2005 Management Studio Express

Yesterday, I have no choice but to reformat my hard disk on my laptop due to the slowness of it! I did every possible performance increase on my machine but with no luck! So I did backup all my files that resides on my drive C before I finally reformatted my Windows XP OS. Lucky for me as I have already created an image or a ghost image of my machine, loaded with all the drivers for my ASUS laptop but no installed development tools and applications.

After recovering my OS and finished installing all necessary applications needed for my work and for my pleasure, I installed Visual Studio 2008 and applied coloring scheme named VibrantInk_V2 by Rob Conery, I really, really like the color combination of this scheme and the black background color makes it easy to read codes rather than the default white color.

VibrantInk_V2

As I am happy with the look and feel of my IDE, I wonder if it’s possible to apply such color scheme to SQL Management Studio Express too. So I googled if there’s one out there that already made some schemes and found this link on how I can apply the current scheme of my IDE to SMSE. I immediately download his tool and compiled it to my VS2008. While running the console application, it gave an error message as shown below:

vscolorstosql Error

What went wrong? So I read his codes and open the registry to compare the hard-coded registry path, found out that the destination key is not existing on my Registry.

   1: private const string DST_KEY = @”Software\Microsoft\Microsoft SQL Server\90\Tools\Shell\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}”;

and so, I changed the value to:

   1: private const string DST_KEY = @”Software\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}”;

to reflect the registry path on my machine. The only difference of the two is the Shell replaced with ShellSEM.

After recompiling the console application,

ssme color scheme

Voila! It worked pretty well for me. Try it on your dev tool now!

Freeware: Taskbar Shuffle

shuffle

A friend of mine showed me his Windows Vista sitting on his laptop and showed me how he moved his open applications on the task bar by just drag-and-drop operation. I said, its cool and I ask him if it is part of WIndows Vista feature and he said No, this is a freeware utility that you can download.

So I copied the application and installed on my WIndows XP machine laptop and voila! It works like a charm!

One thing I like on this nifty application is that I can re-arrange all my opened applications on the taskbar to the way I like. I normally have Altap Salamander as my first opened application, Firefox is the second and Visual Studio as my third. So if this 3 applications were opened and for example, the Altap Salamander closed unexpectedly, I have to re-open again and this time the app will be placed to the 3rd pane. This is where the Taskbar Shuffle comes into play! Very cool and very slick freeware application. You can also re-arrange your system tray icons by just holding the CTRL key while dragging and dropping.

Did I mention that this is free? Try it out and see for yourself.

Download here

Extension Method: Truncate string

If you’re like me who don’t like to display all the contents of my item’s description (not efficient if length is more than 5000 words) in a full blast on every record that I have on my database, by having the function sitting as an extension method, I can easily call this method to truncate or limit the display of that description to a specified given length and the truncated string will then be replaced by a “…”

Here’s the code of how I create it:

   1: public static class StringEx
   2: {
   3:     /// <summary>
   4:     /// Truncates the string to a specified length and replace the truncated to a …
   5:     /// </summary>
   6:     /// <param name=”text”>string that will be truncated</param>
   7:     /// <param name=”maxLength”>total length of characters to maintain before the truncate happens</param>
   8:     /// <returns>truncated string</returns>
   9:     public static string Truncate(this string text, int maxLength)
  10:     {
  11:         // replaces the truncated string to a …
  12:         const string suffix = “…”;
  13:         string truncatedString = text;
  14:  
  15:         if (maxLength <= 0) return truncatedString;
  16:         int strLength = maxLength - suffix.Length;
  17:  
  18:         if (strLength <= 0) return truncatedString;
  19:  
  20:         if (text == null || text.Length <= maxLength) return truncatedString;
  21:  
  22:         truncatedString = text.Substring(0, strLength);
  23:         truncatedString = truncatedString.TrimEnd();
  24:         truncatedString += suffix;
  25:         return truncatedString;
  26:     }
  27: }

and applying the code above like this:

   1: string newText = “this is the palce i want to be, Cindys is the place to be!”;
   2: Console.WriteLine(“New Text: {0}”, newText.Truncate(40));

I already posted this on Extension Method site.

Extension Method: Get total Word Count of a string

Using regular expression and Extension Method in C#, code below provides a simple way to count all words to a given string excluding all whitespaces, tabs and line breaks.

   1: using System.Text.RegularExpressions;
   2:  
   3: public class MyExtension
   4: {
   5:     /// <summary>
   6:     /// Count all word occurrence
   7:     /// </summary>
   8:     /// <param name=”input”>string to begin with</param>
   9:     /// <returns>int</returns>
  10:     public static int WordCount(this string input)
  11:     {
  12:         var count = 0;
  13:         try
  14:         {
  15:             // Exclude whitespaces, Tabs and line breaks
  16:             var re = new Regex(@”[^\s]+”);
  17:             var matches = re.Matches(input);
  18:             count = matches.Count;
  19:         }
  20:         catch
  21:         {
  22:         }
  23:         return count;
  24:     }
  25: }

and we could use this code like this:

   1: string word = “the quick brown\r\nfox    jumps over the lazy \tdog.”;
   2: Console.WriteLine(“Total Words: {0}”, word.WordCount());
   3: // Output: Total Words: 9

The code is also posted in Extension Method website.

Know more about Regular Expressions.

Technorati Tags: