Sign PE file with certificate by programing

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   |    

56 comments:

IlLusioN said... June 27, 2009 at 11:21 AM  

Excellent, I was searching for this. Thanks a lot!!!

Anonymous said... October 5, 2009 at 5:42 PM  

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

Anonymous said... November 20, 2009 at 6:54 PM  

X2Net Signcode does the same thing, you just input your certificates, and select the exe to sign. Fast and simple and FREE.

Generic viagra said... March 11, 2011 at 8:43 PM  

hey guys that,s really amazing posts...

Generic Viagra said... May 10, 2011 at 4:22 PM  

Nice Post, I appreciate with you and your work. Thanks for sharing...

kamagra said... July 27, 2011 at 7:06 PM  

Hi there, nice information provided. thanks for that. keep posting of blogs in the future. thanks once again..

kamagra said... July 27, 2011 at 7:09 PM  

Hi there, nice information provided. thanks for that. keep posting of blogs in the future. thanks once again..

kamagra said... July 27, 2011 at 7:10 PM  

Hi there, nice information provided. thanks for that. keep posting of blogs in the future. thanks once again..

alprazolam no prescription said... August 20, 2011 at 6:32 PM  

This is really amazing blog post found here.... very interesting found.. Thanks very much for the share.... Great work! Keep it up...

spanish songs for kids said... September 22, 2011 at 4:43 AM  

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

Sandra Davis said... September 28, 2011 at 4:30 PM  

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

PMP Seattle said... October 1, 2011 at 6:27 AM  

I’ll keep these details that you have shared. It might be needed this flow in the future.

aso support said... October 6, 2011 at 10:33 AM  

Thanks for writing valuable post regarding the subject.
I’m a fan of your site. Keep up the great work.

Anonymous said... October 7, 2011 at 7:52 PM  

GOOD

viagra brand price said... October 12, 2011 at 1:01 AM  

Thanks mate... just dropped by. Will look for BIKE STN when we get to Seattle. Still in Buenos Airies.

toronto real estate listings said... October 22, 2011 at 6:22 PM  

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.

generic viagra said... October 25, 2011 at 1:39 PM  

Its really a great information. Keep posting.

credit repair agency said... November 14, 2011 at 7:05 PM  

PE stands for Portable Executable.

Anonymous said... December 3, 2011 at 4:21 PM  

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.

Anonymous said... December 3, 2011 at 4:25 PM  

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.

organic supplements said... December 29, 2011 at 2:28 PM  

There are some very great sources here and thank you for being so kind to post them here.

online pharmacy said... January 11, 2012 at 11:18 PM  

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.

dietas Barcelona said... January 16, 2012 at 1:45 PM  

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!

find doctors list said... January 16, 2012 at 3:06 PM  

I’m satisfied by the way you brought out ideas. Thanks for sharing.
doctor ratings and reviews

Hosting companies in india said... January 23, 2012 at 9:12 PM  

Glad to visit this professional blog... I would love to learn more and more about technical and programming related things.. Great work!

tubal reversal surgery said... January 25, 2012 at 1:59 PM  

The blog is written in such a way that it is so easy to read and understand.

jane silver said... February 17, 2012 at 10:20 PM  

Sweet, thanks for the code that really saves me a lot of time!! Cheers :)

Anil Kumar Pal said... February 24, 2012 at 9:27 PM  

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

Computer Support Services said... February 28, 2012 at 6:48 AM  

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.

Plumber said... March 2, 2012 at 1:33 PM  

Great code.So helping for me.

Buy Viagra said... March 19, 2012 at 7:53 PM  

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.

office 2010 said... March 27, 2012 at 5:03 PM  

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

andrew said... March 27, 2012 at 9:12 PM  

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

Econis LABS - Engineering Answers said... March 31, 2012 at 4:38 AM  

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!

PMPerfect said... April 5, 2012 at 9:23 AM  

Another interesting to learn for the day. Thank you for sharing the knowledge.

senior care TN said... May 5, 2012 at 1:43 AM  

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.

price per head service said... June 23, 2012 at 11:54 AM  

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!

Agen Ibcbet said... August 10, 2012 at 11:33 AM  

Dream patch this one

sbobet said... August 28, 2012 at 4:20 PM  

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!

creating template said... September 22, 2012 at 1:23 PM  

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

escorts barcelona said... October 29, 2012 at 9:37 PM  

Nice brief and this post helped me a lot in my college assignment. Say thank you you as your information.

Anonymous said... February 21, 2013 at 3:48 AM  

Really nice post

pmp training
pmp certification

Anonymous said... May 5, 2013 at 10:08 PM  

úùïèñîîîwow get movin

Pasaran Bola said... June 22, 2013 at 4:32 PM  

This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want...HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great! Bola Tangkas Tangkasnet

Yura Sama said... August 9, 2013 at 2:40 PM  

Nice...
kisstorel

Obat Sifilis Paling Manjur said... September 16, 2013 at 1:10 PM  

Terima kasih informasinya gan.

Obat Sipilis Ampuh
Obat Kencing Nanah
Obat Gonore Ampuh
Obat Raja Singa Ampuh
Obat Kutil Kelamin
Obat Wasir Ampuh
Obat Kondiloma Akuminata
Obat Klamidia Ampuh
Obat Herpes Genital Ampuh
Obat Bisul Kutil Kelamin
Obat Jengger Ayam Ampuh
Obat Kutil Kelamin

Akako said... October 16, 2013 at 11:49 AM  

getting the correct noise can be challenging for professional participants as a result of quantity linked to selections within people npselalu.com

Judi Online said... December 30, 2013 at 3:20 PM  

I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Sbobet

Minati Natalia said... March 27, 2014 at 12:34 PM  

thanks for the information, this is really very, interesting
Prediksi Bola | Judi Online | Agen Casino | Taruhan Bola
Casino Online | Agen Bola | Prediksi Dan Berita Sepakbola
Agen Bola Online | Bandar Bola | Agen Casino| Situs Judi
Agen Bola | Taruhan Bola Online | Agen Casino Terpercaya
Taruhan Bola | Judi Online | AgenCasino Terpercaya
Agen Bola Online, Situs Judi Casino Online, Bandar Taruhan Bola
Prediksi Akurat | Prediksi Bola | Berita Bola | Bursa Bola

Sbobet said... April 7, 2014 at 3:27 PM  

Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but other than that, this is great blog. A great read. Dewa Poker

Agen Bola said... April 7, 2014 at 3:38 PM  

I agree with you. This post is truly inspiring. I like your post and everything you share with us is current and very informative, I want to bookmark the page so I can return here from you that you have done a fantastic job. Agen Bola

y8y8 said... May 28, 2014 at 6:10 PM  

Your information helped me a lot at work. hope you have many more blog posts. friv 10

Torronto Pearson Aiport Taxi said... June 22, 2014 at 3:40 AM  

Thats great
Toronto Pearson Airport Taxi
Toronto Airport Taxi
Pearson Airport Taxi

Sagheer said... June 26, 2014 at 2:29 PM  

For More Lol pictures, funny pictures, funny comics, lol photos
lolsgag.blogspot.com

rezeki said... August 29, 2014 at 4:05 PM  

Great Sharing

I will try it


Rezekibet

Metamorfosis said... October 10, 2014 at 4:30 PM  

Pelatihan SDM is network marketing and training information or training an employee who has worked with many consulting firms and training institutions.
pendidikan dan pelatihan sdm,
pelatihan akuntansi,
sales marketing,
pelatihan di jogja,
lembaga pelatihan sdm,
manajemen bisnis,
pelatihan administrasi perkantoran,
administrasi kantor,
lembaga training motivasi,
pelatihan sekretaris,
pelatihan karyawan,
training jogja,
in house training,
pelatihan dan pengembangan sdm,
pelatihan manajemen sdm,
program training karyawan,
pelatihan dan pengembangan karyawan,
pelatihan sumber daya manusia,
training manajemen,
training sdm,
informasi training,
pusat pelatihan,
pelatihan rumah sakit,
_____
id card murah,
cara membuat id card,
membuat id card,
desain id card,
buat id card,
percetakan id card,
cetak id card,
cetak member card,

Post a Comment

Next previous home
 
Copyright 2009 deepxw | TCP-Z, Best TCP/IP Patch