Speed up for some HTC applications (Disabling Vertical Sync)

Search This thread

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
Do you remember how EnableVSync=0 speeds up MenuEnhancement (at least on earlier devices)? ;)
I've investigated that HTC uses vertical synchronization in:
-ManilaToday.dll
-Manila.exe
-mode9.dll
-HTCAlbum.exe
-HTCPhotoPicker.exe
-YouTube.exe
-htcAfe.dll
-HTCFPTViewer.exe

In some apps like album disabling vsync gives noticeable perfomance boost, in some not (for example, I don't see any differences in manila, but probably some scenes would be faster)
In attachment you can get Album 2011 executables with and without vsync: check photo scrolling.

How to patch these files?
-open file in IDA
-go to ExtEscape xrefs, look at R1, it should be: 0x186B8, 0x186B9 or 0x186BA
-patch BL ExtEscape to NOP or any meaningless operation

Tech info:
vsync can be enabled in 3d party applications using this code:

Code:
#define VSYNC_BASE		0x186B8

#define VSYNC_SWITCH	(VSYNC_BASE+0)
#define VSYNC_ENABLE	(VSYNC_BASE+1)
#define VSYNC_DISABLE	(VSYNC_BASE+2)

//slower (sometimes causes terrible lags):
int EnableVSync(HDC hdc, int enable)
{
	char en = (char)enable;
	return ExtEscape(hdc, VSYNC_SWITCH, 4, &en, NULL, NULL);
};
//or
//faster:
int EnableVSync(HDC hdc, int enable)
{
	return ExtEscape(hdc, enable ? VSYNC_ENABLE : VSYNC_DISABLE, 0, NULL, 0, NULL);
}

Please, don't ask me to patch your files. If you don't notice boost on faster devices, don't post your negative experience: I test everything only on SE X1
 

Attachments

  • Album_3_2_20113922_0.zip
    1.1 MB · Views: 127
Last edited:
  • Like
Reactions: poyensa

miniterror

Senior Member
Feb 5, 2009
3,614
404
wonder why nobody says anything about this:-o
it looks like ti could be usefull or are all chefs already using this
or are chefs beware of a negative site of this tric?
i dont really get how it is supposed to be done so i cant try it
also the album attached is way older then the one i use so i think i cant compare it:p
 

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
or are chefs beware of a negative site of this tric?
There seems to be almost no negative sites. Most of chefs disable VSync for htcmenus and get no issues, so why disabling vsync in other applications should affect anything? Main difference is that htcmenus' VSync can be enabled/disabled in registry while it can't be disabled for other packages.

also the album attached is way older then the one i use so i think i cant compare it
You can always copy older HTCAlbum.exe over newer one just to compare perfomance. It is uploaded for example.

//I use album 2011 because it zooms a lot faster than any newer albums.
 
Last edited:

NRGZ28

Retired Senior Mod & Senior RD
Apr 6, 2007
10,512
9,977
XDA-Developers
I just tried it on my Leo and it's noticeably faster scrolling through pics (once the pic is opened... ). Although it does loose the smooth focus in/out action and of course pinch to zoom :) Good initiative though, disable vsync in manila and see what happens!!
 

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
Although it does loose the smooth focus in/out action and of course pinch to zoom :) Good initiative though, disable vsync in manila and see what happens!!
That's probably because of older version of album.

Before opening this thread, I've patched all files mentioned above.
Manila files - not so much noticeable changes, but manila's htcmenus seems to open faster. May be some scenes like music tab's landscape mode would be much better, I haven't checked.
Album/Photopicker get a lot of boost.
YouTube - scrolling videos' list became faster.
htcAfe.dll - CM*.exe work a bit faster, but they are pretty quick even without this trick.
Footprints - not checked. I don't use them in my roms.
 

Nixeus

Senior Member
Sep 14, 2007
1,724
43
Hello and thanks a lot for this tweak !

I have ida pro 5.5 advanced, but when i decompile htcalbum.exe or other file, i don't have any xrefs..

Could you please tell me how do you find the extscap xref please ? Which menu in ida do you use please ?

Thanks a lot :)

regards,

Nixeus
 

Nixeus

Senior Member
Sep 14, 2007
1,724
43
I think i have located the good area :



So, if i understand, i need to change BL to NOP.
SO....what is the hex code of BL please ?

How can i found it please ?

Thanks a lot :)

regards,

Nixeus
 

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
I think i have located the good area :

So, if i understand, i need to change BL to NOP.
SO....what is the hex code of BL please ?

How can i found it please ?

Thanks a lot :)

regards,

Nixeus

Yeah, you've found correct area.
I am not at my desktop pc (where all apps are located), so I can't tell you exact nop bytes. In that case I suggest you to replace BL ExtEscape bytes with next or previous instruction bytes (MOV R4, R0 or MOV R1, R4 in your file) as they will not harm anything here but will reliably disable jump.
 

Nixeus

Senior Member
Sep 14, 2007
1,724
43
Thanks a lot for your answer :) It's very very funny to do this exercice :)

I have found the hex code for BL : It's "00 EB"

I have read on google that the NOP instruction don't exist in ARM7, but the equivalent is MOV R0,R0, i will try to search how writing MOV R0,R0.

If you have some docs about ASM in ARM.....i could help me :)

Thanks a lot !!! :D :D
 
Last edited:

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
I have read on google that the NOP instruction don't exist in ARM7

If you have some docs about ASM in ARM.....i could help me :)
thumb processor mode has nop, sure :) don't remember about arm mode.
I have some docs but they are in russian.
but the equivalent is MOV R0,R0, i will try to search how writing MOV R0,R0.
Any useless instruction can be equivalent. MOV Rx, Rx (replace x with any number) are useless. In current context MOV R4, R0 or MOV R1, R4 are useless, too, and you know its bytes, so you can copy them. I usually do that, too (lazy to open asm compilator for such little problems).

