1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

TiVo-VideoReDo-AutoProcessor Program

Discussion in 'TiVo Home Media Features & TiVoToGo' started by dlfl, Jul 19, 2007.

  1. Aug 15, 2007 #41 of 418
    Dan203

    Dan203 Super Moderator Staff Member TCF Club

    37,512
    180
    Apr 17, 2000
    Nevada
    FYI if you will be using this on Windows Vista and you have UAC enabled then you will need to run TVAP as an administrator or output as DVR-MS will fail.

    Dan
     
  2. Aug 15, 2007 #42 of 418
    FrooBrar

    FrooBrar tivodecode author

    42
    0
    Dec 4, 2006
    I just committed a new module to tivodecode CVS called tivocom, which so far just provides access to file metadata, and also to get and set the MAK in the registry that Tivo Desktop uses. It is not based on Dan203's code at all, it is written in ATL instead of MFC, and has what I hope is a powerful, fairly well thought out interface which does not hide any available data from the consumer of the interfaces.

    Please let me know what you think of it. You will need to check out both tivodecode and tivocom, and open the .sln in Visual Studio 2005 (express will not work for ATL, but then it would not have worked for MFC either).

    CVS instructions are available at the following URL in case you are not familiar with it:
    http://sourceforge.net/cvs/?group_id=183716

    I could also put a binary up somewhere if you would prefer.
     
  3. Aug 15, 2007 #43 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    So Dan, do I correctly infer from this that it does run on Vista, at least for you?

    (That would be good news to me. As I state in the readme, I don't run Vista, so can't test on that OS.)
     
  4. Aug 15, 2007 #44 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    First, thanks for your TiVoDecode efforts!

    This is very interesting -- I will look at it. I have built the TiVoDecode 0.2Pre3 .sln in VS2005 and actually fixed a small bug that was preventing it from reading the MAK file (a '\' vs. '/' problem in the file path).

    It would be nice to improve 3 aspects in TVAP over what is involved in using the Dan203 ActiveX control:

    1. I have to parse the xml string (not really a big deal).
    2. I have to deploy and install 2.6MB of VS2005 C++ CRT as part of my installation package.
    3. User has to enter MAK.

    I'm wondering about the deployment dependencies of your module. From the VS2005 help it appears there are options that vary from no dependency on the CRT runtime to complete dependency.

    You might want to update the link to the CRT redistributable in your TivoDecode web page to point to the VS2005 SP1 version. The .ocx from Dan203 will not register with the older version you link to (which has exactly the same file name just to keep things confusing). This kind of hassle is another reason for wanting to eliminate that dependency.

    It would be interesting to see if a binary of your module can be linked into my C# program in the normal (very easy) way that COM objects are handled.
     
  5. Aug 15, 2007 #45 of 418
    Dan203

    Dan203 Super Moderator Staff Member TCF Club

    37,512
    180
    Apr 17, 2000
    Nevada
    Yeah it seems to work fine on Vista, except that VRD has to be run in admin mode for DVR-MS output to work. And since you're using COM, that means VRD inherits the permissions of your program, which means you have to run TVAP in admin mode for the DVR-MS output mode to work through that.

    One small complaint... The minimize button in the dialog doesn't work. You shoulw reenable it, catch the event it produces and use that to invoke your minimize to tray function. That is common design for an app that minimizes to the tray.

    Dan
     
  6. Aug 15, 2007 #46 of 418
    Dan203

    Dan203 Super Moderator Staff Member TCF Club

    37,512
    180
    Apr 17, 2000
    Nevada
    Very cool! My control was very quickly hacked together based on some MFC source I used to test the XML output capabilities of tivodecode a few months back. I didn't have a lot of time to put into it, so I just threw something together. This will be a nice addition to the project as it will allow better expansion when future additions are made to tivodecode. (like the ability to save modified XML back to the file :))

    Dan
     
  7. Aug 15, 2007 #47 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    Maybe I could have TVAP detect whether it's in admin mode and disable the DVR_MS output choice with a message to the user. (?)

    Your "small complaint" refers to the MAK dialog staying up if the program is minimized, correct? (Never thought to test that.) BTW that "dialog" is actually a custom designed form -- I could find no ready-made dialog for text entry in C#, which amazes me since Borland Builder C++ had such things long ago!

    Thanks,
    Dave
     
  8. Aug 15, 2007 #48 of 418
    Dan203

    Dan203 Super Moderator Staff Member TCF Club

    37,512
    180
    Apr 17, 2000
    Nevada
    No. I'm talking about the main dialog. At least in Vista the minimize button does not work at all. It doesn't even highlight. It's like it's disabled.

    Dan
     
  9. Aug 16, 2007 #49 of 418
    FrooBrar

    FrooBrar tivodecode author

    42
    0
    Dec 4, 2006
    Please let me know what exactly you needed to change so I can fix it for the next version.

    I have no plans to do anything about this. I consider it beyond the scope of the tivodecode project

    I have removed this requirement in current CVS.

    The COM interface I have made allows both getting and setting the MAK that TiVo Desktop uses in the registry (it's in HKEY_CURRENT_USER, so per-user).

    Use the mak property on the TivoDecode object to get and set this MAK.

    You can call the OpenTivoFile method on the TivoDecode object to get an object which implements ITivoFile, which has a mak property you can set to override the TiVo Desktop mak if you want to use a different mak, or if one is not set in the registry. Make sure to set this BEFORE getting the chunks property from the ITivoFile interface.

    I have switched the projects in CVS to use static linking of CRT, so there should be no more dependency beyond standard Windows DLLs. The tivocom project is also statically linked both with CRT and ATL, so no additional dependencies there.

    Done.

    Got to love Microsoft...

    I don't see why it would not.

    I put a binary up temporarily at http://tivodecode.sourceforge.net/tivocom/tivocom.zip for you to try. I also included the .PDB file in case you have any crashes, you can get a helpful stack trace from the debugger for me at least ;)
     
  10. Aug 17, 2007 #50 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    I've been experimenting with your binary with mostly good results. No problem importing it into C# with an automatically produced Interop wrapper DLL. The first thing I did was create a TivoDecodeClass object and attempt to get the MAK. This threw an "Invalid Data" exception and the MAK was null. However I found I could set the MAK with that object and after that all was OK. After setting it once:

    1. I could get it.
    2. I could get the chunks.
    3. I could unregister then reregister tivocom.dll and it was still OK. (I could get the MAK without setting it first.)
    4. I could shut down the program and restart and it still could get the MAK.

    I found exactly the same behavior on another computer that doesn't have the VS2005 on it. I haven't looked at your code yet but I wonder how it's getting the MAK after setting it once whereas it couldn't get it the first time? I've looked at everything with "tivocom" in it in the registry and find nothing resembling a MAK, either plain text or encoded.

    Could it be that something in the encryption stuff gets properly initialized when I set the MAK so that it then works OK after that?


    On the MAK file thing, the change I made was near the top of tivodecode.c:

    Code:
    static const char MAK_DOTFILE_NAME[] = "\\tivodecode_mak";
    The two backslashes replace '/.' . I determined this by tracing.

    Sure would love to have it get the MAK so the user wouldn't have to enter it in TVAP! Any ideas?
     
  11. Aug 17, 2007 #51 of 418
    FrooBrar

    FrooBrar tivodecode author

    42
    0
    Dec 4, 2006
    The MAK is stored in the same place/way as TiVo Desktop does it. The specific registry location is HKEY_CURRENT_USER\Software\TiVo\SharingKeys, and the value which it reads should be type REG_BINARY named "TiVoToGo Media". I have only tested this against TiVo Desktop version 2.2 (yes, I know, old), please check what this key looks like when you get the Invalid data exception and let me know. If I had to bet, TiVo changed how they stored the MAK in the registry, or at least the value type, as the ATL registry access wrappers will throw an invalid data error (or something like that) if the reg value does not match what I asked for.

    I will look into this. This will not work as-is as it will break *NIX.
     
  12. Aug 17, 2007 #52 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    I'll take a closer look at this (don't have access to the computers at the moment).
    I've found the binary keys where you say they are -- can't swear to the exact registry key name. However I've done things like use your object to set the MAK to an invalid value and have seen the registry values change and WMP would then no longer play the .tivo files (until I used your object to set the MAK back correctly). I note there are TWO seemingly identical binary keys in that part of the registry (can't remember their exact names without looking but I think one has "media" in the name and the other has "tivoToGo"). I wonder if that is a difference from 2.2 ?

    One possible hitch in further testing is that once I set the MAK correctly via your object, the problem cannot be duplicated on that computer (even if you unregister/reregister tivocom.dll and/or restart my program). It suggests that tivocom is storing this number some other non-volatile place, e.g., in the registry, that survives through unregistration (?).

    Another thought is the MAK encryption has changed for the later versions of Desktop (I'm using 2.3 BTW) but they are still backwards compatible with the older encryptions (?). (Thus when the MAK is set via your object the binary value actually changes but can still be decoded by the TiVo software.) A way to test this would be to re-enter the MAK in desktop then see if the "get" problem reappears for tivocom.

    All in all I'm encouraged that this seems to be the only hitch in using your binary!
    I haven't tested it for dependency on the VS80CRT runtime but from what you say there shouldn't be any.
     
  13. Aug 17, 2007 #53 of 418
    Dan203

    Dan203 Super Moderator Staff Member TCF Club

    37,512
    180
    Apr 17, 2000
    Nevada
    The MAK is still stored under HKEY_CURRENT_USER\Software\TiVo\SharingKeys. Perhaps just the key name has changed? In 2.5 they are labeled...

    TiVoToGo Media
    TiVoToGo Metadata

    If that's not it then it's possible TiVo changed how the key is stored. I know somewhere around here someone mentioned that they were encrypted and required some sort of built in Windows encryption service to be running to properly store and retrieve the key. This change may have come about when TiVo moved away from the password system.

    Dan
     
  14. Aug 17, 2007 #54 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    The key names are the same in Ver. 2.3 . I pm'ed you guys with some interesting info about this behavior, including registry dumps of the keys, and my MAK. The binary keys are different depending on whether set in DeskTop or by the TiVoCom dll.
     
  15. Aug 18, 2007 #55 of 418
    FrooBrar

    FrooBrar tivodecode author

    42
    0
    Dec 4, 2006
    I bet they changed the entropy parameter to the CryptProtectData function

    Yep, CryptProtectData and CryptUnprotectData. See MSDN for details on these functions.

    Nope, the version of the TiVo Desktop I have doesn't have the password.

    I guess it is time to download 2.5 and step through the setting of the MAK again...
     
  16. Aug 18, 2007 #56 of 418
    FrooBrar

    FrooBrar tivodecode author

    42
    0
    Dec 4, 2006
    I downloaded 2.5 and set a breakpoint on CryptProtectData, and that's exactly what they did. They changed the entropy for the Media key to match the Metadata key. I am guessing that when they had a password, they used that as the entropy. When they first removed the password dialog, they just hacked it out and set the entropy to the empty string (ie, empty password). Then, they noticed that and decided that wasn't such a good idea, when they already had a seperate entropy value they were using for the Metadata key, so they started using that instead, falling back to the old format when reading in case someone upgraded from an older version of TiVo Desktop without resetting their MAK.

    I just uploaded a new version of the DLL (same url as before) which tries to read the new format first, then falls back to the old format on the INVALID_DATA error. The setting of the MAK still uses the old format, as both old and new TiVo Desktop versions support this format, while only new versions would support the new format.

    Please try it out and let me know how it works for you.
     
  17. Aug 18, 2007 #57 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    Thanks, this seems to work perfectly. Can get or set MAK as desired.

    I discovered the encrypted MAK in the registry varies each time you set it via DeskTop. A (random) time value must be used as part of the encryption key (?).
     
  18. Aug 18, 2007 #58 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    The minimize button will be fixed in the next version.

    Regarding Vista permissions, it looks like it's possible to detect the user access level and also to prompt the user to "elevate" TVAP and its child processes to Admin on Vista. (Apparently Vista by default doesn't assign admin privileges to the program even when launched by an admin user, correct?)

    The "elevation prompt" feature requires embedding a manifest in the program but that doesn't look too difficult. In either case DVR-MS functions will have to be turned off if the admin privileges aren't present or obtained via elevation.

    Comments? Suggestions?
     
  19. Aug 18, 2007 #59 of 418
    dlfl

    dlfl Cranky old novice

    7,002
    19
    Jul 6, 2006
    Near...
    Can someone running Vista with admin privileges and with UAC enabled (the default I believe) run the attached test program and let me know what happens?

    What should happen is a Windows prompt should appear saying an unknown program wants to run and the choices are "allow" or "cancel". If you allow it to run a little window should say "Running with admin privileges". If you cancel I assume it just doesn't run the program.

    If the program does run but doesn't acquire admin privileges the window will say "No admin privileges !"

    Also, if someone has a PC running XP and can run this from an account that doesn't have admin privileges I would appreciate knowing what that does too.

    Thanks!
     
  20. Aug 18, 2007 #60 of 418
    FrooBrar

    FrooBrar tivodecode author

    42
    0
    Dec 4, 2006
    The attached images... If you cancel the UAC prompt, then the program does not run.
     

    Attached Files:

Share This Page