Alexandre Julliard : loader: Hide the preloader from the ps output.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 31 13:05:21 CST 2006


Module: wine
Branch: refs/heads/master
Commit: c20d6c409569a916231d14acd8a5a104cfedf74b
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=c20d6c409569a916231d14acd8a5a104cfedf74b

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Mar 31 19:16:22 2006 +0200

loader: Hide the preloader from the ps output.

---

 loader/preloader.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/loader/preloader.c b/loader/preloader.c
index 1ca6d83..9480ca9 100644
--- a/loader/preloader.c
+++ b/loader/preloader.c
@@ -287,6 +287,14 @@ static inline gid_t wld_getegid(void)
     return ret;
 }
 
+static inline int wld_prctl( int code, int arg )
+{
+    int ret;
+    __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
+                          : "=a" (ret) : "0" (SYS_prctl), "r" (code), "c" (arg) );
+    return SYSCALL_RET(ret);
+}
+
 
 /* replacement for libc functions */
 
@@ -871,6 +879,26 @@ static int is_in_preload_range( const El
     return 0;
 }
 
+/* set the process name if supported */
+static void set_process_name( int argc, char *argv[] )
+{
+    unsigned int i, off;
+    char *p, *name, *end;
+
+    /* set the process short name */
+    for (p = name = argv[1]; *p; p++) if (p[0] == '/' && p[1]) name = p + 1;
+    if (wld_prctl( 15 /* PR_SET_NAME */, (int)name ) == -1) return;
+
+    /* find the end of the argv array and move everything down */
+    end = argv[argc - 1];
+    while (*end) end++;
+    off = argv[1] - argv[0];
+    for (p = argv[1]; p <= end; p++) *(p - off) = *p;
+    wld_memset( end - off, 0, off );
+    for (i = 1; i < argc; i++) argv[i] -= off;
+}
+
+
 /*
  *  wld_start
  *
@@ -956,6 +984,7 @@ void* wld_start( void **stack )
     delete_av[i].a_type = AT_NULL;
 
     /* get rid of first argument */
+    set_process_name( *pargc, argv );
     pargc[1] = pargc[0] - 1;
     *stack = pargc + 1;
 




More information about the wine-cvs mailing list