Wednesday, November 27, 2013

Using Visual SourceSafe 2005 with Visual Studio 2010, Visual Studio 2012 and Visual Studio 2013

Visual SourceSafe is out of mainstream support since 2012 and will be in Extended support until 2017. However, may people use the product past its lifetime dates, if for no other reason at least because they have programs developed originally and stored in VSS databases that will still need maintaining.
Microsoft Visual SourceSafe 2005 will still install on modern computers, and will still integrate with recent version of Visual Studio
image

Opening projects from source control

Visual SourceSafe 2005 was changed from VSS 6.0 and integrated with the File/Open Project/Solution dialog in Visual Studio. On Windows XP, Vista (and 7, I think), the Open dialog showed a dedicated ‘Visual SourceSafe’ icon in the tray, so it was intuitive to discover the Open from source control functionality. Since then, Windows changed the layout of the Open dialog, and SourceSafe option can only be found if you scroll the folders tree to the top…
Open Project from SourceSafe in VS 2005image
Even worse, the namespace extension providing integration with Explorer and the Open dialogs broke during the years. Here are the options on how to fix the Open From Source Control functionality:

A) Use SourceSafe 6.0 way of opening from source control.

When it integrated with the File/Open dialog, SourceSafe 2005 has set some registry keys that make VSS Integration package in VS hide the OpenFromSourceControl commands under File/SourceControl menu. You can modify the registry and bring back those commands:
1) Using regedit, open the registry and locate under
[HKLM\SOFTWARE\Microsoft\SourceSafe\Namespace Extension]
DisableOpenFromSourceControl == (DWord)1.

2) Change the value to (Dword)0 or delete the value completely. There will be a similar value for SourceSafe Internet provider under Microsoft\SourceSafe\RemoteAccess\Namespace Extension, change that as well
(Note: The values are under Wow6432Node hive on 64-bit machines)
image
3) Restart Visual Studio and now you should have under File/SourceControl a menu item that allows opening solution from source control.
image
4) Make sure to select a different location when opening from source control in a new enlistment (the equivalent of “Change Destination Folder” in the open functionality from the OpenProject dialog)
 image

B) Fix the namespace extension.

1) If you installed VSS 2005 RTM and try to navigate the namespace extension you will see there are no items available under SourceSafe node. Clicking on the SourceSafe icons in the tree results in an error message “No such interface supported”

imageimage
This error has been fixed in the SourceSafe 2005 Update build, so please install VS80-KB943847-X86-INTL (which you should do anyway)
2) Now you should be able to navigate the SourceSafe databases in the File/Open dialog, you should be able to select a solution or project and change the scc location, however, when you’ll try to open the solution Visual Studio will display another error message “The selected file is not a valid solution file”.
image
Why does this break? Surely you’ve selected a solution file! In order to return the path to the solution to VisualStudio, TDNamespaceExtension.dll which is the NSE deployed by SourceSafe needs to create a URI like msss://SoursafeDatabasePath/~files/PathToTheSolution (there’s more to that, but you get the idea). Unfortunately the MSSS scheme parser is a component implemented by a dll that ships with VisualStudio, so in order to create the parser TDNamespaceExtension looks up in registry under Visual Studio registry hive; as SourceSafe 2005 shipped in the box with Visual Studio 2005 (VS 8.0),  it looks under this registry key
HKLM\Software\Microsoft\VisualStudio\8.0\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}
Of course this key does not exist if you install a more recent version of Visual Studio…
For  Sourcesafe to find the correct parser, the TDNamespaceExtension.dll had to be updated to look under the right key. To make VSS work with VS2008 and VS2010 Microsoft released patches to TDNamespaceExtension (e.g. KB976375 is what you can install for VS2010). But for VS2012 and VS2013 Microsoft hasn’t released anymore such updates, probably due to SourceSafe reaching the end of mainstream support. Sad smile
If you have multiple versions of VisualStudio installed (e.g. I have VS2010, VS2012 and VS2013 installed) and have fixed VSS to work with one version of VS you won’t (I have fixed it for VS2010 installing the KB article mentions above) you see this problem in the other versions, because VSS is able to find the parser from that version of VS (from VS2010 in my case).
Anyway, it’s easy to fix the problem manually even without KB articles, by setting a registry value which tells SourceSafe where to locate the MSSS scheme parser. Besides looking under the VS 8.0 hive, TDNamespaceExtension also looks in a common place, under HKCU\Software\Classes\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}
So we can register the parser there, pointing to the current version of Visual Studio you have installed. E.g.:
- Save the content below to a file with .reg extension
- Edit the 12.0 if necessary and replace with the version of VS you have installed
- Double click the file and import it into registry.
---------------------------------------------------------------------------------
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}]
"InprocServer32"="C:\\Program Files\\Microsoft Visual Studio 12.0\\Common7\\IDE\\VS SCC\\VssProvider.dll"
"ThreadingModel"="Both"
@="VAPI Scheme Parser Msss"

---------------------------------------------------------------------------------
Now you should be able to open file from source control using the File/Open/Project without running into the “The selected file is not a valid solution file” error.

Note: The above file worked for me on a 32-bit machine. On my 64-bit machine, I have the VAPI parser registered under multiple locations (I think the last one is written by VS setup and gets copied into 12.0_Config hive on first run); it won't hurt to register it similarly though.

---------------------------------------------------------------------------------
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}]
@="VAPI Scheme Parser Msss"

[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}\InprocServer32]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\VS SCC\\VssProvider.dll"
"ThreadingModel"="Both"

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}]
@="VAPI Scheme Parser Msss"

[HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}\InprocServer32]
@="c:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\VS SCC\\VssProvider.dll"
"ThreadingModel"="Both"

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}]
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\VS SCC\\VssProvider.dll"
"ThreadingModel"="Both"
@="VAPI Scheme Parser Msss"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\CLSID\{53544C4D-CFBF-404e-9E37-19C8BB80F6E3}]
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\VS SCC\\VssProvider.dll"
"ThreadingModel"="Both"
@="VAPI Scheme Parser Msss"
---------------------------------------------------------------------------------

Pwned


Today I had my system infected with a trojan. I don’t even remember when it was the last time to have one… The worst part of it – I didn’t get it by visiting dubious sites (pr0n, warez), but from a news site (http://news.com). Most likely the malware was masquerading as an ad and exploited some unpatched hole in Adobe Flash (caveat!) as the site is full of Flash advertisements and had problems in the past, too.
I was browsing the news and suddenly the browser disappeared (crashed). I restarted it thanking Adobe and thinking nothing more of it. Soon after that, problems appeared.
The first red flag was an elevated prompt from Windows 7, asking for permission to run ‘SoftwareUpdate.exe’. Since I was not installing anything, I canceled it. Yet the prompt came again, and again, and again. From the dialog’s details, the program was "c:\Users\alinc\AppData\Local\temp\SoftwareUpdates.exe", so I renamed the executable to *.exe_ extension, and canceled the prompt again. This time I got error messages that updates can’t be installed, so I set up to investigate who was displaying it. To my surprise, I could not launch TaskManger (taskmgr.exe) nor SysInternal’s ProcessExplorer (procexp.exe). As soon as the programs were started, they were closed automatically... It was clear now I was infected.
I logged off, and switched users, logging in with a different local Administrator account. Problems occurred here as well, I still could not launch ProcExp. Soon I started to get tons of error messages “A Write command during the test failed to complete”, culminating with a “System error, hard disk failure detected”. All the icons on desktop disappeared leaving only one “Smart_Hdd” shortcut.
Screenshot2
I opened a command prompt and stated to see problem here as well - folders and files disappeared from ‘dir’ commands. I renamed procexp.exe to something else (alin.exe) and this way I was able to launch it without being closed anymore. You can see in one look Process Explorer highlighted in gray 2 suspect programs (C:\ProgramData\rmIhrYfwFjUdy.exe and C:\ProgramData\QFUDzzwTiL1aQy.exe): they had weird names, were launched from ProgramData, had no Description or CompanyName.
screenshot1
Even more worrying, rmIhrYfwFjUdy.exe had launched a recursive “attrib.exe /s +h \*.*” (not shown, I killed it immediately)– this was hiding all the files and folders on my computer! I believe all these was a scamming scheme to convince me into buying some “cleanup program” that would fix the “hard drive failures” “detected” and reported in the previous messages.
I tried to stop/kill the malicious programs by pressing Delete, but those were protecting each other – as soon as one was killed, the other one was immediately starting it up again. The solution is to right click them, and use “Suspend” command. Suspend both, then you’ll be able to kill them without coming back. Now I could move the binaries out of the way for my collection and investigate further.
I run another Sysinternal/Microsoft tool, Autoruns. This indicated rmIhrYfwFjUdy.exe was launched at logon time via a registry value written under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. I deleted that as well.
I updated Microsoft Security Essentials to the latest definitions, and I started a scan. With latest definitions, it flagged as malware two of the binaries. QFUDzzwTiL1aQy was recognized as Win32/Bumat!rts, and SoftwareUpdate was recognized as Win32/Tibs!IT. The 3rd program was not recognized, so I used the Microsoft’s Virus Submission Sample Page to submit rmIhrYfwFjUdy.exe for further analysis. 
The trojan left more traces on my computer:
- The "Smart HDD" shortcut on desktop pointing to QFUDzzwTiL1aQy.
- A “Smart HDD” program group with 2 entries, one masquerading as an “Uninstall” program, but pointing to the same malware.
- Most folders and files were hidden. I had to run recursive ‘attrib –h’ of my own to reset attributes.
- The StartMenu and Taskbar settings were all changed. All the icons in start menus were hidden, the taskbar was set with Vista-like settings (program buttons with texts, no grouping, system tray showing all icons, etc). I had to go to Properties and explicitly set or reset all to defaults.
Startmenu
- All icons under “Administrative Tools” were deleted. In fact, the whole “C:\ProgramData\Microsoft\Windows\Start Menu” folder was cleaned of all files.
AdminTools
- The “C:\Users\All Users” folder is also gone. There may be other effects I haven’t found yet…
Basically I’ve lost all the shortcuts/icons of all installed programs, but I’m still pleased I caught it in time before it caused more damage - the situation could have been much worse…
In any case, this was one more win for Sysinternals tools.

Sunday, November 24, 2013

Using color themes with Visual Studio 2013 Express Editions

Microsoft has recently released Visual Studio 2013 and Matthew Johnson has released a new version of the Visual Studio 2013 Color Theme Editor. Unfortunately it doesn’t support (yet?) the Express editions of VS2013.
My previous article about using color themes with Visual Studio 2012 seemed to have been quite popular, it’s the most accessed article on my blog...  Therefore, to continue the tradition, here is how to install the new theme colors available with Matt’s extension to work with the Visual Studio 2013 Express.
1) First, download the zip file http://www.alinconstantin.net/download/VS2013Themes.zip – it contains the 8 pkgdef files defining the colors of the 8 new themes from Matt’s extension, plus the 9th pkgdef with the theme names.
Note: If you get errors when you try downloading the file, rest assured the file is still there on my home server. It’s likely a temporary problem with my Internet connection or the DNS servers, so try again later. (I’d also appreciate a warning mail if I don’t notice the problem myself and it doesn’t get resolved in 1 day)
2) Create a folder (say named “Themes”) and unpack the zip file in that folder. The location of the folder depends on the Express edition you’re using. E.g. create the folder under this path:
Express for Windows Desktop %ProgramFiles%\Microsoft Visual Studio 12.0\Common7\IDE\WDExpressExtensions
Express for Windows %ProgramFiles%\Microsoft Visual Studio 12.0\Common7\IDE\VSWinExpressExtensions
Express for Web %ProgramFiles%\Microsoft Visual Studio 12.0\Common7\IDE\VWDExpressExtensions

Note: If running on a 64-bit machine, instead of %ProgramFiles% use %ProgramFiles(x86)% because Visual Studio is a 32-bit process.
Note 2: Visual Studio Express for Windows Phone was not released for 2013. If you need to colorize Express for Windows Phone 2012, see the Using color themes with Visual Studio 2012 Express Editions article.
image
3) Open a “Developer Command Prompt for VS2013”. When using Windows 8, search for “Visual Studio tools” and open the folder found. Visual Studio 2013 no longer installs the tools shortcuts directly in the Start Menu to avoid polluting the menu with 9+ rarely used shortcuts.
imageimage
Anyway, once there type the command forcing VS Express to re-read the extensions settings.
image
Again, that depends on the version of Express used:
Express for Windows Desktop wdexpress.exe /updateconfiguration
Express for Windows vswinexpress.exe /updateconfiguration
Express for Web vwdexpress.exe /updateconfiguration

4) Start VS Express  and the themes should now be available in Tools/Options/Environment/General page.
image
Should someone with a VS Professional/Ultimate install use Matt’s extension to create/edit a custom theme that you want to use on Express, that’s also possible. You will need a pkgdef file with the new theme, which you can get in two ways:
  • On the machine with the VS install look under ‘%LocalAppData%\Microsoft\VisualStudio\12.0\Extensions’ folder. There should be some subfolders with random names, and one of them will contain a Colors.pkgdef file containing the theme of interest (open it with notepad and you should see in the beginning the theme’s name to confirm). Copy that file in the Themes folder created in step 2) above, rename it to give it a more appropriate name
  • Or, you can open the theme of interest in editor, and use the Export Theme button in the window's toolbar:
     
    In the FileSave dialog, make sure to set the file type to .PkgDef (by default the extension saves the file as .VsTheme), like this: After exporting the file, copy it in the Themes folder created in step 2) above in your VS Express installation.
Now you can repeat steps 3-4) above to force VS Express read the new extension pkgdef file, and you should be able to use the new custom theme in Tools/Options dialog.