Gary Davis' Blog

DotNET/PayPal Development and other Techie Stuff
posts - 42, comments - 10, trackbacks - 0

Tuesday, January 15, 2013

How I Lost My Windows 7 Firewall Rules

I run a Windows 7 Web Server on a Media PC (see here) as my home server and from work, I connected to it using Remote Desktop. I ran Windows Update and part way through the 19 updates, the Remote Desktop connection froze. I figured the updates needed a reboot and but the server never came back up. I’d have to wait till I got home to figure out what happened.Updates1

When I got home, the server was pretty much how I left it from work. It had completed the updates and was just ready to reboot. The problem was that I could not connect to the server remotely. Outgoing connections were working fine (web pages, etc.). It turned out that the Firewall was blocking everything. I disabled the firewall and was then able to connect to the server (web pages, Remote Desktop, SQL Server).

I went into the Windows Firewall advanced settings and all inbound and outbound rules were missing!

First I ran MalwareBytes Anti-Malware and it showed no viruses or threats. Next I went to restore back to before the updates but my System Restore was not turned on! I do run Windows Backup and the last backup of the system image was a few days earlier. I could get my firewall rules from the SYSTEM registry on that backup.

FirewallRegThe backup creates a VHD virtual drive for the system and the program files. I mounted the system VHD as a drive and located the registry (\windows\system32\config\SYSTEM). I ran regedit and attached the SYSTEM registry file hive to get to the registry settings for the firewall. I located the firewall settings at this location HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess. I attached the backup hive to HKEY_LOCAL_MACHINE\SYSTEMBackup (focus on HKEY_LOCAL_MACHINE then File->Load Hive). I drilled down to SharedAccess on the SYSTEMBackup (see image).

Comparing this structure on SYSTEMBackup to SYSTEM, I noticed that on SYSTEM the entire Defaults key was missing and the Parameters\FirewallPolicy\FirewallRules key was there but there were no rules within it. The Default is probably not required but is the firewall reset info if needed.

I exported the SYSTEMBackup keys to a .reg file. I edited the file to change the location of the keys from SYSTEMBackup to SYSTEM. I then saved the file back (save as ANSI, not unicode). I then right-clicked the file and selected Merge to restore my firewall rules. NOTE: This is potentially very dangerous since you are modifying the registry!

Going back into the Windows Firewall advanced settings showed my inbound and outbound rules in place.

The rules seem to need a bit more tweaking since my HTTP ports are still blocked.

A good place to test out your firewall is at www.grc.com – navigate to the Shields Up page to verify your ports are blocked as expected. Note that your router may be doing most of the port blocking for you.

posted @ Tuesday, January 15, 2013 8:50 PM | Feedback (0) |

Thursday, January 10, 2013

How I Ported a Windows Phone 7 App to WP8

I completed the porting of my Tivo Net Remote app last week from WP7 to WP8 using some ideas from the Nokia Porting Guide. It was published yesterday.

I opened the source code solution using the new SDK and verified it compiled. There were minor changes I wanted to get in. One was to remove the Performance Progress Bar from the toolkit and use the native Progress Bar which was fixed to be like the toolkit version.

I then created a new project in the solution for the WP8 version. I used the copy-as-link on all the source files, though I did compare the differences in the App.xaml to manually migrate some of the lines of code in the .cs. There were a few files, I think tile images, that did not work with the link technique so I copied the files to the new project. The problem seemed to be in the packaging of the xap – the files just were not copied when they were links or something.

The App communicates with the TiVo using sockets and the WP8 has a really nice StreamSocket class I was able to use cutting down the comm code quite a bit for the WP8 version.

To submit the update, both xap files (WP7 and WP8) were uploaded to the Microsoft store. The re-certification process took four or five days.

I uninstalled my test version from my WP8 and searched the store for the new one and found it. The entry showed the Try and Buy buttons though I had purchased the WP7 version long ago. I clicked the Try to install it and it ran in trial mode. This did not make sense that I would have to buy it again.PortArticleImg1

I went to www.WindowsPhone.com to see my purchase history and saw two entries for TivoNetRemote – one to Purchase/Reinstall and the other to simply Reinstall.

I uninstalled the app from the phone and clicked the web page link to reinstall (both entries have the same link/appid). The reinstall did wind up installing the full version so I did not have to re-purchase it. The appid is unchanged from the original.

PortArticleLogWhen someone runs the app, it sends a message to a web service to log some info (max of once per day) and get the app settings.             

posted @ Thursday, January 10, 2013 4:14 PM | Feedback (1) | Filed Under [ Programming WP7 WP8 ]

Saturday, June 2, 2012

The Big Brothers Big Sisters Little Moments App for the Windows Phone 7

The Big Brothers Big Sisters app for the WP7 was created by a team of developers as part of the local Give Camp project. I programmed the screens and web service calls; Robert Hellestrae did the initial foundation; Dave Norderer did the shaker and spinner coding as well as some of the REST data services. Several others were involved with the BBBS Little Moments web site and administration site and project management. Our Big Brothers Big Sisters contact was Kara Justi from the Palm Beach and Marin Counties agency.

BBBS WP7 App

The WP7 version of the Big Brothers Big Sisters Little Moments app was the first to market. The Android version is coming and as far as I know, the iPhone version has no programmers or developers at this time. There is also a website version under development (including an administration section for adding/updating data) and has a REST web service for data (BBBS agencies, activities, etc).

Click on the image to bring up the app details page.BBBS WP7 App

Get involved with Big Brothers Big Sisters and use this app to find activities available within your selected price range, distance, age-group and activity type for your selected local BBBS agency.. Activity providers have made special arrangements with your agency.

You can shake your phone go get the unlocked spinners rolling and see if the result finds an activity you and your "little" would enjoy. A locked spinner can be either selected (meaning selected must match) or unselected (meaning any will match).

Click the search button to see the list ot matches and then click on a match to find out the details of the activity. You can even get directions from your location to the activity.

 

posted @ Saturday, June 2, 2012 5:04 PM | Feedback (0) | Filed Under [ WP7 ]

Friday, June 1, 2012

How to Upgrade Windows 8 Consumer Preview VHD Boot to Release Preview

I already went through the procedure to create a Virtual Hard Drive (VHD) with Win8 Consumer Preview as described in the HowToGeek.com article and wanted to replace the VHD contents with the new Release Preview that came out yesterday. If you have the same situation, this will save you several steps.

If you try to upgrade your Consumer Preview, it will tell you that it is not possible since it is on a VHD. Maybe someone will figure out a workaround so your installed programs are not lost. So I figured for now, I'd just blow away the Consumer Preview and use the same VHD to hold the Release Preview.

The steps you save are creating the VHD and adding it to the boot menu. What you want to do are these steps:

  1. Download the ISO for the RP (from here)
  2. Mount the ISO as a drive (I used this)
  3. Attach the old VHD as a drive letter (Computer Mgt->Disk Mgt->Action->Attach VHD)
  4. Format the VHD drive to blow away the old Win8 CP
  5. Start PowerShell in Administrator mode to run the Install-WindowsImage.ps1 script (from here)
  6. Run Install-WindowsImage as shown below
  7. Assuming your boot menu Win8 entry is still in place, reboot into your new Win8 RP.

To run Install-WindowsImage enter this at the PowerShell prompt. This assumes you have CD'd into the folder with the script:

PS> .\Install-WindowsImage.ps1 –WIM J:\Sources\Install.wim –Apply –Index 1 –Destination I:\


Also, it assumes J: is the mounted ISO and I: is the attached VHD. The script will make the VHD bootable and copy the necessary folders and files from the ISO to the VHD. If you need to add a new boot menu item type bcdboot.exe I:\Windows where I: is your VHD. 

PowerShell running Install-WindowsImage

The Install-WindowsImage took about 4 minutes where the ISO and VHD where on an SSD and 32 minutes when both were on the same hard drive partition.

To reuse the same boot menu, the VHD file name and location need to be the same (use command line bcdedit with no parameters to display the boot menu details).
 
At this point, the VHD has an installed version of Windows 8 Release Preview that can be booted. The initial boot will go through some configuration and setup and you're done. The product key is: DNJXJ-7XBW8-2378T-X22TX-BKG7J or TK8TP-9JN6P-7X7WW-RFFTV-B7QPF .

The howtogeek.com article above has all the details, screenshots and more if you need additional information about this procedure.

Once running, you can install Windows Media Center using the info at this blog.

posted @ Friday, June 1, 2012 1:28 PM | Feedback (1) |

Friday, May 4, 2012

How to recover space from your Android-imaged SDCard

When using a (Micro)SDCard created in Windows for an Android boot, partitions are written to it in a Linux format that Windows does not completely understand.

I did this when rooting my NookColor with CyanogenMod 7. My 8GB card was imaged using the Win32DiskImager tool that takes an IMG file and writes it to the card, laying down various partitions, including one standard Windows partition of about 130MB. This basically hides the remainder of the card from Windows but boots up my NookColor into Andriod just fine.

Well, eventually, you need to recover the card to use in Windows again. You can't use the Windows format command since that will only empty out the small partition. Normally, partitions can be deleted using the Computer Management program (under Disk Management). You select the SDCard volume and right click the partition and delete it.This did not completely work - some partitions did not have the delete option.

To actually delete the partitions, drop down to the command line (run as administrator, just in case). Run diskpart.When the prompt displays, run these commands.

DISKPART> list disk      [lists all the disks on the system]

DISKPART> select disk n      [carefully select the disk that is the SDCard for the following command]

DISKPART> list partition      [lists all the partitions of the selected disk]

DISKPART> list disk      [lists all the disks on the system]

DISKPART> select partition n      [select a partition to delete]

DISKPART> delete partition      [delete the selected partition]

[At this point repeat the list, select and delete commands for each partition

DISKPART> exit      [exits diskpart] 

At this point, I used Disk Manager to create a new partition, assign a drive letter and format the partition to FAT32. This can also be done with DISKPART create partition and assign commands.

Diskpart commands

 References:

posted @ Friday, May 4, 2012 10:18 AM | Feedback (0) |

Monday, April 16, 2012

The Miami's Metrorail App for the Windows Phone 7

My third WP7 app is now available in the Marketplace. Like the Tri-Rail app I released a few weeks ago, this is a useful app for riders of the Miami-Dade County Commuter Rail system known as Miami's Metrorail.

Miami's Metrorail App Home ScreenThe app will let you locate the nearest stations using the WP7's GeoLocation system to determine your current location. It will show the nearest station North of you and the nearest station to the South including the distance to the stations in miles.Miami's Metrorail App in the Marketplace

The list of all stations can be displayed and select one to see the details of that station such as the address and the times the trains will arrive during the day. There is a button to click to display directions to the station using Bing to help navigate you there.

The next arriving Northbound and Southbound trains are displayed with the number of minutes until they arrive.

Select one of the stops at the station to see information about that train and all its other station stops with arrival times.

There home screen has a button to display the Metrorail's mobile website which is really nice and adds a lot of useful information. The station information page displays connection informtion to local Metrobuses and the Metromover.

Finally, there is an info screen that displays some information, web page links and the About screen.

For more information, click the image to get to the marketplace and the app’s home page.

posted @ Wednesday, February 22, 2012 12:00 AM | Feedback (0) | Filed Under [ WP7 ]

The Tri-Rail App for the Windows Phone 7

Well, I have written my second WP7 app. This is a useful app for riders of the S. Florida Commuter Rail system known as Tri-Rail (see http://www.tri-rail.com).

Tri-Rail App Station ScreenThe app will let you locate the nearest stations using the WP7's GeoLocation system to determine your current location. It will show the nearest station North of you and the nearest station to the South including the distance to the stations in miles.

The list of all stations can be displayed and select one to see the details of that station such as the address and the times the trains will arrive during the day. There is a button to click to display directions to the station using Bing to help navigate you there.

The next arriving Northbound and Southbound trains are displayed with the number of minutes until they arrive.

Select one of the stops at the station to see information about that train and all its other station stops with arrival times.

There is a fare calculator that will determine the fare for the train ride. Fares are based on the distance traveled (by zones), whether it is a weekday or weekend rate and the type of travel (one-way, round trip or one of several other types).

Finally, there is an info screen that displays some information, web page links and the About screen.

For more information, click the image to get to the marketplace and the app’s home page.

posted @ Wednesday, February 8, 2012 12:00 AM | Feedback (0) | Filed Under [ WP7 ]

The TivoNetRemote App for the Windows Phone 7

I have been spending some time lately writing an app for the Windows Phone 7 to remote TivoNetRemoteMktMcontrol a TiVo using your home network (not infrared). Today, the app showed up in the marketplace.

TivoNetRemotePhoneS

The app uses the Mango (7.5) version of the Windows Phone 7 which supports TCP/IP socket communication. As you click the buttons, commands are sent to the TiVo over the connection to tell it to do various things. For example, IRCODE PAUSE is the command to pause the TiVo. TiVo has documented most of the commands. The TiVo Premiere, S3 and TiVo HD support network remote control.

The app uses some controls from Telerik to improve the user interface such as page transitions, popups for Trial/Purchase notification and the list picker.

The app has a trial and purchase mode. The trial is free but some functionality is disabled. Purchasing the full version ($1.99) immediately enables the missing functions.

The app uses the Dotfuscator product from Preemptive Solutions to obfuscate the code to deter reverse engineering and decompiling the app as well as add analytics to track the number of times the app is used by all those that downloaded it.TivoRemoteWM6

Much of the text and hyperlinks within the app may be updated by me without requiring users to update their app. This is done by the app downloading an XML file containing the text and other properties from a website. I simply update the XML file and users will have the latest text available to them. For example, one of the pages has a list of resources and links to websites. I can easily add or update this list. Also, there is a page of Headline News which I can update periodically with new and interesting tips.

Development of the app is done using Microsoft’s Visual Studio. The code is C# and WP7 development is in Silverlight (xaml).

About 9 years ago, I wrote a similar app for the Windows Mobile 6 (image on the right). This app also used network commands but it talked to the old Series 1 TiVo using HTTP protocol to the web server that was set up on the TiVo (TivoWeb).

For more information, click the images to get to the marketplace and the app’s home page.

posted @ Wednesday, October 5, 2011 12:00 AM | Feedback (0) | Filed Under [ WP7 ]

How to Enable jQuery Intellisense in Your MVC 3 Razor Code

You probably include your <script> to pull in the jQuery JavaScript in your layout.cshtml (master page in Razor), perhaps something like this:

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.6.2.min.js" type="text/javascript"></script>
 

But your code pages that use jQuery do not show Intellisense. To enable Intellisense, add this to the top of the pages so Visual Studio has a reference to the vsdoc which is hosted by the Microsoft CDN:

@if (false) {<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.6.2.min.js" type="text/javascript" />}
 

The if statement will prevent the script tag from being emitted to the browser since it is only needed for Visual Studio development.jquery

It is not necessary to specify the path to the vsdoc file since Visual Studio knows to look for the vsdoc in the same location and use it if it finds it.

The Intellisense is shown based on deleting then typing the open paren at the point indicated.

BTW, the $(function() at the top of the example is a common shorthand for $(document).ready(function().

The CDN used is the Microsoft Ajax Content Delivery Network and they changed the domain from ajax.microsoft.com to ajax.aspnetcdn.com to improve performance and prevent microsoft.com cookie transmission.

The CDN also has the files for the jQueryUI .js and .css for the themes.

<link type="text/css" rel="Stylesheet" 
    href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.14/themes/redmond/jquery-ui.css" />
<script type="text/javascript" 
    src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.14/jquery-ui.min.js"></script>
 

Note that the current versions of these files at this time is 1.6.2 for jQuery and 1.8.14 for jQueryUI.

posted @ Monday, May 30, 2011 12:00 AM | Feedback (1) | Filed Under [ Programming ]

Log Your Website Visitor Out of Facebook

One of my webs lets the user authenticate using the Facebook OAuth 2.0 Graph protocol. When the user clicks the Logout button, a call is made (Http redirect) to Facebook to have it log the user off Facebook and my site and then it returns to my site to display my page with the button now showing Login instead of Logout. The user never sees any Facebook page during the logout.

The way this works is to pass a parameter to Facebook that indicates the url to return to when it is done. A few weeks ago, this stopped working. Instead of returning to the specified url, Facebook logged out the user but displayed its own page. It ignored the return url parameter.

The return parameter is specified as next=.

I posted a Facebook bug and someone did reply with a solution. It did not immediately work for me but with some experimentation, I found out the needed syntax.

This does work if you do it right. I tried some variations and some work and some don't. By "work", I mean the redirect will log you out and it will return to your url in the "next" parameter.

https://www.facebook.com/logout.php?next=[http://www.yoursite.com]&access_token=[current_token]

  1. Use https, not http - it won't return if you use http (for facebook.com)
  2. Supply the access_token parameter - it won't return if omitted
  3. Both www.facebook.com and m.facebook.com appear to work
  4. Supply or omit the &confirm=1 parameter (some folks mentioned it). It worked either way
  5. UrlEncode the next parameter if necessary (contains question marks, ampersands, equal signs, etc.)
  6. I passed &next=http://localhost:5000/ - final slash is not required but recommended.

posted @ Thursday, May 26, 2011 12:00 AM | Feedback (0) | Filed Under [ Programming ]

Powered by:
Powered By Subtext Powered By ASP.NET