#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

You definitely want to open the stream as binary.

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 :)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.