|
-
Aug 3rd, 2002, 08:39 PM
#1
Thread Starter
Addicted Member
-
Aug 3rd, 2002, 08:45 PM
#2
PowerPoster
What compiler are you using? Just put a lot of debugging information in your exe and it'll increase the file size by somewhat.
PS: People actually try to decrease the file size and you're increasing it?
-
Aug 3rd, 2002, 08:57 PM
#3
Thread Starter
Addicted Member
.
Im using dev C++, but i dont want to make a big program, i want a normal sized program that increases the size of a different program :P
When you ask a question, try and answer a few 
-
Aug 5th, 2002, 12:11 PM
#4
Monday Morning Lunatic
Re: Increase file size
You should just be able to open it as a binary file then append 100 NULL bytes to it:
Code:
#include <iostream>
using namespace std;
int main() {
ofstream output("program.exe", ios::binary | ios::append);
char block[100];
memset(block, 0, 100); // i think this is the right way round...
output.seekg(ios::end, 0);
output.write(block, 100);
}
...that's just typed straight into the reply box so I'm not sure if it'll compile -- the theory should work though. I did some work on self-extracting archives and never had any problems by just appending the data to a stub program.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2002, 11:38 AM
#5
Ya ya Baby!!!Me is Back
***Time out***
Explaine me that line please : put.seekg(ios::end, 0);
-
Aug 7th, 2002, 11:40 AM
#6
Monday Morning Lunatic
.seekg goes to a specific location in the file. You give a position and an offset, the position is either the start, end, or current position, and the offset is how far away from that.
The documentation for seekg() will give you the details
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2002, 12:19 PM
#7
Ya ya Baby!!!Me is Back
seekg = input
seekp = output
-
Aug 7th, 2002, 12:23 PM
#8
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2002, 12:37 PM
#9
Ya ya Baby!!!Me is Back
Here is the program and it work but I have a problem by the determination of the size to increment. I wanted the user write the number of null character he wants in the third arguments but I wanted that in Ko so I *1024 but that doesn't increment well.
PHP Code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
void main(int argc, char* argv[])
{
// 0 = name, 1 = file, 2 = size
if (argc != 3)
{
cout << "Missing argument";
exit(0);
}//End if
ofstream fileOut(argv[1], ios::binary | ios::app);
//Si le fichier n'existe pas alors on quitte
if (!fileOut)
{
cout << "File not found";
exit(0);
}//End if
/****Problem is here to calculate in ko****/
unsigned int iSize = (atoi(argv[2]))*1024;
char *cData = new char[iSize];
memset(cData, 0, iSize);
fileOut.seekp(0,ios::end);
fileOut.write(cData,fileOut.tellp());
fileOut.close();
}//End Main
But that code can be compiled without problem.
Daok
-
Aug 7th, 2002, 02:13 PM
#10
Ya ya Baby!!!Me is Back
Here is the final version and all work correctly without any problem.
PHP Code:
#include <fstream>
#include <iostream>
#include <string>
//#include <time.h>
#include <windows.h>
using namespace std;
void main(int argc, char* argv[])
{
// 0 = name, 1 = file, 2 = size
if (argc != 3)
{
cout << "Error : Missing argument" << endl;
exit(0);
}//End if
ofstream fileOut(argv[1], ios::binary | ios::app);
//Si le fichier n'existe pas alors on quitte
if (!fileOut)
{
cout << "Error : File not found" << endl;
exit(0);
}//End if
if (atoi(argv[2]) > 10240)
{
cout << "Error : Can not enlarge more than 10 megs each time";
exit(0);
}//End if
unsigned int iSize = (atoi(argv[2]) * 1024);
char *cData = new char[iSize];
memset(cData, 0, iSize);
fileOut.seekp(fileOut.tellp());
fileOut.write(cData,iSize);
fileOut.close();
string cMessage[] = {"Copyright Daok","Daok Production", "Daok Own Ya"};
DWORD dwStart = GetTickCount();
/*srand((unsigned)time(NULL));
cout << cMessage[rand() % 3] << endl;
*/
cout << cMessage[dwStart % 3] << endl;
}//End Main
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|