fstream.h to fstream conversion VC++6 to VC++.NET

Hi Everyone,

I have a MS Visual C++ 6 program that I need to compile using .NET.  I think just about everything will carry over, except I know that I can't include the file fstream.h, because that was abandoned for fstream in .NET.  If I try to compile as-is, I get this error:

Compiling...
FreePHG.cpp
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(70) : fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
Build log was saved at "file://c:\Documents and Settings\rmoore\Desktop\v0.05\Debug\BuildLog.htm"
FreePHG - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


If I remove the ".h" from #include<filestream.h>, I get these errors:

Compiling...
FreePHG.cpp
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(312) : error C2065: 'ofstream' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(312) : error C2146: syntax error : missing ';' before identifier 'OutFile'
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(312) : error C2065: 'OutFile' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(318) : error C2228: left of '.open' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(318) : error C2653: 'ios' : is not a class or namespace name
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(318) : error C2065: 'app' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(318) : error C2653: 'ios' : is not a class or namespace name
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(318) : error C2065: 'binary' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(319) : error C2228: left of '.fail' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(324) : error C2065: 'endl' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(327) : error C2228: left of '.write' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(330) : error C2228: left of '.close' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(370) : error C2065: 'cout' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(668) : error C2065: 'hex' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(670) : error C2065: 'dec' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\rmoore\Desktop\v0.05\Debug\BuildLog.htm"
FreePHG - 15 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Can someone either point me to a resource where I can quickly learn how to make the conversion or, if it's very simple, just let me know specifically what changes are needed?  I think the errors are just those related to output from the fstream.h file, and possibly some changed data types.  There's a lot of source code below, but I don't think many changes at all are needed.

The program itself finds a string in memory and prints it out to a file.  Here's the source code:


#include "stdafx.h"
#include <windows.h>
#include <process.h>                  // So we can use threads.
#include <fstream.h>
#include <stdio.h>

// These are the arguments we can take on the command line.
bool GL_Verbose=true;                  // Will not display any output if have this option.
bool GL_Profiling=false;            // We will display profiling information if using this option.
bool GL_WriteRealTime=false;      // If this is set, then will write to the file in realtime.
int  GL_Delay=1000;                        // Amount we sleep in ms between passes of memory.
int  GL_StringAlignment=8;            // v0.04: It appears that party always alligns strings to 8bytes.
int  GL_Priority=0;                      // For command line priority: -2 = low / 0 = normal / 2= high.
char GL_Extention[4]="hhf";            // Extention we use for output.

// ========================================================================================

// NOTES: 1. This class has alot of local data, be careful to *heap* it or else fix the
//           Tables array (have to be done eventually anyway). Local stack will cause
//           stack overflow most likely.

// Constants (### FIX LATER WITH VECTORS/STRING CLASS ###).
#define MAX_TABLES                        1000      // Can't observe more tables than this without overflow.
#define MAX_STRING                        1000      // Table name or hand # can't be longer than this (+others).

// v0.03: Used to make us try to call ReadProcessMemory() again when party locked it.
//        - With skip this section after MAX_FAIL_RPM_COUNT tried (1 secs seems fine)..
#define MAX_FAIL_RPM_COUNT            50            // Try to re-read this many times...
#define FAIL_RPM_SLEEP                  20            // Sleep for this many ms between tries.

// v0.03: This is used to set the minimum footprint size of a chunk of pages.
#define MIN_PAGE_SIZE                  0x10000      // Always seem to be in pages >65k

// v0.03: Print the profiling information every N seconds.
#define PRINT_PROFILE_TIMING      10            // 10 Seconds seems fine.

// This stucture is used to hold info on a certain table.
typedef struct TableData {
      char TableName[MAX_STRING];                  // Name of table.
      char LastHandNumber[MAX_STRING];      // Last Hand number.
      int  Len;                                          // Length of data we last saw for this hand.
      int  HandCount;                                    // How mnay hands scanned so far.
} TableData;

class PartyHandGrabber
{      // This class encapsulates grabber functions/data.

      // Array of table data - one for each table we ever seen.
      // ### THIS CAN OVERFLOW AND ALSO WE NEVER REMOVE OLD TABLES ###
      TableData Tables[MAX_TABLES];            // ### BE CAREFUL TO HEAP THIS AS > STACK ###
      int NumTables;                                    // How many tables we have in list so far.

      // ---------------------------------------------------------------------------------
      // ------------------------------- DEFAULT MEMBERS ---------------------------------
      // ---------------------------------------------------------------------------------
      public:

      PartyHandGrabber() { NumTables=0; };

      // ---------------------------------------------------------------------------------
      // ----------------------------- UTILITY FUNCTIONS ---------------------------------
      // ---------------------------------------------------------------------------------
      private:

      // UTILTY FUNCTION (STRING):
      bool strcpy_delim(char* Out,const char* In, const char Delim, const int MaxLen)
      {      // Utility function used to do a strcpy using the given deliminator rather than
            // zero/null as the string terminator.
            // NOTE: Will stop if goes beyond MaxLen chars, and return false,
            //       else returns true.

            // Loop through copying until we hit the desired delim.
            for (int I=0;I<(int)strlen(In) && I<MaxLen;I++) {

                  // Is this the deliminator, if so terminate and return.
                  if (In[I]==Delim) {
                        Out[I]=0;                              // Null terminate.
                        return true;                        // All OK.
                  }

                  // Copy the char.
                  Out[I]=In[I];
            }

            // If we got here then something is wrong, null the output and return false.
            Out[0]=0;
            return false;

      } // End strcpy_delim.

      // ---------------------------------------------------------------------------------

      // UTILTY FUNCTION (STRING):
      int GetIndexToNextCharAfterSubString(const char* Buffer, const char* SubString,
                                             const int MaxLen)
      {      // This function will search for the given SubString in the input Buffer,
            // then if found will return the index into Buffer of the next char, else
            // returns -1 on failure.

            // Scan for the desired SubString.
            for (int I=0;I<(MaxLen-(int)(strlen(SubString)-1));I++) {

                  // Look at first char, then use strcmp (for speed...).
                  if (strlen(&Buffer[I])>=strlen(SubString)
                        && Buffer[I]==SubString[0]
                        && strncmp(&Buffer[I],SubString,strlen(SubString))==0) {
                        return I+strlen(SubString);      // Found so lets return the index of next char.
                  }
            }

            // If we got here, then we failed, so return -1.
            return -1;

      }      // End GetIndexToNextCharAfterSubString.

      // ---------------------------------------------------------------------------------

      // UTILTY FUNCTION (STRING):
      int GetIndexToNextSubString(const char* Buffer, const char* SubString,
                                    const int MaxLen)
      {      // This function will search for the given SubString in the input Buffer,
            // then if found will return the index into Buffer of the first char of the
            // substring in the buffer, else returns -1 on failure.

            // Scan for the desired SubString.
            for (int I=0;I<(MaxLen-(int)(strlen(SubString)-1));I++) {

                  // Look at first char, then use strcmp (for speed...).
                  if (strlen(&Buffer[I])>=strlen(SubString)
                        && Buffer[I]==SubString[0]
                        && strncmp(&Buffer[I],SubString,strlen(SubString))==0) {
                        return I;      // Found so lets return the index of it.
                  }
            }

            // If we got here, then we failed, so return -1.
            return -1;

      }      // End GetIndexToNextSubString.

      // ---------------------------------------------------------------------------------
      // v0.04b: UTILTY FUNCTION (WIN32/GDI):
      HWND FindNextWithPrefix(const HWND CurrentWH,const char* PreFix)
      {      // This function will attempt to find the next window on the same level which
            // starts with the prefix we ask for. If it fails returns NULL.
            // If passed CurrentWH is NULL, then lets set to 1st child on the the desktop.

            char WindowText[MAX_STRING];

            // Setup to be the next window after the one we have been passed.
            HWND WH;
            
            // If passed CurrentWH is NULL, then lets set to 1st child on the the desktop.
            if (CurrentWH==NULL)
                  WH=GetWindow(GetDesktopWindow(),GW_CHILD);
            else
                  WH=GetWindow(CurrentWH,GW_HWNDNEXT);
            
            // Kee searching for this prefix.
            while (WH!=NULL) {

                  // has this window got the prefix we want?
                  if (GetWindowText(WH,WindowText,MAX_STRING-1)!=0
                        && strncmp(PreFix,WindowText,strlen(PreFix))==0) {
                        return WH;
                  }
                  
                  // Try the next child on the same level.
                  WH=GetWindow(WH,GW_HWNDNEXT);
            }

            // If we get here, then we not found it.
            return NULL;

      }      // End FindNextWithPrefix.

      // ---------------------------------------------------------------------------------
      // ------------------------------ PRIVATE MEMBERS ----------------------------------
      // ---------------------------------------------------------------------------------

      bool GetTableNameAndHandNumber(const char* Buffer, char* Name, char* Number)
      {      // This function is used to get both the table name and hand number from the
            // buffer.
            // Returns true if both found (and fills Name/Number strings), else false.
            // ### Be carefull about 'Incoplete Hand Histories' ###

            // Used to get the indexed of next char after substring.
            int CharIndex;

            // First lets get the hand number.
            CharIndex=GetIndexToNextCharAfterSubString(Buffer,": ",strlen(Buffer));
            if (CharIndex==-1) {
                  Name[0]=Number[0]=0;                              // Null the strings.
                  return false;                                          // Failed to find substring.
            }

            // Save the hand number.
            // ### '/n' should work but not??? ###
            if (strcpy_delim(Number,&Buffer[CharIndex],' ',MAX_STRING)==false) {
                  Name[0]=Number[0]=0;                              // Null the strings.
                  return false;
            }

            // Not lets get the table name.
            // ### NOTE: If this is incomplete hand history then this wont be here and ###
            // ###       we will be scanning alot of extra crap...                     ###
            CharIndex=GetIndexToNextCharAfterSubString(Buffer,"Table ",strlen(Buffer));
            if (CharIndex==-1) {
                  Name[0]=Number[0]=0;                              // Null the strings.
                  return false;                                          // Failed to find substring.
            }

            // ### v0.02: Was a bug here where tournament table names were getting truncated.
            // Store the Name.
            if (strcpy_delim(Name,&Buffer[CharIndex],'\r',MAX_STRING)==false) {
                  Name[0]=Number[0]=0;                              // Null the strings.
                  return false;
            }

            // ### v0.02: Lets remove " (Real Money)" fromt the name.
            CharIndex=GetIndexToNextSubString(Name," (Real Money)",strlen(Name));
            if (CharIndex==-1) {
                  Name[0]=Number[0]=0;                              // Null the strings.
                  return false;                                          // Failed to find substring.
            }
            Name[CharIndex]=0;                                          // We need add a null to cancel the ' '.

            // If we got here, then all ok.
            return true;

      } // End GetTableNameAndHandNumber.

      // ---------------------------------------------------------------------------------

      bool WriteHandHistoryLog(const char* TableName,const char* HandNumber,
                                 const char* Buffer,const int BufferLen)
      {      // This function writes the Buffer out to the given logfile.
            // It writes in binary mode exactly BufferLen bytes.
            // NOTE: If HandNumber is NULL, then we wont print the hand start prefix.
            // Returns true on success, else false.

            // Used to make the full filename.
            char NewName[MAX_STRING];

            // Output filestream.
            ofstream OutFile;

            // Make the new name.
            sprintf(NewName,"%s.%s",TableName,GL_Extention);

            // Attempt to open the logfile.
            OutFile.open(NewName,ios::app|ios::binary);
            if (OutFile.fail())
                  return false;                                    // Failed to open the file.

            // First we need to write the prefix string for new hand.
            if (HandNumber!=NULL)
                  OutFile << "Game #" << HandNumber << " starts." << endl << endl;

            // Write the rest of the buffer.
            OutFile.write(Buffer,BufferLen);

            // Close the file.
            OutFile.close();

            // If we got here, then all ok.
            return true;

      } // End WriteHandHistoryLog.

      // ---------------------------------------------------------------------------------

      bool HandleTableData(const char* Buffer, const int BufferLen)
      {      // This function does everything needed with the table data we pass it.
            // Returns true if something new done, else false.

            // This holds the Name and Hand Number of the current Buffer if found.
            char CurrentTableName[MAX_STRING];
            char CurrentTableNumber[MAX_STRING];

            // Lets get the table name and number first.
            // NOTE: If this data not here yet, then nothing we can do...
            if (!GetTableNameAndHandNumber(Buffer,CurrentTableName,CurrentTableNumber))
                  return false;                                                      // Failed.

            // v0.03: If we see a "side pot #" 'wins' line, then insist we also see a "main pot" line.
            if (GetIndexToNextSubString(Buffer," side pot #",BufferLen)!=-1
                  && GetIndexToNextSubString(Buffer," main pot ",BufferLen)==-1) {
                  return false;                                                      // Failed, must be missing end...
            }

            // For debugging, print this.
            //if (GL_Profiling==true)
            //      cout << endl << "~ PROFILING: " << CurrentTableName << ' ' << CurrentTableNumber << endl;

            // Now lets see if this exists and write if need be.
            for (int I=0;I<=NumTables;I++) {

                  // Is this a new table, if so then add it to our list.
                  if (I==NumTables) {

                        // v0.04: Minor bug: Was forgetting to check for this...
                        if (NumTables>=(MAX_TABLES-1)) {
                              cout << "Error: Only allocated room for 1000 tables... Stopping" << endl;
                              exit(1);
                        }

                        // For debugging, print this.
                        if (GL_Verbose==true)
                              cout << "* NEW TABLE: " << CurrentTableName << endl;

                        // Add to table list.
                        strcpy(Tables[NumTables].TableName,CurrentTableName);
                        strcpy(Tables[NumTables].LastHandNumber,CurrentTableNumber);
                        Tables[NumTables].Len=BufferLen;            // Save to compair later.
                        Tables[NumTables].HandCount=0;                  // 1st Hand.

                        // ### OFTEN CORRUPT - SO SKIP 1ST HAND ###
                        // Write to the log.
                        //if (!WriteHandHistoryLog(CurrentTableName,CurrentTableNumber,
                        //                           Buffer,BufferLen)) {
                        //      cout << "Failed to write to logfile" << endl;
                        //      return false;                                    // Failed.
                        //}

                        // One more table now.
                        NumTables++;

                        // Return true, as we actually did something this run.
                        return true;

                  }      // End is this new table?

                  // Is this the table we are looking for?
                  if (strcmp(CurrentTableName,Tables[I].TableName)==0) {

                        // Is this a new hand we not seen before?
                        if (strcmp(CurrentTableNumber,Tables[I].LastHandNumber)>0) {

                              // For debugging, print this.
                              if (GL_Verbose==true) {
                                    cout << "> New Hand [" << Tables[I].HandCount+1 << "] @ " << CurrentTableName << " #"
                                           << CurrentTableNumber << " (> #" << Tables[I].LastHandNumber << ')' << endl;
                              }

                              // Replace in the table list.
                              strcpy(Tables[I].LastHandNumber,CurrentTableNumber);
                              Tables[I].Len=BufferLen;                  // Save to compair later.
                              Tables[I].HandCount++;                        // Another hand now.

                              // Write to the log.
                              if (!WriteHandHistoryLog(CurrentTableName,CurrentTableNumber,
                                                         Buffer, BufferLen)) {
                                    cout << "Failed to write to logfile" << endl;
                                    return false;                              // Failed.
                              }

                              // Return true, as we actually did something this run.
                              return true;

                        }

                        // Is this a hand we have now got more data for (and not the first hand!)?
                        // v0.03: ### BUGFIX: This explains why the split-pot and side pot bugs were so prominent!
                        if (strcmp(CurrentTableNumber,Tables[I].LastHandNumber)==0
                              && Tables[I].HandCount>0 // ### HUGE BUG!!! Was: Tables[NumTables].HandCount>0
                              && BufferLen>Tables[I].Len) {

                              // For debugging, print this.
                              if (GL_Verbose==true) {
                                    cout << "+ New Data [" << Tables[I].HandCount << "] @ " << CurrentTableName << " #"
                                           << CurrentTableNumber << endl;
                              }

                              // Write *ONLY* what is new.
                              // NOTE: Don't write the hand start prefix either.
                              if (!WriteHandHistoryLog(CurrentTableName,NULL,
                                                         &Buffer[Tables[I].Len],
                                                         BufferLen-Tables[I].Len)) {
                                    cout << "Failed to write to logfile" << endl;
                                    return false;                              // Failed.
                              }

                              // New hand length now for the table list.
                              // NOTE: Do this *after* we logged it.
                              Tables[I].Len=BufferLen;                  // Save to compair later.

                              // Return true, as we actually did something this run.
                              return true;

                        }

                        // Same old hand, so return false as done nothing.
                        return false;

                  }      // End is this existing table?

            }      // End for each table in list.


            // Should never get here.
            cout << "Error with new hand..." << endl;
            exit(1);
            return false;

      } // End HandleTableData.

      // -------------------------------------------------------------------------------------

      void PartyMemoryScanner(const char* LobbyTitle)
      {      // This function will scan all of the party memory looking for new Hand Histories,
            // and do all the required work when found.
            // Returns false if something wrong, else true.
            // v0.04b: Can now handle multiple copies of Party in the same user area.
            // v0.05: Can now take different lobby titles, so will work on Empire also.

            // Used to count how many mem passes/min we are doing.
            if (GL_Profiling==true) {
                  static unsigned int Count=0;
                  static unsigned int StartTicks=GetTickCount(); // ### ms in a DWORD, so can wrap after 47 days...
                  static unsigned int LastTicks=GetTickCount();

                  // Print stats.
                  if (GetTickCount()-LastTicks>=PRINT_PROFILE_TIMING*1000) {
                        cout << "~ PROFILING: " << ((double)Count/((double)(GetTickCount()-StartTicks)/1000.0))*60.0
                               << " scans/min" << endl;
                        LastTicks=GetTickCount();
                  }

                  // One more call.
                  Count++;
            }

            // Process ID of the window.
            DWORD PID;

            // Used to find the allowable range of memory for the process.
            SYSTEM_INFO SI;

            // Used to check each mem segment's properties.
            MEMORY_BASIC_INFORMATION MBI;

            // This is used so we don't keep reallocating this.
            static char* Buffer = NULL;
            static DWORD BufferLen = 0;

            // Window handle for party processes.
            HWND WH=NULL;                        // Init to NULL for FindNextWithPrefix() loop.
            
            // 0.04b: Loop through all of the party poker processes.
            while ((WH=FindNextWithPrefix(WH,LobbyTitle))!=NULL) {

                  // Get the PID of the window.
                  GetWindowThreadProcessId(WH,&PID);

                  // Open the process.
                  HANDLE hProcess = OpenProcess(PROCESS_VM_READ|PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION,false,PID);

                  // Determine applications memory addresses range.
                  GetSystemInfo(&SI);

                  // Set to the start/base address.
                  void* CurrentAddress = SI.lpMinimumApplicationAddress;

                  // Keep searching until we got to the end of memory chunks.
                  while (CurrentAddress <= SI.lpMaximumApplicationAddress) {

                        // Set to 0, juzt in case this fails.
                        MBI.RegionSize = 0;

                        DWORD Ret = VirtualQueryEx(hProcess,CurrentAddress,&MBI,sizeof(MEMORY_BASIC_INFORMATION));

                        if (Ret == sizeof(MEMORY_BASIC_INFORMATION)) {
         
                              if (MBI.Type == MEM_PRIVATE && MBI.State == MEM_COMMIT
                                    && MBI.AllocationProtect == PAGE_READWRITE
                                    && MBI.Protect == PAGE_READWRITE
                                    //&& MBI.RegionSize > 0) {
                                    && MBI.RegionSize >= MIN_PAGE_SIZE) {      // ### FROM PROFILINING: THIS *ALWAYS* SEEMS TO BE 65k+
                                    //&& MBI.RegionSize <= 0x400000) {            // ### FROM PROFILINING: UPER BOUND CHANGES ALOT (UPTO 4MB, MAYBE MORE)

                                    DWORD NumRead=0;

                                    // Do we need a bigger buffer?
                                    if (MBI.RegionSize>BufferLen) {
                                          if (Buffer!=NULL)
                                                delete [] Buffer;
                                          Buffer = new char[MBI.RegionSize];
                                          BufferLen=MBI.RegionSize;
                                    }

                                    // v0.03: Read the memory - Try many times in case locked, then give in...
                                    int FailCount=0;
                                    while (!ReadProcessMemory(hProcess,MBI.BaseAddress,Buffer,MBI.RegionSize,&NumRead)) {

                                          // v0.03: This can send our calcualtions off, so profile for it.
                                          //if (GL_Profiling)
                                          //      cout << "~ PROFILING: ReadProcessMemory() failed" << endl;

                                          // Failed again.
                                          FailCount++;

                                          // Just incase we get stuck in a loop forever...
                                          if (FailCount==MAX_FAIL_RPM_COUNT) {
                                                NumRead=0;                  // So we will have to skip this.
                                                break;                        // No more trying.
                                          }

                                          // Sleep a little to give party a chance to unlock the mem.
                                          Sleep(FAIL_RPM_SLEEP);
                                    };

                                    // -----------------------------------------------------------------#
                                    // v0.03: Optimize this as much as possible (core).

                                    // Have we at least got a big enough region to be useful
                                    if (NumRead>=strlen("#Game No :  ")) {

                                          //  Check if region contain search string.
                                          // v0.03: Optimized (Crappy VC6++ compilier don't like strlen in for)...
                                          //        - Note: Using Boyer-Moore etc, not gona help much here...
                                          register unsigned int MaxLen=NumRead-strlen("#Game No :  ");
                                          for (register unsigned int I=0;I<MaxLen;I+=GL_StringAlignment) {

                                                // Look for "#Game No : " - Don't use stncmp - slow as fuck...
                                                // v0.04: Use the fact always alligned to just check via a 32bit comp.
                                                //        NOTE: Will even cast to non-aligned int, but will be slower.
                                                if ((*((unsigned int*)(&Buffer[I]))) == ((((unsigned int)'m')<<24)
                                                                                                            |(((unsigned int)'a')<<16)
                                                                                                            |(((unsigned int)'G')<<8)
                                                                                                            |(((unsigned int)'#'))) // Remember: big-endian...
                                                      && Buffer[I+4]=='e'
                                                      && Buffer[I+5]==' '
                                                      && Buffer[I+6]=='N'
                                                      && Buffer[I+7]=='o'
                                                      && Buffer[I+8]==' '
                                                      && Buffer[I+9]==':'
                                                      && Buffer[I+10]==' '
                                                      && Buffer[I+11]>='0'
                                                      && Buffer[I+11]<='9') {

                                                      // Does it have the stars?
                                                      bool HasStars=false;
                                                      for (unsigned int S=I+1+strlen("#Game No :  ");S<NumRead-1;S++) {
                                                            if (Buffer[S]=='\n') {
                                                                  if (Buffer[S+1]=='*')
                                                                        HasStars=true;
                                                                  break;
                                                            }
                                                      }
                                                      if (!HasStars)
                                                            continue;

                                                      // Look for terminating " wins ".
                                                      // v0.04: Only bother if not in realtime mode.
                                                      for (unsigned int J=I+1+strlen("#Game No :  ");J<NumRead-(GL_WriteRealTime==true?0:strlen(" wins "));J++) {

                                                            // Stop if we hit a non-ascii char (10/13 = CR/NL).
                                                            if (Buffer[J]!=10 && Buffer[J]!=13 && (Buffer[J]<32 || Buffer[J]>127)) {
                                                                  //!isascii(Buffer[J])) {
                                                                  I=J;

                                                                  // v0.04: Must make sure we re-align upwards.
                                                                  if (I%GL_StringAlignment!=0)
                                                                        I+=(GL_StringAlignment-(I%GL_StringAlignment));

                                                                  break;
                                                            }

                                                            // v0.04: Terminate on "\n\0" if in realtime mode.
                                                            if ((GL_WriteRealTime==false
                                                                  && Buffer[J]==' '
                                                                  && Buffer[J+1]=='w'
                                                                  && Buffer[J+2]=='i'
                                                                  && Buffer[J+3]=='n'
                                                                  && Buffer[J+4]=='s'
                                                                  && Buffer[J+5]==' ')
                                                                  || (GL_WriteRealTime==true
                                                                        && Buffer[J]=='\n'
                                                                        && Buffer[J+1]==0)) {

                                                                  // WE HAVE FROUND THE START OF A NEW GAME!
                                                                  // LOOK for wins, then break on first non-asci char found.
                                                                  // v0.04: Note the -1 in the expresion is to send us back so we refind the
                                                                  //        "\n\0" if in realtime mode (###bit hacky... fix later###).
                                                                  for (unsigned int K=J+1+(GL_WriteRealTime==true?-1:strlen(" wins "));K<NumRead-1;K++) {
                                                                        if (Buffer[K]=='\n' && Buffer[K+1]==0) {

                                                                              // See if this is a full hand.
                                                                              if(HandleTableData(&Buffer[I],(K-I)+1)) {

                                                                                    // v0.03: Used to try to fins a better footprint.for the pages.
                                                                                    if (GL_Profiling==true) {

                                                                                          // Look for footprint info to help.
                                                                                          static unsigned int MaxRegionSize=0;
                                                                                          static unsigned int MinRegionSize=~0;
                                                                                          if (MBI.RegionSize<MinRegionSize)
                                                                                                MinRegionSize=MBI.RegionSize;
                                                                                          if (MBI.RegionSize>MaxRegionSize)
                                                                                                MaxRegionSize=MBI.RegionSize;
                                                                                          cout << "~ PROFILING: RegionSize=" << hex << "0x" << MBI.RegionSize
                                                                                                 << " (Range: [0x" << MinRegionSize
                                                                                                 << " .. 0x" << MaxRegionSize << "])" << dec << endl;

                                                                                          // Where was the hand?
                                                                                          cout << "~ PROFILING: Found at 0x" << hex << (unsigned int)MBI.BaseAddress+(unsigned int)I
                                                                                                 << " (base=" << MBI.BaseAddress << " / size=0x" << NumRead << " / " << ((double)I/(double)NumRead)*100.0 << "% in)" << dec << endl;
                                                                                    }

                                                                                    // ### V0.03: Is it better to restart or continue through pages
                                                                                    // ###        now we have a better terminator expression?
                                                                                    // ###        - Also makes profiling hard...
                                                                                    // ###        - In theory, if we don't do this then the monotonic assumptions
                                                                                    // ###          could fail, and we lose a hand (big deal?).
                                                                                    //return true;            // So we can start search again...
                                                                              
                                                                              }

                                                                              J=K+1;
                                                                              break;
                                                                              
                                                                        }
                                                                  }

                                                                  I=J;

                                                                  // v0.04: Must make sure we re-align upwards.
                                                                  if (I%GL_StringAlignment!=0)
                                                                        I+=(GL_StringAlignment-(I%GL_StringAlignment));

                                                                  break;

                                                            }

                                                      } //  End match "#Game No : ".

                                                } // End For.

                                          } // End match "#Game No : ".

                                    } // End if (NumRead>=strlen("#Game No :  ").

                                    // ------------------------------------------------------------------#
                              }

                        }

                        // Increase base address for next searching cicle. Last address may overhead max Long value (Windows use 2GB memory, which is near max long value), so add Error checking
                        CurrentAddress = (void*)((DWORD)MBI.BaseAddress + (DWORD)MBI.RegionSize);

                  } // End while more chunks.

                  CloseHandle(hProcess);

            }      // 0.04b: While loop to scan multiple party processes (if they exist).

      } // End PartyMemoryScanner.

