Results 1 to 9 of 9

Thread: MD5: how to compile win32 Console code?

  1. #1

    MD5: how to compile win32 Console code?

    Hi, I have been trying to compile the C source files to test the MD5 Reference implementation as listed in RFC1321.

    I wanted to compile mddriver.c so that I can step through the code to get a better idea of how it works. I'm using Visual C++ 6.0 and I'm not I'm getting the following error:

    Compiling...
    mddriver.c
    c:\documents and settings\desktop\md5 reference implementation\mddriver.c(232) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.


    To create a project, I Selected File->New->Projects->Win32 Console Application, enter a Project name.

    Then create an empty project, and add the following source files:
    md5.c and mddriver.c and the header files global.h and md5.h.

    I've attached the files I have copied and pasted from the white paper.
    I hope someone can give me directions on how to compile this please.
    Attached Files Attached Files

  2. #2
    Red wine, not vodka! ZaiRoN's Avatar
    Join Date
    Oct 2001
    Location
    Italy
    Posts
    922
    Blog Entries
    17
    Uncheck *use precompiled header* somewhere in your project settings.

  3. #3
    Hi, I just tried as you suggest and I now get the following cryptic errors:

    Code:
    c:\mddriver.c(106) : error C2065: 'MD_CTX' : undeclared identifier
    c:\mddriver.c(106) : error C2146: syntax error : missing ';' before identifier 'context'
    c:\mddriver.c(106) : error C2065: 'context' : undeclared identifier
    c:\mddriver.c(107) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(108) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(110) : warning C4013: 'MDInit' undefined; assuming extern returning int
    c:\mddriver.c(111) : warning C4013: 'MDUpdate' undefined; assuming extern returning int
    c:\mddriver.c(111) : error C2065: 'len' : undeclared identifier
    c:\mddriver.c(112) : warning C4013: 'MDFinal' undefined; assuming extern returning int
    c:\mddriver.c(112) : error C2065: 'digest' : undeclared identifier
    c:\mddriver.c(114) : error C2065: 'MD5' : undeclared identifier
    c:\mddriver.c(124) : error C2146: syntax error : missing ';' before identifier 'context'
    c:\mddriver.c(125) : error C2275: 'time_t' : illegal use of this type as an expression
            d:\program files\microsoft visual studio\vc98\include\time.h(79) : see declaration of 'time_t'
    c:\mddriver.c(125) : error C2146: syntax error : missing ';' before identifier 'endTime'
    c:\mddriver.c(125) : error C2065: 'endTime' : undeclared identifier
    c:\mddriver.c(125) : error C2065: 'startTime' : undeclared identifier
    c:\mddriver.c(126) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(127) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(134) : error C2065: 'i' : undeclared identifier
    c:\mddriver.c(135) : error C2065: 'block' : undeclared identifier
    c:\mddriver.c(135) : error C2109: subscript requires array or pointer type
    c:\mddriver.c(135) : error C2106: '=' : left operand must be l-value
    c:\mddriver.c(183) : error C2146: syntax error : missing ';' before identifier 'context'
    c:\mddriver.c(184) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(185) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(192) : error C2065: 'buffer' : undeclared identifier
    c:\mddriver.c(192) : warning C4022: 'fread' : pointer mismatch for actual parameter 1
    c:\mddriver.c(208) : error C2146: syntax error : missing ';' before identifier 'context'
    c:\mddriver.c(209) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(210) : error C2143: syntax error : missing ';' before 'type'
    c:\mddriver.c(213) : warning C4022: 'fread' : pointer mismatch for actual parameter 1
    Last edited by 5aLIVE; September 1st, 2006 at 08:56.

  4. #4
    Here is the working project.

    There was an error in the file mddriver.c

    Code:
    #ifndef MD
    #define MD MD5
    #endif
    Where it should be

    Code:
    #ifndef MD
    #define MD 5
    #endif
    My best regards
    Attached Files Attached Files
    Last edited by Cthulhu; September 1st, 2006 at 09:07.

  5. #5
    Thankyou taking the time to look at this. It now compiles without error which is excellent.

    If I run the mddrive.exe in a console window such as mddriver 5alive. It just carriage returns and appears to be waiting more input instead of displaying the hash.

    Also I would expect the "test suite" strings to be hashed with no arguments?
    Could there another bug in the listings? I'll take a closer look at the code although I am on a steep learning curve as it is.

    UPDATE: Creating a text file and supplying this as a parameter displays the hash as expected.

    UPDATE 2: Doh! I just noticed the switches -s, -t, and -x. I got it working now , although the -t (timetrial) caused a divide by zero exception at 0xC0000094 when digesting 1000 1000byte blocks.

    Thanks,
    5aLIVE.
    Last edited by 5aLIVE; September 1st, 2006 at 09:42.

  6. #6
    Red wine, not vodka! ZaiRoN's Avatar
    Join Date
    Oct 2001
    Location
    Italy
    Posts
    922
    Blog Entries
    17
    UPDATE: Creating a text file and supplying this as a parameter displays the hash as expected.
    Do you understand why?
    Hint: look at the code below:
    Code:
    if (argc > 1)
     for (i = 1; i < argc; i++)
       if (argv[i][0] == '-' && argv[i][1] == 's')
         MDString (argv[i] + 2);
       else if (strcmp (argv[i], "-t") == 0)
         MDTimeTrial ();
       else if (strcmp (argv[i], "-x") == 0)
         MDTestSuite ();
       else
         MDFile (argv[i]);
      else
     MDFilter ();

  7. #7
    Hi Zairon.

    Yes! I spotted these switches after looking at the code again (see post update 2 above). What ever happened to good old program documentation? Easy when you know how huh?

    Now I need to try and to step through this code in the VC6 debugger to see what goes on under the hood.

    Thanks fellas.

  8. #8
    include the .h file maybe if there is one?

  9. #9
    Right, how would I go about debugging a console program in the VC6 IDE when it expects command line arguments? Without arguments I just get see an console window as you would expect.

    I expect I could do it by hardcoding a test string into the driver code and remove the command line arguments. I would prefer to be able to debug the program as it is though.

    Can it be done?

    UPDATE: Of course it can! Select Project Settings->Debug and then enter the desired program arguments in the Program arguments dialogue.
    Last edited by 5aLIVE; September 1st, 2006 at 10:34.

Similar Threads

  1. MD5: how to compile win32 Console code?
    By 5aLIVE in forum Off Topic
    Replies: 6
    Last Post: September 1st, 2006, 09:46
  2. Ollydbg and Console mode
    By Fuzzy in forum OllyDbg Support Forums
    Replies: 2
    Last Post: January 17th, 2006, 13:09
  3. sick template-stuff aka compile-time programs
    By 0rp in forum The Newbie Forum
    Replies: 2
    Last Post: February 23rd, 2005, 12:22
  4. SoftICE Console
    By Euclides in forum Tools of Our Trade (TOT) Messageboard
    Replies: 6
    Last Post: June 21st, 2004, 11:49
  5. vb6 compile to native code
    By Anonymous in forum OllyDbg Support Forums
    Replies: 2
    Last Post: March 20th, 2003, 03:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •