From 515ead4a5d7cfbe29047ca90ed8fe1c581eae523 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 23 Sep 2014 19:48:41 +0000 Subject: [PATCH] [MSPATCHA] * Import from Wine 1.7.27. CORE-8550 #comment mspatcha.dll added in r64248. CORE-8540 svn path=/trunk/; revision=64248 --- reactos/dll/win32/CMakeLists.txt | 1 + reactos/dll/win32/mspatcha/CMakeLists.txt | 16 +++ reactos/dll/win32/mspatcha/mspatcha.spec | 12 ++ reactos/dll/win32/mspatcha/mspatcha_main.c | 128 +++++++++++++++++++++ reactos/dll/win32/mspatcha/version.rc | 26 +++++ reactos/include/psdk/patchapi.h | 52 +++++++++ reactos/media/doc/README.WINE | 1 + 7 files changed, 236 insertions(+) create mode 100644 reactos/dll/win32/mspatcha/CMakeLists.txt create mode 100644 reactos/dll/win32/mspatcha/mspatcha.spec create mode 100644 reactos/dll/win32/mspatcha/mspatcha_main.c create mode 100644 reactos/dll/win32/mspatcha/version.rc create mode 100644 reactos/include/psdk/patchapi.h diff --git a/reactos/dll/win32/CMakeLists.txt b/reactos/dll/win32/CMakeLists.txt index 40e0733e52a..5e65c5808de 100644 --- a/reactos/dll/win32/CMakeLists.txt +++ b/reactos/dll/win32/CMakeLists.txt @@ -107,6 +107,7 @@ add_subdirectory(msimtf) add_subdirectory(msisip) add_subdirectory(msisys.ocx) #add_subdirectory(msnet32) #to be deleted in trunk. +add_subdirectory(mspatcha) add_subdirectory(msports) add_subdirectory(msrle32) add_subdirectory(mssign32) diff --git a/reactos/dll/win32/mspatcha/CMakeLists.txt b/reactos/dll/win32/mspatcha/CMakeLists.txt new file mode 100644 index 00000000000..3b6c04055a9 --- /dev/null +++ b/reactos/dll/win32/mspatcha/CMakeLists.txt @@ -0,0 +1,16 @@ + +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) +add_definitions(-D__WINESRC__) + +spec2def(mspatcha.dll mspatcha.spec) + +list(APPEND SOURCE + mspatcha_main.c + ${CMAKE_CURRENT_BINARY_DIR}/mspatcha_stubs.c + ${CMAKE_CURRENT_BINARY_DIR}/mspatcha.def) + +add_library(mspatcha SHARED ${SOURCE} version.rc) +set_module_type(mspatcha win32dll) +target_link_libraries(mspatcha wine) +add_importlibs(mspatcha msvcrt kernel32 ntdll) +add_cd_file(TARGET mspatcha DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/mspatcha/mspatcha.spec b/reactos/dll/win32/mspatcha/mspatcha.spec new file mode 100644 index 00000000000..cc8ca94fbde --- /dev/null +++ b/reactos/dll/win32/mspatcha/mspatcha.spec @@ -0,0 +1,12 @@ +1 stdcall ApplyPatchToFileA(str str str long) +2 stub ApplyPatchToFileByHandles +3 stub ApplyPatchToFileByHandlesEx +4 stub ApplyPatchToFileExA +5 stub ApplyPatchToFileExW +6 stdcall ApplyPatchToFileW(wstr wstr wstr long) +7 stdcall GetFilePatchSignatureA(str long ptr long ptr long ptr long ptr) +8 stub GetFilePatchSignatureByHandle +9 stdcall GetFilePatchSignatureW(wstr long ptr long ptr long ptr long ptr) +10 stub TestApplyPatchToFileA +11 stub TestApplyPatchToFileByHandles +12 stub TestApplyPatchToFileW diff --git a/reactos/dll/win32/mspatcha/mspatcha_main.c b/reactos/dll/win32/mspatcha/mspatcha_main.c new file mode 100644 index 00000000000..4103eacf39b --- /dev/null +++ b/reactos/dll/win32/mspatcha/mspatcha_main.c @@ -0,0 +1,128 @@ +/* + * PatchAPI + * + * Copyright 2011 David Hedberg for CodeWeavers + * + * 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 + */ + +#include + +#include + +#include +#include +#include +#include + +#include + +WINE_DEFAULT_DEBUG_CHANNEL(mspatcha); + +/***************************************************** + * DllMain (MSPATCHA.@) + */ +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + + switch (fdwReason) + { + case DLL_WINE_PREATTACH: + return FALSE; /* prefer native version */ + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + break; + } + + return TRUE; +} + +static inline WCHAR *strdupAW( const char *src ) +{ + WCHAR *dst = NULL; + if (src) + { + int len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 ); + if ((dst = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len ); + } + return dst; +} + +/***************************************************** + * ApplyPatchToFileA (MSPATCHA.1) + */ +BOOL WINAPI ApplyPatchToFileA(LPCSTR patch_file, LPCSTR old_file, LPCSTR new_file, ULONG apply_flags) +{ + BOOL ret; + WCHAR *patch_fileW, *new_fileW, *old_fileW = NULL; + + if (!(patch_fileW = strdupAW( patch_file ))) return FALSE; + if (old_file && !(old_fileW = strdupAW( old_file ))) + { + HeapFree( GetProcessHeap(), 0, patch_fileW ); + return FALSE; + } + if (!(new_fileW = strdupAW( new_file ))) + { + HeapFree( GetProcessHeap(), 0, patch_fileW ); + HeapFree( GetProcessHeap(), 0, old_fileW ); + return FALSE; + } + ret = ApplyPatchToFileW( patch_fileW, old_fileW, new_fileW, apply_flags ); + HeapFree( GetProcessHeap(), 0, patch_fileW ); + HeapFree( GetProcessHeap(), 0, old_fileW ); + HeapFree( GetProcessHeap(), 0, new_fileW ); + return ret; +} + +/***************************************************** + * ApplyPatchToFileW (MSPATCHA.6) + */ +BOOL WINAPI ApplyPatchToFileW(LPCWSTR patch_file, LPCWSTR old_file, LPCWSTR new_file, ULONG apply_flags) +{ + FIXME("stub - %s, %s, %s, %08x\n", debugstr_w(patch_file), debugstr_w(old_file), + debugstr_w(new_file), apply_flags); + + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/***************************************************** + * GetFilePatchSignatureA (MSPATCHA.7) + */ +BOOL WINAPI GetFilePatchSignatureA(LPCSTR filename, ULONG flags, PVOID data, ULONG ignore_range_count, + PPATCH_IGNORE_RANGE ignore_range, ULONG retain_range_count, + PPATCH_RETAIN_RANGE retain_range, ULONG bufsize, LPSTR buffer) +{ + FIXME("stub - %s, %x, %p, %u, %p, %u, %p, %u, %p\n", debugstr_a(filename), flags, data, + ignore_range_count, ignore_range, retain_range_count, retain_range, bufsize, buffer); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/***************************************************** + * GetFilePatchSignatureW (MSPATCHA.9) + */ +BOOL WINAPI GetFilePatchSignatureW(LPCWSTR filename, ULONG flags, PVOID data, ULONG ignore_range_count, + PPATCH_IGNORE_RANGE ignore_range, ULONG retain_range_count, + PPATCH_RETAIN_RANGE retain_range, ULONG bufsize, LPWSTR buffer) +{ + FIXME("stub - %s, %x, %p, %u, %p, %u, %p, %u, %p\n", debugstr_w(filename), flags, data, + ignore_range_count, ignore_range, retain_range_count, retain_range, bufsize, buffer); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} diff --git a/reactos/dll/win32/mspatcha/version.rc b/reactos/dll/win32/mspatcha/version.rc new file mode 100644 index 00000000000..e2afe687505 --- /dev/null +++ b/reactos/dll/win32/mspatcha/version.rc @@ -0,0 +1,26 @@ +/* + * Copyright 2011 Hans Leidekker for CodeWeavers + * + * 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 + */ + +#define WINE_FILEDESCRIPTION_STR "Wine File Patch API" +#define WINE_FILENAME_STR "mspatcha.dll" +#define WINE_FILEVERSION 6,1,7600,16385 +#define WINE_FILEVERSION_STR "6.1.7600.16385" +#define WINE_PRODUCTVERSION 6,1,7600,16385 +#define WINE_PRODUCTVERSION_STR "6.1.7600.16385" + +#include "wine/wine_common_ver.rc" diff --git a/reactos/include/psdk/patchapi.h b/reactos/include/psdk/patchapi.h new file mode 100644 index 00000000000..9a62a0ff64e --- /dev/null +++ b/reactos/include/psdk/patchapi.h @@ -0,0 +1,52 @@ +/* + * Copyright 2011 Hans Leidekker for CodeWeavers + * + * 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 _PATCHAPI_H_ +#define _PATCHAPI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define APPLY_OPTION_FAIL_IF_EXACT 0x00000001 +#define APPLY_OPTION_FAIL_IF_CLOSE 0x00000002 +#define APPLY_OPTION_TEST_ONLY 0x00000004 +#define APPLY_OPTION_VALID_FLAGS 0x00000007 + +typedef struct _PATCH_IGNORE_RANGE +{ + ULONG OffsetInOldFile; + ULONG LengthInBytes; +} PATCH_IGNORE_RANGE, *PPATCH_IGNORE_RANGE; + +typedef struct _PATCH_RETAIN_RANGE +{ + ULONG OffsetInOldFile; + ULONG LengthInBytes; + ULONG OffsetInNewFile; +} PATCH_RETAIN_RANGE, *PPATCH_RETAIN_RANGE; + +BOOL WINAPI ApplyPatchToFileA(LPCSTR,LPCSTR,LPCSTR,ULONG); +BOOL WINAPI ApplyPatchToFileW(LPCWSTR,LPCWSTR,LPCWSTR,ULONG); +#define ApplyPatchToFile WINELIB_NAME_AW(ApplyPatchToFile) + +#ifdef __cplusplus +} +#endif + +#endif /* _PATCHAPI_H_ */ diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index f1455a03ef8..433950d9c24 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -126,6 +126,7 @@ reactos/dll/win32/msimtf # Synced to Wine-1.7.17 reactos/dll/win32/msisip # Synced to Wine-1.7.17 reactos/dll/win32/msisys.ocx # Synced to Wine-1.7.17 reactos/dll/win32/msnet32 # Synced to Wine-1.7.17 +reactos/dll/win32/mspatcha # Synced to Wine-1.7.27 reactos/dll/win32/msrle32 # Synced to Wine-1.7.17 reactos/dll/win32/mssign32 # Synced to Wine-1.7.17 reactos/dll/win32/mssip32 # Synced to Wine-1.7.17