Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

c++ - VS2010 - Structure change in CryptoAPI - v7.0A Vs v6.0A - WinCrypt.h

In C:Program FilesMicrosoft SDKsWindowsv7.0AIncludeWinCrypt.h, the definition for CERT_CHAIN_ENGINE_CONFIG is

typedef struct _CERT_CHAIN_ENGINE_CONFIG {

    DWORD       cbSize;
    HCERTSTORE  hRestrictedRoot;
    HCERTSTORE  hRestrictedTrust;
    HCERTSTORE  hRestrictedOther;
    DWORD       cAdditionalStore;
    HCERTSTORE* rghAdditionalStore;
    DWORD       dwFlags;
    DWORD       dwUrlRetrievalTimeout;      // milliseconds
    DWORD       MaximumCachedCertificates;
    DWORD       CycleDetectionModulus;

*#if (NTDDI_VERSION >= NTDDI_WIN7)
    HCERTSTORE  hExclusiveRoot;
    HCERTSTORE  hExclusiveTrustedPeople;
#endif*

} CERT_CHAIN_ENGINE_CONFIG, *PCERT_CHAIN_ENGINE_CONFIG;

I am using visual studio 2010 in an XP sp3 machine, in which case, i expect that the following two members in the above structure gets greyed out. But this is not happening,

#if (NTDDI_VERSION >= NTDDI_WIN7)
    HCERTSTORE  hExclusiveRoot;
    HCERTSTORE  hExclusiveTrustedPeople;
#endif

NTDDI_VERSION in-turn is defined in sdkddkver.h as follows, and _WIN32_WINNT somehow takes the value of NTDDI_WIN7 which in my case is incorrect as mine is a XP SP3 machine.

#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
#define  _WIN32_WINNT   0x0601
#endif
#ifndef NTDDI_VERSION
#ifdef _WIN32_WINNT
// set NTDDI_VERSION based on _WIN32_WINNT
#define NTDDI_VERSION   NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT)
#else
#define NTDDI_VERSION   0x06010000
#endif
#endif

The above two members of the structure CERT_CHAIN_ENGINE_CONFIG in question is not present in C:Program FilesMicrosoft SDKsWindowsv6.0AIncludeWinCrypt.hBut my 2010 visual studio project automatically pulls in the header and lib files from C:Program FilesMicrosoft SDKsWindowsv7.0AIncludeWinCrypt.h Because of the conflicting structures, i am getting parameter is incorrect

Please advise how i can over come this issue?

Should i have to install visual studio 2010 sp1?

I found one reference in the web where it says initialising the structure will resolve the issue, but it will not, as the two parameters in question will not be greyed out and will be taken in while building.

UPDATE1:

Settings of my project:

enter image description here $(VCInstalDir) - >C:Program FilesMicrosoft Visual Studio 10.0VC

$(WindowsSdkDir) ->C:Program FilesMicrosoft SDKsWindowsv7.0A

$(FrameworkSdkDir) ->C:Program FilesMicrosoft SDKsWindowsv7.0A

Library file settings,

$(VCInstallDir)lib
$(VCInstallDir)atlmfclib
$(WindowsSdkDir)lib
$(FrameworkSDKDir)lib

UPDATE 2: My preprocessor definitions are

WIN32;_DEBUG;_WINDOWS;_USRDLL;MY_DLL_EXPORTS;%(PreprocessorDefinitions)

%(PreprocessorDefinitions) inherited values as follows

_WINDLL
_MBCS

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

the value of NTDDI_WIN7 which in my case is incorrect as mine is a XP SP3 machine.

As I understand it, the variables are initialized according to what system you are targeting, not what system you are compiling the code on. So you need to look at your project settings and see, what is your target platform, what headers are referenced etc. .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...