84 lines
1.7 KiB
C++
84 lines
1.7 KiB
C++
#include <common/windows.hpp>
|
|
#include <common/string.hpp>
|
|
#include <common/file.hpp>
|
|
#include <common/winnt.hpp>
|
|
#include <decode/disasm.hpp>
|
|
#include <iostream.h>
|
|
|
|
void outDebug(const String &string);
|
|
void dump(char *buff,int size);
|
|
void patch(void);
|
|
|
|
void main(int argc,char **argv)
|
|
{
|
|
patch();
|
|
}
|
|
|
|
void patch(void)
|
|
{
|
|
unsigned char signature[]={0x6A,0x6C,0x6A,0x01,0x9A};
|
|
unsigned char patchbytes[]={0x6A,0x6C,0x6A,0x00,0x9A};
|
|
|
|
// ALREADY PATCHED
|
|
// unsigned char signature[]={0xB8,0x00,0x00,0x0B,0x46,0xFA,0x50,0x9A};
|
|
// unsigned char patchbytes[]={0xB8,0x00,0x00,0x90,0x90,0x90,0x50,0x9A};
|
|
// unsigned char signature[]={0x6A,0x65,0x6A,0x01,0x9A};
|
|
// unsigned char patchbytes[]={0x6A,0x65,0x6A,0x00,0x9A};
|
|
|
|
unsigned char byte;
|
|
int index=0;
|
|
int occurrence=0;
|
|
int pos=0;
|
|
bool modify=true;
|
|
|
|
File ioFile("d:\\program files\\jamwin\\jammerw.exe","r+b");
|
|
if(!ioFile.isOkay())return;
|
|
while(true)
|
|
{
|
|
if(!index)pos=ioFile.tell();
|
|
if(!ioFile.read(byte))break;
|
|
if(byte==signature[index])
|
|
{
|
|
index++;
|
|
}
|
|
else index=0;
|
|
if(index==sizeof(signature))
|
|
{
|
|
if(modify)
|
|
{
|
|
int savePos=ioFile.tell();
|
|
ioFile.seek(pos);
|
|
ioFile.write(patchbytes,sizeof(patchbytes));
|
|
ioFile.seek(savePos);
|
|
}
|
|
occurrence++;
|
|
index=0;
|
|
}
|
|
}
|
|
outDebug(String("Found ")+String().fromInt(occurrence)+String(" occurrences."));
|
|
if(!modify)outDebug("No changes made because modify=false");
|
|
}
|
|
|
|
void dump(char *buff,int size)
|
|
{
|
|
String outLine;
|
|
String item;
|
|
|
|
for(int index=0;index<size;index++)
|
|
{
|
|
::sprintf(item,"0x%02lx ",buff[index]);
|
|
outLine+=item;
|
|
}
|
|
outDebug(outLine);
|
|
}
|
|
|
|
void outDebug(const String &string)
|
|
{
|
|
String outString(string+String("\n"));
|
|
cout << ((String&)string).str() << endl;
|
|
::OutputDebugString(outString.str());
|
|
}
|
|
|
|
|
|
|