My .dat Modifier program.

This is a discussion on My .dat Modifier program. within the C++ Programming forums, part of the General Programming Boards category; Hello, i have done this program in about 5 minutes. I was trying to modify a .dat file to actually ...

  1. #1
    kevinawad
    Guest

    My .dat Modifier program.

    Hello, i have done this program in about 5 minutes. I was trying to modify a .dat file to actually (Basic hack) a small game called Cave story.

    Here's the code if anyone is curious about .dat files .

    Code:
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    
    struct CaveStoryDat
    {
    	int str[50];
    };
    
    int main()
    {
    	CaveStoryDat dat;
    
    	int choice = 0;
    	int value = 0;
    	int number = 0;
    
    	int foundvalues[50];
    
    	ifstream filer;
    	ofstream filew;
    
    	filer.open("Profile.dat", ios::binary);
    	filer.read((char*)&dat, sizeof(CaveStoryDat));
    	filer.close();
    
    
    	while(1)
    	{
    
    		system("cls");
    
    		for(int i = 0; i < 50; i++)
    		{
    			cout << i <<"| "<<dat.str[i]<<" | "<<endl;
    		}
    
    		cout <<"\n\n\n";
    
    		cout <<"1.Search values."<<endl;
    		cout <<"2.Modify values."<<endl;
    		cout <<"3.Save File."<<endl;
    		cout <<"4.Reload file."<<endl;
    
    		cin >> choice;
    		cin.get();
    
    		switch(choice)
    		{
    
    		case 1:
    			system("cls");
    			cout <<"Exact value?: "<<endl;
    			cin >> value;
    			cin.get();
    			system("cls");
    			for(int i = 0; i < 50; i++)
    			{
    				if(dat.str[i] == value)
    				{
    					foundvalues[i] = dat.str[i];
    				}
    
    			}
    
    			for(int i = 0; i < 50; i++)
    			{
    				if(foundvalues[i] == value)
    				{
    					cout << i <<"| "<<foundvalues[i]<<" | "<<endl;
    				}
    
    			}
    
    			choice = 0;
    			cin.get();
    			break;
    
    
    		case 2:
    
    			cout <<"Number?: ";
    			cin >> number;
    
    			cin.get();
    			system("cls");
    
    			cout <<"Value: "<<dat.str[number]<<endl;
    			cout <<"Modify it's value to?: "<<endl;
    			cin >> value;
    			cin.get();
    
    			dat.str[number] = value;
    
    			break;
    
    
    		case 3:
    
    			filew.open("Profile.dat", ios::binary);
    			filew.write((char*)&dat, sizeof(CaveStoryDat));
    			filew.close();
    
    		case 4:
    			filer.open("Profile.dat", ios::binary);
    			filer.read((char*)&dat, sizeof(CaveStoryDat));
    			filer.close();
    
    
    		}
    
    
    
    
    	}
    
    	return 0;
    
    }

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    683
    You do realize that any file can contain any data, and that extensions do not tell what kind of data will be in the file? extensions are used to associate files with software(at least in windows).

  3. #3
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    6,819
    Quote Originally Posted by kevinawad View Post
    Here's the code if anyone is curious about .dat files .
    lern2research
    Quote Originally Posted by phantomotap
    Can you write code while blindfolded only with the blind covering your brain? Can you code while brainfolded?

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,699
    Quote Originally Posted by Raigne View Post
    You do realize that any file can contain any data, and that extensions do not tell what kind of data will be in the file? extensions are used to associate files with software(at least in windows).
    I know you are a Windows guy, Raigne. Just so you are aware, in Linux, Unix and MacOSX the OS just uses the file headers to determine the type.

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    683
    I stand corrected in one aspect then. I apologize OP

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,699
    Its unfortunate that windows doesn't just use file headers to determine type. So many viri could be twarted....

  7. #7
    Registered User
    Join Date
    Nov 2005
    Posts
    683
    Many existing virus's could be stopped, but the way windows is it would open the door for a million more.

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,699
    True. Knowing Microsoft, if it encountered a .vs file it would just start executing it during the reading the file-header process.

  9. #9
    kevinawad
    Guest
    I meant binary data reader :P. Forgot to say so.

    Most of the games use binary to save game files. You can read it with any Hex editor. But, you can also read it with a sample fstream function.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,699
    Speak for yourself, I read binary all the time...

  11. #11
    kevinawad
    Guest
    , first time having to do anything with binary files.

    It's great that i learned one more thing about the computer.

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,699
    There are some issues with binary files that you will discover one day. But for today, I will let you enjoy the glory

  13. #13
    Registered User
    Join Date
    Nov 2005
    Posts
    683
    There are some issues with binary files that you will discover one day
    If you don't know about the issues ahead of time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21