Jun 06

Recently I've taken on a personal project of getting a computer set up all sexy-like for a MAME cabinet. I was lucky enough to have a contact through "someone who knows someone" to build the cabinet for me, but I insisted on doing the software solution myself. The reason for this was because I wanted to set up some fancy software I researched called Hyperspin. It was incredibly polished, and having an app that gave a better illusion of an arcade experience was important because that's the reason why I wanted to do this to begin with.

 

It took some time and about 20GB of video/theme files to get the application up and running like the above video, but it was worth it! The end result is incredible, and although I had to pay (donate) $25 to HyperSpin to get full access to all their themes, it's a cost absolutely worth swallowing.

 

However, one of the issues I ran into was that the ROMs that I acquired had different names than the wheel art associated with the themes. Because HyperSpin associates direct filename links, this meant that all of my ROMs, although definitely there and working, did not have any themes. I tried to find a quick and dirty solution, maybe an existing app to remap the filenames, but I couldn't find any. I was actually quite shocked at this since I have to imagine that I'm not the only one who has run into this.

So, I put on my programmer-gloves and wrote a quick C# app that compares filenames from the ROM directory and the Images (wheel art) directory. If a close match is found, the image filename is renamed to the ROM name. The end result is a way to rename thousands (or tens of thousands in my case) of files automagically.

 

I'm sure there are some bugs, and I'd caution anyone who wants to use it that it may incorrectly rename some files (keep backups before). But, it worked perfectly for me, so I'm going to release it in case anyone else has the same problem as me.

 

The way it works is by doing some brute-force comparisons, checking character by character for matches. If more than half the filename matches, the program considers the name valid and will rename the image. Because it only renames the image, no adverse effects should happen to the HyperSpin database for the game names and descriptions.

 

Requires .NET 3.5 installed

RomRemapper.zip (4.59 kb)

Tags:
May 07

As you may have read before, I've been having a real hard time with spambots picking up and exploiting this site's open comment system. It was getting ridiculous to the tune of over 900 spam comments per week.

 

I finally had enough and decided to put in my "Ghetto Captcha" on the site. 

It was actually very easy to implement, and I'm going to post the code here in hopes of helping other BlogEngine.NET users combat spammers.

Basically what you need to do is change the CommentView.ascx (control) design-view code to bypass the default post validation and insert an intermediate javascript validation.

 

Step 1: Add the new text field:

<input type="checkbox" id="cbNotify" style="width: auto" tabindex="7" />
<label for="cbNotify" style="width:auto;float:none;display:inline"><%=Resources.labels.notifyOnNewComments %></label><br /><br />
What is the name of this blog? <input type="text" id="captchaTest" />  <=== ADD THIS
<input type="button" id="btnSaveAjax" value="<%=Resources.labels.saveComment %>" onclick="return preTest()" tabindex="7" />    <== change onclick
<asp:HiddenField runat="server" ID="hfCaptcha" />

 

 

Step 2: Add the new preTest() javascript

function preTest()
{
    if(document.getElementById("captchaTest").value == "futurepr0n")
    {
        return BlogEngine.validateAndSubmitCommentForm();
    }
    return false;
}

Step 3: There is no step 3

 

SO that's it! Spammers be gone, and very little code change.

 

I realize it's hard to follow code like this out of context, so I've attached the source code for the CommentView.ascx that we're using on this site. Hopefully you can use it to your advantage!

 

CommentView.ascx (6.85 kb)

Tags: | |
Apr 29

So HP just bought Palm. That came out of nowhere.

 

I'm with most of the world out there when I thought that HTC was for sure the frontrunner, if anyone. But, that came with the very serious possibility that it would mean an end to webOS, it would merely be an IP purchase. Being a webOS developer/user/fanatic this was a pretty depressing revelation. But a couple weeks passed and HTC apparently walked away. "Whew" I thought, assuming Palm would now try to stick it out. This came with yet another troubling thought that Palm is bleeding away to death right now. They have a fantastic phone, fantastic platform, they just can't sell a phone no one has heard of! And without money, they weren't going to fix that problem.

 

Enter HP. HP really makes so much sense in hindsight. A company who once was a trailblazer with a mobile form factor (iPaq anyone?), now not even a second thought from most consumers. And in the dust of the latest Dell phone leaks, HP, being far larger and more dominant, had a gaping hole of a product line to fill. It really was a perfect match: Palm, who had a fantastic product line but no money to support it, and HP, who had no mobile product line and too much money to know what to do with it!

Now you have to step back and take a glimpse at the bigger picture. Although Palm is first and foremost a smartphone company, webOS was built from the ground up to be able to run on any device and any form factor. Did you just think that too? That unusually mysterious Windows 7 table, the HP Slate? With webOS? Amazing! Granted, the HP Slate is already very far along in its development so it's unlikely that they will jump ship from Windows 7 for now, but the framework is there from a hardware standpoint. There is a very interesting opportunity here to make the iPad look l<more like> a children's toy.

HP will reportedly "double down" on investing into webOS. Porting it to many form factors to suit its diverse hardware portfolio. At the same time though, HP and Palm have done an incredible thing for people like me: developers. All of a sudden I see this budding platform which has yet to become saturated with apps (like the iPhone or Android variants) with several form factors and possibilities. Double that with the fact that with the PDK, porting apps is now easier than ever. I wouldn't be surprised at all to see a massive influx of apps over the next few months.

One thing you can be sure of is that I will be making some new apps, this time they will go to the app catalog instead of the homebrew gallery. 

 

So with the swift purchase of Palm, the game has changed. There is now a newly confirmed big player in the game. It will be interesting to look back a couple years from now to see how much HTC, Lenovo or RIM missed out by not capitalizing on this brilliant opportunity.

Tags: | |
Apr 13

So, I decided to get off my ass and do something with the site and spruce it up a bit. Seeing how BlogEngine.NET recently released 1.6 with new spam blocking filters (thank god), I decided now was as good of a time as ever.

 

So we are now running under the latest engine and will hopefully be able to moderate comments better.

Oh, and do yourself a favour and buy a Palm Pre :)

Tags:
Mar 24

Recently I was presenting with an interesting problem: I needed to execute code under the User security context as a System account. Typically, you can execute code as a windows service under the system account without issue. Apparently, though, there may issues when trying to access WaitHandles across security contexts. 

To elaborate, when you create an EventWaitHandle in C# as the current user, it will, unless specifically specified, create it with the default security privileges. To prevent malicious programs from fooling around with your global handles, Windows separates these into "security contexts." You would see this as a .NET UnauthorizedAccessException.

Moving along, if you are unable to execute both programs under the same security context (same user), there is still hope! I was able to overcome this by using Windows Impersonation. The premise for the code is that it will execute any code within the application as a different user. As a caveat, this appears to only work when executing the code as the SYSTEM account (i.e. a windows service). If you try to impersonate a user as the admin, or the other way around, it will NOT work. 

