Commit 86441ba7 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Use the insert/replace functionality of the binary patcher

Hasn't received a lot of testing, so will have to see whether this
works in practice.
parent 65184970
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
#include <locale> #include <locale>
#include <qglobal.h> #include <qglobal.h>
#include "binpatch.h" #include "binpatch.h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
# define strcasecmp _stricmp # define strcasecmp _stricmp
# define strncasecmp _strnicmp # define strncasecmp _strnicmp
...@@ -112,7 +112,7 @@ bool BinPatch::patchHelper(char *inbuffer, const char *oldstr, const char *newst ...@@ -112,7 +112,7 @@ bool BinPatch::patchHelper(char *inbuffer, const char *oldstr, const char *newst
write = false; write = false;
break; break;
} }
long oldsize = -1; long oldsize = -1;
if (useLength) { //VC60 if (useLength) { //VC60
oldsize = (unsigned char)(*(inbuffer-1)); oldsize = (unsigned char)(*(inbuffer-1));
...@@ -125,7 +125,7 @@ bool BinPatch::patchHelper(char *inbuffer, const char *oldstr, const char *newst ...@@ -125,7 +125,7 @@ bool BinPatch::patchHelper(char *inbuffer, const char *oldstr, const char *newst
} }
oldsize = getBufferStringLength(inbuffer, inend); oldsize = getBufferStringLength(inbuffer, inend);
if (oldsize < 0) { if (oldsize < 0) {
*rw = (long)(inend-inbuffer); //rewind, entire string not in buffer *rw = (long)(inend-inbuffer); //rewind, entire string not in buffer
break; break;
...@@ -210,8 +210,8 @@ bool BinPatch::patch(const char *oldstr, const char *newstr) ...@@ -210,8 +210,8 @@ bool BinPatch::patch(const char *oldstr, const char *newstr)
break; break;
len = fread(data, sizeof(char), sizeof(data), input); len = fread(data, sizeof(char), sizeof(data), input);
} while(!(feof(input) && (len <= oldlen || len <= newlen))); } while(!(feof(input) && (len <= oldlen || len <= newlen)));
fclose(input); fclose(input);
return true; return true;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment