#250953 - 03/03/2005 16:33
Patching the Player for more dynamic FIDs
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Quote: With player-2.01, one should find 0000 7000 at offset 0x00f4dde
Correction on that. I also see the 0000 7000 at 0x00f4de0 in v2.01:
000f4db0 00 02 00 00 00 02 00 00 00 02 00 00 00 04 00 00 |................|
000f4dc0 00 02 00 00 00 06 00 00 00 02 00 00 00 08 00 00 |................|
000f4dd0 10 00 00 00 10 08 00 00 10 00 00 00 00 10 00 00 |................|
000f4de0 00 70 00 00 00 00 00 00 00 00 00 00 2f 64 65 76 |.p........../dev|
000f4df0 2f 68 64 61 33 00 00 00 2f 64 65 76 2f 64 73 70 |/hda3.../dev/dsp|
000f4e00 00 00 00 00 65 6d 70 65 67 5f 63 6f 64 65 63 5f |....empeg_codec_|
000f4e10 73 6f 75 72 63 65 2e 63 70 70 00 00 54 68 65 72 |source.cpp..Ther|
Quote:
Quote:
3 3 24097 hda3
Bingo, your dynamic partition is 48,194 sectors long. A patched binary, and then 0xAC420 of FID goodness are all yours.
Peter
So, modified with 0xAC42 it should appear like this:
000f4db0 00 02 00 00 00 02 00 00 00 02 00 00 00 04 00 00 |................|
000f4dc0 00 02 00 00 00 06 00 00 00 02 00 00 00 08 00 00 |................|
000f4dd0 10 00 00 00 10 08 00 00 10 00 00 00 00 10 00 00 |................|
000f4de0 42 ac 00 00 00 00 00 00 00 00 00 00 2f 64 65 76 |.p........../dev|
000f4df0 2f 68 64 61 33 00 00 00 2f 64 65 76 2f 64 73 70 |/hda3.../dev/dsp|
000f4e00 00 00 00 00 65 6d 70 65 67 5f 63 6f 64 65 63 5f |....empeg_codec_|
000f4e10 73 6f 75 72 63 65 2e 63 70 70 00 00 54 68 65 72 |source.cpp..Ther|
Edited by mlord (03/03/2005 16:41)
|
Top
|
|
|
|
#250954 - 03/03/2005 16:41
Re: Patching the Player for more dynamic FIDs
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Updated my post above with more complete info.
|
Top
|
|
|
|
#250955 - 03/03/2005 18:08
Program to patch max_fid within player binary (attached) *DELETED*
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
|
Top
|
|
|
|
#250956 - 03/03/2005 18:12
Re: Program to patch max_fid within player binary (attached)
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Mm.. darn.. bug: date on top comments has 2004 instead of 2005.
Cheers
|
Top
|
|
|
|
#250957 - 03/03/2005 18:12
Re: Program to patch max_fid within player binary (attached)
[Re: mlord]
|
carpal tunnel
Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
|
Or Hijack could just patch the memory footprint of that file "in-place" without even altering the disk. It is the kernel, after all, it can do that, right?
|
Top
|
|
|
|
#250958 - 03/03/2005 18:15
Re: Program to patch max_fid within player binary (attached)
[Re: tfabris]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
That is suprisingly difficult, actually. The player is paged in/out of memory (well, probably never *out* since they likely lock the pages down), but it is probably using a read-only shared mapping, which makes it really, REALLY, hard to do.
Cheers
Edited by mlord (03/03/2005 18:16)
|
Top
|
|
|
|
#250959 - 03/03/2005 18:17
Re: Program to patch max_fid within player binary (attached)
[Re: mlord]
|
carpal tunnel
Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
|
In addition, it seems awfully CPU-intensive compared to a one-time, four-byte change in the executable.
Maybe hijack could contain the modify-the-binary code itself, triggered by a menu somewhere.
_________________________
Bitt Faulk
|
Top
|
|
|
|
#250960 - 03/03/2005 18:21
Re: Program to patch max_fid within player binary (attached) *DELETED*
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Post deleted by mlord
Edited by mlord (03/03/2005 18:31)
|
Top
|
|
|
|
#250961 - 03/03/2005 18:36
Re: Program to patch max_fid within player binary (attached)
[Re: wfaulk]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Quote: Maybe hijack could contain the modify-the-binary code itself, triggered by a menu somewhere.
I think I'll leave that to userspace, as a simple shell script, which invokes the program I've provided, remounting the root drive rw and then ro again afterwards. The Hijack ;@MENUEXEC could be used to invoke it.
Or even better, a remote shell script that uses FTP to mount the root drive rw, installs the program, chmods it, runs it (SITE EXEC), and then deletes it and remounts the root drive rw again.
cheers
|
Top
|
|
|
|
#250962 - 03/03/2005 18:38
Re: Program to patch max_fid within player binary (attached)
[Re: wfaulk]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
If we ever added a similar automatic function within Hijack, I'd just hardcode the binary offsets to eliminate the searches.
Cheers
|
Top
|
|
|
|
#250963 - 03/03/2005 19:08
Re: Program to patch max_fid within player binary (attached)
[Re: mlord]
|
carpal tunnel
Registered: 05/01/2001
Posts: 4903
Loc: Detroit, MI USA
|
If anyone is going to do that, one for fidsift would be cool too!
_________________________
Brad B.
|
Top
|
|
|
|
#250964 - 03/03/2005 20:06
Re: Program to patch max_fid within player binary (attached)
[Re: mlord]
|
member
Registered: 06/06/2001
Posts: 183
|
Could you (or someone with the ability/resources) provide a compiled version of this that will run on the Empeg?
Thanks, -Chuck
|
Top
|
|
|
|
#250965 - 03/03/2005 22:11
set_empeg_max_fid (again) *DELETED*
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
|
Top
|
|
|
|
#250966 - 03/03/2005 22:28
set_empeg_max_fid (version 4)
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
UPDATED VERSION!! This one has the right year on the comments, and is also 4x more efficient in how it searches. Also includes a minor bugfix to prevent possible (unlikely) segfault in the event that the search for the patch-point fails. Slightly safer overall, but either version works. Original post now deleted.
ANOTHER UPDATE: this one actually uses the correct new max_fid value from the partition size; the earlier versions forgot to multiply by 2, which normally results in a lower max_fid than that started with!
YET ANOTHER UPDATE: I finally figured out why Peter's number was "off" by 0x1000 in his messages: fixed overhead area for dynamic playlists etc.. in the dynamic data partition. This version of the utility now subtracts this from the new max_fid value (no harm with the previous version, though). As of this version (VERSION 4), it also now prints a version number banner at startup.
Okay, here's some C-code. Works for me on all v2/v3 player versions, and should also work fine on pretty much any other player version. Lots of error-checking included, so I believe it to be very safe.
If compiled for the player, one could just FTP the binary over to an empeg, remount the root drive RW, and then run it with no args. It will figure out how big the /dev/hda3 dynamic data partition is, and hack that value into /empeg/bin/player, all automatically.
Alternatively, one can compile/run it on any Linux/POSIX machine, and supply two command-line parameters: the absolute path to the player binary (must begin with a slash), and the new max_fid value (as otherwise it will use the computer's /dev/hda3 size, which probably won't be correct..).
Cheers
Attachments
250489-set_empeg_max_fid.c (371 downloads)
|
Top
|
|
|
|
#250967 - 03/03/2005 22:29
Re: set_empeg_max_fid (version 4) *DELETED*
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
|
Top
|
|
|
|
#250968 - 03/03/2005 22:32
Re: set_empeg_max_fid (version 4)
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Sample output from running it on my player: Code:
empeg:/# ./set_empeg_max_fid.v4 ./set_empeg_max_fid.v4: version 4 by Mark Lord (March 2005) /dev/hda3: 16632 sectors New max_fid value will be 29168 (71f0 0000) before: 0017b95c: 00 10 00 00 00 70 00 00 00 00 00 00 00 00 00 00 after: 0017b95c: 00 10 00 00 f0 71 00 00 00 00 00 00 00 00 00 00 empeg:/#
|
Top
|
|
|
|
#250969 - 03/03/2005 22:38
Re: set_empeg_max_fid (version 4)
[Re: mlord]
|
pooh-bah
Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
|
Quote: (release early, release often.. the open-source creedo!)
Uh, oh. Isn't that how you got started with hijack? Your not going to start rewriting the player one byte at a time now are you?
-Mike
|
Top
|
|
|
|
#250970 - 04/03/2005 02:14
Re: set_empeg_max_fid (version 4)
[Re: mlord]
|
member
Registered: 06/06/2001
Posts: 183
|
|
Top
|
|
|
|
#250971 - 04/03/2005 07:55
Re: set_empeg_max_fid (version 4)
[Re: mlord]
|
journeyman
Registered: 29/08/2000
Posts: 96
Loc: Hamburg, Germany
|
well...this is so cool !? just a few days after this was brought up, everything works again without having to remount, rebuild... thanks !!!
empeg:/# ./set_empeg_max_fid.v4 ./set_empeg_max_fid.v4: version 4 by Mark Lord (March 2005) /dev/hda3: 24097 sectors New max_fid value will be 44098 (ac42 0000) before: 00112698: 00 10 00 00 00 70 00 00 00 00 00 00 00 00 00 00 after: 00112698: 00 10 00 00 42 ac 00 00 00 00 00 00 00 00 00 00
|
Top
|
|
|
|
#250972 - 04/03/2005 08:57
Re: set_empeg_max_fid (version 4)
[Re: mlord]
|
carpal tunnel
Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
|
Quote: fixed overhead area for dynamic playlists etc.. in the dynamic data partition.
The clue's in the question... "offset... size..."
This is well cool BTW. Shame it got you so few extra FIDs on your own player!
Peter
|
Top
|
|
|
|
#250973 - 04/03/2005 12:32
Re: set_empeg_max_fid (version 4)
[Re: pupvogel]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Quote: /dev/hda3: 24097 sectors New max_fid value will be 44098 (ac42 0000)
Ooops.. cosmetic issue: the first line above is actually reporting "blocks" rather than sectors. Each block consists of two sectors.
But the program is doing the right thing with it, so no worries. I'll release a v5 shortly that displays the message correctly, just to be nicer about it all.
Cheers
|
Top
|
|
|
|
#250974 - 04/03/2005 12:48
set_empeg_max_fid (version 5)
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Here's the updated source code for v5 of set_empeg_max_fid.c (attached).
Just cosmetic changes this time. No need to re-run it if you've already used v4.
-- improved parsing of /proc/partitions
-- fixed display of "sectors" value
-- tidied up display of program name
-- modified license terms to permit embedding within player app in case Peter or others decide to do so. (hint hint..)
Cheers
Attachments
250529-set_empeg_max_fid.c (371 downloads)
|
Top
|
|
|
|
#250975 - 04/03/2005 12:48
Re: set_empeg_max_fid (version 5 binary)
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Here's the precompiled empeg executable for v5.
Cheers
Attachments
250530-set_empeg_max_fid.v5 (418 downloads)
|
Top
|
|
|
|
#250976 - 04/03/2005 12:56
Re: Program to patch max_fid within player binary (attached)
[Re: mlord]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Quote: That is suprisingly difficult, actually. The player is paged in/out of memory (well, probably never *out* since they likely lock the pages down), but it is probably using a read-only shared mapping, which makes it really, REALLY, hard to do.
Actually, I suppose it's an anonymous mapping, not shared, as the loader needs to perform relocation on the loaded image before running it. The place to have it automatically patch things would be in the loader program (userspace): /lib/ld-linux.so.2
Much more difficult within the kernel, though not impossible (obviously). We'd have to detect that ld-linux is mmapping the player, and the player has not been replaced with a shell script for whatever reason, and then we'd have to prefault the page in question (probably a no-op, but gotta check). Not huge I suppose, but more than I'm up for right now.
Cheers
|
Top
|
|
|
|
#250977 - 04/03/2005 14:37
Re: set_empeg_max_fid (version 5 binary)
[Re: mlord]
|
carpal tunnel
Registered: 05/01/2001
Posts: 4903
Loc: Detroit, MI USA
|
Dumb Question: Will the benefit anyone who has a large number of FIDS or only those who have no used a standard builder image?
_________________________
Brad B.
|
Top
|
|
|
|
#250978 - 04/03/2005 14:38
Re: Program to patch max_fid within player binary (attached)
[Re: mlord]
|
carpal tunnel
Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
|
Quote: Much more difficult within the kernel, though not impossible (obviously).
I just think it's nifty that you're even thinking about how it could be done.
Imagine the empeg kernel having a universal "patch" feature that allowed you to make those kinds of tiny changes to the binaries, on-the-fly, without needing to write a special program to do it each time. It could just be a config.ini setting or something...
|
Top
|
|
|
|
#250979 - 04/03/2005 14:43
Re: set_empeg_max_fid (version 5 binary)
[Re: SE_Sport_Driver]
|
carpal tunnel
Registered: 24/12/2001
Posts: 5528
|
Everybody. The partition size is rounded up to the nearest cylinder which means it's bigger than 16MB on larger disks.
|
Top
|
|
|
|
#250980 - 04/03/2005 14:46
Re: set_empeg_max_fid (version 5 binary)
[Re: SE_Sport_Driver]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Anyone with more than 0x6fff (28671) fids can benefit. How much it helps depends on how much space there is in /dev/hda3, but even on stock installs (like my own 30GB unit) it may enable more than the default limit for fids.
Cheers
|
Top
|
|
|
|
#250981 - 04/03/2005 14:57
Re: set_empeg_max_fid (version 5 binary)
[Re: mlord]
|
carpal tunnel
Registered: 05/01/2001
Posts: 4903
Loc: Detroit, MI USA
|
Thanks guys! This is great! I can't remember if my primary drive is the 80gb or 100gb, but this should help!
Here is what I got: Quote: empeg:/# ./set_empeg_max_fid.v5
set_empeg_max_fid.v5: version 5 by Mark Lord (March 2005)
/dev/hda3: 48194 sectors
New max_fid value will be 44098 (0000ac42)
before: 00112698: 00 10 00 00 00 70 00 00 00 00 00 00 00 00 00 00
after: 00112698: 00 10 00 00 42 ac 00 00 00 00 00 00 00 00 00 00
Now, if only I could get my "down, down, down" playlist to be saved between boots!
Edited by SE_Sport_Driver (04/03/2005 15:00)
_________________________
Brad B.
|
Top
|
|
|
|
#250982 - 04/03/2005 16:05
Re: set_empeg_max_fid (version 5 binary)
[Re: SE_Sport_Driver]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14496
Loc: Canada
|
Quote:
Now, if only I could get my "down, down, down" playlist to be saved between boots!
Mmm.. I wonder what might happen if we also patched the 0000 0010 (0x1000) value to a larger number, and adjusted max_fid to compensate.. Peter?
|
Top
|
|
|
|
|
|