Btw, in my opinion, the best and the easiest compilator for little issues is BinEdit (samsung featurephones reverser tool, not .NET version). There you can type something like
Code:
code32
MOV R4, R4
uncheck Big endian mode and check Compile to ARM.

For big patch projects FASMARM is better (search for ARMPC by den_po). Though, it compiles to semc/siemens featurephones patch file format (vkp) which is pretty easy to understand.

I have found the hex code for BL : It's "00 EB"
arm mode instructions are 4-byte long. Set Options->General->["Disassembly" tab]->Number of opcode bytes to 4.
 
Last edited:

Nixeus

Senior Member
Sep 14, 2007
1,724
43
Thanks a lot :)

SO i have modify the options in order to having the OP Code on 4 bits :




I need to replace BL ExtEscap by MOV R4,R0

So the BL ExtEscap is "C8 77 00 EB", so i need to replace C8 77 00 EB by 00 40 A0 E1, it's true ?
 

OndraSter

Retired Recognized Developer
Mar 27, 2009
2,083
272
31
Prague
Yes, exactly that.

// Btw, HTC doesn't sync against VBlank, so that's why it looks weird when scrolling in Opera or anywhere else. (Da_G's information)
 

Nixeus

Senior Member
Sep 14, 2007
1,724
43
:) Thanks a lot for all this informations ! IDA Rock's :D

I have searched in Htc_Messaging and in EzInput in order to speed up the SMS typing....but there is no Vsynch in !
 

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
Nice thread and thanks for sharing the info :).

I did a google on VSync but I could not get a good info related to Mobile Device/WinMo. Can you please add a bit info in this thread on that too or in first post :confused:.

Thanks.
What to add? That's OEM feature, that's why you can't find anything about it.
It is used by HTC pretty widely, and I listed almost all apps that use this feature (which isn't good for older devices like mine).
 
  • Like
Reactions: prabhat

Nixeus

Senior Member
Sep 14, 2007
1,724
43
Hello,

I have tried to disable the ExtEscape on the manila.exe.

I just see an import of ExtEscape, but i don't see the call of the ExtEscape.

It's normal ?

Thanks a lot :)

regards,

Nixeus

Edit : @ UltraShot : I have seen that ExtEscape is a function of coredll.dll so, why you say that it's an oem feature, sorry but i don't understand :(

Thanks a lot ultrashot.
 
Last edited:

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
Hello,
I have tried to disable the ExtEscape on the manila.exe.
I just see an import of ExtEscape, but i don't see the call of the ExtEscape.
It's normal ?
Thanks a lot :)
regards,
Nixeus
no, but i can't say what is wrong.

Edit : @ UltraShot : I have seen that ExtEscape is a function of coredll.dll so, why you say that it's an oem feature, sorry but i don't understand :(

Thanks a lot ultrashot.
ExtEscape is a common WINAPI function but control codes mentioned in first post make it enable/disable vsync.
 

Nixeus

Senior Member
Sep 14, 2007
1,724
43
Thanks a lot Ultrashot for your fast answer.
I don't know why i don't see the call (BL ExtEscape) on manila.exe and on the HTCFPTViewer ( same issue).

This work is very interresting....

Now i would like to create a patch for sense in order to bypass the function thaht compress the walpapper of Sense, but, it's an other thing ;)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Do you remember how EnableVSync=0 speeds up MenuEnhancement (at least on earlier devices)? ;)
    I've investigated that HTC uses vertical synchronization in:
    -ManilaToday.dll
    -Manila.exe
    -mode9.dll
    -HTCAlbum.exe
    -HTCPhotoPicker.exe
    -YouTube.exe
    -htcAfe.dll
    -HTCFPTViewer.exe

    In some apps like album disabling vsync gives noticeable perfomance boost, in some not (for example, I don't see any differences in manila, but probably some scenes would be faster)
    In attachment you can get Album 2011 executables with and without vsync: check photo scrolling.

    How to patch these files?
    -open file in IDA
    -go to ExtEscape xrefs, look at R1, it should be: 0x186B8, 0x186B9 or 0x186BA
    -patch BL ExtEscape to NOP or any meaningless operation

    Tech info:
    vsync can be enabled in 3d party applications using this code:

    Code:
    #define VSYNC_BASE		0x186B8
    
    #define VSYNC_SWITCH	(VSYNC_BASE+0)
    #define VSYNC_ENABLE	(VSYNC_BASE+1)
    #define VSYNC_DISABLE	(VSYNC_BASE+2)
    
    //slower (sometimes causes terrible lags):
    int EnableVSync(HDC hdc, int enable)
    {
    	char en = (char)enable;
    	return ExtEscape(hdc, VSYNC_SWITCH, 4, &en, NULL, NULL);
    };
    //or
    //faster:
    int EnableVSync(HDC hdc, int enable)
    {
    	return ExtEscape(hdc, enable ? VSYNC_ENABLE : VSYNC_DISABLE, 0, NULL, 0, NULL);
    }

    Please, don't ask me to patch your files. If you don't notice boost on faster devices, don't post your negative experience: I test everything only on SE X1
    1
    Nice thread and thanks for sharing the info :).

    I did a google on VSync but I could not get a good info related to Mobile Device/WinMo. Can you please add a bit info in this thread on that too or in first post :confused:.

    Thanks.
    What to add? That's OEM feature, that's why you can't find anything about it.
    It is used by HTC pretty widely, and I listed almost all apps that use this feature (which isn't good for older devices like mine).