Analysis of ActiveX Control cab Compression

Source: Internet
Author: User

1. Introduction
ActiveX control technology is developed on the basis of OLE. It extends [Kuo Zhan] to adapt to the development of Internet, Intranet, and commercial application [Ying Yong] programs. When the ActiveX control program code is transmitted over the Internet [Chuan Shu], it makes sense to transmit [Chuan Shu] program code by compressing [ya suo] technology.
On the other hand, if the ActiveX control also calls [Tiao Yong] to other DLL program modules [Mo Kuai], ie must also download these programs [Xia Zai] to the local. Therefore, Microsoft adopts the common cab compression [ya suo] method [Fang fa], it puts ActiveX control application [Ying Yong] program and other related files [Wen Jian] In the same cab file [Wen Jian, in the codebase attribute [Shu Xing], specify the URL path [Lu Jing] of the cab file [Wen Jian]. When ie finds the codebase attribute [Shu Xing, it automatically parses the URL address [di Zhi] to decompress the cab file [Wen Jian] to the temporary directory of the Client [ke HU, then register the [Zhu ce] File [Wen Jian] and call the [Tiao Yong] com api function [Han Shu] to create the ActiveX control object [DUI Xiang]. In this way, the ActiveX control is transmitted [Chuan Shu].

2. Introduction to cab compression [ya suo] Technology
Microsoft [Wei Ruan] is releasing Windows 95 and plus! 95 and other software [Ruan Jian] adopts a brand new form of cab compression [ya suo] package [Bao] [ya suo Bao, it has the advantages of [ya suo] High compression rate [ya suo LV], high security [An Quan Xing], and not easy to be damaged, it is well received by users [Yong HU] and software [Ruan Jian] producers. Many users [Yong HU] Even want [Xi Wang] to convert their data [Shu Ju] File [Wen Jian] To cab to compress the [ya suo] package [Bao] [ya Suo [ya suo], backup [bei FEn], to minimize the disk [CI pan] space [Kong Jian] occupied by the [bei FEn] File [Wen Jian] [bei Fen Wen Jian], and improve their security [An Quan Xing]. Currently, the software [Ruan Jian] used to create the cab file [Wen Jian] mainly includes cabarc and wincab.
Cabarc is a file [Wen Jian] used for [Yong Yu] compressing [ya suo], listing and compressing [ya suo] package [Bao] [ya suo Bao], and extracting the cab file [wen Jian] tool. Cabarc supports the [Zhi CHI] wildcard [Tong Pei Fu] and recursive path [Lu Jing] To search for [SOU suo] [Lu Jing sou suo]. However, cabarc uses a command similar to the commonly used [ya suo] tool for compressing [Ming Ling] line [Ming Ling hang] interface [Jie MiAn] [Ming Ling hang Jie MiAn],
There are also many parameters [Can Shu], which are not in coordination with the mainstream Windows operating system [XI Tong] [CaO Zuo Xi Tong] [XIE Tiao], it is not very convenient to use.
Wincab is a visual [ke Shi] [ke Shi Hua] new cab compression [ya suo] package [Bao] [ya suo Bao] production software [Ruan Jian], it adopts the graphic [Tu Xing] interface [Jie MiAn], supports [Zhi CHI] split-volume compression [ya suo], and can be used to create cab compression [ya] with the function of [Bao] for self-extracting packages. suo] package [Bao] [ya suo Bao] (*. excellent functions such as EXE file [Wen Jian] format, this fundamentally solves the problem of creating a [ya suo] package [Bao] [ya suo Bao] For cab compression [wen ti]. Note that when running [Yun hangw.wincab.exe, make sure that the [Que baow.makecab.exe file [Wen Jian] is in the same directory.
This article takes wincab as an example to introduce how to create the ActiveX control's cab file [Wen Jian.

3. Compress ActiveX Control [ya suo] into a cab file [Wen Jian]
The main steps are as follows:
1) register the [Zhu ce] yourctl. ocx control.
2) Create the yourctl. inf file [Wen Jian].
The format of the INF file [Wen Jian] is as follows: (when using Visual C ++ 6.0 [Qing Kuang)
[Version]
Signature = "$ Chicago $"
Advancedinf = 2.0
[Add. Code]
Yourctl. ocx = yourctl. ocx
Mfc42.dll = mfc42.dll
Msvcrt. dll = msvcrt. dll
Olepro32.dll = olepro32.dll
[Yourctl. ocx]
File-win32-x86 = thiscab
CLSID = {yourctl. ocx CLSID} // you can find it in the yourctl. odl file [Wen Jian ].
Fileversion =
Registerserver = Yes
[Msvcrt. dll]
Fileversion = 6, 0, 8168, 0
Hook = mfc42installer
[Mfc42.dll]
Fileversion = 6, 0, 8168, 0
Hook = mfc42installer
[Olepro32.dll]
Fileversion = 5, 0, limit 1, 0
Hook = mfc42installer
[Mfc42installer]
File-win32-x86 = value = http://activex.microsoft.com/controls/vc/mfc42.cab
Run = % extract_dir % \ mfc42.exe

Here we need to note that [Shuo Ming] Is that the fileversion of msvcrt. dll, mfc42.dll, and olepro32.dll is different based on different VC versions. For example, in vc5.0sp3, it should be as follows:
Olepro32.dll 5, 0, 4230,1
Mfc42.dll, 21
Msvcrt. dll 5, 0
Each VC version has a different version number [ban Ben Hao]. Here we only introduce the two common versions. In addition, the [Xia Zai] path for mfc42installer download [Lu Jing] Except for vc4.1 and earlier versions.
3) Start [Qi Dong] wincab and start compressing [ya suo]. (In this example, "makecab.exe" must be in the wincab directory)
I) Start [Qi Dong] wincab, then run the [Zhi hang] "cabinet" menu [Cai Dan] "new" command [Ming Ling] or click the "new cabinet" button on the [Dan Ji] shortcut bar, prepare a new cab compression [ya suo] package [Bao] [ya suo Bao].
Ii) Click "add file (s) to Cabinet" on the [Dan Ji] shortcut bar to open the "add file (s) to Cabinet" dialog box [Dui Hua Kuang].
Iii) select the file [Wen Jian] from the [Xuan ZE] [ya suo] package [Bao] [ya suo Bao] to be added to the cab for compression, and click the [Dan Ji] OPEN button, add them to the wincab file [Wen Jian] list [lie Biao. Here, you only need to add the yourctl. ocx and yourctl. INF files [Wen Jian].
Iv) in the wincab shortcut toolbar, enter [Shu RU] in the "Cabinet path and name" box or use the "browse for path and name" button to specify that the cab compresses the [ya suo] package [Bao] [ya suo Bao] path [Lu Jing] and file [Wen Jian] Name [Wen Jian Ming].
V) Specify the cab size for compressing the [ya suo] package [Bao] [ya suo Bao] in the "cabinet size" column.
Vi) in the compression method box, select the [Xuan ZE] compression [ya suo] method.
Vii) Click the [Dan Ji] "Save cabinet" button. wincab compresses [ya suo] according to user [Yong HU] requirements.
Viii) after [ya suo] is compressed, wincab will provide a "wincab Report" report box, report the number of [Wen Jian] related files to [Yong HU], compress [Wen Jian] files before and after [ya suo], and compress the [ya suo] ratio [ya suo LV] and [Qing Kuang] for [ya suo] compression. So far, a cab file [Wen Jian] is generated.
4. Conclusion
Because the [ya suo] compression rate of cab [ya suo LV] is higher than that of our commonly used [ya suo] package [Bao] [ya suo Bao] for ARJ, zip, and RAR Compression many (about 20% ), this further reduces the disk [CI pan] space [Kong Jian] occupied by the [ya suo] File [Wen Jian]. when the [Chuan Shu] ActiveX control is transmitted over the Internet, the network [Wang Luo] traffic [Liu Liang] is reduced. it also speeds up the opening of the web page [Wang Ye.
In addition, because the cab compression [ya suo] package [Bao] [ya suo Bao] has the "Read-Only [Zhi du]" attribute [Shu Xing], after creation, you cannot modify [Xiu Gai] or delete [Shan Chu]. therefore, it is difficult to be affected by [Bing du], misoperation, and other problems [wen ti]. Security [An Quan Xing] is also guaranteed, [Yong HU] is the best choice for [Xuan ZE] When compressing [Wen Jian] files in Windows [ya suo] and backing up [bei FEn].
Note: ** Fund project [Xiang Mu] **, National 973 Plan (No.: g1998030600 ).
About certificate [Zheng Shu] and signature-| zuiwanting published on 9:58:00

\ Program Files \ Microsoft Visual Studio. NET 2003 \ SDK \ V1.1 \ bin has a tool for [Zheng Shu] and signature.
1. Makecert.exe --- certificate [Zheng Shu] creation tool
2. Cert2spc.exe --- issuer certificate [Zheng Shu] Test Tool
3. Signcode.exe --- file [Wen Jian] Signature Tool
Create your own root certificate [Zheng Shu]:
Makecert-SK mypk-SS myname-n "cn = luo31 Studio"-R c: \ luo31.cer
SK-indicates the storage name of the CMK [Mi Yao] container location [Wei Zhi], SS-topic certificate [Zheng Shu, n-certificate [Zheng Shu] issued by [DUI Xiang], R-certificate [Zheng Shu] storage location [Wei Zhi];
If you need to export the private key [Si yao] File [Wen Jian], do not use SK instead of S, eg: makecert-SS myname-n "cn = luo31 Studio"-SV c: \ luo31.pvk-R c: \ luo31.cer
Create a subcertificate [Zheng Shu] authorizing [Shou Quan] From the root certificate [Zheng Shu]:
Makecert-SK "mypk"-Is myname-n "cn = luo31"-$ commercial-ic c: \ luo31.cer c: \ 31.cer
SK-indicates the storage name of the CMK [Mi Yao] container location [Wei Zhi], is-issuer's certificate [Zheng Shu, n-certificate [Zheng Shu] issued by [DUI Xiang], IC-issuer's certificate [Zheng Shu] storage location [Wei Zhi], -$-authorized [Shou Quan] range [Fan Wei] (used for [Yong Yu] code signature );
Use cert2spc to generate a SPC issuer certificate [Zheng Shu] (optional ):
Cert2spc c: \ 31.cer c: \ 31.spc
Use signcode to sign your program, library, or cab package [Bao:
Double-click signcode or type signcode in the control [Kong Zhi] [Kong Zhi Tai]. If the parameter [Can Shu] is not included, the [Qi Dong] Signature wizard [Xiang Dao] will be started. In step 3, select [Xuan ZE] "custom options [Xuan Xiang]". step 4: select [Xuan ZE] "select [Xuan ZE] from [Wen Jian]" and select [Xuan ZE] 31.spc or 31.cer. Step 5: select [Xuan ZE] "Private Key in CSP [Si yao] ", in the key [Mi Yao] container, select [Xuan ZE] The mypk we defined. In other steps, the default value is [Mo Ren]. To add a timestamp [shi jian Chuo], please go to the timestamp [shi jian Chuo] server [Fu Wu Qi] address [di Zhi] and key-in: (Free timestamp [shi jian Chuo] certified [Ren Zheng]) http://timestamp.verisign.com/scripts/timstamp.dll;
After that, observe the [Wen Jian] attribute [Shu Xing] [Wen Jian Shu Xing] of the file you signed. the number [Shu Zi] signature [Shu Zi Qian Ming] must have been added

3. Reference of ActiveX Control on the page [Yin Yong]

<Object ID = "axgraphocxscada" style = "Z-INDEX: 102; left: 160px; width: 784px; position: absolute; top: 80px; Height: 536px"
Codebase = "graphocx. Cab # version =," classid = "CLSID: 87186ea1-4d89-4f3e-9d25-1f03f0dddb95"
Name = "axgraphocxscada" viewastext>
<Param name = "_ version" value = "65536">
<Param name = "_ extentx" value = "20743">
<Param name = "_ extenty" value = "14182">
<Param name = "_ stockprops" value = "0">
</Object>

//////////

I found some relevant information on the Internet and finally made it. I would like to make a small summary:

First, prepare the required tools as follows:

Production tools: iexpress.exe and makecab.exe,

Signing tool: cert2spc.exe,makecert.exe,signcode.exe

Next I will explain how to use them to help us prepare the required cab package.

The following is my reference information on the Internet.

1. Pack OCX files and third-party DLL files into cab files:

Internet software distribution is a "Software Package" that consists of a. cab file that contains a. inf file or a software distribution. OSD file (or both.

A distribution unit can also contain software components,

Such as ActiveX controls (. ocx),. DLL files,. EXE files, Java class files, or applets. When the codebase feature of the object element on the Web page references the. inf file.

Internet Explorer automatically downloads and installs the. cab file as a software distributor. The version is automatically checked and updated each time you access the file.

The inf file is a text file that specifies the files (such as. dll or other. ocx) to be downloaded or submitted to run the control ). A. inf file is bundled.

The cab compresses all the required files. By default, files with the same version number as existing hard disks are not downloaded.

First, write an INF file. The information includes packaging the. ocx file and related. dll file, and downloading it to the Folder \ windows \ system32. The details are as follows:

[Version]

Signature = "$ Chicago $"

Advancedinf = 2.0

[Add. Code]

Pcpos. ocx = pcpos. ocx

Comm. dll = comm. dll

[Pcpos. ocx]

File-win32-x86 = thiscab

Registerserver = Yes

CLSID = {719a1d6e-7099-4123-9d63-f0118aff2d61}

Destdir = 11

Fileversion =

[Comm. dll]

File-win32-x86 = thiscab

Registerserver = Yes

Destdir = 11

Fileversion =

[Registerfiles]

% 11% \ pcpos. ocx

Note:

"Thiscab" is a keyword that indicates the cab file containing the INF. You can also download the required DLL file from the Internet by specifying an http url, for example:

File-win32-x86 = http://www.mysite.com/mydir/NEEDED.DLL

The keyword "file-win32-x86" specifies that the platform is x86.

The visible property of the file version number.

"Destdir" indicates the address of the mounted directory or file: 11. Specify it as the system directory windows // system32;

"CLSID" indicates the CLSID of the control to be installed.

Create a cab:

Use \ windows \ system32 \ iexpress.exe.

1) Select "create new self extraction directive file" and click Next.

2) Select "create compressed files only (ActiveX instils)" and click Next.

3) Click Add, add the file (pcpos. ocx, pcpos. dll, Comm. dll, tcpclnt. dll), and click Next.

4) Click Browse and enter the storage address of the. cab file (including the obtained file name). Here testcab. Cab is selected and "store files using long file name inside package" is selected ". Click Next.

5) Select "don't save" and click "Next" until the operation is completed.

Note:

If the control has been registered on the client and is not registered using. Cab, the control cannot be updated when it is automatically registered using. Cab. You must manually delete the file.

2. Digitally Sign the cab file

In the legend above, the digital signature is automatically downloaded without prompting, so try again:

There are three gadgets in the middle of \ Microsoft Visual Studio. NET 2003 \ SDK \ V1.1 \ bin to use them for digital signature.

1.makecert.exe --- certificate creation tool

2.cert2spc.exe --- issuer Certificate Test Tool

3.signcode.exe --- file signature Tool

Steps:

1) makecert-SS name-n "cn = company name"-sv d: \ pos. PVK-r d: \ pos. Cer where Sk-indicates the location of the key container of the topic,

SS-topic certificate storage name, N-certificate issuance object, R-certificate storage location,-SV export private key file (used for signature ).

Note: At this time, the password will be entered three times, and the password will be exactly the same for three times.

2) use cert2spc to generate a SPC issuer certificate (optional): cert2spc D: \ pos. Cer c: \ pos. SPC

3) double-click signcode. The signature wizard is started without parameters. Select the file to be signed first. Next, select "Custom ",

Next, select from file to add the newly generated pos. Cer certificate. Next, select the newly generated private key pos. PVK, and then click Next,

The SPC certificate can be used, and the next step is to continue. Add a timestamp and enter http: // timestamp.verisign.com/scripts/timstamp.dll testcab. Cab in the timestamp,

Next step.

In this way, the cab file is signed. However, when you click this file, the certificate becomes unavailable because the certificate is not forwarded.

File properties-> digital certificate-> details-> View Certificate-> install certificate, enter the certificate Installation Wizard, and select "Trusted Root Certificate Authority" in the storage area ", click Finish.

The idea is as shown above. If you do not understand it, you can check relevant information on the Internet. Hope to help you.

I found some relevant information on the Internet and finally made it. I would like to make a small summary:

First, prepare the required tools as follows:

Production tools: iexpress.exe and makecab.exe,

Signing tool: cert2spc.exe,makecert.exe,signcode.exe

Next I will explain how to use them to help us prepare the required cab package.

The following is my reference information on the Internet.

1. Pack OCX files and third-party DLL files into cab files:

Internet software distribution is a "Software Package" that consists of a. cab file that contains a. inf file or a software distribution. OSD file (or both.

A distribution unit can also contain software components,

Such as ActiveX controls (. ocx),. DLL files,. EXE files, Java class files, or applets. When the codebase feature of the object element on the Web page references the. inf file.

Internet Explorer automatically downloads and installs the. cab file as a software distributor. The version is automatically checked and updated each time you access the file.

The inf file is a text file that specifies the files (such as. dll or other. ocx) to be downloaded or submitted to run the control ). A. inf file is bundled.

The cab compresses all the required files. By default, files with the same version number as existing hard disks are not downloaded.

First, write an INF file. The information includes packaging the. ocx file and related. dll file, and downloading it to the Folder \ windows \ system32. The details are as follows:

[Version]

Signature = "$ Chicago $"

Advancedinf = 2.0

[Add. Code]

Pcpos. ocx = pcpos. ocx

Comm. dll = comm. dll

[Pcpos. ocx]

File-win32-x86 = thiscab

Registerserver = Yes

CLSID = {719a1d6e-7099-4123-9d63-f0118aff2d61}

Destdir = 11

Fileversion =

[Comm. dll]

File-win32-x86 = thiscab

Registerserver = Yes

Destdir = 11

Fileversion =

[Registerfiles]

% 11% \ pcpos. ocx

Note:

"Thiscab" is a keyword that indicates the cab file containing the INF. You can also download the required DLL file from the Internet by specifying an http url, for example:

File-win32-x86 = http://www.mysite.com/mydir/NEEDED.DLL

The keyword "file-win32-x86" specifies that the platform is x86.

The visible property of the file version number.

"Destdir" indicates the address of the mounted directory or file: 11. Specify it as the system directory windows // system32;

"CLSID" indicates the CLSID of the control to be installed.

Create a cab:

Use \ windows \ system32 \ iexpress.exe.

1) Select "create new self extraction directive file" and click Next.

2) Select "create compressed files only (ActiveX instils)" and click Next.

3) Click Add, add the file (pcpos. ocx, pcpos. dll, Comm. dll, tcpclnt. dll), and click Next.

4) Click Browse and enter the storage address of the. cab file (including the obtained file name). Here testcab. Cab is selected and "store files using long file name inside package" is selected ". Click Next.

5) Select "don't save" and click "Next" until the operation is completed.

Note:

If the control has been registered on the client and is not registered using. Cab, the control cannot be updated when it is automatically registered using. Cab. You must manually delete the file.

2. Digitally Sign the cab file

In the legend above, the digital signature is automatically downloaded without prompting, so try again:

There are three gadgets in the middle of \ Microsoft Visual Studio. NET 2003 \ SDK \ V1.1 \ bin to use them for digital signature.

1.makecert.exe --- certificate creation tool

2.cert2spc.exe --- issuer Certificate Test Tool

3.signcode.exe --- file signature Tool

Steps:

1) makecert-SS name-n "cn = company name"-sv d: \ pos. PVK-r d: \ pos. Cer where Sk-indicates the location of the key container of the topic,

SS-topic certificate storage name, N-certificate issuance object, R-certificate storage location,-SV export private key file (used for signature ).

Note: At this time, the password will be entered three times, and the password will be exactly the same for three times.

2) use cert2spc to generate a SPC issuer certificate (optional): cert2spc D: \ pos. Cer c: \ pos. SPC

3) double-click signcode. The signature wizard is started without parameters. Select the file to be signed first. Next, select "Custom ",

Next, select from file to add the newly generated pos. Cer certificate. Next, select the newly generated private key pos. PVK, and then click Next,

The SPC certificate can be used, and the next step is to continue. Add a timestamp and enter http: // timestamp.verisign.com/scripts/timstamp.dll testcab. Cab in the timestamp,

Next step.

In this way, the cab file is signed. However, when you click this file, the certificate becomes unavailable because the certificate is not forwarded.

File properties-> digital certificate-> details-> View Certificate-> install certificate, enter the certificate Installation Wizard, and select "Trusted Root Certificate Authority" in the storage area ", click Finish.

The idea is as shown above. If you do not understand it, you can check relevant information on the Internet. Hope to help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.