CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: RtlCaptureStackBackTrace

  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,595

    RtlCaptureStackBackTrace

    Does anyone know what I need to #include in order to get RtlCaptureStackBackTrace in VS2019?

    The MSDN page suggests that it's in winnt.h but that I should either include FltKernel.h or Ntifs.h - but if I #include either FltKernel.h or Ntifs.h, the compiler tells me it can't find them (and in fact they don't seem to exist on my system). And if I simply #include winnt.h, RtlCaptureStackBackTrace comes up as an unidentified symbol
    "A problem well stated is a problem half solved. - Charles F. Kettering

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,315

    Re: RtlCaptureStackBackTrace

    Quote Originally Posted by John E View Post
    Does anyone know what I need to #include in order to get RtlCaptureStackBackTrace in VS2019?

    The MSDN page suggests that it's in winnt.h but that I should either include FltKernel.h or Ntifs.h - but if I #include either FltKernel.h or Ntifs.h, the compiler tells me it can't find them (and in fact they don't seem to exist on my system). And if I simply #include winnt.h, RtlCaptureStackBackTrace comes up as an unidentified symbol
    Have you installed the Windows Sdk? Are the VS paths set to find the sdk?

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,188

    Re: RtlCaptureStackBackTrace

    Using RtlCaptureStackBackTrace() with my VS2019 compiles OK with #include <winnt.h> (the other ones should be automatically included with winnt.h). As Arjay says in his post #2, have you got an SDK installed? In VS Installer, configuration - which SDK(s) have you got installed?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.6.5)

  4. #4
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,595

    Re: RtlCaptureStackBackTrace

    Hi guys - the only ones which say SDK in their name are:-

    Windows 10 SDK (10.0.18362.0)
    Windows Universal CRT SDK
    .NET Framework 4.6.1 SDK
    .NET Framework 4.8 SDK
    .NET Core 3.0 SDK
    "A problem well stated is a problem half solved. - Charles F. Kettering

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,757

    Re: RtlCaptureStackBackTrace

    I guess the
    Windows 10 SDK (10.0.18362.0)
    is what you need to install.
    Victor Nijegorodov

  6. #6
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,595

    Re: RtlCaptureStackBackTrace

    Thanks Victor but that one's already installed...

    [Edit...] Here's how it looks in winnt.h :-
    Code:
    // begin_ntifs
    
    #pragma region Application or OneCore Family
    #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
    
    #if (NTDDI_VERSION > NTDDI_WINXP)
    
    NTSYSAPI
    _Success_(return != 0)
    WORD  
    NTAPI
    RtlCaptureStackBackTrace(
        _In_ DWORD FramesToSkip,
        _In_ DWORD FramesToCapture,
        _Out_writes_to_(FramesToCapture,return) PVOID* BackTrace,
        _Out_opt_ PDWORD BackTraceHash
        );
    
    
    #endif
    
    #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
    So maybe one of the #if's is failing...
    Last edited by John E; March 24th, 2020 at 10:58 AM.
    "A problem well stated is a problem half solved. - Charles F. Kettering

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,188

    Re: RtlCaptureStackBackTrace

    Ah. Have you set _WIN32_WINNT? This needs to reflect the version of the OS to be used. Sorry, I automatically set it at the top of any of my code before anything else.

    For Windows 7 I use:

    Code:
    #ifdef WINVER
    	#undef WINVER
    #endif
    #define WINVER 0x0601
    
    #ifdef _WIN32_WINNT
    	#undef _WIN32_WINNT
    #endif
    #define _WIN32_WINNT WINVER
    For info about the version numbers see https://docs.microsoft.com/en-us/cpp...t?view=vs-2019
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.6.5)

  8. #8
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,595

    Re: RtlCaptureStackBackTrace

    Quote Originally Posted by 2kaud View Post
    Ah. Have you set _WIN32_WINNT? This needs to reflect the version of the OS to be used.
    That was it 2kaud, thanks (I still had it set to 0x500)

    On a separate issue... I often see this code in programs written for gcc:-

    Code:
    #include <limits>
    
        int x = std::min(something, something_else);
    but for building with MSVC I always need to change it to #include <algorithm> - is that something which got changed at some point or is this really different for different compilers?
    "A problem well stated is a problem half solved. - Charles F. Kettering

  9. #9
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,188

    Re: RtlCaptureStackBackTrace

    std::min() is part of <algorithms>. It's possible that for gcc <limits> also includes <algorithms>. Different compilers have different STL implementations. Also, min may be implemented in another file which is included by algorithms, limits etc. If you look at the STL include files you'll see that they themselves also use multiple includes (which aren't documented as considered internal to an implementation). Some programmers know that xx is defined in aa and yy is defined in bb which also includes aa. So if they need both xx and yy they just include bb as they know that bb also includes aa. IMO this is not good practice - the required include should always be used - there's no penalty via include guards etc. There's no guarantee that in future these internal includes might change.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)