Sign PE file with certificate by programing
Saturday, May 30, 2009
Someone needs this function, so I post it.
First, you need to creat a *.cer and *.pvk by makecert.exe.
#include
#pragma comment (lib, "Cryptui.lib")
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// Function: SignFile
//
// Purpose: Sign PE file with certificate. (*.pvk and *.cer)
//
// Arguments:
// pszExeFile [in] The PE file name.
// pszPvkFile [in] The private key file name. (*.pvk)
// pszCertFile [in] The certificate file name. (*.cer, *.spc)
//
// Returns:
// If success, return TURE.
//
// Notes:
//
// Last modified: 2009.01.20
BOOL SignFile(LPTSTR pszExeFile, LPTSTR pszPvkFile, LPTSTR pszCertFile)
{
CRYPTUI_WIZ_DIGITAL_SIGN_INFO signInfo;
CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO pvkInfo;
CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO pvkFileInfo;
BOOL bResult;
pvkFileInfo.dwSize = sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO);
pvkFileInfo.pwszPvkFileName = pszPvkFile;
pvkFileInfo.pwszProvName = NULL;
pvkFileInfo.dwProvType = PROV_RSA_FULL;
pvkInfo.dwSize = sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO);
pvkInfo.pwszSigningCertFileName = pszCertFile;
pvkInfo.dwPvkChoice = CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE;
pvkInfo.pPvkFileInfo = &pvkFileInfo;
signInfo.dwSize = sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_INFO);
signInfo.dwSubjectChoice = CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_FILE;
signInfo.pwszFileName = pszExeFile;
signInfo.dwSigningCertChoice = CRYPTUI_WIZ_DIGITAL_SIGN_PVK;
signInfo.pSigningCertPvkInfo = &pvkInfo;
signInfo.pwszTimestampURL = NULL;
signInfo.dwAdditionalCertChoice = CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN;
signInfo.pSignExtInfo = NULL;
bResult = CryptUIWizDigitalSign(CRYPTUI_WIZ_NO_UI, NULL, NULL, &signInfo, NULL);
return bResult;
} // SignFile()
Posted by deepxw at 00:15 |
Labels: Programing


Excellent, I was searching for this. Thanks a lot!!!
this is like this from cmd.exe && WDK? (sample for signing driver)
del /q vusbbus/*.cat
:makecert.exe -$ individual -r -pe -ss "Jes Certificate Store" -n CN="Jes" "Jes.cer"
inf2cat /driver:vusbbus /os:XP_X64,Vista_X64,7_X64 /v
signtool.exe sign /v /s "Jes Certificate Store" vusbbus\vusbbus.cat
signtool.exe sign /v /s "Jes Certificate Store" /n "Jes" /t http://timestamp.verisign.com/scripts/timestamp.dll vusbbus\vusbbus.sys
certmgr.exe -add Jes.cer -s -r localMachine root
certmgr.exe -add Jes.cer -s -r localMachine trustedpublisher
X2Net Signcode does the same thing, you just input your certificates, and select the exe to sign. Fast and simple and FREE.
hey guys that,s really amazing posts...
Nice Post, I appreciate with you and your work. Thanks for sharing...
Hi there, nice information provided. thanks for that. keep posting of blogs in the future. thanks once again..
Hi there, nice information provided. thanks for that. keep posting of blogs in the future. thanks once again..
Hi there, nice information provided. thanks for that. keep posting of blogs in the future. thanks once again..
This is really amazing blog post found here.... very interesting found.. Thanks very much for the share.... Great work! Keep it up...
The article in your blog reminds me some old memory .That is good .It gives me happy .I think we will have a harmonious talk.Do you agree?
learning spanish for kids
english to spanish for kids
learn spanish for kids
learn spanish on dvd
spanish songs for kids
Thanks for taking the time to discuss this, I feel strongly about information and love learning more on this. If possible, as you gain expertise, It is extremely helpful for me. would you mind updating your blog with more information.
Generic Levitra
I’ll keep these details that you have shared. It might be needed this flow in the future.
Thanks for writing valuable post regarding the subject.
I’m a fan of your site. Keep up the great work.
GOOD
Thanks mate... just dropped by. Will look for BIKE STN when we get to Seattle. Still in Buenos Airies.
great, I've been looking for this information for a couple of an hour and I am so glad that you posted this information in this site.
Its really a great information. Keep posting.
PE stands for Portable Executable.
cheap goose jackets online sale Denmark Canada, UK,
goose trillium parka jackets online sale Denmark Canada, UK,
Canada goose freestyle vest online sale Denmark Canada, UK,
Canada Goose Chilliwack Bomber sale online sale Denmark Canada, UK,
Canada Goose Mens Citadel jackets online sale Denmark Canada, UK,
cheap Goose Expedition Parka coats online sale Denmark Canada, UK,
canada goose snow mantra parka online sale Denmark Canada, UK,
Canada Goose Yorkville Parka Jackets online sale Denmark Canada, UK,
womens Goose Chilliwack Parka online sale Denmark Canada, UK,
womens Goose Expedition Parka online sale Denmark Canada, UK,
womens Goose Kensington Parka Jackets online sale Denmark Canada, UK,
womens Goose Montebello Parka jackets online sale Denmark Canada, UK,
Canada Goose Womens Solaris Parka online sale Denmark Canada, UK.
cheap goose jackets online sale Denmark Canada, UK,
goose trillium parka jackets online sale Denmark Canada, UK,
Canada goose freestyle vest online sale Denmark Canada, UK,
Canada Goose Chilliwack Bomber sale online sale Denmark Canada, UK,
Canada Goose Mens Citadel jackets online sale Denmark Canada, UK,
cheap Goose Expedition Parka coats online sale Denmark Canada, UK,
canada goose snow mantra parka online sale Denmark Canada, UK,
Canada Goose Yorkville Parka Jackets online sale Denmark Canada, UK,
womens Goose Chilliwack Parka online sale Denmark Canada, UK,
womens Goose Expedition Parka online sale Denmark Canada, UK,
womens Goose Kensington Parka Jackets online sale Denmark Canada, UK,
womens Goose Montebello Parka jackets online sale Denmark Canada, UK,
Canada Goose Womens Solaris Parka online sale Denmark Canada, UK.
There are some very great sources here and thank you for being so kind to post them here.
a real important information, specially for those who wants to apply this in some work, or well in a project, in my case if for my final project, I have to presented the next week, and this is the final point in that work.
Nice site! Me gusta un par de de los artículos que se han escrito, publicado y, en particular los comentarios! Definitivamente voy a visitar de nuevo!
I’m satisfied by the way you brought out ideas. Thanks for sharing.
doctor ratings and reviews
Glad to visit this professional blog... I would love to learn more and more about technical and programming related things.. Great work!
The blog is written in such a way that it is so easy to read and understand.
Sweet, thanks for the code that really saves me a lot of time!! Cheers :)
Intersting and beautiful blog lovely presentation thanks for sharing your views...microsoft windows vista We24support tech team are available 24/7 for repairs on computers, printers, laptops, desktops. Our tech team taken to new heights with our technician’s knowledge and support.at 1-866-978-0799 Microsoft Windows Vista support
I am following your blog regularly and got great information. I really like the tips you have given. Thanks a lot for sharing. Will be referring a lot of friends about this.
Great code.So helping for me.
Hmm..seems like you do have a great knowledge about blog engine. And i do love your themes here. Great looking site plus it carries huge information.
http://wise.com.vn/forum/member.php?u=3139
http://derangedgaming.comze.com/forum/index.php?action=profile;u=2695
http://www.eurseree.co.th/webboard/index.php?action=profile;u=12695
http://forum.healthncaretips.com/index.php?action=profile;u=231
http://www.refclix.com/forum/index.php?action=profile;u=198382
http://vb.hno-cam.com/member.php?u=193833
http://www.belukar.com/member.php?u=3429
http://directionalgaming.net/index.php?action=profile;u=27557
http://www.alafaq-jo.org/VB/member.php?u=9562
http://forum.smarthyipers.com/index.php?action=profile;u=27237
http://die-nachrichten.at/forum/member.php?u=4531
http://ttsunv.com/petro/index.php?action=profile;u=25
http://www.lukasene.com/member.php?u=718
http://decoway.com/forum/index.php?action=profile;u=391
http://tunisia-news.fr/vb/member.php?u=12890
http://everydaygamers.co.cc/member.php?u=386
http://browshapingnyc.com/forum/index.php?action=profile;u=2435
http://readersshelf.com/forum/index.php?action=profile;u=24365
http://pabstblueribbon.homeip.net/forum/index.php?action=profile;u=83142
http://108futurecars.com/108board/index.php?action=profile;u=53348
http://kchme.com/Smf/index.php?action=profile;u=129879
http://forums.fadedcloud.com/index.php?action=profile;u=264
http://www.lifelendava.si/forum/index.php?action=profile;u=53023
Very nice post and helpful too. I have been looking around for this for some time now and feel happy to get this here.
andy
website - www.creditrestoreusa.com
Wow great post very informative, all i can add is if you would like to read more on the subject of Engineering Services and Solutions you should visit this location! Hope it is helpful!
Another interesting to learn for the day. Thank you for sharing the knowledge.
Over 80% of seniors suggest they want to remain in their own homes.Beginning in 2011, over 8,000 people very day will turn 85.We have learned that even the little things that make our senior living communities feel like home can make a big difference in the lives of seniors.
I would really admire the work and efforts you did to make this blog wonderful and spectacular thanks keep post I wanted to write a quick note to express my thanks. I'm really impressed by a blog unique and perfectly chosen and organized!
Dream patch this one
My wife and i were really glad Raymond managed to finish off his research through the entire ideas he made when using the web page. It's not at all simplistic to just find yourself giving freely instructions many others might have been trying to sell. We figure out we need the website owner to thank for that. The illustrations you've made, the simple web site menu, the relationships your site aid to promote - it is many extraordinary, and it is letting our son and the family recognize that this situation is interesting, which is exceptionally essential. Thank you for the whole lot!
I am very interesting with this post
thanks friend
Daftar Situs Penyedia Template Blogger Gratis Yang SEO Friendly
Cara Mengganti Template di Blogspot Versi Terbaru
Cara Mengedit Template Blogspot
Cara Mengedit Template Blog Agar Seo Friendly
Cara Mengedit Template Blog Agar Seo Friendly
Cara Membuat / Memasang Menu Navigasi Breadcrumbs Terindex Google
Cara Memasang / Menampilkan Author Blog di Google SERP
Cara membuat Drop Cap / Huruf Besar di Posting Blogger
Cara Membuat / Memasang Daftar Isi / Sitemap Blog Otomatis
Cara Membuat / Memasang Rating Bintang Rich Snippet Google di Blogger
Cara Membuat Artikel Terkait / Related Post di Blog
Html Color Codes / Kode Warna Html
Nice brief and this post helped me a lot in my college assignment. Say thank you you as your information.
Really nice post
pmp training
pmp certification
úùïèñîîîwow get movin