      // ---------------------------------------------------------------------------------
      // ------------------------------- PUBLIC MEMBERS ----------------------------------
      // ---------------------------------------------------------------------------------
      public:

      void StartLoop(void)
      {                  
            // Keep going until we lose the party process.
            while(1) {
                  
                  // v0.5: First lets try scanning for Party.
                  PartyMemoryScanner("PartyPoker.com:");

                  // v0.5: Next lets check for Empire.
                  PartyMemoryScanner("EmpirePoker:");

                  // Lets rest the CPU.
                  Sleep(GL_Delay);
            }
      }

}; // End PartyHandGrabber class.

// ========================================================================================

void ParseArgs(int argc,char** argv)
{      // This function will parse the command line arguments.

      for (int I=1;I<argc;I++) {

            // v0.04: Is this the realtime write to file flag?
            if (strcmp(argv[I],"-r")==0) {
                  GL_WriteRealTime=true;
            }

            // v0.03: Is this the profiling flag?
            // v0.04: ### BUG: Forgot to add the else, was just an if...
            else if (strcmp(argv[I],"-prof")==0) {
                  GL_Profiling=true;
            }

            // v0.02: Is this the silent flag?
            else if (strcmp(argv[I],"-s")==0) {
                  GL_Verbose=false;
            }

            // Is this the verbose flag (?
            else if (strcmp(argv[I],"-v")==0) {
                  GL_Verbose=true;            // v0.02: Now does nothing... Verbose default.
            }

            // Is this telling us the delay?
            else if (strcmp(argv[I],"-d")==0 && I<argc-1) {
                  GL_Delay=atol(argv[I+1]);
                  if (GL_Delay<0 || GL_Delay>10000) {
                        cout << "Syntax: p_grabber [-s] [-prof] [-r] [-d DelayMS] [-e Extention] [-a AlignBits] [-p Priority]" << endl
                               << "> DelayMS must be in the range 0 to 10000ms [default: 1000ms]." << endl;
                        exit(1);
                  }
                  I++;                                    // Skip 2nd argument.
            }

            // Is this telling us the extention?
            else if (strcmp(argv[I],"-e")==0 && I<argc-1) {
                  if (strlen(argv[I+1])<=1 || strlen(argv[I+1])>3) {
                        cout << "Syntax: p_grabber [-s] [-prof] [-r] [-d DelayMS] [-e Extention] [-a AlignBits] [-p Priority]" << endl
                             << "> Extention must contain 1, 2 or 3 characters [default: \"hhf\"]." << endl;
                        exit(1);
                  }
                  strcpy(GL_Extention,argv[I+1]);
                  I++;                                    // Skip 2nd argument.
            }

            // v0.04: Is this telling us a new string allignment?
            else if (strcmp(argv[I],"-a")==0 && I<argc-1) {
                  GL_StringAlignment=atol(argv[I+1]);
                  if (GL_StringAlignment!=1 && GL_StringAlignment!=2 && GL_StringAlignment!=4
                        && GL_StringAlignment!=8 && GL_StringAlignment!=16) {
                        cout << "Syntax: p_grabber [-s] [-prof] [-r] [-d DelayMS] [-e Extention] [-a AlignBits] [-p Priority]" << endl
                               << "> AlignBits must be 1, 2, 4, 8 or 16 [default: 8]." << endl;
                        exit(1);
                  }
                  I++;                                    // Skip 2nd argument.
            }

            // v0.04: Is this telling us a new priority?
            else if (strcmp(argv[I],"-p")==0 && I<argc-1) {
                  GL_Priority=atol(argv[I+1]);
                  if (GL_Priority<-2 || GL_Priority>2) {
                        cout << "Syntax: p_grabber [-s] [-prof] [-r] [-d DelayMS] [-e Extention] [-a AlignBits] [-p Priority]" << endl
                               << "> Priority must be -2, -1, 0, 1 or 2 [default: 0]." << endl;
                        exit(1);
                  }
                  I++;                                    // Skip 2nd argument.
            }

            // Must be invalid arguments then.
            else {
                  cout << "Syntax: p_grabber [-s] [-prof] [-r] [-d DelayMS] [-e Extention] [-a AlignBits] [-p Priority]" << endl;
                  exit(1);
            }

      }

}      // End ParseArgs.

// ========================================================================================

DWORD WINAPI MainThread(void *Param)
{      // Used so we can start with different priorities (saves messing with the batch file).

      static PartyHandGrabber PHG;

      // Start the main loop (never returns...).
      PHG.StartLoop();

      // ### NEVER RETURNS - BUT MIGHT BE USEFUL IF WE ONE DAY ADD A GUI ###
      //ExitThread(0);
      return 0;
}

// ========================================================================================

void DisplayStartupInfo(void)
{      // Displays the parameters we are using.
      cout << "# FreePHG v0.05 started." << endl << endl;

    cout << "> File Extention   : \"." << GL_Extention << "\"" << endl;
      cout << "> Scanning Delay   : " << GL_Delay << "ms" << endl;
      cout << "> Process Priority : ";
      if (GL_Priority==-2)
            cout << "Low" << endl;
      else if (GL_Priority==-1)
            cout << "BelowNormal" << endl;
      else if (GL_Priority==0)
            cout << "Normal" << endl;
      else if (GL_Priority==1)
            cout << "AboveNormal" << endl;
      else if (GL_Priority==2)
            cout << "High" << endl;
      cout << "> Real Time Logs   : " << (GL_WriteRealTime?"ON":"OFF") << endl;
       cout << "> Profiling Mode   : " << (GL_Profiling?"ON":"OFF") << endl;
    cout << "> String Alignment : " << GL_StringAlignment << "bytes" << endl;

      cout << endl << "# Waiting for tables..." << endl << endl;
}

// ========================================================================================

int main(int argc, char** argv)
{

      DWORD ThreadID;      // Unused, but must have for win9x...
      HANDLE ThreadHandle;

      // Parse the arguments.
      ParseArgs(argc,argv);

      // Display something just to let the user know that we have started.
      if (GL_Verbose==true)
            DisplayStartupInfo();

      // Start the thread.
      ThreadHandle=CreateThread(NULL,0,MainThread,0,0,&ThreadID);

      // Set the desired priority of the thread.
      if (GL_Priority==-2)
            SetThreadPriority(ThreadHandle,THREAD_PRIORITY_LOWEST);
      else if (GL_Priority==-1)
            SetThreadPriority(ThreadHandle,THREAD_PRIORITY_BELOW_NORMAL);
      else if (GL_Priority==0)
            SetThreadPriority(ThreadHandle,THREAD_PRIORITY_NORMAL);
      else if (GL_Priority==1)
            SetThreadPriority(ThreadHandle,THREAD_PRIORITY_ABOVE_NORMAL);
      else if (GL_Priority==2)
            SetThreadPriority(ThreadHandle,THREAD_PRIORITY_HIGHEST);

      // Lets just let the thread do it's work (just idle here forever).
      WaitForSingleObject(ThreadHandle,INFINITE);

      return 0;
}

Thanks for any help.

-RJM
quamusaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JoshdanGCommented:
Try adding the following after your includes.  That should at least cut down on some of the errors, dunno about all.

using namespace std;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
quamusaAuthor Commented:
Might be getting somewhere... replacing the includes chunk with this:

#include "stdafx.h"
#include <windows.h>
using namespace std;
#include <process.h>
using namespace std;
#include <fstream>
using namespace std;
#include <stdio.h>
using namespace std;



Yields these errors:

------ Build started: Project: FreePHG, Configuration: Debug Win32 ------
Compiling...
FreePHG.cpp
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(69) : error C2871: 'std' : a namespace with this name does not exist
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(71) : error C2871: 'std' : a namespace with this name does not exist
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(374) : error C2065: 'cout' : undeclared identifier
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(874) : error C2563: mismatch in formal parameter list
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(874) : error C2568: '<<' : unable to resolve function overload
        c:\program files\microsoft visual studio 8\vc\include\ostream(971): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
        with
        [
            _Elem=wchar_t,
            _Traits=std::char_traits<wchar_t>
        ]
        c:\program files\microsoft visual studio 8\vc\include\ostream(963): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>
        ]
        c:\program files\microsoft visual studio 8\vc\include\ostream(937): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
Build log was saved at "file://c:\Documents and Settings\rmoore\Desktop\v0.05\Debug\BuildLog.htm"
FreePHG - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
0
quamusaAuthor Commented:
Changed includes chunk to this:

#include "stdafx.h"
#include <windows.h>
#include <process.h>            // So we can use threads.
#include <fstream>
#include <iostream>
//#include <stdio>
using namespace std;

(adding iostream in place of stdio) and the thing compiles and runs.  However, I still get these warnings, which I would like to address:------ Build started: Project: FreePHG, Configuration: Debug Win32 ------
Compiling...
FreePHG.cpp
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(317) : warning C4996: 'sprintf' was declared deprecated
        c:\program files\microsoft visual studio 8\vc\include\stdio.h(345) : see declaration of 'sprintf'
        Message: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(381) : warning C4996: 'strcpy' was declared deprecated
        c:\program files\microsoft visual studio 8\vc\include\string.h(73) : see declaration of 'strcpy'
        Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(382) : warning C4996: 'strcpy' was declared deprecated
        c:\program files\microsoft visual studio 8\vc\include\string.h(73) : see declaration of 'strcpy'
        Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(415) : warning C4996: 'strcpy' was declared deprecated
        c:\program files\microsoft visual studio 8\vc\include\string.h(73) : see declaration of 'strcpy'
        Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
c:\documents and settings\rmoore\desktop\v0.05\freephg.cpp(797) : warning C4996: 'strcpy' was declared deprecated
        c:\program files\microsoft visual studio 8\vc\include\string.h(73) : see declaration of 'strcpy'
        Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
Compiling manifest to resources...
Linking...
Embedding manifest...
Build log was saved at "file://c:\Documents and Settings\rmoore\Desktop\v0.05\Debug\BuildLog.htm"
FreePHG - 0 error(s), 5 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

quamusaAuthor Commented:
Nevermind, those were obvious fixes... program now compiles without error... guess I solved my own problem, thanks for the guidance
0
Jase-CoderCommented:
>> Nevermind, those were obvious fixes... program now compiles without error... guess I solved my own problem, thanks for the guidance

the other guy told you how to fix the problem so you should accept his answer!
0
quamusaAuthor Commented:
Yeah sorry about that, I got so excited with the fix i've been programming all night and forgot about the points!  Thanks again for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.