Commit 3cfca20d authored by Vitaly Lipatov's avatar Vitaly Lipatov

0.5.7.3-alt1

- build with wow64 support
parent 29799851
tar: wine-grdwine name=@name@-@version@ tar: wine-grdwine name=@name@-@version@ base=@name@-@version@/grdwine
copy?: *.rules copy?: *.rules
copy?: *.patch copy?: *.patch
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
%define _lto_cflags %{nil} %define _lto_cflags %{nil}
Name: wine-etersoft-grdwine Name: wine-etersoft-grdwine
Version: 0.5.7.2 Version: 0.5.7.3
Release: alt1 Release: alt1
Summary: Guardant usb dongle helper library for Wine Summary: Guardant usb dongle helper library for Wine
...@@ -19,28 +19,48 @@ Source: %name-%version.tar ...@@ -19,28 +19,48 @@ Source: %name-%version.tar
Source1: 90-grdnt.rules Source1: 90-grdnt.rules
Patch1: 0001-build-both-ELF-and-PE-parts.patch ExclusiveArch: %ix86 x86_64
Patch2: 0001-don-t-use-DLL_WINE_PREATTACH.patch
%define libwinedir %_libdir/wine-etersoft
BuildRequires: libwine-devel >= 6.23 # TODO: use mingw detection from wine or just wait for total PE using
%def_with pebuild
# check if we need wow64 build also
%if "%(test -d %libwinedir/i386-windows && echo 1)" == "1"
%def_with wow64
%endif
ExclusiveArch: %ix86 x86_64
%ifarch x86_64 aarch64 %ifarch x86_64 aarch64
%def_with build64 %def_with build64
%define winepkgname wine-etersoft-grdwine %define winearch wine64
%define opkgname wine-grdwine %define winepkgname wine-etersoft-grdwine
%else %define winedevpkgname wine-etersoft-devel-tools
%def_without build64 %define opkgname wine-grdwine
%define winepkgname wine32-etersoft-grdwine
%define opkgname wine32-grdwine
%endif %endif
Provides: %opkgname = %EVR # workaround for https://bugzilla.altlinux.org/38130
Obsoletes: %opkgname < %EVR # buildwow64 = _arch = x86_64 && with wow64
%if "%_arch" == "x86_64" && %{expand:%%{?_with_wow64:1}%%{!?_with_wow64:0}}
%def_with buildwow64
%undefine _with_build64
%endif
%ifarch %ix86
%def_without build64
%define winepkgname wine32-etersoft-grdwine
%define winedevpkgname wine32-etersoft-devel-tools
%define opkgname wine32-grdwine
%endif
%define libwinedir %_libdir/wine-etersoft BuildRequires: %winedevpkgname >= 9
# lib.req: ERROR: /tmp/.private/lav/wine-cpcsp_proxy-buildroot/usr/lib64/wine/x86_64-unix/cpcsp_proxy.so: library ntdll.so not found
AutoReq: no
Provides: %opkgname = %EVR
Obsoletes: %opkgname < %EVR
# TODO: move to rpm-macros-wine # TODO: move to rpm-macros-wine
# set arch dependent dirs # set arch dependent dirs
...@@ -60,8 +80,10 @@ Obsoletes: %opkgname < %EVR ...@@ -60,8 +80,10 @@ Obsoletes: %opkgname < %EVR
%define winepedir aarch64-windows %define winepedir aarch64-windows
%define winesodir aarch64-unix %define winesodir aarch64-unix
%endif %endif
%define winepe32dir i386-windows
%add_verify_elf_skiplist %libwinedir/%winesodir/grdwine.dll.so %add_verify_elf_skiplist %libwinedir/%winesodir/grdwine.dll.so
%add_verify_elf_skiplist %libwinedir/%winesodir/grdwine.so
%description %description
Guardant usb dongle helper library for Wine. Guardant usb dongle helper library for Wine.
...@@ -89,39 +111,64 @@ Old keys Stealth II and Stealth III are not supported here ...@@ -89,39 +111,64 @@ Old keys Stealth II and Stealth III are not supported here
%prep %prep
%setup %setup
%patch1 -p1 %if_with buildwow64
%patch2 -p1 cp -a grdwine grdwine_wow64
%endif
%build %build
#autoreconf %make_build -C grdwine \
./bootstrap.sh LIBDIR=%_libdir \
%if_with pebuild
%if_with build64 TARGETDLL=grdwine.dll \
%configure \
--enable-win64 \
%else %else
%configure \ TARGETDLL="grdwine.dll grdwine.dll.so" \
%endif
%nil
%if_with buildwow64
%make_build -C grdwine_wow64 \
LIBDIR=%_libdir \
WOW64BUILD=yes \
TARGETDLL=grdwine.dll \
grdwine.dll
%nil
%endif %endif
--with-wineincs=%_includedir \
--with-wineso=%buildroot/%libwinedir/%winesodir \
--with-winepe=%buildroot/%libwinedir/%winepedir
%make_build
%install %install
%makeinstall_std mkdir -p %buildroot%libwinedir/{%winesodir,%winepedir}
cp grdwine/grdwine.so %buildroot%libwinedir/%winesodir
cp grdwine/grdwine.dll %buildroot%libwinedir/%winepedir
%if_with buildwow64
mkdir -p %buildroot%libwinedir/%winepe32dir
cp grdwine_wow64/grdwine.dll %buildroot%libwinedir/%winepe32dir
%endif
%if_without pebuild
cp grdwine/grdwine.dll.so %buildroot%libwinedir/%winesodir
%endif
%if_with build64 %if_with build64
install -D -m0644 %SOURCE1 %buildroot%_udevrulesdir/90-grdnt.rules install -D -m0644 %SOURCE1 %buildroot%_udevrulesdir/90-grdnt.rules
%endif %endif
%files -n %winepkgname %files -n %winepkgname
%libwinedir/%winesodir/grdwine.dll.so %libwinedir/%winesodir/grdwine.so
%libwinedir/%winepedir/grdwine.dll %libwinedir/%winepedir/grdwine.dll
%if_with buildwow64
%libwinedir/%winepe32dir/grdwine.dll
%endif
%if_without pebuild
%libwinedir/%winesodir/grdwine.dll.so
%endif
%if_with build64 %if_with build64
%_udevrulesdir/*.rules %_udevrulesdir/*.rules
%endif %endif
%changelog %changelog
* Thu Sep 18 2025 Vitaly Lipatov <lav@altlinux.ru> 0.5.7.3-alt1
- build with wow64 support
* Wed May 22 2024 Vitaly Lipatov <lav@altlinux.ru> 0.5.7.2-alt1 * Wed May 22 2024 Vitaly Lipatov <lav@altlinux.ru> 0.5.7.2-alt1
- added guardant Stealth 2 support (eterbug #17339) - added guardant Stealth 2 support (eterbug #17339)
......
MODULE = grdwine.dll
UNIXLIB = grdwine.so
CROSSBUILD =
WOW64BUILD =
LIBDIR = /usr/lib
#LIBDIR = /usr/lib/x86_64-linux-gnu
ifeq ($(shell echo $(LIBDIR) | grep -q 64 && echo -n x86_64),x86_64)
WINEARCH = x86_64-windows
UNIXARCH = x86_64-unix
else
WINEARCH = i686-windows
UNIXARCH = i386-unix
ifeq ($(shell arch),x86_64)
CROSSBUILD = -m32
endif
endif
ifeq ($(WOW64BUILD),yes)
WINEARCH = i686-windows
UNIXARCH =
ifeq ($(shell arch),x86_64)
CROSSBUILD = -m32
endif
endif
UNIXGCC = gcc $(CROSSBUILD) -DWINE_UNIX_LIB -fPIC -I/usr/include/wine/windows
WINELIBDIR = $(LIBDIR)/wine-etersoft
#
ifeq ($(shell test -e $(WINELIBDIR)/$(UNIXARCH)/ntdll.dll.so || ! test "$(TARGETDLL)" = "grdwine.dll" && echo -n yes),yes)
WINEGCC = winegcc $(CROSSBUILD)
TARGETDLL=grdwine.dll.so
else
WINEGCC = winegcc -b $(WINEARCH) -D__WINE_PE_BUILD
TARGETDLL=grdwine.dll
endif
CFLAGS = -g -O2 -Wall -D__WINESRC__
IMPORTS = ntdll kernel32 crypt32 advapi32
LIBS = $(IMPORTS:%=-l%)
#UNIXLIBS = -ldl
UNIXLIBS = -ldl $(WINELIBDIR)/$(UNIXARCH)/ntdll.so
DEPS = Makefile grdimpl.h
UNIXDEPS = Makefile grdimpl.h
OBJ = grdwine.c grdwine.spec
UNIXOBJ = grdimpl_linux.c
all: grdwine.so $(TARGETDLL)
%.cross.o: %.c $(DEPS)
$(WINEGCC) -c -o $@ $< $(CFLAGS)
%.o: %.c $(UNIXDEPS)
$(UNIXGCC) -c -o $@ $< $(CFLAGS)
grdwine.so: $(UNIXOBJ)
$(UNIXGCC) -o $@ $^ -shared $(CFLAGS) $(UNIXLIBS)
#strip $@
ifeq ($(TARGETDLL),grdwine.dll)
grdwine.dll: $(OBJ)
$(WINEGCC) -o $@ $^ -shared -Wl,--wine-builtin $(CFLAGS) $(LIBS)
#strip $@
else
grdwine.dll: grdwine.spec
$(WINEGCC) -o $@ -Wb,--fake-module -shared $^ -mno-cygwin
endif
grdwine.dll.so: $(OBJ)
$(WINEGCC) -o $@ $^ -shared -Wl,--wine-builtin $(CFLAGS) $(LIBS)
#strip $@
clean:
rm -f *.o *.so *.dll *.lib
MODULE = grdwine.dll
UNIXLIB = grdwine.so
UNIX_CFLAGS =
SOURCES = \
grdimpl_linux.c \
grdwine.c
/*
* Wine debugging interface
*
* Copyright 1999 Patrik Stridvall
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep install
#endif
#ifndef __WINE_WINE_DEBUG_H
#define __WINE_WINE_DEBUG_H
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#ifndef GUID_DEFINED
#include <guiddef.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct _GUID;
/*
* Internal definitions (do not use these directly)
*/
enum __wine_debug_class
{
__WINE_DBCL_FIXME,
__WINE_DBCL_ERR,
__WINE_DBCL_WARN,
__WINE_DBCL_TRACE,
__WINE_DBCL_NOTOUR,
__WINE_DBCL_INIT = 7 /* lazy init flag */
};
struct __wine_debug_channel
{
unsigned char flags;
char name[15];
};
#ifndef WINE_NO_TRACE_MSGS
# define __WINE_GET_DEBUGGING_TRACE(dbch) ((dbch)->flags & (1 << __WINE_DBCL_TRACE))
#else
# define __WINE_GET_DEBUGGING_TRACE(dbch) 0
#endif
#ifndef WINE_NO_DEBUG_MSGS
# define __WINE_GET_DEBUGGING_WARN(dbch) ((dbch)->flags & (1 << __WINE_DBCL_WARN))
# define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME))
# define __WINE_GET_DEBUGGING_NOTOUR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_NOTOUR))
#else
# define __WINE_GET_DEBUGGING_WARN(dbch) 0
# define __WINE_GET_DEBUGGING_FIXME(dbch) 0
# define __WINE_GET_DEBUGGING_NOTOUR(dbch) 0
#endif
/* define error macro regardless of what is configured */
#define __WINE_GET_DEBUGGING_ERR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_ERR))
#define __WINE_GET_DEBUGGING(dbcl,dbch) __WINE_GET_DEBUGGING##dbcl(dbch)
#define __WINE_IS_DEBUG_ON(dbcl,dbch) \
(__WINE_GET_DEBUGGING##dbcl(dbch) && (__wine_dbg_get_channel_flags(dbch) & (1 << __WINE_DBCL##dbcl)))
#define __WINE_DPRINTF(dbcl,dbch) \
do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \
struct __wine_debug_channel * const __dbch = (dbch); \
const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \
__WINE_DBG_LOG
#define __WINE_DBG_LOG(...) \
wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0)
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__MINGW32__) || defined (_MSC_VER) || !defined(__WINE_USE_MSVCRT))
#define __WINE_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
#else
#define __WINE_PRINTF_ATTR(fmt,args)
#endif
#ifdef WINE_NO_TRACE_MSGS
#define WINE_TRACE(...) do { } while(0)
#define WINE_TRACE_(ch) WINE_TRACE
#endif
#ifdef WINE_NO_DEBUG_MSGS
#define WINE_WARN(...) do { } while(0)
#define WINE_WARN_(ch) WINE_WARN
#define WINE_FIXME(...) do { } while(0)
#define WINE_FIXME_(ch) WINE_FIXME
#define WINE_NOTOUR(...) do { } while(0)
#define WINE_NOTOUR_(ch) WINE_NOTOUR
#endif
NTSYSAPI int WINAPI __wine_dbg_write( const char *str, unsigned int len );
extern DECLSPEC_EXPORT unsigned char __cdecl __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel );
extern DECLSPEC_EXPORT const char * __cdecl __wine_dbg_strdup( const char *str );
extern DECLSPEC_EXPORT int __cdecl __wine_dbg_output( const char *str );
extern DECLSPEC_EXPORT int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function );
/*
* Exported definitions and macros
*/
/* These functions return a printable version of a string, including
quotes. The string will be valid for some time, but not indefinitely
as strings are re-used. */
#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
# define __wine_dbg_cdecl __cdecl
#else
# define __wine_dbg_cdecl
#endif
static const char * __wine_dbg_cdecl wine_dbg_vsprintf( const char *format, va_list args ) __WINE_PRINTF_ATTR(1,0);
static inline const char * __wine_dbg_cdecl wine_dbg_vsprintf( const char *format, va_list args )
{
char buffer[200];
vsnprintf( buffer, sizeof(buffer), format, args );
return __wine_dbg_strdup( buffer );
}
static const char * __wine_dbg_cdecl wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
static inline const char * __wine_dbg_cdecl wine_dbg_sprintf( const char *format, ... )
{
const char *ret;
va_list args;
va_start( args, format );
ret = wine_dbg_vsprintf( format, args );
va_end( args );
return ret;
}
static int __wine_dbg_cdecl wine_dbg_vprintf( const char *format, va_list args ) __WINE_PRINTF_ATTR(1,0);
static inline int __wine_dbg_cdecl wine_dbg_vprintf( const char *format, va_list args )
{
char buffer[1024];
vsnprintf( buffer, sizeof(buffer), format, args );
return __wine_dbg_output( buffer );
}
static int __wine_dbg_cdecl wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
static inline int __wine_dbg_cdecl wine_dbg_printf( const char *format, ... )
{
int ret;
va_list args;
va_start( args, format );
ret = wine_dbg_vprintf( format, args );
va_end( args );
return ret;
}
static int __wine_dbg_cdecl wine_dbg_vlog( enum __wine_debug_class cls,
struct __wine_debug_channel *channel, const char *func,
const char *format, va_list args ) __WINE_PRINTF_ATTR(4,0);
static inline int __wine_dbg_cdecl wine_dbg_vlog( enum __wine_debug_class cls,
struct __wine_debug_channel *channel,
const char *function, const char *format, va_list args )
{
int ret;
if (*format == '\1') /* special magic to avoid standard prefix */
{
format++;
function = NULL;
}
if ((ret = __wine_dbg_header( cls, channel, function )) != -1) ret += wine_dbg_vprintf( format, args );
return ret;
}
static int __wine_dbg_cdecl wine_dbg_log( enum __wine_debug_class cls,
struct __wine_debug_channel *channel, const char *func,
const char *format, ... ) __WINE_PRINTF_ATTR(4,5);
static inline int __wine_dbg_cdecl wine_dbg_log( enum __wine_debug_class cls,
struct __wine_debug_channel *channel,
const char *function, const char *format, ... )
{
va_list args;
int ret;
va_start( args, format );
ret = wine_dbg_vlog( cls, channel, function, format, args );
va_end( args );
return ret;
}
#if defined _NTSYSTEM_ || defined WINE_UNIX_LIB
extern int ntdll_wcstoumbs(const WCHAR *,DWORD,char *,DWORD,BOOL);
#else
#ifndef NTSTATUS
typedef LONG NTSTATUS;
#endif
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(WCHAR *,DWORD,DWORD*,const char *,DWORD);
NTSYSAPI NTSTATUS WINAPI RtlUnicodeToUTF8N(LPSTR,DWORD,DWORD*,LPCWSTR,DWORD);
#endif
static inline const char *wine_dbgstr_an( const char *str, int n )
{
static const char hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
char buffer[300], *dst = buffer;
if (!str) return "(null)";
if (!((ULONG_PTR)str >> 16)) return wine_dbg_sprintf( "#%04x", LOWORD(str) );
#ifndef WINE_UNIX_LIB
if (IsBadStringPtrA( str, n )) return "(invalid)";
#endif
if (n == -1) for (n = 0; str[n]; n++) ;
*dst++ = '"';
while (n-- > 0 && dst <= buffer + sizeof(buffer) - 9)
{
unsigned char c = *str++;
switch (c)
{
case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
case '\t': *dst++ = '\\'; *dst++ = 't'; break;
case '"': *dst++ = '\\'; *dst++ = '"'; break;
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
default:
if (c < ' ')
{
*dst++ = '\\';
*dst++ = 'x';
*dst++ = hex[(c >> 4) & 0x0f];
*dst++ = hex[c & 0x0f];
}
else if (c >= 127)
{
#if defined _NTSYSTEM_ || defined WINE_UNIX_LIB
*dst++ = '\\';
*dst++ = 'x';
*dst++ = hex[(c >> 4) & 0x0f];
*dst++ = hex[c & 0x0f];
#else
WCHAR wc;
DWORD reslen;
RtlMultiByteToUnicodeN(&wc, sizeof(wc), &reslen, (const char *)&c, 1);
RtlUnicodeToUTF8N(dst, 4, &reslen, &wc, sizeof(wc));
dst += reslen;
#endif
}
else *dst++ = c;
}
}
*dst++ = '"';
if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
*dst++ = '.';
}
*dst = 0;
return __wine_dbg_strdup( buffer );
}
static inline const char *wine_dbgstr_wn( const WCHAR *str, int n )
{
static const char hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
char buffer[300], *dst = buffer;
if (!str) return "(null)";
if (!((ULONG_PTR)str >> 16)) return wine_dbg_sprintf( "#%04x", LOWORD(str) );
#ifndef WINE_UNIX_LIB
if (IsBadStringPtrW( str, n )) return "(invalid)";
#endif
if (n == -1) for (n = 0; str[n]; n++) ;
*dst++ = 'L';
*dst++ = '"';
while (n-- > 0 && dst <= buffer + sizeof(buffer) - 10)
{
WCHAR c = *str++;
switch (c)
{
case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
case '\t': *dst++ = '\\'; *dst++ = 't'; break;
case '"': *dst++ = '\\'; *dst++ = '"'; break;
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
default:
if (c < ' ')
{
*dst++ = '\\';
*dst++ = hex[(c >> 12) & 0x0f];
*dst++ = hex[(c >> 8) & 0x0f];
*dst++ = hex[(c >> 4) & 0x0f];
*dst++ = hex[c & 0x0f];
}
else if (c >= 127)
{
DWORD reslen;
#if defined _NTSYSTEM_ || defined WINE_UNIX_LIB
reslen = ntdll_wcstoumbs(&c, 1, dst, 4, FALSE);
#else
RtlUnicodeToUTF8N(dst, 4, &reslen, &c, sizeof(c));
#endif
dst += reslen;
}
else *dst++ = (char)c;
}
}
*dst++ = '"';
if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
*dst++ = '.';
}
*dst = 0;
return __wine_dbg_strdup( buffer );
}
static inline const char *wine_dbgstr_a( const char *s )
{
return wine_dbgstr_an( s, -1 );
}
static inline const char *wine_dbgstr_w( const WCHAR *s )
{
return wine_dbgstr_wn( s, -1 );
}
#if defined(__hstring_h__) && defined(__WINSTRING_H_)
static inline const char *wine_dbgstr_hstring( HSTRING hstr )
{
UINT32 len;
const WCHAR *str = WindowsGetStringRawBuffer( hstr, &len );
return wine_dbgstr_wn( str, len );
}
#endif
static inline const char *wine_dbgstr_guid( const GUID *id )
{
if (!id) return "(null)";
if (!((ULONG_PTR)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04hx>", (WORD)(ULONG_PTR)id );
return wine_dbg_sprintf( "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
(unsigned int)id->Data1, id->Data2, id->Data3,
id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
}
static inline const char *wine_dbgstr_fourcc( unsigned int fourcc )
{
char str[4] = { (char)fourcc, (char)(fourcc >> 8), (char)(fourcc >> 16), (char)(fourcc >> 24) };
if (!fourcc)
return "''";
if (isprint( str[0] ) && isprint( str[1] ) && isprint( str[2] ) && isprint( str[3] ))
return wine_dbg_sprintf( "'%.4s'", str );
return wine_dbg_sprintf( "0x%08x", fourcc );
}
static inline const char *wine_dbgstr_point( const POINT *pt )
{
if (!pt) return "(null)";
return wine_dbg_sprintf( "(%d,%d)", (int)pt->x, (int)pt->y );
}
static inline const char *wine_dbgstr_rect( const RECT *rect )
{
if (!rect) return "(null)";
return wine_dbg_sprintf( "(%d,%d)-(%d,%d)", (int)rect->left, (int)rect->top,
(int)rect->right, (int)rect->bottom );
}
static inline const char *wine_dbgstr_longlong( ULONGLONG ll )
{
if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
}
#if defined(__oaidl_h__) && defined(V_VT)
static inline const char *wine_dbgstr_vt( VARTYPE vt )
{
static const char *const variant_types[] =
{
"VT_EMPTY","VT_NULL","VT_I2","VT_I4","VT_R4","VT_R8","VT_CY","VT_DATE",
"VT_BSTR","VT_DISPATCH","VT_ERROR","VT_BOOL","VT_VARIANT","VT_UNKNOWN",
"VT_DECIMAL","15","VT_I1","VT_UI1","VT_UI2","VT_UI4","VT_I8","VT_UI8",
"VT_INT","VT_UINT","VT_VOID","VT_HRESULT","VT_PTR","VT_SAFEARRAY",
"VT_CARRAY","VT_USERDEFINED","VT_LPSTR","VT_LPWSTR","32","33","34","35",
"VT_RECORD","VT_INT_PTR","VT_UINT_PTR","39","40","41","42","43","44","45",
"46","47","48","49","50","51","52","53","54","55","56","57","58","59","60",
"61","62","63","VT_FILETIME","VT_BLOB","VT_STREAM","VT_STORAGE",
"VT_STREAMED_OBJECT","VT_STORED_OBJECT","VT_BLOB_OBJECT","VT_CF","VT_CLSID",
"VT_VERSIONED_STREAM"
};
static const char *const variant_flags[16] =
{
"",
"|VT_VECTOR",
"|VT_ARRAY",
"|VT_VECTOR|VT_ARRAY",
"|VT_BYREF",
"|VT_VECTOR|VT_BYREF",
"|VT_ARRAY|VT_BYREF",
"|VT_VECTOR|VT_ARRAY|VT_BYREF",
"|VT_RESERVED",
"|VT_VECTOR|VT_RESERVED",
"|VT_ARRAY|VT_RESERVED",
"|VT_VECTOR|VT_ARRAY|VT_RESERVED",
"|VT_BYREF|VT_RESERVED",
"|VT_VECTOR|VT_BYREF|VT_RESERVED",
"|VT_ARRAY|VT_BYREF|VT_RESERVED",
"|VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED",
};
if (vt & ~VT_TYPEMASK)
return wine_dbg_sprintf( "%s%s", wine_dbgstr_vt(vt&VT_TYPEMASK), variant_flags[vt>>12] );
if (vt < sizeof(variant_types)/sizeof(*variant_types))
return variant_types[vt];
if (vt == VT_BSTR_BLOB)
return "VT_BSTR_BLOB";
return wine_dbg_sprintf( "vt(invalid %x)", vt );
}
static inline const char *wine_dbgstr_variant( const VARIANT *v )
{
if (!v)
return "(null)";
if (V_VT(v) & VT_BYREF) {
if (V_VT(v) == (VT_VARIANT|VT_BYREF))
return wine_dbg_sprintf( "%p {VT_VARIANT|VT_BYREF: %s}", v, wine_dbgstr_variant(V_VARIANTREF(v)) );
if (V_VT(v) == (VT_BSTR|VT_BYREF))
return wine_dbg_sprintf( "%p {VT_BSTR|VT_BYREF: %s}", v, V_BSTRREF(v) ? wine_dbgstr_w(*V_BSTRREF(v)) : "(none)" );
return wine_dbg_sprintf( "%p {%s %p}", v, wine_dbgstr_vt(V_VT(v)), V_BYREF(v) );
}
if (V_ISARRAY(v) || V_ISVECTOR(v))
return wine_dbg_sprintf( "%p {%s %p}", v, wine_dbgstr_vt(V_VT(v)), V_ARRAY(v) );
switch(V_VT(v)) {
case VT_EMPTY:
return wine_dbg_sprintf( "%p {VT_EMPTY}", v );
case VT_NULL:
return wine_dbg_sprintf( "%p {VT_NULL}", v );
case VT_I2:
return wine_dbg_sprintf( "%p {VT_I2: %d}", v, V_I2(v) );
case VT_I4:
return wine_dbg_sprintf( "%p {VT_I4: %d}", v, (int)V_I4(v) );
case VT_R4:
return wine_dbg_sprintf( "%p {VT_R4: %f}", v, V_R4(v) );
case VT_R8:
return wine_dbg_sprintf( "%p {VT_R8: %lf}", v, V_R8(v) );
case VT_CY:
return wine_dbg_sprintf( "%p {VT_CY: %s}", v, wine_dbgstr_longlong(V_CY(v).int64) );
case VT_DATE:
return wine_dbg_sprintf( "%p {VT_DATE: %lf}", v, V_DATE(v) );
case VT_LPSTR:
return wine_dbg_sprintf( "%p {VT_LPSTR: %s}", v, wine_dbgstr_a((const char *)V_BSTR(v)) );
case VT_LPWSTR:
return wine_dbg_sprintf( "%p {VT_LPWSTR: %s}", v, wine_dbgstr_w(V_BSTR(v)) );
case VT_BSTR:
return wine_dbg_sprintf( "%p {VT_BSTR: %s}", v, wine_dbgstr_w(V_BSTR(v)) );
case VT_DISPATCH:
return wine_dbg_sprintf( "%p {VT_DISPATCH: %p}", v, V_DISPATCH(v) );
case VT_ERROR:
return wine_dbg_sprintf( "%p {VT_ERROR: %08x}", v, (int)V_ERROR(v) );
case VT_BOOL:
return wine_dbg_sprintf( "%p {VT_BOOL: %x}", v, V_BOOL(v) );
case VT_UNKNOWN:
return wine_dbg_sprintf( "%p {VT_UNKNOWN: %p}", v, V_UNKNOWN(v) );
case VT_I1:
return wine_dbg_sprintf( "%p {VT_I1: %d}", v, V_I1(v) );
case VT_UI1:
return wine_dbg_sprintf( "%p {VT_UI1: %u}", v, V_UI1(v) );
case VT_UI2:
return wine_dbg_sprintf( "%p {VT_UI2: %u}", v, V_UI2(v) );
case VT_UI4:
return wine_dbg_sprintf( "%p {VT_UI4: %u}", v, (unsigned int)V_UI4(v) );
case VT_I8:
return wine_dbg_sprintf( "%p {VT_I8: %s}", v, wine_dbgstr_longlong(V_I8(v)) );
case VT_UI8:
return wine_dbg_sprintf( "%p {VT_UI8: %s}", v, wine_dbgstr_longlong(V_UI8(v)) );
case VT_INT:
return wine_dbg_sprintf( "%p {VT_INT: %d}", v, V_INT(v) );
case VT_UINT:
return wine_dbg_sprintf( "%p {VT_UINT: %u}", v, V_UINT(v) );
case VT_VOID:
return wine_dbg_sprintf( "%p {VT_VOID}", v );
case VT_RECORD:
return wine_dbg_sprintf( "%p {VT_RECORD: %p %p}", v, V_RECORD(v), V_RECORDINFO(v) );
default:
return wine_dbg_sprintf( "%p {vt %s}", v, wine_dbgstr_vt(V_VT(v)) );
}
}
#endif /* defined(__oaidl_h__) && defined(V_VT) */
#ifndef WINE_TRACE
#define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default)
#define WINE_TRACE_(ch) __WINE_DPRINTF(_TRACE,&__wine_dbch_##ch)
#endif
#define WINE_TRACE_ON(ch) __WINE_IS_DEBUG_ON(_TRACE,&__wine_dbch_##ch)
#ifndef WINE_WARN
#define WINE_WARN __WINE_DPRINTF(_WARN,__wine_dbch___default)
#define WINE_WARN_(ch) __WINE_DPRINTF(_WARN,&__wine_dbch_##ch)
#endif
#define WINE_WARN_ON(ch) __WINE_IS_DEBUG_ON(_WARN,&__wine_dbch_##ch)
#ifndef WINE_FIXME
#define WINE_FIXME __WINE_DPRINTF(_FIXME,__wine_dbch___default)
#define WINE_FIXME_(ch) __WINE_DPRINTF(_FIXME,&__wine_dbch_##ch)
#endif
#define WINE_FIXME_ON(ch) __WINE_IS_DEBUG_ON(_FIXME,&__wine_dbch_##ch)
#ifndef WINE_NOTOUR
#define WINE_NOTOUR __WINE_DPRINTF(_NOTOUR,__wine_dbch___default)
#define WINE_NOTOUR_(ch) __WINE_DPRINTF(_NOTOUR,&__wine_dbch_##ch)
#endif
#define WINE_NOTOUR_ON(ch) __WINE_IS_DEBUG_ON(_NOTOUR,&__wine_dbch_##ch)
#define WINE_ERR __WINE_DPRINTF(_ERR,__wine_dbch___default)
#define WINE_ERR_(ch) __WINE_DPRINTF(_ERR,&__wine_dbch_##ch)
#define WINE_ERR_ON(ch) __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch)
#define WINE_DECLARE_DEBUG_CHANNEL(ch) \
static struct __wine_debug_channel __wine_dbch_##ch = { 0xff, #ch }; \
C_ASSERT(sizeof(#ch) <= sizeof(__wine_dbch_##ch.name))
#define WINE_DEFAULT_DEBUG_CHANNEL(ch) \
static struct __wine_debug_channel __wine_dbch_##ch = { 0xff, #ch }; \
C_ASSERT(sizeof(#ch) <= sizeof(__wine_dbch_##ch.name)); \
static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch
#define WINE_MESSAGE wine_dbg_printf
#ifdef __WINESRC__
/* Wine uses shorter names that are very likely to conflict with other software */
static inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
static inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); }
static inline const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); }
static inline const char *debugstr_fourcc( unsigned int cc ) { return wine_dbgstr_fourcc( cc ); }
static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); }
static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
#if defined(__hstring_h__) && defined(__WINSTRING_H_)
static inline const char *debugstr_hstring( struct HSTRING__ *s ) { return wine_dbgstr_hstring( s ); }
#endif
#if defined(__oaidl_h__) && defined(V_VT)
static inline const char *debugstr_vt( VARTYPE vt ) { return wine_dbgstr_vt( vt ); }
static inline const char *debugstr_variant( const VARIANT *v ) { return wine_dbgstr_variant( v ); }
#endif
#define TRACE WINE_TRACE
#define TRACE_(ch) WINE_TRACE_(ch)
#define TRACE_ON(ch) WINE_TRACE_ON(ch)
#define WARN WINE_WARN
#define WARN_(ch) WINE_WARN_(ch)
#define WARN_ON(ch) WINE_WARN_ON(ch)
#define FIXME WINE_FIXME
#define FIXME_(ch) WINE_FIXME_(ch)
#define FIXME_ON(ch) WINE_FIXME_ON(ch)
#define NOTOUR WINE_NOTOUR
#define NOTOUR_(ch) WINE_NOTOUR_(ch)
#define NOTOUR_ON(ch) WINE_NOTOUR_ON(ch)
#undef ERR /* Solaris got an 'ERR' define in <sys/reg.h> */
#define ERR WINE_ERR
#define ERR_(ch) WINE_ERR_(ch)
#define ERR_ON(ch) WINE_ERR_ON(ch)
#define MESSAGE WINE_MESSAGE
#endif /* __WINESRC__ */
#ifdef __cplusplus
}
#endif
#endif /* __WINE_WINE_DEBUG_H */
/*
* Definitions for Unix libraries
*
* Copyright (C) 2021 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_WINE_UNIXLIB_H
#define __WINE_WINE_UNIXLIB_H
#include "winternl.h"
typedef UINT64 unixlib_handle_t;
#ifdef WINE_UNIX_LIB
typedef NTSTATUS (*unixlib_entry_t)( void *args );
extern DECLSPEC_EXPORT const unixlib_entry_t __wine_unix_call_funcs[];
extern DECLSPEC_EXPORT const unixlib_entry_t __wine_unix_call_wow64_funcs[];
/* some useful helpers from ntdll */
NTSYSAPI const char *ntdll_get_build_dir(void);
NTSYSAPI const char *ntdll_get_data_dir(void);
NTSYSAPI DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen );
NTSYSAPI int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict );
NTSYSAPI int ntdll_wcsicmp( const WCHAR *str1, const WCHAR *str2 );
NTSYSAPI int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n );
/* exception handling */
#ifdef __i386__
typedef struct { int reg[16]; } __wine_jmp_buf;
#elif defined(__x86_64__)
typedef struct { DECLSPEC_ALIGN(16) struct { unsigned __int64 Part[2]; } reg[16]; } __wine_jmp_buf;
#elif defined(__arm__)
typedef struct { int reg[28]; } __wine_jmp_buf;
#elif defined(__aarch64__)
typedef struct { __int64 reg[24]; } __wine_jmp_buf;
#else
typedef struct { int reg; } __wine_jmp_buf;
#endif
NTSYSAPI int __attribute__ ((__nothrow__,__returns_twice__)) __wine_setjmpex( __wine_jmp_buf *buf,
EXCEPTION_REGISTRATION_RECORD *frame );
NTSYSAPI void DECLSPEC_NORETURN __wine_longjmp( __wine_jmp_buf *buf, int retval );
NTSYSAPI void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp );
#define __TRY \
do { __wine_jmp_buf __jmp; \
int __first = 1; \
for (;;) if (!__first) \
{ \
do {
#define __EXCEPT \
} while(0); \
ntdll_set_exception_jmp_buf( NULL ); \
break; \
} else { \
if (__wine_setjmpex( &__jmp, NULL )) { \
do {
#define __ENDTRY \
} while (0); \
break; \
} \
ntdll_set_exception_jmp_buf( &__jmp ); \
__first = 0; \
} \
} while (0);
NTSYSAPI BOOLEAN KeAddSystemServiceTable( ULONG_PTR *funcs, ULONG_PTR *counters, ULONG limit,
BYTE *arguments, ULONG index );
NTSYSAPI NTSTATUS KeUserModeCallback( ULONG id, const void *args, ULONG len, void **ret_ptr, ULONG *ret_len );
/* wide char string functions */
static inline int ntdll_iswspace( WCHAR wc )
{
return ('\t' <= wc && wc <= '\r') || wc == ' ' || wc == 0xa0;
}
static inline size_t ntdll_wcslen( const WCHAR *str )
{
const WCHAR *s = str;
while (*s) s++;
return s - str;
}
static inline WCHAR *ntdll_wcscpy( WCHAR *dst, const WCHAR *src )
{
WCHAR *p = dst;
while ((*p++ = *src++));
return dst;
}
static inline WCHAR *ntdll_wcscat( WCHAR *dst, const WCHAR *src )
{
ntdll_wcscpy( dst + ntdll_wcslen(dst), src );
return dst;
}
static inline int ntdll_wcscmp( const WCHAR *str1, const WCHAR *str2 )
{
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
return *str1 - *str2;
}
static inline int ntdll_wcsncmp( const WCHAR *str1, const WCHAR *str2, int n )
{
if (n <= 0) return 0;
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
return *str1 - *str2;
}
static inline WCHAR *ntdll_wcschr( const WCHAR *str, WCHAR ch )
{
do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
return NULL;
}
static inline WCHAR *ntdll_wcsrchr( const WCHAR *str, WCHAR ch )
{
WCHAR *ret = NULL;
do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
return ret;
}
static inline WCHAR *ntdll_wcspbrk( const WCHAR *str, const WCHAR *accept )
{
for ( ; *str; str++) if (ntdll_wcschr( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
return NULL;
}
static inline SIZE_T ntdll_wcsspn( const WCHAR *str, const WCHAR *accept )
{
const WCHAR *ptr;
for (ptr = str; *ptr; ptr++) if (!ntdll_wcschr( accept, *ptr )) break;
return ptr - str;
}
static inline SIZE_T ntdll_wcscspn( const WCHAR *str, const WCHAR *reject )
{
const WCHAR *ptr;
for (ptr = str; *ptr; ptr++) if (ntdll_wcschr( reject, *ptr )) break;
return ptr - str;
}
static inline LONG ntdll_wcstol( const WCHAR *s, WCHAR **end, int base )
{
BOOL negative = FALSE, empty = TRUE;
LONG ret = 0;
if (base < 0 || base == 1 || base > 36) return 0;
if (end) *end = (WCHAR *)s;
while (ntdll_iswspace(*s)) s++;
if (*s == '-')
{
negative = TRUE;
s++;
}
else if (*s == '+') s++;
if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
{
base = 16;
s += 2;
}
if (base == 0) base = s[0] != '0' ? 10 : 8;
while (*s)
{
int v;
if ('0' <= *s && *s <= '9') v = *s - '0';
else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10;
else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10;
else break;
if (v >= base) break;
if (negative) v = -v;
s++;
empty = FALSE;
if (!negative && (ret > MAXLONG / base || ret * base > MAXLONG - v))
ret = MAXLONG;
else if (negative && (ret < (LONG)MINLONG / base || ret * base < (LONG)(MINLONG - v)))
ret = MINLONG;
else
ret = ret * base + v;
}
if (end && !empty) *end = (WCHAR *)s;
return ret;
}
static inline ULONG ntdll_wcstoul( const WCHAR *s, WCHAR **end, int base )
{
BOOL negative = FALSE, empty = TRUE;
ULONG ret = 0;
if (base < 0 || base == 1 || base > 36) return 0;
if (end) *end = (WCHAR *)s;
while (ntdll_iswspace(*s)) s++;
if (*s == '-')
{
negative = TRUE;
s++;
}
else if (*s == '+') s++;
if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
{
base = 16;
s += 2;
}
if (base == 0) base = s[0] != '0' ? 10 : 8;
while (*s)
{
int v;
if ('0' <= *s && *s <= '9') v = *s - '0';
else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10;
else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10;
else break;
if (v >= base) break;
s++;
empty = FALSE;
if (ret > MAXDWORD / base || ret * base > MAXDWORD - v)
ret = MAXDWORD;
else
ret = ret * base + v;
}
if (end && !empty) *end = (WCHAR *)s;
return negative ? -ret : ret;
}
#define iswspace(ch) ntdll_iswspace(ch)
#define wcslen(str) ntdll_wcslen(str)
#define wcscpy(dst,src) ntdll_wcscpy(dst,src)
#define wcscat(dst,src) ntdll_wcscat(dst,src)
#define wcscmp(s1,s2) ntdll_wcscmp(s1,s2)
#define wcsncmp(s1,s2,n) ntdll_wcsncmp(s1,s2,n)
#define wcschr(str,ch) ntdll_wcschr(str,ch)
#define wcsrchr(str,ch) ntdll_wcsrchr(str,ch)
#define wcspbrk(str,ac) ntdll_wcspbrk(str,ac)
#define wcsspn(str,ac) ntdll_wcsspn(str,ac)
#define wcscspn(str,rej) ntdll_wcscspn(str,rej)
#define wcsicmp(s1, s2) ntdll_wcsicmp(s1,s2)
#define wcsnicmp(s1, s2,n) ntdll_wcsnicmp(s1,s2,n)
#define wcstol(str,e,b) ntdll_wcstol(str,e,b)
#define wcstoul(str,e,b) ntdll_wcstoul(str,e,b)
#else /* WINE_UNIX_LIB */
NTSYSAPI NTSTATUS WINAPI __wine_unix_call( unixlib_handle_t handle, unsigned int code, void *args );
extern unixlib_handle_t __wine_unixlib_handle;
extern NTSTATUS (WINAPI *__wine_unix_call_dispatcher)( unixlib_handle_t, unsigned int, void * );
extern NTSTATUS WINAPI __wine_init_unix_call(void);
#define WINE_UNIX_CALL(code,args) __wine_unix_call_dispatcher( __wine_unixlib_handle, (code), (args) )
#endif /* WINE_UNIX_LIB */
#endif /* __WINE_WINE_UNIXLIB_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment