Java Card CAP 文件组件分析 09—— Reference Location Component

来源:互联网 发布:如何导入sql数据库 编辑:程序博客网 时间:2024/06/06 11:41

Reference Location组件保存了method组件中索引的偏移。

1
2
3
4
5
6
7
8
reference_location_component {
    u1 tag
    u2 size
    u2 byte_index_count
    u1 offsets_to_byte_indices[byte_index_count]
    u2 byte2_index_count
    u1 offsets_to_byte2_indices[byte2_index_count]
}

以helloworld.cap中的RefLocation.cap为例:

0×09 | 0×00 0×13 | 0×00 0×03 | 0x0E 0×26 0x2B | 0×00 0x0C | 0×05 0x0C 0×06 0×04 0×08 0×05 0×11 0x0C 0×07 0×09 0×06 0×09

  • tag: 09 COMPONENT_ReferenceLocation
  • size: 0×13 该组件中除去tag和size的3个字节,还有19 bytes的信息。
  • byte_index_count: 03 在offsets_to_byte_indices数组中的元素数量
  • offsets_to_byte_indices[3]: 0x0E 0×26 0x2B 数组中的值是Method_info的偏移,该偏移位置的值是一个constant_pool[]的下标
  • byte2_index_count: 0x0C
  • offsets_to_byte2_indices[12]: 0×05 0x0C 0×06 0×04 0×08 0×05 0×11 0x0C 0×07 0×09 0×06 0×09

在卡内installer中对RefLocation.cap的解析:

1
2
3
4
5
6
7
8
9
10
11
12
13
    //Parse reference location component
    intiPosr = 0;
#define READU1 readU1(pReferenceLocationComponent,&iPosr)
#define READU2 readU2(pReferenceLocationComponent,&iPosr)
    u2 byteIndexCount = READU2;
    COUT<setOffsetsToByte2Indices(byte2IndexCount);
    for(intir2=0;ir2offsetsToByte2Indices+ir2) = READU1;
    }
 
    newapplet->pRefLoc = pRlc;
 
#undef READU2
#undef READU1

作者:fish
转自:http://www.dreamingfish123.info/?p=684
0 0
原创粉丝点击