Log in

View Full Version : Make your Pocket PC Opera Browser look like a desktop Web Browser - a new tweak!


Menneisyys
05-07-2006, 07:40 PM
I’ve published several articles on modifying the way Pocket PC Web browsers identify themselves to Web servers. (For example, this article (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=648&more=1&c=1&tb=1&pb=1) explains how this can be done to the WM5 version of Internet Explorer Mobile and this article (http://www.pocketpcmag.com/blogs/index.php?blog=3&title=how_do_i_change_the_user_agent_informati&more=1) does the same as far as pre-WM5 versions of Pocket Internet Explorer versions are concerned. I’ve also elaborated on this question, as far as other, alternate Web browsers are concerned, in my other articles – for example, the well-known Web Browser Bible, linked from this all-in-one link collection (http://www.pocketpcmag.com/blogs/index.php?blog=3&title=link_collection_to_the_latest_pocket_pc&more=1&c=1&tb=1&pb=1)).

As you can’t do the same in the current, beta2 version of Opera in the GUI/in the configuration files (of which I’ve published several articles; see for example this (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=583&more=1)), upon an AximSite user request (http://www.aximsite.com/boards/showthread.php?t=126053) I’ve decided to "hack" the current Opera Mobile 8.5 beta2 to enable this functionality.

First, let’s have a look at what User-Agent string Opera currently sends to Web servers. If you have read my article on the latest StowAway keyboard driver (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=482&more=1&c=1&tb=1&pb=1), you already know; but, of course, you may want to check it out yourself (for example, with this server-side, freely distributable, free-source program (http://www.winmobiletech.com/sekalaiset/ReturnHTTPHeaders.java) I’ve written for this purpose):

Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; PPC; 480x640) Opera 8.50 [en]

What should you send out instead of this? The following:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

In here, I used bold to denote the differences.

In the following section, I explain how the hack can be done.

Hacking

In order to "hack" Opera to send out the latter string (to identify itself as a desktop browser), you’ll need to do the following:

* transfer the 5.2 Mbytes long opera.dll to your desktop PC
* get a hexa editor; I recommend Geoffrey Prewett's free HexEdit.exe (http://www-physics.mps.ohio-state.edu/~prewett/hexedit/index.html).
* start the latter, passing the former as a parameter
* Look for the first occurrence of Mozilla/4.0 with Find:

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm2003-hexed-0.png)


* It’ll be as follows in the WM2003(SE) version:

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm2003-hexed-1.png)

and the following in the WM5 version:

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm5-hexed-1.png)


* You’ll need to overwrite the highlighted region so that it becomes the following:

in the WM2003(SE) version:

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm2003-hexed-2.png)

and, in the WM5 version:

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm5-hexed-2.png)


* After transferring back the DLL to your PDA (overwriting the former one; make sure you don’t run Opera for this to work), a quick "return the headers" test certainly shows the client already sends out the right headers:

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm2003-final.bmp.png)

and, under WM5,

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm5-final.bmp.png)

And, a real test with for example the AximSite forums (which automatically switch to the PDA-optimized view upon sensing a PDA client):

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/OperaAgent-wm2003-final-2.bmp.png)

Yes, it also considers the hacked client a fully-fledged desktop IE6 one!


Tips on Usage – Easy Switching Between the Non-Hacked and the Hacked Version

Please do note that there may be cases when making your Pocket PC Web browsers tell Web server is highly disadvantageous. For example, take the example of most Pocket PC sites. They automatically switch to PDA-optimized page layout when sensing a Pocket PC browser. This will result in greatly reduced transfer and page rendering times and bandwidth usage. Also, some sites will just not work because they use for example fully-fledged JavaScript that most Pocket PC web browsers are just incapable to handle. This was (before the recent changes, of which I’ve also elaborated in my blog (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=318&more=1&c=1&tb=1&pb=1)) the case with Yahoo Mail (see my article linked from this article (http://www.pocketpcmag.com/blogs/index.php?blog=3&title=how_do_i_change_the_user_agent_informati&more=1) on this problem).

Therefore, you may want to have the possibility of easily switching back to the original version – even without the usage of a desktop computer. It’s, actually, very-very easy: as you can have two Opera installations (if you manually copy the files around) on your PDA, you can just rename the original, say, \Program Files\Opera directory (http://www.winmobiletech.com/052006OperaAgentChange/OperaDirRename-1.bmp.png) to, say, \Program Files\Opera2 directory (http://www.winmobiletech.com/052006OperaAgentChange/OperaDirRename-2.bmp.png) and just recreate the directory with the same files (except for the different, "hacked" opera.dll file) in another one – for example, Opera, OperaHacked or anything. Then, you’ll only need to create new .lnk file(s) in \Windows\Start Menu\Programs to point to the two different versions. Fortunately, this all is possible because there’re only few files in the home directory of Opera and all the other files are orders of magnitude smaller than opera.dll itself, which means you won’t lose much storage memory by just duplicating the contents of the home directory. This way, it’ll be really easy to switch between the two Opera versions – you’ll only need to click one of the two icons in your Start Menu to be able to choose from the two versions, as in this screenshot:

Click here for screenshot! (http://www.winmobiletech.com/052006OperaAgentChange/TwoIcons.bmp.png)

If You Are Afraid of Hexa Editing...

...don’t be afraid, I’ve uploaded the modified DLL’s to here (http://www.winmobiletech.com/sekalaiset/OperaDesktopBrowserUserAgent.rar) (I’ll also contact the Opera folks whether it’s OK with them; will remove the DLL’s when it’s not). The RAR file contains two DLL’s; one for the WM2003(SE) and one for the WM5 version of Opera beta2. You will only need to un-RAR the DLL you need and overwrite your original one with it.

Please note that this tutorial (and the DLL files) should NOT be used with the outdated beta1 version of Opera Mobile - only beta2!