Wednesday, February 23, 2011

Overtaking applications

There is a nice registry hack that allows you to execute a specific application when you try to execute actually a different application. For example if you try to run notepad.exe, the calc.exe will be launched instead.

The key you create in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options must have the name of the application you want to take over. For example you can create a new key called notepad.exe and then create a new string with the name Debugger and value C:\WINDOWS\system32\calc.exe.
Now if you try to run notepad, the calculator will be launched instead. 

Thursday, February 10, 2011

Memory limitations for Delphi 7

Application developed under Delphi 7 are 32 bit, and they can only access a limited amount of RAM. 
This Microsoft document says that the limit is 2GB.
So I have made some tests and indeed I could not allocate more than 2GB of RAM. However, The document also says that 32bit applications could access up to 3GB of RAM if the following conditions are met:
  • The OS uses the /3GB switch
  • The application has the IMAGE_FILE_LARGE_ADDRESS_AWARE flag set.
Here is the official documentation for /3GB switch.
There is a possible draw back when using the /3GB flag: the OS is squeezed in to 1GB of RAM, instead of 2GB. In some situations this might not be enough. However, I thin this is unlikely. 1GB should be enough for OS.

Related article: How difficult is to write a solid software protection (licensing) scheme?