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. Still problem with a class and function

Still problem with a class and function

Scheduled Pinned Locked Moved C / C++ / MFC
helpcryptographylounge
9 Posts 4 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.
  • N Offline
    N Offline
    nah1337
    wrote on last edited by
    #1

    Hi im trying to return char with the function but it gives error, anhy help

    struct random_class {

    char \*crypto\_buf;
    
    void \_\_thiscall classfunction (void \*pParam);
    

    };
    random_class* pParam;

    void (__thiscall* classfunction)(void *pParam );
    void __thiscall myclassfunction(void *pParam )
    {
    classfunction(pParam->crypto_buf);
    }

    error C2227: left of '->crypto_buf' must point to class/struct/union/generic type 1> type is 'void *'

    L CPalliniC D 3 Replies Last reply
    0
    • N nah1337

      Hi im trying to return char with the function but it gives error, anhy help

      struct random_class {

      char \*crypto\_buf;
      
      void \_\_thiscall classfunction (void \*pParam);
      

      };
      random_class* pParam;

      void (__thiscall* classfunction)(void *pParam );
      void __thiscall myclassfunction(void *pParam )
      {
      classfunction(pParam->crypto_buf);
      }

      error C2227: left of '->crypto_buf' must point to class/struct/union/generic type 1> type is 'void *'

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      nah1337 wrote:

      void __thiscall myclassfunction(void *pParam )

      Why did you make pParam a pointer to a void?

      txtspeak is the realm of 9 year old children, not developers. Christian Graus

      1 Reply Last reply
      0
      • N nah1337

        Hi im trying to return char with the function but it gives error, anhy help

        struct random_class {

        char \*crypto\_buf;
        
        void \_\_thiscall classfunction (void \*pParam);
        

        };
        random_class* pParam;

        void (__thiscall* classfunction)(void *pParam );
        void __thiscall myclassfunction(void *pParam )
        {
        classfunction(pParam->crypto_buf);
        }

        error C2227: left of '->crypto_buf' must point to class/struct/union/generic type 1> type is 'void *'

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

        Why do you need to use explicitely __thiscall?

        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.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        N 1 Reply Last reply
        0
        • CPalliniC CPallini

          Why do you need to use explicitely __thiscall?

          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.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          N Offline
          N Offline
          nah1337
          wrote on last edited by
          #4

          because the function that i dissasembled does have void * pointer and it is also __thiscall Here is how the dissasembled func looks like:

          void *__thiscall sub_402355(void *this)
          {
          void *v1; // ebx@1
          signed int v2; // edi@1
          void *v3; // esi@1

          v3 = this;
          *(_BYTE *)this = 0;
          v2 = 0;
          v1 = this;
          do
          {
          sub_401462(*((_BYTE *)v3 + v2++ + 188), v1);
          v1 = (char *)v1 + 2;
          }
          while ( v2 < 16 );
          return v3;
          }

          CPalliniC 1 Reply Last reply
          0
          • N nah1337

            because the function that i dissasembled does have void * pointer and it is also __thiscall Here is how the dissasembled func looks like:

            void *__thiscall sub_402355(void *this)
            {
            void *v1; // ebx@1
            signed int v2; // edi@1
            void *v3; // esi@1

            v3 = this;
            *(_BYTE *)this = 0;
            v2 = 0;
            v1 = this;
            do
            {
            sub_401462(*((_BYTE *)v3 + v2++ + 188), v1);
            v1 = (char *)v1 + 2;
            }
            while ( v2 < 16 );
            return v3;
            }

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

            What are you doing? Do you intend to reproduce the function behaviour in C? :)

            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.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            In testa che avete, signor di Ceprano?

            N 1 Reply Last reply
            0
            • CPalliniC CPallini

              What are you doing? Do you intend to reproduce the function behaviour in C? :)

              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.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              N Offline
              N Offline
              nah1337
              wrote on last edited by
              #6

              No i want to hook the function and return the crypto char in the class.

              L 1 Reply Last reply
              0
              • N nah1337

                Hi im trying to return char with the function but it gives error, anhy help

                struct random_class {

                char \*crypto\_buf;
                
                void \_\_thiscall classfunction (void \*pParam);
                

                };
                random_class* pParam;

                void (__thiscall* classfunction)(void *pParam );
                void __thiscall myclassfunction(void *pParam )
                {
                classfunction(pParam->crypto_buf);
                }

                error C2227: left of '->crypto_buf' must point to class/struct/union/generic type 1> type is 'void *'

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                nah1337 wrote:

                classfunction(pParam->crypto_buf);

                Have you tried:

                classfunction(((random_class *) pParam)->crypto_buf);

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "Man who follows car will be exhausted." - Confucius

                N 1 Reply Last reply
                0
                • N nah1337

                  No i want to hook the function and return the crypto char in the class.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Take a look at your manuals, you cannot access anything from a void*, you must cast it so that it points to some type, otherwise the compiler does not know how to access the data.

                  txtspeak is the realm of 9 year old children, not developers. Christian Graus

                  1 Reply Last reply
                  0
                  • D David Crow

                    nah1337 wrote:

                    classfunction(pParam->crypto_buf);

                    Have you tried:

                    classfunction(((random_class *) pParam)->crypto_buf);

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "Man who follows car will be exhausted." - Confucius

                    N Offline
                    N Offline
                    nah1337
                    wrote on last edited by
                    #9

                    wow now i can compile it thnx for your help, i hadnt tryed it and this shows my knowledge of c++ is still weak much to learn.

                    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