Jim Lawless' Blog


A Lightweight Alternative to Windows Shortcuts

Originally published on: Fri, 07 Aug 2009 00:35:49 +0000

Some time ago, I needed to provide a desktop shortcut for an application. Rather than using the normal shell API's to create a shortcut on the Windows desktop, I wondered if I could make an EXE tiny enough so that it was almost the same size as a typical shortcut.

I used this pet project as an excuse to learn a little about the Netwide Assembler (NASM32). I opted to use some of the Visual C++ 5.0 runtime libraries and linker, so my NASM code probably looks different than most you'll see elsewhere.

I wrote a small program that simply calls WinExec passing in "notepad.exe" as the argument.

The resulting EXE is about 2K in size ... bigger than most of my shortcuts, but a worthwhile effort. I had rewritten this so that it would work properly with a separate linker and had gotten the EXE down to a very tiny size. Unfortunately, I no longer have that source.


; A Lightweight Alternative to Windows Shortcuts
;
; License: MIT / X11
; Copyright (c) 2009 by James K. Lawless
; jimbo@radiks.net http://www.radiks.net/~jimbo
; http://www.mailsend-online.com
;
; Permission is hereby granted, free of charge, to any person
; obtaining a copy of this software and associated documentation
; files (the "Software"), to deal in the Software without
; restriction, including without limitation the rights to use,
; copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the
; Software is furnished to do so, subject to the following
; conditions:
;
; The above copyright notice and this permission notice shall be
; included in all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
; OTHER DEALINGS IN THE SOFTWARE.
;
   extern _WinExec@8
   global _main
   global _mainCRTStartup
   SECTION .text
_mainCRTStartup:
   push dword 1
   push dword child
   call _WinExec@8
   ret
_main:
   ret

   SECTION .data
child: db "notepad.exe",0

To assemble and link this program, I used the following batch file:


nasm -l %1.lst -f win32 %1.asm
link %1 /defaultlib:kernel32.lib

Unless otherwise noted, all code and text entries are Copyright ©2009 by James K. Lawless

del_icio_us Save to del.icio.us
stumbleupon Save to StumbleUpon
digg Digg it
reddit Save to Reddit
facebook Share on Facebook
twitter Share on Twitter
aolfav More bookmarks



Previous post: BSave and BLoad for the Commodore 64
Next post:Embedding JavaScript in a Batch File


Search this Blog (and site)

Search this Site with PicoSearch


Subscribe to this Blog

 Subscribe!


Contact Me

Email: jimbo@radiks.net


Follow me on Twitter

http://twitter.com/lawlessGuy


Recent Posts

Mad Schemes : Learning Lisp via SICP

Auto Save Clipboard Images Redux

Extending SpiderMonkey JavaScript on Windows

Rhino JavaScript to EXE with launch4j

Compiling Rhino JavaScript to Java

Directory Traversal in Rhino JavaScript

Taking Shape

We've Moved!


Popular Posts

A Command-Line MP3 Player for Windows

Auto Save Images from the Clipboard

Java in a Windows EXE with launch4j

An Interview with Tom Zimmer: Forth System Developer

Setting Windows Console Text Colors in C


Random Posts

Obfuscated Perl

An Embedded Mini-Interpreter

Screen Captures with Java and Clojure

Envy

Site Tracking with Perl

BSave and BLoad for the Commodore 64

Structuring my Thinking

Auto Save Clipboard Images Redux

A Simple Media Control Interface Script Processor

Book Review : Using Google App Engine


Full List of Posts

http://www.mailsend-online.com/bloglist.htm


Blogroll

MicroISV on a Shoestring
DadHacker
The Bottom Feeder
Writin' That Code!
The Recursive ISV
The Thomsen Blog
Prototypically Speaking
The Reinvigorated Programmer