mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2024-10-28 11:19:36 +01:00
un-screw steamshim on Windows again
This commit is contained in:
parent
6007c45c8a
commit
748aff99cc
1 changed files with 456 additions and 469 deletions
|
@ -2,11 +2,10 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <io.h>
|
typedef HANDLE PipeType;
|
||||||
#include <errno.h>
|
#define NULLPIPE NULL
|
||||||
typedef int PipeType;
|
|
||||||
#define NULLPIPE 0
|
|
||||||
typedef unsigned __int8 uint8;
|
typedef unsigned __int8 uint8;
|
||||||
typedef __int32 int32;
|
typedef __int32 int32;
|
||||||
typedef unsigned __int64 uint64;
|
typedef unsigned __int64 uint64;
|
||||||
|
@ -47,30 +46,25 @@ static int pipeReady(PipeType fd);
|
||||||
|
|
||||||
static int pipeReady(PipeType fd)
|
static int pipeReady(PipeType fd)
|
||||||
{
|
{
|
||||||
return 1;
|
|
||||||
DWORD avail = 0;
|
DWORD avail = 0;
|
||||||
return (PeekNamedPipe(fd, NULL, 0, NULL, &avail, NULL) && (avail > 0));
|
return (PeekNamedPipe(fd, NULL, 0, NULL, &avail, NULL) && (avail > 0));
|
||||||
} /* pipeReady */
|
} /* pipeReady */
|
||||||
|
|
||||||
static int writePipe(PipeType fd, const void *buf, const unsigned int _len)
|
static int writePipe(PipeType fd, const void *buf, const unsigned int _len) {
|
||||||
{
|
const DWORD len = (DWORD)_len;
|
||||||
const ssize_t len = (ssize_t) _len;
|
DWORD bw = 0;
|
||||||
ssize_t bw;
|
return ((WriteFile(fd, buf, len, &bw, NULL) != 0) && (bw == len));
|
||||||
while (((bw = _write(fd, buf, len)) == -1) && (errno == EINTR)) { /*spin*/ }
|
} // writePipe
|
||||||
return (bw == len);
|
|
||||||
} /* writePipe */
|
|
||||||
|
|
||||||
static int readPipe(PipeType fd, void *buf, const unsigned int _len)
|
static int readPipe(PipeType fd, void *buf, const unsigned int _len) {
|
||||||
{
|
const DWORD len = (DWORD)_len;
|
||||||
const ssize_t len = (ssize_t) _len;
|
DWORD br = 0;
|
||||||
ssize_t br;
|
return ReadFile(fd, buf, len, &br, NULL) ? (int)br : -1;
|
||||||
while (((br = _read(fd, buf, len)) == 0)) { /*spin*/ }
|
} // readPipe
|
||||||
return (int) br;
|
|
||||||
} /* readPipe */
|
|
||||||
|
|
||||||
static void closePipe(PipeType fd)
|
static void closePipe(PipeType fd)
|
||||||
{
|
{
|
||||||
_close(fd);
|
CloseHandle(fd);
|
||||||
} /* closePipe */
|
} /* closePipe */
|
||||||
|
|
||||||
static char *getEnvVar(const char *key, char *buf, const size_t buflen)
|
static char *getEnvVar(const char *key, char *buf, const size_t buflen)
|
||||||
|
@ -352,13 +346,6 @@ const STEAMSHIM_Event *STEAMSHIM_pump(void)
|
||||||
return retval;
|
return retval;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
/* Run Steam event loop. */
|
|
||||||
if (br == 0)
|
|
||||||
{
|
|
||||||
dbgpipe("Child sending SHIMCMD_PUMP().\n");
|
|
||||||
write1ByteCmd(SHIMCMD_PUMP);
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} /* STEAMSHIM_pump */
|
} /* STEAMSHIM_pump */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue