mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:52:57 +00:00
[IMM32][NETAPI32][SDK] Reduce Wine dependency (#7912)
Related to #7870. netapi32.dll uses NDK. So, we have to reduce dependency on Wine. JIRA issue: CORE-5743 - Introduce wine2ros module in sdk/lib/wine2ros/. - Reduce Wine dependency.
This commit is contained in:
parent
45b928f8bc
commit
2c475add8c
9 changed files with 367 additions and 97 deletions
|
@ -27,6 +27,6 @@ add_rc_deps(imm32.rc ${imm32_rc_deps})
|
||||||
|
|
||||||
add_library(imm32 MODULE ${SOURCE} imm32.rc)
|
add_library(imm32 MODULE ${SOURCE} imm32.rc)
|
||||||
set_module_type(imm32 win32dll UNICODE ENTRYPOINT ImmDllInitialize 12)
|
set_module_type(imm32 win32dll UNICODE ENTRYPOINT ImmDllInitialize 12)
|
||||||
target_link_libraries(imm32 wine win32ksys uuid)
|
target_link_libraries(imm32 wine2ros win32ksys uuid)
|
||||||
add_importlibs(imm32 advapi32 user32 gdi32 kernel32 ntdll)
|
add_importlibs(imm32 advapi32 user32 gdi32 kernel32 ntdll)
|
||||||
add_cd_file(TARGET imm32 DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET imm32 DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
/*
|
|
||||||
* PROJECT: ReactOS IMM32
|
|
||||||
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
|
||||||
* PURPOSE: Debugging IMM32
|
|
||||||
* COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef enum tagDEBUGCHANNEL
|
|
||||||
{
|
|
||||||
DbgChimm = 0,
|
|
||||||
} DEBUGCHANNEL;
|
|
||||||
|
|
||||||
#if DBG
|
|
||||||
#ifndef __RELFILE__
|
|
||||||
#define __RELFILE__ __FILE__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ERR_LEVEL 0x1
|
|
||||||
#define TRACE_LEVEL 0x8
|
|
||||||
|
|
||||||
#define WINE_DEFAULT_DEBUG_CHANNEL(x) static int DbgDefaultChannel = DbgCh##x;
|
|
||||||
#define DBG_IS_CHANNEL_ENABLED(ch) Imm32IsDebugChannelEnabled(ch)
|
|
||||||
|
|
||||||
#define DBG_PRINT(ch, level, tag, fmt, ...) (void)( \
|
|
||||||
(((level) == ERR_LEVEL) || DBG_IS_CHANNEL_ENABLED(ch)) ? \
|
|
||||||
(DbgPrint("(%s:%d) %s" fmt, __RELFILE__, __LINE__, (tag), ##__VA_ARGS__), FALSE) : TRUE \
|
|
||||||
)
|
|
||||||
|
|
||||||
#define ERR(fmt, ...) DBG_PRINT(DbgDefaultChannel, ERR_LEVEL, "err: ", fmt, ##__VA_ARGS__)
|
|
||||||
#define WARN(fmt, ...) DBG_PRINT(DbgDefaultChannel, ERR_LEVEL, "warn: ", fmt, ##__VA_ARGS__)
|
|
||||||
#define FIXME(fmt, ...) DBG_PRINT(DbgDefaultChannel, ERR_LEVEL, "fixme: ", fmt, ##__VA_ARGS__)
|
|
||||||
#define TRACE(fmt, ...) DBG_PRINT(DbgDefaultChannel, TRACE_LEVEL, "", fmt, ##__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define WINE_DEFAULT_DEBUG_CHANNEL(x)
|
|
||||||
#define DBG_IS_CHANNEL_ENABLED(ch,level)
|
|
||||||
#define DBG_PRINT(ch,level)
|
|
||||||
#define ERR(fmt, ...)
|
|
||||||
#define WARN(fmt, ...)
|
|
||||||
#define FIXME(fmt, ...)
|
|
||||||
#define TRACE(fmt, ...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DBG
|
|
||||||
static inline BOOL
|
|
||||||
Imm32IsDebugChannelEnabled(DEBUGCHANNEL channel)
|
|
||||||
{
|
|
||||||
CHAR szValue[MAX_PATH], *pch0, *pch;
|
|
||||||
|
|
||||||
if (!GetEnvironmentVariableA("DEBUGCHANNEL", szValue, _countof(szValue)))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
for (pch0 = szValue;; pch0 = pch + 1)
|
|
||||||
{
|
|
||||||
pch = strchr(pch0, ',');
|
|
||||||
if (pch)
|
|
||||||
*pch = ANSI_NULL;
|
|
||||||
if (channel == DbgChimm && _stricmp(pch0, "imm") == 0)
|
|
||||||
return TRUE;
|
|
||||||
if (!pch)
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* #define UNEXPECTED() (ASSERT(FALSE), TRUE) */
|
|
||||||
#define UNEXPECTED() TRUE
|
|
||||||
|
|
||||||
/* Unexpected Condition Checkers */
|
|
||||||
#if DBG
|
|
||||||
#define FAILED_UNEXPECTEDLY(hr) \
|
|
||||||
(FAILED(hr) ? (ERR("FAILED(0x%08X)\n", hr), UNEXPECTED()) : FALSE)
|
|
||||||
#define IS_NULL_UNEXPECTEDLY(p) \
|
|
||||||
(!(p) ? (ERR("%s was NULL\n", #p), UNEXPECTED()) : FALSE)
|
|
||||||
#define IS_ZERO_UNEXPECTEDLY(p) \
|
|
||||||
(!(p) ? (ERR("%s was zero\n", #p), UNEXPECTED()) : FALSE)
|
|
||||||
#define IS_TRUE_UNEXPECTEDLY(x) \
|
|
||||||
((x) ? (ERR("%s was %d\n", #x, (int)(x)), UNEXPECTED()) : FALSE)
|
|
||||||
#define IS_ERROR_UNEXPECTEDLY(x) \
|
|
||||||
((x) != ERROR_SUCCESS ? (ERR("%s was %d\n", #x, (int)(x)), UNEXPECTED()) : FALSE)
|
|
||||||
#else
|
|
||||||
#define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
|
|
||||||
#define IS_NULL_UNEXPECTEDLY(p) (!(p))
|
|
||||||
#define IS_ZERO_UNEXPECTEDLY(p) (!(p))
|
|
||||||
#define IS_TRUE_UNEXPECTEDLY(x) (x)
|
|
||||||
#define IS_ERROR_UNEXPECTEDLY(x) ((x) != ERROR_SUCCESS)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IS_CROSS_THREAD_HIMC(hIMC) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))
|
|
||||||
#define IS_CROSS_PROCESS_HWND(hWnd) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))
|
|
|
@ -44,7 +44,33 @@
|
||||||
|
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
|
||||||
#include "debug.h"
|
#include <wine2ros.h>
|
||||||
|
|
||||||
|
/* #define UNEXPECTED() (ASSERT(FALSE), TRUE) */
|
||||||
|
#define UNEXPECTED() TRUE
|
||||||
|
|
||||||
|
/* Unexpected Condition Checkers */
|
||||||
|
#if DBG
|
||||||
|
#define FAILED_UNEXPECTEDLY(hr) \
|
||||||
|
(FAILED(hr) ? (ERR("FAILED(0x%08X)\n", hr), UNEXPECTED()) : FALSE)
|
||||||
|
#define IS_NULL_UNEXPECTEDLY(p) \
|
||||||
|
(!(p) ? (ERR("%s was NULL\n", #p), UNEXPECTED()) : FALSE)
|
||||||
|
#define IS_ZERO_UNEXPECTEDLY(p) \
|
||||||
|
(!(p) ? (ERR("%s was zero\n", #p), UNEXPECTED()) : FALSE)
|
||||||
|
#define IS_TRUE_UNEXPECTEDLY(x) \
|
||||||
|
((x) ? (ERR("%s was %d\n", #x, (int)(x)), UNEXPECTED()) : FALSE)
|
||||||
|
#define IS_ERROR_UNEXPECTEDLY(x) \
|
||||||
|
((x) != ERROR_SUCCESS ? (ERR("%s was %d\n", #x, (int)(x)), UNEXPECTED()) : FALSE)
|
||||||
|
#else
|
||||||
|
#define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
|
||||||
|
#define IS_NULL_UNEXPECTEDLY(p) (!(p))
|
||||||
|
#define IS_ZERO_UNEXPECTEDLY(p) (!(p))
|
||||||
|
#define IS_TRUE_UNEXPECTEDLY(x) (x)
|
||||||
|
#define IS_ERROR_UNEXPECTEDLY(x) ((x) != ERROR_SUCCESS)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IS_CROSS_THREAD_HIMC(hIMC) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))
|
||||||
|
#define IS_CROSS_PROCESS_HWND(hWnd) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))
|
||||||
|
|
||||||
#define IMM_INIT_MAGIC 0x19650412
|
#define IMM_INIT_MAGIC 0x19650412
|
||||||
#define IMM_INVALID_CANDFORM ULONG_MAX
|
#define IMM_INVALID_CANDFORM ULONG_MAX
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl
|
${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl)
|
||||||
${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
|
|
||||||
|
|
||||||
add_definitions(-D__WINESRC__)
|
|
||||||
spec2def(netapi32.dll netapi32.spec ADD_IMPORTLIB)
|
spec2def(netapi32.dll netapi32.spec ADD_IMPORTLIB)
|
||||||
add_rpc_files(client
|
add_rpc_files(client
|
||||||
${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl/atsvc.idl
|
${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl/atsvc.idl
|
||||||
|
@ -53,7 +51,7 @@ add_library(netapi32 MODULE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/netapi32.def)
|
${CMAKE_CURRENT_BINARY_DIR}/netapi32.def)
|
||||||
|
|
||||||
set_module_type(netapi32 win32dll)
|
set_module_type(netapi32 win32dll)
|
||||||
target_link_libraries(netapi32 wine ${PSEH_LIB})
|
target_link_libraries(netapi32 wine2ros ${PSEH_LIB})
|
||||||
add_delay_importlibs(netapi32 samlib secur32)
|
add_delay_importlibs(netapi32 samlib secur32)
|
||||||
add_importlibs(netapi32 iphlpapi ws2_32 advapi32 rpcrt4 msvcrt kernel32 ntdll)
|
add_importlibs(netapi32 iphlpapi ws2_32 advapi32 rpcrt4 msvcrt kernel32 ntdll)
|
||||||
add_pch(netapi32 netapi32.h "${PCH_SKIP_SOURCE}")
|
add_pch(netapi32 netapi32.h "${PCH_SKIP_SOURCE}")
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#ifndef __WINE_NETAPI32_H__
|
#ifndef __WINE_NETAPI32_H__
|
||||||
#define __WINE_NETAPI32_H__
|
#define __WINE_NETAPI32_H__
|
||||||
|
|
||||||
|
#ifndef __REACTOS__
|
||||||
#include <wine/config.h>
|
#include <wine/config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -19,8 +21,12 @@
|
||||||
#include <nb30.h>
|
#include <nb30.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
#include <wine2ros.h>
|
||||||
|
#else
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
#include <wine/unicode.h>
|
#include <wine/unicode.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ndk/rtlfuncs.h>
|
#include <ndk/rtlfuncs.h>
|
||||||
|
|
|
@ -56,6 +56,7 @@ add_subdirectory(ucrt)
|
||||||
add_subdirectory(udmihelp)
|
add_subdirectory(udmihelp)
|
||||||
add_subdirectory(uuid)
|
add_subdirectory(uuid)
|
||||||
add_subdirectory(vcruntime)
|
add_subdirectory(vcruntime)
|
||||||
|
add_subdirectory(wine2ros)
|
||||||
add_subdirectory(wdmguid)
|
add_subdirectory(wdmguid)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
7
sdk/lib/wine2ros/CMakeLists.txt
Normal file
7
sdk/lib/wine2ros/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
list(APPEND SOURCE
|
||||||
|
wine2ros.c
|
||||||
|
)
|
||||||
|
add_library(wine2ros STATIC ${SOURCE})
|
||||||
|
add_dependencies(wine2ros psdk)
|
||||||
|
target_include_directories(wine2ros INTERFACE ${REACTOS_SOURCE_DIR}/sdk/lib/wine2ros)
|
235
sdk/lib/wine2ros/wine2ros.c
Normal file
235
sdk/lib/wine2ros/wine2ros.c
Normal file
|
@ -0,0 +1,235 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS Wine-To-ReactOS
|
||||||
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||||
|
* PURPOSE: Reducing dependency on Wine
|
||||||
|
* COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if DBG
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "wine2ros.h"
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
IntIsDebugChannelEnabled(_In_ PCSTR channel)
|
||||||
|
{
|
||||||
|
CHAR szValue[MAX_PATH];
|
||||||
|
PCHAR pch0, pch1;
|
||||||
|
BOOL ret;
|
||||||
|
DWORD error;
|
||||||
|
|
||||||
|
error = GetLastError();
|
||||||
|
ret = GetEnvironmentVariableA("DEBUGCHANNEL", szValue, _countof(szValue));
|
||||||
|
SetLastError(error);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
for (pch0 = szValue;; pch0 = pch1 + 1)
|
||||||
|
{
|
||||||
|
pch1 = strchr(pch0, ',');
|
||||||
|
if (pch1)
|
||||||
|
*pch1 = ANSI_NULL;
|
||||||
|
if (_stricmp(pch0, channel) == 0)
|
||||||
|
return TRUE;
|
||||||
|
if (!pch1)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEBUGSTR_HEX "0123456789ABCDEF"
|
||||||
|
#define DEBUGSTR_QUOTE_TAIL_LEN 8
|
||||||
|
|
||||||
|
static PSTR
|
||||||
|
debugstr_quote_a(
|
||||||
|
_Out_ PSTR pszBuf,
|
||||||
|
_In_ SIZE_T cchBuf,
|
||||||
|
_In_opt_ PCSTR pszSrc)
|
||||||
|
{
|
||||||
|
PCH pch = pszBuf;
|
||||||
|
PCCH pchSrc = pszSrc;
|
||||||
|
|
||||||
|
if (!pszSrc)
|
||||||
|
return "(null)";
|
||||||
|
|
||||||
|
if (!((ULONG_PTR)pszSrc >> 16))
|
||||||
|
{
|
||||||
|
snprintf(pszBuf, cchBuf, "%p", pszSrc);
|
||||||
|
return pszBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pch++ = '"';
|
||||||
|
--cchBuf;
|
||||||
|
|
||||||
|
for (; cchBuf > DEBUGSTR_QUOTE_TAIL_LEN; ++pchSrc)
|
||||||
|
{
|
||||||
|
switch (*pchSrc)
|
||||||
|
{
|
||||||
|
case '\'': case '\"': case '\\': case '\t': case '\r': case '\n':
|
||||||
|
*pch++ = '\\';
|
||||||
|
if (*pchSrc == '\t')
|
||||||
|
*pch++ = 't';
|
||||||
|
else if (*pchSrc == '\r')
|
||||||
|
*pch++ = 'r';
|
||||||
|
else if (*pchSrc == '\n')
|
||||||
|
*pch++ = 'n';
|
||||||
|
else
|
||||||
|
*pch++ = *pchSrc;
|
||||||
|
cchBuf -= 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if (*pchSrc >= ' ')
|
||||||
|
{
|
||||||
|
*pch++ = *pchSrc;
|
||||||
|
--cchBuf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pch++ = '\\';
|
||||||
|
*pch++ = 'x';
|
||||||
|
*pch++ = DEBUGSTR_HEX[(*pchSrc >> 4) & 0xF];
|
||||||
|
*pch++ = DEBUGSTR_HEX[*pchSrc & 0xF];
|
||||||
|
cchBuf -= 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cchBuf <= DEBUGSTR_QUOTE_TAIL_LEN)
|
||||||
|
{
|
||||||
|
*pch++ = '.';
|
||||||
|
*pch++ = '.';
|
||||||
|
*pch++ = '.';
|
||||||
|
}
|
||||||
|
*pch++ = '"';
|
||||||
|
*pch = ANSI_NULL;
|
||||||
|
return pszBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PSTR
|
||||||
|
debugstr_quote_w(
|
||||||
|
_Out_ PSTR pszBuf,
|
||||||
|
_In_ SIZE_T cchBuf,
|
||||||
|
_In_opt_ PCWSTR pszSrc)
|
||||||
|
{
|
||||||
|
PCH pch = pszBuf;
|
||||||
|
PCWCH pchSrc = pszSrc;
|
||||||
|
|
||||||
|
if (!pszSrc)
|
||||||
|
return "(null)";
|
||||||
|
|
||||||
|
if (!((ULONG_PTR)pszSrc >> 16))
|
||||||
|
{
|
||||||
|
snprintf(pszBuf, cchBuf, "%p", pszSrc);
|
||||||
|
return pszBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pch++ = '"';
|
||||||
|
--cchBuf;
|
||||||
|
|
||||||
|
for (; cchBuf > DEBUGSTR_QUOTE_TAIL_LEN; ++pchSrc)
|
||||||
|
{
|
||||||
|
switch (*pchSrc)
|
||||||
|
{
|
||||||
|
case L'\'': case L'\"': case L'\\': case L'\t': case L'\r': case L'\n':
|
||||||
|
*pch++ = '\\';
|
||||||
|
if (*pchSrc == L'\t')
|
||||||
|
*pch++ = 't';
|
||||||
|
else if (*pchSrc == L'\r')
|
||||||
|
*pch++ = 'r';
|
||||||
|
else if (*pchSrc == L'\n')
|
||||||
|
*pch++ = 'n';
|
||||||
|
else
|
||||||
|
*pch++ = *pchSrc;
|
||||||
|
cchBuf -= 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if (*pchSrc >= L' ' && *pchSrc < 0x100)
|
||||||
|
{
|
||||||
|
*pch++ = (CHAR)*pchSrc;
|
||||||
|
--cchBuf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pch++ = '\\';
|
||||||
|
*pch++ = 'x';
|
||||||
|
*pch++ = DEBUGSTR_HEX[(*pchSrc >> 12) & 0xF];
|
||||||
|
*pch++ = DEBUGSTR_HEX[(*pchSrc >> 8) & 0xF];
|
||||||
|
*pch++ = DEBUGSTR_HEX[(*pchSrc >> 4) & 0xF];
|
||||||
|
*pch++ = DEBUGSTR_HEX[*pchSrc & 0xF];
|
||||||
|
cchBuf -= 6;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cchBuf <= DEBUGSTR_QUOTE_TAIL_LEN)
|
||||||
|
{
|
||||||
|
*pch++ = '.';
|
||||||
|
*pch++ = '.';
|
||||||
|
*pch++ = '.';
|
||||||
|
}
|
||||||
|
*pch++ = '"';
|
||||||
|
*pch = ANSI_NULL;
|
||||||
|
return pszBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEBUGSTR_NUM_BUFFS 5
|
||||||
|
#define DEBUGSTR_BUFF_SIZE MAX_PATH
|
||||||
|
|
||||||
|
static LPSTR
|
||||||
|
debugstr_next_buff(void)
|
||||||
|
{
|
||||||
|
static CHAR s_bufs[DEBUGSTR_NUM_BUFFS][DEBUGSTR_BUFF_SIZE];
|
||||||
|
static SIZE_T s_index = 0;
|
||||||
|
PCHAR ptr = s_bufs[s_index];
|
||||||
|
s_index = (s_index + 1) % _countof(s_bufs);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCSTR
|
||||||
|
debugstr_a(_In_opt_ PCSTR pszA)
|
||||||
|
{
|
||||||
|
return debugstr_quote_a(debugstr_next_buff(), DEBUGSTR_BUFF_SIZE, pszA);
|
||||||
|
}
|
||||||
|
|
||||||
|
PCSTR
|
||||||
|
debugstr_w(_In_opt_ PCWSTR pszW)
|
||||||
|
{
|
||||||
|
return debugstr_quote_w(debugstr_next_buff(), DEBUGSTR_BUFF_SIZE, pszW);
|
||||||
|
}
|
||||||
|
|
||||||
|
PCSTR
|
||||||
|
debugstr_guid(_In_opt_ const GUID *id)
|
||||||
|
{
|
||||||
|
PCHAR ptr;
|
||||||
|
|
||||||
|
if (!id)
|
||||||
|
return "(null)";
|
||||||
|
|
||||||
|
ptr = debugstr_next_buff();
|
||||||
|
|
||||||
|
if (!((ULONG_PTR)id >> 16))
|
||||||
|
{
|
||||||
|
snprintf(ptr, DEBUGSTR_BUFF_SIZE, "%p", id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(ptr, DEBUGSTR_BUFF_SIZE,
|
||||||
|
"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DBG */
|
88
sdk/lib/wine2ros/wine2ros.h
Normal file
88
sdk/lib/wine2ros/wine2ros.h
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS Wine-To-ReactOS
|
||||||
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||||
|
* PURPOSE: Reducing dependency on Wine
|
||||||
|
* COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* <wine/debug.h> */
|
||||||
|
#if DBG
|
||||||
|
#ifndef __RELFILE__
|
||||||
|
#define __RELFILE__ __FILE__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ERR_LEVEL 0x1
|
||||||
|
#define TRACE_LEVEL 0x8
|
||||||
|
|
||||||
|
#define WINE_DEFAULT_DEBUG_CHANNEL(x) static PCSTR DbgDefaultChannel = #x;
|
||||||
|
|
||||||
|
BOOL IntIsDebugChannelEnabled(_In_ PCSTR channel);
|
||||||
|
|
||||||
|
#define DBG_PRINT(ch, level, tag, fmt, ...) (void)( \
|
||||||
|
(((level) == ERR_LEVEL) || IntIsDebugChannelEnabled(ch)) ? \
|
||||||
|
(DbgPrint("(%s:%d) %s" fmt, __RELFILE__, __LINE__, (tag), ##__VA_ARGS__), FALSE) : TRUE \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define ERR(fmt, ...) DBG_PRINT(DbgDefaultChannel, ERR_LEVEL, "err: ", fmt, ##__VA_ARGS__)
|
||||||
|
#define WARN(fmt, ...) DBG_PRINT(DbgDefaultChannel, ERR_LEVEL, "warn: ", fmt, ##__VA_ARGS__)
|
||||||
|
#define FIXME(fmt, ...) DBG_PRINT(DbgDefaultChannel, ERR_LEVEL, "fixme: ", fmt, ##__VA_ARGS__)
|
||||||
|
#define TRACE(fmt, ...) DBG_PRINT(DbgDefaultChannel, TRACE_LEVEL, "", fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define UNIMPLEMENTED FIXME("%s is unimplemented", __FUNCTION__);
|
||||||
|
|
||||||
|
PCSTR debugstr_a(_In_opt_ PCSTR pszA);
|
||||||
|
PCSTR debugstr_w(_In_opt_ PCWSTR pszW);
|
||||||
|
PCSTR debugstr_guid(_In_opt_ const GUID *id);
|
||||||
|
#else
|
||||||
|
#define WINE_DEFAULT_DEBUG_CHANNEL(x)
|
||||||
|
#define IntIsDebugChannelEnabled(channel) FALSE
|
||||||
|
#define DBG_PRINT(ch, level)
|
||||||
|
#define ERR(fmt, ...)
|
||||||
|
#define WARN(fmt, ...)
|
||||||
|
#define FIXME(fmt, ...)
|
||||||
|
#define TRACE(fmt, ...)
|
||||||
|
#define UNIMPLEMENTED
|
||||||
|
#define debugstr_a(pszA) ((PCSTR)NULL)
|
||||||
|
#define debugstr_w(pszW) ((PCSTR)NULL)
|
||||||
|
#define debugstr_guid(id) ((PCSTR)NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* <wine/unicode.h> */
|
||||||
|
#define memicmpW(s1,s2,n) _wcsnicmp((s1),(s2),(n))
|
||||||
|
#define strlenW(s) wcslen((s))
|
||||||
|
#define strcpyW(d,s) wcscpy((d),(s))
|
||||||
|
#define strcatW(d,s) wcscat((d),(s))
|
||||||
|
#define strcspnW(d,s) wcscspn((d),(s))
|
||||||
|
#define strstrW(d,s) wcsstr((d),(s))
|
||||||
|
#define strtolW(s,e,b) wcstol((s),(e),(b))
|
||||||
|
#define strchrW(s,c) wcschr((s),(c))
|
||||||
|
#define strrchrW(s,c) wcsrchr((s),(c))
|
||||||
|
#define strncmpW(s1,s2,n) wcsncmp((s1),(s2),(n))
|
||||||
|
#define strncpyW(s1,s2,n) wcsncpy((s1),(s2),(n))
|
||||||
|
#define strcmpW(s1,s2) wcscmp((s1),(s2))
|
||||||
|
#define strcmpiW(s1,s2) _wcsicmp((s1),(s2))
|
||||||
|
#define strncmpiW(s1,s2,n) _wcsnicmp((s1),(s2),(n))
|
||||||
|
#define strtoulW(s1,s2,b) wcstoul((s1),(s2),(b))
|
||||||
|
#define strspnW(str, accept) wcsspn((str),(accept))
|
||||||
|
#define strpbrkW(str, accept) wcspbrk((str),(accept))
|
||||||
|
#define tolowerW(n) towlower((n))
|
||||||
|
#define toupperW(n) towupper((n))
|
||||||
|
#define islowerW(n) iswlower((n))
|
||||||
|
#define isupperW(n) iswupper((n))
|
||||||
|
#define isalphaW(n) iswalpha((n))
|
||||||
|
#define isalnumW(n) iswalnum((n))
|
||||||
|
#define isdigitW(n) iswdigit((n))
|
||||||
|
#define isxdigitW(n) iswxdigit((n))
|
||||||
|
#define isspaceW(n) iswspace((n))
|
||||||
|
#define iscntrlW(n) iswcntrl((n))
|
||||||
|
#define atoiW(s) _wtoi((s))
|
||||||
|
#define atolW(s) _wtol((s))
|
||||||
|
#define strlwrW(s) _wcslwr((s))
|
||||||
|
#define struprW(s) _wcsupr((s))
|
||||||
|
#define sprintfW _swprintf
|
||||||
|
#define vsprintfW _vswprintf
|
||||||
|
#define snprintfW _snwprintf
|
||||||
|
#define vsnprintfW _vsnwprintf
|
||||||
|
#define isprintW iswprint
|
Loading…
Add table
Add a link
Reference in a new issue