0
#include <fstream>
#include <iostream>
using namespace std;
  char * buffer;
  long size;
  
int main () {

  ifstream infile ("d2gfx.dll",ifstream::in);
  ofstream outfile ("d2gfx.dll",ofstream::out);

  infile.seekg(0xBD30,ifstream::beg);
  size=infile.tellg();
  infile.seekg(0xBD30);

  buffer = new char [size];

  infile.read (buffer,size);
  cout << buffer << "\n";
  system("pause");
  outfile.seekp(0xBD30,ifstream::beg);
  size=outfile.tellp();
  outfile.seekp(0xBD30);
  outfile.write ("D2Mad.dll",10);
  delete[] buffer;

  outfile.close();
  infile.close();
  return 0;
}

for the better part of today I've been trying to statically modify a dll using the above code(and variations thereof), but to no avail, I'm hoping someone can give me some insight into what I'm doing wrong/ a better way to do this
thanks

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by Ancient Dragon
0

You definitely want to open the stream as binary.

already tried that, just replaces everything in the .dll with 0x00 except for my string, after which the dll ends(looks like its generating a new dll.....)
thanks for the quick reply :)

0

why don't you replace the ifstream and ofstream objects with just one fstream object then open it for both input and output, in binary mode.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.