Alexandre Julliard : msv1_0: Implement Wow64 entry points in the Unix library.

Alexandre Julliard julliard at winehq.org
Tue Nov 9 15:55:06 CST 2021


Module: wine
Branch: master
Commit: 78cdb254dd311291ab3f02f8bc10d4d0b510b338
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=78cdb254dd311291ab3f02f8bc10d4d0b510b338

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Nov  9 11:41:29 2021 +0100

msv1_0: Implement Wow64 entry points in the Unix library.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msv1_0/main.c    |  4 +--
 dlls/msv1_0/unixlib.c | 78 ++++++++++++++++++++++++++++++++++++++++++++-------
 dlls/msv1_0/unixlib.h |  9 ++----
 3 files changed, 71 insertions(+), 20 deletions(-)

diff --git a/dlls/msv1_0/main.c b/dlls/msv1_0/main.c
index 73d7faef456..32783f2f6cf 100644
--- a/dlls/msv1_0/main.c
+++ b/dlls/msv1_0/main.c
@@ -51,9 +51,7 @@ static NTSTATUS ntlm_check_version(void)
 
 static void ntlm_cleanup( struct ntlm_ctx *ctx )
 {
-    struct cleanup_params params = { ctx };
-
-    __wine_unix_call( ntlm_handle, unix_cleanup, &params );
+    __wine_unix_call( ntlm_handle, unix_cleanup, ctx );
 }
 
 static NTSTATUS ntlm_chat( struct ntlm_ctx *ctx, char *buf, unsigned int buflen, unsigned int *retlen )
diff --git a/dlls/msv1_0/unixlib.c b/dlls/msv1_0/unixlib.c
index 674b61c1f7b..799577fd4a5 100644
--- a/dlls/msv1_0/unixlib.c
+++ b/dlls/msv1_0/unixlib.c
@@ -54,7 +54,7 @@ struct com_buf
 static SECURITY_STATUS read_line( struct ntlm_ctx *ctx, unsigned int *offset )
 {
     char *newline;
-    struct com_buf *com_buf = ctx->com_buf;
+    struct com_buf *com_buf = (struct com_buf *)(ULONG_PTR)ctx->com_buf;
 
     if (!com_buf)
     {
@@ -66,7 +66,7 @@ static SECURITY_STATUS read_line( struct ntlm_ctx *ctx, unsigned int *offset )
         }
         com_buf->size = INITIAL_BUFFER_SIZE;
         com_buf->offset = 0;
-        ctx->com_buf = com_buf;
+        ctx->com_buf = (ULONG_PTR)com_buf;
     }
 
     do
@@ -97,7 +97,7 @@ static SECURITY_STATUS read_line( struct ntlm_ctx *ctx, unsigned int *offset )
 
 static NTSTATUS ntlm_chat( void *args )
 {
-    struct chat_params *params = args;
+    const struct chat_params *params = args;
     struct ntlm_ctx *ctx = params->ctx;
     struct com_buf *com_buf;
     SECURITY_STATUS status = SEC_E_OK;
@@ -107,7 +107,7 @@ static NTSTATUS ntlm_chat( void *args )
     write( ctx->pipe_out, "\n", 1 );
 
     if ((status = read_line( ctx, &offset )) != SEC_E_OK) return status;
-    com_buf = ctx->com_buf;
+    com_buf = (struct com_buf *)(ULONG_PTR)ctx->com_buf;
     *params->retlen = strlen( com_buf->buffer );
 
     if (*params->retlen > params->buflen) return SEC_E_BUFFER_TOO_SMALL;
@@ -128,9 +128,8 @@ static NTSTATUS ntlm_chat( void *args )
 
 static NTSTATUS ntlm_cleanup( void *args )
 {
-    struct cleanup_params *params = args;
-    struct ntlm_ctx *ctx = params->ctx;
-    struct com_buf *com_buf = ctx->com_buf;
+    struct ntlm_ctx *ctx = args;
+    struct com_buf *com_buf = (struct com_buf *)(ULONG_PTR)ctx->com_buf;
 
     if (!ctx || (ctx->mode != MODE_CLIENT && ctx->mode != MODE_SERVER)) return STATUS_INVALID_HANDLE;
     ctx->mode = MODE_INVALID;
@@ -154,7 +153,7 @@ static NTSTATUS ntlm_cleanup( void *args )
 
 static NTSTATUS ntlm_fork( void *args )
 {
-    struct fork_params *params = args;
+    const struct fork_params *params = args;
     struct ntlm_ctx *ctx = params->ctx;
     int pipe_in[2], pipe_out[2];
 
@@ -216,7 +215,6 @@ static NTSTATUS ntlm_check_version( void *args )
     char *argv[3], buf[80];
     NTSTATUS status = STATUS_DLL_NOT_FOUND;
     struct fork_params params = { &ctx, argv };
-    struct cleanup_params cleanup_params = { &ctx };
     int len;
 
     argv[0] = (char *)"ntlm_auth";
@@ -249,7 +247,7 @@ static NTSTATUS ntlm_check_version( void *args )
                               "Make sure that ntlm_auth >= %d.%d.%d is in your path. "
                               "Usually, you can find it in the winbind package of your distribution.\n",
                               NTLM_AUTH_MAJOR_VERSION, NTLM_AUTH_MINOR_VERSION, NTLM_AUTH_MICRO_VERSION );
-    ntlm_cleanup( &cleanup_params );
+    ntlm_cleanup( &ctx );
     return status;
 }
 
@@ -260,3 +258,63 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
     ntlm_fork,
     ntlm_check_version,
 };
+
+#ifdef _WIN64
+
+typedef ULONG PTR32;
+
+static NTSTATUS wow64_ntlm_chat( void *args )
+{
+    struct
+    {
+        PTR32 ctx;
+        PTR32 buf;
+        UINT  buflen;
+        PTR32 retlen;
+    } const *params32 = args;
+
+    struct chat_params params =
+    {
+        ULongToPtr(params32->ctx),
+        ULongToPtr(params32->buf),
+        params32->buflen,
+        ULongToPtr(params32->retlen)
+    };
+
+    return ntlm_chat( &params );
+}
+
+static NTSTATUS wow64_ntlm_fork( void *args )
+{
+    struct
+    {
+        PTR32 ctx;
+        PTR32 argv;
+    } const *params32 = args;
+
+    struct fork_params params;
+    PTR32 *argv32 = ULongToPtr(params32->argv);
+    char **argv;
+    NTSTATUS ret;
+    int i, argc = 0;
+
+    while (argv32[argc]) argc++;
+    argv = malloc( (argc + 1) * sizeof(*argv) );
+    for (i = 0; i <= argc; i++) argv[i] = ULongToPtr( argv32[i] );
+
+    params.ctx = ULongToPtr(params32->ctx);
+    params.argv = argv;
+    ret = ntlm_fork( &params );
+    free( argv );
+    return ret;
+}
+
+const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
+{
+    wow64_ntlm_chat,
+    ntlm_cleanup,
+    wow64_ntlm_fork,
+    ntlm_check_version,
+};
+
+#endif  /* _WIN64 */
diff --git a/dlls/msv1_0/unixlib.h b/dlls/msv1_0/unixlib.h
index efd640aaa4a..7aee646ed50 100644
--- a/dlls/msv1_0/unixlib.h
+++ b/dlls/msv1_0/unixlib.h
@@ -57,7 +57,7 @@ struct arc4_info
 #define FLAG_NEGOTIATE_NTLM2        0x00080000
 #define FLAG_NEGOTIATE_KEY_EXCHANGE 0x40000000
 
-struct com_buf;
+typedef UINT64 com_buf_ptr;
 
 struct ntlm_ctx
 {
@@ -68,7 +68,7 @@ struct ntlm_ctx
     int          pipe_out;
     char         session_key[16];
     unsigned int flags;
-    struct com_buf *com_buf;
+    com_buf_ptr  com_buf;
     struct
     {
         struct
@@ -99,11 +99,6 @@ struct chat_params
     unsigned int *retlen;
 };
 
-struct cleanup_params
-{
-    struct ntlm_ctx *ctx;
-};
-
 struct fork_params
 {
     struct ntlm_ctx *ctx;




More information about the wine-cvs mailing list