[Wine] wineio (iowraping under wine)
Christian Schmitz (derem)
list at schweb.com.ar
Tue May 17 07:59:46 CDT 2016
Hi wine people
Finally i can grant parallel port acces to TOPmax EEtools chip programmer.
I dont know why i need to modify the wineio.c wrapper.
I put below the new code with the hope that was usefull to another people.
Best Regards
Christian
====================== wineio.c ===========================
/*
* Copyright (c) 2005 Nicolas Bernard <http://www.lafraze.net/nbernard/>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Modified by Christian Schmitz <http://www.schlabs.com.ar> 2016
*/
/* this is a wrapper to authorize the use of a port (eg: parallel port)
* by a program which assume it can (eg wine). */
/* this program must be setuid root */
//
// Usage:
// wineio [your program]
//
//
// Notes:
// 1-this executable replace the binary that you normally calls
// For example:
// Write
// wineio Tmw.exe
// instead
// wine Tmw.exe
//
// 2- The executable must be owned by root
// 3- This program must be setuid root
//
//
#include <sys/io.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/**** adjust those values according to your configuration *****/
//#define
WINE_PATH "/usr/bin/wine /home/wolf/.wine/drive_c/EETools/Tmw.exe" /* the
program to launch */
//#define PORT_FROM 0x370 /* beginning of the memory area authorize
*/
//#define PORT_TO 0x37F /* end of it */
#define WINE_PATH "/usr/bin/wine" /* the program to launch */
//#define WINE_PATH "/home/wolf/bin/wineio2" /* the program to launch */
#define PORT_FROM 0x378 /* beginning of the memory area authorize
*/
#define PORT_TO 0x37F /* end of it */
#define UID 1000 /* uid of the user under which to launch the program */
/************************************************************/
int debuglevel=9;
int
main(int argc, char* argv[], char *const envp[])
{
char** nargv;
int i;
//Setting permissions
if (ioperm(PORT_FROM, PORT_TO - PORT_FROM + 1, 1)) {
fprintf(stderr, "ioperm: %s\n", strerror(errno));
return 1;
}
if(debuglevel>1){
printf("\tPermissions \tOK (%04x-%04x)\n",PORT_FROM,PORT_TO);
}
//Malloc
nargv = malloc((argc + 1) * sizeof(char*));
if (nargv == NULL) {
fprintf(stderr, "malloc: unable to allocate memory\n");
return 2;
}
for (i = 0; i < argc; i++)
nargv[i] = argv[i];
//old code do not work cannot execute wine saying
//"is not elf 386 program"
// nargv[argc] = NULL;
//New working code
nargv[0] = "wine";
nargv[argc] = 0;
if(debuglevel>1){
printf("\tMalloc \tOK (%d)\n",argc);
}
// Setuid
if (setuid(UID)) {
fprintf(stderr, "setuid: %s\n", strerror(errno));
return 3;
}
if(debuglevel>1){
printf("\tSetuid \tOK (%d)\n",UID);
}
// Program execution
if(debuglevel>1){
// printf("Executing prg :%s \n",nargv[1]);
printf("\tExecuting :%s %s\n",WINE_PATH,nargv[1]);
}
execve(WINE_PATH, nargv, envp);
fprintf(stderr, "execve: %s\n", strerror(errno));
return 4;
}
====================== end wineio.c =====================
El Lunes 02 Mayo 2016, Christian Schmitz (derem) escribió:
> > Hi,
> >
> > Windows programs that need to load a custom driver for hardware like a
> > programmer don't work with wine. I suggest you look at the programmers
> > made by Conitec at http://www.conitec.com especially the GALEP-5D. Not
> > only do they work with Linux they are actually running Linux. I had the
> > same problem as you and have been very happy with the 5D.
> >
> > Best regards,
> > Fred Boatwright
>
> Dear Fred.
> The topmax (the chip programmer) do not use driver under wine, use direct
> parallel port access (0x378 if my memory does not fail). I get working on
> opensuse 11.0.
>
> But now under opensuse 42.1 (into the wine) i dont know how give port
> access to the application. And i dont know how solve the elf 386 binary
> problem.
>
> Interesting programmer the GALEP-5D, i use TOPMAX (lpt version).
>
> Best Regards
> Christian
>
> > On 05/02/2016 09:33 AM, Christian Schmitz (derem) wrote:
> > > Hi everyone:
> > > I am a wine user, and i migrate from opensuse 11.0 to the new opensuse
> > > leap42.1.
> > >
> > > I have a chip programmer connected via parallel port. This programmer
> > > is esential to my work, and the program run only on windows.
> > >
> > > In the past i use a IOWRAPPER in C that i call wineio.c. So after
> > > compile wineio, give permissions (root and sticky) i can run the
> > > software and program chips.
> > >
> > > The iowrapper used is attached to this email. This was working on
> > > opensuse 11.0 (64 bits) but in opensuse LEAP 42.1 (64 bits) i got this
> > > error:
> > >
> > > Executing prg :c:\Program Files (x86)\EEtools\Tmw.exe
> > > /usr/bin/wineio: not an i386 ELF binary... don't know how to load it
> > >
> > >
> > > I try recompile, i do make wineio, the program is compiled and run. The
> > > wineio is operative becasue the text "executing prg" is in line 90 of
> > > wineio.c
> > >
> > >
> > > I dont know how get working my hardware thru wine.
> > >
> > > Best Regards to all, any clue will be appreciated.
> > > Christian
> > > -------------- next part --------------
> > > A non-text attachment was scrubbed...
> > > Name: wineio.c
> > > Type: text/x-csrc
> > > Size: 2893 bytes
> > > Desc: not available
> > > URL:
> > > <http://www.winehq.org/pipermail/wine-users/attachments/20160502/9c982a
> > >9e /attachment.c>
More information about the wine-users
mailing list