Without further adieu, the code:

    //Tokens required to call OpenProcessToken. All three are required to impersonate a user context
    public const UInt32 TOKEN_DUPLICATE = 0x0002;
    public const UInt32 TOKEN_IMPERSONATE = 0x0004;
    public const UInt32 TOKEN_QUERY = 0x0008;


    //OpenProcessToken will open a process via its handle and attempt to retrieve the user token for that process.
    //We need this to grab the user token from a known shared program in order to run as the same user context. This prevents permission

   
    //This function will only succeed if executed under the SYSTEM account for security reasons
    [DllImport("advapi32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool OpenProcessToken(IntPtr ProcessHandle, UInt32 DesiredAccess, out IntPtr TokenHandle);

    --------------------------------------------------------------------------------
        Process[] p = Process.GetProcessesByName("KnownUserProgram");
        if (p.Length > 0)
        {
          IntPtr pHandle = p[0].Handle;
          IntPtr currentHandle = WindowsIdentity.GetCurrent().Token;
          //In order to impersonate, duplicate, impersonate and query access must be requested.
          //OpenProcessToken attempts to steal a user token from a known application. This will only work under the SYSTEM account
          bool success = OpenProcessToken(pHandle, TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY, out currentHandle);

          if (success)
          {
            Console.Writeline("Successfully captured user token");
            WindowsIdentity id = new WindowsIdentity(currentHandle);
            //Impersonate will cause the program to begin executing as if it were the current user         

            WindowsImpersonationContext context = id.Impersonate();
            Console.Writeline("Impersonation complete");
          }
          else
          {
            Console.Writeline("Failed to get user token.");
          }
        }
        else
        {
          Console.Writeline("Mainline is not running, cannot grab user token");
        }
      }
      catch (Exception ex)
      {
        Console.Writeline(ex.ToString());
        Console.Writeline("Impersonation failed");
      }
      Console.Writeline( String.Format("Continuing under the {0} context", WindowsIdentity.GetCurrent().Name));

Tags: | | |
Feb 24

I've decided to release an interim version of TGH to help those in desperate need to switch phone audio modes in addition to media audio modes. For those who haven't kept up, the previous version was only able to toggle the media audio output.

You can only toggle between headset (non-bluetooth) and front speaker at the moment. Also, note that after one phone call, the audio mode will RESET to whatever mode it was at before. I'm still trying to work out why this is happening and to see if there's anything non-intrusive that I can do to prevent this.

com.palm.futurepr0n.theghastlyheadset_0.0.2_all.ipk (32.87 kb)

Tags:
Feb 18

If you're one of the many (including me) who struggle daily with having their phones get stuck in headset mode, this may be your lucky day. After a final frustrating encounter with this problem, which required me to once again clean out the headset with alcohol, I decided to do something about it. Long story short, I created an app.

 

The Ghastly Headset (derived from the fact the Pre thinks there's a headset that isn't there... a ghost headset) is fairly limited and approximately 3 hours in its infancy. It has three main functions:

 

  1. Show the current audio mode (either speaker, headset or headset w/ mic)
  2. Force headset mode
  3. Force speaker mode
I've tested the application and the forcing of the audio seems to persist across applications (thank god), however I'm unable to fully test with a stuck Pre because I just fixed mine! So that's where I need you, loyal beta testers. I need people with stuck Pre handsets to see if forcing speaker mode will actually work. Toggling the headset (if it's not stuck) will reset the audio mode to whichever you want it to be.



 

Please download and let me know any feedback you have either here or on the PreCentral official forum post!


 

com.palm.futurepr0n.theghastlyheadset_0.0.1_all.ipk (32.38 kb)

Tags: | | |
Feb 05

As part of one of my latest projects, I had to venture into the land of jQuery. It wasn't long before I realized how powerful the platform was, and even shorter before I started browsing for plugins that I could leverage to add that extra layer of polish to my project.

This is when I found Galleria, a powerful gallery plugin, with the extra-sexy feature of creating thumbnails for you. "Great," I thought, "this will fit perfectly into my website!" Wrong.

"Exception thrown and not caught, Line: 2799" - AGHHHHH!

Due to my ignorance about jQuery, I struggled trying to get it to work. I'm not a newcomer to javascript, even with complex javascript thanks to webOS, but this plugin was just NOT working. It took me a good hour or two before I realized there was probably some incompatibility between jQuery versions, and shortly after I discovered the plugin only worked with up to 1.2.6. This was a problem for me, because a lot of my plugins required 1.3.X, and the newest version was 1.4.1. Googling the interwebs, I also found that other people suffered from the same problem as me but no working solution was ever created.

Fear no more! I have fixed Galleria to work with jQuery 1.4.1. I used the underrated javascript debugger built in Visual Studio 2005 to locate the incompatibilities and resolve them. Those were:

  • @rel need to be changed to rel (no @)
  • The thumbnail preview was attempting to parse an image that didn't exist, so now a check is made to ensure a URL is present
  • There was an extra quotation mark on the same line

