Lo and behold <drum roll> – the Geek is back! And this time, he’s bigger than ever.
<Reader screams go here>
Welcome back! Okay, so you might be thinking – "Huh? I thought the ‘trilogy’ was over!"
Well, erm, yes, it was, but we decided to step into George Lucas’ shoes and release StarWars Episode I. Yet rather than going back to the future, we’re gonna go further. See, we’re better than Lucas 😉
<Ed: Sorry, readers, Dax has become a real ol’ freak. We’re gonna work on that – slap!
Erm…huhwhat? Oh yeah! And besides, we wanna end this year with a big bang!!
So, what are we gonna get up to this time? How about increased integrated security in your setup and application, creating shortcuts anywhere, bill boarding everywhere, nag ads, creating background-free setups, a look at the Pandhi setup-background gallery, internationalization and lots more!
So without further ado (and I don’t mean ActiveX Data Objects 😉 let’s step on it
Y’know, today’s crackers tend to find our ‘security file’ no matter what we name it and where we place it. So I did a little digging myself and found some ‘tips’ to give us a slightly better chance at it…
Question: How do they find the file, no matter where we keep it, and whatever we name it?
Answer: Simple. They use a file monitoring / registry monitoring utility such as RegMon or FileMon, which use APIs to see which file is being written or read from. The same for registry entries.
Question: How come they cracked my EXE even if it was made using a ‘packer’?
Answer: Okay, now get one thing straight, for every good guy there is a bad guy, for every Karl Moore there is a Dax Pandhi, and for every packer is an unpacker!! The same is for security software, even the famous ActiveLock OCX can be (and has been) cracked.
Note: For those who don’t know, a Packer is a software that can encode and put your EXE/DLL into a ‘protective box’, or in other words, it gives your software super encrypted protection. An Unpacker can undo what the packer does. For each packer there is a different unpacker and all rely on different methods.
Question: Does this mean that we lost the war?
Answer: No! Of course not, you still have your secret weapon me!! (Okay stop laughing!)
Seriously, you need just three things to go against piracy better than the rest: Visual Basic 6, this article and just a wee bit of imagination (yes, that thing with which you could picture me as a dude with a 3ft. beard and a pair of rose-colored glasses).
Here’s a small overview of how the cracker tracks your information reading and writing.
Top Tip: Yet again, crackers might be reading this very article, so use your imagination and twist the code all round and round. If you don’t know how, just grab a pack o’ good ol’ imagination.
Encoding is not enough, so let’s look at what we could do to combat the problem:
- Create an ActiveX DLL Project.
- In Class1 (by default) there is nothing, so code the following in it:
Option ExplicitPublic Declare Function GetWindowsDirectory& Lib _"kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer _As String, ByVal nSize As Long)Private Declare Function WritePrivateProfileString& _Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal _lpApplicationName As String, ByVal lpKeyName As Any, ByVal _lpString As Any, ByVal lpFileName As String)Public Function WindowsDir() Dim strBuffer As String * 260 Dim intX As Integer GetWindowsDirectory strBuffer, 260 WindowsDir = Left(strBuffer, InStr(strBuffer, Chr(0)) - 1) If Right$(WindowsDir,1) <> "" Then _ WindowsDir = WindowsDir & ""End FunctionPublic Sub SetKeyString(strFile As String, strSection _ As String, strKey As String, strData As String) WritePrivateProfileString strSection, strKey, strData, strFileEnd SubPublic Function XOREncode(strKey As String, strInPath _As String) As String Dim strInput As String Dim strOutput As String Dim dblX As Double Open strInPath For Binary As #1 strInput = Input(LOF(1), 1) Close #1 For dblX = 1 To Len(strInput) strKey = strKey & strKey If Len(strKey) >= Len(strInput) Then dblX = Len(strInput) End If Next dblX For dblX = 1 To Len(strInput) strOutput = strOutput & Chr(Asc(Mid(strInput, dblX, 1)) _Xor Asc(Mid(strKey, dblX, 1))) Next dblXXOREncode = strOutputEnd FunctionPublic Function SecureData(strData As String)Dim sWD0 As String' Dummy Store FileDim sWD1 As String' Dummy Store FileDim sWD2 As String' Dummy Store FileDim sWD3 As String' Dummy Store FileDim sReal As String' Real Store FileDim sTemp As String SWD0 = WindowsDir & "data1.dat"SWD1 = WindowsDir & "data2.dat"SWD2 = WindowsDir & "data3.dat"SWD3 = WindowsDir & "data4.dat"SReal = WindowsDir & "gr386.vxd" ' gr386.vxd looks like a system file, so it MAY ' Throw our tracker off course a bitSTemp = XOREncode "MyKey12345", strDataSetKeyString SWD0, "Security", "Code", STempSTemp = XOREncode "MyKey67890", strDataSetKeyString SWD1, "Security", "Code", STemp' Write the real data in between the dummies to confuse the trackerSTemp = XOREncode "MyKey12345", strDataSetKeyString SReal, "Security", "Code", STempSTemp = XOREncode "MyKeyABCDE", strDataSetKeyString SWD2, "Security", "Code", STempSTemp = XOREncode "MyKeyFGHIJ", strDataSetKeyString SWD3, "Security", "Code", STemp' Now let's throw our tracker off-course!! ;>MoveFile swd1, swd2MoveFile SWD3, SWD4 ' By Now his screen must be filled with 2000 tracks' Use other encoding functions you may have here to encode SRealEnd Function
- Compile the DLL (compile to P-Code for best result) and bootstrap it (see parts 2 & 3)
- In setup1.vbp, open Project | References
- In the dialog that opens up, click browse and open the new DLL.
- Now, click OK and it is registered AND referenced into your project.
- Now, wherever you want to write the data out, use the SecureData function
Now, in your app (not setup1.vbp but the app you’re using setup1.vbp for) use the XOREncode function in conjunction with the INI Class (look around VB-World.net for that one ;).
As the INI Class reads the data within gr386.vxd, XOREncode it and voila you have your lil’ serial number!!
This way, you can create a cool 2-way security store that can be accessed and modified by both the setup application and your software.
Top Tip: For showing the registration info in the about box, extract the info from the store and save it temporarily in a registry key. Don’t delete the registry key, just keep it it will be another breadcrumb in the wrong direction to throw the hackers off trail (If you don’t follow me, read Hansel & Gretel)
Everything is "web-integrated" these days. Browsers (of course), desktops, MP3 players, word processors, why, even my toaster’s web ready it actually chats to me via ToastMessenger!
There it goes againNo, Toasty, I don’t want any toast right now tsk, see what I mean? Anyway, what I mean is, sometimes it is nice to see a web page in your setups, right?
NOTE: This means that your user MUST have Internet Explorer 4.01 or later, otherwise its crash time!
Press Ctrl+T and in the components dialog, add the Microsoft Internet Controls . Let’s suppose you have a purpose for showing a web page (its nice to have a purpose) say, you want your user to read the latest FAQ or readme information. That latest info is stored at http://www.website.com/myfiles/faq.htm – so remember it when we need to write this URL J
Open the readme form (What? You didn’t make one? Go to Part 1). Now, in the form, remove the text box and stuff and create a web browser object from the new components we added. Rename it to wb1 (the default, webbrowser1, is a loooong name). In the readme form’s Form_Load () event, type in the following code:
Just in case your user doesn’t have a net connection or is not connected at the time, that dreary PAGE NOT FOUND error will come up. To prevent it, change the above code in Form_Load () to the following. Also, bootstrap your HTML file (readme/faq) to the Windows directory, see part 2/part 3.
Dim iGo As StringIGo = MsgBox("Would you like to get the latest readme information and " & _"FAQs from the internet (Net Connection required). If so, connect to " & _"the net and click Yes, otherwise click No to read the current " & _"information within the setup.", _vbQuestion + vbYesNo, "Get Latest Info")' Let's see what the idiot (user) says...If iGo = vbYes Then Wb1.Navigate2 "http://www.website.com/myfiles/faq.htm"Else Wb1.navigate2 WindowsDir & "myfaq.htm"End If
There, a little bit of web savvy in your setup!
Author’s Personal Note: Hi, erm, if you have a net connection please e-mail the police! The Developer.com Technocrats have enslaved me and are making me write articles!! Thanks! I gotta go, I hear General Moore approaching!!
Before you say anything, I dunno, it sounded cool, that’s all no other reason for the cheesy title. Basically, what we have here are a bunch of highly significant tips from our dear readers, along with a bunch of important FAQs. Here goes nothing!
Q: How Do I Create Custom Uninstallation Utility for setup1.vbp?
A: Wellermyou don’t! The Geek Gods of Microsoft did not give us that customizability. L Though, if someone does know how, please mail me! J
Q: How Can I Show a "Percentage" text label in the file copy dialog?
A: Oh dear, another disappointment for you guys, sorry, you can’t. Microsoft made the progress bar not from ComCtl or some other OCX but from a damn PictureBox , so I think you can pretty much guess why we can’t show a % label.
Q: I Need To Store Some BMPs/JPGs for backgrounds, but I don’t want to bootstrap them.
A: If you don’t want to bootstrap, the best option is to use resource files (see Part 3) and try to keep them under 64kb .
Q: Can I change the progress bar in the file copy dialog?
A: Oh dear, don’t EVER do that! I tried to do it and I ended up writing and modifying about 400 lines of code! When setup1.vbp was made (originally at Microsoft) those naughty weenies still hadn’t figured the meaning of full customizability…
Q: How can I create start menu type links or icons on the desktop or other places?
A: Okay, about 80 people mailed me on this, I know I told them to wait for the next part, so here’s my answer:
You already have the solution sitting in basSetup1.bas!
Now, I’ll answer your question, but only if your promise to explore the wonders of setup1.vbp because there are a LOT of them that even I haven’t yet touched!
Here’s the function you’ll need to create shell links or start menu icons for your non-geeks. Please note you will have to modify this function a bit to throw icons off the start menu and onto the desktop or so. But I won’t go into that, as it’ll be a good exercise for you:
'-----------------------------------------------------------' SUB: CreateShellLink'' Creates (or replaces) a link in either Start>Programs or' any of its immediate subfolders in the Windows 95 shell.'' IN: [strLinkPath] - full path to the target of the link' Ex: 'c:Program FilesMy ApplicationMyApp.exe"' [strLinkArguments] - command-line arguments for the link' Ex: '-f -c "c:Program FilesMy ApplicationMyApp.dat" -q'' [strLinkName] - text caption for the link' [fLog] - Whether or not to write to the logfile (default' is true if missing)'' OUT:' The link will be created in the folder strGroupName'-----------------------------------------------------------'Public Sub CreateShellLink(ByVal strLinkPath As String, _ByVal strGroupName As String, ByVal strLinkArguments As _String, ByVal strLinkName As String, ByVal fPrivate As _Boolean, sParent As String, Optional ByVal fLog As _Boolean = True)
Please note that you don’t have to copy this code anywhere, it already exists in the bassetup1.bas module. If you do modify it, copy the entire function and paste it at the bottom of the module, and rename it to something else because setup1.vbp initially needs CreateShellLink for use in the setup.
Also, I DO NOT mean to discourage you by not giving you the entire cut-n-paste code. But c’mon – you’re red-blooded Visual Basic programmers – get off you butt (or on your butt) and find out how, search the ‘names’ in modShell.bas, read the entire code of CreateShellLink in basSetup1.vbp go, you can do it! And with all this encouragement, even Elvis would give it a go (uh-huh-huh).
"C’mon, kids, wash our hands before dinner" Nag Screens!
I love nag ads and nag screens in "unregistered" software especially the ones I create myself!
It’s like in the soft shiny-shoe life of Cherry Blossom – the shoe-brush is suddenly broken, isn’t it?
Or maybe like on a 8-lane highway without any cars your tires burst into a flat! It is a important to have nag screens especially in freeware to make those user see that you a great human before letting them use your hard-work! 😉
Here’s an example of what a nag screen in a setup program should look like:
Some Nag Tips
Make the nag form stay on top and create a timed progress bar with the following code, then the user will HAVE to read what you say until the time runs out:
Private Sub Timer1_Timer()Progress1.Value = Progress1.Value + 1If Progress1.Value = 100 Then Unload Me FrmMyForm.ShowEnd IfEnd Sub
Then, set the Timer Interval property to 100. Optionally, you can set the progress bar’s Visible property to False to irritate the user 😉
What is the one thing that makes a setup look cool? Billboards!
But the damn progress bar in file copy is a picture box so we can’t get the percentage which is needed to change the billboard images… so what do we do?
We create ‘timed’ billboards! Remember that image box control we made in Part 2? We will use it to show these billboards. I don’t remember that image control’s name (oops) so we’ll call it imgBill (do not add ‘Gates’ as a suffix).
Then, we create a few BMP files (for this, we use 3 files) and keep them under 64kb. Now we load these images in a resource file (see part 3 for details).
Now, here’s what to do:
- First run your installation and get the average time that it takes to copy the files. Try running it on a P-II 300 based system, then on a P-MMX 166 based system, from both the times, create an average time (approximate value will do)
- Assuming it takes 20 seconds for the installation at average, that is what we will do to the timer give it 20 seconds to display multiple billboards.
- Create Timer1 on frmCopy.frm and set its Timer property to 1000 (1 second)
- In frmCopy declarations section, add the following line:
Public intBill As Integer
- Now add the following code in Timer1_Timer() event:
Private Sub Timer1_Timer()IntBill = IntBill + 1If IntBill = 6 Then imgBill.Picture = _LoadResPicture("Bill2", vbResBitmap)' In the above we load Bill2 instead of Bill1 as Bill1' Will be loaded in Form_Load()if intBill = 12 Then imgBill.Picture = _LoadResPicture("Bill3", vbResBitmap)End SubPrivate Sub Form_Load()imgBill.Picture = LoadResPicture("Bill1", vbResBitmap)End Sub
That was easy, we’re finished with bill boarding!!
From the feedback I received, I have a feeling that a lot of you guys are stuck with the thought "D’oh, even if we customize setup1.vbp, how far can we go?"
Of course, I’m also pleased to announced that the majority of you guys knew what to do. Thanks to all you folks, innumerable to mention here, who have sent me their copy of setup1.exe! Though next time, please send me setup1.vbp and its files instead of setup1.exe J
But there still are people who are D’oh-ing as to where to go and how, so it’s time to present the great, the one, the only Geekular Setup Gallery!!! <drum-roll>
The below images are snapshots from setup programs I created for a commercial product of mine and should give you an idea as to what’s possible with Visual Basic.
A cool mixture of blue and black. Note I used image boxes as buttons and used labels with MousePointer set to Custom and an icon as the MouseIcon. The labels acted as buttons and the images acted as the dummy-look of the buttons.
Desert sun with normal buttons, with Style set to Graphical and color set to match the background. This setup was originally created without that blue wash background just like all the others here.
This is one setup for which I barely made it through alive while selecting the perfect color for the labels and command buttons!!
Specially made for attorney software or word processors. Doesn’t it look cool?
Inspired by that movie StarGate both look, feel and name! Note the command buttons are replaced with labels with dark background colors and light foreground colors. The colors range from white to black and all others are in between. Colors are very important and should be always placed nicely.
A Standard Windows like setup with familiar look and feel. The UI looks like a completely Win2k-based setup.
Images & Names Copyright © 1999-2000 Extreme TechnoVision/Trademarks of Extreme TechnoVision
I hope you’re up to your neck in inspiration, you will create cool stuff.
For those interested, all the above were created with VB6 Enterprise, Bryce 4, 3D Studio MAX 3 and Corel Photo-Paint 9, but you can find lots of free graphics software on the Net if your budget is low 😉
<Dax gets up with 3 tweety birds flying around his head>
Now that’s what I call a good ride, eh? We finally have shortcuts here and there, more security-conscious setups and apps, timer-based billboards, plus we even browsed a setup gallery.
Just like this fourth edition of Customizing Your Setup, there could be a fifth. Now, my brain is conked out of ideas for part 5 but if you want it, you’ll have to tell me what you want! Get on your mail client and send me a message at firstname.lastname@example.org (yes, my new address!). After all, this is YOUR series.
So if you want anything, YOU have to ask for it, and then and only then will you get it. Good news by the way, General Moore has let me out on bail and I’m going off frolicking on some Web sites – so till next time, this is the Hyper-Idiotic-Cronologically-Impossible-Unearthly-Nuclear-atomic-cosmic-neutronic-buffoon saying goodnight!
– Dax Pandhi