Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Change Finder sizes between Base 10 and Base 2' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Change Finder sizes between Base 10 and Base 2
Authored by: peterhoneyman on Jan 06, '12 06:34:57AM

I skimmed the source code, but ... well ... can someone with a better foundation in Foundation explain how it works? TiA.



[ Reply to This | # ]
Change Finder sizes between Base 10 and Base 2
Authored by: arcticmac on Jan 06, '12 09:15:13AM

Basically it reads the copy of the foundation framework on your disk and looks for certain patterns, and then replaces a couple of carefully selected bytes. As to what exactly those bytes do, I'm actually not sure, though I'd sure be interested to know. They don't seem to be anything obvious like a divisor.



[ Reply to This | # ]
Change Finder sizes between Base 10 and Base 2
Authored by: peterhoneyman on Jan 06, '12 11:03:44AM
thanks. i read it again and ... i am still all "eek!"

i'm not gonna run this program, but i'm curious: does it take forever to run? it loops over every byte of a 10+ MB file (on my MBP).

(and

for (i = 1; i < (fileLen - 160); i++)
{
  while (i < (fileLen - 160) &amp;&amp; ... ) i++;
  if (i >= (fileLen - 160)) break;
  ...
}
is a mess. just sayin'!)

[ Reply to This | # ]
Change Finder sizes between Base 10 and Base 2
Authored by: arcticmac on Jan 06, '12 11:58:23PM

On a modern computer, looping over that many bytes doesn't take very long, especially when all you do at each one is to check and see if it matches one of four pre-defined values. If you think about it, it's actually only reading from each offset once (although I admit, I kinda thought it was going to double over the first time I read the code). It takes about a half a second to run the patch on my MacBook (which is ~4yrs old). (I modified the code so that it edits a _copy_ of the foundation framework that I made elsewhere so that I don't need to have it run rooted. makes me feel a little safer somehow, even though I know the difference is probably negligible.)

Closer inspection reveals that the change made (at least under 10.6) is to change a -24 to a 0, so that 1024+(-24) becomes 1024+0. Interesting, it looks like the framework has another way of accomplishing this itself, if a particular bit in a bitfield is either set or not set. I wonder if it might be possible to set that bitfield via a pref someplace instead of needing to patch the framework (patching system frameworks is a yucky solution!).

Edited on Jan 06, '12 11:59:44PM by arcticmac



[ Reply to This | # ]