All in all, very simple changes. I think this goes without saying, but I'll say it anyway: I take no responsibility for any problems you may have with the jQuery I have attached. Any charity you wish to show for the plugin should be directed at the official developers for their hard work. I want none of it!

If you are lazy like me, and I suspect you are, you probably just skipped to the end of this article to find the download link. Well here you go:

FIXED jquery.galleria.zip (4.46 kb)

Dec 06

Sadly, this will be the last effort I put into battery monitor. My interest in homebrew development waned as soon as the official app catalog opened. Also sad is the list of changed features is shockingly sparse.

 

  • Removed capacity since it was unreliable and caused more headache than it was worth
  • Removed front page, moved options into the application menu
  • The detailed status can also be accessed through the application menu
  • The runtime should now report days, and also won't report data that is 0
Note, changing the polling time on the fly takes effect AFTER the last poll completed. So, if you had your interval set to 30 minutes and you change your mind to put it to 5 seconds, you won't see any updated info until the 30 minute poll is honoured. Changing the polling time on the fly may also skew the graphing data.

Although this closes the chapter on my freshman efforts with webOS, it is not my swan song to webOS. There will be new applications, but they will not be spoofing the Palm vendor id, so they can go to the official app catalog.

Thanks to everyone for your continued support and suggestions, and I'm sorry that I couldn't implement most of them.


The latest version will also be available at precentral.net

com.palm.futurepr0n.batterymonitor_1.0.2_all.ipk (25.22 kb)

 

Edit: Found a bug and was forced to release a new version!

 

If you still like my app (please do!) and want to show support, feel free to donate.

 

 

Tags:
Nov 08

This post is to help anyone who might google not having any audio play through their headset speaker on the Pre.

 

So there I was, listening to some streaming radio with headphones on the commuter train home when I get a call. I realize that you can answer the call fine and talk through your headphones but, through natural habit, I unplugged my headphones and tried to talk on the phone normally. All of a sudden, there was no sound! SHIT! My phone is barely a month old and already the speaker is broken.

 

There is a bit of confusion around this specific problem because there are really two problems with the same symptoms. These being:

  1. You hear no audio through music apps without headphones
  2. You hear no audio when accepting a call (except through the speaker phone)
  3. The proximity sensor doesn't work, or the screen doesn't turn off when you put the phone to your face during a call

 

Through my past experiences with my xbox breaking, I've grown more and more restless in dealing with warranties. So I decided to investigate the problem on the single most powerful resource for the Palm Pre, precentral.net. I immediately found that many people were experiencing this problem, and the accepted solution was either doing a soft reset (sym+orange+r) or by plugging in the headphones back in a couple times to get the phone back into normal mode. This, however, did not work for me. Growing frustrated, I tried pulling the battery, several resets, plugging in the headphone over and over with no luck. As a last ditch effort, I used webOSDoctor to erase my phone back to factory. Still nothing.

 

Fuck!

 

Well, this is where the useful information may come for you. As I said before, there seems to be two unique problems with the same symptoms. The first being a software issue, the second being hardware. Yes, believe it or not, there is a hardware problem. The good news is you can fix it completely by yourself!

 

Before doing what I suggest, please know that I accept NO responsibility for any damage you do to your device. I do not work for palm, nor do I represent them in anyway.

 

Continuing on, the problem has to do with the headphone jack becoming blocked with dirt - dust - or some sort of fragment. This tricks the phone into thinking that the headphones are always plugged in. Not good! To fix this, you need to simply follow these steps:

  1. Shut down the Pre, remove the battery
  2. Get a Q-tip and remove some of the cotton so that it will fit in the Pre headphone jack (see where I'm going with this?)
  3. Dip the Q-tip into rubbing alcohol and shake off any excess
  4. Clean out the inside of the headset jack thoroughly (if you don't see anything on the Q-tip, don't fret - neither did I)
  5. Use the other end of the q-tip to dry out the alcohol

 

Done! That's it! This is what worked for me and I'm hoping it will save you the trouble of dealing with warranties.

 

Tags: | |