ildasm, ilasm
От: infused  
Дата: 30.09.03 09:05
Оценка:
Если использовать ildasm, то в полученном .il файле всегда есть такой участок:

.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 1:0:3300:0
}
.assembly con1
{
.custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyKeyFileAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyDelaySignAttribute::.ctor(bool) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyKeyNameAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 00 00 00 )
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(bool,
// bool) = ( 01 00 01 01 00 00 )
.hash algorithm 0x00008004
.ver 1:0:1368:19310
}
.module con1.exe
// MVID: {66D1A8A3-CDA6-4D2D-BDA7-1E7823A4F231}
.imagebase 0x00400000
.subsystem 0x00000003
.file alignment 512
.corflags 0x00000001
// Image base: 0x03110000





Так вот, для чего нужен .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) ???
Если его менять как и н что это влияет?

Зачем нужен ctor и вообще зачем ( 01 00 00 00 00 ) ???


Зараннее благодарен...
Re: ildasm, ilasm
От: V.Petrovski Беларусь  
Дата: 30.09.03 09:32
Оценка:
Здравствуйте, infused, Вы писали:

I>Если использовать ildasm, то в полученном .il файле всегда есть такой участок:


I>.assembly extern mscorlib

I>{
I> .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
I> .ver 1:0:3300:0
I>}
I>.assembly con1
I>{
I> .custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 00 00 00 )
..
I> .custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 00 00 00 )
I> .hash algorithm 0x00008004
I> .ver 1:0:1368:19310
I>}
I>Так вот, для чего нужен .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) ???

An assembly reference can store either a full public key or an 8 byte "publickeytoken." Either can be used to validate that the same private key used to sign the assembly at compile time signed the assembly used at runtime. Neither is required to be present, and while both can be stored this is not useful.

A conforming implementation of the CLI need not perform this validation, but it is permitted to do so, and it may refuse to load an assembly for which the validation fails. A conforming implementation of the CLI may also refuse to permit access to an assembly unless the assembly reference contains either the public key or the public key token. A conforming implementation of the CLI shall make the same access decision independent of whether a public key or a token is used.


I>Если его менять как и н что это влияет?


Если его поменять то может не скомпилится код, или если скомпилится то в рантайме выдаст ошибку
о невозможности загрузить сборку.

I>Зачем нужен ctor и вообще зачем ( 01 00 00 00 00 ) ???


.ctor — это конструктор
( 01 00 00 00 00 ) — это его параметры

Здесь 01 00 — это прагма (магическое число)
а 00 00 00 — это значение параметров

Для лучшего понимания посмотри
\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers Guide\docs\Partition II Metadata.doc
... << RSDN@Home 1.1 beta 1 Peru Music — Aguas claras>>
Re[2]: ildasm, ilasm
От: infused  
Дата: 30.09.03 11:03
Оценка:
большой спасиб!
Re[2]: ildasm, ilasm
От: Kupaev Россия www.rsdn.ru
Дата: 01.10.03 07:13
Оценка:
Здравствуйте, V.Petrovski, Вы писали:

Позволю себе немного уточнить. Первые два байта (0x0001 ) — это так называемый пролог, у атрибутов пролог всегда равен 0x0001. Затем следуют ЗНАЧЕНИЯ аргументов того конструктора, которому соответствует атрибут. КОЛИЧЕСТВО этих параметров и ТИПЫ этих параметров описываются в сигнатуре конструктора, в атрибуте их попросту нет. Кроме того, в сигнатурах метода (а конструктор, разумеется, мы может отнести к методам) хранится и тип возвращаемого методом значения. При этом, разумеется, все в кодированном — перекодированном виде, так что с налёта понять что-либо попросту невозможно.
Судя по приведённому примеру, в качестве аргумента конструктору передаётся просто пустая строка, не так ли? Даже могу предположить, что где-то в программе не указаны название программы и сведения о копирайте. :
Задача "распознавания" сигнатур и приведения их в удобочитаемый вид — сама по себе достаточно интересна. Если ты хочешь в этом разобраться, то запасись терпением и изучи тот документ, "координаты" которого тебе привели.

С уважением,

OldDino

VP>Здравствуйте, infused, Вы писали:


I>>Если использовать ildasm, то в полученном .il файле всегда есть такой участок:

I>>{
I>> .custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 00 00 00 )
I>> .custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 00 00 00 )

I>>Зачем нужен ctor и вообще зачем ( 01 00 00 00 00 ) ???


VP>.ctor — это конструктор

VP>( 01 00 00 00 00 ) — это его параметры

VP>Здесь 01 00 — это прагма (магическое число)

VP>а 00 00 00 — это значение параметров

VP>Для лучшего понимания посмотри

VP>\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers Guide\docs\Partition II Metadata.doc
... << RSDN@Home 1.1 beta 2 >>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.