C++ question

Discussion in 'OT Technology' started by Shibboleth, Oct 1, 2004.

  1. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    Alright, let me try to translate from the C++ floating in my brain to english. I'm trying to parse a struct as is would appear in C++:
    Code:
      struct myStruct {
      	int a;
      	DWORD b;
      	BYTE c[4];
      	struct SomeOtherStruct;
      };
    After I parse the struct I want to create a mirrored struct in memory. Then I'll start putting values in the struct based on a pointer or something. Anyway, my questio is this: What is the most effective way to automatically create the data type parsed from the struct? What I have so far is a union:
    Code:
    union dataTypes {
      	BYTE data[8];
      	bool bType;
      	unsigned int uiType;
      	int iType;
      	BYTE byType;
      	CHAR cType;;
      	WORD wType;
      	short sType;
      	DWORD dwType;
      	long lType;
      	float fType;
      	double dType;
     };
    I then do a ReadProcessMemory to the data array (8 being the most bytes I would need to read ). What I can then do is have a long if/else chain that stricmps the data type it parses (say it's a "DWORD") and once it figures that out it'll do a ultoa(union.dwType,szLine,16); and return that string to get the data. However, I find this very ineffective. These stricmp chains are rediculous, and I can't possibly counter for every typedef'd unsigned this or pointer that. So I ask, is there another way? Any help would be appreciated
     
  2. KRYST!

    KRYST! wat

    Joined:
    Jun 10, 2004
    Messages:
    4,484
    Likes Received:
    0
    Location:
    Brisbane, AUS
    I've interfaced with RS-232 ports with C++, created large scalable C++ systems and in general have a good understanding of the language.

    What you said there lost me. Sorry :(
     
  3. kosstamogen

    kosstamogen New Member

    Joined:
    Aug 26, 2004
    Messages:
    386
    Likes Received:
    0
    Location:
    SoCal
    The crazy assignments they give students these days eh? I saw this other java thread talking about printing out the lyrics of a song... I thought to myself this assignment is:hs: :slap:



    This may be completely out of scope to what you're asking but what you are describing seems to be a VARIANT type. Its a union of a bunch of other types. Probably dosen't help, and having a hard time understanding your question.
     
  4. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    It's not an assignment, just something I'm trying to build to make my life easier. I'll look in to VARIANT, but if I could, might I PM you and try to explain better? Thanks for the help.
     

Share This Page