Commit Graph
88 Commits
Author SHA1 Message Date
baldurk 047bff7261 Add an new android hooking method using JDWP to inject & PLT hooks
* This is based on the GAPID method of injection, using the same steps
  to connect with JDWP and debug the application, breakpointing on key
  init-time steps to patch vulkan layer search paths and load libraries
  from our installed apk.
* We diverge by then using PLT hooks instead of trampolines to hook the
  EGL/GL calls - and so we also hook dlopen.
* This should work on any debuggable application - not currently checked
  but does not replace/break any of the previous injection, which can
  still work.
2018-01-26 21:19:13 +00:00
baldurk e305029ddd Update copyright years to 2018 2018-01-01 17:55:29 +00:00
baldurk 82a0e055ba Change how replay programs are identified, from filename to sym export
* Instead of checking on the filename, we look for a specially named
  exported symbol somewhere in a module that's already loaded.
* This allows us to mark the python module as a replay program, so if
  it's loaded into the python interpreter it will be able to use the
  replay API.
2017-08-31 18:34:19 +01:00
baldurk 030cbfde9a Batch update copyright years everywhere 2017-01-06 12:13:31 +00:00
baldurk 8d0915401f Unify feature macro handling 2016-11-07 18:14:49 +01:00
baldurk 8f4a55a3b5 Set all processes under a given UI instance to log to the same file.
* Using OS-specific append writing functions instead of simple fopen/
  fwrite/fclose we can guarantee that multiple processes writing to the
  same log file won't trash or interleave their log output.
* To make the logs readable the PID is now included along with the
  project/timestamp.
* After that, we make sure that when we launch a program we set the
  output log to the same file as the parent UI. This keeps all the logs
  together and removes user confusion over which logfile is needed.
* We also move all of RenderDoc's temporary files under a RenderDoc
  folder in the temp folder, instead of scattering the files in the root
2016-11-02 23:37:38 +01:00
baldurk aeb0f3a005 For libraries opened with RTLD_DEEPBIND, use plthook to hook dlopen
* Split out the hook functions into linux and apple/android (which are
  currently unimplemented).
