mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-01 18:42:40 +00:00
improve GetTickCount64 patching
This commit is contained in:
parent
78bb35901f
commit
36ed33685c
2 changed files with 56 additions and 3 deletions
54
scripts/patch_xp.c
Normal file
54
scripts/patch_xp.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
// patch GetTickCount64 for running on Windows XP
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
unsigned char* buf;
|
||||
FILE* f=fopen(argv[1],"rb");
|
||||
if (f==NULL) {
|
||||
perror("open");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fseek(f,0,SEEK_END);
|
||||
|
||||
size_t size=ftell(f);
|
||||
buf=malloc(size);
|
||||
|
||||
fseek(f,0,SEEK_SET);
|
||||
|
||||
fread(buf,1,size,f);
|
||||
fclose(f);
|
||||
|
||||
// patch
|
||||
size_t remain=size;
|
||||
unsigned char* buf1=buf;
|
||||
while (size>=14) {
|
||||
unsigned char* where=memchr(buf1,'G',remain);
|
||||
if (where==NULL) {
|
||||
printf("GetTickCount64 not found\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (memcmp(where,"GetTickCount64",14)==0) {
|
||||
printf("found GetTickCount64 - patching...\n");
|
||||
where[12]=0;
|
||||
where[13]=0;
|
||||
break;
|
||||
}
|
||||
|
||||
buf1=where+1;
|
||||
remain=size-(buf1-buf);
|
||||
}
|
||||
|
||||
// write
|
||||
FILE* of=fopen(argv[1],"wb");
|
||||
if (f==NULL) {
|
||||
perror("open write");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fwrite(buf,1,size,of);
|
||||
fclose(of);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -36,9 +36,8 @@ cp ../../res/docpdf/manual.pdf . || exit 1
|
|||
i686-w64-mingw32-strip -s furnace.exe || exit 1
|
||||
|
||||
# patch to remove GetTickCount64
|
||||
xxd -c 256 -ps furnace.exe | sed "s/4765745469636b436f756e743634/4765745469636b436f756e740000/g" | xxd -ps -r > furnace-patched.exe
|
||||
rm furnace.exe
|
||||
mv furnace-patched.exe furnace.exe
|
||||
gcc -o patch_xp ../../scripts/patch_xp.c || exit 1
|
||||
./patch_xp furnace.exe || exit 1
|
||||
|
||||
zip -r furnace.zip LICENSE.txt furnace.exe README.txt manual.pdf papers demos instruments wavetables
|
||||
|
||||
|
|
Loading…
Reference in a new issue