Commit Graph

549 Commits

Author SHA1 Message Date
baldurk 8aa0390948 Add string messages to returned result codes to display to user
* Most of the main entry points that can fail with relevant reasons now has a
  way of specifying a message to return with it. This message can be displayed
  to the user to give more information or context about an error.
2022-04-26 16:21:54 +01:00
Le Philousophe 75a7f66280 Don't run hooks multiple times when shared objects are symlinked
When two shared objects are symlinked and if one is loaded,
CheckLoadedLibraries detects the other one as loaded too and run hooks a
second time.
Prevent this as it leads to recursive blocking calls in libEGL.
2022-04-15 10:58:03 +01:00
baldurk 3e5d912767 Ensure injected DLL doesn't run out of stack space
* GL hooks registration was using an obscene amount of stack because MSVC
  doesn't share stack for mutually exclusive locals (all the temporary
  FunctionHooks) so an executable that reduces the default thread stack size
  enough would fail to start.
* We also explicitly allocate 1MB of stack for injecting our DLL in future to
  avoid this issue.
2022-04-08 17:45:24 +01:00
baldurk ab19941650 Use _NT_SYMBOL_PATH where available as search path for callstacks 2022-03-10 11:13:26 +00:00
baldurk a51b20369f On windows only inherit handles if required for process output 2022-02-17 17:38:32 +00:00
baldurk fcdea67879 Update copyright years to 2022 2022-02-17 17:38:32 +00:00
Jake Turner f74b350f93 Apple: wait for ~16 seconds for application launch
On Apple Silicon it can take ~10 seconds for the OS to launch an Intel x64 process.
The Intel executable is translated on launch using Rosetta.
2022-02-16 11:10:34 +00:00
Jake Turner f9b6752f14 Apple: fix hooking not working on OSX 12
Change hooking to use link time symbol address instead of runtime dlsym
Since OSX12 dlsym(RTLD_NEXT,...) returns the interposed symbol not the real symbol
2022-02-16 11:10:34 +00:00
baldurk 6ca3d00f25 Print an error message for process creation failures on windows 2022-01-31 12:02:26 +00:00
baldurk 1464eaeb81 Ensure linux process hooks don't do anything on replay 2021-10-06 16:31:44 +01:00
baldurk 552621a87f Fix a compile warning that appears on redhat 2021-09-27 10:03:39 +01:00
baldurk 90a6e2b425 Specify file handles as explicitly non-inheriting on windows
* We never want to inherit these, and e.g. Qt process launches are hardcoded to
  always inherit handles so these need to be excluded so files don't stay open.
2021-09-09 12:24:17 +01:00
baldurk dc955079ab Fix RELEASE define on linux
* This fixes some debug text appearing in the resource inspector, and lets linux
  users submit manual bug reports from release builds.
2021-08-18 20:12:07 +01:00
baldurk e889e4aa52 Ensure we hook all exec* variants not just 'terminal' ones. Closes #2301 2021-07-13 17:04:21 +01:00
Jake Turner ee73091d54 Fix crash trying to capture invalid app name
Before the code change this command

renderdoccmd capture ~/dsdsds.app

would trigger segmentation fault accessing a null pointer
2021-07-12 20:36:05 +01:00
baldurk 6dafc45b8b Allow custom string argument formatting without va_list 2021-05-11 11:03:54 +01:00
baldurk aedf0cc701 Handle D3D12 hooked libraries on replay moving in memory on reload 2021-04-28 11:59:10 +01:00
Jake Turner 5b2203d9d2 Mac support to get executable path from .app file 2021-04-26 21:58:13 +01:00
baldurk f4d4c1862e Use minimal function hooking to allow dynamic D3D12 runtime selection
* By intercepting D3D12.dll's load of D3D12Core.dll and wrapping the COM
  interface it gets back, we can load the D3D12Core.dll that we desired.
* As a default, we load the D3D12Core.dll embedded in the capture. There's also
  a config setting to allow the user to override this, though in principle this
  shouldn't be needed.
* We only do all this if the SDK version used to capture is higher than that
  normally available on the system. So if a new runtime isn't in use, we won't
  do any hooking at all.
2021-04-22 15:52:15 +01:00
Jake Turner e4cd163c5f Reformatting *.mm files with clang-format 2021-04-07 11:54:46 +01:00
Jake Turner 372a449858 Apple support for capture keys F11, F12, PrtScrn
Implemented bool GetKeyState(int key)
Added apple_helpers.mm
apple_isKeyPressed() & apple_initKeyboard()
keyboard capturing is implemented using addLocalMonitorForEventsMatchingMask
2021-03-28 10:52:18 +01:00
Jake Turner 65e0028f64 Apple increased lsof wait time
Need a longer time when launching applications from xcode for debugging
Previously the wait time was ~1 second, now it is ~8 seconds
2021-03-26 09:39:55 +00:00
baldurk 911d290948 Fix warning about implicit std::pair copy in android hook code 2021-03-23 12:50:26 +00:00
baldurk 6f8bf648aa Fix build on VS2019 2021-03-22 19:19:38 +00:00
baldurk 3b341649f6 Properly set byte count for STARTUPINFO struct 2021-03-22 18:37:10 +00:00
baldurk c30e969a69 Remove vulkan environment variable when not hooking child processes
* If we don't explicitly remove it, the environment variable can get inherited
  into child processes that we don't intend to hook.
2021-03-22 18:37:09 +00:00
baldurk 287da369fc Fix handling of child processes on linux
* We need to ensure we remodify LD_LIBRARY_PATH and LD_PRELOAD before fork/exec
  if the application (say bash running a script) has overwritten them. We also
  don't want these to be accidentally inherited into children if we're not
  hooking children - the same for the vulkan env var, which can't be unset
  immediately on process injection like the others because it needs to hang
  around indefinitely.
2021-03-22 18:37:09 +00:00
baldurk 01f86e7c3a Pause at main first before adding PIDs to zombie list on linux 2021-03-22 18:37:09 +00:00
Jake Turner 6b6a720c08 Apple remove allocPath from GetExecutableFilename
allocPath was allocated but never used
2021-03-16 19:22:31 +00:00
Jake Turner 004a731607 On Apple use GetLibraryFilename() to set libfile
Solves problem when injecting renderdoc into a process from an executable which is not renderdoccmd or qrenderdoc
2021-03-14 11:17:31 +00:00
Artyom Dangizyan 7171350638 fix heap buffer overflow 2021-03-01 10:12:34 +00:00
baldurk 11268b358a Remap block-compressed 3D textures to 2D arrays on GL. Closes #2186 2021-02-22 12:38:43 +00:00
Jake Turner 1f332f629f Fix Apple platform bug in GetTickFrequency
The numerator and denominator were the wrong way around.
Discovered running renderdoccmd unit tests on M1 Mac Book Air
2021-02-19 10:09:10 +00:00
baldurk 31c45634be Fix linux injected process incorrectly detecting debugger. Closes #2170
* We use ptrace to detect child processes reliably, but that makes us look like
  a debugger to the child. * There isn't a reliable and simple way to pass down
  a PID to ignore (environment variables are the only simple option I can see,
  and they can't be reliably inherited, ptrace to poke data would require lots
  of work to figure out _where_ to poke that data).
* So instead we use a semi-heuristic - if the debugger PID is found but it
  contains executable pages mapped from librenderdoc.so assume we're still being
  ptrace setup'd, and check again next time we want to know if a debugger is
  connected.
2021-02-02 18:40:01 +00:00
JohnnyonFlame ca4bbc0530 Fix asm/ptrace.h include order 2021-01-27 00:29:14 +00:00
JohnnyonFlame 58a760cc16 Fixed missing ARM_pc define on armhf target. 2021-01-27 00:29:14 +00:00
baldurk 5ce6093661 Pick resident set memory for current memory usage on linux
* The virtual size can be much bigger than the actual amount of memory in use
  that we care about.
2021-01-22 14:20:11 +00:00
baldurk 026da176bb Update copyright years to 2021 2021-01-13 13:56:10 +00:00
Aliya Pazylbekova c1ecd9d375 Some GGP modifications
qrenderdoc/Code/CaptureContext.cpp
- Adds GGP windowing system

renderdoc/driver/ihv/amd/amd_counters.cpp
- Enables AMD counters

renderdoc/driver/vulkan/vk_serialise.cpp
- Handling VK_STRUCTURE_TYPE_PRESENT_FRAME_TOKEN_GGP in pNext
for vkQueuePresentKHR

renderdoc/os/posix/ggp/ggp_callstack.cpp
- Check that the file was opened
2020-12-25 10:32:22 +00:00
Alex Vakulenko e4e2d781bb Fix access mode for ::popen() call in ggp OS wrapper
popen's access mode was accidentally changed from string to enum used in
FileIO::open() wrappers. This is a posix function and should keep using
the string.
2020-12-15 22:52:05 +00:00
baldurk 6726540a11 Remove test passing NULL for rdcstr 2020-12-09 22:25:53 +00:00
baldurk f70c5be592 Fix issues with linux/mac builds 2020-12-09 21:57:15 +00:00
baldurk e5f4ca7bb8 Remove use of const char * in public API and OS specific where possible
* This prevents unnecessary conversions back and forth between rdcstr and const
  char * when going through interfaces. In the OS specific layer this is rarely
  an issue because most of the implementations don't convert to rdcstr, but it
  is convenient to be able to pass in an rdcstr directly. The few cases where
  there's an unecessary construction of an rdcstr is acceptable.
* A couple of places in the public API need to return a string from a global
  function, so can't return an rdcstr due to C ABI, so they still return a const
  char *.
* Similarly const char * is kept for logging, to avoid a dependency on rdcstr
  and because that's one place where unnecessary conversions/constructions may
  be impactful.
2020-12-07 17:44:50 +00:00
baldurk 117e16041a Add an error message and don't add child process for invalid ident 2020-10-26 10:24:40 +00:00
baldurk e8f6156df3 Compile fixes in linux process handling 2020-10-26 10:19:42 +00:00
baldurk a95d51e28c Deliberately 'leak' winsock to avoid deadlock on shutdown. Closes #2079 2020-10-19 17:00:25 +01:00
baldurk 8f6359059b Make more config flags non-debug.
* Only performance-sensitive flags should be debug only. Otherwise there's no
  strong reason to limit these to non-official builds.
2020-10-01 17:48:35 +01:00
LukeRoss00 33a1c9b2c6 Update win32_callstack.cpp
Module offset was mistakenly being erased together with .pdb extension
2020-09-11 15:31:31 +01:00
baldurk 78f1f8f3d1 Remove volatile from Atomic parameter declarations
* This was leaky from windows' InterlockedIncrement etc declarations, and is not
  necessary.
2020-09-09 16:40:04 +01:00
baldurk d71d275dc4 Don't re-read entire logfile every time, only read from last position 2020-09-03 17:45:41 +01:00