Changeset 4664
- Timestamp:
- 10/05/10 02:16:54 (3 years ago)
- Location:
- zzuf/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/libzzuf/lib-win32.c
r4663 r4664 65 65 HANDLE hTemplateFile) 66 66 { 67 fprintf(stderr, "CreateFileA(%s)\n", lpFileName); 68 return ORIG(CreateFileA)(lpFileName, dwDesiredAccess, dwShareMode, 69 lpSecurityAttributes, dwCreationDisposition, 70 dwFlagsAndAttributes, hTemplateFile); 67 HANDLE ret; 68 ret = ORIG(CreateFileA)(lpFileName, dwDesiredAccess, dwShareMode, 69 lpSecurityAttributes, dwCreationDisposition, 70 dwFlagsAndAttributes, hTemplateFile); 71 debug("%s(\"%s\", %x, %x, ..., %x, %x, ...) = [%i]", 72 __func__, lpFileName, dwDesiredAccess, dwShareMode, 73 dwCreationDisposition, dwFlagsAndAttributes, (int)ret); \ 74 return ret; 71 75 } 72 76 #endif -
zzuf/trunk/src/myfork.c
r4650 r4664 34 34 # include <tlhelp32.h> 35 35 #endif 36 #if defined HAVE_IO_H 37 # include <io.h> 38 #endif 36 39 #include <string.h> 37 40 #include <fcntl.h> /* for O_BINARY */ … … 73 76 74 77 #if defined HAVE_WINDOWS_H 78 # define PARENT_FD(x) ((x) ? 0 : 1) 79 # define CHILD_FD(x) ((x) ? 1 : 0) 80 #else 81 # define PARENT_FD(x) 0 82 # define CHILD_FD(x) 1 83 #endif 84 85 #if defined HAVE_WINDOWS_H 75 86 static void rep32(uint8_t *buf, void *addr); 76 87 static int dll_inject(PROCESS_INFORMATION *, char const *); … … 91 102 ret = pipe(pipes[i]); 92 103 #elif defined HAVE__PIPE 104 int tmp; 105 /* The pipe is created with NOINHERIT otherwise both parts are 106 * inherited. We then duplicate the part we want. */ 93 107 ret = _pipe(pipes[i], 512, _O_BINARY | O_NOINHERIT); 108 tmp = _dup(pipes[i][CHILD_FD(i)]); 109 close(pipes[i][CHILD_FD(i)]); 110 pipes[i][CHILD_FD(i)] = tmp; 94 111 #endif 95 112 if(ret < 0) … … 111 128 for(i = 0; i < 3; i++) 112 129 { 113 close(pipes[i][ 1]);114 child->fd[i] = pipes[i][ 0];130 close(pipes[i][CHILD_FD(i)]); 131 child->fd[i] = pipes[i][PARENT_FD(i)]; 115 132 } 116 133 … … 259 276 memset(&sinfo, 0, sizeof(sinfo)); 260 277 sinfo.cb = sizeof(sinfo); 261 #if 0 262 DuplicateHandle(pid, (HANDLE)_get_osfhandle(pipes[0][1]), pid, 263 /* FIXME */ &sinfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS); 264 DuplicateHandle(pid, (HANDLE)_get_osfhandle(pipes[1][1]), pid, 265 &sinfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS); 266 DuplicateHandle(pid, (HANDLE)_get_osfhandle(pipes[2][1]), pid, 267 &sinfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS); 278 279 sinfo.hStdInput = (HANDLE)_get_osfhandle(pipes[0][CHILD_FD(0)]); 280 sinfo.hStdOutput = (HANDLE)_get_osfhandle(pipes[1][CHILD_FD(1)]); 281 sinfo.hStdError = (HANDLE)_get_osfhandle(pipes[2][CHILD_FD(2)]); 268 282 sinfo.dwFlags = STARTF_USESTDHANDLES; 269 #endif 270 ret = CreateProcess(NULL, child->newargv[0], NULL, NULL, FALSE, 283 ret = CreateProcess(NULL, child->newargv[0], NULL, NULL, TRUE, 271 284 CREATE_SUSPENDED, NULL, NULL, &sinfo, &pinfo); 272 285 if(!ret) -
zzuf/trunk/src/zzuf.c
r4646 r4664 939 939 continue; 940 940 941 for(j = 0; j < 3; j++)941 for(j = 1; j < 3; j++) 942 942 ZZUF_FD_SET(opts->child[i].fd[j], &fdset, maxfd); 943 943 } … … 945 945 tv.tv_usec = 1000; 946 946 947 #if _WIN32 948 for(i = 0; i < opts->maxchild; i++) 949 for (j = 1; j < 3; j++) 950 { 951 char tmpbuf[1025]; 952 int tmp = _read(opts->child[i].fd[j], tmpbuf, 1024); 953 if (tmp > 0) 954 { 955 tmpbuf[tmp] = 0; 956 fprintf(stderr, "read %i bytes on fd %i: \"%s\"\n", tmp, j, tmpbuf); 957 } 958 } 959 #endif 960 961 errno = 0; 947 962 ret = select(maxfd + 1, &fdset, NULL, NULL, &tv); 948 963 if(ret < 0 && errno)
Note: See TracChangeset
for help on using the changeset viewer.
