You are viewing our Forum Archives. To view or take place in current topics click here.
[C++] Gears 2 Screenshot Tool
Posted:
[C++] Gears 2 Screenshot ToolPosted:
Status: Offline
Joined: Jun 12, 201014Year Member
Posts: 531
Reputation Power: 33
Got bored, wanted to code something.
Before loading:
[ Register or Signin to view external links. ]
After loading:
[ Register or Signin to view external links. ]
Executable: [ Register or Signin to view external links. ]
Source: [ Register or Signin to view external links. ] (**** huge because of the Intellisense database)
Also, this was really annoying because last time I tried doing this I did it in a console app but it caused the screenshot to turn out corrupt and couldn't figure out why. I did it again this time, but figure out the problem was that I forgot to open the output file as binary ("wb+" vs. "w+"). GOT ALL DAT SORTED OUT NOW.
Before loading:
[ Register or Signin to view external links. ]
After loading:
[ Register or Signin to view external links. ]
Executable: [ Register or Signin to view external links. ]
Source: [ Register or Signin to view external links. ] (**** huge because of the Intellisense database)
Also, this was really annoying because last time I tried doing this I did it in a console app but it caused the screenshot to turn out corrupt and couldn't figure out why. I did it again this time, but figure out the problem was that I forgot to open the output file as binary ("wb+" vs. "w+"). GOT ALL DAT SORTED OUT NOW.
#2. Posted:
Status: Offline
Joined: May 07, 201113Year Member
Posts: 3,380
Reputation Power: 155
Status: Offline
Joined: May 07, 201113Year Member
Posts: 3,380
Reputation Power: 155
can you make me a small program if i paid??!??!?!?!
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Jun 12, 201014Year Member
Posts: 531
Reputation Power: 33
TTG-Rylie16 wrote can you make me a small program if i paid??!??!?!?!
If you want to PM me the details I'd be happy to talk to you about it.
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: May 07, 201113Year Member
Posts: 3,380
Reputation Power: 155
Status: Offline
Joined: May 07, 201113Year Member
Posts: 3,380
Reputation Power: 155
okay i did check your pms!
- 0useful
- 0not useful
#5. Posted:
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
Status: Offline
Joined: Jan 24, 201014Year Member
Posts: 1,478
Reputation Power: 106
that bear is looking sexy clk
get bored again? Try and do it in native C++ 8)
get bored again? Try and do it in native C++ 8)
- 0useful
- 0not useful
#6. Posted:
Status: Offline
Joined: Jun 12, 201014Year Member
Posts: 531
Reputation Power: 33
-Derp wrote that bear is looking sexy clk
get bored again? Try and do it in native C++ 8)
This is actually an [ Register or Signin to view external links. ] app :p
Sooo... it is native. The console app I was working on a loooonnnggg time ago was coded very bad but has basically the same functionality
header file:
#ifndef gears_h
#define gears_h
#include <iostream>
#include <fstream>
#include "string.h"
using namespace std;
unsigned int MakeUInt32(char* dicks);
struct GearsHeader
{
char* InternalGameType;
char* FriendlyGameType;
char* InternalMapName;
char* FriendlyMapName;
// there's more here, but i don't feel like mapping it out
};
#endif
Main class:
// Gears 2 Screenshot Extractor.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "gears.h"
#define HEADEROFFSET 0xD000
#define IMAGEOFFSET 0xE000
typedef unsigned char BYTE;
// Declare the size buffer
struct SizeStruct
{
char* SizeBuffer;
__declspec(property(get = GetSize)) int Size;
int GetSize()
{
int Value = 0;
for (int i = 0, shift = 24; i < 4; i++, shift-=8)
{
Value |= (int)*(SizeBuffer + i) << shift;
}
return Value;
};
};
int _tmain(int argc, char* argv[])
{
if (argc == 1)
{
cout << "Exiting, did not pass file" << endl;
return 1;
}
else if (argc == 2)
{
cout << "Did not pass output file" << endl;
}
// Open our file for reading.
FILE* File = fopen(argv[1], "rb");
// Check to make sure the path was valid...
if (!File)
{
cout << "File path not valid!" << endl;
return 2;
}
SizeStruct* ss = new SizeStruct();
ss->SizeBuffer = new char[0x4];
/* Header Data */
// Seek to the header offset + 0x10 from the beginning of the file (SEEK_SET)
fseek(File, HEADEROFFSET + 0x10, SEEK_SET);
// Initialize the Gears Header
GearsHeader* gh = new GearsHeader();
// Read the internal game mode name size
fread(ss->SizeBuffer, 1, 0x4, File); // Internal game mode size
// Declare internal game type
gh->InternalGameType = new char[ss->Size + 1];
// Read the internal game type name
fread(gh->InternalGameType, 1, ss->Size, File); // Internal game mode name
// Read the friendly game mode name size
fread(ss->SizeBuffer, 1, 4, File); // Friendly game mode size
// Declare friendly game type
gh->FriendlyGameType = new char[ss->Size + 1];
// Read the friendly game mode name
fread(gh->FriendlyGameType, 1, ss->Size, File); // Friendly game mode name
// Jump forward 8 bytes
fseek(File, 0x8, SEEK_CUR);
// Read the internal map name size
fread(ss->SizeBuffer, 1, 4, File); // Internal map size
// Declare internal map name
gh->InternalMapName = new char[ss->Size + 1];
// Read the internal map name
fread(gh->InternalMapName, 1, ss->Size, File); // Internal map name
// Read the friendly map name size
fread(ss->SizeBuffer, 1, 4, File); // Friendly map size
// Declare friendly map name
gh->FriendlyMapName = new char[ss->Size + 1];
// Read the friendly map name
fread(gh->FriendlyMapName, 1, ss->Size, File); // Friendly map name
/* Image Data */
// Seek to where the entry size is
fseek(File, 0xC074, SEEK_SET);
// Read the value there
fread(ss->SizeBuffer, 1, 4, File);
int size = ss->Size;
// Seek back to the image offset
fseek(File, IMAGEOFFSET, SEEK_SET);
// Declare our image data
char* ImageData = new char[ss->Size];
// Read the data
fread(ImageData, 1, ss->Size, File);
int i = ss->Size;
// Create the output file
FILE* Output = fopen(argv[2], "wb+");
// Write the output data
fwrite(ImageData, 1, ss->Size, Output);
// Close the files / cleanup
fclose(File);
fclose(Output);
delete[] ImageData;
delete[] ss->SizeBuffer;
// Read out our data
cout << "Internal map name: " << gh->InternalMapName << endl;
cout << "Friendly map name: " << gh->FriendlyMapName << endl;
cout << "Interal gametype name: " << gh->InternalGameType << endl;
cout << "Friendly gametype name: " << gh->FriendlyGameType << endl;
cout << "\r\n\r\nFile sucessfully read and written to " << argv[2] << endl;
return 0;
}
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.