Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error in MD5Init() Function

Error in MD5Init() Function

Scheduled Pinned Locked Moved C / C++ / MFC
helpregexquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Developer611
    wrote on last edited by
    #1

    Hi there . I can't call MD5Init() function. in fact i can't initialize MD5 message digest context . here is my code : #include // Declare pattern of function implementation int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int); int __stdcall WndProc(HWND, UINT, WPARAM, LPARAM); CCoding clsCoding; // // MD5 structure information // typedef struct { ULONG i[2]; ULONG buf[4]; unsigned char in[64]; unsigned char digest[16]; } MD5_CTX; // // The MD5Init function initializes an MD5 message digest context. // typedef void (*MD5Init)(MD5_CTX*); // // The MD5Update function updates the MD5 context by using the supplied buffer for the message whose MD5 digest is being generated // typedef void (*MD5Update)(MD5_CTX*, unsigned char* input, unsigned int inlen); // // The MD5Final function ends an MD5 message digest previously started by a call to the MD5Init function // typedef void (*MD5Final)(MD5_CTX); // ============================== int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { // // Handle to the dll file // HINSTANCE hinstLib; // =============================== // Declare variable of type def // MD5Init InitializeMD5; MD5Update UpdateMD5; MD5Final FinalizeMD5; MD5_CTX md5Ctx; // ============================== hinstLib = LoadLibrary(L"Cryptdll.Dll"); // If the handle is valid try to get function address if (hinstLib != NULL) { InitializeMD5 = (MD5Init) GetProcAddress(hinstLib, ("MD5Init")); UpdateMD5 = (MD5Update) GetProcAddress(hinstLib, ("MD5Update")); FinalizeMD5 = (MD5Final) GetProcAddress(hinstLib, ("MD5Final")); // If the function address is valid try call function if (InitializeMD5 != NULL) { (InitializeMD5)(&md5Ctx); (UpdateMD5)(&md5Ctx,(unsigned char*) md5Ctx.in, 10); (FinalizeMD5)(md5Ctx); } } DialogBox(hInstance, MAKEINTRESOURCE(IDD_FORMMAIN), NULL, WndProc); return 0; } Error : Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. Where is the problem ?

    DMASTER

    CPalliniC 1 Reply Last reply
    0
    • D Developer611

      Hi there . I can't call MD5Init() function. in fact i can't initialize MD5 message digest context . here is my code : #include // Declare pattern of function implementation int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int); int __stdcall WndProc(HWND, UINT, WPARAM, LPARAM); CCoding clsCoding; // // MD5 structure information // typedef struct { ULONG i[2]; ULONG buf[4]; unsigned char in[64]; unsigned char digest[16]; } MD5_CTX; // // The MD5Init function initializes an MD5 message digest context. // typedef void (*MD5Init)(MD5_CTX*); // // The MD5Update function updates the MD5 context by using the supplied buffer for the message whose MD5 digest is being generated // typedef void (*MD5Update)(MD5_CTX*, unsigned char* input, unsigned int inlen); // // The MD5Final function ends an MD5 message digest previously started by a call to the MD5Init function // typedef void (*MD5Final)(MD5_CTX); // ============================== int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { // // Handle to the dll file // HINSTANCE hinstLib; // =============================== // Declare variable of type def // MD5Init InitializeMD5; MD5Update UpdateMD5; MD5Final FinalizeMD5; MD5_CTX md5Ctx; // ============================== hinstLib = LoadLibrary(L"Cryptdll.Dll"); // If the handle is valid try to get function address if (hinstLib != NULL) { InitializeMD5 = (MD5Init) GetProcAddress(hinstLib, ("MD5Init")); UpdateMD5 = (MD5Update) GetProcAddress(hinstLib, ("MD5Update")); FinalizeMD5 = (MD5Final) GetProcAddress(hinstLib, ("MD5Final")); // If the function address is valid try call function if (InitializeMD5 != NULL) { (InitializeMD5)(&md5Ctx); (UpdateMD5)(&md5Ctx,(unsigned char*) md5Ctx.in, 10); (FinalizeMD5)(md5Ctx); } } DialogBox(hInstance, MAKEINTRESOURCE(IDD_FORMMAIN), NULL, WndProc); return 0; } Error : Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. Where is the problem ?

      DMASTER

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      You missed a WINAPI, change

      Developer611 wrote:

      typedef void (*MD5Init)(MD5_CTX*);

      to

      typedef void (WINAPI *MD5Init)(MD5_CTX*);

      :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      [my articles]

      In testa che avete, signor di Ceprano?

      D 1 Reply Last reply
      0
      • CPalliniC CPallini

        You missed a WINAPI, change

        Developer611 wrote:

        typedef void (*MD5Init)(MD5_CTX*);

        to

        typedef void (WINAPI *MD5Init)(MD5_CTX*);

        :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        [my articles]

        D Offline
        D Offline
        Developer611
        wrote on last edited by
        #3

        Dear Pallini, Thanks to your reply.

        DMASTER

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups