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. Security Check Stack overflow compiler GS option

Security Check Stack overflow compiler GS option

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingvisual-studiodata-structuressecurity
3 Posts 2 Posters 7 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi I put my ownerdraw code in a C dll upon exiting it I got a Security check stack overflow. I turned the /GS complier option off looked to work fine under VS debugger. The Calling code is MFC C/C++ The DLL is in C Here is the MFC code

    CMystatic::CMystatic()
    {
    width = 0;
    mod = LoadLibrary(TEXT("C:\\SYSADATA\\SYSADATA\\x64\\Debug\\SYSADATA.DLL"));
    drawptr = (fownerdraw)GetProcAddress(mod, "ownerdraw");
    strsize.cx = 0;
    strsize.cy = 0;
    myexitparm = &exitparm;
    }

    void CMystatic::DrawItem(LPDRAWITEMSTRUCT pdi)
    {

    exitparm.pdi = pdi;
    exitparm.sizeptr = &strsize;
    
    (drawptr)(myexitparm);
    

    }

    Here is the C DLL

    typedef struct EXITPARM
    {
    LPDRAWITEMSTRUCT pdi;
    SIZE* sizeptr;

    };
    // void ownerdraw(exitparmptr);
    typedef struct EXITPARM* exitparmptr;
    __declspec(dllexport) void ownerdraw(exitparmptr parmptr);

    void ownerdraw(exitparmptr parmptr)
    {

    LPDRAWITEMSTRUCT pdi = parmptr->pdi;
    

    // (char*)myexit += 8;
    SIZE* mysize = parmptr->sizeptr;

    V 1 Reply Last reply
    0
    • F ForNow

      Hi I put my ownerdraw code in a C dll upon exiting it I got a Security check stack overflow. I turned the /GS complier option off looked to work fine under VS debugger. The Calling code is MFC C/C++ The DLL is in C Here is the MFC code

      CMystatic::CMystatic()
      {
      width = 0;
      mod = LoadLibrary(TEXT("C:\\SYSADATA\\SYSADATA\\x64\\Debug\\SYSADATA.DLL"));
      drawptr = (fownerdraw)GetProcAddress(mod, "ownerdraw");
      strsize.cx = 0;
      strsize.cy = 0;
      myexitparm = &exitparm;
      }

      void CMystatic::DrawItem(LPDRAWITEMSTRUCT pdi)
      {

      exitparm.pdi = pdi;
      exitparm.sizeptr = &strsize;
      
      (drawptr)(myexitparm);
      

      }

      Here is the C DLL

      typedef struct EXITPARM
      {
      LPDRAWITEMSTRUCT pdi;
      SIZE* sizeptr;

      };
      // void ownerdraw(exitparmptr);
      typedef struct EXITPARM* exitparmptr;
      __declspec(dllexport) void ownerdraw(exitparmptr parmptr);

      void ownerdraw(exitparmptr parmptr)
      {

      LPDRAWITEMSTRUCT pdi = parmptr->pdi;
      

      // (char*)myexit += 8;
      SIZE* mysize = parmptr->sizeptr;

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      I never saw such an error/warning in my code. What I see in your code snippet (and it is was I don't like) is this expression:

      void ownerdraw(exitparmptr parmptr)
      {
      LPDRAWITEMSTRUCT pdi = parmptr->pdi;

      What happens when the function argument parmptr is nullptr? Yes, the program crash!

      F 1 Reply Last reply
      0
      • V Victor Nijegorodov

        I never saw such an error/warning in my code. What I see in your code snippet (and it is was I don't like) is this expression:

        void ownerdraw(exitparmptr parmptr)
        {
        LPDRAWITEMSTRUCT pdi = parmptr->pdi;

        What happens when the function argument parmptr is nullptr? Yes, the program crash!

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        Right upon exiting the C DLL it crashed really don’t think there is any stack storage corruption when I turned if /GS option all was okay Just wondering going from inside a MFC C++ method to C DLL any special calling convention think__cedcl is the default

        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