2016-09-26 17:33:51 +02:00
baldurk 5f28b745a2 Format code according to newly added clang-format
_  /)
                 mo / )
                 |/)\)
                  /\_
                  \__|=
                 (    )
                 __)(__
           _____/      \\_____
          |  _     ___   _   ||
          | | \     |   | \  ||
          | |  |    |   |  | ||
          | |_/     |   |_/  ||
          | | \     |   |    ||
          | |  \    |   |    ||
          | |   \. _|_. | .  ||
          |                  ||
          |repository history||
          |                  ||
  *       | *   **    * **   |**      **
   \))ejm97/.,(//,,..,,\||(,,.,\\,.((//
2016-05-22 19:41:53 +02:00
baldurk 863dc1d259 Split 'linux' os-specific code into 'posix' and then 'linux'/'android'
* And eventually probably 'apple' as well.
2016-05-14 01:53:51 +02:00
baldurk 20625eeeba Add a LibraryHooks callback when capture options are changed 2016-04-30 17:18:45 +02:00
Michael Vance 8b1794456d Switch RENDERDOC_PLATFORM to RENDERDOC_PLATFORM_<PLAT>.
Notes
======
- With no clean way to do string comparisons in the C preprocessor, have a define per-platform. This avoids the clever string concatenation for determining the OS-specic bits, and allows SN-DBS to distribute builds without custom rewrite rules.
- Fix up instances of WIN32, etc., in non-3rdparty sources to refer to this.
- Move the per-platform specific bits into their own subdirs.
2016-04-15 13:59:59 -04:00
baldurk 2e0ffa7813 Batch update copyright years everywhere 2016-02-07 18:50:45 +01:00
baldurk 7b952c53ef Move loadmodule/getprocaddress code into os_specific 2016-02-07 18:44:53 +01:00
baldurk 079a44b4a9 Speculative fix - try to avoid crashes if hooked dlopen is called early
* This isn't particularly stable/nice, probably needs a complete rethink
2015-10-01 00:51:22 +02:00
baldurk 62f7362e92 Move dlopen to be hooked centrally on linux, to be multi-API friendly 2015-08-23 22:23:53 +02:00
baldurk bde6fabf7d Rearrange project structure, so that drivers can be easily disabled
* This is kind of arbitrary at the moment, but in future when D3D12 and
  Vulkan drivers appear, not everyone who builds RenderDoc will want to
  build all drivers, so making them separate projects makes it more easy
  to disable/remove them.
2015-06-29 20:04:47 +02:00
baldurk adaf3b25e6 Remove orphaned file 2015-06-19 22:37:30 +02:00
baldurk 1d96ac2b05 Simplify renderdoc_app.h to remove typedefs and dependency on stl 2015-06-19 22:34:57 +02:00
baldurk 6993052c31 Linux compile fixes 2015-04-14 08:05:13 +01:00
baldurk b41b5242d1 Support switching between multiple APIs in the same program. Closes #124
* The core class is now responsible for tracking the active window and
  cycling through, so it can cycle through multiple APIs.
* For GL we only set up associations for capturable windows, and only
  those that present (since helper windows are often created). Since
  GL doesn't really have a 'this window is done rendering' call, we just
  decay old windows that haven't presented in >5 seconds.
* Also on GL, legacy/uncapturable windows aren't associated so they will
  not cycle to at all.
* The embedding API now expects a device pointer and window handle to
  set active window or start/end a capture. You can still pass NULLs if
  there is only one API active.
2015-04-13 11:31:30 +01:00
baldurk 35fa1ce2bf Refuse to capture on old contexts, warn on compat profiles. Closes #125
* If CreateContextAttribs is not used to create the context, the overlay
  will run in super-duper old mode using immediate mode calls and fixed
  function pipeline. This way it should display on (in theory) any GL
  app. Capturing will be prevented.
* Compatibility profile contexts are still allowed, but a warning is
  displayed in the overlay.
* If CreateContextAttribs is used to create a < 3.2 version context, we
  go down the same path as for legacy contexts, except with an accurate
  overlay message (just that the version isn't supported).
2015-04-08 21:43:04 +01:00
baldurk 6cd1f70bb6 Fix several warnings for compiling on VS2015
* Note at the time of committing there are still some warnings in MS
  headers that you might need to suppress in a couple of files.
* 3rd party code just has the warnings suppressed for ease of merging.
* The majority of warning fixes were for local variables shadowing
  other locals, function parameters, or members. In most cases they
  weren't a problem, but in some cases it was potentially dangerous!
2015-03-13 10:16:19 +00:00
baldurk 446d7d6da5 Take our own copy of the X connection that we are passed
* We need to copy the X display (by fetching its connection string and
  calling XOpenDisplay), so that if the Display* we had gets closed then
  nothing will crash.
2015-02-25 22:26:45 +00:00
baldurk c9c52537f1 ARB_dsa part 1 - hook DSA functions, implement all but tex* & create*
* Doesn't compile yet! Just splitting this up logically so the change is
  a bit easier to digest.
* I've commented and organised a bit better the gl_hookset.h hook list.
* The function hooks are set up for all of the ARB_dsa entry points.
  Those that are semnatically identical to EXT_dsa are set up as aliases
  (with EXT_ being canonical, so we can fall back if ARB_dsa isn't
  supported - see comments in gl_hookset.h).
* Implemented the new functions except for the glTexture* family and the
  glCreate* family. No deduplication of code yet.
* As with EXT_dsa we "promote" to the DSA function for serialisation,
  but since unlike EXT_dsa we can't assume ARB_dsa is present, instead
  we emulate those functions that we might use unconditionally but may
  not be present.
2015-02-22 23:36:33 +00:00
baldurk ee37bca573 Implement Process::CreateAndInjectIntoProcess on linux
* It's not exactly feature parity but it's a start, and any UI would use
  this under the hood.
* This means at least linux has a semi user-friendly way to launch and
  capture programs - it's limited but you can just use
  $ ./bin/renderdoccmd -c /path/to/program "argument string"
  from the root of the repository.
* Logfile and capture options (which can't be set yet, but you could easily
  hack in something to set them in renderdoccmd.cpp) are passed via
  environment variables to the child process.
2015-01-04 01:02:05 +00:00
baldurk f1f72ec8ff Add process for programs to voluntarily remove renderdoc. Refs #115
* To remove renderdoc (e.g. if the API version doesn't match what is
  expected), user code can call RENDERDOC_Shutdown() to remove the running
  thread and undo any library hooks, then unload the dynamic library.
* This still isn't recommended as there could be unexpected side-effects,
  and it will definitely break if this happens after any APIs have been
  initialised, but it's an option.
2014-12-21 11:30:29 +00:00
baldurk de702ac1d9 Stop filtering wgl extensions, just return all we don't hook as-is
* I will assume for now that any wgl functions I don't explicitly hook have
  no effect on the captured frame and we can safely just let them straight
  through to the real function.
2014-12-20 19:54:46 +00:00
baldurk 3298905d1d Optimise/improve hookset.pl, return dummy function pointers
* Now instead of returning NULL for entry points that we don't support and
  hoping the application will handle that or error out, instead we return
  a function that will log an error if it is ever called, and then pass
  through to the real function. In most cases, the capture will probably be
  broken as whichever function isn't saved.
* hookset.pl is much faster too, it outputs the whole gl_hookset_defs.h
  file and doesn't do multiple searches over the whole set of headers in
  official/ for each function.
2014-12-20 19:54:46 +00:00
baldurk 652f3529a3 Track if a context is core or not, re-check vendor checks on core
* When a compatibility context is created (via the old CreateContext, or
  via an appropriate CreateContextAttribs call), we can still do the vendor
  checks but we want to make sure we perform them again if we ever create a
  core profile context. Note that actually *using* a compatibility context
  isn't supported at the moment, but this won't explicitly break that.
2014-12-14 12:17:41 +00:00
baldurk 2c12423975 Return some WGL extensions that we can easily support. 2014-12-14 00:29:16 +00:00
baldurk c207391b54 Linux compile fixes. 2014-12-12 00:15:45 +00:00
baldurk 5fe0354ce4 Drop use of CONTEXT_FORWARD_COMPATIBLE_BIT, add CORE_PROFILE_BIT 2014-12-11 22:41:11 +00:00
baldurk 12af78d535 Print out the attribs a context is created with 2014-12-11 22:39:35 +00:00
baldurk 11df77cdff Return wglGetSwapIntervalEXT straight 2014-12-11 21:08:19 +00:00
baldurk 9be802082f Add a vendor check to detect if FBOs or VAOs are actually shared
* This lets us detect if the FBO/VAO behaviour is different from the main
  spec, and so we won't miss deletes or other events if the context is
  different since we'll treat them as shared like any other object.
2014-12-11 20:30:34 +00:00
baldurk bda809f9dc Allow GL driver to switch current contexts when really necessary 2014-12-06 20:25:48 +00:00
baldurk 1d0ba67331 Fix for fetching "dll export" functions via getprocaddress on linux 2014-12-05 23:49:50 +00:00
baldurk d30ce5d6b2 Fixes for replay, and populating hooks (call through hooked func) 2014-12-03 18:16:06 +00:00
baldurk 185df924dc Use proper wglGetProcAddress hook 2014-12-03 16:52:37 +00:00
baldurk 2f48158a89 Add some extensions that we already support, and ARB func aliases 2014-12-03 16:03:19 +00:00
baldurk 1061948185 Implement AllowFullscreen (or rather, !AllowFullscreen) for win32 GL 2014-12-03 10:41:37 +00:00
baldurk 4aab1172a4 Save out multisample count on default framebuffer 2014-12-02 23:27:03 +00:00
baldurk 9369c85953 Mute the spam about supported extension functions not being returned 2014-12-02 01:31:35 +00:00
baldurk 15e9b58317 Linux fixes for switch to UTF-8 strings. 2014-12-01 21:40:43 +00:00
baldurk 50d6b62adf Proper SRGB handling in opengl. See gl-320-fbo-srgb
* We create fake backbuffer as SRGB if the original default backbuffer was
  SRGB in the program.
* All of our output backbuffers are also SRGB, and we enable
  GL_FRAMEBUFFER_SRGB when writing to them.
* Add the 'fake' srgb curve applied to linear data to display it as if it
  were srgb, which tends to look intuitively correct even if it's not 100%
  accurate. See the behaviour existing in D3D11 already.
2014-12-01 17:13:30 +00:00
baldurk 2484bc8bc7 Use UTF-8 everywhere possible and only use wchar_t where required.
* This means that all APIs pass byte string types. ALL strings everywhere
  in the entire codebase must be assumed to be and treated as UTF-8 content
  not ASCII.
* Gets rid of all the horrible %hs specifiers that caused warnings on
  linux! Hooray.
* We convert to wide strings, or use wide characters, only when necessary
  to use the Win32 API. Some windows specific code will stay in wide chars
  just for convenience.
* Files are already serialised as UTF-8 strings for linux/windows binary
  compatibility, so this change doesn't break backwards compatibility.
2014-11-23 14:45:16 +00:00
baldurk 6afe7b7cd1 Speculative change to prevent infinite loop of renderdoccmd.exe
* There was a report of renderdoccmd.exe doing --cap32for64 in an infinite
  loop on itself (each process trying to inject the previous). I'm not sure
  how this could get started, but assuming this was happening automatically
  for 'hook into children', try to break the infinite loop by refusing to
  inject into our own exes.
2014-11-16 16:38:48 +00:00
baldurk 643447f521 Fix for hook fetching/populating on capture and replay 2014-11-16 12:34:55 +00:00
baldurk 92d77e32b3 Add missing \s 2014-11-15 00:33:11 +00:00
baldurk 29b4c65162 Work around issue where application 'exports' gl symbols
* This is a bit complex. If an application has a global symbol e.g.
  GLENABLE glEnable; as their function pointers that they fill out from
  glXGetProcAddress, then OUR glEnable global function gets replaced with
  that symbol. It's weird. But it means crashes if we try and return the
  address of that symbol as a function pointer.
* However it's also possible to get the reverse problem - if an application
  has a shared library that has those symbols expecting them to be function
  pointers, those symbols will get overridden with our global functions
  and it will mean an instant crash when they try to assign to those func
  ptrs.
* I'm not sure if there is an ideal fix to this Catch-22, as we also need
  to export these bare functions in case someone just plain links against
  libGL and expects them to be there, with no GetProcAddress/dlsym funny
  business.
2014-11-15 00:13:44 +00:00