Windows version crashes, whenever an elevated window is open

Create issue
Issue #26 resolved
Former user created an issue

I am running the last version for windows, which is 0.6.1 (from http://www.joachim-breitner.de/archive/arbtt/ ).

When a window with elevated rights is open on the desktop, arbtt-capture will crash. It does so with this message:

arbtt-capture.exe
OpenProcess: permission denied (Zugriff verweigert).

This can easily be reproduced like this:

Open services.msc (the windows tool that lets you view, start and stop your services). Opening it will prompt you to give it Administrator privileges. You will do so.

Start arbtt-capture.exe (or if it is running, wait for ~1 minute until it tries to capture another sample).

It will fail with the mentioned message 100% of the time.

Comments (15)

  1. nomeata repo owner

    Dear Anonymous. Thanks for your report. Unfortunately, I don’t use windows myself, and I am not sure if anyone else uses it on Windows these days. So I’m not sure how viable it is to support the windows version.

    I can probably try to make arbtt-capture ignore a window where OpenProcess fails... if you are really interested in running arbtt, and willing to test prereleases, I can try to implement that.

  2. amenthes

    I am very willing to test prerelease software. I am also fluent in many programming languages (though, sadly, not Haskell), but I believe i would be able to compile it myself.

    Also, I'm currently working on a tool that incorporates timeline data from various sources. It's far from done, but I will make this open source of course. Here's a tiny glimpse of what I'm working on: https://twitter.com/amenthes_de/status/637369943223308289

    It is inspired by ManicTime, which I use on windows and dearly miss on Linux (which is how I found out about arbtt in the first place).

  3. nomeata repo owner

    ok, let me know if you managed to compile it yourself, and then I'll give you patches to test. I might have higher reaction times this week, though, due to attending ICFP2015.

  4. amenthes

    I can't build on windows right now, there's something depending on the unix package and it's not working on windows.

    So a cabal install arbtt fails with

    Resolving dependencies...
    Configuring unix-2.7.1.0...
    Building unix-2.7.1.0...
    Failed to install unix-2.7.1.0
    Build log ( C:\Users\user\AppData\Roaming\cabal\logs\unix-2.7.1.0.log ):
    setup-Configure-Cabal-1.22.4.0-i386-windows-ghc-7.10.2.exe: Package
    unix-2.7.1.0 can't be built on this system.
    cc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.exe
    checking for suffix of executables... .exe
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking dlfcn.h usability... no
    checking dlfcn.h presence... no
    checking for dlfcn.h... no
    checking for an ANSI C-conforming const... yes
    checking for special C compiler options needed for large files... no
    checking for _FILE_OFFSET_BITS value needed for large files... unknown
    checking for _LARGE_FILES value needed for large files... unknown
    checking dirent.h usability... yes
    checking dirent.h presence... yes
    checking for dirent.h... yes
    checking fcntl.h usability... yes
    checking fcntl.h presence... yes
    checking for fcntl.h... yes
    checking grp.h usability... no
    checking grp.h presence... no
    checking for grp.h... no
    checking limits.h usability... yes
    checking limits.h presence... yes
    checking for limits.h... yes
    checking pwd.h usability... no
    checking pwd.h presence... no
    checking for pwd.h... no
    checking signal.h usability... yes
    checking signal.h presence... yes
    checking for signal.h... yes
    checking for string.h... (cached) yes
    checking sys/resource.h usability... no
    checking sys/resource.h presence... no
    checking for sys/resource.h... no
    checking for sys/stat.h... (cached) yes
    checking sys/times.h usability... no
    checking sys/times.h presence... no
    checking for sys/times.h... no
    checking sys/time.h usability... yes
    checking sys/time.h presence... yes
    checking for sys/time.h... yes
    checking sys/utsname.h usability... no
    checking sys/utsname.h presence... no
    checking for sys/utsname.h... no
    checking sys/wait.h usability... no
    checking sys/wait.h presence... no
    checking for sys/wait.h... no
    checking bsd/libutil.h usability... no
    checking bsd/libutil.h presence... no
    checking for bsd/libutil.h... no
    checking libutil.h usability... no
    checking libutil.h presence... no
    checking for libutil.h... no
    checking pty.h usability... no
    checking pty.h presence... no
    checking for pty.h... no
    checking utmp.h usability... no
    checking utmp.h presence... no
    checking for utmp.h... no
    checking termios.h usability... no
    checking termios.h presence... no
    checking for termios.h... no
    checking time.h usability... yes
    checking time.h presence... yes
    checking for time.h... yes
    checking for unistd.h... (cached) yes
    checking utime.h usability... yes
    checking utime.h presence... yes
    checking for utime.h... yes
    checking for getgrgid_r... no
    checking for getgrnam_r... no
    checking for getpwnam_r... no
    checking for getpwuid_r... no
    checking for getpwnam... no
    checking for getpwuid... no
    checking for getpwent... no
    checking for getgrent... no
    checking for lchown... no
    checking for setenv... no
    checking for sysconf... no
    checking for unsetenv... no
    checking for clearenv... no
    checking for nanosleep... no
    checking for ptsname... no
    checking for setitimer... no
    checking for readdir_r... no
    checking for telldir... yes
    checking for seekdir... yes
    checking for execvpe... yes
    checking for struct stat.st_atim... no
    checking for struct stat.st_mtim... no
    checking for struct stat.st_ctim... no
    checking for struct stat.st_atimespec... no
    checking for struct stat.st_mtimespec... no
    checking for struct stat.st_ctimespec... no
    checking for struct stat.st_atimensec... no
    checking for struct stat.st_mtimensec... no
    checking for struct stat.st_ctimensec... no
    checking for struct stat.st_atime_n... no
    checking for struct stat.st_mtime_n... no
    checking for struct stat.st_ctime_n... no
    checking for struct stat.st_uatime... no
    checking for struct stat.st_umtime... no
    checking for struct stat.st_uctime... no
    checking for struct passwd.pw_gecos... no
    checking for utimensat... no
    checking for futimens... no
    checking for lutimes... no
    checking for futimes... no
    checking for mkstemps... no
    checking for mkdtemp... no
    checking for fsync... no
    checking for fdatasync... no
    checking for posix_fadvise... no
    checking for posix_fallocate... no
    checking for library containing shm_open... no
    checking value of SIGABRT... 22
    checking value of SIGALRM... -1
    checking value of SIGBUS... -1
    checking value of SIGCHLD... -1
    checking value of SIGCONT... -1
    checking value of SIGFPE... 8
    checking value of SIGHUP... -1
    checking value of SIGILL... 4
    checking value of SIGINT... 2
    checking value of SIGKILL... -1
    checking value of SIGPIPE... -1
    checking value of SIGQUIT... -1
    checking value of SIGSEGV... 11
    checking value of SIGSTOP... -1
    checking value of SIGTERM... 15
    checking value of SIGTSTP... -1
    checking value of SIGTTIN... -1
    checking value of SIGTTOU... -1
    checking value of SIGUSR1... -1
    checking value of SIGUSR2... -1
    checking value of SIGPOLL... -1
    checking value of SIGPROF... -1
    checking value of SIGSYS... -1
    checking value of SIGTRAP... -1
    checking value of SIGURG... -1
    checking value of SIGVTALRM... -1
    checking value of SIGXCPU... -1
    checking value of SIGXFSZ... -1
    checking value of SIG_BLOCK... -1
    checking value of SIG_SETMASK... -1
    checking value of SIG_UNBLOCK... -1
    checking value of SIGINFO... -1
    checking value of SIGWINCH... -1
    checking for _SC_GETGR_R_SIZE_MAX... no
    checking for _SC_GETPW_R_SIZE_MAX... no
    checking return type of usleep... int
    checking return type of unsetenv... int
    checking for RTLD_NEXT from dlfcn.h... no
    checking for RTLD_DEFAULT from dlfcn.h... no
    checking for openpty... no
    checking for openpty in -lutil... no
    checking for openpty in -lbsd... no
    checking for /dev/ptmx... yes
    checking for /dev/ptc... no
    checking for library containing dlopen... no
    checking build system type... i686-pc-mingw32
    checking host system type... i686-pc-mingw32
    checking target system type... i686-pc-mingw32
    checking for library containing sem_close... no
    configure: Not found
    configure: creating ./config.status
    config.status: creating unix.buildinfo
    config.status: creating include/HsUnixConfig.h
    configure: WARNING: unrecognized options: --with-compiler, --with-gcc
    cabal: Error: some packages failed to install:
    arbtt-0.9.0.7 depends on unix-2.7.1.0 which failed to install.
    unix-2.7.1.0 failed during the building phase. The exception was:
    ExitFailure 1
    

    I did get pcre-light on windows with this solution.

  5. amenthes

    I'm now able to compile myself, and the issue is still present with 0.9. If you get around to it i'd happily test a patch. This is not high priority, please don't feel rushed!

  6. amenthes

    interestingly, some of my build are far larger than the 0.6 binaries.

    arbtt-capture: 2.9M -> 12.3M
    arbtt-dump:    2.8M -> 12.1M
    arbtt-import   d.n.e -> 3.7M
    arbtt-recover   2.8M -> 3.6M
    arbtt-stats    3.8M -> 13.6M
    

    Am i doing something wrong?

  7. amenthes

    The patch applies correctly, but cabal build fails:

    srcGraphicsWin32WindowExtra.hsc:103:17:
        Couldn't match type `()' with `Bool'
        Expected type: IO Bool
          Actual type: IO ()
        In a stmt of a 'do' block:
          unless (str `elem` ["", "Default IME"])
          $ do { modifyIORef resultRef ((winh, str, proc) :) }
        In the expression:
          do { proc <- alloca $ \ pid_p -> do { ... };
               len <- c_GetWindowTextLength winh;
               str <- allocaArray0 len $ \ c_test -> do { ... };
               unless (str `elem` ["", "Default IME"])
               $ do { modifyIORef resultRef ((winh, str, proc) :) } }
        In a stmt of a 'do' block:
          if not v then
              return True
          else
              do { proc <- alloca $ \ pid_p -> ...;
                   len <- c_GetWindowTextLength winh;
                   str <- allocaArray0 len $ \ c_test -> ...;
                   .... }
    

    This appears to be related to the third hunk in the patch, where the return True is pulled to the left. When i move it back (or if i remove the third hunk from the patch file), i get this error instead:

    [10 of 13] Compiling Graphics.Win32.Window.Extra ( dist\build\arbtt-capture\arbtt-capture-tmp\Graphics\Win32\Window\Extra.hs, dist\build\arbtt-capture\arbtt-capture-tmp\Graphics\Win32\Window\Extra.o )
    
    srcGraphicsWin32WindowExtra.hsc:78:13:
        Couldn't match type `Either () Bool' with `Bool'
        Expected type: IO Bool
          Actual type: IO (Either () Bool)
        In a stmt of a 'do' block:
          ignoreEPerm
          $ do { v <- c_IsWindowVisible winh;
                 if not v then
                     return True
                 else
                     do { proc <- alloca $ ...;
                          .... } }
        In the expression:
          do { ignoreEPerm
               $ do { v <- c_IsWindowVisible winh;
                      if not v then return True else ... } }
        In the second argument of `($)', namely
          `\ winh _ -> do { ignoreEPerm $ do { ... } }'
    
  8. amenthes

    Looks good! The capture is no longer crashing. Instead it collects data of all windows it can acces. So most of the data is available, just the elevated window(s) is/are missing. Which is fine.

  9. Log in to comment