Slashdot Mirror


After DeCSS, DVD Jon Releases DeDRMS

An anonymous reader writes "Jon Lech Johansen, who reverse engineered FairPlay back in January, and wrote the decryption code that was later used by an anonymous developer to create the playfair utility, has released a similar utility: DeDRMS. It's only 230 lines. T-shirts anyone?"

49 of 610 comments (clear)

  1. Re:Curious how he wrote it in C#. by Rikus · · Score: 4, Informative

    I'm guessing it will be rewriten by plenty of people in various different languages. C, perl, python... fortran77?
    I don't even have a C# compiler.

  2. Host it on Freenet? by Anonymous Coward · · Score: 3, Informative

    Let's host this program on Freenet, it is a project that make's the best use for what Freenet was made for.

    1. Re:Host it on Freenet? by Anonymous Coward · · Score: 1, Informative

      1. DeDRMS can be used for Fair Use, not just "illegal piracy" - which, by the way, is a misleading term anyway; you really mean "copyright infringement"

      2. At least it's better than associating Freenet with child pornography, like it is now!

    2. Re:Host it on Freenet? by RPoet · · Score: 4, Informative

      You know, instead of saying "we" should do it, you could have just done it. It's very easy. So I did it for you.

      CHK@XTn8vik~xxqsIJzLcDFUlPQqrw4NAwI,griuDFoqruNU 09 1-2Qj8Ew/DeDRMS.cs

      (Watch out for the space inserted by the slashdot code, remove it)

      --
      "Oppression and harassment is a small price to pay to live in the land of the free." -- Montgomery Burns.
  3. blah by Anonymous Coward · · Score: 4, Informative

    For the junk filer:
    jhsvjklhajskdvhakjsdhvalkjsdhkajdhfasd hsfvhasdhvf asdf asdf asdf asdf sdf asdhvashdvasdf asdf asd sdf coipx vxjzlk sdhvaasd fasd fadfg fiobvxcoizv jcxoixz jxzc sdhvaf cmdrtaco sucks akljdkls asd asd fvx sdhvas gh hh hhf dd sdf sf sd
    hdvash jk k fgh jgdvvcbbn cv c dhvc c vb fg hdrghdfg fg dg df g dsf
    ashdva sdfgsgewrr benrtnrt er er revr dv shdva aioajdoi jfasdioj v;xjf kldasjkl;vasj sdhva sjkdfsdkvn alkn lkan alksnsdflk nsfnvlad dhvahsdva aisovaiouvoivoiua ioua auao iuasi us shdva asivoa jvhbusa ui hiuahsiuhfsa ha ahsdjkfahkdj lfhalksjdfhalk askjda
    vhasdvhasdjhvaksjdhva a kjas lkjdakljf svhasdhvaskjhvlaskjdvhas a kljs djklakslj af
    asvhajkshvjkshas dhasdjvkhasdv akjdfjadf asds s d fsd fsad fads asdfas asdf asdf sdfs vxcvxcvzxcvx ss dfsdxvc dfa bioub oiu zklxcvx nsm,m,fns,m
    sdfas ikj oixj movnxmcvnxcvo sdoifjs dfsddafgdfg kamlxcvbjio zkcnvzlk nxclk xcivx as df sdf asdf asd vi xoizjvzcvn socso s asd addfsdfahtgh fghdfgh df gd d

    using System;
    using System.IO;
    using System.Text;
    using System.Security.Cryptography;

    class M4PStream
    {
    private Rijndael alg;

    private BinaryReader br;
    private BinaryWriter bw;
    private byte [] sbuffer;

    private string AtomDRMS = "drms";
    private string AtomMP4A = "mp4a";
    private string AtomSINF = "sinf";
    private string AtomUSER = "user";
    private string AtomKEY = "key ";
    private string AtomIVIV = "iviv";
    private string AtomNAME = "name";
    private string AtomPRIV = "priv";
    private string AtomSTSZ = "stsz";
    private string AtomMDAT = "mdat";

    public M4PStream( FileStream fs )
    {
    br = new BinaryReader( fs );
    bw = new BinaryWriter( fs );
    sbuffer = br.ReadBytes( Convert.ToInt32( fs.Length ) );

    alg = Rijndael.Create();
    alg.Mode = CipherMode.CBC;
    alg.Padding = PaddingMode.None;
    }

    byte [] NetToHost( byte [] Input, int Pos, int Count )
    {
    if( BitConverter.IsLittleEndian )
    {
    for( int i = 0; i < Count; i++ )
    {
    Array.Reverse( Input, Pos + (i * 4), 4 );
    }
    }

    return Input;
    }

    int GetAtomPos( string Atom )
    {
    byte [] Bytes = Encoding.ASCII.GetBytes( Atom );

    for( int i = 0; i < (sbuffer.Length - 3); i++ )
    {
    if( sbuffer[ i + 0 ] == Bytes[ 0 ] &&
    sbuffer[ i + 1 ] == Bytes[ 1 ] &&
    sbuffer[ i + 2 ] == Bytes[ 2 ] &&
    sbuffer[ i + 3 ] == Bytes[ 3 ] )
    {
    return i;
    }
    }

    throw new Exception( String.Format( "Atom '{0}' not found", Atom ) );
    }

    uint GetAtomSize( int Pos )
    {
    byte [] Bytes = new byte[ 4 ];
    Buffer.BlockCopy( sbuffer, Pos - 4, Bytes, 0, 4 );
    return BitConverter.ToUInt32( NetToHost( Bytes, 0, 1 ), 0 );
    }

    byte [] GetAtomData( int Pos, bool bNetToHost )
    {
    uint Size;
    byte [] Bytes;

    Size = GetAtomSize( Pos );
    Bytes = new byte[ Size - 8 ];
    Buffer.BlockCopy( sbuffer, Pos + 4, Bytes, 0, Bytes.Length );

    return bNetToHost ? NetToHost( Bytes, 0, Bytes.Length / 4 ) : Bytes;
    }

    public void Decrypt( byte [] CipherText, int Offset, int Count,
    byte [] Key, byte [] IV )
    {
    MemoryStream ms = new MemoryStream();

    ICryptoTransform ct = alg.CreateDecryptor( Key, IV );
    CryptoStream cs = new CryptoStream( ms, ct, CryptoStreamMode.Write );
    cs.Write( CipherText, Offset, (Count / 16) * 16 );
    cs.Close();

    ms.ToArray().CopyTo( CipherText, Offset );
    }

    public byte [] GetUserKey( uint UserID, uint KeyID )
    {
    byte [] UserKey;
    BinaryReader bruk;

    string strHome =
    Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData );
    bool bUnix = Environment.OSVersion.ToString().IndexOf( "Unix" ) != -1;
    string strFile = String.Format( "{0}{1}{

  4. Re:Curious how he wrote it in C#. by harlows_monkeys · · Score: 4, Informative
    These things are traditionally written in C ( for speed )

    You are assuming that C# is slow. That is not a good assumption.

  5. Re:Looks like his webserver was written in C#! by Anonymous Coward · · Score: 5, Informative

    I was fortunate enough to load the page during the 1 minute that the server stayed up.

    Now let's see how long my little mirror stays up!

    http://fire.prohosting.com/xonerate/dedrms.txt

  6. Re:Curious how he wrote it in C#. by sosume · · Score: 4, Informative

    Since this code is easily converted to c++ (or VB) using one of the various tools available, this won't gain much or any speed under .NET.

    BTW he *could* have included some comments ;)

  7. Re:Looks like his webserver was written in C#! by Anonymous Coward · · Score: 5, Informative

    Stupid junk filter doesn't let me post this. Why oh why? Code after filler...

    In the beginning God created the heaven and the earth.
    2 And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
    3 And God said, Let there be light: and there was light.
    4 And God saw the light, that it was good: and God divided the light from the darkness.
    5 And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.
    6 And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.
    7 And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.
    8 And God called the firmament Heaven. And the evening and the morning were the second day.
    9 And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so.
    10 And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.
    11 And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.
    12 And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.
    13 And the evening and the morning were the third day.
    14 And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:
    15 And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.
    16 And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.
    17 And God set them in the firmament of the heaven to give light upon the earth,
    18 And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.
    19 And the evening and the morning were the fourth day.
    20 And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.
    21 And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.
    22 And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.
    23 And the evening and the morning were the fifth day.
    24 And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.
    25 And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good.
    26 And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth.
    27 So God created man in his own image, in the image of God created he him; male and female created he them.
    28 And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth.
    29 And God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat.
    30 And to every beast of the earth, and

  8. Re:Written in C# by ikkonoishi · · Score: 4, Informative

    Think music notation

    Thus c# = c sharp

  9. Re:Looks like his webserver was written in C#! by reub2000 · · Score: 2, Informative

    ed2k Link: DeDRMS.cs

  10. Re:C#, Mono, and making it do something by Anonymous Coward · · Score: 3, Informative

    I can't really help you with the problems with installing the mono client... but this is what I did (with my win2k box)

    www.go-mono.com -> c# compiler -> downloads page

    get the file mono-0.31-win32-1.exe

    run it, click okay a couple times...

    get a copy of the code....

    mcs DeDRMS.cs

    and you have an exe that's command-driven.

    command is : DeDrms.exe myfile.m4p

  11. Re:Curious how he wrote it in C#. by Anonymous Coward · · Score: 5, Informative
    I was able to access the README before the server went down:

    Compiling:

    * With MonoDevelop [1]: Open DeDRMS.cmbx and click F8.
    * With mcs [2]: mcs -out:DeDRMS.exe *.cs
    * With csc [3]: csc /out:DeDRMS.exe *.cs

    [1] http://www.monodevelop.org
    [2] http://www.go-mono.com
    [3] http://msdn.microsoft.com/netframework/technologyi nfo/howtoget/

    Usage:

    * DeDRMS.exe file.m4p

    Notes:

    DeDRMS requires that you already have the user key file(s) for
    your files. The user key file(s) can be generated by playing
    your files with the VideoLAN Client [1][2].

    DeDRMS does not remove the UserID, name and email address.
    The purpose of DeDRMS is to enable Fair Use, not facilitate
    copyright infringement.

    [1] http://www.videolan.org/vlc/
    [2] http://wiki.videolan.org/tiki-read_article.php?art icleId=5
  12. Re:Curious how he wrote it in C#. by Anonymous Coward · · Score: 3, Informative

    Things like that were traditionally written in C because it's easy to manipulate memory and pointers, which is useful for making things like encryption/decryption easier to write.

  13. It works, but...... by Anonymous Coward · · Score: 2, Informative

    It works, but you have to open the file with VLC first so the key for it is in the documents and settings\application data\drms directory.

  14. Re:DeDRMS by moonbender · · Score: 3, Informative

    Originally, the actual authors complained about publishers distributing their work lawfully. Nowadays, the publishers (and not the actual authors, who have sold away their copyright) complain about other people who illegaly distribute their work. Thus, it is almost the reverse.
    Although I agree that your argument is correct, too - however, the legal owner isn't necessarily the rightful owner: some people will say that selling away copyrights shouldn't be possible, and certainly not rightful.

    --
    Switch back to Slashdot's D1 system.
  15. Not really a cracking tool... by ThePyro · · Score: 3, Informative

    This tool seems to require that you already have your key stored in a file somewhere. This code just uses that key along with .NET's built-in cryptographic services to decrypt the data and write it back to the file. Seems like getting your hands on the key in the first place would be the hard part...

    1. Re:Not really a cracking tool... by Chester+K · · Score: 4, Informative

      This code just uses that key along with .NET's built-in cryptographic services to decrypt the data and write it back to the file. Seems like getting your hands on the key in the first place would be the hard part...

      VLC will extract your user key and save it into your home directory when you use it to try to play a FairPlay-protected file from an authorized system.

      --

      NO CARRIER
  16. Freenet mirror by RPoet · · Score: 2, Informative

    Freenet mirror:

    CHK@XTn8vik~xxqsIJzLcDFUlPQqrw4NAwI,griuDFoqruNU 09 1-2Qj8Ew/DeDRMS.cs

    (Watch out for space inserted by the slashdot code, remove it)

    --
    "Oppression and harassment is a small price to pay to live in the land of the free." -- Montgomery Burns.
  17. Re:C#, Mono, and making it do something by cduffy · · Score: 3, Informative

    Re installing Mono on Linux, you might do well to use the GARNOME packages; that way, you're building everything from source to be installed under its own prefix, and thus avoiding dependency hell.

  18. Re:Curious how he wrote it in C#. by Sam+H · · Score: 5, Informative

    Using C# makes sense to me. It provides Rijndael and MD5 in System.Security.Cryptography out of the box. These cypher and hash algorithms are at the core of the DRMS encryption scheme. The same code in C would either use obscure libraries or 1000 extra lines of code.

    --
    God, root, what is difference ?
  19. CODE MIRROR HERE by blixel · · Score: 3, Informative
  20. SharpDevelop by renelicious · · Score: 4, Informative

    This is a little offtopic, but since its written in C#, for those of you what don't have Visual Studio and don't want to mess with the command line tools (or don't have Mono on Linux) SharpDevelop is a great C# development product. Its GPL. Again a little of topic, but its always good to pimp your favorite software.

    Yes, there's also a Linux version.

    --
    "Luke, I am your node.parent();"
  21. If Apple were smart... by goMac2500 · · Score: 4, Informative

    They'd make iTunes work under WINE. As a side note I am sick and tired of people complaining that Apple does not let iTunes Music Store songs work under other media players. They do. Any media player can play iTunes Store music using the QuickTime API. All you have to do is write a plugin to interface with QuickTime. I wrote a QuickTime based media player a few years ago. Guess what? I started it up today and it played iTunes Music Store songs just fine. NO modifications. Its my own media player, yet it plays DRM'd music fine, no special un-DRMing.

  22. Re:Curious how he wrote it in C#. by t_pet422 · · Score: 5, Informative

    I don't even have a C# compiler.

    Install the .NET Framework (run Windows Update). It will install one at %WINDIR%\Microsoft.NET\Framework\v1.1.4322\csc.exe
    You can compile this with csc /out:DrDRMS.exe *.cs

  23. Re:C#, Mono, and making it do something by damiam · · Score: 2, Informative

    apt-get install mono

    --
    It's hard to be religious when certain people are never incinerated by bolts of lightning.
  24. Re:pretty cool... by TravisWatkins · · Score: 5, Informative

    No, it's not up to the player to enforce the DRM. When you purchase a song from iTunes you are given the DRM'ed file, an md5 hash of the file, and two keys. Not sure what the other key is for, but one is the encryption key. You put that with the song and you get a DRM free song. Thats exactly what this does. PS - Reverse engineering the iTMS is fun!

    --

    "But I'm still right here, giving blood and keeping faith. And I'm still right here."
  25. Re:ok... by sweetooth · · Score: 2, Informative

    It's not under the LGPL, and I don't even believe that it has been put out under Microsofts Shared Source license (yet). Even the Mono implementations aren't released under the LGPL they are licensed under the MIT X11 license with exceptions. Which you can read about in the Mono FAQ at go-mono.com

  26. Re:Site Down? by danielblair · · Score: 1, Informative
    It's Slashdotted!!! Here is MY MIRROR!!! USE IT AND TRY AND MIRROR TO OTHER PLACES SO EVERYONE DOESN'T GO DOWN!!!

    http://www.realcoders.org/dedrm/DeDRMS_cs.cs

    -Daniel Blair

    --
    -- Daniel R. Blair Senior Software Architect/Unix & FreeBSD Guru/DJ w: http://unixcoders.org t: @freebsd_hacker
  27. Re:Curious how he wrote it in C#. by Anonymous Coward · · Score: 3, Informative

    No, the libraries are not "extra" -- it's impossible to get .NET without them. In fact .NET itself relies on the crypto stuff.

  28. What this does by EvilGrin666 · · Score: 5, Informative

    For those of you that don't know. It removes the protection from a .m4p file (Downloaded with iTunes) . So basically you end up with a Vanilla AAC file.

    1. Re:What this does by danielsfca2 · · Score: 2, Informative
      > ...which you can then re-import into iTunes, right-click on and say "convert to MP3"

      ...which would make someone an idiot for transcoding music (Hello shitty sound!), and a bigger one for not knowing that AAC is better at any given bitrate anyway.

      Non-idiots will use this program to create unencrypted AACs which they will then leave in that format and play on the many media players that support AAC.

      If you wanted a shitty-sounding MP3 why not just use Kazaa in the first place?

  29. Re:Curious how he wrote it in C#. by omicronish · · Score: 4, Informative

    Install the .NET Framework (run Windows Update). It will install one at %WINDIR%\Microsoft.NET\Framework\v1.1.4322\csc.exe You can compile this with csc /out:DrDRMS.exe *.cs

    And if you're on Linux, you can download Mono and compile with mcs DeDRMS.cs.

  30. Re:Trouble installing .NET Framework by wasabii · · Score: 4, Informative

    www.go-mono.com

  31. Re:Curious how he wrote it in C#. by Cthefuture · · Score: 1, Informative

    You are assuming that C# is slow. That is not a good assumption.

    Maybe they weren't assuming anything but had actually done testing?

    I don't know about that, but I have in fact done testing and C# is slower at almost everything when compared to C/C++ and it gets really bad at the high end.

    Try making the equivalent (in terms of performance and memory usage) of a C++ std::vector in C#.

    --
    The ratio of people to cake is too big
  32. Re:Inevitable? So what? Who cares? by werdna · · Score: 2, Informative

    Sometimes, it's necessary to demonstrate the absurdity and futility of a bad law in order to make the lawmakers (and judges) understand why it's bad.

    And as a guy who has actually lobbied against technology regulation, I am here to tell you that the present "demonstration" does not evidence badness of the technology regulation. Indeed, content people use precisely these circumstances, and again, I am here to tell you it persuades, to evidence that they need the regulation as well as technology to survive.

    I am well-versed in the arguments against. I am simply telling you that they do not move legislators to repeal technology regulation, and tend to the contrary, to get them to consider even stranger more desperate bills like last year's spate of "stupid Hollings bills."

    Consider this -- How, exactly, does showing that you can pick a lock prove the absurdity and futility of laws making it a crime to own a lock pick? Sure, I can find counterarguments, and you can too, but none that would make men change a vote. And I'm a pretty good advocate as these things go.

    This doesen't help.

    P.S. Thanks for the litref :)

  33. This is how to compile it for FREE by $exyNerdie · · Score: 4, Informative


    Follow the steps to compile and run it:
    (1) Get the source code (at your own risk) and save it as DeDRMS.cs
    (2) Download and Install the NET Framework SDK for FREE (reqiures Windows 2000, Windows Server 2003 or Windows XP).
    (3) Use the included compiler csc.exe to compile the source code into executable code. Use this on command line (dos prompt) C:>csc DeDRMS.cs OR C:>csc.exe DeDRMS.cs
    (4) It will create DeDRMS.exe in the same folder where you saved DeDRMS.cs.
    (5) Profit or Jail??

  34. Or for those of you on a Linux box by dethl · · Score: 5, Informative

    1. Get and compile Mono (emerge mono for those of you with Gentoo). 2. In the command line, type: mcs DeDRMS.cs 3. Then type: mono DeDRMS.exe There ya go!

    --
    "Some fight for law. Some fight for justice. What will you fight for? One day, you will see."
  35. Binary available here! by Anonymous Coward · · Score: 4, Informative

    Compiled Binary for Windows 2000/NT/XP
    http://userwww.sfsu.edu/~astern/DeDRMS .exe
    7.00 KB

    C# Source
    http://userwww.sfsu.edu/~astern/DeDRMS.cs
    7.21 KB

    Andrew
    astern at s f s u dot edu

  36. Re:Curious how he wrote it in C#. by Anonymous Coward · · Score: 2, Informative
    It's not a cracking tool. You have to have a legitimate copy of the song from iTunes. That is, if you haven't paid for the song this tool does you no good. It just removes the DRMS protection from something you've legitimately paid for. Hurrah.

    One thing I noted in looking at the two files in iTunes: The file was still flagged with my email address, but no longer had my name under "Purchased by"... It looks like the file is still tracable to the account that bought it. Take that into account before sharing them. It shouldn't take much work to fix that last bit, and it would be a worthy addition to this program.

  37. Re:Curious how he wrote it in C#. by Anonymous Coward · · Score: 3, Informative

    I think mono is available from fink (or in the process of being made available).

    There is also rotor from Microsoft, which is supposed to compile under MacOS X.

  38. Replying to first post by Anonymous Coward · · Score: 1, Informative

    ... so people will actually see this.

    I compiled it on my Win2K box and got the following message:

    C:\iTunes\ALICEI~1\Dirt>dedrms "05 Rooster 1.m4p"
    Exception: Could not find a part of the path "C:\Documents and Settings\administ rator\Application Data\drms\03293A28.001".


    Upon surfing Johansen's site, I found the following readme that the Slashdot submitter failed to mention:

    Compiling:

    * With MonoDevelop [1]: Open DeDRMS.cmbx and click F8.
    * With mcs [2]: mcs -out:DeDRMS.exe *.cs
    * With csc [3]: csc /out:DeDRMS.exe *.cs

    [1] http://www.monodevelop.org
    [2] http://www.go-mono.com
    [3] http://msdn.microsoft.com/netframework/technologyi nfo/howtoget/

    Usage:

    * DeDRMS.exe file.m4p

    Notes:

    DeDRMS requires that you already have the user key file(s) for
    your files. The user key file(s) can be generated by playing
    your files with the VideoLAN Client [1][2].

    DeDRMS does not remove the UserID, name and email address.
    The purpose of DeDRMS is to enable Fair Use, not facilitate
    copyright infringement.

    [1] http://www.videolan.org/vlc/
    [2] http://wiki.videolan.org/tiki-read_article.php?art icleId=5

    2004-04-25 == Jon Lech Johansen ====


    So it sounds like you have to run some lame-ass VideoLAN doohickey before DeDRMS will work.

    Gee, tres impressive. Tell you what, Jon... call me when you have a standalone M4P2MP3.EXE ready to go. Right now, all of the circumvention hacks for iTunes are way more of a hassle than just burning your tracks to CD and re-ripping them to MP3.

  39. Why C# can outperform C/C++ by ca1v1n · · Score: 5, Informative

    Remember that research that found that emulating the underlying hardware with a sufficiently intelligent userland dynamic profiler was usually faster than running directly on the underlying hardware? The dynamic profiler can optimize like no compiler will ever be able to do with static analysis. It's a similar principle to what Transmeta does with their x86 emulation. Modern Just-In-Time Compilers use dynamic profiling to accelerate things, and they're getting quite good. It's certainly quite possible to design a C# vector class that's both more memory and processor efficient in most cases than C++. Here's how:

    1) Record in the virtual machine/JIT every time a vector gets resized.
    2) Based on the pattern of resizing, speculatively allocate for new vectors/resizes as much memory as they'll ever need, or at least as much as they'll need any time soon.
    3) When you guess wrong about a speculative allocation, adjust your speculation.

    C++ doubles the amount of space allocated for a vector (or queue, or list, or stack, or dequeue, or binary heap, etc) whenever a resize exceeds the amount already allocated, unless you know enough to tell it to do otherwise. This keeps the amortized cost of increasing size by one constant. C++ doesn't benefit from profiling like C# does because there's no virtual machine that can change what binary code is actually sent to the processor. You could hack vector profiling together yourself, but it would be slow. Of course, this doesn't really help C# if you're never resizing your vectors, but that doesn't mean C# can't do better than C, even if C++ will have it beat. If you've ever done much benchmarking of the C++ STL, you know that it's usually faster than otherwise identical code written with arrays, which shouldn't be possible, since the array access code can be done fairly easily in assembly without virtual function table lookups and such, but nonetheless is quite real.

    The trick to this whole scheme is doing the speculation quickly and accurately. We may not be to the point yet where JIT code reliably outperforms statically compiled code in less space, but there are an army of extraordinarily intelligent grad students out there writing dissertations on the topic, and I assure you they'll make it happen.

  40. Re:Curious how he wrote it in C#. by AstroDrabb · · Score: 2, Informative
    It even destroyed gcc C in trig calculations, though, got slaughtered by gcc C's 'double' math tests.
    From the article:
    compiled using gcc within the Cygwin bash shell emulation layer for Windows.

    A much more fair comparision would have been gcc under a *nix environment instead of the Win32 port. This "benchmark" also didn't take into consideration slower startup times, pauses due to garbage collection or code being JITed. All in all, this benchmark is useless. Though from personal experience, I do agree that C# and Java both have very good performance on modern hardware to make their use a much better alternative over lower level and error prone languages like C/C++. Java and C# both showed good numbers, except for that strange regression in Java's Trig functions.
    --
    If Tyranny and Oppression come to this land,
    it will be in the guise of fighting a foreign enemy. -James Madison
  41. Re:This is a mistake..... by TrashGod · · Score: 2, Informative

    Mono is available from Darwin Ports,, among others.
    Not that I've tried it:-)

  42. So which DRM does it decode? by shodson · · Score: 2, Informative

    So this undo Apple's FairPlay DRM? Or Microsoft's DRM? Quicktime? I couldn't really tell which DRM scheme it De-s.

  43. Re:Curious how he wrote it in C#. by Anonymous Coward · · Score: 1, Informative

    Or Portable.NET (google for it). I find it often works much better than Mono (and it has proper System.Windows.Forms support out of the box).

  44. DRM stripping can be done with iMovie by Anonymous Coward · · Score: 2, Informative

    With all the hoopla about open source programs to strip DRM from music bought at the iTunes music store, no one has mentioned that the same (or similar) can be done with Apple's own iMovie. If you import a protected song into an iMovie project, iMovie will transcode the .m4p into an .aiff file that you can find in the Media folder of your project. The .aiff file is a normal aiff file, no DRM.

  45. Re:Needs wildcard support by TheDanish · · Score: 2, Informative

    Just use "for" for expanding wildcards.

    Mini-howto:
    Make directory "here" and batch file "foo.bat"

    Put single line into batch file:

    for %%f in (*.m4p) do DeDRMS "%%f"

    Run the batch file.

    --
    Danish != nationality