Could someone please test this C++ program for me?
I've written these fairly straightforward programs. What the test.exe does is it opens a file called DoNothing.exe an executable (a PE binary file). It does that fine. Then it reads the contents of the DoNothing.exe file into a buffer which seems to work fine also. Then after that I attempt to search for a string from the above buffer which starts with a '$' and ends with a '$' separated by other characters. I then iterate through the buffer and modify the contents of this string. So its essentially replaces the exact same number of characters of this string not adding any additional characters and no less characters either. So it seems to do that fine. Now I attempt to write the contents of the buffer (which as been modified with the new string) to a new file called DoNothing1.exe. The names of the files are arbitrary. Following the creation of the DoNothing1.exe file I attempt to see if this file runs fine without any errors and if the program displays the new string. for a while the DoNothing1.exe was executing fine but the old string kept being displayed and so I assumed the string was not being modified with the new one. I am encouraging if someone can run this same code to see if works for them. It seems I get inconsistent results. Now I know about modifying a text fle which is fine but I am ken on learning how to modify an executable. So please suggestions would be appreciated and by all means see if this test code would work for them. The error message that I ma getting is the following: 

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

E:\DEVS\Projects\JustTesting\Test\Release>donothing1.exe
Program too big to fit in memory

-----------------------------------------------------------
    // program 1 Call it Donothing.exe

    #include <iostream>

    using namespace std;

    char VarB[] = "$#$%^&*()_+=-{}][&|<>?$*$";

    void main()
    {	
	cout << VarB << endl;
    }

    // program 2 Call it Test.exe

    #include <afx.h>
    #include <windows.h>
    #include <iostream>


    CString ModifyCurrentPath(char * pFileName);

    #define MAX_SIZE    100000

    using namespace std;

    void main()
    {
        int i, j;
        HANDLE hFile;
        char bufferReturned[100000];
        char buffer[MAX_PATH];
        CString strExist;
        CString strNew;
        char * ptr = NULL;
        unsigned long nNumberOfBytesRead = 0;
        unsigned long nNumberOfBytesWritten = 0;
        OFSTRUCT OFSTRUCT_STRUCT = {0};
    
        char * szExistFileName = "DoNothing.exe";
        char * szNewFileName = "DoNothing1.exe";

        strExist.Empty();
        strExist = ModifyCurrentPath(szExistFileName);

        hFile = CreateFile ( strExist.GetBuffer(strExist.GetLength()), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);

        if(hFile == INVALID_HANDLE_VALUE)
        {
            cout << "Error opening the file" << endl;
            cout << GetLastError() << endl;
            exit(1);
        }
        cout << "Successfully opened a file" << endl;

        ReadFile(hFile, bufferReturned, MAX_SIZE, &nNumberOfBytesRead, NULL);
    
        buffer[nNumberOfBytesRead] = '\0';

        cout << nNumberOfBytesRead << endl;

        for(i = 0; i < nNumberOfBytesRead; i++)
        {
            if((buffer[i] == '$') && (buffer[i + 24] == '$'))
            {
                cout << "found the string" << endl;
                for(j = i; j < i + 24; j++)
                {
                    buffer[j] = 'A';
                }
                break;    
            }
        }
        cout << endl;
        CloseHandle(hFile);

        strNew.Empty();
        strNew = ModifyCurrentPath(szNewFileName);
    
        hFile = CreateFile ( strNew.GetBuffer(strNew.GetLength()), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);

        if(WriteFile(hFile, buffer, (nNumberOfBytesRead), &nNumberOfBytesWritten,NULL))
        {
            if( nNumberOfBytesRead == nNumberOfBytesWritten)
                cout << "success in writing file" << endl;
            else
                cout << "write attempt failed" << endl;
        }    
        CloseHandle(hFile);
        exit(0);
    }

    CString ModifyCurrentPath(char * pFileName)
    {
        int index;
        CString strRet;
        char buffer[MAX_PATH];
    
        GetModuleFileName( NULL, buffer, MAX_PATH );
        strRet = buffer;

        index  = strRet.ReverseFind('\\');

        strRet = strRet.Left(index + 1);
        strRet = strRet + pFileName;

        return strRet;    
}
Could someone please test this C++ program for me?
===

I've written these fairly straightforward programs. What the test.exe does is it opens a file called DoNothing.exe an executable (a PE binary file). It does that fine. Then it reads the contents of the DoNothing.exe file into a buffer which seems to work fine also. Then after that I attempt to search for a string from the above buffer which starts with a '$' and ends with a '$' separated by other characters. I then iterate through the buffer and modify the contents of this string. So its essentially replaces the exact same number of characters of this string not adding any additional characters and no less characters either. So it seems to do that fine. Now I attempt to write the contents of the buffer (which as been modified with the new string) to a new file called DoNothing1.exe. The names of the files are arbitrary. Following the creation of the DoNothing1.exe file I attempt to see if this file runs fine without any errors and if the program displays the new string. for a while the DoNothing1.exe was executing fine but the old string kept being displayed and so I assumed the string was not being modified with the new one. I am encouraging if someone can run this same code to see if works for them. It seems I get inconsistent results. Now I know about modifying a text fle which is fine but I am ken on learning how to modify an executable. So please suggestions would be appreciated and by all means see if this test code would work for them. The error message that I ma getting is the following: 

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

E:\DEVS\Projects\JustTesting\Test\Release>donothing1.exe
Program too big to fit in memory

-----------------------------------------------------------
    // program 1 Call it Donothing.exe

    #include <iostream>

    using namespace std;

    char VarB[] = "$#$%^&*()_+=-{}][&|<>?$*$";

    void main()
    {	
	cout << VarB << endl;
    }

    // program 2 Call it Test.exe

    #include <afx.h>
    #include <windows.h>
    #include <iostream>


    CString ModifyCurrentPath(char * pFileName);

    #define MAX_SIZE    100000

    using namespace std;

    void main()
    {
        int i, j;
        HANDLE hFile;
        char bufferReturned[100000];
        char buffer[MAX_PATH];
        CString strExist;
        CString strNew;
        char * ptr = NULL;
        unsigned long nNumberOfBytesRead = 0;
        unsigned long nNumberOfBytesWritten = 0;
        OFSTRUCT OFSTRUCT_STRUCT = {0};
    
        char * szExistFileName = "DoNothing.exe";
        char * szNewFileName = "DoNothing1.exe";

        strExist.Empty();
        strExist = ModifyCurrentPath(szExistFileName);

        hFile = CreateFile ( strExist.GetBuffer(strExist.GetLength()), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);

        if(hFile == INVALID_HANDLE_VALUE)
        {
            cout << "Error opening the file" << endl;
            cout << GetLastError() << endl;
            exit(1);
        }
        cout << "Successfully opened a file" << endl;

        ReadFile(hFile, bufferReturned, MAX_SIZE, &nNumberOfBytesRead, NULL);
    
        buffer[nNumberOfBytesRead] = '\0';

        cout << nNumberOfBytesRead << endl;

        for(i = 0; i < nNumberOfBytesRead; i++)
        {
            if((buffer[i] == '$') && (buffer[i + 24] == '$'))
            {
                cout << "found the string" << endl;
                for(j = i; j < i + 24; j++)
                {
                    buffer[j] = 'A';
                }
                break;    
            }
        }
        cout << endl;
        CloseHandle(hFile);

        strNew.Empty();
        strNew = ModifyCurrentPath(szNewFileName);
    
        hFile = CreateFile ( strNew.GetBuffer(strNew.GetLength()), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);

        if(WriteFile(hFile, buffer, (nNumberOfBytesRead), &nNumberOfBytesWritten,NULL))
        {
            if( nNumberOfBytesRead == nNumberOfBytesWritten)
                cout << "success in writing file" << endl;
            else
                cout << "write attempt failed" << endl;
        }    
        CloseHandle(hFile);
        exit(0);
    }

    CString ModifyCurrentPath(char * pFileName)
    {
        int index;
        CString strRet;
        char buffer[MAX_PATH];
    
        GetModuleFileName( NULL, buffer, MAX_PATH );
        strRet = buffer;

        index  = strRet.ReverseFind('\\');

        strRet = strRet.Left(index + 1);
        strRet = strRet + pFileName;

        return strRet;    
}