VC资源中的RCDATA是啥,RT_MANIFEST是啥意思,请详细赐教,谢谢。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VC资源中的RCDATA是啥,RT_MANIFEST是啥意思,请详细赐教,谢谢。相关的知识,希望对你有一定的参考价值。
参考技术A 英文的,很详细,来自MSDNRCDATA resource
Defines a raw data resource for an application. Raw data resources permit the inclusion of binary data directly in the executable file.
nameID RCDATA [optional-statements] raw-data ...
Parameters
nameID
Unique name or a 16-bit unsigned integer value that identifies the resource.
optional-statements
This parameter can be zero or more of the following statements.
Statement Description
CHARACTERISTICS dword User-defined information about a resource that can be used by tools that read and write resource files. For more information, see CHARACTERISTICS.
LANGUAGE language, sublanguage Language for the resource. For more information, see LANGUAGE.
VERSION dword User-defined version number for the resource that can be used by tools that read and write resource files. For more information, see VERSION.
raw-data
Raw data consisting of one or more integers or strings of characters. Integers can be specified in decimal, octal, or hexadecimal format. To be compatible with 16-bit Windows, integers are stored as WORD values. You can store an integer as a DWORD value by qualifying the integer with the "L" suffix.
Strings are enclosed in quotation marks. RC does not automatically append a terminating null character to a string. Each string is a sequence of the specified ANSI characters, unless you qualify it as a wide-character string with the L prefix.
The block of data begins on a DWORD boundary and RC performs no padding or alignment of data within the raw-data block. It is your responsibility to ensure the proper alignment of data within the block.
Certain attributes are also supported for backward compatibility. For more information, see Common Resource Attributes.
Examples
The following example demonstrates the use of the RCDATA statement:
resname RCDATA
"Here is an ANSI string\0", // explicitly null-terminated
L"Here is a Unicode string\0", // explicitly null-terminated
1024, // integer, stored as WORD
7L, // integer, stored as DWORD
0x029a, // hex integer
0o733, // octal integer
=====================================
RT_MANIFEST
Since Windows XP, Windows reserves a new type of resource RT_MANIFEST for SxS manifests.
Within the RT_MANIFEST resource, Windows reserves ID 1-16. A binary cannot have two IDs of resource type RT_MANIFEST within 1-16. Windows will refuse to load such binary in Windows XP/Windows Server 2003.
Only three IDs are used today in Windows.
excerpt from Winuser.h
#define RT_MANIFEST MAKEINTRESOURCE(24)
#define CREATEPROCESS_MANIFEST_RESOURCE_ID MAKEINTRESOURCE( 1)
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(2)
#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(3)
#define MINIMUM_RESERVED_MANIFEST_RESOURCE_ID MAKEINTRESOURCE( 1 /*inclusive*/)
#define MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(16 /*inclusive*/)
CREATEPROCESS_MANIFEST_RESOURCE_ID
CREATEPROCESS_MANIFEST_RESOURCE_ID is used primarily for EXEs. If an executable has a resource of type RT_MANIFEST, ID CREATEPROCESS_MANIFEST_RESOURCE_ID, Windows will create a process default activation context for the process. The process default activation context will be used by all components running in the process.
CREATEPROCESS_MANIFEST_RESOURCE_ID can also used by DLLs. When Windows probe for dependencies, if the dll has a resource of type RT_MANIFEST, ID CREATEPROCESS_MANIFEST_RESOURCE_ID, Windows will use that manifest as the dependency.
ISOLATIONAWARE_MANIFEST_RESOURCE_ID
ISOLATIONAWARE_MANIFEST_RESOURCE_ID is used primarily for DLLs. It should be used if the dll wants private dependencies other than the process default. For example, if an dll depends on comctl32.dll version 6.0.0.0. It should have a resource of type RT_MANIFEST, ID ISOLATIONAWARE_MANIFEST_RESOURCE_ID to depend on comctl32.dll version 6.0.0.0, so that even if the process executable wants comctl32.dll version 5.1, the dll itself will still use the right version of comctl32.dll.
When LoadLibrary is called, before loading the dependencies of the dll, the NT library loader checks to see if the dll has a resource of type RT_MANIFEST, ID ISOLATIONAWARE_MANIFEST_RESOURCE_ID. If it does, the loader calls CreateActCtx with the resource, and use the generated activation context to probe the dll's static dependencies. This is reason why the dll can have private dependencies with the ISOLATIONAWARE_MANIFEST_RESOURCE_ID resource.
The activation context created during LoadLibrary is stored in the loader data structure tracking the dll.
Normally this activation context is used only during LoadLibrary, for the dll's static dependencies.
Sometimes, you want to use the activation context outside of probing the dll's static dependencies. You can define macro ISOLATION_AWARE_ENABLED when you compile the module.
ISOLATION_AWARE_ENABLED
When ISOLATION_AWARE_ENABLED is defined, Windows re-defines certain APIs. For example LoadLibraryExW is redefined to IsolationAwareLoadLibraryExW.
When IsolationAwareLoadLibraryExW is first called, it tries to retrieve the activation context stored in the loader data structure when the calling library is loaded. If the library does not have such activation context (for example, the library does not have a manifest of id ISOLATIONAWARE_MANIFEST_RESOURCE_ID), IsolationAwareLoadLibraryExW tries to create a new activation context with the calling library with id ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID MAKEINTRESOURCE. If the creation fails, IsolationAwareLoadLibraryExW will use the process default activation context.
Once the activation context is determined, IsolationAwareLoadLibraryExW will call ActivateActCtx on the activation context, call the real API (LoadLibraryExW), and on return, it calls DeactivationActCtx. This way, the correct activation context is automatically used.
Not all APIs affected by activation context are wrapped. For example, GetModuleHandleEx is not wrapped, and neither is any of the COM APIs. For a complete list of APIs wrapped by ISOLATION_AWARE_ENABLED, check your copy of Windows SDK.
C:\Program Files\Microsoft SDKs\Windows\v6.0\Include>dir *.inl
Volume in drive C has no label.
Volume Serial Number is ECD1-6DB0
Directory of C:\Program Files\Microsoft SDKs\Windows\v6.0\Include
10/30/2006 01:44 AM 159,222 commctrl.inl
10/30/2006 01:44 AM 32,836 commdlg.inl
10/30/2006 01:44 AM 12,065 prsht.inl
10/30/2006 01:44 AM 23,430 WinBase.Inl
10/30/2006 01:44 AM 36,308 WinUser.Inl
If the APIs you use are not wrapped by ISOLATION_AWARE_ENABLED, you have to do the activation/deactivation yourself properly. You can use the C++ helper class described in MSDN http://msdn2.microsoft.com/en-us/library/aa375197.aspx.
For more information, please see MSDN section about Sxs Isolated Applications and Side-by-side Assemblies.追问
谢谢你的答复,请问能给出中文的描述吗,通用的作用是什么,如何使用呢,
本回答被提问者采纳 参考技术B 应该是模板和二进制的什么文件吧RCDATA 和用户定义的资源有啥区别?
【中文标题】RCDATA 和用户定义的资源有啥区别?【英文标题】:What is the difference between RCDATA and User-Defined Resource?RCDATA 和用户定义的资源有什么区别? 【发布时间】:2014-12-01 20:19:06 【问题描述】:RCDATA 和用户定义的资源有区别吗? RCDATA 只是用户定义资源的通用名称吗?
【问题讨论】:
据我所知没有区别。 “为应用程序定义原始数据资源。原始数据资源允许将二进制数据直接包含在可执行文件中” 区别在于资源类型。用户定义资源的类型是您给它的名称。 RCDATA 的类型是 RT_RCDATA。 【参考方案1】:有两种资源适合存储用户定义的数据。
第一种类型是 RCDATA(原始数据)。 Windows 知道资源的类型,但不知道如何解释资源数据本身。
第二种是 Windows 未定义其类型的任何资源。在这种情况下,Windows 既不知道资源的类型,也不知道如何解释资源数据。
您可以将任何一种资源用于用户定义的数据。
我相信它是 Windows 认为是用户定义资源的第二种资源。这是System defined resource types 的列表。
RESOURCEHEADER sructure 的 Type 成员解释了用户定义的资源是什么。
【讨论】:
那么将 RCDATA 视为由 Windows 创建供我们使用的用户定义资源是错误的吗?将其视为二进制资源类型是否更好,并且用户定义的资源也恰好存储二进制数据,两者之间没有任何关系? 我尽量避免在我的回答中使用“用户定义的资源”一词,因为它对不同的人似乎意味着不同的东西。对某些人来说,它似乎意味着 RCDATA 类型的资源(顺便说一句,它是由 Windows 定义的资源类型),但我读过的 MSDN 文档似乎使用该术语来表示类型是用户定义的资源。至于思考这些事情的最佳方式,我真的不能说哪种方式最适合你。 这似乎是一个哲学问题,哈哈,无论如何,我认为最好将它们视为相同的东西(它们都存储二进制数据),但类型名称不同。【参考方案2】:“RCDATA 和用户定义的资源有区别吗?”
如果我读到 the documentation 它会说
RCDATA 资源为应用程序定义原始数据资源。原始数据资源允许将二进制数据直接包含在可执行文件中。
它还说
特性 |双字| 用户定义的信息,关于可供读取和写入资源文件的工具使用的资源。有关详细信息,请参阅特性。
“RCDATA 只是用户定义资源的通用名称吗?”
所以我想说,可以认为没有真正的区别,但只是 RCDATA
是您的资源 (.rc
) 文件中用于用户定义的资源的关键字.
【讨论】:
以上是关于VC资源中的RCDATA是啥,RT_MANIFEST是啥意思,请详细赐教,谢谢。的主要内容,如果未能解决你的问题,请参考以下文章