X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/blobdiff_plain/2c0c12554ebcd58eb3f1fbf2fa322588ec6ce259..419f2c983bc269255b2a4ce279b253de1ff174b7:/usb-driver.c diff --git a/usb-driver.c b/usb-driver.c index c71cbd0..692208e 100644 --- a/usb-driver.c +++ b/usb-driver.c @@ -37,6 +37,7 @@ static pthread_mutex_t int_wait = PTHREAD_MUTEX_INITIALIZER; #define NO_WINDRVR 1 #undef DEBUG +#ifdef DEBUG void hexdump(unsigned char *buf, int len) { int i; @@ -46,6 +47,7 @@ void hexdump(unsigned char *buf, int len) { fprintf(stderr,"\n"); } } +#endif int usb_deviceinfo(unsigned char *buf) { int i,j,k,l; @@ -75,7 +77,7 @@ int usb_deviceinfo(unsigned char *buf) { udi->Pipe0.dwNumber = 0x00; udi->Pipe0.dwMaximumPacketSize = usbdevice->descriptor.bMaxPacketSize0; udi->Pipe0.type = 0; - udi->Pipe0.direction = 3; + udi->Pipe0.direction = WDU_DIR_IN_OUT; udi->Pipe0.dwInterval = 0; pConfigs = &(udi->pConfigs); @@ -221,7 +223,7 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { case VERSION: version = (struct version_struct*)(wdheader->data); strcpy(version->version, "WinDriver no more"); - version->versionul = 999; + version->versionul = 802; #ifdef DEBUG fprintf(stderr,"faking VERSION\n"); #endif @@ -512,9 +514,11 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { it->dwCounter = 1; } else { pthread_mutex_lock(&int_wait); + pthread_mutex_unlock(&int_wait); } } else { pthread_mutex_lock(&int_wait); + pthread_mutex_unlock(&int_wait); } #endif @@ -585,8 +589,7 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { return ret; } -int ioctl(int fd, int request, ...) -{ +int ioctl(int fd, int request, ...) { va_list args; void *argp; int ret; @@ -606,17 +609,14 @@ int ioctl(int fd, int request, ...) return ret; } -typedef int (*open_funcptr_t) (const char *, int, mode_t); - -int open (const char *pathname, int flags, ...) -{ - static open_funcptr_t func = NULL; +int open (const char *pathname, int flags, ...) { + static int (*func) (const char *, int, mode_t) = NULL; mode_t mode = 0; va_list args; int fd; if (!func) - func = (open_funcptr_t) dlsym (REAL_LIBC, "open"); + func = (int (*) (const char *, int, mode_t)) dlsym (REAL_LIBC, "open"); if (flags & O_CREAT) { va_start(args, flags); @@ -687,7 +687,7 @@ FILE *fopen(const char *path, const char *mode) { char *fgets(char *s, int size, FILE *stream) { static char* (*func) (char*, int, FILE*) = NULL; - const char modules[] = "windrvr6 160960 0 - Live 0xf98b0000\n"; + const char modules[][256] = {"windrvr6 1 0 - Live 0xdeadbeef\n", "parport_pc 1 0 - Live 0xdeadbeef\n"}; char *ret = NULL; @@ -695,10 +695,10 @@ char *fgets(char *s, int size, FILE *stream) { func = (char* (*) (char*, int, FILE*)) dlsym(REAL_LIBC, "fgets"); if (modulesfp == stream) { - if (!modules_read) { - strcpy(s, modules); + if (modules_read < sizeof(modules)) { + strcpy(s, modules[modules_read]); ret = s; - modules_read = 1; + modules_read++; } } else { ret = (*func)(s,size,stream); @@ -719,4 +719,17 @@ int fclose(FILE *fp) { return (*func)(fp); } + +int access(const char *pathname, int mode) { + static int (*func) (const char*, int); + + if (!func) + func = (int (*) (const char*, int)) dlsym(REAL_LIBC, "access"); + + if (!strcmp(pathname, "/dev/windrvr6")) { + return 0; + } else { + return (*func)(pathname, mode); + } +} #endif