Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56007
-- v2: msdelta: Add ApplyDelta stub. include: Add msdelta header file.
From: Vijay Kiran Kamuju infyquest@gmail.com
--- include/Makefile.in | 1 + include/msdelta.h | 169 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 include/msdelta.h
diff --git a/include/Makefile.in b/include/Makefile.in index d4a166e265c..b73543ab4ec 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -468,6 +468,7 @@ SOURCES = \ msdaguid.h \ msdasc.idl \ msdasql.h \ + msdelta.h \ mshtmcid.h \ mshtmdid.h \ mshtmhst.idl \ diff --git a/include/msdelta.h b/include/msdelta.h new file mode 100644 index 00000000000..d288f60e066 --- /dev/null +++ b/include/msdelta.h @@ -0,0 +1,169 @@ +/* + * Copyright 2024 Vijay Kiran Kamuju + * + * 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 _MSDELTA_H_ +#define _MSDELTA_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <windows.h> +#include <wincrypt.h> + +typedef __int64 DELTA_FILE_TYPE; +typedef __int64 DELTA_FLAG_TYPE; + +#define DELTA_FILE_SIZE_LIMIT 32*1024*1024 +#define DELTA_OPTIONS_SIZE_LIMIT 128*1024*1024 +#define DELTA_MAX_HASH_SIZE 32 + +#define DELTA_FILE_TYPE_RAW (DELTA_FILE_TYPE)0x00000001 +#define DELTA_FILE_TYPE_I386 (DELTA_FILE_TYPE)0x00000002 +#define DELTA_FILE_TYPE_IA64 (DELTA_FILE_TYPE)0x00000004 +#define DELTA_FILE_TYPE_AMD64 (DELTA_FILE_TYPE)0x00000008 +#define DELTA_FILE_TYPE_CLI_I386 (DELTA_FILE_TYPE)0x00000010 +#define DELTA_FILE_TYPE_CLI_AMD64 (DELTA_FILE_TYPE)0x00000020 +#define DELTA_FILE_TYPE_CLI_ARM (DELTA_FILE_TYPE)0x00000040 +#define DELTA_FILE_TYPE_CLI_ARM64 (DELTA_FILE_TYPE)0x00000080 + +#define DELTA_FILE_TYPE_SET_RAW_ONLY DELTA_FILE_TYPE_RAW +#define DELTA_FILE_TYPE_SET_EXECUTABLES_1 DELTA_FILE_TYPE_RAW|DELTA_FILE_TYPE_I386| \ + DELTA_FILE_TYPE_IA64|DELTA_FILE_TYPE_AMD64 +#define DELTA_FILE_TYPE_SET_EXECUTABLES DELTA_FILE_TYPE_SET_EXECUTABLES_1 +#define DELTA_FILE_TYPE_SET_EXECUTABLES_2 DELTA_FILE_TYPE_RAW|DELTA_FILE_TYPE_CLI_I386| \ + DELTA_FILE_TYPE_IA64|DELTA_FILE_TYPE_CLI_AMD64| \ + DELTA_FILE_TYPE_CLI_ARM +#define DELTA_FILE_TYPE_SET_EXECUTABLES_3 DELTA_FILE_TYPE_RAW|DELTA_FILE_TYPE_CLI_I386| \ + DELTA_FILE_TYPE_IA64|DELTA_FILE_TYPE_CLI_AMD64| \ + DELTA_FILE_TYPE_CLI_ARM|DELTA_FILE_TYPE_CLI_ARM64 +#define DELTA_FILE_TYPE_SET_EXECUTABLES_LATEST DELTA_FILE_TYPE_SET_EXECUTABLES_3 + +#define DELTA_FLAG_NONE (DELTA_FLAG_TYPE)0x00000000 +#define DELTA_APPLY_FLAG_ALLOW_PA19 (DELTA_FLAG_TYPE)0x00000001 +#define DELTA_FLAG_E8 (DELTA_FLAG_TYPE)0x00000001 +#define DELTA_FLAG_MARK (DELTA_FLAG_TYPE)0x00000002 +#define DELTA_FLAG_IMPORTS (DELTA_FLAG_TYPE)0x00000004 +#define DELTA_FLAG_EXPORTS (DELTA_FLAG_TYPE)0x00000008 +#define DELTA_FLAG_RESOURCES (DELTA_FLAG_TYPE)0x00000010 +#define DELTA_FLAG_RELOCS (DELTA_FLAG_TYPE)0x00000020 +#define DELTA_FLAG_I386_SMASHLOCK (DELTA_FLAG_TYPE)0x00000040 +#define DELTA_FLAG_I386_JMPS (DELTA_FLAG_TYPE)0x00000080 +#define DELTA_FLAG_I386_CALLS (DELTA_FLAG_TYPE)0x00000100 +#define DELTA_FLAG_AMD64_DISASM (DELTA_FLAG_TYPE)0x00000200 +#define DELTA_FLAG_AMD64_PDATA (DELTA_FLAG_TYPE)0x00000400 +#define DELTA_FLAG_IA64_DISASM (DELTA_FLAG_TYPE)0x00000800 +#define DELTA_FLAG_IA64_PDATA (DELTA_FLAG_TYPE)0x00001000 +#define DELTA_FLAG_UNBIND (DELTA_FLAG_TYPE)0x00002000 +#define DELTA_FLAG_CLI_DISASM (DELTA_FLAG_TYPE)0x00004000 +#define DELTA_FLAG_CLI_METADATA (DELTA_FLAG_TYPE)0x00008000 +#define DELTA_FLAG_CLI_HEADERS (DELTA_FLAG_TYPE)0x00010000 +#define DELTA_FLAG_IGNORE_FILE_SIZE_LIMIT (DELTA_FLAG_TYPE)0x00020000 +#define DELTA_FLAG_IGNORE_OPTIONS_SIZE_LIMIT (DELTA_FLAG_TYPE)0x00040000 +#define DELTA_FLAG_ARM_DISASM (DELTA_FLAG_TYPE)0x00080000 +#define DELTA_FLAG_ARM_PDATA (DELTA_FLAG_TYPE)0x00100000 +#define DELTA_FLAG_CLI4_METADATA (DELTA_FLAG_TYPE)0x00200000 +#define DELTA_FLAG_CLI4_DISASM (DELTA_FLAG_TYPE)0x00400000 +#define DELTA_FLAG_ARM64_DISASM (DELTA_FLAG_TYPE)0x00800000 +#define DELTA_FLAG_ARM64_PDATA (DELTA_FLAG_TYPE)0x01000000 + +#define DELTA_DEFAULT_FLAGS_RAW DELTA_FLAG_NONE +#define DELTA_DEFAULT_FLAGS_I386 DELTA_FLAG_MARK|DELTA_FLAG_IMPORTS| \ + DELTA_FLAG_EXPORTS|DELTA_FLAG_RESOURCES| \ + DELTA_FLAG_RELOCS|DELTA_FLAG_I386_SMASHLOCK| \ + DELTA_FLAG_I386_JMPS|DELTA_FLAG_I386_CALLS| \ + DELTA_FLAG_UNBIND|DELTA_FLAG_CLI_DISASM| \ + DELTA_FLAG_CLI_METADATA +#define DELTA_DEFAULT_FLAGS_IA64 DELTA_FLAG_MARK|DELTA_FLAG_IMPORTS| \ + DELTA_FLAG_EXPORTS|DELTA_FLAG_RESOURCES| \ + DELTA_FLAG_RELOCS|DELTA_FLAG_IA64_DISASM| \ + DELTA_FLAG_IA64_PDATA| DELTA_FLAG_UNBIND| \ + DELTA_FLAG_CLI_DISASM|DELTA_FLAG_CLI_METADATA +#define DELTA_DEFAULT_FLAGS_AMD64 DELTA_FLAG_MARK|DELTA_FLAG_IMPORTS| \ + DELTA_FLAG_EXPORTS|DELTA_FLAG_RESOURCES| \ + DELTA_FLAG_RELOCS|DELTA_FLAG_AMD64_DISASM| \ + DELTA_FLAG_AMD64_PDATA| DELTA_FLAG_UNBIND| \ + DELTA_FLAG_CLI_DISASM|DELTA_FLAG_CLI_METADATA +#define DELTA_CLI4_FLAGS_I386 i DELTA_FLAG_MARK|DELTA_FLAG_IMPORTS| \ + DELTA_FLAG_EXPORTS|DELTA_FLAG_RESOURCES| \ + DELTA_FLAG_RELOCS|DELTA_FLAG_I386_SMASHLOCK| \ + DELTA_FLAG_I386_JMPS|DELTA_FLAG_I386_CALLS| \ + DELTA_FLAG_UNBIND|DELTA_FLAG_CLI4_DISASM| \ + DELTA_FLAG_CLI4_METADATA +#define DELTA_CLI4_FLAGS_AMD64 DELTA_FLAG_MARK|DELTA_FLAG_IMPORTS| \ + DELTA_FLAG_EXPORTS|DELTA_FLAG_RESOURCES| \ + DELTA_FLAG_RELOCS|DELTA_FLAG_AMD64_DISASM| \ + DELTA_FLAG_AMD64_PDATA| DELTA_FLAG_UNBIND| \ + DELTA_FLAG_CLI4_DISASM|DELTA_FLAG_CLI4_METADATA +#define DELTA_CLI4_FLAGS_ARM DELTA_FLAG_MARK|DELTA_FLAG_IMPORTS| \ + DELTA_FLAG_EXPORTS|DELTA_FLAG_RESOURCES| \ + DELTA_FLAG_RELOCS|DELTA_FLAG_ARM_DISASM| \ + DELTA_FLAG_ARM_PDATA| DELTA_FLAG_UNBIND| \ + DELTA_FLAG_CLI4_DISASM|DELTA_FLAG_CLI4_METADATA +#define DELTA_CLI4_FLAGS_ARM64 DELTA_FLAG_MARK|DELTA_FLAG_IMPORTS| \ + DELTA_FLAG_EXPORTS|DELTA_FLAG_RESOURCES| \ + DELTA_FLAG_RELOCS|DELTA_FLAG_ARM64_DISASM| \ + DELTA_FLAG_ARM64_PDATA| DELTA_FLAG_UNBIND| \ + DELTA_FLAG_CLI4_DISASM|DELTA_FLAG_CLI4_METADATA + +typedef struct _DELTA_INPUT +{ + union { + LPCVOID lpcStart; + LPVOID lpStart; + }; + SIZE_T uSize; + BOOL Editable; +} DELTA_INPUT; +typedef DELTA_INPUT *LPDELTA_INPUT; +typedef const DELTA_INPUT *LPCDELTA_INPUT; + +typedef struct _DELTA_OUTPUT +{ + LPVOID lpStart; + SIZE_T uSize; +} DELTA_OUTPUT; +typedef DELTA_OUTPUT *LPDELTA_OUTPUT; +typedef const DELTA_OUTPUT *LPCDELTA_OUTPUT; + +typedef struct _DELTA_HASH +{ + DWORD HashSize; + UCHAR HashValue[DELTA_MAX_HASH_SIZE]; +} DELTA_HASH; +typedef DELTA_HASH *LPDELTA_HASH; +typedef const DELTA_HASH *LPCDELTA_HASH; + +typedef struct _DELTA_HEADER_INFO +{ + DELTA_FILE_TYPE FileTypeSet; + DELTA_FILE_TYPE FileType; + DELTA_FLAG_TYPE Flags; + SIZE_T TargetSize; + FILETIME TargetFileTime; + ALG_ID TargetHashAlgId; + DELTA_HASH TargetHash; +} DELTA_HEADER_INFO; +typedef DELTA_HEADER_INFO *LPDELTA_HEADER_INFO; +typedef const DELTA_HEADER_INFO *LPCDELTA_HEADER_INFO; + +#ifdef __cplusplus +} +#endif + +#endif /* _MSDELTA_H_ */
From: Vijay Kiran Kamuju infyquest@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56007 --- configure | 1 + configure.ac | 1 + dlls/msdelta/Makefile.in | 4 ++ dlls/msdelta/msdelta.spec | 4 +- dlls/msdelta/msdelta_main.c | 80 ++++++++++++++++++++++++++++++ dlls/msdelta/tests/Makefile.in | 5 ++ dlls/msdelta/tests/apply_delta.c | 85 ++++++++++++++++++++++++++++++++ include/msdelta.h | 4 ++ 8 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 dlls/msdelta/msdelta_main.c create mode 100644 dlls/msdelta/tests/Makefile.in create mode 100644 dlls/msdelta/tests/apply_delta.c
diff --git a/configure b/configure index c4c79ae8493..207788eb982 100755 --- a/configure +++ b/configure @@ -22009,6 +22009,7 @@ wine_fn_config_makefile dlls/msdaps enable_msdaps wine_fn_config_makefile dlls/msdasql enable_msdasql wine_fn_config_makefile dlls/msdasql/tests enable_tests wine_fn_config_makefile dlls/msdelta enable_msdelta +wine_fn_config_makefile dlls/msdelta/tests enable_tests wine_fn_config_makefile dlls/msdmo enable_msdmo wine_fn_config_makefile dlls/msdmo/tests enable_tests wine_fn_config_makefile dlls/msdrm enable_msdrm diff --git a/configure.ac b/configure.ac index cba55126869..6b67e576d86 100644 --- a/configure.ac +++ b/configure.ac @@ -2826,6 +2826,7 @@ WINE_CONFIG_MAKEFILE(dlls/msdaps) WINE_CONFIG_MAKEFILE(dlls/msdasql) WINE_CONFIG_MAKEFILE(dlls/msdasql/tests) WINE_CONFIG_MAKEFILE(dlls/msdelta) +WINE_CONFIG_MAKEFILE(dlls/msdelta/tests) WINE_CONFIG_MAKEFILE(dlls/msdmo) WINE_CONFIG_MAKEFILE(dlls/msdmo/tests) WINE_CONFIG_MAKEFILE(dlls/msdrm) diff --git a/dlls/msdelta/Makefile.in b/dlls/msdelta/Makefile.in index 5f26bb04dde..5b77ae263cd 100644 --- a/dlls/msdelta/Makefile.in +++ b/dlls/msdelta/Makefile.in @@ -1,3 +1,7 @@ MODULE = msdelta.dll +IMPORTLIB = msdelta
EXTRADLLFLAGS = -Wb,--prefer-native + +SOURCES = \ + msdelta_main.c diff --git a/dlls/msdelta/msdelta.spec b/dlls/msdelta/msdelta.spec index ce2b5edf472..0666b258994 100644 --- a/dlls/msdelta/msdelta.spec +++ b/dlls/msdelta/msdelta.spec @@ -1,7 +1,7 @@ -@ stub ApplyDeltaA +@ stdcall ApplyDeltaA(long ptr ptr ptr) @ stub ApplyDeltaB @ stub ApplyDeltaProvidedB -@ stub ApplyDeltaW +@ stdcall ApplyDeltaW(long ptr ptr ptr) @ stub CreateDeltaA @ stub CreateDeltaB @ stub CreateDeltaW diff --git a/dlls/msdelta/msdelta_main.c b/dlls/msdelta/msdelta_main.c new file mode 100644 index 00000000000..1a05575e2ba --- /dev/null +++ b/dlls/msdelta/msdelta_main.c @@ -0,0 +1,80 @@ +/* + * MSDelta + * + * Copyright 2024 Vijay Kiran Kamuju + * + * 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 <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "msdelta.h" +#include "wine/debug.h" + + +WINE_DEFAULT_DEBUG_CHANNEL(msdelta); + + +static WCHAR *strdupAW(const char *src) +{ + WCHAR *dst = NULL; + if (src) + { + int len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0); + if ((dst = malloc(len * sizeof(WCHAR)))) + MultiByteToWideChar(CP_ACP, 0, src, -1, dst, len); + } + return dst; +} + +/***************************************************** + * ApplyDeltaA (MSDELTA.@) + */ +BOOL WINAPI ApplyDeltaA(DELTA_FLAG_TYPE flags, LPCSTR source_file, + LPCSTR delta_file, LPCSTR target_file) +{ + BOOL ret; + WCHAR *source_fileW, *delta_fileW = NULL, *target_fileW = NULL; + + source_fileW = strdupAW(source_file); + delta_fileW = strdupAW(delta_file); + target_fileW = strdupAW(target_file); + + ret = ApplyDeltaW(flags, source_fileW, delta_fileW, target_fileW); + + free(source_fileW); + free(delta_fileW); + free(target_fileW); + + return ret; +} + +BOOL WINAPI ApplyDeltaW(DELTA_FLAG_TYPE flags, LPCWSTR source_file, + LPCWSTR delta_file, LPCWSTR target_file) +{ + BOOL ret = FALSE; + FIXME("(%llx,%s,%s,%s): stub!\n", flags, debugstr_w(source_file), debugstr_w(delta_file), debugstr_w(target_file)); + + if (!source_file) + { + SetLastError(ERROR_INVALID_DATA); + return ret; + } + SetLastError(ERROR_FILE_NOT_FOUND); + + return ret; +} diff --git a/dlls/msdelta/tests/Makefile.in b/dlls/msdelta/tests/Makefile.in new file mode 100644 index 00000000000..5b212084b81 --- /dev/null +++ b/dlls/msdelta/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = msdelta.dll +IMPORTS = msdelta + +SOURCES = \ + apply_delta.c diff --git a/dlls/msdelta/tests/apply_delta.c b/dlls/msdelta/tests/apply_delta.c new file mode 100644 index 00000000000..ce591fdac88 --- /dev/null +++ b/dlls/msdelta/tests/apply_delta.c @@ -0,0 +1,85 @@ +/* + * Unit tests for MSDelta API functions + * + * Copyright (c) 2024 Vijay Kiran Kamuju + * + * 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 + * + * NOTES + * + * Without mspatchc.dll, the inability to create test patch files under Wine + * limits testing to the supplied small files. + */ + +#include "wine/test.h" +#include "windef.h" +#include "winerror.h" + +#include "msdelta.h" + +static BOOL (WINAPI *pApplyDeltaA)(DELTA_FLAG_TYPE, LPCSTR, LPCSTR, LPCSTR); + +static BOOL init_function_pointers(void) +{ + HMODULE msdelta = LoadLibraryA("msdelta.dll"); + if (!msdelta) + { + win_skip("msdelta.dll not found\n"); + return FALSE; + } + pApplyDeltaA = (void *)GetProcAddress(msdelta, "ApplyDeltaA"); + + return TRUE; +} + +static void test_ApplyDelta(void) +{ + DWORD err; + + if (!pApplyDeltaA) + return; + + SetLastError(0xdeadbeef); + ok(!pApplyDeltaA(0, NULL, NULL, NULL), + "ApplyDeltaA: expected FALSE\n"); + err = GetLastError(); + ok(err == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got 0x%08lx\n", err); + + SetLastError(0xdeadbeef); + ok(!pApplyDeltaA(0, "src.tmp", NULL, NULL), + "ApplyDeltaA: expected FALSE\n"); + err = GetLastError(); + ok(err == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got 0x%08lx\n", err); + + SetLastError(0xdeadbeef); + ok(!pApplyDeltaA(0, "src.tmp", "delta.tmp", NULL), + "ApplyDeltaA: expected FALSE\n"); + err = GetLastError(); + ok(err == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got 0x%08lx\n", err); + + SetLastError(0xdeadbeef); + ok(!pApplyDeltaA(0, "src.tmp", "delta.tmp", "tgt.tmp"), + "ApplyDeltaA: expected FALSE\n"); + err = GetLastError(); + ok(err == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got 0x%08lx\n", err); +} + +START_TEST(apply_delta) +{ + if (!init_function_pointers()) + return; + + test_ApplyDelta(); +} diff --git a/include/msdelta.h b/include/msdelta.h index d288f60e066..3fb87ae1587 100644 --- a/include/msdelta.h +++ b/include/msdelta.h @@ -162,6 +162,10 @@ typedef struct _DELTA_HEADER_INFO typedef DELTA_HEADER_INFO *LPDELTA_HEADER_INFO; typedef const DELTA_HEADER_INFO *LPCDELTA_HEADER_INFO;
+BOOL WINAPI ApplyDeltaA(DELTA_FLAG_TYPE, LPCSTR, LPCSTR, LPCSTR); +BOOL WINAPI ApplyDeltaW(DELTA_FLAG_TYPE, LPCWSTR, LPCWSTR, LPCWSTR); +#define ApplyDelta WINELIB_NAME_AW(ApplyDelta) + #ifdef __cplusplus } #endif
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=141126
Your paranoid android.
=== debian11 (build log) ===
/usr/bin/i686-w64-mingw32-ld: tmp657a3984/msdelta-00000000.spec.o:fake:(.edata+0x28): undefined reference to `ApplyDeltaA@16' /usr/bin/i686-w64-mingw32-ld: tmp657a3984/msdelta-00000000.spec.o:fake:(.edata+0x34): undefined reference to `ApplyDeltaW@16' collect2: error: ld returned 1 exit status Task: The win32 Wine build failed
=== debian11b (build log) ===
/usr/bin/i686-w64-mingw32-ld: tmp65881f0e/msdelta-00000000.spec.o:fake:(.edata+0x28): undefined reference to `ApplyDeltaA@16' /usr/bin/i686-w64-mingw32-ld: tmp65881f0e/msdelta-00000000.spec.o:fake:(.edata+0x34): undefined reference to `ApplyDeltaW@16' collect2: error: ld returned 1 exit status Task: The wow32 Wine build failed