/* VLC's libqt4_plugin.dll patcher This program can patch VLC's libqt4_plugin.dll to solve the volume control problem. Suggested usage: cd path_to_VLC's_direcotry\plugins mv libqt4_plugin.dll libqt4_plugin.dll.backup path_to_this_program.exe libtq4_plugin.dll.backup libqt4_plugin.dll Note: strings in this program don't use '\0' as terminate character. Original python code (http://forum.videolan.org/viewtopic.php?f=14&t=79258&sid=d587667b82edc613b75b6d9e24dbbb13&start=20#p272045): PATH_SRC = r'c:\program files\videolan\vlc\plugins\libqt4_plugin.dll' PATH_DST = r'libqt4_plugin.dll' src = open(PATH_SRC, 'rb') data = src.read() src.close() s = 'unknown APPCOMMAND = %d\x00' pos = data.index(s) + len(s) if pos % 4 > 0: pos += 4 - pos % 4 t = data[pos + 32 : pos + 36] data = data[:pos] + t * 3 + data[pos + 12:] dst = open(PATH_DST, 'wb') dst.write(data) dst.close() */ #include #include #include #include #include #include /* function to get a substring's position in a string, where strings have not terminate at \0 returns the substring's position in the string, or -1 if the substring not found */ int mystrstr(char *a,int na,char *b,int nb) { int j; for(int i=0;i0) //pos have to be divisible by 4 { pos+=4-(pos%4); } char *temp=(char *)malloc(4); //allocate 4 bytes for temp string if(temp==NULL) { printf("Cannot allocate 4 bytes of memory.\n"); return 1; } memcpy(temp,content+pos+32,4); //get string into temp file=open(argv[2],O_WRONLY|O_BINARY|O_CREAT,S_IWRITE); //open new file for writing if(file==-1) { printf("Cannot open file for writing: \"%s\"\n",argv[2]); return 1; } write(file,content,pos); //writing out the first part for(int i=0;i<4;i++) //writing out temp for 4 times { write(file,temp,4); } write(file,content+pos+16,filestat.st_size-pos-16); //writing out the last part close(file); //close file free(temp); //freeing variables free(content); printf("Everything OK, file \"%s\" created from \"%s\" successfully.\n",argv[2],argv[1]); return 0; }